@openchamber/web 1.13.4 → 1.13.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cli-output.js +2 -0
- package/bin/cli-output.test.js +36 -0
- package/bin/cli.test.js +12 -0
- package/bin/lib/cli-http.js +1 -0
- package/bin/lib/cli-network.js +1 -0
- package/bin/lib/cli-paths.js +2 -0
- package/bin/lib/commands-tunnel.js +6 -2
- package/dist/assets/{DiagramView-BAoYIAGR.js → DiagramView-Bbj-QI7h.js} +1 -1
- package/dist/assets/{MarkdownRendererImpl-B0NE4mIY.js → MarkdownRendererImpl-BNr_9Jsb.js} +1 -1
- package/dist/assets/{MultiRunWindow-BT4kt6aB.js → MultiRunWindow-DMMu53kw.js} +1 -1
- package/dist/assets/{NewWorktreeDialog-Bx-zQyBp.js → NewWorktreeDialog-5TYBoMMA.js} +1 -1
- package/dist/assets/{OnboardingScreen-CbJOPUxm.js → OnboardingScreen-BucKVBD7.js} +1 -1
- package/dist/assets/{SessionSwitcherDropdown-BbUzUNEi.js → SessionSwitcherDropdown-B6kvduse.js} +1 -1
- package/dist/assets/{SettingsWindow-CSb8eo8p.js → SettingsWindow-BEfDro9b.js} +1 -1
- package/dist/assets/{TerminalView-ME5MOz7S.js → TerminalView-CMdqMpTy.js} +1 -1
- package/dist/assets/{main-fsOGbLGZ.js → main-DOdUrt3s.js} +3 -3
- package/dist/assets/{main-D6eC2bnV.js → main-KEVf2Yak.js} +2 -2
- package/dist/assets/{miniChat-DKGU29GZ.js → miniChat-Nlzqr3Df.js} +2 -2
- package/dist/assets/{mobile-YHQHMYWC.js → mobile-BIhOFhia.js} +2 -2
- package/dist/assets/{renderElectronMiniChatApp-3vxeddJO.js → renderElectronMiniChatApp-Cb1iUq8M.js} +2 -2
- package/dist/assets/{renderMobileApp-BrvLHYCY.js → renderMobileApp-7chEBHPK.js} +3 -3
- package/dist/assets/{useAppFontEffects-b7bqtGFf.js → useAppFontEffects-Bd0ks39c.js} +3 -3
- package/dist/index.html +1 -1
- package/dist/mini-chat.html +1 -1
- package/dist/mobile.html +1 -1
- package/package.json +1 -1
- package/server/lib/git/routes.test.js +4 -4
- package/server/lib/github/routes.js +1 -0
- package/server/lib/package-manager.js +1 -1
- package/server/lib/package-manager.test.js +8 -1
- package/server/lib/quota/providers/google/index.js +14 -6
- package/server/lib/quota/providers/index.js +3 -3
- package/server/lib/quota/providers/index.test.js +17 -0
- package/server/lib/tunnels/providers/ngrok.js +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TerminalView-
|
|
2
|
-
import{j as s,e as mt,a as ro,R as i,d as Pf,p as cc,b as Tf,H as Xe,I as Rf,u as ga,l as yo,n as xa,D as ba,q as ya,S as Bl,v as Vl,w as dc,C as uc,L as _l,N as Mh,O as Fh,T as Lh,W as Oh,X as ni,Y as Bh,$ as Vh,F as _h,a0 as $h,a1 as zh,a2 as Wh,a3 as Ef,a4 as Uh,a5 as Hh,a6 as $l,a7 as Gh,s as Kh,m as qh,a8 as dd,a9 as ud,aa as fd,ab as Yh,ac as Qh,ad as Jh,ae as Xh,af as Zh,ag as ep,_ as io,ah as md,ai as hd,aj as pd,G as tp}from"./vendor-.bun-By2L9XvG.js";import{f as fc,h as dr,j as Ji,k as gd,l as sp,m as wa,n as Mf,p as np,e as As,q as Lo,b as Ee,t as rp,v as Fa,w as Gr,a as Wr,x as Ur,y as zl,z as ip,A as op,R as xd,B as bd,u as Js,C as ap,D as Ni,E as Ff,F as Lf,G as mc,o as Vn,H as lp,g as Ci,I as cp,r as hc,J as dp,K as pc,L as Of,M as up,N as fp,O as na,P as ra,Q as mp,S as hp,T as pp,U as yd,V as wd,W as vd,X as jd,Y as gp,Z as xp,_ as Sd,d as Nd,$ as bp,a0 as yp,a1 as wp,i as vp,s as jp}from"./index-BsXkdBYx.js";import{u as Nt,m as Pe,ao as bs,I as D,p as ur,t as ce,ap as en,aq as Rr,ar as tn,as as sn,a as Jn,at as Er,au as Ii,av as kd,aw as Et,ax as Mt,ay as Ft,az as Sp,ac as Do,aA as va,aB as ri,ad as Io,ae as Bf,a5 as gc,aC as Vf,aD as Np,Q as ss,z as ut,aE as kp,a7 as _f,y as vr,x as xc,D as ws,R as Pi,aF as $f,aG as zf,aH as ja,aI as Wf,aJ as Uf,aK as Hf,aL as Gf,aM as Cp,aN as Ap,T as bc,aO as La,aP as ii,aQ as yc,aR as ia,X as Zs,aS as Dp,aT as Kf,aU as Ip,aV as qf,aW as wc,aX as Hs,aY as Us,B as $e,aZ as _s,a_ as $s,a$ as ci,b0 as Pp,b1 as Tp,b2 as zo,b3 as Tn,b4 as Yf,b5 as Qf,a2 as vc,b6 as Rp,b7 as Cd,b8 as Ad,b9 as ki,n as vn,ba as Ti,bb as Xi,bc as Ep,bd as Mp,be as Fp,bf as Lp,bg as Oa,bh as Ba,bi as Va,bj as _a,bk as oi,bl as li,bm as Op,bn as Bp,bo as on,bp as Vp,bq as _p,br as $p,bs as zp,bt as Wp,k as Ai,bu as jc,bv as Up,bw as Hp,bx as Gp,by as Kp,bz as qp,bA as Yp,bB as Qp,bC as _n,bD as $n,bE as zn,bF as Nn,bG as Wn,bH as Ls,bI as Jp,w as Po,M as $a,S as za,bJ as Xp,bK as ir,bL as Zp,b as di,d as Sc,c as Wa,bM as eg,bN as Jf,bO as tg,bP as sg,e as Nc,bQ as ng,f as wn,bR as Ua,a3 as Pr,j as rg,bS as ig,bT as rl,bU as og,bV as ag,F as Hr,bW as kc,bX as Ha,bY as fn,bZ as Ri,l as Zi,b_ as Xf,b$ as lg,c0 as cg,c1 as dg,c2 as Dd,c3 as ug,q as Kr,r as Id,v as Pd,c4 as Td,c5 as Zf,c6 as Rd,c7 as Ed,c8 as em,c9 as fg,ca as tm,o as Md,J as mg,cb as il,cc as Cc,cd as hg,ce as pg,cf as gg,cg as Oo,ch as xg,ci as Ac,cj as bg,ck as Dc,cl as sm,cm as Wo,cn as yg,co as Tr,cp as wg,cq as nm,cr as vg,cs as jg,ct as Fd,cu as rm,cv as im,cw as om,E as Ic,P as Ga,G as Ka,L as Sa,cx as Na,cy as Ln,H as Sg,K as Ng,cz as kg,cA as Wl,cB as Cg,cC as Ag,cD as Dg,cE as Ld,cF as Ig,cG as Pg,cH as Tg,cI as Pc,cJ as am,cK as Rg,cL as Eg,cM as Mg,cN as Fg,cO as Od,cP as Bd,cQ as Lg,cR as Og,cS as Bg,cT as Vg,cU as _g,cV as $g,N as zg,cW as Vd,cX as Wg,cY as lm,O as Ug,cZ as Hg,A as Gg,C as Kg,c_ as qg,c$ as Yg,d0 as Qg,d1 as Jg,d2 as Xg,d3 as Zg,d4 as ex,d5 as tx,d6 as sx,d7 as ka,d8 as nx,d9 as _d,da as rx,db as ix,dc as ox,dd as oo,de as ax,df as $d,dg as lx,dh as cx,di as dx,dj as ux,dk as cm,dl as dm,dm as fx,dn as mx,dp as hx,dq as oa,a9 as px,dr as gx,ds as ol,dt as xx,du as bx,U as yx,V as wx,W as vx,Y as zd,Z as Wd,_ as Ud,dv as jx,$ as um,a0 as fm,dw as Sx,aj as Nx,ak as kx,al as Cx,am as Ax,an as Dx,af as Ix,ag as Px,ah as Tx,ai as Rx}from"./useAppFontEffects-b7bqtGFf.js";import{I as Hd,o as Ex,p as Gd,q as Mx,r as Kd,t as Jr,s as Fx,v as al,w as To,U as Ca,x as Aa,y as eo,z as Bo,B as to,k as mm,M as hm,i as mn,j as Lx,Q as pm,E as Ox,F as Bx,G as Vx,l as Ul,H as gm,P as xm,J as _x,K as $x,C as zx,a as Wx,L as Tc,R as bm,T as Rc,V as Ec,W as Mc,X as ym,Y as wm,Z as Hl,_ as vm,$ as Gl,a0 as aa,a1 as Ux,a2 as Hx,e as wo,N as Gx,D as Kx,u as qx,n as Yx,m as Kl,a3 as Qx,a4 as Jx,g as Xx,a5 as Zx,a6 as eb,c as tb,O as jm,d as sb,a7 as nb}from"./NewWorktreeDialog-Bx-zQyBp.js";import{S as rb,C as ib,W as ob,g as Fc,r as ab,n as cs,i as Ro,d as so,c as Gi,a as qd,b as lb,e as vo,f as Sm,h as cb,j as db,u as ll}from"./SessionSwitcherDropdown-BbUzUNEi.js";function Nm(t){const{drafts:e,editingDraftId:n,commentText:r,onTextChange:o,selection:a,isDragging:c,fileLabel:l,newWidgetId:d,mapDraftToRange:u,onSave:m,onCancel:f,onEdit:g,onDelete:b}=t,p=[];for(const x of e){const y=u(x);if(x.id===n){p.push({afterLine:y.end,id:`edit-${x.id}`,content:s.jsx(Hd,{initialText:r,onTextChange:o,fileLabel:l,lineRange:y,isEditing:!0,onSave:m,onCancel:f},`edit-${x.id}`)});continue}p.push({afterLine:y.end,id:`card-${x.id}`,content:s.jsx(Ex,{draft:x,onEdit:()=>g(x),onDelete:()=>b(x)},`card-${x.id}`)})}if(a&&!n&&!c){const x={...a,start:Math.min(a.start,a.end),end:Math.max(a.start,a.end)};p.push({afterLine:x.end,id:d,content:s.jsx(Hd,{initialText:r,onTextChange:o,fileLabel:l,lineRange:x,isEditing:!1,onSave:m,onCancel:f},d)})}return p}function Yd(t){const e=mt.c(14);let n,r,o,a;e[0]!==t?({size:o,className:n,style:a,...r}=t,e[0]=t,e[1]=n,e[2]=r,e[3]=o,e[4]=a):(n=e[1],r=e[2],o=e[3],a=e[4]);const c=typeof o=="number"?`${o}px`:o,l=typeof o=="number"?`${o}px`:o;let d;e[5]!==a||e[6]!==c||e[7]!==l?(d={width:c,height:l,...a},e[5]=a,e[6]=c,e[7]=l,e[8]=d):d=e[8];let u;e[9]===Symbol.for("react.memo_cache_sentinel")?(u=s.jsx("path",{d:"M112,148a12,12,0,0,0-12,12v19L69.17,148.2A4,4,0,0,1,68,145.37V97.94a36,36,0,1,0-24,0v47.43a27.81,27.81,0,0,0,8.2,19.8L83,196H64a12,12,0,0,0,0,24h48a12,12,0,0,0,12-12V160A12,12,0,0,0,112,148ZM56,52A12,12,0,1,1,44,64,12,12,0,0,1,56,52ZM212,158.06V110.63a27.81,27.81,0,0,0-8.2-19.8L173,60h19a12,12,0,0,0,0-24H144a12,12,0,0,0-12,12V96a12,12,0,0,0,24,0V77l30.83,30.83a4,4,0,0,1,1.17,2.83v47.43a36,36,0,1,0,24,0ZM200,204a12,12,0,1,1,12-12A12,12,0,0,1,200,204Z"}),e[9]=u):u=e[9];let m;return e[10]!==n||e[11]!==r||e[12]!==d?(m=s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 256 256",fill:"currentColor",className:n,style:d,...r,children:u}),e[10]=n,e[11]=r,e[12]=d,e[13]=m):m=e[13],m}const ai=[{id:"finder",label:"Finder",appName:"Finder"},{id:"terminal",label:"Terminal",appName:"Terminal"},{id:"iterm2",label:"iTerm2",appName:"iTerm"},{id:"ghostty",label:"Ghostty",appName:"Ghostty"},{id:"vscode",label:"VS Code",appName:"Visual Studio Code"},{id:"intellij",label:"IntelliJ",appName:"IntelliJ IDEA"},{id:"visual-studio",label:"Visual Studio",appName:"Visual Studio"},{id:"cursor",label:"Cursor",appName:"Cursor"},{id:"android-studio",label:"Android Studio",appName:"Android Studio"},{id:"pycharm",label:"PyCharm",appName:"PyCharm"},{id:"xcode",label:"Xcode",appName:"Xcode"},{id:"sublime-text",label:"Sublime",appName:"Sublime Text"},{id:"webstorm",label:"WebStorm",appName:"WebStorm"},{id:"rider",label:"Rider",appName:"Rider"},{id:"zed",label:"Zed",appName:"Zed"},{id:"phpstorm",label:"PhpStorm",appName:"PhpStorm"},{id:"eclipse",label:"Eclipse",appName:"Eclipse"},{id:"windsurf",label:"Windsurf",appName:"Windsurf"},{id:"vscodium",label:"VSCodium",appName:"VSCodium"},{id:"rustrover",label:"RustRover",appName:"RustRover"},{id:"kiro",label:"Kiro",appName:"Kiro"},{id:"antigravity",label:"Antigravity",appName:"Antigravity"},{id:"trae",label:"Trae",appName:"Trae"}],ql="finder",Yl=new Set(["finder","terminal"]),Lc=t=>typeof window<"u"&&window.__OPENCHAMBER_PLATFORM__==="win32"&&t.id==="finder"?{...t,label:"Explorer",appName:"File Explorer"}:t,Ql=t=>{if(!t)return null;const e=ai.find(n=>n.id===t)??null;return e?Lc(e):null},cl=()=>ai.filter(t=>Yl.has(t.id)).map(t=>({...Lc(t)})),ub=()=>{if(typeof window>"u")return ql;const t=window.localStorage.getItem("openInAppId");return t&&Ql(t)?t:ql};let dl=!1,Vi=!1,Xr=!1,Zr=0,jo=null;const Qd=()=>{jo&&(clearTimeout(jo),jo=null)},yr=ro()((t,e)=>({selectedAppId:ub(),availableApps:cl(),hasLoadedApps:!1,isCacheStale:!1,isScanning:!1,initialize:()=>{if(dl||typeof window>"u")return;dl=!0;const n=(d,u=!0)=>{if(!Array.isArray(d)||d.length===0){t({availableApps:cl(),hasLoadedApps:u});return}const m=new Set(d.map(p=>p.name)),f=new Map(d.map(p=>[p.name,p.iconDataUrl??void 0])),b=ai.filter(p=>m.has(p.appName)||Yl.has(p.id)).map(p=>({...Lc(p),iconDataUrl:f.get(p.appName)}));t({availableApps:b,hasLoadedApps:!0})},r=async d=>{if(!dr()||!Ji()||Vi||e().hasLoadedApps&&!d)return;const m=ai.map(f=>f.appName);Qd(),Vi=!0,Xr=!1,t({isScanning:!0});try{const{apps:f,success:g,hasCache:b,isCacheStale:p}=await gd(m,d),x=g&&!b&&f.length===0&&Zr<3;if(t({isCacheStale:b?p:!1}),n(f,g?!x:!1),g){if(x){const h=[800,1600,3200][Zr]??3200;Zr+=1,Xr=!0,jo=setTimeout(()=>{r()},h);return}Zr=0,Xr=!1;return}if(Zr<3){const h=[1e3,3e3,7e3][Zr]??7e3;Zr+=1,Xr=!0,jo=setTimeout(()=>{r()},h)}}finally{Vi=!1,Xr||t({isScanning:!1})}};r();const o=d=>{const u=d.detail,m=u&&typeof u.openInAppId=="string"&&u.openInAppId.length>0&&Ql(u.openInAppId)?u.openInAppId:null;m&&(window.localStorage.setItem("openInAppId",m),t({selectedAppId:m}))},a=()=>{r()},c=d=>{const u=d.detail;Array.isArray(u)&&(Zr=3,Xr=!1,t({isScanning:!1,isCacheStale:!1}),n(u))};window.addEventListener("openchamber:settings-synced",o),window.addEventListener("openchamber:app-ready",a),window.addEventListener("openchamber:installed-apps-updated",c),window.__openchamberAppReady&&r(),window.setTimeout(()=>{e().hasLoadedApps||r()},5e3)},loadInstalledApps:async n=>{if(dl||e().initialize(),!dr()||!Ji()||Vi||e().hasLoadedApps&&!n)return;const o=ai.map(a=>a.appName);Qd(),n&&t({hasLoadedApps:!1}),Vi=!0,Xr=!1,t({isScanning:!0});try{const{apps:a,hasCache:c,isCacheStale:l}=await gd(o,n),d=new Set(a.map(g=>g.name)),u=new Map(a.map(g=>[g.name,g.iconDataUrl??void 0])),f=ai.filter(g=>d.has(g.appName)||Yl.has(g.id)).map(g=>({...g,iconDataUrl:u.get(g.appName)}));t({availableApps:f.length>0?f:cl(),hasLoadedApps:f.length>0,isCacheStale:c?l:!1})}finally{Vi=!1,Xr||t({isScanning:!1})}},selectApp:async n=>{Ql(n)&&(t({selectedAppId:n}),typeof window<"u"&&window.localStorage.setItem("openInAppId",n),await fc({openInAppId:n}))}})),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",ul=t=>({...t,fallbackIconDataUrl:t.id==="finder"&&window.__OPENCHAMBER_PLATFORM__!=="win32"?fb:t.id==="terminal"?mb:void 0}),Jd=t=>{const e=mt.c(8),{label:n,iconDataUrl:r,fallbackIconDataUrl:o}=t,[a,c]=i.useState(!1);let l;e[0]!==n?(l=n.trim().slice(0,1).toUpperCase()||"?",e[0]=n,e[1]=l):l=e[1];const d=l,u=r||o;if(u&&!a){let g;e[2]===Symbol.for("react.memo_cache_sentinel")?(g=()=>c(!0),e[2]=g):g=e[2];let b;return e[3]!==u?(b=s.jsx("img",{src:u,alt:"",className:"h-4 w-4 rounded-sm",onError:g}),e[3]=u,e[4]=b):b=e[4],b}let m;e[5]===Symbol.for("react.memo_cache_sentinel")?(m=Pe("h-4 w-4 rounded-sm flex items-center justify-center","bg-[var(--surface-muted)] text-[9px] font-medium text-muted-foreground"),e[5]=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=mt.c(75),{directory:n,className:r}=t,{t:o}=Nt(),a=yr(pb),c=yr(gb),l=yr(xb),d=yr(bb),u=yr(yb),m=yr(wb),f=yr(vb);let g,b;e[0]!==u?(g=()=>{u()},b=[u],e[0]=u,e[1]=g,e[2]=b):(g=e[1],b=e[2]),i.useEffect(g,b);const p=dr()&&Ji();let x;e:{let ke;e[3]!==c||e[4]!==a?(ke=c.find(F=>F.id===a)??c.find(jb)??c[0]??ai[0],e[3]=c,e[4]=a,e[5]=ke):ke=e[5];const Q=ke;if(Q){let F;e[6]!==Q?(F=ul(Q),e[6]=Q,e[7]=F):F=e[7],x=F;break e}let ge;e[8]===Symbol.for("react.memo_cache_sentinel")?(ge=ul(ai[0]),e[8]=ge):ge=e[8],x=ge}const y=x;if(!p||!n||c.length===0)return null;let h;e[9]!==n?(h=async ke=>{await sp(n,ke.id,ke.appName)||await wa(n,ke.appName)},e[9]=n,e[10]=h):h=e[10];const C=h;let w;e[11]!==C||e[12]!==f?(w=async ke=>{await f(ke.id),await C(ke)},e[11]=C,e[12]=f,e[13]=w):w=e[13];const S=w;let j;e[14]!==n||e[15]!==o?(j=async()=>{(await ur(n)).ok&&ce.success(o("openInApp.toast.pathCopied"))},e[14]=n,e[15]=o,e[16]=j):j=e[16];const k=j;let v;e[17]!==r?(v=Pe("app-region-no-drag inline-flex h-7 items-center self-center rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px]","bg-[var(--surface-elevated)] overflow-hidden","border border-border/60",r),e[17]=r,e[18]=v):v=e[18];let A;e[19]!==C||e[20]!==y?(A=()=>{C(y)},e[19]=C,e[20]=y,e[21]=A):A=e[21];const I=d&&"animate-pulse";let N;e[22]!==I?(N=Pe("inline-flex h-full items-center px-2.5 typography-ui-label font-medium","text-foreground hover:bg-interactive-hover transition-colors",I),e[22]=I,e[23]=N):N=e[23];let O;e[24]!==y.label||e[25]!==o?(O=o("openInApp.actions.openInAria",{app:y.label}),e[24]=y.label,e[25]=o,e[26]=O):O=e[26];let P;e[27]!==y.fallbackIconDataUrl||e[28]!==y.iconDataUrl||e[29]!==y.label?(P=s.jsx(Jd,{label:y.label,iconDataUrl:y.iconDataUrl,fallbackIconDataUrl:y.fallbackIconDataUrl}),e[27]=y.fallbackIconDataUrl,e[28]=y.iconDataUrl,e[29]=y.label,e[30]=P):P=e[30];let T;e[31]!==N||e[32]!==O||e[33]!==P||e[34]!==A?(T=s.jsx("button",{type:"button",onClick:A,className:N,"aria-label":O,children:P}),e[31]=N,e[32]=O,e[33]=P,e[34]=A,e[35]=T):T=e[35];let L;e[36]===Symbol.for("react.memo_cache_sentinel")?(L=Pe("inline-flex h-full w-7 items-center justify-center","border-l border-[var(--interactive-border)] text-muted-foreground","hover:bg-interactive-hover hover:text-foreground transition-colors"),e[36]=L):L=e[36];let R;e[37]!==o?(R=o("openInApp.actions.chooseAppAria"),e[37]=o,e[38]=R):R=e[38];let B;e[39]===Symbol.for("react.memo_cache_sentinel")?(B=s.jsx(D,{name:"arrow-down-s",className:"h-4 w-4"}),e[39]=B):B=e[39];let V;e[40]!==R?(V=s.jsx(en,{asChild:!0,children:s.jsx("button",{type:"button",className:L,"aria-label":R,children:B})}),e[40]=R,e[41]=V):V=e[41];let _;e[42]!==k?(_=()=>{k()},e[42]=k,e[43]=_):_=e[43];let E;e[44]===Symbol.for("react.memo_cache_sentinel")?(E=s.jsx(D,{name:"file-copy",className:"h-4 w-4"}),e[44]=E):E=e[44];let Z;e[45]!==o?(Z=o("openInApp.actions.copyPath"),e[45]=o,e[46]=Z):Z=e[46];let ne;e[47]!==Z?(ne=s.jsx("span",{className:"typography-ui-label text-foreground",children:Z}),e[47]=Z,e[48]=ne):ne=e[48];let Y;e[49]!==_||e[50]!==ne?(Y=s.jsxs(bs,{className:"flex items-center gap-2",onClick:_,children:[E,ne]}),e[49]=_,e[50]=ne,e[51]=Y):Y=e[51];let H;e[52]===Symbol.for("react.memo_cache_sentinel")?(H=s.jsx(Rr,{}),e[52]=H):H=e[52];let re;if(e[53]!==c||e[54]!==S||e[55]!==y.id){let ke;e[57]!==S||e[58]!==y.id?(ke=Q=>{const ge=ul(Q);return s.jsxs(bs,{className:"flex items-center gap-2",onClick:()=>{S(Q)},children:[s.jsx(Jd,{label:Q.label,iconDataUrl:Q.iconDataUrl,fallbackIconDataUrl:ge.fallbackIconDataUrl}),s.jsx("span",{className:"typography-ui-label text-foreground",children:Q.label}),y.id===Q.id?s.jsx(D,{name:"check",className:"ml-auto h-4 w-4 text-primary"}):null]},Q.id)},e[57]=S,e[58]=y.id,e[59]=ke):ke=e[59],re=c.map(ke),e[53]=c,e[54]=S,e[55]=y.id,e[56]=re}else re=e[56];let ae;e[60]!==l||e[61]!==m||e[62]!==o?(ae=l?s.jsxs(bs,{className:"flex items-center gap-2",onClick:()=>{m(!0)},children:[s.jsx(D,{name:"refresh",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:o("openInApp.actions.refreshApps")})]}):null,e[60]=l,e[61]=m,e[62]=o,e[63]=ae):ae=e[63];let me;e[64]!==Y||e[65]!==re||e[66]!==ae?(me=s.jsxs(tn,{align:"end",className:"w-56 max-h-[70vh] overflow-y-auto",children:[Y,H,re,ae]}),e[64]=Y,e[65]=re,e[66]=ae,e[67]=me):me=e[67];let Se;e[68]!==V||e[69]!==me?(Se=s.jsxs(sn,{children:[V,me]}),e[68]=V,e[69]=me,e[70]=Se):Se=e[70];let te;return e[71]!==T||e[72]!==Se||e[73]!==v?(te=s.jsxs("div",{className:v,children:[T,Se]}),e[71]=T,e[72]=Se,e[73]=v,e[74]=te):te=e[74],te};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 jb(t){return t.id===ql}const Sb=1e6,Nb="terminal-store";let Xd=!1;const fl=t=>typeof t=="object"&&t!==null,kb=t=>{const e=/^tab-(\d+)$/.exec(t);if(!e)return null;const n=Number(e[1]);return Number.isFinite(n)?n:null};function Dn(t){let e=t.trim();for(;e.length>1&&e.endsWith("/");)e=e.slice(0,-1);return e}const ml=(t,e)=>({id:t,terminalSessionId:null,lifecycle:"idle",label:e,iconKey:null,bufferChunks:[],bufferLength:0,isConnecting:!1,createdAt:Date.now(),previewUrl:null,previewAutoOpened:!1,previewUrlLocked:!1}),hl=t=>({tabs:[t],activeTabId:t.id}),xr=(t,e)=>t.tabs.findIndex(n=>n.id===e),Vs=ro()(Pf(cc((t,e)=>({sessions:new Map,projectActionRuns:{},nextChunkId:1,nextTabId:1,hasHydrated:typeof window>"u",ensureDirectory:n=>{const r=Dn(n);r&&t(o=>{if(o.sessions.has(r))return o;const a=new Map(o.sessions),c=`tab-${o.nextTabId}`,l=ml(c,"Terminal");return a.set(r,hl(l)),{sessions:a,nextTabId:o.nextTabId+1}})},getDirectoryState:n=>{const r=Dn(n);return e().sessions.get(r)},getActiveTab:n=>{const r=Dn(n),o=e().sessions.get(r);if(!o)return;const a=o.activeTabId;return a?o.tabs.find(c=>c.id===a)??o.tabs[0]:o.tabs[0]},createTab:n=>{const r=Dn(n);if(!r)return"tab-invalid";const o=`tab-${e().nextTabId}`;return t(a=>{const c=new Map(a.sessions),l=c.get(r),d=a.nextTabId+1,m=`Terminal ${(l?.tabs.length??0)+1}`,f=ml(o,m);return l?c.set(r,{...l,tabs:[...l.tabs,f]}):c.set(r,hl(f)),{sessions:c,nextTabId:d}}),o},setActiveTab:(n,r)=>{const o=Dn(n);t(a=>{const c=new Map(a.sessions),l=c.get(o);return!l||l.activeTabId===r||xr(l,r)<0?a:(c.set(o,{...l,activeTabId:r}),{sessions:c})})},setTabLabel:(n,r,o)=>{const a=Dn(n),c=o.trim();c&&t(l=>{const d=new Map(l.sessions),u=d.get(a);if(!u)return l;const m=xr(u,r);if(m<0||u.tabs[m]?.label===c)return l;const f=[...u.tabs];return f[m]={...f[m],label:c},d.set(a,{...u,tabs:f}),{sessions:d}})},setTabIconKey:(n,r,o)=>{const a=Dn(n);t(c=>{const l=new Map(c.sessions),d=l.get(a);if(!d)return c;const u=xr(d,r);if(u<0)return c;const m=o?.trim()||null;if(d.tabs[u]?.iconKey===m)return c;const f=[...d.tabs];return f[u]={...f[u],iconKey:m},l.set(a,{...d,tabs:f}),{sessions:l}})},closeTab:async(n,r)=>{const o=Dn(n),l=e().sessions.get(o)?.tabs.find(d=>d.id===r)?.terminalSessionId??null;if(l)try{await np(l)}catch{}t(d=>{const u=new Map(d.sessions),m=u.get(o);if(!m)return d;const f=xr(m,r);if(f<0)return d;const g=m.tabs.filter(y=>y.id!==r),b=Object.fromEntries(Object.entries(d.projectActionRuns).filter(([,y])=>!(y.directory===o&&y.tabId===r))),p=Object.keys(b).length!==Object.keys(d.projectActionRuns).length;if(g.length===0){const y=`tab-${d.nextTabId}`,h=ml(y,"Terminal");return u.set(o,hl(h)),{sessions:u,nextTabId:d.nextTabId+1,...p?{projectActionRuns:b}:{}}}let x=m.activeTabId;return m.activeTabId===r&&(x=g[Math.min(f,g.length-1)]?.id??g[0]?.id??null),u.set(o,{...m,tabs:g,activeTabId:x}),{sessions:u,...p?{projectActionRuns:b}:{}}})},setTabSessionId:(n,r,o)=>{const a=Dn(n);t(c=>{const l=new Map(c.sessions),d=l.get(a);if(!d)return c;const u=xr(d,r);if(u<0)return c;const m=d.tabs[u],f=o!==null&&m.terminalSessionId!==o,g=o?"running":m.terminalSessionId?"exited":m.lifecycle,b={...m,terminalSessionId:o,lifecycle:g,isConnecting:!1,...f?{bufferChunks:[],bufferLength:0}:{}},p=[...d.tabs];return p[u]=b,l.set(a,{...d,tabs:p}),{sessions:l}})},setTabLifecycle:(n,r,o)=>{const a=Dn(n);t(c=>{const l=new Map(c.sessions),d=l.get(a);if(!d)return c;const u=xr(d,r);if(u<0)return c;const m=[...d.tabs];return m[u]={...m[u],lifecycle:o,isConnecting:!1},l.set(a,{...d,tabs:m}),{sessions:l}})},setConnecting:(n,r,o)=>{const a=Dn(n);t(c=>{const l=new Map(c.sessions),d=l.get(a);if(!d)return c;const u=xr(d,r);if(u<0)return c;const m=[...d.tabs];return m[u]={...m[u],isConnecting:o},l.set(a,{...d,tabs:m}),{sessions:l}})},appendToBuffer:(n,r,o)=>{if(!o)return;const a=Dn(n);t(c=>{const l=new Map(c.sessions),d=l.get(a);if(!d)return c;const u=xr(d,r);if(u<0)return c;const m=d.tabs[u],f=c.nextChunkId,g={id:f,data:o},b=[...m.bufferChunks,g];let p=m.bufferLength+o.length;for(;p>Sb&&b.length>1;){const y=b.shift();if(!y)break;p-=y.data.length}const x=[...d.tabs];return x[u]={...m,bufferChunks:b,bufferLength:p},l.set(a,{...d,tabs:x}),{sessions:l,nextChunkId:f+1}})},setTabPreviewUrl:(n,r,o,a={})=>{const c=Dn(n);t(l=>{const d=new Map(l.sessions),u=d.get(c);if(!u)return l;const m=xr(u,r);if(m<0)return l;const f=u.tabs[m],g=a.autoOpened??f.previewAutoOpened,b=a.locked??f.previewUrlLocked;if(f.previewUrl===o&&f.previewAutoOpened===g&&f.previewUrlLocked===b)return l;const p=[...u.tabs];return p[m]={...f,previewUrl:o,previewAutoOpened:g,previewUrlLocked:b},d.set(c,{...u,tabs:p}),{sessions:d}})},markPreviewAutoOpened:(n,r)=>{const o=Dn(n);t(a=>{const c=new Map(a.sessions),l=c.get(o);if(!l)return a;const d=xr(l,r);if(d<0)return a;const u=l.tabs[d];if(!u.previewUrl||u.previewAutoOpened)return a;const m=[...l.tabs];return m[d]={...u,previewAutoOpened:!0},c.set(o,{...l,tabs:m}),{sessions:c}})},setProjectActionRun:n=>{t(r=>{const o=r.projectActionRuns[n.key];return o&&o.directory===n.directory&&o.actionId===n.actionId&&o.tabId===n.tabId&&o.sessionId===n.sessionId&&o.status===n.status?r:{projectActionRuns:{...r.projectActionRuns,[n.key]:n}}})},updateProjectActionRunStatus:(n,r)=>{t(o=>{const a=o.projectActionRuns[n];return!a||a.status===r?o:{projectActionRuns:{...o.projectActionRuns,[n]:{...a,status:r}}}})},removeProjectActionRun:n=>{t(r=>{if(!r.projectActionRuns[n])return r;const o={...r.projectActionRuns};return delete o[n],{projectActionRuns:o}})},clearBuffer:(n,r)=>{const o=Dn(n);t(a=>{const c=new Map(a.sessions),l=c.get(o);if(!l)return a;const d=xr(l,r);if(d<0)return a;const u=[...l.tabs];return u[d]={...u[d],bufferChunks:[],bufferLength:0},c.set(o,{...l,tabs:u}),{sessions:c}})},removeDirectory:n=>{const r=Dn(n);t(o=>{const a=new Map(o.sessions);a.delete(r);const c=Object.fromEntries(Object.entries(o.projectActionRuns).filter(([,l])=>l.directory!==r));return{sessions:a,projectActionRuns:c}})},clearAll:()=>{t({sessions:new Map,projectActionRuns:{},nextChunkId:1,nextTabId:1})}}),{name:Nb,storage:Tf(()=>Mf()),partialize:t=>({sessions:Array.from(t.sessions.entries()).map(([e,n])=>[e,{activeTabId:n.activeTabId,tabs:n.tabs.map(r=>({id:r.id,label:r.label,iconKey:r.iconKey,terminalSessionId:r.terminalSessionId,lifecycle:r.lifecycle,createdAt:r.createdAt}))}]),nextTabId:t.nextTabId}),merge:(t,e)=>{if(!fl(t))return e;const n=Array.isArray(t.sessions)?t.sessions:[],r=new Map;let o=0;for(const l of n){if(!Array.isArray(l)||l.length!==2)continue;const[d,u]=l;if(typeof d!="string"||!fl(u))continue;const m=Array.isArray(u.tabs)?u.tabs:[],f=[];for(const p of m){if(!fl(p))continue;const x=typeof p.id=="string"?p.id:null;if(!x)continue;const y=kb(x);y!==null&&(o=Math.max(o,y));const h=typeof p.terminalSessionId=="string"||p.terminalSessionId===null?p.terminalSessionId:null,C=p.lifecycle,w=C==="idle"||C==="running"||C==="exited"?C:h?"running":"idle";f.push({id:x,label:typeof p.label=="string"?p.label:"Terminal",iconKey:typeof p.iconKey=="string"?p.iconKey:null,terminalSessionId:h,lifecycle:w,createdAt:typeof p.createdAt=="number"?p.createdAt:Date.now(),bufferChunks:[],bufferLength:0,isConnecting:!1,previewUrl:null,previewAutoOpened:!1,previewUrlLocked:!1})}if(f.length===0)continue;const g=typeof u.activeTabId=="string"?u.activeTabId:null,b=g?f.some(p=>p.id===g):!1;r.set(d,{tabs:f,activeTabId:b?g:f[0].id})}const a=typeof t.nextTabId=="number"&&Number.isFinite(t.nextTabId)?t.nextTabId:1,c=Math.max(e.nextTabId,a,o+1);return{...e,sessions:r,nextChunkId:1,nextTabId:c,hasHydrated:!0}}})));if(typeof window<"u"&&!Xd){Xd=!0;const t=Vs.persist,e=()=>{Vs.getState().hasHydrated||Vs.setState({hasHydrated:!0})};t?.hasHydrated?.()?e():t?.onFinishHydration?t.onFinishHydration(e):e()}const Cb=[{pattern:/^dev(:.*)?$/i},{pattern:/^start(:.*)?$/i},{pattern:/^preview(:.*)?$/i},{pattern:/^serve(:.*)?$/i},{pattern:/^develop(:.*)?$/i}],Ab=["dev","start","preview","serve"];async function Db(t,e,n){if(!t)return null;const r=Tb(e);if(r)return{command:r.command,label:r.name||"Start Preview",actionId:r.id};if(n){const o=Rb(n);if(o){const a=await Eb(t);return{command:`${a==="npm"?"npm run":a==="yarn"?"yarn":a==="pnpm"?"pnpm":a==="bun"?"bun run --shell=bun":"npm run"} ${o}`,label:`Start (${o})`}}}if(await Ib(t)){const o=await Pb(),a=typeof o=="number"&&Number.isFinite(o)&&o>0?o:8e3;return{command:`python3 -m http.server ${a}`,label:"Static preview",previewUrlHint:`http://127.0.0.1:${a}/`}}return null}async function Ib(t){const e=`${t}/index.html`,n=await Da(e,t);return typeof n=="string"&&n.trim().length>0}async function Pb(){try{const t=await As("/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 Tb(t){for(const e of t){const n=`${e.name} ${e.command}`.toLowerCase();if(Ab.some(o=>n.includes(o)))return e}return null}function Rb(t){for(const{pattern:e}of Cb)for(const n of Object.keys(t))if(e.test(n))return n;return null}async function Eb(t){const e=await Da(`${t}/package.json`,t);if(e)try{const r=JSON.parse(e),o=typeof r.packageManager=="string"?r.packageManager.toLowerCase():"";if(o.startsWith("bun@"))return"bun";if(o.startsWith("pnpm@"))return"pnpm";if(o.startsWith("yarn@"))return"yarn";if(o.startsWith("npm@"))return"npm"}catch{}const n=[["bun.lock","bun"],["bun.lockb","bun"],["pnpm-lock.yaml","pnpm"],["yarn.lock","yarn"],["package-lock.json","npm"]];for(const[r,o]of n){const a=await Da(`${t}/${r}`,t);if(typeof a=="string"&&a.trim().length>0)return o}return"npm"}async function Da(t,e){if(e?.trim())try{const r=new URLSearchParams({path:t,directory:e,optional:"true"}),o=await As(`/api/fs/read?${r.toString()}`,{cache:"no-store"});if(o.ok)return o.text()}catch{}const n=Lo()?.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 As(`/api/fs/read?path=${encodeURIComponent(t)}&optional=true`,{cache:"no-store"});return r.ok?r.text():null}catch{return null}}async function Mb(t){try{const e=await Da(`${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 Fb=t=>new Promise(e=>{window.setTimeout(e,t)}),Lb="\x1B",Ob=new RegExp(`${Lb}\\[[0-9;?]*[ -/]*[@-~]`,"g"),Bb=/https?:\/\/[^\s<>'"`]+/gi,sr="__openchamber_auto_discover_preview__",Vb=15e3,_b=t=>{let e="";for(let n=0;n<t.length;n+=1){const r=t.charCodeAt(n);r>=0&&r<=8||r===11||r===12||r>=14&&r<=31||r===127||(e+=t[n])}return e},$b=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}},zb=t=>{const n=t.replace(Ob,"").match(Bb);if(!n||n.length===0)return null;const r=n.map(a=>a.replace(/[),.;]+$/,"")).filter(Boolean);if(r.length===0)return null;const o=[];for(const a of r)try{const c=new URL(a);c.port&&c.port.length>0&&o.push({raw:a,parsed:c})}catch{}if(o.length>0){const a=c=>{const{parsed:l}=c,d=l.hostname.toLowerCase(),u=d==="localhost"||d==="127.0.0.1"||d==="0.0.0.0"||d==="::1",m=l.pathname||"/",f=m.split("/").filter(Boolean).length,g=m==="/"||m==="",b=!!(l.search||l.hash);let p=0;return u&&(p+=50),g&&(p+=30),p-=Math.min(f*5,20),b&&(p-=10),p};return o.sort((c,l)=>a(l)-a(c)),o[0]?.parsed.origin??o[0]?.raw??null}return r[0]??null},km=({projectRef:t,directory:e,className:n,compact:r=!1,allowMobile:o=!1})=>{const{t:a}=Nt(),{terminal:c,runtime:l}=Jn(),{isMobile:d}=Er(),u=i.useMemo(()=>dr(),[]),m=Gd(z=>z.instances),f=Gd(z=>z.load),g=Ee(z=>z.setBottomTerminalOpen),b=Ee(z=>z.setActiveMainTab),p=Ee(z=>z.setSettingsPage),x=Ee(z=>z.setSettingsDialogOpen),y=Ee(z=>z.setSettingsProjectsSelectedId),h=Ee(z=>z.openContextPreview),C=Vs(z=>z.sessions),w=Vs(z=>z.ensureDirectory),S=Vs(z=>z.setTabLabel),j=Vs(z=>z.setTabIconKey),k=Vs(z=>z.setActiveTab),v=Vs(z=>z.setConnecting),A=Vs(z=>z.setTabSessionId),I=Vs(z=>z.setTabPreviewUrl),N=Vs(z=>z.projectActionRuns),O=Vs(z=>z.setProjectActionRun),P=Vs(z=>z.updateProjectActionRunStatus),T=Vs(z=>z.removeProjectActionRun),[L,R]=i.useState([]),[B,V]=i.useState(null),[_,E]=i.useState(!1),Z=i.useRef({}),ne=i.useRef({}),Y=i.useRef({}),H=i.useRef({}),re=i.useRef(0),ae=t?.id??null,me=t?.path??"",Se=i.useMemo(()=>ae?{id:ae,path:me}:null,[ae,me]);i.useEffect(()=>{u&&f().catch(()=>{})},[u,f]);const te=i.useCallback(async z=>{await Ii(z)},[]),ke=i.useCallback(async()=>{if(!Se)return;const z=re.current+1;re.current=z,E(!0);try{const xe=await kd(Se);if(re.current!==z)return;const je=xe.actions;R(je),V(K=>K===sr||K&&je.some(ye=>ye.id===K)?K:null)}catch{if(re.current!==z)return}finally{re.current===z&&E(!1)}},[Se]),Q=i.useMemo(()=>Mx(e||Se?.path||""),[e,Se?.path]),ge=i.useMemo(()=>B?L.find(z=>z.id===B)??null:null,[L,B]),F=i.useMemo(()=>({id:sr,name:a("projectActions.actions.autoDiscover"),command:"",icon:"search",autoOpenUrl:!0}),[a]),se=!d,ee=i.useMemo(()=>se?[F,...L]:L,[L,F,se]);i.useEffect(()=>{ke()},[ke]),i.useEffect(()=>{if(typeof window>"u")return;const z=xe=>{const je=xe.detail;ae&&(je?.projectId&&je.projectId!==ae||ke())};return window.addEventListener(Kd,z),()=>{window.removeEventListener(Kd,z)}},[ke,ae]),i.useEffect(()=>{B&&(B===sr&&se||L.some(z=>z.id===B)||V(null))},[L,se,B]),i.useEffect(()=>{for(const[z,xe]of Object.entries(N)){const K=C.get(xe.directory)?.tabs.find(ye=>ye.id===xe.tabId);(!K||K.terminalSessionId!==xe.sessionId)&&T(z)}},[N,T,C]),i.useEffect(()=>{for(const[z,xe]of Object.entries(N)){const je=ne.current[z]??{lastSeenChunkId:null,openedUrl:!1,tail:"",openInPreview:!1};ne.current[z]=je;const K=ee.find(Oe=>Oe.id===xe.actionId);if(!K)continue;const Le=C.get(xe.directory)?.tabs.find(Oe=>Oe.id===xe.tabId);if(!Le||!Array.isArray(Le.bufferChunks)||Le.bufferChunks.length===0)continue;const Re=Le.bufferChunks.filter(Oe=>je.lastSeenChunkId===null?!0:Oe.id>je.lastSeenChunkId);if(Re.length===0)continue;const X=Re.map(Oe=>Oe.data).join(""),M=`${je.tail}${X}`,le=!je.openedUrl&&K.autoOpenUrl===!0?zb(M):null,ie=Re[Re.length-1]?.id??je.lastSeenChunkId;if(je.lastSeenChunkId=ie,je.tail=M.slice(-512),le)if(je.openedUrl=!0,je.openInPreview){const Oe=N[z];Oe&&(I(Oe.directory,Oe.tabId,le,{locked:!1,autoOpened:!1}),Oe.status==="waiting-for-preview"&&P(z,"running"),window.clearTimeout(H.current[z]),delete H.current[z],h(Oe.directory,le))}else te(le),ce.success(a("projectActions.toast.openedUrlFromOutput"));ne.current[z]=je}for(const z of Object.keys(ne.current))N[z]||(delete ne.current[z],window.clearTimeout(H.current[z]),delete H.current[z])},[ee,h,te,N,I,a,C,P]);const Ne=i.useCallback(async(z,xe={})=>{if(!Q)throw new Error(a("projectActions.error.noActiveDirectory"));const je=Jr(Q,z.id);w(Q);const K=Vs.getState(),ye=K.getDirectoryState(Q);let Le=Z.current[je]||null;const Re=Le?!!ye?.tabs.some(le=>le.id===Le):!1;(!Le||!Re)&&(Le=K.createTab(Q),Z.current[je]=Le),S(Q,Le,`Action: ${z.name}`),j(Q,Le,z.icon||"play"),xe.revealTerminal!==!1&&(k(Q,Le),g(!0),b("terminal"));const M=Vs.getState().getDirectoryState(Q)?.tabs.find(le=>le.id===Le);return{key:je,tabId:Le,sessionId:M?.terminalSessionId??null}},[w,Q,b,k,g,j,S,a]),De=i.useCallback(async z=>{if(l.isVSCode||!o&&d)return;if(!Q){ce.error(a("projectActions.error.noActiveDirectoryForAction"));return}const xe=Jr(Q,z.id),je=N[xe];if(!(je&&je.status==="running"))try{const K=z.id===sr?await(async()=>{const[Je,rt]=await Promise.all([kd({id:Se?.id??"",path:Q}),Mb(Q)]),bt=await Db(Q,Je.actions,rt);if(!bt)throw new Error(a("contextPanel.preview.noDevServer"));return{id:sr,name:a("projectActions.actions.autoDiscover"),command:bt.command,icon:"search",autoOpenUrl:!0,openUrl:bt.previewUrlHint||""}})():z,ye=K.autoOpenUrl===!0&&(K.openUrl||"").trim().length>0,{key:Le,tabId:Re,sessionId:X}=await Ne(K,{revealTerminal:!ye&&z.id!==sr});let M=X,le=!1;if(!M){v(Q,Re,!0);try{M=(await c.createSession({cwd:Q})).sessionId,le=!0,A(Q,Re,M)}finally{v(Q,Re,!1)}}if(!M)throw new Error(a("projectActions.error.failedToCreateTerminalSession"));le&&await Fb(350),K.id===sr&&(Y.current[Le]?.(),v(Q,Re,!0),Y.current[Le]=rp(M,Je=>{Je.type==="data"&&typeof Je.data=="string"&&Je.data.length>0&&Vs.getState().appendToBuffer(Q,Re,Je.data),Je.type==="exit"&&(Vs.getState().setTabLifecycle(Q,Re,"exited"),Vs.getState().setConnecting(Q,Re,!1),Vs.getState().removeProjectActionRun(Le),delete ne.current[Le],Y.current[Le]?.(),delete Y.current[Le],window.clearTimeout(H.current[Le]),delete H.current[Le])},()=>{Vs.getState().setConnecting(Q,Re,!1)},{maxRetries:60,initialRetryDelay:250,maxRetryDelay:2e3,connectionTimeout:5e3}));const ie=K.autoOpenUrl===!0&&u&&(K.desktopOpenSshForward||"").trim().length>0,Oe=K.autoOpenUrl?$b(K.openUrl):null,Ge=K.autoOpenUrl&&u?Fx(K.desktopOpenSshForward,m):null;O({key:Le,directory:Q,actionId:K.id,tabId:Re,sessionId:M,status:K.id===sr&&!Oe?"waiting-for-preview":"running"}),window.clearTimeout(H.current[Le]),delete H.current[Le],K.id===sr&&!Oe&&(H.current[Le]=window.setTimeout(()=>{Vs.getState().updateProjectActionRunStatus(Le,"running"),delete H.current[Le]},Vb)),Ge?(I(Q,Re,null,{locked:!0}),te(Ge),ce.success(a("projectActions.toast.openedForwardedUrl"))):Oe?(I(Q,Re,Oe,{locked:!0,autoOpened:!0}),h(Q,Oe),ce.success(a("projectActions.toast.openedActionUrl"))):ye?(I(Q,Re,null,{locked:!0}),ce.error(a("projectActions.error.invalidCustomUrlFormat"))):ie?(I(Q,Re,null,{locked:!0}),ce.error(a("projectActions.error.selectedDesktopSshForwardUnavailable"))):I(Q,Re,null,{locked:!1,autoOpened:!1}),ne.current[Le]={lastSeenChunkId:null,openedUrl:!!Ge||!!Oe||ye,tail:"",openInPreview:K.id===sr};const He=_b(K.command.trim().replace(/\r\n|\r/g,`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TerminalView-CMdqMpTy.js","assets/vendor-.bun-By2L9XvG.js","assets/vendor--Dwc_TRgJ.css","assets/useAppFontEffects-Bd0ks39c.js","assets/index-BsXkdBYx.js","assets/index-B82A6jBD.css","assets/NewWorktreeDialog-5TYBoMMA.js","assets/mobileLayoutPreference-Dio-WWkI.js","assets/SessionSwitcherDropdown-B6kvduse.js","assets/DiagramView-Bbj-QI7h.js","assets/SettingsWindow-BEfDro9b.js","assets/MultiRunWindow-DMMu53kw.js","assets/OnboardingScreen-BucKVBD7.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{j as s,e as mt,a as ro,R as i,d as Pf,p as cc,b as Tf,H as Xe,I as Rf,u as ga,l as yo,n as xa,D as ba,q as ya,S as Bl,v as Vl,w as dc,C as uc,L as _l,N as Mh,O as Fh,T as Lh,W as Oh,X as ni,Y as Bh,$ as Vh,F as _h,a0 as $h,a1 as zh,a2 as Wh,a3 as Ef,a4 as Uh,a5 as Hh,a6 as $l,a7 as Gh,s as Kh,m as qh,a8 as dd,a9 as ud,aa as fd,ab as Yh,ac as Qh,ad as Jh,ae as Xh,af as Zh,ag as ep,_ as io,ah as md,ai as hd,aj as pd,G as tp}from"./vendor-.bun-By2L9XvG.js";import{f as fc,h as dr,j as Ji,k as gd,l as sp,m as wa,n as Mf,p as np,e as As,q as Lo,b as Ee,t as rp,v as Fa,w as Gr,a as Wr,x as Ur,y as zl,z as ip,A as op,R as xd,B as bd,u as Js,C as ap,D as Ni,E as Ff,F as Lf,G as mc,o as Vn,H as lp,g as Ci,I as cp,r as hc,J as dp,K as pc,L as Of,M as up,N as fp,O as na,P as ra,Q as mp,S as hp,T as pp,U as yd,V as wd,W as vd,X as jd,Y as gp,Z as xp,_ as Sd,d as Nd,$ as bp,a0 as yp,a1 as wp,i as vp,s as jp}from"./index-BsXkdBYx.js";import{u as Nt,m as Pe,ao as bs,I as D,p as ur,t as ce,ap as en,aq as Rr,ar as tn,as as sn,a as Jn,at as Er,au as Ii,av as kd,aw as Et,ax as Mt,ay as Ft,az as Sp,ac as Do,aA as va,aB as ri,ad as Io,ae as Bf,a5 as gc,aC as Vf,aD as Np,Q as ss,z as ut,aE as kp,a7 as _f,y as vr,x as xc,D as ws,R as Pi,aF as $f,aG as zf,aH as ja,aI as Wf,aJ as Uf,aK as Hf,aL as Gf,aM as Cp,aN as Ap,T as bc,aO as La,aP as ii,aQ as yc,aR as ia,X as Zs,aS as Dp,aT as Kf,aU as Ip,aV as qf,aW as wc,aX as Hs,aY as Us,B as $e,aZ as _s,a_ as $s,a$ as ci,b0 as Pp,b1 as Tp,b2 as zo,b3 as Tn,b4 as Yf,b5 as Qf,a2 as vc,b6 as Rp,b7 as Cd,b8 as Ad,b9 as ki,n as vn,ba as Ti,bb as Xi,bc as Ep,bd as Mp,be as Fp,bf as Lp,bg as Oa,bh as Ba,bi as Va,bj as _a,bk as oi,bl as li,bm as Op,bn as Bp,bo as on,bp as Vp,bq as _p,br as $p,bs as zp,bt as Wp,k as Ai,bu as jc,bv as Up,bw as Hp,bx as Gp,by as Kp,bz as qp,bA as Yp,bB as Qp,bC as _n,bD as $n,bE as zn,bF as Nn,bG as Wn,bH as Ls,bI as Jp,w as Po,M as $a,S as za,bJ as Xp,bK as ir,bL as Zp,b as di,d as Sc,c as Wa,bM as eg,bN as Jf,bO as tg,bP as sg,e as Nc,bQ as ng,f as wn,bR as Ua,a3 as Pr,j as rg,bS as ig,bT as rl,bU as og,bV as ag,F as Hr,bW as kc,bX as Ha,bY as fn,bZ as Ri,l as Zi,b_ as Xf,b$ as lg,c0 as cg,c1 as dg,c2 as Dd,c3 as ug,q as Kr,r as Id,v as Pd,c4 as Td,c5 as Zf,c6 as Rd,c7 as Ed,c8 as em,c9 as fg,ca as tm,o as Md,J as mg,cb as il,cc as Cc,cd as hg,ce as pg,cf as gg,cg as Oo,ch as xg,ci as Ac,cj as bg,ck as Dc,cl as sm,cm as Wo,cn as yg,co as Tr,cp as wg,cq as nm,cr as vg,cs as jg,ct as Fd,cu as rm,cv as im,cw as om,E as Ic,P as Ga,G as Ka,L as Sa,cx as Na,cy as Ln,H as Sg,K as Ng,cz as kg,cA as Wl,cB as Cg,cC as Ag,cD as Dg,cE as Ld,cF as Ig,cG as Pg,cH as Tg,cI as Pc,cJ as am,cK as Rg,cL as Eg,cM as Mg,cN as Fg,cO as Od,cP as Bd,cQ as Lg,cR as Og,cS as Bg,cT as Vg,cU as _g,cV as $g,N as zg,cW as Vd,cX as Wg,cY as lm,O as Ug,cZ as Hg,A as Gg,C as Kg,c_ as qg,c$ as Yg,d0 as Qg,d1 as Jg,d2 as Xg,d3 as Zg,d4 as ex,d5 as tx,d6 as sx,d7 as ka,d8 as nx,d9 as _d,da as rx,db as ix,dc as ox,dd as oo,de as ax,df as $d,dg as lx,dh as cx,di as dx,dj as ux,dk as cm,dl as dm,dm as fx,dn as mx,dp as hx,dq as oa,a9 as px,dr as gx,ds as ol,dt as xx,du as bx,U as yx,V as wx,W as vx,Y as zd,Z as Wd,_ as Ud,dv as jx,$ as um,a0 as fm,dw as Sx,aj as Nx,ak as kx,al as Cx,am as Ax,an as Dx,af as Ix,ag as Px,ah as Tx,ai as Rx}from"./useAppFontEffects-Bd0ks39c.js";import{I as Hd,o as Ex,p as Gd,q as Mx,r as Kd,t as Jr,s as Fx,v as al,w as To,U as Ca,x as Aa,y as eo,z as Bo,B as to,k as mm,M as hm,i as mn,j as Lx,Q as pm,E as Ox,F as Bx,G as Vx,l as Ul,H as gm,P as xm,J as _x,K as $x,C as zx,a as Wx,L as Tc,R as bm,T as Rc,V as Ec,W as Mc,X as ym,Y as wm,Z as Hl,_ as vm,$ as Gl,a0 as aa,a1 as Ux,a2 as Hx,e as wo,N as Gx,D as Kx,u as qx,n as Yx,m as Kl,a3 as Qx,a4 as Jx,g as Xx,a5 as Zx,a6 as eb,c as tb,O as jm,d as sb,a7 as nb}from"./NewWorktreeDialog-5TYBoMMA.js";import{S as rb,C as ib,W as ob,g as Fc,r as ab,n as cs,i as Ro,d as so,c as Gi,a as qd,b as lb,e as vo,f as Sm,h as cb,j as db,u as ll}from"./SessionSwitcherDropdown-B6kvduse.js";function Nm(t){const{drafts:e,editingDraftId:n,commentText:r,onTextChange:o,selection:a,isDragging:c,fileLabel:l,newWidgetId:d,mapDraftToRange:u,onSave:m,onCancel:f,onEdit:g,onDelete:b}=t,p=[];for(const x of e){const y=u(x);if(x.id===n){p.push({afterLine:y.end,id:`edit-${x.id}`,content:s.jsx(Hd,{initialText:r,onTextChange:o,fileLabel:l,lineRange:y,isEditing:!0,onSave:m,onCancel:f},`edit-${x.id}`)});continue}p.push({afterLine:y.end,id:`card-${x.id}`,content:s.jsx(Ex,{draft:x,onEdit:()=>g(x),onDelete:()=>b(x)},`card-${x.id}`)})}if(a&&!n&&!c){const x={...a,start:Math.min(a.start,a.end),end:Math.max(a.start,a.end)};p.push({afterLine:x.end,id:d,content:s.jsx(Hd,{initialText:r,onTextChange:o,fileLabel:l,lineRange:x,isEditing:!1,onSave:m,onCancel:f},d)})}return p}function Yd(t){const e=mt.c(14);let n,r,o,a;e[0]!==t?({size:o,className:n,style:a,...r}=t,e[0]=t,e[1]=n,e[2]=r,e[3]=o,e[4]=a):(n=e[1],r=e[2],o=e[3],a=e[4]);const c=typeof o=="number"?`${o}px`:o,l=typeof o=="number"?`${o}px`:o;let d;e[5]!==a||e[6]!==c||e[7]!==l?(d={width:c,height:l,...a},e[5]=a,e[6]=c,e[7]=l,e[8]=d):d=e[8];let u;e[9]===Symbol.for("react.memo_cache_sentinel")?(u=s.jsx("path",{d:"M112,148a12,12,0,0,0-12,12v19L69.17,148.2A4,4,0,0,1,68,145.37V97.94a36,36,0,1,0-24,0v47.43a27.81,27.81,0,0,0,8.2,19.8L83,196H64a12,12,0,0,0,0,24h48a12,12,0,0,0,12-12V160A12,12,0,0,0,112,148ZM56,52A12,12,0,1,1,44,64,12,12,0,0,1,56,52ZM212,158.06V110.63a27.81,27.81,0,0,0-8.2-19.8L173,60h19a12,12,0,0,0,0-24H144a12,12,0,0,0-12,12V96a12,12,0,0,0,24,0V77l30.83,30.83a4,4,0,0,1,1.17,2.83v47.43a36,36,0,1,0,24,0ZM200,204a12,12,0,1,1,12-12A12,12,0,0,1,200,204Z"}),e[9]=u):u=e[9];let m;return e[10]!==n||e[11]!==r||e[12]!==d?(m=s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 256 256",fill:"currentColor",className:n,style:d,...r,children:u}),e[10]=n,e[11]=r,e[12]=d,e[13]=m):m=e[13],m}const ai=[{id:"finder",label:"Finder",appName:"Finder"},{id:"terminal",label:"Terminal",appName:"Terminal"},{id:"iterm2",label:"iTerm2",appName:"iTerm"},{id:"ghostty",label:"Ghostty",appName:"Ghostty"},{id:"vscode",label:"VS Code",appName:"Visual Studio Code"},{id:"intellij",label:"IntelliJ",appName:"IntelliJ IDEA"},{id:"visual-studio",label:"Visual Studio",appName:"Visual Studio"},{id:"cursor",label:"Cursor",appName:"Cursor"},{id:"android-studio",label:"Android Studio",appName:"Android Studio"},{id:"pycharm",label:"PyCharm",appName:"PyCharm"},{id:"xcode",label:"Xcode",appName:"Xcode"},{id:"sublime-text",label:"Sublime",appName:"Sublime Text"},{id:"webstorm",label:"WebStorm",appName:"WebStorm"},{id:"rider",label:"Rider",appName:"Rider"},{id:"zed",label:"Zed",appName:"Zed"},{id:"phpstorm",label:"PhpStorm",appName:"PhpStorm"},{id:"eclipse",label:"Eclipse",appName:"Eclipse"},{id:"windsurf",label:"Windsurf",appName:"Windsurf"},{id:"vscodium",label:"VSCodium",appName:"VSCodium"},{id:"rustrover",label:"RustRover",appName:"RustRover"},{id:"kiro",label:"Kiro",appName:"Kiro"},{id:"antigravity",label:"Antigravity",appName:"Antigravity"},{id:"trae",label:"Trae",appName:"Trae"}],ql="finder",Yl=new Set(["finder","terminal"]),Lc=t=>typeof window<"u"&&window.__OPENCHAMBER_PLATFORM__==="win32"&&t.id==="finder"?{...t,label:"Explorer",appName:"File Explorer"}:t,Ql=t=>{if(!t)return null;const e=ai.find(n=>n.id===t)??null;return e?Lc(e):null},cl=()=>ai.filter(t=>Yl.has(t.id)).map(t=>({...Lc(t)})),ub=()=>{if(typeof window>"u")return ql;const t=window.localStorage.getItem("openInAppId");return t&&Ql(t)?t:ql};let dl=!1,Vi=!1,Xr=!1,Zr=0,jo=null;const Qd=()=>{jo&&(clearTimeout(jo),jo=null)},yr=ro()((t,e)=>({selectedAppId:ub(),availableApps:cl(),hasLoadedApps:!1,isCacheStale:!1,isScanning:!1,initialize:()=>{if(dl||typeof window>"u")return;dl=!0;const n=(d,u=!0)=>{if(!Array.isArray(d)||d.length===0){t({availableApps:cl(),hasLoadedApps:u});return}const m=new Set(d.map(p=>p.name)),f=new Map(d.map(p=>[p.name,p.iconDataUrl??void 0])),b=ai.filter(p=>m.has(p.appName)||Yl.has(p.id)).map(p=>({...Lc(p),iconDataUrl:f.get(p.appName)}));t({availableApps:b,hasLoadedApps:!0})},r=async d=>{if(!dr()||!Ji()||Vi||e().hasLoadedApps&&!d)return;const m=ai.map(f=>f.appName);Qd(),Vi=!0,Xr=!1,t({isScanning:!0});try{const{apps:f,success:g,hasCache:b,isCacheStale:p}=await gd(m,d),x=g&&!b&&f.length===0&&Zr<3;if(t({isCacheStale:b?p:!1}),n(f,g?!x:!1),g){if(x){const h=[800,1600,3200][Zr]??3200;Zr+=1,Xr=!0,jo=setTimeout(()=>{r()},h);return}Zr=0,Xr=!1;return}if(Zr<3){const h=[1e3,3e3,7e3][Zr]??7e3;Zr+=1,Xr=!0,jo=setTimeout(()=>{r()},h)}}finally{Vi=!1,Xr||t({isScanning:!1})}};r();const o=d=>{const u=d.detail,m=u&&typeof u.openInAppId=="string"&&u.openInAppId.length>0&&Ql(u.openInAppId)?u.openInAppId:null;m&&(window.localStorage.setItem("openInAppId",m),t({selectedAppId:m}))},a=()=>{r()},c=d=>{const u=d.detail;Array.isArray(u)&&(Zr=3,Xr=!1,t({isScanning:!1,isCacheStale:!1}),n(u))};window.addEventListener("openchamber:settings-synced",o),window.addEventListener("openchamber:app-ready",a),window.addEventListener("openchamber:installed-apps-updated",c),window.__openchamberAppReady&&r(),window.setTimeout(()=>{e().hasLoadedApps||r()},5e3)},loadInstalledApps:async n=>{if(dl||e().initialize(),!dr()||!Ji()||Vi||e().hasLoadedApps&&!n)return;const o=ai.map(a=>a.appName);Qd(),n&&t({hasLoadedApps:!1}),Vi=!0,Xr=!1,t({isScanning:!0});try{const{apps:a,hasCache:c,isCacheStale:l}=await gd(o,n),d=new Set(a.map(g=>g.name)),u=new Map(a.map(g=>[g.name,g.iconDataUrl??void 0])),f=ai.filter(g=>d.has(g.appName)||Yl.has(g.id)).map(g=>({...g,iconDataUrl:u.get(g.appName)}));t({availableApps:f.length>0?f:cl(),hasLoadedApps:f.length>0,isCacheStale:c?l:!1})}finally{Vi=!1,Xr||t({isScanning:!1})}},selectApp:async n=>{Ql(n)&&(t({selectedAppId:n}),typeof window<"u"&&window.localStorage.setItem("openInAppId",n),await fc({openInAppId:n}))}})),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",ul=t=>({...t,fallbackIconDataUrl:t.id==="finder"&&window.__OPENCHAMBER_PLATFORM__!=="win32"?fb:t.id==="terminal"?mb:void 0}),Jd=t=>{const e=mt.c(8),{label:n,iconDataUrl:r,fallbackIconDataUrl:o}=t,[a,c]=i.useState(!1);let l;e[0]!==n?(l=n.trim().slice(0,1).toUpperCase()||"?",e[0]=n,e[1]=l):l=e[1];const d=l,u=r||o;if(u&&!a){let g;e[2]===Symbol.for("react.memo_cache_sentinel")?(g=()=>c(!0),e[2]=g):g=e[2];let b;return e[3]!==u?(b=s.jsx("img",{src:u,alt:"",className:"h-4 w-4 rounded-sm",onError:g}),e[3]=u,e[4]=b):b=e[4],b}let m;e[5]===Symbol.for("react.memo_cache_sentinel")?(m=Pe("h-4 w-4 rounded-sm flex items-center justify-center","bg-[var(--surface-muted)] text-[9px] font-medium text-muted-foreground"),e[5]=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=mt.c(75),{directory:n,className:r}=t,{t:o}=Nt(),a=yr(pb),c=yr(gb),l=yr(xb),d=yr(bb),u=yr(yb),m=yr(wb),f=yr(vb);let g,b;e[0]!==u?(g=()=>{u()},b=[u],e[0]=u,e[1]=g,e[2]=b):(g=e[1],b=e[2]),i.useEffect(g,b);const p=dr()&&Ji();let x;e:{let ke;e[3]!==c||e[4]!==a?(ke=c.find(F=>F.id===a)??c.find(jb)??c[0]??ai[0],e[3]=c,e[4]=a,e[5]=ke):ke=e[5];const Q=ke;if(Q){let F;e[6]!==Q?(F=ul(Q),e[6]=Q,e[7]=F):F=e[7],x=F;break e}let ge;e[8]===Symbol.for("react.memo_cache_sentinel")?(ge=ul(ai[0]),e[8]=ge):ge=e[8],x=ge}const y=x;if(!p||!n||c.length===0)return null;let h;e[9]!==n?(h=async ke=>{await sp(n,ke.id,ke.appName)||await wa(n,ke.appName)},e[9]=n,e[10]=h):h=e[10];const C=h;let w;e[11]!==C||e[12]!==f?(w=async ke=>{await f(ke.id),await C(ke)},e[11]=C,e[12]=f,e[13]=w):w=e[13];const S=w;let j;e[14]!==n||e[15]!==o?(j=async()=>{(await ur(n)).ok&&ce.success(o("openInApp.toast.pathCopied"))},e[14]=n,e[15]=o,e[16]=j):j=e[16];const k=j;let v;e[17]!==r?(v=Pe("app-region-no-drag inline-flex h-7 items-center self-center rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px]","bg-[var(--surface-elevated)] overflow-hidden","border border-border/60",r),e[17]=r,e[18]=v):v=e[18];let A;e[19]!==C||e[20]!==y?(A=()=>{C(y)},e[19]=C,e[20]=y,e[21]=A):A=e[21];const I=d&&"animate-pulse";let N;e[22]!==I?(N=Pe("inline-flex h-full items-center px-2.5 typography-ui-label font-medium","text-foreground hover:bg-interactive-hover transition-colors",I),e[22]=I,e[23]=N):N=e[23];let O;e[24]!==y.label||e[25]!==o?(O=o("openInApp.actions.openInAria",{app:y.label}),e[24]=y.label,e[25]=o,e[26]=O):O=e[26];let P;e[27]!==y.fallbackIconDataUrl||e[28]!==y.iconDataUrl||e[29]!==y.label?(P=s.jsx(Jd,{label:y.label,iconDataUrl:y.iconDataUrl,fallbackIconDataUrl:y.fallbackIconDataUrl}),e[27]=y.fallbackIconDataUrl,e[28]=y.iconDataUrl,e[29]=y.label,e[30]=P):P=e[30];let T;e[31]!==N||e[32]!==O||e[33]!==P||e[34]!==A?(T=s.jsx("button",{type:"button",onClick:A,className:N,"aria-label":O,children:P}),e[31]=N,e[32]=O,e[33]=P,e[34]=A,e[35]=T):T=e[35];let L;e[36]===Symbol.for("react.memo_cache_sentinel")?(L=Pe("inline-flex h-full w-7 items-center justify-center","border-l border-[var(--interactive-border)] text-muted-foreground","hover:bg-interactive-hover hover:text-foreground transition-colors"),e[36]=L):L=e[36];let R;e[37]!==o?(R=o("openInApp.actions.chooseAppAria"),e[37]=o,e[38]=R):R=e[38];let B;e[39]===Symbol.for("react.memo_cache_sentinel")?(B=s.jsx(D,{name:"arrow-down-s",className:"h-4 w-4"}),e[39]=B):B=e[39];let V;e[40]!==R?(V=s.jsx(en,{asChild:!0,children:s.jsx("button",{type:"button",className:L,"aria-label":R,children:B})}),e[40]=R,e[41]=V):V=e[41];let _;e[42]!==k?(_=()=>{k()},e[42]=k,e[43]=_):_=e[43];let E;e[44]===Symbol.for("react.memo_cache_sentinel")?(E=s.jsx(D,{name:"file-copy",className:"h-4 w-4"}),e[44]=E):E=e[44];let Z;e[45]!==o?(Z=o("openInApp.actions.copyPath"),e[45]=o,e[46]=Z):Z=e[46];let ne;e[47]!==Z?(ne=s.jsx("span",{className:"typography-ui-label text-foreground",children:Z}),e[47]=Z,e[48]=ne):ne=e[48];let Y;e[49]!==_||e[50]!==ne?(Y=s.jsxs(bs,{className:"flex items-center gap-2",onClick:_,children:[E,ne]}),e[49]=_,e[50]=ne,e[51]=Y):Y=e[51];let H;e[52]===Symbol.for("react.memo_cache_sentinel")?(H=s.jsx(Rr,{}),e[52]=H):H=e[52];let re;if(e[53]!==c||e[54]!==S||e[55]!==y.id){let ke;e[57]!==S||e[58]!==y.id?(ke=Q=>{const ge=ul(Q);return s.jsxs(bs,{className:"flex items-center gap-2",onClick:()=>{S(Q)},children:[s.jsx(Jd,{label:Q.label,iconDataUrl:Q.iconDataUrl,fallbackIconDataUrl:ge.fallbackIconDataUrl}),s.jsx("span",{className:"typography-ui-label text-foreground",children:Q.label}),y.id===Q.id?s.jsx(D,{name:"check",className:"ml-auto h-4 w-4 text-primary"}):null]},Q.id)},e[57]=S,e[58]=y.id,e[59]=ke):ke=e[59],re=c.map(ke),e[53]=c,e[54]=S,e[55]=y.id,e[56]=re}else re=e[56];let ae;e[60]!==l||e[61]!==m||e[62]!==o?(ae=l?s.jsxs(bs,{className:"flex items-center gap-2",onClick:()=>{m(!0)},children:[s.jsx(D,{name:"refresh",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:o("openInApp.actions.refreshApps")})]}):null,e[60]=l,e[61]=m,e[62]=o,e[63]=ae):ae=e[63];let me;e[64]!==Y||e[65]!==re||e[66]!==ae?(me=s.jsxs(tn,{align:"end",className:"w-56 max-h-[70vh] overflow-y-auto",children:[Y,H,re,ae]}),e[64]=Y,e[65]=re,e[66]=ae,e[67]=me):me=e[67];let Se;e[68]!==V||e[69]!==me?(Se=s.jsxs(sn,{children:[V,me]}),e[68]=V,e[69]=me,e[70]=Se):Se=e[70];let te;return e[71]!==T||e[72]!==Se||e[73]!==v?(te=s.jsxs("div",{className:v,children:[T,Se]}),e[71]=T,e[72]=Se,e[73]=v,e[74]=te):te=e[74],te};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 jb(t){return t.id===ql}const Sb=1e6,Nb="terminal-store";let Xd=!1;const fl=t=>typeof t=="object"&&t!==null,kb=t=>{const e=/^tab-(\d+)$/.exec(t);if(!e)return null;const n=Number(e[1]);return Number.isFinite(n)?n:null};function Dn(t){let e=t.trim();for(;e.length>1&&e.endsWith("/");)e=e.slice(0,-1);return e}const ml=(t,e)=>({id:t,terminalSessionId:null,lifecycle:"idle",label:e,iconKey:null,bufferChunks:[],bufferLength:0,isConnecting:!1,createdAt:Date.now(),previewUrl:null,previewAutoOpened:!1,previewUrlLocked:!1}),hl=t=>({tabs:[t],activeTabId:t.id}),xr=(t,e)=>t.tabs.findIndex(n=>n.id===e),Vs=ro()(Pf(cc((t,e)=>({sessions:new Map,projectActionRuns:{},nextChunkId:1,nextTabId:1,hasHydrated:typeof window>"u",ensureDirectory:n=>{const r=Dn(n);r&&t(o=>{if(o.sessions.has(r))return o;const a=new Map(o.sessions),c=`tab-${o.nextTabId}`,l=ml(c,"Terminal");return a.set(r,hl(l)),{sessions:a,nextTabId:o.nextTabId+1}})},getDirectoryState:n=>{const r=Dn(n);return e().sessions.get(r)},getActiveTab:n=>{const r=Dn(n),o=e().sessions.get(r);if(!o)return;const a=o.activeTabId;return a?o.tabs.find(c=>c.id===a)??o.tabs[0]:o.tabs[0]},createTab:n=>{const r=Dn(n);if(!r)return"tab-invalid";const o=`tab-${e().nextTabId}`;return t(a=>{const c=new Map(a.sessions),l=c.get(r),d=a.nextTabId+1,m=`Terminal ${(l?.tabs.length??0)+1}`,f=ml(o,m);return l?c.set(r,{...l,tabs:[...l.tabs,f]}):c.set(r,hl(f)),{sessions:c,nextTabId:d}}),o},setActiveTab:(n,r)=>{const o=Dn(n);t(a=>{const c=new Map(a.sessions),l=c.get(o);return!l||l.activeTabId===r||xr(l,r)<0?a:(c.set(o,{...l,activeTabId:r}),{sessions:c})})},setTabLabel:(n,r,o)=>{const a=Dn(n),c=o.trim();c&&t(l=>{const d=new Map(l.sessions),u=d.get(a);if(!u)return l;const m=xr(u,r);if(m<0||u.tabs[m]?.label===c)return l;const f=[...u.tabs];return f[m]={...f[m],label:c},d.set(a,{...u,tabs:f}),{sessions:d}})},setTabIconKey:(n,r,o)=>{const a=Dn(n);t(c=>{const l=new Map(c.sessions),d=l.get(a);if(!d)return c;const u=xr(d,r);if(u<0)return c;const m=o?.trim()||null;if(d.tabs[u]?.iconKey===m)return c;const f=[...d.tabs];return f[u]={...f[u],iconKey:m},l.set(a,{...d,tabs:f}),{sessions:l}})},closeTab:async(n,r)=>{const o=Dn(n),l=e().sessions.get(o)?.tabs.find(d=>d.id===r)?.terminalSessionId??null;if(l)try{await np(l)}catch{}t(d=>{const u=new Map(d.sessions),m=u.get(o);if(!m)return d;const f=xr(m,r);if(f<0)return d;const g=m.tabs.filter(y=>y.id!==r),b=Object.fromEntries(Object.entries(d.projectActionRuns).filter(([,y])=>!(y.directory===o&&y.tabId===r))),p=Object.keys(b).length!==Object.keys(d.projectActionRuns).length;if(g.length===0){const y=`tab-${d.nextTabId}`,h=ml(y,"Terminal");return u.set(o,hl(h)),{sessions:u,nextTabId:d.nextTabId+1,...p?{projectActionRuns:b}:{}}}let x=m.activeTabId;return m.activeTabId===r&&(x=g[Math.min(f,g.length-1)]?.id??g[0]?.id??null),u.set(o,{...m,tabs:g,activeTabId:x}),{sessions:u,...p?{projectActionRuns:b}:{}}})},setTabSessionId:(n,r,o)=>{const a=Dn(n);t(c=>{const l=new Map(c.sessions),d=l.get(a);if(!d)return c;const u=xr(d,r);if(u<0)return c;const m=d.tabs[u],f=o!==null&&m.terminalSessionId!==o,g=o?"running":m.terminalSessionId?"exited":m.lifecycle,b={...m,terminalSessionId:o,lifecycle:g,isConnecting:!1,...f?{bufferChunks:[],bufferLength:0}:{}},p=[...d.tabs];return p[u]=b,l.set(a,{...d,tabs:p}),{sessions:l}})},setTabLifecycle:(n,r,o)=>{const a=Dn(n);t(c=>{const l=new Map(c.sessions),d=l.get(a);if(!d)return c;const u=xr(d,r);if(u<0)return c;const m=[...d.tabs];return m[u]={...m[u],lifecycle:o,isConnecting:!1},l.set(a,{...d,tabs:m}),{sessions:l}})},setConnecting:(n,r,o)=>{const a=Dn(n);t(c=>{const l=new Map(c.sessions),d=l.get(a);if(!d)return c;const u=xr(d,r);if(u<0)return c;const m=[...d.tabs];return m[u]={...m[u],isConnecting:o},l.set(a,{...d,tabs:m}),{sessions:l}})},appendToBuffer:(n,r,o)=>{if(!o)return;const a=Dn(n);t(c=>{const l=new Map(c.sessions),d=l.get(a);if(!d)return c;const u=xr(d,r);if(u<0)return c;const m=d.tabs[u],f=c.nextChunkId,g={id:f,data:o},b=[...m.bufferChunks,g];let p=m.bufferLength+o.length;for(;p>Sb&&b.length>1;){const y=b.shift();if(!y)break;p-=y.data.length}const x=[...d.tabs];return x[u]={...m,bufferChunks:b,bufferLength:p},l.set(a,{...d,tabs:x}),{sessions:l,nextChunkId:f+1}})},setTabPreviewUrl:(n,r,o,a={})=>{const c=Dn(n);t(l=>{const d=new Map(l.sessions),u=d.get(c);if(!u)return l;const m=xr(u,r);if(m<0)return l;const f=u.tabs[m],g=a.autoOpened??f.previewAutoOpened,b=a.locked??f.previewUrlLocked;if(f.previewUrl===o&&f.previewAutoOpened===g&&f.previewUrlLocked===b)return l;const p=[...u.tabs];return p[m]={...f,previewUrl:o,previewAutoOpened:g,previewUrlLocked:b},d.set(c,{...u,tabs:p}),{sessions:d}})},markPreviewAutoOpened:(n,r)=>{const o=Dn(n);t(a=>{const c=new Map(a.sessions),l=c.get(o);if(!l)return a;const d=xr(l,r);if(d<0)return a;const u=l.tabs[d];if(!u.previewUrl||u.previewAutoOpened)return a;const m=[...l.tabs];return m[d]={...u,previewAutoOpened:!0},c.set(o,{...l,tabs:m}),{sessions:c}})},setProjectActionRun:n=>{t(r=>{const o=r.projectActionRuns[n.key];return o&&o.directory===n.directory&&o.actionId===n.actionId&&o.tabId===n.tabId&&o.sessionId===n.sessionId&&o.status===n.status?r:{projectActionRuns:{...r.projectActionRuns,[n.key]:n}}})},updateProjectActionRunStatus:(n,r)=>{t(o=>{const a=o.projectActionRuns[n];return!a||a.status===r?o:{projectActionRuns:{...o.projectActionRuns,[n]:{...a,status:r}}}})},removeProjectActionRun:n=>{t(r=>{if(!r.projectActionRuns[n])return r;const o={...r.projectActionRuns};return delete o[n],{projectActionRuns:o}})},clearBuffer:(n,r)=>{const o=Dn(n);t(a=>{const c=new Map(a.sessions),l=c.get(o);if(!l)return a;const d=xr(l,r);if(d<0)return a;const u=[...l.tabs];return u[d]={...u[d],bufferChunks:[],bufferLength:0},c.set(o,{...l,tabs:u}),{sessions:c}})},removeDirectory:n=>{const r=Dn(n);t(o=>{const a=new Map(o.sessions);a.delete(r);const c=Object.fromEntries(Object.entries(o.projectActionRuns).filter(([,l])=>l.directory!==r));return{sessions:a,projectActionRuns:c}})},clearAll:()=>{t({sessions:new Map,projectActionRuns:{},nextChunkId:1,nextTabId:1})}}),{name:Nb,storage:Tf(()=>Mf()),partialize:t=>({sessions:Array.from(t.sessions.entries()).map(([e,n])=>[e,{activeTabId:n.activeTabId,tabs:n.tabs.map(r=>({id:r.id,label:r.label,iconKey:r.iconKey,terminalSessionId:r.terminalSessionId,lifecycle:r.lifecycle,createdAt:r.createdAt}))}]),nextTabId:t.nextTabId}),merge:(t,e)=>{if(!fl(t))return e;const n=Array.isArray(t.sessions)?t.sessions:[],r=new Map;let o=0;for(const l of n){if(!Array.isArray(l)||l.length!==2)continue;const[d,u]=l;if(typeof d!="string"||!fl(u))continue;const m=Array.isArray(u.tabs)?u.tabs:[],f=[];for(const p of m){if(!fl(p))continue;const x=typeof p.id=="string"?p.id:null;if(!x)continue;const y=kb(x);y!==null&&(o=Math.max(o,y));const h=typeof p.terminalSessionId=="string"||p.terminalSessionId===null?p.terminalSessionId:null,C=p.lifecycle,w=C==="idle"||C==="running"||C==="exited"?C:h?"running":"idle";f.push({id:x,label:typeof p.label=="string"?p.label:"Terminal",iconKey:typeof p.iconKey=="string"?p.iconKey:null,terminalSessionId:h,lifecycle:w,createdAt:typeof p.createdAt=="number"?p.createdAt:Date.now(),bufferChunks:[],bufferLength:0,isConnecting:!1,previewUrl:null,previewAutoOpened:!1,previewUrlLocked:!1})}if(f.length===0)continue;const g=typeof u.activeTabId=="string"?u.activeTabId:null,b=g?f.some(p=>p.id===g):!1;r.set(d,{tabs:f,activeTabId:b?g:f[0].id})}const a=typeof t.nextTabId=="number"&&Number.isFinite(t.nextTabId)?t.nextTabId:1,c=Math.max(e.nextTabId,a,o+1);return{...e,sessions:r,nextChunkId:1,nextTabId:c,hasHydrated:!0}}})));if(typeof window<"u"&&!Xd){Xd=!0;const t=Vs.persist,e=()=>{Vs.getState().hasHydrated||Vs.setState({hasHydrated:!0})};t?.hasHydrated?.()?e():t?.onFinishHydration?t.onFinishHydration(e):e()}const Cb=[{pattern:/^dev(:.*)?$/i},{pattern:/^start(:.*)?$/i},{pattern:/^preview(:.*)?$/i},{pattern:/^serve(:.*)?$/i},{pattern:/^develop(:.*)?$/i}],Ab=["dev","start","preview","serve"];async function Db(t,e,n){if(!t)return null;const r=Tb(e);if(r)return{command:r.command,label:r.name||"Start Preview",actionId:r.id};if(n){const o=Rb(n);if(o){const a=await Eb(t);return{command:`${a==="npm"?"npm run":a==="yarn"?"yarn":a==="pnpm"?"pnpm":a==="bun"?"bun run --shell=bun":"npm run"} ${o}`,label:`Start (${o})`}}}if(await Ib(t)){const o=await Pb(),a=typeof o=="number"&&Number.isFinite(o)&&o>0?o:8e3;return{command:`python3 -m http.server ${a}`,label:"Static preview",previewUrlHint:`http://127.0.0.1:${a}/`}}return null}async function Ib(t){const e=`${t}/index.html`,n=await Da(e,t);return typeof n=="string"&&n.trim().length>0}async function Pb(){try{const t=await As("/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 Tb(t){for(const e of t){const n=`${e.name} ${e.command}`.toLowerCase();if(Ab.some(o=>n.includes(o)))return e}return null}function Rb(t){for(const{pattern:e}of Cb)for(const n of Object.keys(t))if(e.test(n))return n;return null}async function Eb(t){const e=await Da(`${t}/package.json`,t);if(e)try{const r=JSON.parse(e),o=typeof r.packageManager=="string"?r.packageManager.toLowerCase():"";if(o.startsWith("bun@"))return"bun";if(o.startsWith("pnpm@"))return"pnpm";if(o.startsWith("yarn@"))return"yarn";if(o.startsWith("npm@"))return"npm"}catch{}const n=[["bun.lock","bun"],["bun.lockb","bun"],["pnpm-lock.yaml","pnpm"],["yarn.lock","yarn"],["package-lock.json","npm"]];for(const[r,o]of n){const a=await Da(`${t}/${r}`,t);if(typeof a=="string"&&a.trim().length>0)return o}return"npm"}async function Da(t,e){if(e?.trim())try{const r=new URLSearchParams({path:t,directory:e,optional:"true"}),o=await As(`/api/fs/read?${r.toString()}`,{cache:"no-store"});if(o.ok)return o.text()}catch{}const n=Lo()?.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 As(`/api/fs/read?path=${encodeURIComponent(t)}&optional=true`,{cache:"no-store"});return r.ok?r.text():null}catch{return null}}async function Mb(t){try{const e=await Da(`${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 Fb=t=>new Promise(e=>{window.setTimeout(e,t)}),Lb="\x1B",Ob=new RegExp(`${Lb}\\[[0-9;?]*[ -/]*[@-~]`,"g"),Bb=/https?:\/\/[^\s<>'"`]+/gi,sr="__openchamber_auto_discover_preview__",Vb=15e3,_b=t=>{let e="";for(let n=0;n<t.length;n+=1){const r=t.charCodeAt(n);r>=0&&r<=8||r===11||r===12||r>=14&&r<=31||r===127||(e+=t[n])}return e},$b=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}},zb=t=>{const n=t.replace(Ob,"").match(Bb);if(!n||n.length===0)return null;const r=n.map(a=>a.replace(/[),.;]+$/,"")).filter(Boolean);if(r.length===0)return null;const o=[];for(const a of r)try{const c=new URL(a);c.port&&c.port.length>0&&o.push({raw:a,parsed:c})}catch{}if(o.length>0){const a=c=>{const{parsed:l}=c,d=l.hostname.toLowerCase(),u=d==="localhost"||d==="127.0.0.1"||d==="0.0.0.0"||d==="::1",m=l.pathname||"/",f=m.split("/").filter(Boolean).length,g=m==="/"||m==="",b=!!(l.search||l.hash);let p=0;return u&&(p+=50),g&&(p+=30),p-=Math.min(f*5,20),b&&(p-=10),p};return o.sort((c,l)=>a(l)-a(c)),o[0]?.parsed.origin??o[0]?.raw??null}return r[0]??null},km=({projectRef:t,directory:e,className:n,compact:r=!1,allowMobile:o=!1})=>{const{t:a}=Nt(),{terminal:c,runtime:l}=Jn(),{isMobile:d}=Er(),u=i.useMemo(()=>dr(),[]),m=Gd(z=>z.instances),f=Gd(z=>z.load),g=Ee(z=>z.setBottomTerminalOpen),b=Ee(z=>z.setActiveMainTab),p=Ee(z=>z.setSettingsPage),x=Ee(z=>z.setSettingsDialogOpen),y=Ee(z=>z.setSettingsProjectsSelectedId),h=Ee(z=>z.openContextPreview),C=Vs(z=>z.sessions),w=Vs(z=>z.ensureDirectory),S=Vs(z=>z.setTabLabel),j=Vs(z=>z.setTabIconKey),k=Vs(z=>z.setActiveTab),v=Vs(z=>z.setConnecting),A=Vs(z=>z.setTabSessionId),I=Vs(z=>z.setTabPreviewUrl),N=Vs(z=>z.projectActionRuns),O=Vs(z=>z.setProjectActionRun),P=Vs(z=>z.updateProjectActionRunStatus),T=Vs(z=>z.removeProjectActionRun),[L,R]=i.useState([]),[B,V]=i.useState(null),[_,E]=i.useState(!1),Z=i.useRef({}),ne=i.useRef({}),Y=i.useRef({}),H=i.useRef({}),re=i.useRef(0),ae=t?.id??null,me=t?.path??"",Se=i.useMemo(()=>ae?{id:ae,path:me}:null,[ae,me]);i.useEffect(()=>{u&&f().catch(()=>{})},[u,f]);const te=i.useCallback(async z=>{await Ii(z)},[]),ke=i.useCallback(async()=>{if(!Se)return;const z=re.current+1;re.current=z,E(!0);try{const xe=await kd(Se);if(re.current!==z)return;const je=xe.actions;R(je),V(K=>K===sr||K&&je.some(ye=>ye.id===K)?K:null)}catch{if(re.current!==z)return}finally{re.current===z&&E(!1)}},[Se]),Q=i.useMemo(()=>Mx(e||Se?.path||""),[e,Se?.path]),ge=i.useMemo(()=>B?L.find(z=>z.id===B)??null:null,[L,B]),F=i.useMemo(()=>({id:sr,name:a("projectActions.actions.autoDiscover"),command:"",icon:"search",autoOpenUrl:!0}),[a]),se=!d,ee=i.useMemo(()=>se?[F,...L]:L,[L,F,se]);i.useEffect(()=>{ke()},[ke]),i.useEffect(()=>{if(typeof window>"u")return;const z=xe=>{const je=xe.detail;ae&&(je?.projectId&&je.projectId!==ae||ke())};return window.addEventListener(Kd,z),()=>{window.removeEventListener(Kd,z)}},[ke,ae]),i.useEffect(()=>{B&&(B===sr&&se||L.some(z=>z.id===B)||V(null))},[L,se,B]),i.useEffect(()=>{for(const[z,xe]of Object.entries(N)){const K=C.get(xe.directory)?.tabs.find(ye=>ye.id===xe.tabId);(!K||K.terminalSessionId!==xe.sessionId)&&T(z)}},[N,T,C]),i.useEffect(()=>{for(const[z,xe]of Object.entries(N)){const je=ne.current[z]??{lastSeenChunkId:null,openedUrl:!1,tail:"",openInPreview:!1};ne.current[z]=je;const K=ee.find(Oe=>Oe.id===xe.actionId);if(!K)continue;const Le=C.get(xe.directory)?.tabs.find(Oe=>Oe.id===xe.tabId);if(!Le||!Array.isArray(Le.bufferChunks)||Le.bufferChunks.length===0)continue;const Re=Le.bufferChunks.filter(Oe=>je.lastSeenChunkId===null?!0:Oe.id>je.lastSeenChunkId);if(Re.length===0)continue;const X=Re.map(Oe=>Oe.data).join(""),M=`${je.tail}${X}`,le=!je.openedUrl&&K.autoOpenUrl===!0?zb(M):null,ie=Re[Re.length-1]?.id??je.lastSeenChunkId;if(je.lastSeenChunkId=ie,je.tail=M.slice(-512),le)if(je.openedUrl=!0,je.openInPreview){const Oe=N[z];Oe&&(I(Oe.directory,Oe.tabId,le,{locked:!1,autoOpened:!1}),Oe.status==="waiting-for-preview"&&P(z,"running"),window.clearTimeout(H.current[z]),delete H.current[z],h(Oe.directory,le))}else te(le),ce.success(a("projectActions.toast.openedUrlFromOutput"));ne.current[z]=je}for(const z of Object.keys(ne.current))N[z]||(delete ne.current[z],window.clearTimeout(H.current[z]),delete H.current[z])},[ee,h,te,N,I,a,C,P]);const Ne=i.useCallback(async(z,xe={})=>{if(!Q)throw new Error(a("projectActions.error.noActiveDirectory"));const je=Jr(Q,z.id);w(Q);const K=Vs.getState(),ye=K.getDirectoryState(Q);let Le=Z.current[je]||null;const Re=Le?!!ye?.tabs.some(le=>le.id===Le):!1;(!Le||!Re)&&(Le=K.createTab(Q),Z.current[je]=Le),S(Q,Le,`Action: ${z.name}`),j(Q,Le,z.icon||"play"),xe.revealTerminal!==!1&&(k(Q,Le),g(!0),b("terminal"));const M=Vs.getState().getDirectoryState(Q)?.tabs.find(le=>le.id===Le);return{key:je,tabId:Le,sessionId:M?.terminalSessionId??null}},[w,Q,b,k,g,j,S,a]),De=i.useCallback(async z=>{if(l.isVSCode||!o&&d)return;if(!Q){ce.error(a("projectActions.error.noActiveDirectoryForAction"));return}const xe=Jr(Q,z.id),je=N[xe];if(!(je&&je.status==="running"))try{const K=z.id===sr?await(async()=>{const[Je,rt]=await Promise.all([kd({id:Se?.id??"",path:Q}),Mb(Q)]),bt=await Db(Q,Je.actions,rt);if(!bt)throw new Error(a("contextPanel.preview.noDevServer"));return{id:sr,name:a("projectActions.actions.autoDiscover"),command:bt.command,icon:"search",autoOpenUrl:!0,openUrl:bt.previewUrlHint||""}})():z,ye=K.autoOpenUrl===!0&&(K.openUrl||"").trim().length>0,{key:Le,tabId:Re,sessionId:X}=await Ne(K,{revealTerminal:!ye&&z.id!==sr});let M=X,le=!1;if(!M){v(Q,Re,!0);try{M=(await c.createSession({cwd:Q})).sessionId,le=!0,A(Q,Re,M)}finally{v(Q,Re,!1)}}if(!M)throw new Error(a("projectActions.error.failedToCreateTerminalSession"));le&&await Fb(350),K.id===sr&&(Y.current[Le]?.(),v(Q,Re,!0),Y.current[Le]=rp(M,Je=>{Je.type==="data"&&typeof Je.data=="string"&&Je.data.length>0&&Vs.getState().appendToBuffer(Q,Re,Je.data),Je.type==="exit"&&(Vs.getState().setTabLifecycle(Q,Re,"exited"),Vs.getState().setConnecting(Q,Re,!1),Vs.getState().removeProjectActionRun(Le),delete ne.current[Le],Y.current[Le]?.(),delete Y.current[Le],window.clearTimeout(H.current[Le]),delete H.current[Le])},()=>{Vs.getState().setConnecting(Q,Re,!1)},{maxRetries:60,initialRetryDelay:250,maxRetryDelay:2e3,connectionTimeout:5e3}));const ie=K.autoOpenUrl===!0&&u&&(K.desktopOpenSshForward||"").trim().length>0,Oe=K.autoOpenUrl?$b(K.openUrl):null,Ge=K.autoOpenUrl&&u?Fx(K.desktopOpenSshForward,m):null;O({key:Le,directory:Q,actionId:K.id,tabId:Re,sessionId:M,status:K.id===sr&&!Oe?"waiting-for-preview":"running"}),window.clearTimeout(H.current[Le]),delete H.current[Le],K.id===sr&&!Oe&&(H.current[Le]=window.setTimeout(()=>{Vs.getState().updateProjectActionRunStatus(Le,"running"),delete H.current[Le]},Vb)),Ge?(I(Q,Re,null,{locked:!0}),te(Ge),ce.success(a("projectActions.toast.openedForwardedUrl"))):Oe?(I(Q,Re,Oe,{locked:!0,autoOpened:!0}),h(Q,Oe),ce.success(a("projectActions.toast.openedActionUrl"))):ye?(I(Q,Re,null,{locked:!0}),ce.error(a("projectActions.error.invalidCustomUrlFormat"))):ie?(I(Q,Re,null,{locked:!0}),ce.error(a("projectActions.error.selectedDesktopSshForwardUnavailable"))):I(Q,Re,null,{locked:!1,autoOpened:!1}),ne.current[Le]={lastSeenChunkId:null,openedUrl:!!Ge||!!Oe||ye,tail:"",openInPreview:K.id===sr};const He=_b(K.command.trim().replace(/\r\n|\r/g,`
|
|
3
3
|
`));await c.sendInput(M,`${He}\r`)}catch(K){T(xe),delete ne.current[xe],Y.current[xe]?.(),delete Y.current[xe],window.clearTimeout(H.current[xe]),delete H.current[xe],ce.error(K instanceof Error?K.message:a("projectActions.error.failedToRunAction"))}},[m,Ne,o,d,u,Q,te,h,N,l.isVSCode,T,v,O,I,A,Se?.id,a,c]),Be=i.useCallback(async z=>{const xe=Jr(Q,z.id),je=N[xe];if(!je)return;P(xe,"stopping");try{await c.sendInput(je.sessionId,"")}catch{}if(await new Promise(Le=>{window.setTimeout(Le,1e3)}),Vs.getState().getDirectoryState(je.directory)?.tabs.find(Le=>Le.id===je.tabId)?.terminalSessionId===je.sessionId){if(typeof c.forceKill=="function")try{await c.forceKill({sessionId:je.sessionId})}catch{}else try{await c.close(je.sessionId)}catch{}A(je.directory,je.tabId,null)}T(xe),delete ne.current[xe],Y.current[xe]?.(),delete Y.current[xe],window.clearTimeout(H.current[xe]),delete H.current[xe]},[Q,N,T,A,c,P]),Fe=i.useCallback(()=>{const z=ge??ee[0];if(!z)return;const xe=Jr(Q,z.id),je=N[xe];if(je?.status!=="stopping"){if(je){Be(z);return}De(z)}},[ee,Q,De,N,ge,Be]),Me=i.useCallback((z,xe=!1)=>{if(V(z.id),!xe){De(z);return}const je=Jr(Q,z.id),K=N[je];if(K?.status!=="stopping"){if(K){Be(z);return}De(z)}},[Q,De,N,Be]),he=i.useCallback(()=>{Se?.id&&(y(Se.id),p("projects"),x(!0))},[x,p,y,Se?.id]);if(l.isVSCode||!o&&d||!Se||!Q)return null;const Ae=ge??ee[0]??null;if(!Ae)return null;const pe=Ae.icon||"play",ue=Ae.id===sr?"search":al[pe]||"play",U=Jr(Q,Ae.id),fe=N[U],de=fe?.status==="stopping",G=fe?.status==="waiting-for-preview",$=fe?C.get(fe.directory)?.tabs.find(z=>z.id===fe.tabId)?.previewUrl??null:null,ve=!!(fe&&$),be=()=>{!fe||!$||h(fe.directory,$)};return r?s.jsxs("div",{className:"inline-flex items-center",children:[s.jsx("button",{type:"button",disabled:_||de,className:Pe("app-region-no-drag inline-flex h-9 w-9 items-center justify-center rounded-[10px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] p-2","typography-ui-label font-medium text-muted-foreground hover:bg-interactive-hover hover:text-foreground transition-colors","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","disabled:cursor-not-allowed",n),onClick:Fe,"aria-label":fe?a("projectActions.actions.stopNamedAria",{name:Ae.name}):a("projectActions.actions.runNamedAria",{name:Ae.name}),children:de||G?s.jsx(D,{name:"loader-4",className:"h-5 w-5 animate-spin text-[var(--status-warning)]"}):fe?s.jsx(D,{name:"stop",className:"h-5 w-5 text-[var(--status-warning)]"}):s.jsx(D,{name:ue,className:"h-5 w-5"})}),ve?s.jsxs(Et,{children:[s.jsx(Mt,{asChild:!0,children:s.jsx("button",{type:"button",className:"app-region-no-drag -ml-1 inline-flex h-9 w-7 items-center justify-center rounded-[10px] text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":a("projectActions.actions.openPreview"),onClick:be,children:s.jsx(D,{name:"global",className:"h-4 w-4"})})}),s.jsx(Ft,{sideOffset:6,children:a("projectActions.actions.openPreview")})]}):null,s.jsxs(sn,{children:[s.jsx(en,{asChild:!0,children:s.jsx("button",{type:"button",className:"app-region-no-drag -ml-1 inline-flex h-9 w-5 items-center justify-center rounded-[10px] text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":a("projectActions.actions.chooseActionAria"),children:s.jsx(D,{name:"arrow-down-s",className:"h-3.5 w-3.5"})})}),s.jsxs(tn,{align:"end",className:"w-52 max-h-[70vh] overflow-y-auto",children:[s.jsxs(bs,{className:"flex items-center gap-2",onClick:he,children:[s.jsx(D,{name:"add",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:a("projectActions.actions.addNewAction")})]}),s.jsx(Rr,{}),ee.map(z=>{const xe=z.icon||"play",je=z.id===sr?"search":al[xe]||"play",K=Jr(Q,z.id),ye=N[K],Le=!!ye,Re=ye?.status==="stopping";return s.jsxs(bs,{className:"flex items-center gap-2",onClick:()=>{Me(z,!0)},children:[s.jsx(D,{name:je,className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:z.name}),Re||ye?.status==="waiting-for-preview"?s.jsx(D,{name:"loader-4",className:"ml-auto h-4 w-4 animate-spin text-[var(--status-warning)]"}):Le?s.jsx(D,{name:"stop",className:"ml-auto h-4 w-4 text-[var(--status-warning)]"}):null]},z.id)})]})]})]}):s.jsxs("div",{className:Pe("app-region-no-drag inline-flex shrink-0 items-center self-center rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px]","bg-[var(--surface-elevated)] overflow-hidden","border border-border/60",r?"h-9":"h-7",n),children:[s.jsx("button",{type:"button",onClick:Fe,disabled:_||de,className:Pe("inline-flex h-full items-center justify-center typography-ui-label font-medium text-foreground hover:bg-interactive-hover",r?"w-9 px-0":"px-2.5","transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:cursor-not-allowed"),"aria-label":fe?a("projectActions.actions.stopNamedAria",{name:Ae.name}):a("projectActions.actions.runNamedAria",{name:Ae.name}),children:s.jsx("span",{className:"inline-flex h-4 w-4 shrink-0 items-center justify-center",children:de||G?s.jsx(D,{name:"loader-4",className:"h-4 w-4 animate-spin text-[var(--status-warning)]"}):fe?s.jsx(D,{name:"stop",className:"h-4 w-4 text-[var(--status-warning)]"}):s.jsx(D,{name:ue,className:"h-4 w-4"})})}),ve?s.jsxs(Et,{children:[s.jsx(Mt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:be,className:Pe(r?"inline-flex h-full w-8 items-center justify-center":"inline-flex h-full w-7 items-center justify-center","border-l border-[var(--interactive-border)] text-foreground","hover:bg-interactive-hover transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary"),"aria-label":a("projectActions.actions.openPreview"),children:s.jsx(D,{name:"global",className:"h-4 w-4"})})}),s.jsx(Ft,{sideOffset:6,children:a("projectActions.actions.openPreview")})]}):null,s.jsxs(sn,{children:[s.jsx(en,{asChild:!0,children:s.jsx("button",{type:"button",className:Pe(r?"inline-flex h-full w-8 items-center justify-center":"inline-flex h-full w-7 items-center justify-center","border-l border-[var(--interactive-border)] text-muted-foreground","hover:bg-interactive-hover hover:text-foreground transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary"),"aria-label":a("projectActions.actions.chooseActionAria"),children:s.jsx(D,{name:"arrow-down-s",className:"h-4 w-4"})})}),s.jsxs(tn,{align:"start",className:"w-52 max-h-[70vh] overflow-y-auto",children:[s.jsxs(bs,{className:"flex items-center gap-2",onClick:he,children:[s.jsx(D,{name:"add",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:a("projectActions.actions.addNewAction")})]}),s.jsx(Rr,{}),ee.map(z=>{const xe=z.icon||"play",je=z.id===sr?"search":al[xe]||"play",K=Jr(Q,z.id),ye=N[K],Le=!!ye,Re=ye?.status==="stopping";return s.jsxs(bs,{className:"flex items-center gap-2",onClick:()=>{Me(z,!0)},children:[s.jsx(D,{name:je,className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:z.name}),Re||ye?.status==="waiting-for-preview"?s.jsx(D,{name:"loader-4",className:"ml-auto h-4 w-4 animate-spin text-[var(--status-warning)]"}):Le?s.jsx(D,{name:"stop",className:"ml-auto h-4 w-4 text-[var(--status-warning)]"}):null]},z.id)})]})]})]})},qa="app-region-no-drag inline-flex h-8 w-8 items-center justify-center gap-2 rounded-md typography-ui-label font-medium text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:pointer-events-none disabled:opacity-50 hover:bg-interactive-hover transition-colors",Wb="app-region-no-drag inline-flex h-9 w-9 items-center justify-center gap-2 p-2 rounded-md typography-ui-label font-medium text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:pointer-events-none disabled:opacity-50 hover:text-foreground hover:bg-interactive-hover transition-colors",Uo=i.memo(function(e){const n=mt.c(17),{visible:r,title:o,ariaLabel:a,onClick:c,className:l,Icon:d,iconClassName:u,pressed:m}=e,f=r===void 0?!0:r,g=m===void 0?!1:m;if(!f)return null;const b=l??qa,p=g&&"bg-interactive-selection text-interactive-selection-foreground";let x;n[0]!==b||n[1]!==p?(x=Pe(b,p),n[0]=b,n[1]=p,n[2]=x):x=n[2];const y=u??"h-[18px] w-[18px]";let h;n[3]!==d||n[4]!==y?(h=s.jsx(D,{name:d,className:y}),n[3]=d,n[4]=y,n[5]=h):h=n[5];let C;n[6]!==a||n[7]!==c||n[8]!==g||n[9]!==x||n[10]!==h?(C=s.jsx(Mt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:c,"aria-label":a,"aria-pressed":g,className:x,children:h})}),n[6]=a,n[7]=c,n[8]=g,n[9]=x,n[10]=h,n[11]=C):C=n[11];let w;n[12]!==o?(w=s.jsx(Ft,{children:s.jsx("p",{children:o})}),n[12]=o,n[13]=w):w=n[13];let S;return n[14]!==C||n[15]!==w?(S=s.jsxs(Et,{children:[C,w]}),n[14]=C,n[15]=w,n[16]=S):S=n[16],S}),Ub=i.memo(function(e){const n=mt.c(42),{isMobile:r,githubAuthStatus:o,githubAccounts:a,githubAvatarUrl:c,githubLogin:l,isSwitchingGitHubAccount:d,handleGitHubAccountSwitch:u}=e,{t:m}=Nt();if(!o?.connected||r)return null;if(a.length>1){let p;n[0]===Symbol.for("react.memo_cache_sentinel")?(p=Pe(qa,"h-7 w-7 overflow-hidden rounded-full border border-border/60 bg-muted/80 p-0"),n[0]=p):p=n[0];let x;n[1]!==l||n[2]!==m?(x=l?m("header.github.connectedWithLogin",{login:l}):m("header.github.connected"),n[1]=l,n[2]=m,n[3]=x):x=n[3];let y;n[4]!==c||n[5]!==l||n[6]!==m?(y=c?s.jsx("img",{src:c,alt:l?m("header.github.avatarWithLogin",{login:l}):m("header.github.avatar"),className:"h-full w-full object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):s.jsx(D,{name:"github-fill",className:"h-3.5 w-3.5 text-foreground"}),n[4]=c,n[5]=l,n[6]=m,n[7]=y):y=n[7];let h;n[8]!==d||n[9]!==x||n[10]!==y?(h=s.jsx(en,{asChild:!0,children:s.jsx("button",{type:"button",className:p,title:x,disabled:d,children:y})}),n[8]=d,n[9]=x,n[10]=y,n[11]=h):h=n[11];let C;n[12]!==m?(C=m("header.github.accountsTitle"),n[12]=m,n[13]=C):C=n[13];let w;n[14]!==C?(w=s.jsx(Np,{className:"typography-ui-header font-semibold text-foreground",children:C}),n[14]=C,n[15]=w):w=n[15];let S;n[16]===Symbol.for("react.memo_cache_sentinel")?(S=s.jsx(Rr,{}),n[16]=S):S=n[16];let j;if(n[17]!==a||n[18]!==u||n[19]!==d||n[20]!==m){let A;n[22]!==u||n[23]!==d||n[24]!==m?(A=I=>{const N=I.user,O=!!I.current,P=I.source==="gh-cli"?m("header.github.accountSource.cli"):m("header.github.accountSource.oauth");return s.jsxs(bs,{className:"gap-2",disabled:d,onSelect:()=>{O||u(I.id)},children:[N?.avatarUrl?s.jsx("img",{src:N.avatarUrl,alt:N.login?m("header.github.avatarWithLogin",{login:N.login}):m("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(D,{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:N?.name?.trim()||N?.login||"GitHub"}),N?.login?s.jsxs("span",{className:"truncate typography-micro text-muted-foreground",children:[s.jsx("span",{className:"font-mono",children:N.login}),s.jsx("span",{className:"mx-1 opacity-50",children:"·"}),s.jsx("span",{children:P})]}):null]}),O?s.jsx(D,{name:"check",className:"h-4 w-4 text-primary"}):null]},I.id)},n[22]=u,n[23]=d,n[24]=m,n[25]=A):A=n[25],j=a.map(A),n[17]=a,n[18]=u,n[19]=d,n[20]=m,n[21]=j}else j=n[21];let k;n[26]!==w||n[27]!==j?(k=s.jsxs(tn,{align:"end",className:"w-64",children:[w,S,j]}),n[26]=w,n[27]=j,n[28]=k):k=n[28];let v;return n[29]!==h||n[30]!==k?(v=s.jsxs(sn,{children:[h,k]}),n[29]=h,n[30]=k,n[31]=v):v=n[31],v}let f;n[32]!==l||n[33]!==m?(f=l?m("header.github.connectedWithLogin",{login:l}):m("header.github.connected"),n[32]=l,n[33]=m,n[34]=f):f=n[34];let g;n[35]!==c||n[36]!==l||n[37]!==m?(g=c?s.jsx("img",{src:c,alt:l?m("header.github.avatarWithLogin",{login:l}):m("header.github.avatar"),className:"h-full w-full object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):s.jsx(D,{name:"github-fill",className:"h-3.5 w-3.5 text-foreground"}),n[35]=c,n[36]=l,n[37]=m,n[38]=g):g=n[38];let b;return n[39]!==f||n[40]!==g?(b=s.jsx("div",{className:"app-region-no-drag flex h-7 w-7 items-center justify-center overflow-hidden rounded-full border border-border/60 bg-muted/80",title:f,children:g}),n[39]=f,n[40]=g,n[41]=b):b=n[41],b}),Hb=i.memo(function(e){const n=mt.c(84),{isDesktopApp:r,currentInstanceLabel:o,compactCurrentInstanceLabel:a,currentInstanceIsLocal:c,isDesktopServicesOpen:l,setIsDesktopServicesOpen:d,refreshCurrentInstanceLabel:u,desktopServicesTab:m,setDesktopServicesTab:f,quotaResultsLength:g,fetchAllQuotas:b,servicesTabItems:p,quotaLastUpdated:x,quotaDisplayMode:y,quotaDisplayTabItems:h,handleDisplayModeChange:C,handleUsageRefresh:w,isQuotaLoading:S,isUsageRefreshSpinning:j,hasRateLimits:k,rateLimitGroups:v,expandedFamilies:A,toggleFamilyExpanded:I,shortcutLabel:N,showDevShutdown:O,isDevShutdownInFlight:P,onDevShutdown:T,remoteUpdateInfo:L,remoteUpdateChecking:R,remoteUpdateError:B,onOpenRemoteUpdate:V,showPredValues:_,timeFormatPreference:E}=e,{t:Z}=Nt();let ne;n[0]!==m||n[1]!==b||n[2]!==g||n[3]!==u||n[4]!==d?(ne=Me=>{d(Me),Me&&(u(),m==="usage"&&g===0&&b())},n[0]=m,n[1]=b,n[2]=g,n[3]=u,n[4]=d,n[5]=ne):ne=n[5];let Y;n[6]!==o||n[7]!==r||n[8]!==Z?(Y=r?Z("header.services.openWithCurrent",{current:o}):Z("header.services.open"),n[6]=o,n[7]=r,n[8]=Z,n[9]=Y):Y=n[9];const H=r?"w-auto max-w-[14rem] justify-start gap-1.5 px-2.5":"h-8 w-8";let re;n[10]!==H?(re=Pe(qa,H),n[10]=H,n[11]=re):re=n[11];let ae;n[12]===Symbol.for("react.memo_cache_sentinel")?(ae=s.jsx(D,{name:"stack",className:"h-[18px] w-[18px]"}),n[12]=ae):ae=n[12];let me;n[13]!==a||n[14]!==r?(me=r?s.jsx("span",{className:"truncate typography-ui-label font-medium text-foreground",children:a}):null,n[13]=a,n[14]=r,n[15]=me):me=n[15];let Se;n[16]!==Y||n[17]!==re||n[18]!==me?(Se=s.jsx(Mt,{asChild:!0,children:s.jsx(en,{asChild:!0,children:s.jsxs("button",{type:"button","aria-label":Y,className:re,children:[ae,me]})})}),n[16]=Y,n[17]=re,n[18]=me,n[19]=Se):Se=n[19];let te;n[20]!==o||n[21]!==r||n[22]!==N||n[23]!==Z?(te=r?Z("header.services.tooltip.currentInstanceWithShortcuts",{current:o,toggle:N("toggle_services_menu"),nextTab:N("cycle_services_tab")}):Z("header.services.tooltip.servicesWithShortcuts",{toggle:N("toggle_services_menu"),nextTab:N("cycle_services_tab")}),n[20]=o,n[21]=r,n[22]=N,n[23]=Z,n[24]=te):te=n[24];let ke;n[25]!==te?(ke=s.jsx(Ft,{children:s.jsx("p",{children:te})}),n[25]=te,n[26]=ke):ke=n[26];let Q;n[27]!==Se||n[28]!==ke?(Q=s.jsxs(Et,{children:[Se,ke]}),n[27]=Se,n[28]=ke,n[29]=Q):Q=n[29];let ge;n[30]!==b||n[31]!==g||n[32]!==f?(ge=Me=>{const he=Me;f(he),he==="usage"&&g===0&&b()},n[30]=b,n[31]=g,n[32]=f,n[33]=ge):ge=n[33];let F;n[34]!==m||n[35]!==p||n[36]!==ge?(F=s.jsx("div",{className:"sticky top-0 z-20 px-2 pt-1.5 pb-px",children:s.jsx("div",{className:"h-9",children:s.jsx(To,{items:p,activeId:m,onSelect:ge,layoutMode:"fit",variant:"active-pill",activePillInsetClassName:"gap-0.5 px-px py-0",activePillButtonClassName:"h-8",className:"h-full"})})}),n[34]=m,n[35]=p,n[36]=ge,n[37]=F):F=n[37];let se;n[38]!==c||n[39]!==m||n[40]!==r||n[41]!==l||n[42]!==V||n[43]!==R||n[44]!==B||n[45]!==L||n[46]!==d||n[47]!==Z?(se=r&&m==="instance"?s.jsxs("div",{children:[c?null:s.jsx("div",{className:"border-b border-[var(--interactive-border)] px-4 py-2.5",children:s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"typography-ui-label font-medium text-foreground",children:Z("header.services.remoteUpdate.title")}),s.jsx("div",{className:"typography-micro text-muted-foreground",children:L?.available?Z("header.services.remoteUpdate.available",{version:L.version||""}):R?Z("header.services.remoteUpdate.checking"):B||Z("header.services.remoteUpdate.upToDate")})]}),L?.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:V,children:Z("header.services.remoteUpdate.actions.open")}):null]})}),s.jsx(Sp,{embedded:!0,open:l&&m==="instance",onOpenChange:qb,onHostSwitched:()=>d(!1)})]}):null,n[38]=c,n[39]=m,n[40]=r,n[41]=l,n[42]=V,n[43]=R,n[44]=B,n[45]=L,n[46]=d,n[47]=Z,n[48]=se):se=n[48];let ee;n[49]!==m||n[50]!==l?(ee=m==="mcp"?s.jsx(hm,{active:l&&m==="mcp"}):null,n[49]=m,n[50]=l,n[51]=ee):ee=n[51];let Ne;n[52]!==m||n[53]!==A||n[54]!==C||n[55]!==w||n[56]!==k||n[57]!==S||n[58]!==j||n[59]!==y||n[60]!==h||n[61]!==x||n[62]!==v||n[63]!==_||n[64]!==Z||n[65]!==E||n[66]!==I?(Ne=m==="usage"?s.jsxs("div",{className:"overflow-x-hidden",children:[s.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-[var(--interactive-border)] px-4 py-2.5",children:[s.jsxs("div",{className:"flex min-w-0 items-baseline gap-2",children:[s.jsx("span",{className:"typography-ui-header font-semibold text-foreground",children:Z("header.services.rateLimits")}),s.jsx("span",{className:"truncate typography-micro text-muted-foreground",children:Cm(x,E)})]}),s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("div",{className:"h-7 w-[10.5rem]",children:s.jsx(To,{items:h,activeId:y,onSelect:Me=>{C(Me)},layoutMode:"fit",variant:"active-pill",activePillInsetClassName:"gap-0.5 px-px py-0",className:"h-full"})}),s.jsx("button",{type:"button",className:Pe("inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors","hover:text-foreground hover:bg-interactive-hover","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary"),onClick:w,disabled:S||j,"aria-label":Z("header.services.refreshRateLimitsAria"),children:s.jsx(D,{name:"refresh",className:Pe("h-4 w-4",j&&"animate-spin")})})]})]}),k?null:s.jsx("div",{className:"px-4 py-5 text-center",children:s.jsx("span",{className:"typography-ui-label text-muted-foreground",children:Z("header.services.noRateLimits")})}),s.jsx("div",{className:"py-2",children:v.map((Me,he)=>{const Ae=A[Me.providerId]??[];return s.jsxs(i.Fragment,{children:[he>0?s.jsx("div",{className:"mx-4 my-2 border-t border-[var(--interactive-border)]"}):null,s.jsxs("div",{className:"flex items-center gap-2 px-4 py-2",children:[s.jsx(Do,{providerId:Me.providerId,className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label font-medium text-foreground",children:Me.providerName})]}),Me.entries.length===0&&(!Me.modelFamilies||Me.modelFamilies.length===0)?s.jsx("div",{className:"px-4 pb-2",children:s.jsx("span",{className:"typography-ui-label text-muted-foreground",children:Me.error??Z("header.services.noRateLimitsReported")})}):s.jsxs("div",{className:"space-y-3 px-4 pb-2",children:[Me.entries.map(pe=>{const[ue,U]=pe,fe=y==="remaining"?U.remainingPercent:U.usedPercent,de=va(U.usedPercent,U.resetAt,U.windowSeconds,ue),G=de?.dailyAllocationPercent!=null?y==="remaining"?100-ri(de.elapsedRatio):ri(de.elapsedRatio):null,$=Io(U.valueLabel,fe),ve=Bf(U.resetAt,U.resetAfterFormatted??U.resetAtFormatted,E);return s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0 flex items-center gap-2",children:[s.jsx("span",{className:"truncate typography-ui-label text-foreground",children:gc(ue)}),ve?s.jsx("span",{className:"truncate typography-micro text-muted-foreground",children:ve}):null]}),s.jsx("span",{className:"typography-ui-label tabular-nums text-foreground",children:$==="-"?"":$})]}),s.jsx(Ca,{percent:fe,tonePercent:U.usedPercent,className:"h-1.5",expectedMarkerPercent:G}),de&&_?s.jsx(Aa,{paceInfo:de,compact:!0}):null]},`${Me.providerId}-${ue}`)}),Me.modelFamilies&&Me.modelFamilies.length>0?s.jsx("div",{className:"space-y-0.5",children:Me.modelFamilies.map(pe=>{const ue=pe.familyId??"other",U=Ae.includes(ue);return s.jsxs(eo,{open:U,onOpenChange:()=>I(Me.providerId,ue),children:[s.jsxs(Bo,{className:"flex w-full items-center justify-between rounded-md px-1 py-1.5 text-left hover:bg-[var(--interactive-hover)]/50 transition-colors",children:[s.jsx("span",{className:"typography-ui-label font-medium text-foreground",children:pe.familyLabel}),U?s.jsx(D,{name:"arrow-down-s",className:"h-4 w-4 text-muted-foreground"}):s.jsx(D,{name:"arrow-right-s",className:"h-4 w-4 text-muted-foreground"})]}),s.jsx(to,{children:s.jsx("div",{className:"space-y-2.5 pb-1 pl-1 pt-1",children:pe.models.map(fe=>{const[de,G]=fe,$=y==="remaining"?G.remainingPercent:G.usedPercent,ve=va(G.usedPercent,G.resetAt,G.windowSeconds),be=ve?.dailyAllocationPercent!=null?y==="remaining"?100-ri(ve.elapsedRatio):ri(ve.elapsedRatio):null,z=Io(G.valueLabel,$);return s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-3",children:[s.jsx("span",{className:"truncate typography-micro text-muted-foreground",children:mm(de)}),s.jsx("span",{className:"typography-ui-label tabular-nums text-foreground",children:z==="-"?"":z})]}),s.jsx(Ca,{percent:$,tonePercent:G.usedPercent,className:"h-1.5",expectedMarkerPercent:be}),ve&&_?s.jsx(Aa,{paceInfo:ve,compact:!0}):null]},`${Me.providerId}-${de}`)})})})]},ue)})}):null]})]},Me.providerId)})})]}):null,n[52]=m,n[53]=A,n[54]=C,n[55]=w,n[56]=k,n[57]=S,n[58]=j,n[59]=y,n[60]=h,n[61]=x,n[62]=v,n[63]=_,n[64]=Z,n[65]=E,n[66]=I,n[67]=Ne):Ne=n[67];let De;n[68]!==P||n[69]!==T||n[70]!==O||n[71]!==Z?(De=O?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"mx-4 my-2 border-t border-[var(--interactive-border)]"}),s.jsx("div",{className:"px-2 pb-2",children:s.jsx(bs,{disabled:P,onSelect:()=>{T()},children:Z("header.services.shutdownDev")})})]}):null,n[68]=P,n[69]=T,n[70]=O,n[71]=Z,n[72]=De):De=n[72];let Be;n[73]!==F||n[74]!==se||n[75]!==ee||n[76]!==Ne||n[77]!==De?(Be=s.jsxs(tn,{align:"end",className:"w-[min(27rem,calc(100vw-2rem))] max-h-[75vh] overflow-y-auto bg-[var(--surface-elevated)] p-0",children:[F,se,ee,Ne,De]}),n[73]=F,n[74]=se,n[75]=ee,n[76]=Ne,n[77]=De,n[78]=Be):Be=n[78];let Fe;return n[79]!==l||n[80]!==ne||n[81]!==Q||n[82]!==Be?(Fe=s.jsxs(sn,{open:l,onOpenChange:ne,children:[Q,Be]}),n[79]=l,n[80]=ne,n[81]=Q,n[82]=Be,n[83]=Fe):Fe=n[83],Fe}),Gb=(t,e)=>t===e?!0:!t||!e?!1:t.totalTokens===e.totalTokens&&t.percentage===e.percentage&&t.contextLimit===e.contextLimit&&(t.outputLimit??0)===(e.outputLimit??0)&&(t.normalizedOutput??0)===(e.normalizedOutput??0)&&t.thresholdLimit===e.thresholdLimit&&(t.lastMessageId??"")===(e.lastMessageId??""),Kb=t=>{const e=t.trim();if(!e)return"";const n=e.split(/\s+/).filter(Boolean);if(n.length>=2){const r=n[0],o=n[1].slice(0,3),a=`${r} ${o}`.trim();return n.length>2||a.length<e.length?`${a}...`:a}return e.length>12?`${e.slice(0,9).trimEnd()}...`:e},Cm=(t,e)=>{if(!t)return"-";try{return Vf(t,e,{fallback:"-"})}catch{return"-"}},In=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},ei=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,Zd=({onToggleLeftDrawer:t,onToggleRightDrawer:e,leftDrawerOpen:n,rightDrawerOpen:r})=>{const{t:o}=Nt(),a=Ee(J=>J.setSessionSwitcherOpen),c=Ee(J=>J.toggleSidebar),l=Ee(J=>J.isSidebarOpen),d=Ee(J=>J.toggleBottomTerminal),u=Ee(J=>J.toggleRightSidebar),m=Ee(J=>J.openContextOverview),f=Ee(J=>J.openContextPlan),g=Ee(J=>J.openContextBrowser),b=Ee(J=>J.openContextPanelTab),p=Ee(J=>J.closeContextPanel),x=Ee(J=>J.contextPanelByDirectory),y=Ee(J=>J.activeMainTab),h=Ee(J=>J.setActiveMainTab),C=Ee(J=>J.shortcutOverrides),w=Ee(J=>J.timeFormatPreference),S=ss(J=>J.getCurrentModel),j=Jn(),[k,v]=i.useState(!1),A=ut(J=>J.getContextUsage),I=ut(J=>!!J.newSessionDraft?.open),N=ut(J=>J.currentSessionId),O=kp(N??""),P=_f(N??null),T=vr(J=>J.activeSessions),L=xc(),R=ws(J=>J.activeProjectId?J.projects.find(st=>st.id===J.activeProjectId)??null:null),B=i.useMemo(()=>{if(!R)return null;const J=R.label?.trim();if(J)return J;const st=R.path.split(/[\\/]/).filter(Boolean);return st[st.length-1]??null},[R]),V=mn(J=>J.results),_=mn(J=>J.fetchAllQuotas),E=mn(J=>J.isLoading),Z=mn(J=>J.lastUpdated),ne=mn(J=>J.displayMode),Y=mn(J=>J.showPredValues),H=mn(J=>J.dropdownProviderIds),re=mn(J=>J.loadSettings),ae=mn(J=>J.setDisplayMode),{isMobile:me}=Er(),Se=Pi(J=>J.status),te=Pi(J=>J.setStatus),ke=i.useRef(null),[Q,ge]=i.useState(()=>typeof window>"u"?!1:dr()),F=i.useMemo(()=>Fa(),[]),se=$f(),[ee,Ne]=i.useState(!1),De=i.useMemo(()=>typeof navigator>"u"?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||""),[]),Be=i.useMemo(()=>typeof window>"u"?!1:!!window.__OPENCHAMBER_ELECTRON__&&window.__OPENCHAMBER_PLATFORM__==="win32",[]),Fe=i.useMemo(()=>{if(typeof window>"u")return null;const J=window.__OPENCHAMBER_MACOS_MAJOR__;if(typeof J=="number"&&Number.isFinite(J)&&J>0)return J;if(typeof navigator>"u")return null;const st=(navigator.userAgent||"").match(/Mac OS X (\d+)[._](\d+)/);if(!st)return null;const gt=Number.parseInt(st[1],10),Pt=Number.parseInt(st[2],10);return Number.isNaN(gt)?null:gt===10?Pt:gt},[]);Xe.useEffect(()=>{typeof window>"u"||ge(dr())},[]);const Me=S(),he=Me&&typeof Me.limit=="object"&&Me.limit!==null?Me.limit:null,Ae=he&&typeof he.context=="number"?he.context:0,pe=he&&typeof he.output=="number"?he.output:0,ue=A(Ae,pe),[U,fe]=i.useState(null),de=!N||O;Xe.useEffect(()=>{if(!N){fe(J=>J===null?J:null);return}if(ue&&ue.totalTokens>0){fe(J=>Gb(J,ue)?J:ue);return}de&&fe(J=>J===null?J:null)},[ue,N,de]);const G=Ee(J=>J.isSessionSwitcherOpen),$=Se?.connected?Se.user?.avatarUrl??null:null,ve=Se?.connected?Se.user?.login??null:null,be=Se?.accounts??[],[z,xe]=i.useState(!1),[je,K]=i.useState(!1),[ye,Le]=i.useState(!1),[Re,X]=i.useState(!1),[M,le]=i.useState("Local"),[ie,Oe]=i.useState(!0),[Ge,He]=i.useState(!1),[Je,rt]=i.useState(null),[bt,yt]=i.useState(!1),[_e,Ye]=i.useState(null),nt=i.useMemo(()=>Kb(M),[M]),[wt,kt]=i.useState(Q?"instance":"usage"),[vt,St]=i.useState("usage");Xe.useEffect(()=>{!Q&&wt==="instance"&&kt("usage")},[wt,Q]);const et=i.useMemo(()=>Gr(),[]),Ot=!et&&y==="chat"&&!!U&&U.totalTokens>0,ns=U&&U.contextLimit>0?Math.min(999,U.totalTokens/U.contextLimit*100):0,Wt=i.useCallback(async()=>{if(!(typeof window>"u"||!Q))try{if(Ji()){le("Local"),Oe(!0);return}Oe(!1);const J=await zf(),st=window.__OPENCHAMBER_LOCAL_ORIGIN__||window.location.origin,gt=Wr();if(gt&&ja(gt,st)){le("Local"),Oe(!0);return}const Pt=J.hosts.find(Zt=>gt?ja(gt,Wf(Zt)):!1);if(Pt?.label?.trim()){le(Uf(Pt.label.trim()));return}le("Instance")}catch{le("Local"),Oe(!0)}},[Q]);Xe.useEffect(()=>{Wt()},[Wt]);const Ve=i.useCallback(async()=>{if(ie){rt(null),Ye(null);return}yt(!0),Ye(null);try{const J=new URLSearchParams({appType:"web",instanceMode:"remote"}),st=await As(`/api/openchamber/update-check?${J.toString()}`,{method:"GET",headers:{Accept:"application/json"}});if(!st.ok)throw new Error(`Server responded with ${st.status}`);const gt=await st.json();rt({available:gt.available??!1,version:gt.version,currentVersion:gt.currentVersion??"unknown",body:gt.body,nextSuggestedCheckInSec:typeof gt.nextSuggestedCheckInSec=="number"?gt.nextSuggestedCheckInSec:void 0,packageManager:gt.packageManager,updateCommand:gt.updateCommand})}catch(J){rt(null),Ye(J instanceof Error?J.message:o("header.services.remoteUpdate.error"))}finally{yt(!1)}},[ie,o]);i.useEffect(()=>{rt(null),Ye(null),He(!1)},[ie,M]),i.useEffect(()=>{if(!Q||ie)return;const J=3e3,st=3600*1e3;let gt=!1,Pt=null;const Zt=is=>{Pt=window.setTimeout(()=>{if(gt||typeof document<"u"&&document.visibilityState!=="visible"){Zt(st);return}Ve().finally(()=>{gt||Zt(st)})},is)};return Zt(J),()=>{gt=!0,Pt!==null&&window.clearTimeout(Pt)}},[Ve,ie,M,Q]);const Ze=i.useCallback(()=>{if(Je?.available){He(!0);return}Ve()},[Ve,Je?.available]);Lx();const _t=mn(J=>J.selectedModels),jt=mn(J=>J.expandedFamilies),xt=mn(J=>J.toggleFamilyExpanded),rs=i.useMemo(()=>{const J=[];for(const st of pm){if(!H.includes(st.id))continue;const gt=V.find(Fs=>Fs.providerId===st.id),Pt=gt?.usage?.windows??{},Zt=gt?.usage?.models,is=Object.entries(Pt),ms={providerId:st.id,providerName:st.name,entries:is,error:gt&&!gt.ok&>.configured?gt.error:void 0};if(Zt&&Object.keys(Zt).length>0){const Fs=_t[st.id]??[],qs=Fs.length>0,er=Ox(Zt,st.id),qn=Bx(st.id),Fr=Vx(qn);ms.modelFamilies=[];for(const gn of Fr){const tr=er.get(gn.id)??[];if(tr.length===0)continue;const xn=qs?tr.filter(bn=>Fs.includes(bn)):tr;if(xn.length===0)continue;const Mn=[];for(const bn of xn){const or=Zt[bn];if(or?.windows){const Cn=Object.entries(or.windows);Cn.length>0&&Mn.push([bn,Cn[0][1]])}}Mn.length>0&&ms.modelFamilies.push({familyId:gn.id,familyLabel:gn.label,models:Mn})}const Bs=er.get(null)??[],Lr=qs?Bs.filter(gn=>Fs.includes(gn)):Bs;if(Lr.length>0){const gn=[];for(const tr of Lr){const xn=Zt[tr];if(xn?.windows){const Mn=Object.entries(xn.windows);Mn.length>0&&gn.push([tr,Mn[0][1]])}}gn.length>0&&ms.modelFamilies.push({familyId:null,familyLabel:o("header.services.modelFamily.other"),models:gn})}}(is.length>0||ms.modelFamilies&&ms.modelFamilies.length>0||ms.error)&&J.push(ms)}return J},[H,V,_t,o]),Gt=rs.length>0;i.useEffect(()=>{re()},[re]);const Ut=i.useCallback(async J=>{ae(J);try{await fc({usageDisplayMode:J})}catch(st){console.warn("Failed to update usage display mode:",st)}},[ae]),as=i.useCallback(()=>{if(Re)return;X(!0);const J=new Promise(st=>setTimeout(st,500));Promise.all([_(),J]).finally(()=>{X(!1)})},[_,Re]),Bt=i.useMemo(()=>N?L.find(J=>J.id===N)??T.find(J=>J.id===N)??P??Hf().find(J=>J.id===N)??null:null,[N,P,T,L]),Lt=i.useRef(null),[Vt,Kt]=i.useState(0);i.useEffect(()=>{if(!N){Lt.current&&(Lt.current=null,Kt(Pt=>Pt+1));return}if(Bt){Lt.current={sessionId:N,session:Bt,expiresAt:Date.now()+2e3};return}const J=Lt.current;if(!J||J.sessionId!==N)return;const st=J.expiresAt-Date.now();if(st<=0){Lt.current=null,Kt(Pt=>Pt+1);return}const gt=window.setTimeout(()=>{Lt.current?.sessionId===N&&(Lt.current=null),Kt(Pt=>Pt+1)},st);return()=>{window.clearTimeout(gt)}},[N,Bt]);const Xt=(()=>{if(Bt)return Bt;if(!N)return null;const J=Lt.current;return J&&J.sessionId===N&&J.expiresAt>Date.now()?J.session:null})(),Qt=ut(J=>N?J.worktreeMetadata.get(N)?.path??"":""),vs=ut(J=>N?J.worktreeMetadata.get(N)?.branch?.trim()??null:null),Dt=Gf(J=>N?J.getAttachment(N):void 0),$t=i.useMemo(()=>Dt?Cp(Dt,{pending:o("gitView.empty.worktreeSetupInProgress")}):null,[o,Dt]),Ct=i.useMemo(()=>Dt?Dt.legacy?"legacy":Dt.degraded?"degraded":Dt.worktreeStatus==="pending"?"pending":Dt.worktreeStatus==="missing"?"missing":Dt.worktreeStatus==="invalid"?"invalid":Dt.attentionReason?"attention":null:null,[Dt]),ds=i.useMemo(()=>In(Qt||""),[Qt]),qe=i.useMemo(()=>{const J=typeof Xt?.directory=="string"?Xt.directory:"";return In(J||"")},[Xt?.directory]),at=ut(J=>J.newSessionDraft?.open?In(J.newSessionDraft.bootstrapPendingDirectory??J.newSessionDraft.directoryOverride??""):""),Qe=i.useMemo(()=>ds||qe||at,[at,qe,ds]),At=ut(J=>{const st=In(ds||qe||"");if(!st)return null;for(const gt of J.availableWorktreesByProject.values()){const Zt=gt.find(is=>In(is.path)===st)?.branch?.trim();if(Zt)return Zt}return null}),ts=Ap(Qe||null)||vs||At,xs=i.useMemo(()=>{if(!N)return B??"OpenChamber";const J=Xt?.title?.trim();return J&&J.length>0?J:"Untitled Session"},[B,Xt?.title,N]),ks=i.useMemo(()=>In(Qe||R?.path||""),[R?.path,Qe]),Jt=i.useMemo(()=>R?{id:R.id,path:R.path}:null,[R]),ls=i.useRef(null);i.useEffect(()=>{!Jt||!ks||(ls.current={projectRef:Jt,directory:ks})},[ks,Jt]);const Ps=i.useMemo(()=>Jt&&ks?{projectRef:Jt,directory:ks}:ls.current,[ks,Jt]),Ts=bc(J=>J.planModeEnabled),hn=ut(J=>J.isSessionPlanAvailable),Gs=Ts&&N?hn(N):!1,an=Gs,Rn=i.useRef("");i.useEffect(()=>{if(!Ts){Ee.getState().activeMainTab==="plan"&&Ee.getState().setActiveMainTab("chat");return}if(!N)return;const J=`${N||"none"}:${qe||"none"}:${Xt?.time?.created||0}:${Xt?.slug||"none"}`;Rn.current!==J&&(Rn.current=J),!Gs&&Ee.getState().activeMainTab==="plan"&&Ee.getState().setActiveMainTab("chat")},[Ts,Gs,Xt?.slug,Xt?.time?.created,N,qe]);const Os=i.useCallback(async J=>{if(!(!J||z)){xe(!0);try{const st=j.github?await j.github.authActivate(J):await(async()=>{const gt=await As("/api/github/auth/activate",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({accountId:J})}),Pt=await gt.json().catch(()=>null);if(!gt.ok||!Pt)throw new Error(Pt?.error||gt.statusText);return Pt})();te(st)}catch(st){console.error("Failed to switch GitHub account:",st)}finally{xe(!1)}}},[z,j.github,te]),we=i.useCallback(()=>{if(typeof document>"u")return;const J=document.activeElement;if(!J)return;const st=J.tagName;(st==="INPUT"||st==="TEXTAREA"||st==="SELECT"||J.isContentEditable)&&J.blur()},[]),tt=i.useCallback(()=>{if(me){we(),a(!G);return}c()},[we,me,G,a,c]),dt=i.useCallback(()=>{Ur("desktop_open_draft_mini_chat_window",{directory:In(Qe||R?.path||""),projectId:R?.id??null,apiBaseUrl:Wr(),clientToken:zl()}).catch(J=>{console.warn("[header] failed to open draft mini chat window",J)})},[R?.id,R?.path,Qe]),It=i.useCallback(()=>{if(I){dt();return}N&&Ur("desktop_open_session_mini_chat_window",{sessionId:N,directory:In(Qe||R?.path||""),apiBaseUrl:Wr(),clientToken:zl()}).catch(J=>{console.warn("[header] failed to open session mini chat window",J)})},[R?.path,N,dt,I,Qe]),Ht=i.useCallback(()=>{const J=In(Qe||"");if(!J)return;const st=x[J];if(ei(st)==="context"){p(J);return}m(J)},[p,x,m,Qe]),ht=i.useMemo(()=>{const J=In(Qe||"");if(!J)return!1;const st=x[J];return ei(st)==="context"},[x,Qe]),hs=i.useCallback(()=>{const J=In(Qe||"");if(!J)return;const st=x[J];if(ei(st)==="plan"){p(J);return}f(J)},[p,x,f,Qe]),ps=i.useCallback(()=>{const J=In(Qe||"");if(!J)return;const st=x[J];if(ei(st)==="diff"){p(J);return}b(J,{mode:"diff",stagedDiff:!1})},[p,x,b,Qe]),js=i.useCallback(()=>{const J=In(Qe||"");if(!J)return;const st=x[J];if(ei(st)==="browser"){p(J);return}g(J)},[p,x,g,Qe]),Ss=i.useMemo(()=>{const J=In(Qe||"");if(!J)return!1;const st=x[J];return ei(st)==="plan"},[x,Qe]),Ds=i.useMemo(()=>{const J=In(Qe||"");if(!J)return!1;const st=x[J];return ei(st)==="diff"},[x,Qe]),Un=i.useMemo(()=>{const J=In(Qe||"");if(!J)return!1;const st=x[J];return ei(st)==="browser"},[x,Qe]),Es=qa,En=Wb,Hn=i.useMemo(()=>je?"services":n?"sessions":r?"git":y,[y,je,n,r]),Xn=i.useCallback(()=>{K(!1),n&&t&&t(),r&&e&&e(),!t&&G&&a(!1)},[G,n,t,e,r,a]),Ue=i.useCallback(()=>{n||K(!1),t?.()},[n,t]),os=i.useCallback(()=>{r||K(!1),e?.()},[e,r]),fs=i.useMemo(()=>Q&&De&&!ee?"5.5rem":se?"max(calc(0.75rem + var(--oc-wco-left-inset, 0px)), 5.5rem)":(!Q||Be)&&!et?"calc(0.75rem + var(--oc-wco-left-inset, 0px))":"0.75rem",[Q,ee,De,se,et,Be]);Xe.useEffect(()=>{typeof document>"u"||document.documentElement.style.setProperty("--oc-titlebar-left-inset",fs)},[fs]);const zs=l?"0.75rem":"var(--oc-titlebar-left-inset, 0.75rem)",Ks=l?"0px":"calc(var(--oc-titlebar-controls-width, 5.5rem) + 0.5rem)";Xe.useEffect(()=>{if(!Q||!De){Ne(!1);return}let J=!1;const st=async()=>{try{const Pt=await Ur("desktop_is_window_fullscreen");J||Ne(Pt===!0)}catch{J||Ne(!1)}},gt=()=>{st()};return st(),window.addEventListener("openchamber:window-resized",gt),()=>{J=!0,window.removeEventListener("openchamber:window-resized",gt)}},[Q,De]);const Ws=i.useMemo(()=>!Q||!De||Fe===null?"":Fe>=26?"h-12":Fe<=15?"h-14":"",[Q,De,Fe]),pn=i.useMemo(()=>{if(!(Q&&!Be||et))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))"}},[Q,et,Be]),Ns=i.useCallback(()=>{if(typeof document>"u")return;const J=ke.current?.getBoundingClientRect().height;J&&document.documentElement.style.setProperty("--oc-header-height",`${J}px`)},[]);Xe.useEffect(()=>{if(typeof window>"u")return;Ns();const J=ke.current;if(!J||typeof ResizeObserver>"u")return()=>{};let st=0;const gt=()=>{st||(st=requestAnimationFrame(()=>{st=0,Ns()}))},Pt=new ResizeObserver(gt);return Pt.observe(J),window.addEventListener("resize",gt),window.addEventListener("orientationchange",gt),()=>{st&&cancelAnimationFrame(st),Pt.disconnect(),window.removeEventListener("resize",gt),window.removeEventListener("orientationchange",gt)}},[Ns]),Xe.useEffect(()=>{Ns()},[Ns,me,Ws]);const qr=i.useCallback(async J=>{const st=J.target;st.closest(".app-region-no-drag")||st.closest("button, a, input, select, textarea")||J.button===0&&Q&&await ip()},[Q]),Gn=i.useMemo(()=>{if(me){const J=[{id:"chat",label:o("layout.mainTab.chat"),icon:"chat-4"}];return an&&J.push({id:"plan",label:o("layout.mainTab.plan"),icon:"file-text"}),J.push({id:"diff",label:o("layout.mainTab.diff"),icon:"diff"},{id:"files",label:o("layout.mainTab.files"),icon:"folder-6"},{id:"terminal",label:o("layout.mainTab.terminal"),icon:"terminal-box"},{id:"context",label:o("layout.mainTab.context"),icon:"file-list-2"},{id:"diagram",label:o("layout.mainTab.diagram"),icon:"file"}),J}return[]},[me,an,o]),fr=i.useCallback(J=>La(ii(J,C)),[C]);Xe.useEffect(()=>{!me&&(y==="git"||y==="terminal"||y==="diff"||y==="files"||y==="context")&&h("chat")},[y,me,h]);const Kn=i.useMemo(()=>{const J=[];return Q&&J.push({value:"instance",label:o("layout.services.instance"),icon:s.jsx(D,{name:"server",className:"h-3.5 w-3.5"})}),J.push({value:"usage",label:o("layout.services.usage"),icon:s.jsx(D,{name:"timer",className:"h-3.5 w-3.5"})},{value:"mcp",label:"MCP",icon:s.jsx(Ul,{className:"h-3.5 w-3.5"})}),J},[Q,o]),gs=i.useMemo(()=>Kn.map(J=>({id:J.value,label:J.label,icon:J.icon})),[Kn]),Ms=i.useMemo(()=>{if(typeof window>"u"||Q||et)return!1;const J=window.location.hostname;return J==="localhost"||J==="127.0.0.1"||J==="::1"},[Q,et]),jr=i.useCallback(async()=>{if(k)return;v(!0),Le(!1);const J=[];let st=!1;try{try{for(const[,gt]of Vs.getState().sessions.entries())for(const Pt of gt.tabs)Pt.previewUrl&&J.push(Pt.previewUrl)}catch{}try{await op({})}catch{}try{(await As("/api/system/dev-shutdown",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({previewUrls:J})})).ok?st=!0:st=(await As("/api/system/shutdown",{method:"POST"})).ok}catch{}}finally{st||v(!1)}},[k,Le]),jn=i.useMemo(()=>[{value:"usage",label:o("header.services.used")},{value:"remaining",label:o("header.services.remaining")}],[o]),ln=i.useMemo(()=>jn.map(J=>({id:J.value,label:J.label})),[jn]),Zn=i.useMemo(()=>[{id:"usage",label:o("layout.services.usage"),icon:s.jsx(D,{name:"timer",className:"h-3.5 w-3.5"})},{id:"mcp",label:"MCP",icon:s.jsx(Ul,{className:"h-3.5 w-3.5"})}],[o]);Xe.useEffect(()=>{const J=st=>{if(yc(st)&&!st.shiftKey&&!st.altKey){const gt=parseInt(st.key,10);gt>=1&><=Gn.length&&(st.preventDefault(),me&&(we(),Xn()),h(Gn[gt-1].id))}};return window.addEventListener("keydown",J),()=>window.removeEventListener("keydown",J)},[we,Xn,me,h,Gn]),Xe.useEffect(()=>{const J=st=>{const gt=ii("toggle_services_menu",C);if(ia(st,gt)){st.preventDefault(),ye?Le(!1):(Le(!0),Wt(),wt==="usage"&&V.length===0&&_());return}const Pt=ii("cycle_services_tab",C);if(ia(st,Pt)){st.preventDefault();const is=Kn.map(er=>er.value);if(is.length===0)return;const ms=is.indexOf(wt),Fs=ms===-1?0:(ms+1)%is.length,qs=is[Fs];kt(qs),Le(!0),Wt(),qs==="usage"&&V.length===0&&_();return}const Zt=ii("toggle_context_plan",C);ia(st,Zt)&&(st.preventDefault(),hs())};return window.addEventListener("keydown",J),()=>window.removeEventListener("keydown",J)},[C,ye,wt,Kn,V.length,_,Wt,hs]);const Mr=J=>{const st=y===J.id,gt=J.icon==="diff",Pt=gt?null:J.icon,Zt=J.id==="chat",is=Fs=>gt?s.jsx(Yd,{size:Fs}):Pt?s.jsx(D,{name:Pt,className:`h-${Fs/4} w-${Fs/4}`}):null,ms=s.jsxs("button",{type:"button",onClick:()=>h(J.id),className:Pe("relative flex h-8 items-center gap-2 px-3 rounded-lg typography-ui-label font-medium transition-colors",st?"app-region-no-drag bg-interactive-selection text-interactive-selection-foreground shadow-none":"app-region-no-drag text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",Zt&&!me&&"min-w-[100px] justify-center"),"aria-label":J.label,"aria-selected":st,role:"tab",children:[me?is(20):s.jsxs(s.Fragment,{children:[is(16),s.jsx("span",{className:"header-tab-label",children:J.label})]}),J.badge!==void 0&&J.badge>0&&s.jsx("span",{className:"header-tab-badge typography-micro text-status-info font-medium",children:J.badge})]});return s.jsx(i.Fragment,{children:ms},J.id)},Yr=et?null:s.jsxs(Et,{children:[s.jsx(Mt,{asChild:!0,children:s.jsx("button",{type:"button","aria-label":o("header.actions.toggleChangesPanelAria"),"aria-pressed":Ds,onClick:ps,className:Es,children:s.jsxs("span",{className:"relative h-5 w-5 overflow-hidden rounded-[2px]",children:[s.jsx("span",{className:"absolute left-[4px] top-[4px] h-3 w-[5px] bg-[var(--status-error)]/25"}),s.jsx("span",{className:"absolute right-[4px] top-[4px] h-3 w-[5px] bg-[var(--status-success)]/25"}),s.jsx(D,{name:"layout-column",className:"absolute inset-0 h-5 w-5"})]})})}),s.jsx(Ft,{children:s.jsx("p",{children:o("header.actions.toggleChangesPanel")})})]}),ui=s.jsxs(s.Fragment,{children:[an&&s.jsxs(Et,{children:[s.jsx(Mt,{asChild:!0,children:s.jsx("button",{type:"button","aria-label":o("header.actions.openPlanAria"),onClick:hs,className:Pe(Es,Ss&&"bg-[var(--interactive-hover)]"),children:s.jsx(D,{name:"file-text",className:"h-[18px] w-[18px]"})})}),s.jsx(Ft,{children:s.jsx("p",{children:o("header.actions.planWithShortcut",{shortcut:fr("toggle_context_plan")})})})]}),s.jsx(hb,{directory:ks,className:"mr-1"}),s.jsx(Hb,{isDesktopApp:Q,currentInstanceLabel:M,compactCurrentInstanceLabel:nt,currentInstanceIsLocal:ie,isDesktopServicesOpen:ye,setIsDesktopServicesOpen:Le,refreshCurrentInstanceLabel:Wt,desktopServicesTab:wt,setDesktopServicesTab:kt,quotaResultsLength:V.length,fetchAllQuotas:_,servicesTabItems:gs,quotaLastUpdated:Z,quotaDisplayMode:ne,showPredValues:Y,quotaDisplayTabItems:ln,handleDisplayModeChange:Ut,handleUsageRefresh:as,isQuotaLoading:E,isUsageRefreshSpinning:Re,hasRateLimits:Gt,rateLimitGroups:rs,expandedFamilies:jt,toggleFamilyExpanded:xt,shortcutLabel:fr,showDevShutdown:Ms,isDevShutdownInFlight:k,onDevShutdown:jr,remoteUpdateInfo:Je,remoteUpdateChecking:bt,remoteUpdateError:_e,onOpenRemoteUpdate:Ze,timeFormatPreference:w}),s.jsx(Uo,{title:o("header.actions.terminalPanelWithShortcut",{shortcut:fr("toggle_terminal")}),ariaLabel:o("header.actions.toggleTerminalPanelAria"),onClick:d,Icon:"terminal-box"}),me?null:s.jsx(Uo,{title:o("contextPanel.browser.open"),ariaLabel:o("contextPanel.browser.open"),onClick:js,pressed:Un,Icon:"global"}),s.jsx(Uo,{title:o("header.actions.rightSidebarWithShortcut",{shortcut:fr("toggle_right_sidebar")}),ariaLabel:o("header.actions.toggleRightSidebarAria"),onClick:u,Icon:"layout-right"}),s.jsx(Ub,{isMobile:me,githubAuthStatus:Se,githubAccounts:be,githubAvatarUrl:$,githubLogin:ve,isSwitchingGitHubAccount:z,handleGitHubAccountSwitch:Os})]}),mr=F&&(I||!!N),us=()=>s.jsxs("div",{onMouseDown:qr,className:Pe("app-region-drag relative flex h-12 select-none items-center pr-3",Ws),style:pn,role:"tablist","aria-label":o("header.navigation.mainAria"),children:[s.jsx("div",{"aria-hidden":!0,className:"shrink-0 self-stretch transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",style:{width: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:Ks}}),s.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[s.jsx(rb,{children:s.jsxs("button",{type:"button","aria-label":o("sessions.switcher.openAria"),className:"app-region-no-drag mr-3 flex min-w-0 flex-col items-start rounded-md px-1 py-0.5 -my-0.5 text-left transition-colors hover:bg-interactive-hover/60 focus-visible:outline-none focus-visible:bg-interactive-hover/60",children:[s.jsx("span",{className:"truncate typography-ui-label text-[14px] font-normal leading-tight text-foreground max-w-full",children:I?o("sessions.switcher.draftTitle"):xs}),B||ts||!I&&Ct?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:[B?s.jsx("span",{className:"truncate",children:B}):null,ts?s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5",children:[s.jsx(D,{name:"git-branch",className:"h-3 w-3 flex-shrink-0 text-muted-foreground/70"}),s.jsx("span",{className:"truncate",children:ts})]}):null,!I&&Ct?s.jsxs("span",{className:Pe("inline-flex min-w-0 items-center gap-0.5",Ct==="attention"||Ct==="invalid"||Ct==="missing"?"text-status-warning":"text-muted-foreground/60"),children:[s.jsx(D,{name:"alert",className:"h-3 w-3 flex-shrink-0"}),s.jsx("span",{className:"truncate",children:$t})]}):null]}):null]})}),Gn.length>0&&s.jsx("div",{className:"flex items-center gap-1 rounded-lg bg-[var(--surface-muted)]/50 p-1",children:Gn.map(J=>Mr(J))}),s.jsx("div",{className:"flex-1"}),s.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[Ot&&U?s.jsx(ib,{totalTokens:U.totalTokens,percentage:ns,colorPercentage:U.percentage,contextLimit:U.contextLimit,outputLimit:U.outputLimit??0,size:"compact",hideIcon:!0,showPercentIcon:!0,onClick:Ht,pressed:ht,className:mr?"":"mr-3.5",valueClassName:"typography-ui-label font-medium leading-none text-foreground",percentIconClassName:"h-4.5 w-4.5"}):null,Yr,s.jsx(Uo,{visible:mr,title:o(I?"header.actions.newMiniChat":"header.actions.openSessionMiniChat"),ariaLabel:o(I?"header.actions.newMiniChatAria":"header.actions.openSessionMiniChatAria"),onClick:It,className:Pe(Es,"mr-1"),Icon:"picture-in-picture-2"}),ui,s.jsx(ob,{visible:Be})]})]})]}),cn=()=>s.jsxs("div",{className:"app-region-drag relative flex items-center gap-2 px-3 py-2 select-none",children:[s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[t?s.jsx("button",{type:"button",onClick:Ue,className:Pe(En,Hn==="sessions"&&"bg-interactive-selection text-interactive-selection-foreground"),"aria-label":o(n?"header.actions.closeSessionsAria":"header.actions.openSessionsAria"),children:s.jsx(D,{name:"layout-left",className:"h-5 w-5"})}):G?s.jsx("button",{type:"button",onClick:()=>a(!1),className:"app-region-no-drag h-9 w-9 p-2 text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary rounded-md active:bg-interactive-active","aria-label":o("header.actions.backAria"),children:s.jsx(D,{name:"arrow-left-s",className:"h-5 w-5"})}):s.jsx("button",{type:"button",onClick:tt,className:"app-region-no-drag h-9 w-9 p-2 text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary rounded-md active:bg-interactive-active","aria-label":o("header.actions.openSessionsAria"),children:s.jsx(D,{name:"play-list-add",className:"h-5 w-5"})}),!t&&G&&s.jsx("span",{className:"typography-ui-label font-semibold text-foreground",children:o("header.sessions.title")})]}),(!G||!!t)&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"app-region-no-drag flex min-w-0 flex-1 items-center",children:s.jsx("div",{className:"flex min-w-0 flex-1 overflow-x-auto overflow-y-hidden scrollbar-hidden touch-pan-x overscroll-x-contain",children:s.jsx("div",{className:"flex w-max items-center gap-1 pr-1",children:s.jsx("div",{className:"flex items-center gap-0.5 rounded-lg bg-[var(--surface-muted)]/50 p-0.5",role:"tablist","aria-label":o("header.navigation.mainAria"),children:Gn.map(J=>{const st=y===J.id,gt=J.icon==="diff",Pt=gt?null:J.icon;return s.jsxs(Et,{children:[s.jsx(Mt,{asChild:!0,children:s.jsxs("button",{type:"button",onClick:()=>{me&&(we(),Xn()),h(J.id)},"aria-label":J.label,"aria-selected":st,role:"tab",className:Pe(En,"relative rounded-lg",Hn===J.id&&"bg-interactive-selection text-interactive-selection-foreground"),children:[gt?s.jsx(Yd,{className:"h-5 w-5"}):Pt?s.jsx(D,{name:Pt,className:"h-5 w-5"}):null,J.badge!==void 0&&J.badge>0&&s.jsx("span",{className:"absolute -top-1 -right-1 text-[10px] font-semibold text-primary",children:J.badge}),J.showDot&&s.jsx("span",{className:"absolute top-1.5 right-1.5 h-2 w-2 rounded-full bg-primary","aria-label":o("header.changes.availableAria")})]})}),s.jsx(Ft,{children:s.jsx("p",{children:J.label})})]},J.id)})})})})}),s.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[Ps&&s.jsx(km,{projectRef:Ps.projectRef,directory:Ps.directory,compact:!0,allowMobile:!0,className:"h-9"}),s.jsxs(sn,{open:je,onOpenChange:J=>{J&&(n&&t&&t(),r&&e&&e()),K(J),J&&V.length===0&&_()},children:[s.jsxs(Et,{children:[s.jsx(Mt,{asChild:!0,children:s.jsx(en,{asChild:!0,children:s.jsx("button",{type:"button","aria-label":o("header.services.viewAria"),className:Pe(En,Hn==="services"&&"bg-interactive-selection text-interactive-selection-foreground"),children:s.jsx(D,{name:"stack",className:"h-5 w-5"})})})}),s.jsx(Ft,{children:s.jsx("p",{children:o("header.services.title")})})]}),s.jsx(tn,{align:"end",sideOffset:0,positionerClassName:"!fixed !bottom-0 !left-0 !right-0 !top-[var(--oc-header-height,56px)] !transform-none",className:"h-full w-screen max-h-none rounded-none border-0 p-0 pt-1 overflow-hidden",children:s.jsxs("div",{className:"flex h-full flex-col bg-[var(--surface-elevated)]",children:[s.jsx("div",{className:"sticky top-0 z-20 bg-[var(--surface-elevated)] px-2 py-px",children:s.jsxs("div",{className:"flex items-center justify-between gap-2 px-3 py-0",children:[s.jsx("div",{className:"h-10 min-w-0 flex-1",children:s.jsx(To,{items:Zn,activeId:vt,onSelect:J=>{const st=J;St(st),st==="usage"&&V.length===0&&_()},layoutMode:"fit",variant:"active-pill",activePillInsetClassName:"gap-0.5 px-px py-0",activePillButtonClassName:"h-8",className:"h-full"})}),s.jsx("button",{type:"button",onClick:()=>K(!1),className:"inline-flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-interactive-hover","aria-label":o("header.services.closeAria"),children:s.jsx(D,{name:"close",className:"h-5 w-5"})})]})}),vt==="mcp"&&s.jsx(hm,{active:je&&vt==="mcp"}),vt==="usage"&&s.jsxs("div",{className:"flex-1 overflow-y-auto overflow-x-hidden pb-[calc(4rem+env(safe-area-inset-bottom))]",children:[s.jsx("div",{className:"border-b border-[var(--interactive-border)]",children:s.jsxs("div",{className:"flex items-center justify-between gap-3 px-4 py-3",children:[s.jsxs("div",{className:"flex flex-col min-w-0 gap-0.5",children:[s.jsx("span",{className:"typography-ui-header font-semibold text-foreground",children:o("header.services.rateLimits")}),s.jsx("span",{className:"truncate typography-micro text-muted-foreground",children:Cm(Z,w)})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s.jsxs("div",{className:"flex items-center h-6",children:[s.jsx("button",{type:"button",onClick:()=>Ut("usage"),className:Pe("typography-ui-label px-1 pb-0.5 transition-colors",ne==="usage"?"text-foreground border-b-2 border-[var(--primary-base)]":"text-muted-foreground hover:text-foreground"),children:o("header.services.used")}),s.jsx("span",{className:"text-muted-foreground typography-ui-label px-0.5",children:"·"}),s.jsx("button",{type:"button",onClick:()=>Ut("remaining"),className:Pe("typography-ui-label px-1 pb-0.5 transition-colors",ne==="remaining"?"text-foreground border-b-2 border-[var(--primary-base)]":"text-muted-foreground hover:text-foreground"),children:o("header.services.remaining")})]}),s.jsx("button",{type:"button",className:Pe("inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors","hover:text-foreground hover:bg-interactive-hover","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary"),onClick:as,disabled:E||Re,"aria-label":o("header.services.refreshRateLimitsAria"),children:s.jsx(D,{name:"refresh",className:Pe("h-4 w-4",Re&&"animate-spin")})})]})]})}),!Gt&&s.jsx("div",{className:"px-4 py-6 text-center",children:s.jsx("span",{className:"typography-ui-label text-muted-foreground",children:o("header.services.noRateLimits")})}),s.jsx("div",{className:"py-1",children:rs.map((J,st)=>s.jsxs(i.Fragment,{children:[st>0?s.jsx("div",{className:"mx-4 my-1 border-t border-[var(--interactive-border)]"}):null,s.jsxs("div",{className:"flex items-center gap-2 px-4 py-2",children:[s.jsx(Do,{providerId:J.providerId,className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label font-medium text-foreground",children:J.providerName})]}),J.entries.length===0&&(!J.modelFamilies||J.modelFamilies.length===0)?s.jsx("div",{className:"px-4 pb-2",children:s.jsx("span",{className:"typography-ui-label text-muted-foreground",children:J.error??o("header.services.noRateLimitsReported")})}):s.jsxs("div",{className:"space-y-3 px-4 pb-2",children:[J.entries.map(([gt,Pt])=>{const Zt=ne==="remaining"?Pt.remainingPercent:Pt.usedPercent,is=va(Pt.usedPercent,Pt.resetAt,Pt.windowSeconds,gt),ms=is?.dailyAllocationPercent!=null?ne==="remaining"?100-ri(is.elapsedRatio):ri(is.elapsedRatio):null,Fs=Io(Pt.valueLabel,Zt),qs=Bf(Pt.resetAt,Pt.resetAfterFormatted??Pt.resetAtFormatted,w);return s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0 flex items-center gap-2",children:[s.jsx("span",{className:"truncate typography-ui-label text-foreground",children:gc(gt)}),qs?s.jsx("span",{className:"truncate typography-micro text-muted-foreground",children:qs}):null]}),s.jsx("span",{className:"typography-ui-label text-foreground tabular-nums",children:Fs==="-"?"":Fs})]}),s.jsx(Ca,{percent:Zt,tonePercent:Pt.usedPercent,className:"h-1.5",expectedMarkerPercent:ms}),is&&Y?s.jsx(Aa,{paceInfo:is,compact:!0}):null]},`${J.providerId}-${gt}`)}),J.modelFamilies&&J.modelFamilies.length>0&&s.jsx("div",{className:"space-y-0.5",children:J.modelFamilies.map(gt=>{const Zt=(jt[J.providerId]??[]).includes(gt.familyId??"other");return s.jsxs(eo,{open:Zt,onOpenChange:()=>xt(J.providerId,gt.familyId??"other"),children:[s.jsxs(Bo,{className:"flex w-full items-center justify-between rounded-md px-1 py-1.5 text-left hover:bg-[var(--interactive-hover)]/50 transition-colors",children:[s.jsx("span",{className:"typography-ui-label font-medium text-foreground",children:gt.familyLabel}),Zt?s.jsx(D,{name:"arrow-down-s",className:"h-4 w-4 text-muted-foreground"}):s.jsx(D,{name:"arrow-right-s",className:"h-4 w-4 text-muted-foreground"})]}),s.jsx(to,{children:s.jsx("div",{className:"space-y-2.5 pb-1 pl-1 pt-1",children:gt.models.map(([is,ms])=>{const Fs=ne==="remaining"?ms.remainingPercent:ms.usedPercent,qs=va(ms.usedPercent,ms.resetAt,ms.windowSeconds),er=qs?.dailyAllocationPercent!=null?ne==="remaining"?100-ri(qs.elapsedRatio):ri(qs.elapsedRatio):null,qn=Io(ms.valueLabel,Fs);return s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-3",children:[s.jsx("span",{className:"truncate typography-micro text-muted-foreground",children:mm(is)}),s.jsx("span",{className:"typography-ui-label text-foreground tabular-nums",children:qn==="-"?"":qn})]}),s.jsx(Ca,{percent:Fs,tonePercent:ms.usedPercent,className:"h-1.5",expectedMarkerPercent:er}),qs&&Y?s.jsx(Aa,{paceInfo:qs,compact:!0}):null]},`${J.providerId}-${is}`)})})})]},gt.familyId??"other")})})]})]},J.providerId))})]})]})})]}),e?s.jsxs(Et,{children:[s.jsx(Mt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:os,className:Pe(En,"relative",Hn==="git"&&"bg-interactive-selection text-interactive-selection-foreground"),"aria-label":r?"Close git sidebar":"Open git sidebar",children:s.jsx(D,{name:"layout-right",className:"h-5 w-5"})})}),s.jsx(Ft,{children:s.jsx("p",{children:r?"Close git sidebar":"Open git sidebar"})})]}):null]})]})]}),kn=Pe("header-safe-area relative z-10 bg-background",me&&"border-b border-border/50");return s.jsxs(s.Fragment,{children:[s.jsx("header",{ref:ke,className:kn,style:{"--padding-scale":"1"},children:me?cn():us()}),s.jsx(gm,{open:Ge,onOpenChange:He,info:Je,downloading:!1,downloaded:!1,progress:null,error:_e,onDownload:()=>{},onRestart:()=>{},runtimeType:"web"})]})};function qb(){}const eu=180,tu=640,Yb=110,Qb=t=>{const e=mt.c(44),{isOpen:n,isMobile:r,children:o}=t,{t:a}=Nt(),c=Ee(Jb),l=Ee(Xb),d=Ee(Zb),u=Ee(ey),[m,f]=i.useState(null),[g,b]=i.useState(!1),p=i.useRef(null),x=i.useRef(0),y=i.useRef(c||300),h=Math.min(tu,Math.max(eu,c||300));let C,w;e[0]!==n?(C=()=>{n||(f(null),b(!1))},w=[n],e[0]=n,e[1]=C,e[2]=w):(C=e[1],w=e[2]),i.useEffect(C,w);let S,j;e[3]!==l||e[4]!==r||e[5]!==n?(S=()=>{if(r||!n||!l)return;const re=()=>{const Se=p.current?.parentElement?.getBoundingClientRect().height;if(!Se||Se<=0)return;const te=Math.max(0,Math.round(Se));f(ke=>ke===te?ke:te)};re();const ae=p.current?.parentElement;if(!ae)return;const me=new ResizeObserver(re);return me.observe(ae),()=>{me.disconnect()}},j=[l,r,n],e[3]=l,e[4]=r,e[5]=n,e[6]=S,e[7]=j):(S=e[6],j=e[7]),i.useEffect(S,j);let k,v;if(e[8]!==l||e[9]!==r||e[10]!==g||e[11]!==d||e[12]!==u?(k=()=>{if(r||!g||l)return;const re=me=>{const Se=x.current-me.clientY,te=Math.min(tu,Math.max(eu,y.current+Se));d(te)},ae=()=>{b(!1),Ee.getState().bottomTerminalHeight<=Yb&&u(!1)};return window.addEventListener("pointermove",re),window.addEventListener("pointerup",ae,{once:!0}),()=>{window.removeEventListener("pointermove",re),window.removeEventListener("pointerup",ae)}},v=[l,r,g,d,u],e[8]=l,e[9]=r,e[10]=g,e[11]=d,e[12]=u,e[13]=k,e[14]=v):(k=e[13],v=e[14]),i.useEffect(k,v),r)return null;const A=n?l?Math.max(0,m??h):h:0,I=n&&l;let N;e[15]!==A||e[16]!==l||e[17]!==n?(N=re=>{!n||l||(b(!0),x.current=re.clientY,y.current=A,re.preventDefault())},e[15]=A,e[16]=l,e[17]=n,e[18]=N):N=e[18];const O=N,P=I?"absolute inset-x-0 bottom-0 z-40":"relative",T=g?"transition-none":"transition-[height] duration-300 ease-in-out",L=(!n||I)&&"border-t-0";let R;e[19]!==L||e[20]!==P||e[21]!==T?(R=Pe("flex overflow-hidden border-t border-border bg-sidebar",P,T,L),e[19]=L,e[20]=P,e[21]=T,e[22]=R):R=e[22];let B;e[23]!==A||e[24]!==I?(B=I?{top:0}:{height:`${A}px`,minHeight:`${A}px`,maxHeight:`${A}px`},e[23]=A,e[24]=I,e[25]=B):B=e[25];const V=!n||!l&&A===0;let _;e[26]!==O||e[27]!==l||e[28]!==n||e[29]!==g||e[30]!==a?(_=n&&!l&&s.jsx("div",{className:Pe("absolute left-0 top-0 z-20 h-[3px] w-full cursor-row-resize hover:bg-[var(--interactive-border)]/80 transition-colors",g&&"bg-[var(--interactive-border)]"),onPointerDown:O,role:"separator","aria-orientation":"horizontal","aria-label":a("terminalView.bottomDock.resizeAria")}),e[26]=O,e[27]=l,e[28]=n,e[29]=g,e[30]=a,e[31]=_):_=e[31];const E=!n&&"pointer-events-none select-none opacity-0";let Z;e[32]!==E?(Z=Pe("relative z-10 flex h-full min-h-0 w-full flex-col transition-opacity duration-300 ease-in-out",E),e[32]=E,e[33]=Z):Z=e[33];const ne=!n;let Y;e[34]!==o||e[35]!==Z||e[36]!==ne?(Y=s.jsx("div",{className:Z,"aria-hidden":ne,children:o}),e[34]=o,e[35]=Z,e[36]=ne,e[37]=Y):Y=e[37];let H;return e[38]!==R||e[39]!==B||e[40]!==V||e[41]!==_||e[42]!==Y?(H=s.jsxs("section",{ref:p,className:R,style:B,"aria-hidden":V,children:[_,Y]}),e[38]=R,e[39]=B,e[40]=V,e[41]=_,e[42]=Y,e[43]=H):H=e[43],H};function Jb(t){return t.bottomTerminalHeight}function Xb(t){return t.isBottomTerminalExpanded}function Zb(t){return t.setBottomTerminalHeight}function ey(t){return t.setBottomTerminalOpen}const su=280,nu=280,ru=500,ty=({isOpen:t,isMobile:e,children:n,className:r,topBar:o})=>{const{t:a}=Nt(),c=Ee(v=>v.sidebarWidth),l=Ee(v=>v.setSidebarWidth),[d,u]=i.useState(!1),m=i.useRef(0),f=i.useRef(c||su),g=i.useRef(null),b=i.useRef(null),p=i.useRef(null),x=i.useCallback(v=>Math.min(ru,Math.max(nu,v)),[]),y=i.useCallback(v=>{const A=p.current;A&&(A.style.width=`${v}px`,A.style.minWidth=`${v}px`,A.style.maxWidth=`${v}px`,A.style.setProperty("--oc-left-sidebar-width",`${v}px`))},[]);if(i.useEffect(()=>{e&&d&&u(!1)},[e,d]),i.useEffect(()=>{d||(g.current=null,b.current=null)},[d]),e)return null;const h=Math.min(ru,Math.max(nu,c||su)),C=t?h:0,w=v=>{if(t){try{v.currentTarget.setPointerCapture(v.pointerId)}catch{}b.current=v.pointerId,u(!0),m.current=v.clientX,f.current=C,g.current=C,y(C),v.preventDefault()}},S=v=>{if(e||!d||b.current!==v.pointerId)return;const A=v.clientX-m.current,I=x(f.current+A);g.current!==I&&(g.current=I,y(I))},j=v=>{if(b.current!==v.pointerId||e)return;try{v.currentTarget.releasePointerCapture(v.pointerId)}catch{}const A=x(g.current??C);b.current=null,g.current=null,u(!1),l(A)},k=d?g.current??C:C;return s.jsxs("aside",{ref:p,className:Pe("relative flex h-full overflow-hidden border-r border-border/40 will-change-[width] motion-reduce:transition-none","bg-sidebar oc-vibrancy-surface",!t&&"border-r-0",r),style:{width:`${k}px`,minWidth:`${k}px`,maxWidth:`${k}px`,"--oc-left-sidebar-width":`${d?k: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||C===0,children:[t&&s.jsx("div",{className:Pe("absolute right-0 top-0 z-20 h-full w-[3px] cursor-col-resize hover:bg-[var(--interactive-border)]/80 transition-colors",d&&"bg-[var(--interactive-border)]"),onPointerDown:w,onPointerMove:S,onPointerUp:j,onPointerCancel:j,role:"separator","aria-orientation":"vertical","aria-label":a("sidebar.resize.leftPanelAria")}),s.jsxs("div",{className:Pe("relative z-10 flex h-full shrink-0 flex-col transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",d&&"pointer-events-none",!t&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-left-sidebar-width)",overflowX:"hidden"},"aria-hidden":!t,children:[o,s.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:s.jsx(Zs,{children:n})})]})]})},sy=()=>{const t=mt.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},Ho=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")};function ny(){const t=ws(f=>f.activeProjectId?f.projects.find(g=>g.id===f.activeProjectId)??null:null),e=ut(f=>f.currentSessionId),n=_f(e??null),r=ut(f=>e?f.worktreeMetadata.get(e)?.path??"":""),o=ut(f=>f.newSessionDraft?.open?Ho(f.newSessionDraft.bootstrapPendingDirectory??f.newSessionDraft.directoryOverride??""):""),a=i.useMemo(()=>Ho(r||""),[r]),c=i.useMemo(()=>{const f=typeof n?.directory=="string"?n.directory:"";return Ho(f||"")},[n?.directory]),l=a||c||o,d=i.useMemo(()=>Ho(l||t?.path||""),[t?.path,l]),u=i.useMemo(()=>t?{id:t.id,path:t.path}:null,[t]),m=i.useRef(null);return i.useEffect(()=>{u&&d&&(m.current={projectRef:u,directory:d})},[d,u]),i.useMemo(()=>u&&d?{projectRef:u,directory:d}:m.current,[u,d])}const iu="app-region-no-drag inline-flex h-8 w-8 items-center justify-center gap-2 rounded-md typography-ui-label font-medium text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary hover:bg-interactive-hover transition-colors",ry=()=>{const t=mt.c(31),{t:e}=Nt(),n=Ee(iy),r=Ee(oy),o=Ee(ay),a=ny(),c=i.useRef(null),l=La(ii("toggle_sidebar",o));let d;e:{if(typeof window>"u"){d=!1;break e}d=!!window.__OPENCHAMBER_ELECTRON__&&window.__OPENCHAMBER_PLATFORM__==="win32"}const u=d,m=cy;let f,g;t[0]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{if(typeof document>"u")return;const L=c.current;if(!L)return;const R=()=>{const V=L.getBoundingClientRect().width;document.documentElement.style.setProperty("--oc-titlebar-controls-width",`${Math.round(V)}px`)};if(R(),typeof ResizeObserver>"u")return;const B=new ResizeObserver(R);return B.observe(L),()=>{B.disconnect()}},g=[],t[0]=f,t[1]=g):(f=t[0],g=t[1]),i.useEffect(f,g);const b="app-region-no-drag absolute left-0 top-0 z-30 flex select-none items-center pr-2";let p;t[2]===Symbol.for("react.memo_cache_sentinel")?(p={height:"var(--oc-header-height, 3rem)",paddingLeft:"var(--oc-titlebar-left-inset, 0.75rem)"},t[2]=p):p=t[2];const x="flex items-center gap-2";let y;t[3]!==e?(y=u?s.jsxs(Et,{children:[s.jsx(Mt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:m,"aria-label":e("header.actions.openAppMenuAria"),className:Pe(iu,"shrink-0"),children:s.jsx(D,{name:"menu-2",className:"h-[18px] w-[18px]"})})}),s.jsx(Ft,{children:s.jsx("p",{children:e("header.actions.openAppMenu")})})]}):null,t[3]=e,t[4]=y):y=t[4];const h=Et;let C;t[5]!==e?(C=e("header.actions.openSessionsAria"),t[5]=e,t[6]=C):C=t[6];let w,S;t[7]===Symbol.for("react.memo_cache_sentinel")?(w=Pe(iu,"shrink-0"),S=s.jsx(D,{name:"layout-left",className:"h-[18px] w-[18px]"}),t[7]=w,t[8]=S):(w=t[7],S=t[8]);let j;t[9]!==C||t[10]!==n?(j=s.jsx(Mt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:n,"aria-label":C,className:w,children:S})}),t[9]=C,t[10]=n,t[11]=j):j=t[11];const k=Ft,v=e("header.actions.openSessionsWithShortcut",{shortcut:l});let A;t[12]!==v?(A=s.jsx("p",{children:v}),t[12]=v,t[13]=A):A=t[13];let I;t[14]!==k||t[15]!==A?(I=s.jsx(k,{children:A}),t[14]=k,t[15]=A,t[16]=I):I=t[16];let N;t[17]!==h||t[18]!==j||t[19]!==I?(N=s.jsxs(h,{children:[j,I]}),t[17]=h,t[18]=j,t[19]=I,t[20]=N):N=t[20];let O;t[21]!==r||t[22]!==a?(O=a?s.jsx(km,{projectRef:a.projectRef,directory:a.directory,className:r?"oc-vibrancy-pill":void 0}):null,t[21]=r,t[22]=a,t[23]=O):O=t[23];let P;t[24]!==N||t[25]!==O||t[26]!==y?(P=s.jsxs("div",{ref:c,className:x,children:[y,N,O]}),t[24]=N,t[25]=O,t[26]=y,t[27]=P):P=t[27];let T;return t[28]!==P||t[29]!==p?(T=s.jsx("div",{className:b,style:p,children:P}),t[28]=P,t[29]=p,t[30]=T):T=t[30],T};function iy(t){return t.toggleSidebar}function oy(t){return t.isSidebarOpen}function ay(t){return t.shortcutOverrides}function ly(t){console.warn("[titlebar] failed to open app menu",t)}function cy(t){const e=t.currentTarget.getBoundingClientRect();Ur("desktop_show_app_menu",{x:e.left,y:e.bottom}).catch(ly)}const ou=420,dy=({isOpen:t,children:e,className:n})=>{const{t:r}=Nt(),o=Ee(j=>j.rightSidebarWidth),a=Ee(j=>j.setRightSidebarWidth),[c,l]=i.useState(!1),d=i.useRef(0),u=i.useRef(o||ou),m=i.useRef(null),f=i.useRef(null),g=i.useRef(null),b=i.useCallback(j=>Math.min(xd,Math.max(bd,j)),[]),p=i.useCallback(j=>{const k=g.current;k&&(k.style.width=`${j}px`,k.style.minWidth=`${j}px`,k.style.maxWidth=`${j}px`,k.style.setProperty("--oc-right-sidebar-width",`${j}px`))},[]),x=Math.min(xd,Math.max(bd,o||ou)),y=t?x:0,h=j=>{if(t){try{j.currentTarget.setPointerCapture(j.pointerId)}catch{}f.current=j.pointerId,l(!0),d.current=j.clientX,u.current=y,m.current=y,p(y),j.preventDefault()}},C=j=>{if(!c||f.current!==j.pointerId)return;const k=d.current-j.clientX,v=b(u.current+k);m.current!==v&&(m.current=v,p(v))},w=j=>{if(f.current!==j.pointerId)return;try{j.currentTarget.releasePointerCapture(j.pointerId)}catch{}const k=b(m.current??y);f.current=null,m.current=null,l(!1),a(k)},S=c?m.current??y:y;return s.jsxs("aside",{ref:g,className:Pe("relative flex h-full overflow-hidden border-l border-border/40 will-change-[width] motion-reduce:transition-none","bg-sidebar",!t&&"border-l-0",n),style:{width:`${S}px`,"--oc-right-sidebar-width":`${c?S:x}px`,overflowX:"clip",transitionProperty:c?"none":"width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!t||y===0,children:[t&&s.jsx("div",{className:Pe("absolute left-0 top-0 z-20 h-full w-[3px] cursor-col-resize hover:bg-[var(--interactive-border)]/80 transition-colors",c&&"bg-[var(--interactive-border)]"),onPointerDown:h,onPointerMove:C,onPointerUp:w,onPointerCancel:w,role:"separator","aria-orientation":"vertical","aria-label":r("sidebar.resize.rightPanelAria")}),s.jsx("div",{className:Pe("relative z-10 flex h-full min-h-0 shrink-0 flex-col pt-2 transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",c&&"pointer-events-none",!t&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-right-sidebar-width)"},"aria-hidden":!t,children:t?e:null})]})},au=t=>({providerID:t.providerID,modelID:t.modelID,variant:t.variant,agent:t.agent});function Am(t){const e=mt.c(120),{t:n}=Nt(),{open:r,onOpenChange:o,target:a,projectDirectory:c,submitting:l,onConfirm:d}=t,u=l===void 0?!1:l,m=ss(wy),f=ss(yy),g=Dp(by),b=ss(xy),p=ss(gy),x=ss(py),y=ss(hy),h=ss(my);let C;e[0]!==h||e[1]!==x||e[2]!==p||e[3]!==y?(C=()=>au({providerID:p,modelID:x,variant:y,agent:h}),e[0]=h,e[1]=x,e[2]=p,e[3]=y,e[4]=C):C=e[4];const[w,S]=i.useState(C);let j,k;e[5]!==g||e[6]!==f||e[7]!==m||e[8]!==r||e[9]!==c?(j=()=>{r&&(m({directory:c,source:"todoSendDialog"}),f({directory:c}),g())},k=[r,m,f,g,c],e[5]=g,e[6]=f,e[7]=m,e[8]=r,e[9]=c,e[10]=j,e[11]=k):(j=e[10],k=e[11]),i.useEffect(j,k);let v,A;e[12]!==h||e[13]!==x||e[14]!==p||e[15]!==y||e[16]!==r?(v=()=>{r&&S(au({providerID:p,modelID:x,variant:y,agent:h}))},A=[r,p,x,y,h],e[12]=h,e[13]=x,e[14]=p,e[15]=y,e[16]=r,e[17]=v,e[18]=A):(v=e[17],A=e[18]),i.useEffect(v,A);let I,N;e[19]!==w.modelID||e[20]!==w.providerID||e[21]!==r||e[22]!==b?(I=()=>{if(!r||b.length===0)return;const ye=b.find(M=>M.id===w.providerID)??b[0],Le=Array.isArray(ye?.models)?ye.models:[],Re=Le.some(M=>M.id===w.modelID),X=Le[0]?.id??"";ye?.id===w.providerID&&Re||S(M=>({...M,providerID:ye?.id??"",modelID:Re?M.modelID:X,variant:""}))},N=[r,b,w.providerID,w.modelID],e[19]=w.modelID,e[20]=w.providerID,e[21]=r,e[22]=b,e[23]=I,e[24]=N):(I=e[23],N=e[24]),i.useEffect(I,N);const O=fy;let P;if(e[25]!==w.modelID||e[26]!==w.providerID||e[27]!==b){let ye;e[29]!==w.providerID?(ye=Re=>Re.id===w.providerID,e[29]=w.providerID,e[30]=ye):ye=e[30],P=b.find(ye)?.models?.find(Re=>Re.id===w.modelID),e[25]=w.modelID,e[26]=w.providerID,e[27]=b,e[28]=P}else P=e[28];const T=P;let L;e[31]!==T?(L=T?.variants?Object.keys(T.variants):[],e[31]=T,e[32]=L):L=e[32];const R=L,B=R.length>0;let V,_;e[33]!==w.variant||e[34]!==B?(V=()=>{B||!w.variant||S(uy)},_=[B,w.variant],e[33]=w.variant,e[34]=B,e[35]=V,e[36]=_):(V=e[35],_=e[36]),i.useEffect(V,_);let E;e[37]!==w.modelID||e[38]!==w.providerID?(E=w.providerID.trim().length>0&&w.modelID.trim().length>0,e[37]=w.modelID,e[38]=w.providerID,e[39]=E):E=e[39];const Z=E;let ne;e[40]!==Z||e[41]!==w||e[42]!==d||e[43]!==u?(ne=()=>{!Z||u||d(w)},e[40]=Z,e[41]=w,e[42]=d,e[43]=u,e[44]=ne):ne=e[44];const Y=ne;let H,re;e[45]!==Y||e[46]!==r?(H=()=>{if(!r)return;const ye=Le=>{(Le.metaKey||Le.ctrlKey)&&Le.key==="Enter"&&(Le.preventDefault(),Y())};return window.addEventListener("keydown",ye),()=>window.removeEventListener("keydown",ye)},re=[r,Y],e[45]=Y,e[46]=r,e[47]=H,e[48]=re):(H=e[47],re=e[48]),i.useEffect(H,re);let ae;e[49]!==n||e[50]!==a?(ae=n(a==="worktree"?"rightSidebar.contextNotesTodo.sendDialog.title.newWorktree":"rightSidebar.contextNotesTodo.sendDialog.title.newSession"),e[49]=n,e[50]=a,e[51]=ae):ae=e[51];const me=ae;let Se;e[52]!==o||e[53]!==u?(Se=ye=>{u||o(ye)},e[52]=o,e[53]=u,e[54]=Se):Se=e[54];let te;e[55]!==me?(te=s.jsx(Hs,{children:s.jsx(Us,{children:me})}),e[55]=me,e[56]=te):te=e[56];let ke;e[57]!==n?(ke=n("chat.modelControls.model"),e[57]=n,e[58]=ke):ke=e[58];let Q;e[59]!==ke?(Q=s.jsx("span",{className:"typography-meta font-medium text-muted-foreground",children:ke}),e[59]=ke,e[60]=Q):Q=e[60];let ge;e[61]===Symbol.for("react.memo_cache_sentinel")?(ge=(ye,Le)=>{S(Re=>({...Re,providerID:ye,modelID:Le,variant:""}))},e[61]=ge):ge=e[61];let F;e[62]!==w.modelID||e[63]!==w.providerID?(F=s.jsx(Kf,{providerId:w.providerID,modelId:w.modelID,className:"max-w-[320px] justify-between",dropdownPortalToBody:!0,onChange:ge}),e[62]=w.modelID,e[63]=w.providerID,e[64]=F):F=e[64];let se;e[65]!==Q||e[66]!==F?(se=s.jsxs("div",{className:"flex min-w-0 flex-col gap-1.5",children:[Q,F]}),e[65]=Q,e[66]=F,e[67]=se):se=e[67];let ee;e[68]!==n?(ee=n("sessions.scheduledTasks.editor.thinkingLevel.label"),e[68]=n,e[69]=ee):ee=e[69];let Ne;e[70]!==ee?(Ne=s.jsx("span",{className:"typography-meta font-medium text-muted-foreground",children:ee}),e[70]=ee,e[71]=Ne):Ne=e[71];const De=!B;let Be;e[72]===Symbol.for("react.memo_cache_sentinel")?(Be=ye=>S(Le=>({...Le,variant:ye})),e[72]=Be):Be=e[72];let Fe;e[73]!==w.variant||e[74]!==De||e[75]!==R?(Fe=s.jsx(Ip,{value:w.variant,options:R,disabled:De,onChange:Be}),e[73]=w.variant,e[74]=De,e[75]=R,e[76]=Fe):Fe=e[76];let Me;e[77]!==Ne||e[78]!==Fe?(Me=s.jsxs("div",{className:"flex flex-col gap-1.5",children:[Ne,Fe]}),e[77]=Ne,e[78]=Fe,e[79]=Me):Me=e[79];let he;e[80]!==n?(he=n("sessions.scheduledTasks.editor.agent.label"),e[80]=n,e[81]=he):he=e[81];let Ae;e[82]!==he?(Ae=s.jsx("span",{className:"typography-meta font-medium text-muted-foreground",children:he}),e[82]=he,e[83]=Ae):Ae=e[83];let pe;e[84]===Symbol.for("react.memo_cache_sentinel")?(pe=ye=>S(Le=>({...Le,agent:ye})),e[84]=pe):pe=e[84];let ue;e[85]!==w.agent?(ue=s.jsx(qf,{agentName:w.agent,filter:O,dropdownPortalToBody:!0,onChange:pe}),e[85]=w.agent,e[86]=ue):ue=e[86];let U;e[87]!==Ae||e[88]!==ue?(U=s.jsxs("div",{className:"flex flex-col gap-1.5",children:[Ae,ue]}),e[87]=Ae,e[88]=ue,e[89]=U):U=e[89];let fe;e[90]!==se||e[91]!==Me||e[92]!==U?(fe=s.jsxs("div",{className:"flex flex-col gap-4",children:[se,Me,U]}),e[90]=se,e[91]=Me,e[92]=U,e[93]=fe):fe=e[93];let de;e[94]!==o?(de=()=>o(!1),e[94]=o,e[95]=de):de=e[95];let G;e[96]!==n?(G=n("rightSidebar.contextNotesTodo.sendDialog.actions.cancel"),e[96]=n,e[97]=G):G=e[97];let $;e[98]!==u||e[99]!==de||e[100]!==G?($=s.jsx($e,{variant:"ghost",size:"sm",onClick:de,disabled:u,children:G}),e[98]=u,e[99]=de,e[100]=G,e[101]=$):$=e[101];const ve=!Z||u;let be;e[102]!==u||e[103]!==n?(be=n(u?"rightSidebar.contextNotesTodo.sendDialog.actions.sending":"rightSidebar.contextNotesTodo.sendDialog.actions.send"),e[102]=u,e[103]=n,e[104]=be):be=e[104];let z;e[105]!==Y||e[106]!==ve||e[107]!==be?(z=s.jsx($e,{size:"sm",onClick:Y,disabled:ve,children:be}),e[105]=Y,e[106]=ve,e[107]=be,e[108]=z):z=e[108];let xe;e[109]!==$||e[110]!==z?(xe=s.jsxs("div",{className:"flex items-center justify-end gap-2",children:[$,z]}),e[109]=$,e[110]=z,e[111]=xe):xe=e[111];let je;e[112]!==te||e[113]!==fe||e[114]!==xe?(je=s.jsxs(_s,{className:"max-w-md overflow-visible",children:[te,fe,xe]}),e[112]=te,e[113]=fe,e[114]=xe,e[115]=je):je=e[115];let K;return e[116]!==r||e[117]!==Se||e[118]!==je?(K=s.jsx($s,{open:r,onOpenChange:Se,children:je}),e[116]=r,e[117]=Se,e[118]=je,e[119]=K):K=e[119],K}function uy(t){return{...t,variant:""}}function fy(t){return wc(t.mode)}function my(t){return t.currentAgentName||""}function hy(t){return t.currentVariant||""}function py(t){return t.currentModelId}function gy(t){return t.currentProviderId}function xy(t){return t.providers}function by(t){return t.loadAgents}function yy(t){return t.loadAgents}function wy(t){return t.loadProviders}const Jl=5,Dm=15,Go=new Map,la=t=>{const e=Math.sqrt(t/100),n=12*e,r=24*e;return Math.ceil(n+r+1)},vy=(t,e)=>{const n=la(e);return Math.max(n*Jl,Math.min(n*Dm,n*t))},jy=async(t,e)=>{const n=await Ep(t.path);return{...t,title:n?.title||t.path.split("/").pop()||e}},Sy=()=>typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`todo_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,lu=t=>[...t.filter(e=>!e.completed),...t.filter(e=>e.completed)],cu=(t,e)=>{const n=t.findIndex(r=>r.completed);return n===-1?[...t,e]:[...t.slice(0,n),e,...t.slice(n)]},Ny=t=>{const e=mt.c(20),{id:n,children:r}=t;let o;e[0]!==n?(o={id:n},e[0]=n,e[1]=o):o=e[1];const{attributes:a,listeners:c,setNodeRef:l,setActivatorNodeRef:d,transform:u,transition:m,isDragging:f}=dc(o);let g;e[2]!==u?(g=uc.Transform.toString(u),e[2]=u,e[3]=g):g=e[3];let b;e[4]!==g||e[5]!==m?(b={transform:g,transition:m},e[4]=g,e[5]=m,e[6]=b):b=e[6];const p=f&&"opacity-60";let x;e[7]!==p?(x=Pe(p),e[7]=p,e[8]=x):x=e[8];let y;e[9]!==a||e[10]!==r||e[11]!==f||e[12]!==c||e[13]!==d?(y=r({attributes:a,listeners:c,setActivatorNodeRef:d,isDragging:f}),e[9]=a,e[10]=r,e[11]=f,e[12]=c,e[13]=d,e[14]=y):y=e[14];let h;return e[15]!==l||e[16]!==b||e[17]!==x||e[18]!==y?(h=s.jsx("li",{ref:l,style:b,className:x,children:y}),e[15]=l,e[16]=b,e[17]=x,e[18]=y,e[19]=h):h=e[19],h},ky=({projectRef:t,projectLabel:e,canCreateWorktree:n=!1,onActionComplete:r,className:o})=>{const{t:a}=Nt(),[c,l]=i.useState(!1),[d,u]=i.useState(""),[m,f]=i.useState([]),[g,b]=i.useState(""),[p,x]=i.useState(null),[y,h]=i.useState(()=>new Set),[C,w]=i.useState([]),[S,j]=i.useState(null),[k,v]=i.useState(!1),[A,I]=i.useState(0),N=i.useRef(!1),O=i.useRef(""),P=i.useRef(null),T=Ee(M=>M.todoPanelHeight),L=Ee(M=>M.setTodoPanelHeight),R=Ee(M=>M.notesPanelHeight),B=Ee(M=>M.setNotesPanelHeight),[V,_]=i.useState(!1),E=i.useRef(0),Z=i.useRef(T),ne=ut(M=>M.currentSessionId),Y=ut(M=>M.createSession),H=ut(M=>M.initializeNewOpenChamberSession),re=ut(M=>M.sendMessage),ae=ut(M=>M.setCurrentSession),me=ci(M=>M.setPendingInputText),Se=Js(M=>M.currentDirectory),te=Ee(M=>M.openContextPanelTab),ke=Ee(M=>M.setActiveMainTab),Q=Ee(M=>M.setSessionSwitcherOpen),ge=Ee(M=>M.padding),F=i.useCallback(async(M,le)=>{if(!t)return!1;const ie=t.id,Ge=(Go.get(ie)??Promise.resolve()).catch(()=>{}).then(()=>Pp(t,{notes:M,todos:le}));Go.set(ie,Ge);try{const He=await Ge;return He||ce.error(a("rightSidebar.contextNotesTodo.toast.saveNotesFailed")),He}finally{Go.get(ie)===Ge&&Go.delete(ie)}},[t,a]);i.useEffect(()=>{if(!t){u(""),f([]),w([]),b(""),h(new Set);return}let M=!1;return l(!0),(async()=>{try{const le=await Tp(t),ie=await Promise.all(le.plans.map(Oe=>jy(Oe,a("rightSidebar.contextNotesTodo.plan.defaultTitle"))));if(M)return;u(le.notes),f(lu(le.todos)),w(ie),O.current=le.notes,N.current=!0,b(""),h(new Set)}catch{M||(ce.error(a("rightSidebar.contextNotesTodo.toast.loadNotesFailed")),u(""),f([]),w([]),O.current="",N.current=!0)}finally{M||l(!1)}})(),()=>{M=!0}},[A,t,a]),i.useEffect(()=>{if(!t)return;const M=le=>{const ie=le.detail;ie?.projectId&&ie.projectId!==t.id||I(Oe=>Oe+1)};return window.addEventListener("openchamber:project-plan-saved",M),window.addEventListener("openchamber:project-notes-updated",M),()=>{window.removeEventListener("openchamber:project-plan-saved",M),window.removeEventListener("openchamber:project-notes-updated",M)}},[t]),i.useEffect(()=>{if(m.length<7)return;const M=vy(m.length,ge),le=la(ge)*Jl;T!==M&&(T<le||T>M)&&L(M)},[m.length,ge,T,L]),i.useEffect(()=>{if(!V)return;const M=ie=>{const Oe=ie.clientY-E.current,Ge=Math.min(la(ge)*Dm,Math.max(la(ge)*Jl,Z.current+Oe));L(Ge)},le=()=>{_(!1)};return window.addEventListener("pointermove",M),window.addEventListener("pointerup",le,{once:!0}),window.addEventListener("pointercancel",le,{once:!0}),()=>{window.removeEventListener("pointermove",M),window.removeEventListener("pointerup",le),window.removeEventListener("pointercancel",le)}},[V,ge,L]);const se=i.useCallback(M=>{_(!0),E.current=M.clientY,Z.current=T,M.preventDefault()},[T]),ee=i.useCallback(()=>{P.current!==null&&(window.clearTimeout(P.current),P.current=null)},[]),Ne=i.useCallback(()=>{ee(),O.current=d,F(d,m)},[ee,d,F,m]);i.useEffect(()=>{if(!(!t||!N.current)&&d!==O.current)return P.current=window.setTimeout(()=>{P.current=null,O.current=d,F(d,m)},400),()=>{ee()}},[ee,d,F,t,m]),i.useEffect(()=>()=>ee(),[ee]);const De=i.useCallback(()=>{const M=g.trim();if(!M)return;const le=cu(m,{id:Sy(),text:M.slice(0,zo),completed:!1,createdAt:Date.now()});f(le),b(""),F(d,le)},[g,d,F,m]),Be=i.useCallback(M=>{h(le=>{const ie=new Set(le);return ie.has(M)?ie.delete(M):ie.add(M),ie})},[]),Fe=i.useCallback((M,le)=>{const ie=m.find(Je=>Je.id===M);if(!ie||ie.completed===le)return;const Oe=m.filter(Je=>Je.id!==M),Ge={...ie,completed:le},He=le?[...Oe,Ge]:cu(Oe,Ge);f(He),F(d,He)},[d,F,m]),Me=i.useCallback(M=>{const le=m.filter(ie=>ie.id!==M);f(le),F(d,le)},[d,F,m]),he=i.useCallback(()=>{const M=m.filter(le=>!le.completed);M.length!==m.length&&(f(M),F(d,M))},[d,F,m]),Ae=i.useCallback(M=>{const{active:le,over:ie}=M;if(!ie||le.id===ie.id)return;const Oe=m.findIndex(Je=>Je.id===le.id),Ge=m.findIndex(Je=>Je.id===ie.id);if(Oe===-1||Ge===-1)return;const He=lu(Rf(m,Oe,Ge));f(He),F(d,He)},[d,F,m]),pe=ga(yo(xa,{activationConstraint:{distance:8}})),ue=g.slice(0,zo),U=m.reduce((M,le)=>M+(le.completed?1:0),0),fe=i.useCallback(()=>{ke("chat"),Q(!1)},[ke,Q]),de=i.useCallback((M,le)=>{!t||p||j({kind:"session",todoId:M,todoText:le})},[t,p]),G=i.useCallback(M=>{if(!ne){ce.error(a("rightSidebar.contextNotesTodo.toast.noActiveSession"));return}fe();const le=`\`\`\`md
|
|
4
4
|
${M}
|
|
5
5
|
\`\`\``;me(le,"append"),ce.success(a("rightSidebar.contextNotesTodo.toast.sentToCurrentSession")),r?.()},[ne,r,fe,me,a]),$=i.useCallback((M,le)=>{if(!(!t||p)){if(!n){ce.error(a("rightSidebar.contextNotesTodo.toast.worktreeRequiresGitRepo"));return}j({kind:"worktree",todoId:M,todoText:le})}},[n,t,p,a]),ve=i.useCallback(async M=>{if(!t||!S)return;const le=await Tn("plan.todo.visible",{todo_text:S.todoText}),Oe=[{synthetic:!0,text:await Tn("plan.todo.instructions",{todo_text:S.todoText})}];v(!0),x(S.todoId);try{fe();let Ge=null,He=t.path;if(S.kind==="worktree"){if(!n){ce.error(a("rightSidebar.contextNotesTodo.toast.worktreeRequiresGitRepo"));return}const rt=await Yf(t.path,Qf());if(!rt?.id)return;Ge=rt.id,He=rt.path}else{const rt=await Y(void 0,t.path,null);if(!rt?.id){ce.error(a("rightSidebar.contextNotesTodo.toast.createSessionFailed"));return}Ge=rt.id,He=rt.directory??t.path,H(rt.id,ss.getState().agents??[])}if(!Ge)return;const Je=vc.getState();Je.saveSessionModelSelection(Ge,M.providerID,M.modelID),M.agent.trim()&&(Je.saveSessionAgentSelection(Ge,M.agent),Je.saveAgentModelForSession(Ge,M.agent,M.providerID,M.modelID),Je.saveAgentModelVariantForSession(Ge,M.agent,M.providerID,M.modelID,M.variant||void 0)),ae(Ge,He),await re(le,M.providerID,M.modelID,M.agent.trim()||void 0,void 0,void 0,Oe,M.variant||void 0),ce.success(S.kind==="worktree"?a("rightSidebar.contextNotesTodo.toast.sentToNewWorktreeSession"):a("rightSidebar.contextNotesTodo.toast.sentToNewSession")),j(null),r?.()}catch(Ge){const He=Ge instanceof Error?Ge.message:void 0;ce.error(a("rightSidebar.contextNotesTodo.toast.sendTodoFailed"),He?{description:He}:void 0)}finally{v(!1),x(null)}},[n,Y,H,r,S,t,fe,re,ae,a]),be=i.useRef(null),[z,xe]=i.useState(!1),[je,K]=i.useState(null),ye=i.useCallback(async M=>{if(!(!t||je)){K(M);try{if(!await Rp(t,M)){ce.error(a("rightSidebar.contextNotesTodo.toast.deletePlanFailed"));return}w(ie=>ie.filter(Oe=>Oe.id!==M)),window.dispatchEvent(new CustomEvent("openchamber:project-plan-saved",{detail:{projectId:t.id}}))}finally{K(null)}}},[je,t,a]),Le=i.useCallback(async()=>{if(!t||z)return;const M=await ap({defaultPath:t.path,filters:[{name:"Plan files",extensions:["md","markdown","txt"]},{name:"All files",extensions:["*"]}]});if(M.success&&M.path){xe(!0);try{const le=new URLSearchParams({path:M.path,allowOutsideWorkspace:"true"});M.outsideFileGrant&&le.set("outsideFileGrant",M.outsideFileGrant);const ie=await As(`/api/fs/read?${le.toString()}`,{cache:"no-store"});if(!ie.ok){ce.error(a("rightSidebar.contextNotesTodo.toast.readPlanFileFailed"));return}const Oe=await ie.text();if(!Oe.trim()){ce.error(a("rightSidebar.contextNotesTodo.toast.planFileEmpty"));return}const Ge=M.path.split("/").pop()?.replace(/\.(md|markdown|txt)$/i,"").trim()||"";if(!await Cd(t,Oe,Ge)){ce.error(a("rightSidebar.contextNotesTodo.toast.importPlanFailed"));return}window.dispatchEvent(new CustomEvent("openchamber:project-plan-saved",{detail:{projectId:t.id}})),ce.success(a("rightSidebar.contextNotesTodo.toast.planImported"))}catch(le){const ie=le instanceof Error?le.message:void 0;ce.error(a("rightSidebar.contextNotesTodo.toast.readPlanFileFailed"),ie?{description:ie}:void 0)}finally{xe(!1)}}else M.error==="Native file picker not available"&&be.current?.click()},[z,t,a]),Re=i.useCallback(async M=>{if(!(!t||!M)){xe(!0);try{const le=await M.text();if(!le.trim()){ce.error(a("rightSidebar.contextNotesTodo.toast.planFileEmpty"));return}const ie=M.name.replace(/\.(md|markdown|txt)$/i,"").trim();if(!await Cd(t,le,ie)){ce.error(a("rightSidebar.contextNotesTodo.toast.importPlanFailed"));return}window.dispatchEvent(new CustomEvent("openchamber:project-plan-saved",{detail:{projectId:t.id}})),ce.success(a("rightSidebar.contextNotesTodo.toast.planImported"))}catch(le){const ie=le instanceof Error?le.message:void 0;ce.error(a("rightSidebar.contextNotesTodo.toast.readPlanFileFailed"),ie?{description:ie}:void 0)}finally{xe(!1)}}},[t,a]),X=i.useCallback(M=>{const le=t?.path?.trim(),ie=Se?.trim()||le;ie&&te(ie,{mode:"plan",targetPath:M.path,dedupeKey:M.path,label:M.title})},[Se,te,t]);return t?s.jsxs("div",{className:Pe("w-full min-w-0 space-y-3 p-3",o),children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("h3",{className:"min-w-0 truncate typography-ui-label font-semibold text-foreground",title:t.path,children:a("rightSidebar.contextNotesTodo.notes.title",{project:e?.trim()||t.path.split("/").filter(Boolean).pop()||t.path})}),s.jsxs("span",{className:"typography-meta text-muted-foreground",children:[d.length,"/",Ad]})]}),s.jsx(ki,{value:d,onChange:M=>u(M.target.value.slice(0,Ad)),onBlur:Ne,placeholder:a("rightSidebar.contextNotesTodo.notes.placeholder"),resizedHeight:R,onResizeHeightChange:B,useScrollShadow:!0,scrollShadowSize:56,disabled:c})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("h3",{className:"typography-ui-label font-semibold text-foreground",children:a("rightSidebar.contextNotesTodo.todo.title")}),s.jsx("span",{className:"typography-meta text-muted-foreground",children:m.length===1?a("rightSidebar.contextNotesTodo.todo.itemsSingle",{count:m.length}):a("rightSidebar.contextNotesTodo.todo.itemsPlural",{count:m.length})}),s.jsx("button",{type:"button",onClick:he,disabled:c||U===0,className:"typography-meta rounded-md px-1.5 py-0.5 text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 disabled:cursor-not-allowed disabled:opacity-50",children:a("rightSidebar.contextNotesTodo.todo.clearCompleted")})]}),s.jsxs("span",{className:"typography-meta text-muted-foreground",children:[ue.length,"/",zo]})]}),s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(vn,{value:ue,onChange:M=>b(M.target.value.slice(0,zo)),onKeyDown:M=>{M.key==="Enter"&&(M.preventDefault(),De())},placeholder:a("rightSidebar.contextNotesTodo.todo.inputPlaceholder"),disabled:c,className:"h-8"}),s.jsx("button",{type:"button",onClick:De,disabled:c||ue.trim().length===0,className:"inline-flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-md border border-border/70 text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 disabled:cursor-not-allowed disabled:opacity-50","aria-label":a("rightSidebar.contextNotesTodo.todo.addAria"),title:a("rightSidebar.contextNotesTodo.todo.addAria"),children:s.jsx(D,{name:"add",className:"h-4 w-4"})})]}),s.jsx("div",{className:Pe("overflow-y-auto rounded-lg border border-border/60 bg-background/40",V&&"transition-none"),style:m.length<7?void 0:{height:`${T}px`,maxHeight:`${T}px`},children:m.length===0?s.jsx("p",{className:"px-3 py-3 typography-meta text-muted-foreground",children:a("rightSidebar.contextNotesTodo.todo.empty")}):s.jsx(ba,{sensors:pe,collisionDetection:ya,onDragEnd:Ae,children:s.jsx(Bl,{items:m.map(M=>M.id),strategy:Vl,children:s.jsx("ul",{className:"divide-y divide-border/50",children:m.map(M=>{const le=y.has(M.id);return s.jsx(Ny,{id:M.id,children:ie=>s.jsxs("div",{className:Pe("flex gap-1.5 px-2.5 py-1.5",le?"items-start":"items-center"),children:[s.jsx("button",{type:"button",ref:ie.setActivatorNodeRef,...ie.attributes,...ie.listeners,onClick:Oe=>{Oe.preventDefault(),Oe.stopPropagation()},className:"flex h-6 w-4 flex-shrink-0 touch-none items-center justify-center text-muted-foreground hover:text-foreground","aria-label":a("rightSidebar.contextNotesTodo.todo.actions.reorder",{text:M.text}),title:a("rightSidebar.contextNotesTodo.todo.actions.reorder",{text:M.text}),children:s.jsx(D,{name:"draggable",className:"h-3.5 w-3.5"})}),s.jsx("div",{className:"flex h-6 items-center",children:s.jsx(Ti,{checked:M.completed,onChange:Oe=>Fe(M.id,Oe),ariaLabel:a("rightSidebar.contextNotesTodo.todo.actions.markComplete",{text:M.text})})}),s.jsx("button",{type:"button",onClick:()=>Be(M.id),className:Pe("block min-h-6 min-w-0 flex-1 bg-transparent p-0 text-left typography-ui-label leading-normal text-foreground",le?"whitespace-normal break-words":"overflow-hidden text-ellipsis whitespace-nowrap","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",M.completed&&"text-muted-foreground line-through"),title:le?void 0:M.text,"aria-label":le?a("rightSidebar.contextNotesTodo.todo.actions.collapse",{text:M.text}):a("rightSidebar.contextNotesTodo.todo.actions.expand",{text:M.text}),children:M.text}),s.jsxs("div",{className:"flex h-6 items-center gap-0.5",children:[s.jsx("button",{type:"button",onClick:()=>Me(M.id),className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":a("rightSidebar.contextNotesTodo.todo.actions.delete",{text:M.text}),title:a("rightSidebar.contextNotesTodo.todo.actions.delete",{text:M.text}),children:s.jsx(D,{name:"delete-bin",className:"h-3.5 w-3.5"})}),s.jsxs(sn,{children:[s.jsx(en,{asChild:!0,children:s.jsx("button",{type:"button",disabled:p===M.id,className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 disabled:cursor-not-allowed disabled:opacity-50","aria-label":a("rightSidebar.contextNotesTodo.todo.actions.send",{text:M.text}),title:a("rightSidebar.contextNotesTodo.todo.actions.send",{text:M.text}),children:s.jsx(D,{name:"send-plane",className:"h-3.5 w-3.5"})})}),s.jsxs(tn,{align:"end",className:"w-56",children:[s.jsx(bs,{onClick:()=>G(M.text),children:a("rightSidebar.contextNotesTodo.todo.sendMenu.currentSession")}),s.jsx(bs,{onClick:()=>de(M.id,M.text),children:a("rightSidebar.contextNotesTodo.todo.sendMenu.newSession")}),s.jsx(bs,{onClick:()=>{$(M.id,M.text)},disabled:!n,children:a("rightSidebar.contextNotesTodo.todo.sendMenu.newWorktreeSession")})]})]})]})]})},M.id)})})})})}),m.length>=7&&s.jsx("div",{className:Pe("h-[3px] w-full cursor-row-resize hover:bg-[var(--interactive-border)]/80 transition-colors",V&&"bg-[var(--interactive-border)]"),onPointerDown:se,role:"separator","aria-orientation":"horizontal","aria-label":a("rightSidebar.contextNotesTodo.todo.resizeAria")})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("h3",{className:"typography-ui-label font-semibold text-foreground",children:a("rightSidebar.contextNotesTodo.plans.title")}),s.jsx("span",{className:"typography-meta text-muted-foreground",children:C.length===1?a("rightSidebar.contextNotesTodo.plans.filesSingle",{count:C.length}):a("rightSidebar.contextNotesTodo.plans.filesPlural",{count:C.length})})]}),s.jsx("input",{ref:be,type:"file",accept:".md,.markdown,.txt,text/markdown,text/plain",className:"hidden",onChange:M=>{const le=M.target.files?.[0]??null;Re(le),M.currentTarget.value=""}}),s.jsx("button",{type:"button",onClick:Le,disabled:!t||z,className:"inline-flex h-6 w-6 items-center justify-center rounded-md border border-border/70 text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 disabled:cursor-not-allowed disabled:opacity-50","aria-label":a("rightSidebar.contextNotesTodo.plans.importFromFile"),title:a("rightSidebar.contextNotesTodo.plans.importFromFile"),children:s.jsx(D,{name:"add",className:"h-3.5 w-3.5"})})]}),s.jsx("div",{className:"max-h-56 overflow-y-auto rounded-lg border border-border/60 bg-background/40",children:C.length===0?s.jsx("p",{className:"px-3 py-3 typography-meta text-muted-foreground",children:a("rightSidebar.contextNotesTodo.plans.empty")}):s.jsx("ul",{className:"divide-y divide-border/50",children:C.map(M=>s.jsxs("li",{className:"flex items-center gap-1.5 px-2.5 py-1.5",children:[s.jsxs("button",{type:"button",onClick:()=>X(M),className:"flex min-w-0 flex-1 items-center justify-between gap-3 rounded-md px-1.5 py-1 text-left hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",children:[s.jsx("span",{className:"min-w-0 truncate typography-ui-label text-foreground",children:M.title}),s.jsx("span",{className:"flex-shrink-0 typography-micro text-muted-foreground",children:new Date(M.createdAt).toLocaleDateString(Xi())})]}),s.jsx("button",{type:"button",onClick:()=>{ye(M.id)},disabled:je===M.id,className:"inline-flex h-6 w-6 flex-shrink-0 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 disabled:cursor-not-allowed disabled:opacity-50",title:a("rightSidebar.contextNotesTodo.plans.deletePlan"),"aria-label":a("rightSidebar.contextNotesTodo.plans.deletePlanWithTitle",{title:M.title}),children:s.jsx(D,{name:"delete-bin",className:"h-3.5 w-3.5"})})]},M.id))})})]}),s.jsx(Am,{open:S!==null,onOpenChange:M=>{!M&&!k&&j(null)},target:S?.kind??"session",projectDirectory:t?.path??null,submitting:k,onConfirm:ve})]}):s.jsx("div",{className:Pe("w-full min-w-0 p-3",o),children:s.jsx("p",{className:"typography-meta text-muted-foreground",children:a("rightSidebar.contextNotesTodo.empty.selectProject")})})},Im=12,Cy=[{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"}],Ay=t=>{const e=mt.c(18),{isActive:n,burstKey:r,className:o,durationMs:a,bursts:c,onComplete:l}=t,d=r===void 0?0:r,u=a===void 0?900:a,m=c===void 0?Cy:c,f=Xe.useRef(!1);let g,b;e[0]!==n||e[1]!==l?(g=()=>{!n&&f.current&&l?.(),n&&(f.current=!0)},b=[n,l],e[0]=n,e[1]=l,e[2]=g,e[3]=b):(g=e[2],b=e[3]),Xe.useEffect(g,b);let p;e[4]===Symbol.for("react.memo_cache_sentinel")?(p=Array.from({length:Im},Dy),e[4]=p):p=e[4];const x=p;if(!n)return null;let y;e[5]!==o?(y=Pe("fireworks-overlay pointer-events-none",o),e[5]=o,e[6]=y):y=e[6];let h;if(e[7]!==d||e[8]!==m||e[9]!==u){let w;e[11]!==d||e[12]!==u?(w=S=>{const j={"--burst-delay":`${S.delay}ms`,"--burst-x":`${S.x}%`,"--burst-y":`${S.y}%`,"--firework-color":`var(${S.colorVar})`,"--firework-duration":`${u}ms`};return s.jsx("div",{className:"firework-burst",style:j,children:x.map((k,v)=>{const A=k.x*S.radius,I=k.y*S.radius,N={"--translate-x":`${A}px`,"--translate-y":`${I}px`,"--particle-delay":`${k.delay}ms`,color:`var(${S.colorVar})`};return s.jsx("span",{className:"firework-particle",style:N},`${S.id}-${v}-${d}`)})},`${S.id}-${d}`)},e[11]=d,e[12]=u,e[13]=w):w=e[13],h=m.map(w),e[7]=d,e[8]=m,e[9]=u,e[10]=h}else h=e[10];let C;return e[14]!==d||e[15]!==y||e[16]!==h?(C=s.jsx("div",{className:y,"aria-hidden":"true","data-burst-key":d,children:h}),e[14]=d,e[15]=y,e[16]=h,e[17]=C):C=e[17],C};function Dy(t,e){const n=Math.PI*2*e/Im;return{x:Math.cos(n),y:Math.sin(n),delay:e*18}}const Iy=t=>{const e=mt.c(13);let n;e[0]!==t?(n={},e[0]=t,e[1]=n):n=e[1];const{durationMs:r}=n,o=r===void 0?3400:r;let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a={isActive:!1,cycle:0},e[2]=a):a=e[2];const[c,l]=Xe.useState(a),d=Xe.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(),l(Py)},e[4]=f):f=e[4];const g=f;let b;e[5]!==o?(b=()=>{m(),l(Ty),d.current=window.setTimeout(()=>{l(Ry),d.current=null},o)},e[5]=o,e[6]=b):b=e[6];const p=b;let x,y;e[7]===Symbol.for("react.memo_cache_sentinel")?(x=()=>()=>m(),y=[m],e[7]=x,e[8]=y):(x=e[7],y=e[8]),Xe.useEffect(x,y);let h;return e[9]!==c.cycle||e[10]!==c.isActive||e[11]!==p?(h={isActive:c.isActive,burstKey:c.cycle,triggerFireworks:p,dismissFireworks:g},e[9]=c.cycle,e[10]=c.isActive,e[11]=p,e[12]=h):h=e[12],h};function Py(t){return t.isActive?{...t,isActive:!1}:t}function Ty(t){return{isActive:!0,cycle:t.cycle+1}}function Ry(t){return t.isActive?{...t,isActive:!1}:t}const Pm=i.createContext(void 0),Ey=t=>{const e=mt.c(10),{children:n}=t,{isActive:r,burstKey:o,triggerFireworks:a,dismissFireworks:c}=Iy();let l;e[0]!==c||e[1]!==a?(l={triggerFireworks:a,dismissFireworks:c},e[0]=c,e[1]=a,e[2]=l):l=e[2];const d=l;let u;e[3]!==o||e[4]!==r?(u=s.jsx(Ay,{isActive:r,burstKey:o}),e[3]=o,e[4]=r,e[5]=u):u=e[5];let m;return e[6]!==n||e[7]!==u||e[8]!==d?(m=s.jsxs(Pm.Provider,{value:d,children:[n,u]}),e[6]=n,e[7]=u,e[8]=d,e[9]=m):m=e[9],m},My=()=>{const t=i.useContext(Pm);if(!t)throw new Error("useFireworksCelebration must be used within FireworksProvider");return t},Tm="gitmojiCache",Fy=1e3*60*60*24*7,Rm="1",Ly="https://raw.githubusercontent.com/carloscuesta/gitmoji/master/packages/gitmojis/src/gitmojis.json",Em=t=>{if(!t||typeof t!="object")return!1;const e=t;return typeof e.emoji=="string"&&typeof e.code=="string"&&typeof e.description=="string"},pl=()=>{if(typeof window>"u")return null;try{const t=window.localStorage.getItem(Tm);if(!t)return null;const e=JSON.parse(t);return!e||e.version!==Rm||typeof e.fetchedAt!="number"||!Array.isArray(e.gitmojis)?null:{gitmojis:e.gitmojis.filter(Em),fetchedAt:e.fetchedAt,version:e.version}}catch{return null}},Oy=t=>{if(!(typeof window>"u"))try{const e={gitmojis:t,fetchedAt:Date.now(),version:Rm};window.localStorage.setItem(Tm,JSON.stringify(e))}catch{return}},du=t=>Date.now()-t.fetchedAt<Fy;let Ko=null;const So=new Set,uu=async()=>{if(Ko)return Ko;const t=(async()=>{try{const e=await fetch(Ly);if(!e.ok)throw new Error(`Failed to load gitmojis: ${e.statusText}`);const n=await e.json(),r=Array.isArray(n.gitmojis)?n.gitmojis.filter(Em):[];return Oy(r),So.forEach(o=>o(r)),r}catch(e){console.warn("Failed to load gitmoji list:",e);const n=[];return So.forEach(r=>r(n)),n}finally{Ko=null}})();return Ko=t,t},By=t=>{const[e,n]=i.useState(()=>t?pl()?.gitmojis??[]:[]),[r,o]=i.useState(!1),a=i.useRef(t);a.current=t,i.useEffect(()=>{if(!t){So.delete(n),n([]),o(!1);return}const l=pl();if(l&&(n(l.gitmojis),du(l)))return;So.add(n),o(!0);let d=!1;return uu().finally(()=>{!d&&a.current&&o(!1)}),()=>{d=!0,So.delete(n)}},[t]);const c=i.useCallback(async()=>{if(!a.current)return[];if(e.length>0)return e;const l=pl();return l&&du(l)?l.gitmojis:uu()},[e]);return{gitmojis:e,isLoading:r,ensureLoaded:c}},fu=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")};function Vy(t,e,n){const r=mt.c(5),[o,a]=i.useState();let c,l;return r[0]!==n||r[1]!==t||r[2]!==e?(c=()=>{if(e){a(void 0);return}if(!t){a(void 0);return}a(void 0);let d=!1;return(async()=>{const[u,m]=await Promise.all([Mp(t),Fp(t)]).catch(_y);if(d)return;const f=fu(u),g=fu(m);if(!f||!g||g===f)return;const b=n||"",p=g.split("/").filter(Boolean).pop()||g;a({source:"sdk",path:g,projectDirectory:f,branch:b,label:b||p,name:p,worktreeRoot:g,worktreeStatus:"ready",headState:b?"branch":"unborn",worktreeSource:"existing"})})(),()=>{d=!0}},l=[t,e,n],r[0]=n,r[1]=t,r[2]=e,r[3]=c,r[4]=l):(c=r[3],l=r[4]),i.useEffect(c,l),e??o}function _y(){return["",""]}const ao=async(t,e)=>{const n=await As(`/api/git/integrate/${t}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!n.ok){const r=await n.json().catch(()=>null);throw new Error(r?.error||`Git integrate request failed: ${n.statusText}`)}return n.json()};async function ho(t){return ao("plan",t)}async function $y(t){return ao("conflict-details",{tempWorktreePath:t})}async function zy(t){return(await ao("cherry-pick-status",{tempWorktreePath:t})).inProgress}async function Wy(t){return ao("run",{plan:t})}async function Uy(t){await ao("abort",{state:t})}async function Hy(t){return ao("continue",{state:t})}const Gy=({repoRoot:t,sourceBranch:e,worktreeMetadata:n,localBranches:r,defaultTargetBranch:o,refreshKey:a,onRefresh:c})=>{const{t:l}=Nt(),d=ut(E=>E.currentSessionId),u=Ee(E=>E.setActiveMainTab),[m,f]=Xe.useState(!1),g=Xe.useRef(null),[b,p]=Xe.useState(o);Xe.useEffect(()=>{p(o)},[o]),Xe.useEffect(()=>{if(m){const E=setTimeout(()=>{g.current?.focus()},0);return()=>clearTimeout(E)}},[m]);const x=!!(t&&e&&b&&b!=="HEAD"&&e!==b),[y,h]=Xe.useState({kind:"idle"}),[C,w]=Xe.useState(!1),[S,j]=Xe.useState([]),k=Xe.useMemo(()=>d?`openchamber.integrate.conflict:${d}`:null,[d]);Xe.useEffect(()=>{if(!k||typeof window>"u")return;const E=window.localStorage.getItem(k);if(!E)return;let Z=!1;try{const ne=JSON.parse(E);if(!ne?.tempWorktreePath||ne.repoRoot!==t){window.localStorage.removeItem(k);return}(async()=>{const Y=await zy(ne.tempWorktreePath).catch(()=>!1);if(Z)return;if(!Y){window.localStorage.removeItem(k);return}const H=await $y(ne.tempWorktreePath).catch(()=>null);Z||H&&h({kind:"conflict",state:ne,details:H})})()}catch{window.localStorage.removeItem(k)}return()=>{Z=!0}},[k,t]),Xe.useEffect(()=>{if(!x){h({kind:"idle"});return}let E=!1;return h({kind:"loading"}),(async()=>{try{const Z=await ho({repoRoot:t,sourceBranch:e,targetBranch:b});if(E)return;if(h({kind:"ready",plan:Z}),Z.commits.length>0){const Y=Z.commits.slice(-50).reverse(),H=await Lp(t,Y);E||(j(H),w(!1))}else E||(j([]),w(!1))}catch{E||h({kind:"idle"})}})(),()=>{E=!0}},[x,t,e,b,a]);const v=Xe.useCallback(E=>{d&&ut.getState().setWorktreeMetadata(d,{...n,createdFromBranch:E})},[d,n]),A=ut(E=>E.openNewSessionDraft),I=Xe.useCallback(async E=>{const Z=await Tn("git.integrate.cherrypick.resolve.visible",{current_commit:E.state.currentCommit,target_branch:E.state.targetBranch}),ne=await Tn("git.integrate.cherrypick.resolve.instructions",{repo_root:E.state.repoRoot,temp_worktree_path:E.state.tempWorktreePath,source_branch:E.state.sourceBranch,target_branch:E.state.targetBranch,current_commit:E.state.currentCommit}),Y=`Cherry-pick conflict context (JSON)
|
|
@@ -210,5 +210,5 @@ ${e.trim()}
|
|
|
210
210
|
Now write the final fused answer.`,synthetic:!0}],directory:Z??Vn.getDirectory()})}catch(_){console.error("[MultiRunFusion] Failed to start fusion",_),ce.error(r("multirun.fusion.toast.failed"))}finally{A(!1)}}};return s.jsx($s,{open:e,onOpenChange:n,children:s.jsxs(_s,{className:"max-w-xl overflow-visible",children:[s.jsxs(Hs,{children:[s.jsx(Us,{children:r("multirun.fusion.title")}),s.jsx(on,{children:r("multirun.fusion.description")})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("div",{className:"max-w-full",children:s.jsx(gh,{selectedModels:x,onAdd:R,onUpdate:(_,E)=>R(E),onRemove:()=>{y([]),g(""),p(""),C("")},maxModels:1,addButtonLabel:B,showChips:!1,addButtonClassName:"h-8 w-fit max-w-[min(28rem,calc(100vw-8rem))] justify-start rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] px-3 py-1.5",dropdownSide:"bottom",dropdownClassName:"w-[min(28rem,calc(100vw-8rem))]",triggerIcon:f?s.jsx(Do,{providerId:f,className:"h-3.5 w-3.5 mr-1"}):void 0})}),T.length>0?s.jsxs($n,{value:h||"__default__",onValueChange:_=>C(_==="__default__"?"":_),children:[s.jsxs(zn,{size:"lg",className:"h-8 w-fit rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] !border-border/80 !bg-[var(--surface-subtle)] hover:!bg-[var(--interactive-hover)]/70 typography-meta font-medium text-foreground px-3 py-1.5",children:[s.jsx(D,{name:"brain-ai-3",className:"h-3.5 w-3.5 text-muted-foreground"}),s.jsx(Nn,{children:_=>_==="__default__"?r("multirun.modelMultiSelect.variant.default"):_})]}),s.jsxs(Wn,{fitContent:!0,portalToBody:!0,children:[s.jsx(Ls,{value:"__default__",children:r("multirun.modelMultiSelect.variant.default")}),T.map(_=>s.jsx(Ls,{value:_,children:_},_))]})]}):null,s.jsx(hh,{value:w,onChange:S,portalToBody:!0,className:"h-8 rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] px-3 py-1.5"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"typography-meta font-medium text-foreground",children:r("multirun.fusion.sources.label",{count:j.length})}),s.jsx("div",{className:"max-h-56 space-y-1 overflow-auto rounded-lg border border-[var(--interactive-border)] p-1",children:j.map(_=>s.jsxs("div",{className:"flex items-center gap-2 rounded-md px-2 py-1.5 typography-meta",children:[s.jsx(Do,{providerId:ha(_.session.title)?.providerID??"",className:"h-4 w-4"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:_.session.title||_.session.id}),s.jsx("button",{type:"button",onClick:()=>k(E=>E.filter(Z=>Z.session.id!==_.session.id)),className:"text-muted-foreground hover:text-foreground",children:s.jsx(D,{name:"close",className:"h-4 w-4"})})]},_.session.id))})]}),s.jsxs(ir,{children:[s.jsx($e,{variant:"ghost",onClick:()=>n(!1),children:r("multirun.fusion.actions.cancel")}),s.jsx($e,{onClick:V,disabled:!L,children:r(v?"multirun.fusion.actions.starting":"multirun.fusion.actions.start")})]})]})})}function R2(t){const e=mt.c(7);let n,r,o,a,c;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx("path",{d:"M12 4.5v6.25M12 10.75v3.5M12 10.75H7.25A3.25 3.25 0 0 0 4 14v1.25M12 10.75h4.75A3.25 3.25 0 0 1 20 14v1.25",stroke:"currentColor",strokeWidth:"1.65",strokeLinecap:"round",strokeLinejoin:"round"}),r=s.jsx("path",{d:"M9.25 7.25 12 4.5l2.75 2.75",stroke:"currentColor",strokeWidth:"1.65",strokeLinecap:"round",strokeLinejoin:"round"}),o=s.jsx("circle",{cx:"4",cy:"17.25",r:"1.55",stroke:"currentColor",strokeWidth:"1.65"}),a=s.jsx("circle",{cx:"12",cy:"17.25",r:"1.55",stroke:"currentColor",strokeWidth:"1.65"}),c=s.jsx("circle",{cx:"20",cy:"17.25",r:"1.55",stroke:"currentColor",strokeWidth:"1.65"}),e[0]=n,e[1]=r,e[2]=o,e[3]=a,e[4]=c):(n=e[0],r=e[1],o=e[2],a=e[3],c=e[4]);let l;return e[5]!==t?(l=s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",...t,children:[n,r,o,a,c]}),e[5]=t,e[6]=l):l=e[6],l}const E2=i.memo(function(e){const n=mt.c(22),{archiveLabel:r,deleteLabel:o,buttonSizeClass:a,iconSizeClass:c,onPointerDown:l,onMouseDown:d,onArchive:u,onDelete:m}=e,f=f2(),g=f?o:r;let b;n[0]!==u||n[1]!==m||n[2]!==f?(b=k=>{if(f||k.shiftKey){m(k);return}u(k)},n[0]=u,n[1]=m,n[2]=f,n[3]=b):b=n[3];const p=b,x=f?"text-destructive hover:text-destructive":"text-muted-foreground hover:text-foreground";let y;n[4]!==a||n[5]!==x?(y=Pe("inline-flex items-center justify-center rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 transition-opacity",x,a),n[4]=a,n[5]=x,n[6]=y):y=n[6];const h=f?"delete-bin":"archive";let C;n[7]!==c||n[8]!==h?(C=s.jsx(D,{name:h,className:c}),n[7]=c,n[8]=h,n[9]=C):C=n[9];let w;n[10]!==p||n[11]!==g||n[12]!==d||n[13]!==l||n[14]!==y||n[15]!==C?(w=s.jsx(Mt,{asChild:!0,children:s.jsx("button",{type:"button",className:y,"aria-label":g,onPointerDown:l,onMouseDown:d,onClick:p,onKeyDown:_2,children:C})}),n[10]=p,n[11]=g,n[12]=d,n[13]=l,n[14]=y,n[15]=C,n[16]=w):w=n[16];let S;n[17]!==g?(S=s.jsx(Ft,{side:"left",sideOffset:8,children:g}),n[17]=g,n[18]=S):S=n[18];let j;return n[19]!==w||n[20]!==S?(j=s.jsxs(Et,{children:[w,S]}),n[19]=w,n[20]=S,n[21]=j):j=n[21],j});function M2(t){const{t:e}=Nt(),{node:n,depth:r=0,groupDirectory:o,projectId:a,archivedBucket:c=!1,currentSessionId:l,pinnedSessionIds:d,expandedParents:u,hasSessionSearchQuery:m,normalizedSessionSearchQuery:f,notifyOnSubtasks:g,editingId:b,setEditingId:p,editTitle:x,setEditTitle:y,handleSaveEdit:h,handleCancelEdit:C,toggleParent:w,handleSessionSelect:S,handleSessionDoubleClick:j,togglePinnedSession:k,handleShareSession:v,copiedSessionId:A,handleCopyShareUrl:I,handleUnshareSession:N,openSidebarMenuKey:O,setOpenSidebarMenuKey:P,renamingFolderId:T,getFoldersForScope:L,getSessionFolderId:R,removeSessionFromFolder:B,addSessionToFolder:V,createFolderAndStartRename:_,openContextPanelTab:E,handleDeleteSession:Z,mobileVariant:ne,alwaysShowActions:Y,renderSessionNode:H,secondaryMeta:re,renderContext:ae="project",subtreeContainsActive:me,subtreeContainsEditing:Se,menuOpenSessionId:te,childRenderExtrasFor:ke,liveSessionById:Q}=t,ge=!!re?.projectLabel,F=!!re?.branchLabel,se=Dr(Ue=>Ue.displayMode),ee=i.useMemo(()=>Gr(),[]),Ne=se==="minimal"||ee,De=i.useMemo(()=>Fa(),[]),Be=i.useContext(Pg),Fe=ee?"group-hover:opacity-100 group-hover:pointer-events-auto":"group-hover:opacity-100 group-hover:pointer-events-auto group-focus-within:opacity-100 group-focus-within:pointer-events-auto",Me=ee?"group-hover:opacity-0":"group-hover:opacity-0 group-focus-within:opacity-0",he=ee,Ae=!c&&!ne,pe=Ne?ee?Ae&&he?"group-hover:pr-18":Ae||he?"group-hover:pr-14":"group-hover:pr-8":"group-hover:pr-2 group-focus-within:pr-2":ee?Ae&&he?"group-hover:pr-18":Ae||he?"group-hover:pr-12":"group-hover:pr-5":Ae?"group-hover:pr-12 group-focus-within:pr-12":"group-hover:pr-5 group-focus-within:pr-5",ue=Ae?"pr-13":"pr-7",U=i.useRef(!1),[fe,de]=i.useState(!1),G=i.useRef(b);G.current=b;const $=i.useRef(null),ve=i.useRef(h);ve.current=h;const[be,z]=i.useState(x),xe=i.useRef(be);xe.current=be;const je=i.useRef(null),K=i.useRef(null),ye=n.session,Le=Q.get(ye.id)??ye,Re=cs(ye.directory??null)??cs(o??null),X=Tg(Re??void 0,{bootstrap:!c}),M=Pc(),le=Bn(Ue=>Ue.enabled),ie=Bn(i.useCallback(Ue=>Ue.selectedIds.has(ye.id),[ye.id])),Oe=Bn(Ue=>Ue.toggleSelected),Ge=Bn(Ue=>Ue.setRange),He=i.useCallback(Ue=>{const os=[],fs=zs=>{zs.children.forEach(Ks=>{os.push(Ks.session.id),fs(Ks)})};return fs(Ue),os},[]),[Je,rt]=i.useState(!1),[bt,yt]=i.useState(!0),_e=`${ae}:${c?"archived":"active"}:${ye.id}`,Ye=am(i.useCallback(Ue=>!!Ue.sessionMemoryState.get(Rg(ye.id))?.isZombie,[ye.id])),nt=Eg(ye.id),wt=Mg(ye.id,Re??void 0),kt=l===ye.id,vt=Le.title||e("sessions.sidebar.session.untitled"),St=n.children.length>0,et=d.has(ye.id),Ot=_e,ns=m?!0:u.has(Ot),Wt=!!Le.parentID,Ze=Fg(ye.id)>0&&(!Wt||g),_t=Le.time?.updated||Le.time?.created||Date.now(),jt=cb(_t),xt=db(_t),rs=O===_e,[Gt,Ut]=i.useState(!1),as=rs||Gt,Bt=i.useMemo(()=>ha(Le.title)!==null,[Le.title]),[Lt,Vt]=i.useState(!1),Kt=ee&&ae==="recent"&&!Ne,Xt=ee&&ae==="recent"&&Ne,Qt=i.useMemo(()=>He(n).length,[He,n]),vs=i.useCallback(async Ue=>{const os=[];let fs=0;for(const zs of Ue)try{await M.ensureSessionRenderable(zs.session.id);const Ks=Od(X.getState(),zs.session.id).list,Ws=zs.session.title||e("sessions.sidebar.session.export.untitledSubagent"),pn=zs.session.agent,Ns=await vs(zs.children);fs+=Ns.skipped,os.push({title:Ws,agent:pn,records:Ks,children:Ns.children})}catch{fs+=He(zs).length+1}return{children:os,skipped:fs}},[He,X,M,e]),Dt=i.useCallback(Ue=>{Ue<=0||ce.warning(Ue===1?e("sessions.sidebar.session.export.skippedSubtaskSingle",{count:Ue}):e("sessions.sidebar.session.export.skippedSubtaskMany",{count:Ue}))},[e]),$t=i.useCallback(async Ue=>{if(!Re){ce.error(e("sessions.sidebar.session.export.nothingToExport"));return}await M.ensureSessionRenderable(ye.id);const os=Od(X.getState(),ye.id).list;if(os.length===0){ce.error(e("sessions.sidebar.session.export.nothingToExport"));return}let fs,zs=0;if(Ue&&n.children.length>0){const Ns=await vs(n.children);fs=Ns.children,zs=Ns.skipped}const Ks=JN(os,Le.title??null,fs),Ws=s2(Le.title??null),pn=await ZN(Ks,Ws);if(pn){ce.success(e("sessions.sidebar.session.export.success"),{action:{label:e(t2()),onClick:()=>{e2(pn).then(Ns=>{Ns||ce.error(e("sessions.sidebar.session.export.failedRevealPath"))})}}}),Dt(zs);return}XN(Ks,Ws),ce.success(e("sessions.sidebar.session.export.success")),Dt(zs)},[vs,X,n.children,Le.title,ye.id,Re,Dt,M,e]),Ct=i.useCallback(async()=>{if(n.children.length>0){yt(!0),rt(!0);return}await $t(!1)},[$t,n.children.length]),ds=i.useCallback(()=>{Re&&Ur("desktop_open_session_mini_chat_window",{sessionId:ye.id,directory:Re,apiBaseUrl:Wr(),clientToken:zl()}).catch(Ue=>{console.warn("[session-sidebar] failed to open mini chat window",Ue)})},[ye.id,Re]);if(i.useEffect(()=>{if(b!==ye.id)return;const Ue=os=>{K.current&&!K.current.contains(os.target)&&ve.current(xe.current)};return document.addEventListener("mousedown",Ue),()=>document.removeEventListener("mousedown",Ue)},[b,ye.id]),i.useLayoutEffect(()=>{if(b!==ye.id){je.current===ye.id&&(je.current=null);return}je.current!==ye.id&&(je.current=ye.id,z(x))},[b,x,ye.id]),b===ye.id)return s.jsx("div",{className:Pe("group relative flex items-center rounded-sm px-1.5 py-1",r>0&&"pl-[20px]"),children:s.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0",children:[s.jsxs("form",{ref:K,className:"flex w-full items-center gap-2",onSubmit:Ue=>{Ue.preventDefault(),h(be)},children:[s.jsx("input",{value:be,onChange:Ue=>z(Ue.target.value),className:"flex-1 min-w-0 bg-transparent typography-ui-label outline-none placeholder:text-muted-foreground",autoFocus:!0,placeholder:e("sessions.sidebar.session.menu.rename"),onKeyDown:Ue=>{if(Ue.stopPropagation(),Ue.key==="Escape"){C();return}}}),s.jsx("button",{type:"submit","aria-label":e("sessions.sidebar.session.rename.save"),title:e("sessions.sidebar.session.rename.save"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(D,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:C,"aria-label":e("sessions.sidebar.session.rename.cancel"),title:e("sessions.sidebar.session.rename.cancel"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(D,{name:"close",className:"size-4"})})]}),Ne?null:s.jsx("div",{className:"flex items-center justify-between gap-3 text-muted-foreground/60 min-w-0 overflow-hidden leading-tight",style:{fontSize:"calc(var(--text-ui-label) * 0.85)"},children:s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 overflow-hidden",children:[St?s.jsx("span",{className:"inline-flex items-center justify-center flex-shrink-0",children:ns?s.jsx(D,{name:"arrow-down-s",className:"h-3 w-3"}):s.jsx(D,{name:"arrow-right-s",className:"h-3 w-3"})}):null,s.jsx("span",{className:"flex-shrink-0",children:jt}),ge?s.jsx("span",{className:"truncate",children:re?.projectLabel}):null,F?s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5",children:[s.jsx(D,{name:"git-branch",className:"h-3 w-3 flex-shrink-0 text-muted-foreground/70"}),s.jsx("span",{className:"truncate",children:re?.branchLabel})]}):null]})})]})},ye.id);const qe=nt?.type??"idle",at=qe==="busy"||qe==="retry",Qe=wt.length,Tt=at||!at&&Ze&&!kt,ts=at?s.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-primary animate-busy-pulse","aria-label":e("sessions.sidebar.session.status.active"),title:e("sessions.sidebar.session.status.active")}):s.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-[var(--status-info)]","aria-label":e("sessions.sidebar.session.status.unread"),title:e("sessions.sidebar.session.status.unread")}),xs=!Y&&St&&(Tt||et),ks=et&&!Tt,Jt=s.jsx(D,{name:"pushpin",className:"h-3 w-3 flex-shrink-0 text-primary","aria-label":e("sessions.sidebar.session.status.pinned")}),ls=Tt||ks?s.jsxs("span",{className:Pe("pointer-events-none absolute left-0.5 inline-flex h-3.5 w-3.5 items-center justify-center transition-opacity",Ne?"top-1/2 -translate-y-1/2":"top-[14.5px] -translate-y-1/2",xs?"opacity-100 group-hover:opacity-0 group-focus-within:opacity-0":""),children:[Tt?ts:null,ks?Jt:null]}):null,Ps=St&&!Y&&(Tt||et),Ts=St?s.jsx("span",{role:"button",tabIndex:0,onClick:Ue=>{Ue.stopPropagation(),w(Ot)},onKeyDown:Ue=>{(Ue.key==="Enter"||Ue.key===" ")&&(Ue.preventDefault(),Ue.stopPropagation(),w(Ot))},style:{minWidth:14,minHeight:14},className:Pe("inline-flex h-3.5 w-3.5 items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 transition-opacity",Kt?"absolute left-1.5 bottom-1":Xt?"relative mr-0.5 shrink-0":Pe("absolute left-0.5",Ne?"top-1/2 -translate-y-1/2":"top-[14.5px] -translate-y-1/2"),!Kt&&!Xt&&Ps?"opacity-0 pointer-events-none group-hover:opacity-100 group-hover:pointer-events-auto group-focus-within:opacity-100 group-focus-within:pointer-events-auto":""),"aria-label":e(ns?"sessions.sidebar.session.subsessions.collapse":"sessions.sidebar.session.subsessions.expand"),children:ns?s.jsx(D,{name:"arrow-down-s",className:"h-3 w-3"}):s.jsx(D,{name:"arrow-right-s",className:"h-3 w-3"})}):null,hn=Ye?s.jsx(D,{name:"error-warning",className:"h-4 w-4 text-status-warning"}):null,Gs=Ue=>{Ue&&Ut(!1),P(Ue?_e:null)},an=Ue=>{if(!Ue&&$.current){const{id:os,title:fs}=$.current;$.current=null,p(os),y(fs)}},Rn=Ue=>{Ut(Ue)},Os=Ue=>{Ue.preventDefault(),Ue.stopPropagation(),P(rs?null:_e)},we=Ue=>{Ue.preventDefault(),Ue.stopPropagation()},tt=Ue=>{Ue.preventDefault(),Ue.stopPropagation()},dt=Ue=>{Ue.preventDefault(),Ue.stopPropagation()},It=Ue=>{Ue.preventDefault(),Ue.stopPropagation()},Ht=Ue=>{Ue.preventDefault(),Ue.stopPropagation(),P(null),Z(ye,{archivedBucket:c})},ht=Ue=>{Ue.preventDefault(),Ue.stopPropagation(),P(null),Z(ye,{archivedBucket:c,hardDelete:!0,skipConfirm:!0})},hs=Ue=>{Ue.preventDefault(),Ue.stopPropagation()},ps=Ue=>{Ue.preventDefault(),Ue.stopPropagation()},js=Ue=>{Ue.preventDefault(),Ue.stopPropagation(),Be?.vscode?.executeCommand("openchamber.openSessionInEditor",ye.id,vt)},Ss=Ue=>{if(U.current){U.current=!1;return}if(le){if(Ue?.preventDefault(),Ue?.stopPropagation(),Ue?.shiftKey){const fs=(typeof document<"u"?Array.from(document.querySelectorAll("[data-session-row]")):[]).map(Ws=>Ws.getAttribute("data-session-row")).filter(Ws=>typeof Ws=="string"&&Ws.length>0),zs=Bn.getState().anchorId,Ks=new Map;Ks.set(ye.id,He(n)),Ge(zs,ye.id,fs,Re??null,Ks);return}Oe(ye.id,Re??null,He(n));return}S(ye.id,Re,a)},Ds=Ue=>{(Ue.button===2||Ue.button===0&&Ue.ctrlKey&&!le)&&(U.current=!0)},Un=Ue=>{ne&&Ue.pointerType==="touch"&&de(!0)},Es=Ue=>{ne&&Ue.pointerType==="touch"&&de(!1)},En=({Item:Ue,Separator:os,Sub:fs,SubTrigger:zs,SubContent:Ks})=>s.jsxs(s.Fragment,{children:[s.jsxs(Ue,{onClick:()=>{$.current={id:ye.id,title:vt}},className:"[&>svg]:mr-1",children:[s.jsx(D,{name:"pencil-ai",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.rename")]}),s.jsxs(Ue,{onClick:()=>k(ye.id),className:"[&>svg]:mr-1",children:[et?s.jsx(D,{name:"unpin",className:"mr-1 h-4 w-4"}):s.jsx(D,{name:"pushpin",className:"mr-1 h-4 w-4"}),e(et?"sessions.sidebar.session.menu.unpin":"sessions.sidebar.session.menu.pin")]}),Le.share?s.jsxs(s.Fragment,{children:[s.jsx(Ue,{onClick:()=>{Le.share?.url&&I(Le.share.url,ye.id)},className:"[&>svg]:mr-1",children:A===ye.id?s.jsxs(s.Fragment,{children:[s.jsx(D,{name:"check",className:"mr-1 h-4 w-4",style:{color:"var(--status-success)"}}),e("sessions.sidebar.session.menu.copied")]}):s.jsxs(s.Fragment,{children:[s.jsx(D,{name:"file-copy",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.copyLink")]})}),s.jsxs(Ue,{onClick:()=>N(ye.id),className:"[&>svg]:mr-1",children:[s.jsx(D,{name:"link-unlink-m",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.unshare")]})]}):s.jsxs(Ue,{onClick:()=>v(Le),className:"[&>svg]:mr-1",children:[s.jsx(D,{name:"share-2",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.share")]}),s.jsxs(Ue,{onClick:()=>{Ct()},className:"[&>svg]:mr-1",children:[s.jsx(D,{name:"download",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.exportMarkdown")]}),Bt?s.jsxs(Ue,{onClick:()=>Vt(!0),className:"[&>svg]:mr-1",children:[s.jsx(R2,{className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.runFusion")]}):null,Re&&!c?(()=>{const Ws=L(Re),pn=R(Re,ye.id);return s.jsxs(s.Fragment,{children:[s.jsx(os,{}),s.jsxs(fs,{children:[s.jsxs(zs,{className:"[&>svg]:mr-1",children:[s.jsx(D,{name:"folder",className:"h-4 w-4"}),e("sessions.sidebar.folders.moveToFolder")]}),s.jsxs(Ks,{className:"min-w-[180px]",children:[Ws.length===0?s.jsx(Ue,{disabled:!0,className:"text-muted-foreground",children:e("sessions.sidebar.folders.none")}):Ws.map(Ns=>s.jsxs(Ue,{onClick:()=>{pn===Ns.id?B(Re,ye.id):V(Re,Ns.id,ye.id)},children:[s.jsx("span",{className:"flex-1 truncate",children:Ns.name}),pn===Ns.id?s.jsx(D,{name:"check",className:"ml-2 h-3.5 w-3.5 text-primary flex-shrink-0"}):null]},Ns.id)),s.jsx(os,{}),s.jsxs(Ue,{onClick:()=>{const Ns=_(Re);Ns&&V(Re,Ns.id,ye.id)},children:[s.jsx(D,{name:"add",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.folders.newFolderEllipsis")]}),pn?s.jsxs(Ue,{onClick:()=>{B(Re,ye.id)},className:"text-destructive focus:text-destructive",children:[s.jsx(D,{name:"close",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.folders.removeFromFolder")]}):null]})]})]})})():null,ee?null:s.jsxs(Ue,{disabled:!Re,onClick:()=>{Re&&E(Re,{mode:"chat",dedupeKey:`session:${ye.id}`,label:vt})},className:"[&>svg]:mr-1",children:[s.jsx(D,{name:"chat-4",className:"mr-1 h-4 w-4"}),s.jsx("span",{className:"truncate",children:e("sessions.sidebar.session.menu.openInSidePanel")}),s.jsx("span",{className:"shrink-0 typography-micro px-1 rounded leading-none pb-px text-[var(--status-warning)] bg-[var(--status-warning)]/10",children:e("sessions.sidebar.session.menu.betaBadge")})]}),De?s.jsxs(Ue,{disabled:!Re,onClick:ds,className:"[&>svg]:mr-1",children:[s.jsx(D,{name:"window",className:"mr-1 h-4 w-4"}),s.jsx("span",{className:"truncate",children:e("sessions.sidebar.session.menu.openMiniChatWindow")})]}):null,s.jsx(os,{}),c?null:s.jsxs(Ue,{className:"[&>svg]:mr-1",onClick:()=>Z(ye,{archivedBucket:c}),children:[s.jsx(D,{name:"inbox-archive",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.bulkActions.archive")]}),s.jsxs(Ue,{className:"text-destructive focus:text-destructive [&>svg]:mr-1",onClick:()=>Z(ye,{archivedBucket:c,hardDelete:!0}),children:[s.jsx(D,{name:"delete-bin",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.bulkActions.delete")]})]}),Hn=s.jsx(tn,{align:"end",className:"min-w-[180px]",finalFocus:()=>!(T||G.current),children:En({Item:bs,Separator:Rr,Sub:Vg,SubTrigger:_g,SubContent:$g})}),Xn=s.jsx(dd,{children:s.jsx(ud,{className:"app-region-no-drag z-50",children:s.jsx(fd,{"data-slot":"dropdown-menu-content",finalFocus:()=>!(T||G.current),style:{backgroundColor:"var(--surface-elevated)",color:"var(--surface-elevated-foreground)"},className:Pe(Bd,"min-w-[180px]"),children:En({Item:({className:Ue,...os})=>s.jsx(Jh,{className:Pe(Lg,Ue),...os}),Separator:({className:Ue,...os})=>s.jsx(Xh,{className:Pe(Og,Ue),...os}),Sub:Zh,SubTrigger:({className:Ue,children:os,...fs})=>s.jsxs(ep,{className:Pe(Bg,Ue),...fs,children:[os,s.jsx(D,{name:"arrow-right-s",className:"ml-auto size-3.5"})]}),SubContent:({className:Ue,children:os,...fs})=>s.jsx(dd,{children:s.jsx(ud,{className:"app-region-no-drag z-50",children:s.jsx(fd,{"data-slot":"dropdown-menu-sub-content",style:{backgroundColor:"var(--surface-elevated)",color:"var(--surface-elevated-foreground)"},className:Pe(Bd,Ue),...fs,children:os})})})})})})});return s.jsxs(i.Fragment,{children:[s.jsx(bN,{sessionId:ye.id,sessionDirectory:Re??null,sessionTitle:vt,children:s.jsxs(Yh,{open:Gt,onOpenChange:Rn,onOpenChangeComplete:an,children:[s.jsxs(Qh,{render:s.jsx("div",{"data-session-row":ye.id,"data-session-scope":Re??"","data-session-archived":c?"1":"0",className:Pe("group relative my-0.5 flex items-center rounded-md py-1 pr-1.5","-ml-3",r>0?"pl-[32px]":"pl-[18px]",kt&&!ie&&"bg-primary/10",ie&&"bg-interactive-selection")}),children:[ls,Ts,s.jsx("div",{className:"flex min-w-0 flex-1 items-center",children:Ne?s.jsxs(Et,{children:[s.jsx(Mt,{asChild:!0,children:s.jsx("button",{type:"button",onPointerDown:Un,onPointerUp:Es,onPointerCancel:Es,onMouseDown:Ds,onClick:Ue=>Ss(Ue),onDoubleClick:Ue=>{Ue.stopPropagation(),j(ye.id,vt)},className:Pe("flex min-w-0 flex-1 cursor-pointer flex-col gap-0 overflow-hidden rounded-md text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 text-foreground select-none transition-[padding]",fe&&"bg-interactive-hover/70",Y?ee?pe:ue:pe),children:s.jsxs("div",{className:Pe("flex w-full items-center min-w-0 flex-1 overflow-hidden","gap-1"),children:[s.jsx("div",{className:Pe("block min-w-0 flex-1 truncate typography-ui-label font-normal",kt?"text-primary":"text-foreground"),children:vo(vt,f)}),Y?s.jsx("span",{className:"ml-2 flex-shrink-0 text-[0.72rem] text-muted-foreground/75",children:xt}):null,Y?null:s.jsx("div",{className:"relative ml-1 flex h-4 min-w-4 flex-shrink-0 items-center justify-end",children:s.jsx("span",{className:Pe("whitespace-nowrap text-right text-[0.72rem] text-muted-foreground/75 transition-opacity duration-150",as?"opacity-0":Me),children:xt})}),Qe>0?s.jsxs("span",{className:"inline-flex items-center gap-1 rounded bg-destructive/10 px-1 py-0.5 text-[0.7rem] text-destructive flex-shrink-0",title:e("sessions.sidebar.session.status.permissionRequired"),"aria-label":e("sessions.sidebar.session.status.permissionRequired"),children:[s.jsx(D,{name:"shield",className:"h-3 w-3"}),s.jsx("span",{className:"leading-none",children:Qe})]}):null]})})}),ee?null:s.jsx(Ft,{side:"right",sideOffset:8,className:"max-w-xs text-left",children:s.jsxs("div",{className:"flex flex-col gap-1 text-left text-xs",children:[s.jsxs("div",{className:Pe("flex items-center gap-3 text-left text-muted-foreground",re?.projectLabel?"justify-between":"justify-start"),children:[re?.projectLabel?s.jsx("div",{className:"min-w-0 truncate",children:re.projectLabel}):null,s.jsx("div",{className:"flex-shrink-0",children:jt})]}),re?.branchLabel?s.jsx("div",{className:"flex items-center gap-3 text-left text-muted-foreground justify-start",children:s.jsx("div",{className:"flex min-w-0 items-center gap-1.5 overflow-hidden",children:s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5",children:[s.jsx(D,{name:"git-branch",className:"h-3 w-3 flex-shrink-0"}),s.jsx("span",{className:"truncate",children:re.branchLabel})]})})}):null]})})]}):s.jsxs("button",{type:"button",onPointerDown:Un,onPointerUp:Es,onPointerCancel:Es,onMouseDown:Ds,onClick:Ue=>Ss(Ue),onDoubleClick:Ue=>{Ue.stopPropagation(),j(ye.id,vt)},className:Pe("flex min-w-0 flex-1 cursor-pointer flex-col gap-0 overflow-hidden rounded-md text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 text-foreground select-none transition-[padding]",fe&&"bg-interactive-hover/70",Y?ee?pe:ue:pe),children:[s.jsxs("div",{className:Pe("flex w-full items-center min-w-0 flex-1 overflow-hidden","gap-1"),children:[s.jsx("div",{className:Pe("block min-w-0 flex-1 truncate typography-ui-label font-normal",kt?"text-primary":"text-foreground"),children:vo(vt,f)}),Qe>0?s.jsxs("span",{className:"inline-flex items-center gap-1 rounded bg-destructive/10 px-1 py-0.5 text-[0.7rem] text-destructive flex-shrink-0",title:e("sessions.sidebar.session.status.permissionRequired"),"aria-label":e("sessions.sidebar.session.status.permissionRequired"),children:[s.jsx(D,{name:"shield",className:"h-3 w-3"}),s.jsx("span",{className:"leading-none",children:Qe})]}):null]}),Ne?null:s.jsx("div",{className:"flex items-center justify-between gap-3 text-muted-foreground/60 min-w-0 overflow-hidden leading-tight",style:{fontSize:"calc(var(--text-ui-label) * 0.85)"},children:s.jsxs("div",{className:Pe("flex min-w-0 items-center gap-1.5 overflow-hidden",Kt&&St?"pl-4":""),children:[s.jsx("span",{className:"flex-shrink-0",children:jt}),ge?s.jsx("span",{className:"truncate",children:re?.projectLabel}):null,F?s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5",children:[s.jsx(D,{name:"git-branch",className:"h-3 w-3 flex-shrink-0 text-muted-foreground/70"}),s.jsx("span",{className:"truncate",children:re?.branchLabel})]}):null]})})]})}),hn&&!ne?s.jsx("div",{className:Pe("absolute top-1/2 -translate-y-1/2 z-10",Ne?"right-0":"right-[30px]"),children:hn}):null,s.jsxs("div",{className:Pe("absolute right-0 top-1/2 z-10 flex -translate-y-1/2 items-center gap-0.5 transition-opacity",as||Y&&!ee?"opacity-100":Pe("opacity-0",Fe)),children:[Ae?s.jsx(E2,{archiveLabel:e("sessions.sidebar.bulkActions.archive"),deleteLabel:e("sessions.sidebar.bulkActions.delete"),buttonSizeClass:Ne&&!Y?"h-4 w-4":"h-6 w-6",iconSizeClass:Ne&&!Y?"h-2.5 w-2.5":"h-3.5 w-3.5",onPointerDown:dt,onMouseDown:It,onArchive:Ht,onDelete:ht}):null,he?s.jsxs(Et,{children:[s.jsx(Mt,{asChild:!0,children:s.jsx("button",{type:"button",className:Pe("inline-flex items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 transition-opacity",Ne&&!Y?"h-4 w-4":"h-6 w-6"),"aria-label":e("sessions.sidebar.session.actions.openInEditor"),onPointerDown:hs,onMouseDown:ps,onClick:js,onKeyDown:Ue=>Ue.stopPropagation(),children:s.jsx(D,{name:"external-link",className:Pe(Ne&&!Y?"h-2.5 w-2.5":"h-3.5 w-3.5")})})}),s.jsx(Ft,{side:"left",sideOffset:8,children:e("sessions.sidebar.session.actions.openInEditor")})]}):null,s.jsxs(sn,{open:rs,onOpenChange:Gs,onOpenChangeComplete:an,children:[s.jsx(en,{asChild:!0,children:s.jsx("button",{type:"button",className:Pe("inline-flex items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 transition-opacity",Ne&&!Y?as?"h-4 w-4 opacity-100":Pe("h-4 w-4 opacity-0",Fe):"h-6 w-6 opacity-100"),"aria-label":e("sessions.sidebar.session.menu.label"),onPointerDown:we,onMouseDown:tt,onClick:Os,onKeyDown:Ue=>Ue.stopPropagation(),children:s.jsx(D,{name:"more-2",className:Pe(Ne&&!Y?"h-2.5 w-2.5":"h-3.5 w-3.5")})})}),Hn]})]})]}),Xn]})}),St&&ns?n.children.map(Ue=>{const os=ke?ke(Ue):{subtreeContainsActive:me,subtreeContainsEditing:Se,menuOpenSessionId:te,nodeStructureKey:""};return H(Ue,r+1,Re??o,a,c,void 0,ae,os)}):null,s.jsx($s,{open:Je,onOpenChange:rt,children:s.jsxs(_s,{showCloseButton:!1,className:"max-w-sm gap-5",children:[s.jsxs(Hs,{children:[s.jsx(Us,{children:e("sessions.sidebar.session.export.dialog.title")}),s.jsx(on,{children:Qt===1?e("sessions.sidebar.session.export.dialog.descriptionSingle",{count:Qt}):e("sessions.sidebar.session.export.dialog.descriptionMany",{count:Qt})})]}),s.jsxs("label",{className:"flex items-center gap-2 typography-ui-label cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:bt,onChange:Ue=>yt(Ue.target.checked),className:"h-4 w-4 rounded border-border accent-primary"}),e("sessions.sidebar.session.export.dialog.includeSubtasks")]}),s.jsxs(ir,{children:[s.jsx($e,{type:"button",onClick:()=>rt(!1),variant:"outline",size:"sm",children:e("sessions.sidebar.dialogs.cancel")}),s.jsx($e,{type:"button",onClick:()=>{rt(!1),$t(bt)},size:"sm",children:e("sessions.sidebar.session.export.dialog.confirm")})]})]})}),Bt?s.jsx(T2,{session:Le,open:Lt,onOpenChange:Vt}):null]},ye.id)}const mf=t=>cs(t.session.directory??null),F2=(t,e)=>(t?.projectLabel??null)===(e?.projectLabel??null)&&(t?.branchLabel??null)===(e?.branchLabel??null),L2=t=>{if(!t.openSidebarMenuKey)return null;const e=t.archivedBucket?"archived":"active",n=`${t.renderContext??"project"}:${e}:`;return t.openSidebarMenuKey.startsWith(n)?t.openSidebarMenuKey.slice(n.length):null},ta=t=>t.menuOpenSessionId??L2(t),$i=(t,e,n)=>e?n.has(t.node.session.id)?!0:zr(t.node,e):!1,Ea=(t,e,n,r,o)=>{if(t.session.id!==e.session.id)return!0;const a=o(t);if(n.has(a)!==r.has(a)||t.children.length!==e.children.length)return!0;for(let c=0;c<t.children.length;c+=1)if(Ea(t.children[c],e.children[c],n,r,o))return!0;return!1},xh=(t,e,n,r)=>{if(t.session.id!==e.session.id)return!0;const o=t.session.id;if((n.get(o)??t.session)!==(r.get(o)??e.session)||t.children.length!==e.children.length)return!0;for(let a=0;a<t.children.length;a+=1)if(xh(t.children[a],e.children[a],n,r))return!0;return!1},O2=(t,e)=>{if(t.hasSessionSearchQuery||e.hasSessionSearchQuery)return!1;const n=t.archivedBucket?"archived":"active",r=e.archivedBucket?"archived":"active";return Ea(t.node,e.node,t.expandedParents,e.expandedParents,o=>`${t.renderContext??"project"}:${n}:${o.session.id}`)||Ea(t.node,e.node,t.expandedParents,e.expandedParents,o=>`${e.renderContext??"project"}:${r}:${o.session.id}`)},B2=(t,e)=>{if(t.node.session.id!==e.node.session.id||t.depth!==e.depth||t.groupDirectory!==e.groupDirectory||t.projectId!==e.projectId||t.archivedBucket!==e.archivedBucket||(t.renderContext??"project")!==(e.renderContext??"project")||t.mobileVariant!==e.mobileVariant||t.alwaysShowActions!==e.alwaysShowActions||t.hasSessionSearchQuery!==e.hasSessionSearchQuery||t.normalizedSessionSearchQuery!==e.normalizedSessionSearchQuery||t.notifyOnSubtasks!==e.notifyOnSubtasks||t.nodeStructureKey!==e.nodeStructureKey||mf(t.node)!==mf(e.node)||!F2(t.secondaryMeta,e.secondaryMeta)||t.liveSessionById!==e.liveSessionById&&xh(t.node,e.node,t.liveSessionById,e.liveSessionById)||t.pinnedSessionIds!==e.pinnedSessionIds&&Ea(t.node,e.node,t.pinnedSessionIds,e.pinnedSessionIds,n=>n.session.id)||t.expandedParents!==e.expandedParents&&O2(t,e)||t.currentSessionId!==e.currentSessionId&&($i(t,t.currentSessionId,t.subtreeContainsActive)||$i(e,e.currentSessionId,e.subtreeContainsActive))||t.editingId!==e.editingId&&($i(t,t.editingId,t.subtreeContainsEditing)||$i(e,e.editingId,e.subtreeContainsEditing))||t.editTitle!==e.editTitle&&($i(t,t.editingId,t.subtreeContainsEditing)||$i(e,e.editingId,e.subtreeContainsEditing))||t.copiedSessionId!==e.copiedSessionId&&(zr(t.node,t.copiedSessionId)||zr(e.node,e.copiedSessionId)))return!1;if(t.openSidebarMenuKey!==e.openSidebarMenuKey){const n=ta(t),r=ta(e);if(zr(t.node,n)||zr(e.node,r))return!1}if(t.renamingFolderId!==e.renamingFolderId){const n=ta(t),r=ta(e);if(zr(t.node,n)||zr(e.node,r))return!1}return t.setEditingId===e.setEditingId&&t.setEditTitle===e.setEditTitle&&t.handleSaveEdit===e.handleSaveEdit&&t.handleCancelEdit===e.handleCancelEdit&&t.toggleParent===e.toggleParent&&t.handleSessionSelect===e.handleSessionSelect&&t.handleSessionDoubleClick===e.handleSessionDoubleClick&&t.togglePinnedSession===e.togglePinnedSession&&t.handleShareSession===e.handleShareSession&&t.handleCopyShareUrl===e.handleCopyShareUrl&&t.handleUnshareSession===e.handleUnshareSession&&t.setOpenSidebarMenuKey===e.setOpenSidebarMenuKey&&t.getFoldersForScope===e.getFoldersForScope&&t.getSessionFolderId===e.getSessionFolderId&&t.removeSessionFromFolder===e.removeSessionFromFolder&&t.addSessionToFolder===e.addSessionToFolder&&t.createFolderAndStartRename===e.createFolderAndStartRename&&t.openContextPanelTab===e.openContextPanelTab&&t.handleDeleteSession===e.handleDeleteSession&&t.renderSessionNode===e.renderSessionNode},V2=i.memo(M2,B2);function _2(t){return t.stopPropagation()}function $2(t){const e=mt.c(71),{t:n}=Nt(),{value:r,setValue:o,showDeletionDialog:a,setShowDeletionDialog:c,onConfirm:l}=t;let d,u,m,f,g,b,p,x,y,h;if(e[0]!==o||e[1]!==n||e[2]!==r){const E=n("sessions.sidebar.session.untitled");f=$s,y=!!r,e[13]!==o?(h=ne=>{ne||o(null)},e[13]=o,e[14]=h):h=e[14],m=_s,p=!1,x="max-w-sm gap-5",u=Hs;let Z;e[15]!==n||e[16]!==r?.archivedBucket?(Z=r?.archivedBucket?n("sessions.sidebar.dialogs.deleteSession.title"):n("sessions.sidebar.dialogs.archiveSession.title"),e[15]=n,e[16]=r?.archivedBucket,e[17]=Z):Z=e[17],e[18]!==Z?(b=s.jsx(Us,{children:Z}),e[18]=Z,e[19]=b):b=e[19],d=on,g=r&&r.descendantCount>0?r.archivedBucket?r.descendantCount===1?n("sessions.sidebar.dialogs.deleteSession.withOneSubtask",{sessionTitle:r.session.title||E,count:r.descendantCount}):n("sessions.sidebar.dialogs.deleteSession.withManySubtasks",{sessionTitle:r.session.title||E,count:r.descendantCount}):r.descendantCount===1?n("sessions.sidebar.dialogs.archiveSession.withOneSubtask",{sessionTitle:r.session.title||E,count:r.descendantCount}):n("sessions.sidebar.dialogs.archiveSession.withManySubtasks",{sessionTitle:r.session.title||E,count:r.descendantCount}):r?.archivedBucket?n("sessions.sidebar.dialogs.deleteSession.single",{sessionTitle:r?.session.title||E}):n("sessions.sidebar.dialogs.archiveSession.single",{sessionTitle:r?.session.title||E}),e[0]=o,e[1]=n,e[2]=r,e[3]=d,e[4]=u,e[5]=m,e[6]=f,e[7]=g,e[8]=b,e[9]=p,e[10]=x,e[11]=y,e[12]=h}else d=e[3],u=e[4],m=e[5],f=e[6],g=e[7],b=e[8],p=e[9],x=e[10],y=e[11],h=e[12];let C;e[20]!==d||e[21]!==g?(C=s.jsx(d,{children:g}),e[20]=d,e[21]=g,e[22]=C):C=e[22];let w;e[23]!==u||e[24]!==b||e[25]!==C?(w=s.jsxs(u,{children:[b,C]}),e[23]=u,e[24]=b,e[25]=C,e[26]=w):w=e[26];let S;e[27]!==c||e[28]!==a?(S=()=>c(!a),e[27]=c,e[28]=a,e[29]=S):S=e[29];const j=!a;let k;e[30]!==a?(k=a?s.jsx(D,{name:"checkbox-blank",className:"h-4 w-4"}):s.jsx(D,{name:"checkbox",className:"h-4 w-4 text-primary"}),e[30]=a,e[31]=k):k=e[31];let v;e[32]!==n?(v=n("sessions.sidebar.dialogs.neverAsk"),e[32]=n,e[33]=v):v=e[33];let A;e[34]!==k||e[35]!==v||e[36]!==S||e[37]!==j?(A=s.jsxs("button",{type:"button",onClick:S,className:"inline-flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary/50","aria-pressed":j,children:[k,v]}),e[34]=k,e[35]=v,e[36]=S,e[37]=j,e[38]=A):A=e[38];let I;e[39]!==o?(I=()=>o(null),e[39]=o,e[40]=I):I=e[40];let N;e[41]!==n?(N=n("sessions.sidebar.dialogs.cancel"),e[41]=n,e[42]=N):N=e[42];let O;e[43]!==I||e[44]!==N?(O=s.jsx("button",{type:"button",onClick:I,className:"inline-flex h-8 items-center justify-center rounded-md border border-border px-3 typography-ui-label text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",children:N}),e[43]=I,e[44]=N,e[45]=O):O=e[45];let P;e[46]!==l?(P=()=>{l()},e[46]=l,e[47]=P):P=e[47];let T;e[48]!==n||e[49]!==r?.archivedBucket?(T=r?.archivedBucket?n("sessions.sidebar.bulkActions.delete"):n("sessions.sidebar.bulkActions.archive"),e[48]=n,e[49]=r?.archivedBucket,e[50]=T):T=e[50];let L;e[51]!==P||e[52]!==T?(L=s.jsx("button",{type:"button",onClick:P,className:"inline-flex h-8 items-center justify-center rounded-md bg-destructive px-3 typography-ui-label text-destructive-foreground hover:bg-destructive/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50",children:T}),e[51]=P,e[52]=T,e[53]=L):L=e[53];let R;e[54]!==O||e[55]!==L?(R=s.jsxs("div",{className:"flex items-center gap-2",children:[O,L]}),e[54]=O,e[55]=L,e[56]=R):R=e[56];let B;e[57]!==A||e[58]!==R?(B=s.jsxs(ir,{className:"w-full sm:items-center sm:justify-between",children:[A,R]}),e[57]=A,e[58]=R,e[59]=B):B=e[59];let V;e[60]!==m||e[61]!==p||e[62]!==B||e[63]!==x||e[64]!==w?(V=s.jsxs(m,{showCloseButton:p,className:x,children:[w,B]}),e[60]=m,e[61]=p,e[62]=B,e[63]=x,e[64]=w,e[65]=V):V=e[65];let _;return e[66]!==f||e[67]!==V||e[68]!==y||e[69]!==h?(_=s.jsx(f,{open:y,onOpenChange:h,children:V}),e[66]=f,e[67]=V,e[68]=y,e[69]=h,e[70]=_):_=e[70],_}function z2(t){const e=mt.c(57),{t:n}=Nt(),{value:r,setValue:o,showDeletionDialog:a,setShowDeletionDialog:c,onConfirm:l}=t,d=r?.archivedBucket===!0,u=r?.sessionCount??0;let m;e[0]!==d||e[1]!==u||e[2]!==n?(m=n(d?u===1?"sessions.sidebar.dialogs.deleteSession.title":"sessions.sidebar.dialogs.deleteSessions.title":u===1?"sessions.sidebar.dialogs.archiveSession.title":"sessions.sidebar.dialogs.archiveSessions.title"),e[0]=d,e[1]=u,e[2]=n,e[3]=m):m=e[3];const f=m;let g;e[4]!==d||e[5]!==u||e[6]!==n?(g=d?u===1?n("sessions.sidebar.dialogs.deleteSessions.singleDescription",{count:u}):n("sessions.sidebar.dialogs.deleteSessions.pluralDescription",{count:u}):u===1?n("sessions.sidebar.dialogs.archiveSessions.singleDescription",{count:u}):n("sessions.sidebar.dialogs.archiveSessions.pluralDescription",{count:u}),e[4]=d,e[5]=u,e[6]=n,e[7]=g):g=e[7];const b=g,p=!!r;let x;e[8]!==o?(x=_=>{_||o(null)},e[8]=o,e[9]=x):x=e[9];let y;e[10]!==f?(y=s.jsx(Us,{children:f}),e[10]=f,e[11]=y):y=e[11];let h;e[12]!==b?(h=s.jsx(on,{children:b}),e[12]=b,e[13]=h):h=e[13];let C;e[14]!==y||e[15]!==h?(C=s.jsxs(Hs,{children:[y,h]}),e[14]=y,e[15]=h,e[16]=C):C=e[16];let w;e[17]!==c||e[18]!==a?(w=()=>c(!a),e[17]=c,e[18]=a,e[19]=w):w=e[19];const S=!a;let j;e[20]!==a?(j=a?s.jsx(D,{name:"checkbox-blank",className:"h-4 w-4"}):s.jsx(D,{name:"checkbox",className:"h-4 w-4 text-primary"}),e[20]=a,e[21]=j):j=e[21];let k;e[22]!==n?(k=n("sessions.sidebar.dialogs.neverAsk"),e[22]=n,e[23]=k):k=e[23];let v;e[24]!==k||e[25]!==w||e[26]!==S||e[27]!==j?(v=s.jsxs("button",{type:"button",onClick:w,className:"inline-flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary/50","aria-pressed":S,children:[j,k]}),e[24]=k,e[25]=w,e[26]=S,e[27]=j,e[28]=v):v=e[28];let A;e[29]!==o?(A=()=>o(null),e[29]=o,e[30]=A):A=e[30];let I;e[31]!==n?(I=n("sessions.sidebar.dialogs.cancel"),e[31]=n,e[32]=I):I=e[32];let N;e[33]!==A||e[34]!==I?(N=s.jsx("button",{type:"button",onClick:A,className:"inline-flex h-8 items-center justify-center rounded-md border border-border px-3 typography-ui-label text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",children:I}),e[33]=A,e[34]=I,e[35]=N):N=e[35];let O;e[36]!==l?(O=()=>{l()},e[36]=l,e[37]=O):O=e[37];let P;e[38]!==d||e[39]!==n?(P=n(d?"sessions.sidebar.bulkActions.delete":"sessions.sidebar.bulkActions.archive"),e[38]=d,e[39]=n,e[40]=P):P=e[40];let T;e[41]!==O||e[42]!==P?(T=s.jsx("button",{type:"button",onClick:O,className:"inline-flex h-8 items-center justify-center rounded-md bg-destructive px-3 typography-ui-label text-destructive-foreground hover:bg-destructive/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50",children:P}),e[41]=O,e[42]=P,e[43]=T):T=e[43];let L;e[44]!==N||e[45]!==T?(L=s.jsxs("div",{className:"flex items-center gap-2",children:[N,T]}),e[44]=N,e[45]=T,e[46]=L):L=e[46];let R;e[47]!==v||e[48]!==L?(R=s.jsxs(ir,{className:"w-full sm:items-center sm:justify-between",children:[v,L]}),e[47]=v,e[48]=L,e[49]=R):R=e[49];let B;e[50]!==R||e[51]!==C?(B=s.jsxs(_s,{showCloseButton:!1,className:"max-w-sm gap-5",children:[C,R]}),e[50]=R,e[51]=C,e[52]=B):B=e[52];let V;return e[53]!==p||e[54]!==B||e[55]!==x?(V=s.jsx($s,{open:p,onOpenChange:x,children:B}),e[53]=p,e[54]=B,e[55]=x,e[56]=V):V=e[56],V}function W2(t){const e=mt.c(36),{t:n}=Nt(),{value:r,setValue:o,onConfirm:a}=t,c=!!r;let l;e[0]!==o?(l=j=>{j||o(null)},e[0]=o,e[1]=l):l=e[1];let d;e[2]!==n?(d=n("sessions.sidebar.dialogs.deleteFolder.title"),e[2]=n,e[3]=d):d=e[3];let u;e[4]!==d?(u=s.jsx(Us,{children:d}),e[4]=d,e[5]=u):u=e[5];let m;e[6]!==n||e[7]!==r?(m=r&&(r.subFolderCount>0||r.sessionCount>0)?r.subFolderCount>0?r.subFolderCount===1?n("sessions.sidebar.dialogs.deleteFolder.withOneSubfolder",{folderName:r.folderName,count:r.subFolderCount}):n("sessions.sidebar.dialogs.deleteFolder.withManySubfolders",{folderName:r.folderName,count:r.subFolderCount}):n("sessions.sidebar.dialogs.deleteFolder.withContentsNoSubfolders",{folderName:r.folderName}):n("sessions.sidebar.dialogs.deleteFolder.single",{folderName:r?.folderName??""}),e[6]=n,e[7]=r,e[8]=m):m=e[8];let f;e[9]!==m?(f=s.jsx(on,{children:m}),e[9]=m,e[10]=f):f=e[10];let g;e[11]!==u||e[12]!==f?(g=s.jsxs(Hs,{children:[u,f]}),e[11]=u,e[12]=f,e[13]=g):g=e[13];let b;e[14]!==o?(b=()=>o(null),e[14]=o,e[15]=b):b=e[15];let p;e[16]!==n?(p=n("sessions.sidebar.dialogs.cancel"),e[16]=n,e[17]=p):p=e[17];let x;e[18]!==b||e[19]!==p?(x=s.jsx("button",{type:"button",onClick:b,className:"inline-flex h-8 items-center justify-center rounded-md border border-border px-3 typography-ui-label text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",children:p}),e[18]=b,e[19]=p,e[20]=x):x=e[20];let y;e[21]!==n?(y=n("sessions.sidebar.bulkActions.delete"),e[21]=n,e[22]=y):y=e[22];let h;e[23]!==a||e[24]!==y?(h=s.jsx("button",{type:"button",onClick:a,className:"inline-flex h-8 items-center justify-center rounded-md bg-destructive px-3 typography-ui-label text-destructive-foreground hover:bg-destructive/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50",children:y}),e[23]=a,e[24]=y,e[25]=h):h=e[25];let C;e[26]!==h||e[27]!==x?(C=s.jsxs(ir,{children:[x,h]}),e[26]=h,e[27]=x,e[28]=C):C=e[28];let w;e[29]!==C||e[30]!==g?(w=s.jsxs(_s,{showCloseButton:!1,className:"max-w-sm gap-5",children:[g,C]}),e[29]=C,e[30]=g,e[31]=w):w=e[31];let S;return e[32]!==c||e[33]!==l||e[34]!==w?(S=s.jsx($s,{open:c,onOpenChange:l,children:w}),e[32]=c,e[33]=l,e[34]=w,e[35]=S):S=e[35],S}const U2=t=>{const e=mt.c(46),{selectedCount:n,scopeKey:r,scopeFolders:o,archivedBucket:a,onMoveToFolder:c,onCreateFolderAndMove:l,onRemoveFromFolder:d,canRemoveFromFolder:u,onDelete:m,onDone:f}=t,{t:g}=Nt(),b=!!r&&!a;let p;e[0]!==a||e[1]!==g?(p=g(a?"sessions.sidebar.bulkActions.delete":"sessions.sidebar.bulkActions.archive"),e[0]=a,e[1]=g,e[2]=p):p=e[2];const x=p;let y;e[3]!==n||e[4]!==g?(y=g("sessions.sidebar.bulkActions.selectedCount",{count:n}),e[3]=n,e[4]=g,e[5]=y):y=e[5];let h;e[6]!==y?(h=s.jsx("span",{className:"typography-ui-label text-muted-foreground whitespace-nowrap",children:y}),e[6]=y,e[7]=h):h=e[7];let C;e[8]!==b||e[9]!==u||e[10]!==l||e[11]!==c||e[12]!==d||e[13]!==o||e[14]!==g?(C=b?s.jsxs(sn,{children:[s.jsxs(Et,{children:[s.jsx(Mt,{asChild:!0,children:s.jsx(en,{asChild:!0,children:s.jsx("button",{type:"button",className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":g("sessions.sidebar.bulkActions.moveToFolder"),children:s.jsx(D,{name:"folder",className:"h-4 w-4"})})})}),s.jsx(Ft,{side:"top",sideOffset:4,children:s.jsx("p",{children:g("sessions.sidebar.bulkActions.moveToFolder")})})]}),s.jsxs(tn,{align:"end",className:"min-w-[180px]",children:[o.length===0?s.jsx(bs,{disabled:!0,className:"text-muted-foreground",children:g("sessions.sidebar.folders.none")}):o.map(B=>s.jsx(bs,{onClick:()=>c(B.id),children:s.jsx("span",{className:"flex-1 truncate",children:B.name})},B.id)),s.jsx(Rr,{}),s.jsxs(bs,{onClick:l,children:[s.jsx(D,{name:"add",className:"mr-1 h-4 w-4"}),g("sessions.sidebar.folders.newFolderEllipsis")]}),u?s.jsxs(bs,{onClick:d,className:"text-destructive focus:text-destructive",children:[s.jsx(D,{name:"close",className:"mr-1 h-4 w-4"}),g("sessions.sidebar.folders.removeFromFolder")]}):null]})]}):null,e[8]=b,e[9]=u,e[10]=l,e[11]=c,e[12]=d,e[13]=o,e[14]=g,e[15]=C):C=e[15];let w;e[16]===Symbol.for("react.memo_cache_sentinel")?(w=Pe("inline-flex h-7 w-7 items-center justify-center rounded-md text-destructive hover:bg-destructive/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50"),e[16]=w):w=e[16];let S;e[17]===Symbol.for("react.memo_cache_sentinel")?(S=s.jsx(D,{name:"delete-bin",className:"h-4 w-4"}),e[17]=S):S=e[17];let j;e[18]!==x||e[19]!==m?(j=s.jsx(Mt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:m,className:w,"aria-label":x,children:S})}),e[18]=x,e[19]=m,e[20]=j):j=e[20];let k;e[21]!==x?(k=s.jsx(Ft,{side:"top",sideOffset:4,children:s.jsx("p",{children:x})}),e[21]=x,e[22]=k):k=e[22];let v;e[23]!==j||e[24]!==k?(v=s.jsxs(Et,{children:[j,k]}),e[23]=j,e[24]=k,e[25]=v):v=e[25];let A;e[26]!==g?(A=g("sessions.sidebar.header.actions.exitSelection"),e[26]=g,e[27]=A):A=e[27];let I;e[28]===Symbol.for("react.memo_cache_sentinel")?(I=s.jsx(D,{name:"close",className:"h-4 w-4"}),e[28]=I):I=e[28];let N;e[29]!==f||e[30]!==A?(N=s.jsx(Mt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:f,className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":A,children:I})}),e[29]=f,e[30]=A,e[31]=N):N=e[31];let O;e[32]!==g?(O=g("sessions.sidebar.header.actions.exitSelection"),e[32]=g,e[33]=O):O=e[33];let P;e[34]!==O?(P=s.jsx(Ft,{side:"top",sideOffset:4,children:s.jsx("p",{children:O})}),e[34]=O,e[35]=P):P=e[35];let T;e[36]!==N||e[37]!==P?(T=s.jsxs(Et,{children:[N,P]}),e[36]=N,e[37]=P,e[38]=T):T=e[38];let L;e[39]!==T||e[40]!==C||e[41]!==v?(L=s.jsxs("div",{className:"ml-auto flex items-center gap-0.5",children:[C,v,T]}),e[39]=T,e[40]=C,e[41]=v,e[42]=L):L=e[42];let R;return e[43]!==L||e[44]!==h?(R=s.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-t border-border px-2.5 py-1.5",children:[h,L]}),e[43]=L,e[44]=h,e[45]=R):R=e[45],R},H2=t=>{const{t:e}=Nt(),{isInlineEditing:n,showDeletionDialog:r,foldersMap:o,addSessionsToFolder:a,removeSessionsFromFolders:c,createFolderAndStartRename:l,archiveSessions:d,deleteSessions:u,setBulkDeleteConfirm:m}=t,f=Bn(P=>P.enabled),g=Bn(P=>P.selectedIds.size),b=g>0,p=Bn(P=>P.selectedIds),x=Bn(P=>P.scopeKey),y=i.useCallback(()=>{Bn.getState().toggleMode()},[]),h=i.useCallback(()=>{Bn.getState().disable()},[]),C=i.useMemo(()=>{if(!b||typeof document>"u")return!1;let P=!1,T=!1;for(const L of p){const R=document.querySelectorAll(`[data-session-row="${CSS.escape(L)}"]`);for(const B of R)B.getAttribute("data-session-archived")==="1"?T=!0:P=!0}return T&&!P},[b,p]),w=i.useMemo(()=>{if(x)return x;if(!b||typeof document>"u")return null;for(const P of p){const L=document.querySelector(`[data-session-row="${CSS.escape(P)}"]`)?.getAttribute("data-session-scope");if(L&&L.length>0)return L}return null},[b,p,x]),S=i.useMemo(()=>w?o[w]??[]:[],[o,w]),j=i.useMemo(()=>{if(!w||!b)return!1;const P=o[w]??[];for(const T of P)for(const L of T.sessionIds)if(p.has(L))return!0;return!1},[o,w,b,p]),k=i.useCallback(P=>{!w||!b||a(w,P,Array.from(p))},[a,p,w,b]),v=i.useCallback(()=>{if(!w||!b)return;const P=l(w);P&&a(w,P.id,Array.from(p))},[a,l,p,w,b]),A=i.useCallback(()=>{!w||!b||c(w,Array.from(p))},[c,p,w,b]),I=i.useCallback(async()=>{const P=Array.from(p);if(P.length!==0){if(C){const{deletedIds:T,failedIds:L}=await u(P);T.length>0&&ce.success(T.length===1?e("sessions.sidebar.bulkActions.deletedSingle",{count:T.length}):e("sessions.sidebar.bulkActions.deletedPlural",{count:T.length})),L.length>0&&ce.error(L.length===1?e("sessions.sidebar.bulkActions.failedDeleteSingle",{count:L.length}):e("sessions.sidebar.bulkActions.failedDeletePlural",{count:L.length}))}else{const{archivedIds:T,failedIds:L}=await d(P);T.length>0&&ce.success(T.length===1?e("sessions.sidebar.bulkActions.archivedSingle",{count:T.length}):e("sessions.sidebar.bulkActions.archivedPlural",{count:T.length})),L.length>0&&ce.error(L.length===1?e("sessions.sidebar.bulkActions.failedArchiveSingle",{count:L.length}):e("sessions.sidebar.bulkActions.failedArchivePlural",{count:L.length}))}Bn.getState().clear()}},[d,C,u,p,e]),N=i.useCallback(()=>{if(!b)return;const P=p.size;if(!r){I();return}m({sessionCount:P,archivedBucket:C})},[C,I,p,r,m,b]),O=i.useCallback(async()=>{m(null),await I()},[I]);return i.useEffect(()=>{if(!f)return;const P=typeof navigator<"u"&&/Macintosh|Mac OS X/.test(navigator.userAgent||""),T=L=>{if(n)return;const R=L.target;if(R&&(R.tagName==="INPUT"||R.tagName==="TEXTAREA"||R.isContentEditable))return;const B=P?L.metaKey:L.ctrlKey;if(L.key==="Escape"){L.preventDefault(),Bn.getState().disable();return}if(B&&L.key==="Backspace"){L.preventDefault(),N();return}if(B&&(L.key==="a"||L.key==="A")){const V=typeof document<"u"?Array.from(document.querySelectorAll("[data-session-row]")):[];if(V.length===0)return;L.preventDefault();const E=Bn.getState().scopeKey??V[0]?.getAttribute("data-session-scope")??null,Z=Y=>E?Y.getAttribute("data-session-scope")===E:!0,ne=V.filter(Z).map(Y=>Y.getAttribute("data-session-row")).filter(Y=>typeof Y=="string"&&Y.length>0);if(ne.length===0)return;Bn.getState().replaceAll(ne,E||null)}};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[N,n,f]),{selectionModeEnabled:f,hasSelection:b,selectedIdsSize:g,bulkScopeIsArchived:C,derivedSelectionScope:w,bulkScopeFolders:S,bulkCanRemoveFromFolder:j,handleToggleSelectionMode:y,handleExitSelectionMode:h,handleBulkMoveToFolder:k,handleBulkCreateFolderAndMove:v,handleBulkRemoveFromFolder:A,handleBulkDelete:N,confirmBulkDelete:O}},G2=2880*60*1e3,K2=t=>!!t.parentID,q2=t=>!!t.time?.archived,ac=t=>{const e=t.time?.updated,n=t.time?.created;return typeof e=="number"&&Number.isFinite(e)?e:typeof n=="number"&&Number.isFinite(n)?n:0},Y2=t=>[...t].sort((e,n)=>ac(n)-ac(e)),Q2=(t,e=Date.now())=>{const n=e-G2,r=t.filter(o=>q2(o)||K2(o)?!1:ac(o)>=n);return Y2(r)},sa="oc.sessions.projectCollapse",hf="oc.sessions.groupOrder",pf="oc.sessions.groupCollapse",gf="oc.sessions.activeSessionByProject",El="oc.sessions.expandedParents.v2",J2="oc.sessions.expandedParents",X2="oc.sessions.pinned",Z2=(t,e,n)=>{const r=new Set;for(const o of t){const a=cs(o.path)?.toLowerCase();a&&r.add(a)}if(n?.includeWorktrees===!1)return r;for(const o of e.values())for(const a of o){const c=cs(a.path)?.toLowerCase();c&&r.add(c)}return r},ek=(t,e,n)=>{if(t.time?.archived)return!0;const r=cs(Tr(t))?.toLowerCase();return r?e.size===0?n?.allowEmptyDirectorySet??!0:e.has(r):n?.allowUnknownDirectory??!0},tk=5*6e4,xf=new Set,Ar=t=>{const e=i.useRef(t);return e.current=t,i.useCallback((...n)=>e.current(...n),[])},bf=({mobileVariant:t=!1,onSessionSelected:e,allowReselect:n=!1,hideDirectoryControls:r=!1,showOnlyMainWorkspace:o=!1})=>{const{t:a}=Nt(),[c,l]=i.useState(!1),[d,u]=i.useState(""),m=i.useRef(null),f=i.useRef(null),g=i.useRef(new Set),[b,p]=i.useState(null),[x,y]=i.useState(""),[h,C]=i.useState(null),[w,S]=i.useState(new Set),j=i.useMemo(()=>Ni(),[]),[k,v]=i.useState(new Set),[A,I]=i.useState(new Map),[N,O]=i.useState(new Map),P=Ee(oe=>oe.isNewWorktreeDialogOpen),T=Ee(oe=>oe.setNewWorktreeDialogOpen),[L,R]=i.useState(!1),[B,V]=i.useState(null),[_,E]=i.useState(null),[Z,ne]=i.useState(""),[Y,H]=i.useState(null),[re,ae]=i.useState(null),[me,Se]=i.useState(null),te=ll(oe=>oe.ids),ke=ll(oe=>oe.setIds),Q=ll(oe=>oe.toggle),[ge,F]=i.useState(()=>{try{const oe=Ni().getItem(pf);if(!oe)return new Set;const lt=JSON.parse(oe);return new Set(Array.isArray(lt)?lt.filter(it=>typeof it=="string"):[])}catch{return new Set}}),[se,ee]=i.useState(()=>{try{const oe=Ni().getItem(hf);if(!oe)return new Map;const lt=JSON.parse(oe),it=new Map;return Object.entries(lt).forEach(([pt,zt])=>{Array.isArray(zt)&&it.set(pt,zt.filter(Is=>typeof Is=="string"))}),it}catch{return new Map}}),[Ne,De]=i.useState(()=>{try{const oe=Ni().getItem(gf);if(!oe)return new Map;const lt=JSON.parse(oe),it=new Map;return Object.entries(lt).forEach(([pt,zt])=>{typeof zt=="string"&&zt.length>0&&it.set(pt,zt)}),it}catch{return new Map}}),[Be,Fe]=i.useState(new Map),Me=i.useRef(new Map),he=i.useRef(0),Ae=Js(oe=>oe.homeDirectory),pe=Js(oe=>oe.currentDirectory),ue=Js(oe=>oe.setDirectory),U=ws(oe=>oe.projects),fe=ws(oe=>oe.activeProjectId),de=ws(oe=>oe.removeProject),G=ws(oe=>oe.setActiveProjectIdOnly),$=ws(oe=>oe.updateProjectMeta),ve=ws(oe=>oe.reorderProjects),be=Ee(oe=>oe.setActiveMainTab),z=Ee(oe=>oe.openContextPanelTab),xe=Ee(oe=>oe.setSettingsDialogOpen),je=Ee(oe=>oe.toggleHelpDialog),K=Ee(oe=>oe.setAboutDialogOpen),ye=Ee(oe=>oe.setSessionSwitcherOpen),Le=Ee(oe=>oe.setScheduledTasksDialogOpen),Re=Ee(oe=>oe.openMultiRunLauncher),X=Ee(oe=>oe.notifyOnSubtasks),M=Ee(oe=>oe.showDeletionDialog),le=Ee(oe=>oe.setShowDeletionDialog),ie=Ha(d,120),Oe=i.useMemo(()=>ie.trim().toLowerCase(),[ie]),Ge=Oe.length>0,He=Ln(oe=>oe.collapsedFolderIds),Je=Ln(oe=>oe.foldersMap),rt=Ln(oe=>oe.getFoldersForScope),bt=Ln(oe=>oe.createFolder),yt=Ln(oe=>oe.renameFolder),_e=Ln(oe=>oe.deleteFolder),Ye=Ln(oe=>oe.addSessionToFolder),nt=Ln(oe=>oe.addSessionsToFolder),wt=Ln(oe=>oe.removeSessionFromFolder),kt=Ln(oe=>oe.removeSessionsFromFolders),vt=Ln(oe=>oe.toggleFolderCollapse),St=Ln(oe=>oe.cleanupSessions),et=Ln(oe=>oe.getSessionFolderId);FS({isSessionSearchOpen:c,setIsSessionSearchOpen:l,sessionSearchInputRef:f,sessionSearchContainerRef:m});const Ot=sm(),ns=Pc(),Wt=xc(),Ve=i.useMemo(()=>Gr(),[]),Ze=vr(oe=>oe.hasLoaded),_t=vr(oe=>oe.activeSessions),jt=vr(oe=>oe.archivedSessions),xt=ut(oe=>oe.currentSessionId),rs=ut(oe=>!!oe.newSessionDraft?.open),Gt=ut(oe=>oe.setCurrentSession),Ut=ut(oe=>oe.updateSessionTitle),as=ut(oe=>oe.shareSession),Bt=ut(oe=>oe.unshareSession),Lt=ut(oe=>oe.worktreeMetadata),Vt=ut(oe=>oe.availableWorktreesByProject),Kt=ut(oe=>oe.openNewSessionDraft),Xt=i.useCallback(oe=>{Kt(oe),Ve&&window.dispatchEvent(new CustomEvent("openchamber:navigate",{detail:{view:"chat"}}))},[Ve,Kt]),Qt=wo(_l(oe=>({checkForUpdates:oe.checkForUpdates,available:oe.available,runtimeType:oe.runtimeType,info:oe.info,downloading:oe.downloading,downloaded:oe.downloaded,progress:oe.progress,error:oe.error,downloadUpdate:oe.downloadUpdate,restartToUpdate:oe.restartToUpdate}))),vs=i.useMemo(()=>Z2(U,Vt,{includeWorktrees:!Ve}),[Vt,Ve,U]),Dt=i.useMemo(()=>{const oe=new Map(Wt.map(pt=>[pt.id,pt])),lt=_t.map(pt=>{const zt=oe.get(pt.id);return zt?zg(zt,pt):pt}),it=new Set(lt.map(pt=>pt.id));return Wt.forEach(pt=>{it.has(pt.id)||lt.push(pt)}),lt.filter(pt=>ek(pt,vs,{allowUnknownDirectory:!Ve,allowEmptyDirectorySet:!Ve}))},[_t,Ve,vs,Wt]),$t=i.useMemo(()=>Wt.map(oe=>{const lt=cs(oe.directory??null)??"";return`${oe.id}:${oe.title??""}:${oe.time?.archived?1:0}:${lt}`}).join("|"),[Wt]),Ct=i.useRef(Wt);i.useEffect(()=>{Ct.current=Wt},[$t,Wt]);const ds=i.useMemo(()=>new Map(Wt.map(oe=>[oe.id,oe])),[Wt]),qe=i.useMemo(()=>U.map(oe=>`${oe.id}:${cs(oe.path)??""}`).join("|"),[U]),at=i.useRef(!1);i.useEffect(()=>{at.current||(at.current=!0,Sa(Ct.current))},[]);const Qe=i.useRef("");i.useEffect(()=>{let oe=!1;const lt=async()=>{const it=ws.getState().projects;if(it.length===0)return;const pt=new Map,zt=[],Is=3;let Xs=0;const un=Array.from({length:Is},async()=>{for(;;){const Fn=Xs;if(Xs+=1,Fn>=it.length)return;const Sn=it[Fn],An=cs(Sn.path);if(An)try{if(!(wn.getState().directories.get(An)?.isGitRepo??await lm(An)))continue;const gi=await Ug({id:Sn.id,path:An});if(oe||gi.length===0)continue;pt.set(An,gi),zt.push(...gi)}catch{}}});await Promise.all(un),!oe&&ut.setState({availableWorktrees:zt,availableWorktreesByProject:pt})};if(Qe.current!==qe)return Qe.current=qe,lt(),()=>{oe=!0}},[qe]),i.useEffect(()=>{let oe=null;const lt=lh(it=>{it.type==="scheduled-task-ran"&&(oe&&clearTimeout(oe),oe=setTimeout(()=>{Sa(Ct.current)},500))});return()=>{oe&&clearTimeout(oe),lt()}},[]);const At=i.useMemo(()=>dr(),[]),{isTablet:Tt}=Er(),ts=t||Tt,{buildGroupSearchText:xs,filterSessionNodesForSearch:ks,buildGroupedSessions:Jt}=MS({homeDirectory:Ae,worktreeMetadata:Lt,pinnedSessionIds:te,gitBranches:Ot,isVSCode:Ve}),{scheduleCollapsedProjectsPersist:ls}=zS({isVSCode:Ve,hasLoadedGlobalSessions:Ze,safeStorage:j,keys:{sessionExpanded:El,sessionExpandedLegacy:J2,projectCollapse:sa,sessionPinned:X2,groupOrder:hf,projectActiveSession:gf,groupCollapse:pf},sessions:Dt,setPinnedSessionIds:ke,groupOrderByProject:se,activeSessionByProject:Ne,collapsedGroups:ge,setExpandedParents:S,setCollapsedProjects:v}),Ps=i.useMemo(()=>[...Dt].sort((oe,lt)=>Gi(oe,lt,te)),[Dt,te]),Ts=i.useMemo(()=>Ps.map(oe=>`${oe.id}:${oe.time?.updated??0}`).join("|"),[Ps]),hn=i.useRef(null),Gs=i.useMemo(()=>{const oe=hn.current;if(oe&&oe.signature===Ts)return oe.map;const lt=new Map(Ps.map((it,pt)=>[it.id,pt]));return hn.current={signature:Ts,map:lt},lt},[Ts,Ps]),an=i.useMemo(()=>{const oe=new Map;return Ps.forEach(lt=>{const it=lt.parentID;if(!it)return;const pt=oe.get(it)??[];pt.push(lt),oe.set(it,pt)}),oe.forEach(lt=>lt.sort((it,pt)=>Gi(it,pt,te))),oe},[Ps,te]),Rn=s.jsxs("div",{className:"py-6 text-center text-muted-foreground",children:[s.jsx("p",{className:"typography-ui-label font-semibold",children:a("sessions.sidebar.empty.noSessions.title")}),s.jsx("p",{className:"typography-meta mt-1",children:a("sessions.sidebar.empty.noSessions.description")})]}),Os=i.useMemo(()=>U.find(oe=>oe.id===h)??null,[U,h]),we=i.useCallback(oe=>{h&&($(h,oe),C(null))},[h,$]),tt=i.useCallback(()=>{T(!0)},[T]),dt=i.useCallback(()=>{const oe=wo.getState();if(oe.available&&oe.info){R(!0);return}Qt.checkForUpdates().then(()=>{const{available:lt,error:it}=wo.getState();if(it){ce.error(a("sessions.sidebar.updateCheck.errorTitle"),{description:it});return}if(!lt){ce.success(a("sessions.sidebar.updateCheck.latestVersion"));return}R(!0)})},[a,Qt]),It=i.useCallback(()=>{t&&ye(!1),xe(!0)},[t,ye,xe]),Ht=Qt.available&&(Qt.runtimeType==="desktop"||Qt.runtimeType==="web"),ht=ut(oe=>oe.deleteSession),hs=ut(oe=>oe.deleteSessions),ps=ut(oe=>oe.archiveSession),js=ut(oe=>oe.archiveSessions),{copiedSessionId:Ss,handleSessionSelect:Ds,handleSessionDoubleClick:Un,handleSaveEdit:Es,handleCancelEdit:En,handleShareSession:Hn,handleCopyShareUrl:Xn,handleUnshareSession:Ue,handleDeleteSession:os,confirmDeleteSession:fs}=LS({activeProjectId:fe,currentDirectory:pe,currentSessionId:xt,mobileVariant:t,allowReselect:n,onSessionSelected:e,isSessionSearchOpen:c,sessionSearchQuery:d,setSessionSearchQuery:u,setIsSessionSearchOpen:l,setActiveProjectIdOnly:G,setDirectory:ue,setActiveMainTab:be,setSessionSwitcherOpen:ye,setCurrentSession:Gt,updateSessionTitle:Ut,shareSession:as,unshareSession:Bt,deleteSession:ht,deleteSessions:hs,archiveSession:ps,archiveSessions:js,childrenMap:an,showDeletionDialog:M,setDeleteSessionConfirm:H,deleteSessionConfirm:Y,setEditingId:p,setEditTitle:y,editingId:b,editTitle:x}),zs=i.useCallback(()=>{if(!re)return;const{scopeKey:oe,folderId:lt}=re;ae(null),_e(oe,lt)},[re,_e]),Ks=i.useCallback(()=>{Pr.requestDirectoryDialog()},[]);i.useEffect(()=>{if(!xt)return;const lt=Dt.find(pt=>pt.id===xt)?.parentID;if(!lt)return;const it=[`project:active:${lt}`,`project:archived:${lt}`,`recent:active:${lt}`,`recent:archived:${lt}`];S(pt=>{if(it.every(Is=>pt.has(Is)))return pt;const zt=new Set(pt);it.forEach(Is=>zt.add(Is));try{j.setItem(El,JSON.stringify(Array.from(zt)))}catch{}return zt})},[xt,Dt,j]);const Ws=i.useCallback(oe=>{S(lt=>{const it=new Set(lt);it.has(oe)?it.delete(oe):it.add(oe);try{j.setItem(El,JSON.stringify(Array.from(it)))}catch{}return it})},[j]),pn=i.useCallback((oe,lt)=>{if(!oe)return null;lt&&He.has(lt)&&vt(lt);const it=bt(oe,a("sessions.sidebar.folder.newFolderName"),lt);return E(it.id),ne(it.name),it},[He,vt,bt,a]),Ns=Ar(Ds),qr=Ar(Un),Gn=Ar(Es),fr=Ar(En),Kn=Ar(Hn),gs=Ar(Xn),Ms=Ar(Ue),jr=Ar(os),jn=Ar(pn),ln=i.useCallback((oe,lt)=>{O(it=>{const pt=new Map(it);return pt.set(oe,lt+7),pt})},[]),Zn=i.useCallback(oe=>{O(lt=>{if(!lt.has(oe))return lt;const it=new Map(lt);return it.delete(oe),it})},[]),Mr=i.useCallback(oe=>{O(lt=>{let it=!1;const pt=new Map(lt),zt=`${oe}:`;for(const Is of pt.keys())Is.startsWith(zt)&&(pt.delete(Is),it=!0);return it?pt:lt})},[]),Yr=i.useCallback(()=>{he.current=Date.now()+150,O(new Map),v(()=>{const oe=new Set(U.map(lt=>lt.id));try{j.setItem(sa,JSON.stringify(Array.from(oe)))}catch{}return Ve||ls(oe),oe})},[U,Ve,j,ls]),ui=i.useCallback(()=>{he.current=Date.now()+150,O(new Map),v(()=>{const oe=new Set;try{j.setItem(sa,JSON.stringify([]))}catch{}return Ve||ls(oe),oe})},[Ve,j,ls]),mr=i.useCallback(oe=>{he.current=Date.now()+150,Mr(oe),v(lt=>{const it=new Set(lt);it.has(oe)?it.delete(oe):it.add(oe);try{j.setItem(sa,JSON.stringify(Array.from(it)))}catch{}return Ve||ls(it),it})},[Ve,Mr,j,ls]),us=i.useMemo(()=>U.map(oe=>({...oe,normalizedPath:cs(oe.path)})).filter(oe=>!!oe.normalizedPath),[U]),cn=i.useMemo(()=>us.map(oe=>oe.normalizedPath),[us]),kn=i.useMemo(()=>{const oe=new Set;return us.forEach(lt=>{if(lt.normalizedPath&&oe.add(lt.normalizedPath),Ve)return;(Vt.get(lt.normalizedPath)??[]).forEach(pt=>{const zt=cs(pt.path);zt&&oe.add(zt)})}),[...oe].sort()},[Vt,Ve,us]),J=i.useRef(null);i.useEffect(()=>{const oe=new Set(kn),lt=J.current;if(J.current=oe,!lt){Ve&&kn.length>0&&Vd(kn,Ct.current);return}const it=kn.filter(pt=>!lt.has(pt));it.length!==0&&Vd(it,Ct.current)},[Ve,kn]);const{github:st}=Jn(),gt=Pi(oe=>oe.status),Pt=Pi(oe=>oe.hasChecked),Zt=Wg(cn),is=rr(oe=>oe.ensureEntry),ms=rr(oe=>oe.setParams),Fs=rr(oe=>oe.refreshTargets);WS({normalizedProjects:us,gitRepoStatus:Zt,setProjectRepoStatus:I,setProjectRootBranches:Fe});const qs=ut(oe=>oe.isLoading);YS({isSessionsLoading:qs,hasLoadedGlobalSessions:Ze,sessions:Dt,archivedSessions:jt,normalizedProjects:us,isVSCode:Ve,availableWorktreesByProject:Vt,cleanupSessions:St});const{getSessionsForProject:er,getArchivedSessionsForProject:qn}=US({isVSCode:Ve,sessions:Dt,archivedSessions:jt,availableWorktreesByProject:Vt,normalizedProjects:us});CS({normalizedProjects:us,sessions:Dt,archivedSessions:jt,availableWorktreesByProject:Vt,isVSCode:Ve,isSessionsLoading:qs,foldersMap:Je,createFolder:bt,addSessionToFolder:Ye,cleanupSessions:St});const Fr=i.useRef(!1);fe&&A.has(fe)&&(Fr.current=!!A.get(fe));const{projectSections:Bs,groupSearchDataByGroup:Lr,sectionsForRender:gn,searchMatchCount:tr}=IS({normalizedProjects:us,getSessionsForProject:er,getArchivedSessionsForProject:qn,availableWorktreesByProject:Vt,projectRepoStatus:A,projectRootBranches:Be,lastRepoStatus:Fr.current,buildGroupedSessions:Jt,hasSessionSearchQuery:Ge,normalizedSessionSearchQuery:Oe,filterSessionNodesForSearch:ks,buildGroupSearchText:xs,foldersMap:Je}),xn=s.jsxs("div",{className:"py-6 text-center text-muted-foreground",children:[s.jsx("p",{className:"typography-ui-label font-semibold",children:a("sessions.sidebar.empty.noMatches.title")}),s.jsx("p",{className:"typography-meta mt-1",children:a("sessions.sidebar.empty.noMatches.description")})]});TS({projectSections:Bs,activeProjectId:fe,activeSessionByProject:Ne,setActiveSessionByProject:De,currentSessionId:xt,handleSessionSelect:Ds,newSessionDraftOpen:rs,mobileVariant:t,openNewSessionDraft:Kt,setActiveMainTab:be,setSessionSwitcherOpen:ye});const{getOrderedGroups:Mn}=RS(se),bn=i.useRef(!1);i.useEffect(()=>{if(bn.current||Bs.length===0)return;const oe=Bs.flatMap(lt=>lt.groups.filter(it=>it.isArchivedBucket).map(it=>`${lt.project.id}:${it.id}`));oe.length>0&&F(lt=>new Set([...lt,...oe])),bn.current=!0},[Bs]);const or=i.useMemo(()=>{const oe=new Map,lt=new Map;return Bs.forEach(it=>{const pt=Sm(it.project.label?.trim()||Ri(it.project.normalizedPath,Ae)||it.project.normalizedPath);it.groups.forEach(zt=>{const Is=zt.branch&&zt.branch!=="HEAD"&&zt.branch!==pt?zt.branch:null,Xs={projectLabel:pt,branchLabel:Is},un=Fn=>{Fn.forEach(Sn=>{const An=it.project.normalizedPath.length,hi=lt.get(Sn.session.id)??-1;An<hi||(oe.set(Sn.session.id,{node:Sn,projectId:it.project.id,groupDirectory:zt.directory,secondaryMeta:Xs}),lt.set(Sn.session.id,An),Sn.children.length>0&&un(Sn.children))})};un(zt.sessions)})}),oe},[Bs,Ae]),Cn=Dr(oe=>oe.showRecentSection),Sr=Dr(oe=>oe.showArchivedSessions),Or=i.useMemo(()=>!Cn||Ve?[]:Q2(Dt).sort((oe,lt)=>Gi(oe,lt,te)),[Ve,te,Dt,Cn]),Nr=i.useMemo(()=>{if(Ve||!Cn)return[];const oe=Or,lt=pt=>{const zt=or.get(pt.id),Is=cs(pt.directory??null),Xs=zt?.node??{session:pt,children:[],worktree:null},Fn=(Ge?ks([Xs],Oe):[Xs])[0];if(!Fn)return null;const Sn=zt?.secondaryMeta?{projectLabel:zt.secondaryMeta.projectLabel,branchLabel:Ve?null:zt.secondaryMeta.branchLabel}:null;return{node:Fn,projectId:zt?.projectId??null,groupDirectory:zt?.groupDirectory??Is,secondaryMeta:Sn}},it=oe.map(lt).filter(pt=>pt!==null);return[{key:"active-now",title:a("sessions.sidebar.activity.recentTitle"),items:it}]},[Or,ks,Ge,Ve,Oe,or,Cn,a]),Ei=i.useMemo(()=>Nr.some(oe=>oe.items.length>0),[Nr]),fi=i.useMemo(()=>new Set(Or.map(oe=>oe.id)),[Or]),Mi=i.useMemo(()=>[...fi],[fi]);Wj({currentSessionId:xt,sortedSessions:Ps,recentSessionIds:Mi,ensureSessionRenderable:ns.ensureSessionRenderable});const nn=i.useMemo(()=>Sr?gn:gn.map(oe=>({...oe,groups:oe.groups.filter(lt=>!lt.isArchivedBucket)})),[gn,Sr]),hr=i.useMemo(()=>{const oe=new Set;return nn.forEach(lt=>{lt.groups.forEach(it=>{const pt=cs(it.directory??null),zt=it.branch?.trim()||Ot.get(pt||"")?.trim();!pt||!zt||oe.add(No(pt,zt))})}),[...oe]},[Ot,nn]),Ys=Aw(hr);i.useEffect(()=>{if(!Pt||!gt?.connected||!st)return;const oe=[],lt=Date.now();if(nn.forEach(pt=>{k.has(pt.project.id)||pt.groups.forEach(zt=>{const Is=cs(zt.directory??null),Xs=zt.branch?.trim()||Ot.get(Is||"")?.trim();if(!Is||!Xs)return;const un=No(Is,Xs),Fn=rr.getState().entries[un],Sn=!!Fn?.status?.pr,An=`${Is}::${Xs}`,hi=Math.max(Fn?.lastRefreshAt??0,Fn?.lastDiscoveryPollAt??0),pi=!!(Fn?.isInitialStatusResolved&&!Sn&&(!g.current.has(An)||lt-hi>=tk));(!Fn||!Fn.isInitialStatusResolved||pi)&&(pi&&g.current.add(An),oe.push({directory:Is,branch:Xs}))})}),oe.length===0)return;const it=new Map;oe.forEach(pt=>{const zt=No(pt.directory,pt.branch,pt.remoteName??null);it.has(zt)||it.set(zt,pt)}),it.forEach((pt,zt)=>{is(zt),ms(zt,{directory:pt.directory,branch:pt.branch,remoteName:pt.remoteName??null,canShow:!0,github:st,githubAuthChecked:Pt,githubConnected:gt.connected})}),Fs([...it.values()],{silent:!0,markInitialResolved:!0})},[k,is,st,Pt,gt?.connected,Ot,Fs,nn,ms]);const co=t?"inline-flex h-6 w-6 cursor-pointer items-center justify-center rounded-md leading-none text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 disabled:cursor-not-allowed":"inline-flex h-6 w-6 cursor-pointer items-center justify-center rounded-md leading-none text-foreground hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 disabled:cursor-not-allowed",Br="h-4.5 w-4.5",ar=ZS({isDesktopShellRuntime:At,projectSections:Bs,projectHeaderSentinelRefs:Me}),kr=Ar((oe,lt=0,it,pt,zt=!1,Is,Xs="project",un)=>s.jsx(V2,{node:oe,depth:lt,groupDirectory:it,projectId:pt,archivedBucket:zt,currentSessionId:xt,pinnedSessionIds:te,expandedParents:w,hasSessionSearchQuery:Ge,normalizedSessionSearchQuery:Oe,notifyOnSubtasks:X,editingId:b,setEditingId:p,editTitle:x,setEditTitle:y,handleSaveEdit:Gn,handleCancelEdit:fr,toggleParent:Ws,handleSessionSelect:Ns,handleSessionDoubleClick:qr,togglePinnedSession:Q,handleShareSession:Kn,copiedSessionId:Ss,handleCopyShareUrl:gs,handleUnshareSession:Ms,openSidebarMenuKey:B,setOpenSidebarMenuKey:V,renamingFolderId:_,getFoldersForScope:rt,getSessionFolderId:et,removeSessionFromFolder:wt,addSessionToFolder:Ye,createFolderAndStartRename:jn,openContextPanelTab:z,handleDeleteSession:jr,mobileVariant:t,alwaysShowActions:ts,renderSessionNode:kr,secondaryMeta:Is,renderContext:Xs,subtreeContainsActive:un?.subtreeContainsActive??xf,subtreeContainsEditing:un?.subtreeContainsEditing??xf,menuOpenSessionId:un?.menuOpenSessionId??null,nodeStructureKey:un?.nodeStructureKey??"",childRenderExtrasFor:un?.childRenderExtrasFor,liveSessionById:ds})),dn=i.useCallback(oe=>{Zn(oe),F(lt=>{const it=new Set(lt);return it.has(oe)?it.delete(oe):it.add(oe),it})},[Zn]),lr=i.useMemo(()=>{const oe=new Map;for(const[lt,it]of Ys)oe.set(lt,{visualState:it.visualState,number:it.number,url:it.url,state:it.prState,draft:it.draft,title:it.title,base:it.base,head:it.head,checks:it.checks,canMerge:it.canMerge,mergeableState:it.mergeableState,repo:it.repo});return oe},[Ys]),Fi=i.useCallback((oe,lt,it,pt,zt,Is,Xs)=>s.jsx(IN,{group:oe,groupKey:lt,projectId:it,hideGroupLabel:pt,compactBodyPadding:Is,hasSessionSearchQuery:Ge,normalizedSessionSearchQuery:Oe,groupSearchDataByGroup:Lr,visibleSessionCount:N.get(lt),collapsedGroups:ge,hideDirectoryControls:r,collapsedFolderIds:He,toggleFolderCollapse:vt,renameFolder:yt,deleteFolder:_e,showDeletionDialog:M,setDeleteFolderConfirm:ae,renderSessionNode:kr,projectRepoStatus:A,lastRepoStatus:Fr.current,showMoreGroupSessions:ln,resetGroupSessionLimit:Zn,mobileVariant:t,alwaysShowActions:ts,activeProjectId:fe,setActiveProjectIdOnly:G,setActiveMainTab:be,setSessionSwitcherOpen:ye,openNewSessionDraft:Xt,addSessionToFolder:Ye,createFolderAndStartRename:jn,renamingFolderId:_,renameFolderDraft:Z,setRenameFolderDraft:ne,setRenamingFolderId:E,pinnedSessionIds:te,expandedParents:w,sessionOrderIndex:Gs,currentSessionId:xt,editingId:b,editTitle:x,openSidebarMenuKey:B,liveSessionById:ds,prVisualStateByDirectoryBranch:lr,onToggleCollapsedGroup:dn,dragHandleProps:zt,scrollContainerRef:Xs}),[Ge,Oe,Lr,N,ge,r,He,vt,yt,_e,M,kr,A,ln,Zn,t,ts,fe,G,be,ye,Xt,Ye,jn,_,Z,te,w,Gs,xt,b,x,B,ds,lr,dn]),Li=!Ve&&Cn&&!Ge?s.jsx(BN,{sections:Nr,renderSessionNode:kr,currentSessionId:xt,editingId:b,openSidebarMenuKey:B,variant:"section"}):null,Vr=!!(_||b||h),{selectionModeEnabled:mi,hasSelection:rn,selectedIdsSize:Oi,bulkScopeIsArchived:uo,derivedSelectionScope:fo,bulkScopeFolders:q,bulkCanRemoveFromFolder:Ce,handleToggleSelectionMode:Te,handleExitSelectionMode:ze,handleBulkMoveToFolder:ft,handleBulkCreateFolderAndMove:Rt,handleBulkRemoveFromFolder:qt,handleBulkDelete:Yt,confirmBulkDelete:ys}=H2({isInlineEditing:Vr,showDeletionDialog:M,foldersMap:Je,addSessionsToFolder:nt,removeSessionsFromFolders:kt,createFolderAndStartRename:pn,archiveSessions:js,deleteSessions:hs,setBulkDeleteConfirm:Se}),pr=i.useCallback(()=>{be("chat"),t&&ye(!1),Re()},[t,Re,be,ye]),Cr=i.useCallback(()=>{be("chat"),t&&ye(!1),Kt()},[t,Kt,be,ye]);return s.jsxs("div",{ref:m,className:Pe("relative flex h-full flex-col text-foreground overflow-x-hidden",t?"":"bg-transparent"),children:[s.jsx(PN,{hideDirectoryControls:r,showRecentControls:!Ve,handleOpenDirectoryDialog:Ks,openNewSessionDraft:Cr,canOpenMultiRun:U.length>0,openMultiRunLauncher:pr,headerActionIconClass:Br,headerActionButtonClass:co,isSessionSearchOpen:c,setIsSessionSearchOpen:l,sessionSearchInputRef:f,sessionSearchQuery:d,setSessionSearchQuery:u,hasSessionSearchQuery:Ge,searchMatchCount:tr,collapseAllProjects:Yr,expandAllProjects:ui,openScheduledTasksDialog:()=>Le(!0),selectionModeEnabled:mi,onToggleSelectionMode:Te}),s.jsx(GN,{topContent:Li,hasSharedSessions:Ei,sectionsForRender:nn,projectSections:Bs,activeProjectId:fe,showOnlyMainWorkspace:o,hasSessionSearchQuery:Ge,emptyState:Rn,searchEmptyState:xn,renderGroupSessions:Fi,homeDirectory:Ae,collapsedProjects:k,hideDirectoryControls:r,projectRepoStatus:A,isDesktopShellRuntime:At,stuckProjectHeaders:ar,mobileVariant:t,alwaysShowActions:ts,toggleProject:mr,setActiveProjectIdOnly:G,setActiveMainTab:be,setSessionSwitcherOpen:ye,openNewSessionDraft:Xt,openNewWorktreeDialog:tt,openProjectEditDialog:C,removeProject:de,projectHeaderSentinelRefs:Me,reorderProjects:ve,getOrderedGroups:Mn,setGroupOrderByProject:ee,openSidebarMenuKey:B,setOpenSidebarMenuKey:V,isInlineEditing:Vr}),mi&&rn?s.jsx(U2,{selectedCount:Oi,scopeKey:fo,scopeFolders:q,archivedBucket:uo,onMoveToFolder:ft,onCreateFolderAndMove:Rt,onRemoveFromFolder:qt,canRemoveFromFolder:Ce,onDelete:Yt,onDone:ze}):null,s.jsx(VN,{onOpenSettings:It,onOpenShortcuts:je,onOpenAbout:()=>K(!0),onOpenUpdate:dt,showRuntimeButtons:!Ve,showUpdateButton:Ht}),s.jsx(gm,{open:L,onOpenChange:R,info:Qt.info,downloading:Qt.downloading,downloaded:Qt.downloaded,progress:Qt.progress,error:Qt.error,onDownload:Qt.downloadUpdate,onRestart:Qt.restartToUpdate,runtimeType:Qt.runtimeType}),Os?s.jsx(tN,{open:!!Os,onOpenChange:oe=>{oe||C(null)},projectId:Os.id,projectName:Os.label||Ri(Os.path,Ae),projectPath:Os.path,initialIcon:Os.icon,initialColor:Os.color,initialIconBackground:Os.iconBackground,onSave:we}):null,s.jsx(Gx,{open:P,onOpenChange:T,onWorktreeCreated:(oe,lt)=>{if(be("chat"),t&&ye(!1),lt?.sessionId){Gt(lt.sessionId,oe);return}Kt({directoryOverride:oe,preserveDirectoryOverride:!0})}}),s.jsx(NS,{}),s.jsx($2,{value:Y,setValue:H,showDeletionDialog:M,setShowDeletionDialog:le,onConfirm:fs}),s.jsx(W2,{value:re,setValue:ae,onConfirm:zs}),s.jsx(z2,{value:me,setValue:Se,showDeletionDialog:M,setShowDeletionDialog:le,onConfirm:ys})]})},wi=t=>t?s.jsx("span",{className:"text-foreground/80 dark:text-foreground/70",children:t}):void 0,br=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},sk=()=>{const{t}=Nt(),[e,n]=i.useState(!1),[r,o]=i.useState(!1),[a,c]=i.useState(null),[l,d]=i.useState([]),[u,m]=i.useState(!1),[f,g]=i.useState(!1),[b,p]=i.useState(!1),[x,y]=i.useState(!1),[h,C]=i.useState(new Set),w=ut(ue=>ue.getWorktreeMetadata),S=ut(ue=>ue.newSessionDraft),j=ut(ue=>ue.setNewSessionDraftTarget),k=ut(ue=>ue.setDraftBootstrapPendingDirectory),v=Hg,A=qg,I=ut(ue=>ue.deleteSessions),N=ut(ue=>ue.archiveSessions),O=Ee(ue=>ue.showDeletionDialog),P=Ee(ue=>ue.setShowDeletionDialog),T=Js(ue=>ue.currentDirectory),L=Js(ue=>ue.homeDirectory),R=Js(ue=>ue.isHomeReady),B=ws(ue=>ue.projects),V=ws(ue=>ue.activeProjectId),{isMobile:_,isTablet:E,hasTouchInput:Z}=Er(),ne=_||E||Z,Y=i.useMemo(()=>{const U=(V?B.find(fe=>fe.id===V)??null:null)?.path??T;return br(U)},[V,T,B]),H=i.useCallback(ue=>{const fe=br(ue.projectDirectory)||Y;return{id:(B.find(G=>br(G.path)===fe)??null)?.id??`path:${fe}`,path:fe}},[Y,B]),re=x&&h.size>0,ae=i.useMemo(()=>{const ue=a?.worktree;return ue&&typeof ue.branch=="string"&&ue.branch.trim().length>0?!0:l.length>0&&l.every(({metadata:U})=>typeof U.branch=="string"&&U.branch.trim().length>0)},[a?.worktree,l]),me=a?.mode==="worktree",Se=me,te=b||!me||!ae,ke=b||!me;i.useEffect(()=>{r||!R||B.length>0||(o(!0),n(!0))},[r,R,B.length]);const Q=i.useCallback(ue=>{c({sessions:ue.sessions,dateLabel:ue.dateLabel,mode:ue.mode??"session",worktree:ue.worktree??null})},[]),ge=i.useCallback(()=>{c(null),d([]),m(!1),g(!1),p(!1),y(!1),C(new Set)},[]),F=i.useCallback(async ue=>{if(ue.sessions.length===0)return;if(ue.sessions.length===1){const G=ue.sessions[0];await v(G.id)?ce.success(t("sessions.sidebar.session.delete.success")):ce.error(t("sessions.sidebar.session.delete.error"));return}const U=ue.sessions.map(G=>G.id),{deletedIds:fe,failedIds:de}=await I(U);if(fe.length>0){const G=de.length>0?de.length===1?t("sessions.sidebar.dialogs.deleteResult.singleFailedToDelete",{count:de.length}):t("sessions.sidebar.dialogs.deleteResult.manyFailedToDelete",{count:de.length}):ue.dateLabel?t("sessions.sidebar.dialogs.deleteResult.removedFromDate",{dateLabel:ue.dateLabel}):void 0;ce.success(fe.length===1?t("sessions.sidebar.bulkActions.deletedSingle",{count:fe.length}):t("sessions.sidebar.bulkActions.deletedPlural",{count:fe.length}),{description:wi(G)})}de.length>0&&ce.error(de.length===1?t("sessions.sidebar.bulkActions.failedDeleteSingle",{count:de.length}):t("sessions.sidebar.bulkActions.failedDeletePlural",{count:de.length}),{description:wi(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})},[v,I,t]);i.useEffect(()=>Pr.onDeleteRequest(ue=>{if(!O&&(ue.mode??"session")==="session"){F(ue);return}Q(ue)}),[Q,O,F]),i.useEffect(()=>Pr.onDirectoryRequest(()=>{n(!0)}),[]),i.useEffect(()=>{if(!a){d([]),m(!1),g(!1),y(!1),C(new Set);return}const ue=a.sessions.map(de=>{const G=w(de.id);return G?{session:de,metadata:G}:null}).filter(de=>!!de);d(ue),m(!1),y(!1),C(new Set);const U=new Map;if(a.worktree?.path&&U.set(br(a.worktree.path),a.worktree),ue.forEach(({metadata:de})=>{de.path&&U.set(br(de.path),de)}),U.size===0){y(!0);return}let fe=!1;return(async()=>{const de=new Map,G=new Set;await Promise.all(Array.from(U.entries()).map(async([$,ve])=>{try{const be=await Gg(ve.path);de.set($,be),be?.isDirty&&G.add($)}catch{ve.status&&(de.set($,ve.status),ve.status.isDirty&&G.add($))}})).catch($=>{console.warn("Failed to inspect worktree status before deletion:",$)}),!fe&&(C(G),y(!0),c($=>{if(!$?.worktree?.path)return $;const ve=br($.worktree.path),be=de.get(ve);if(!be)return $;const z=$.worktree.status;return z?.isDirty===be.isDirty&&z?.ahead===be.ahead&&z?.behind===be.behind&&z?.upstream===be.upstream?$:{...$,worktree:{...$.worktree,status:be}}}),d($=>$.map(ve=>{const be=br(ve.metadata.path),z=de.get(be);return z?{session:ve.session,metadata:{...ve.metadata,status:z}}:ve})))})(),()=>{fe=!0}},[a,w]),i.useEffect(()=>{ae||m(!1)},[ae]);const se=i.useCallback(async(ue,U)=>{const fe=u&&ae,de=H(ue),G=br(ue.path),$=br(de.path);try{await Kg(de,ue,{deleteRemoteBranch:fe,deleteLocalBranch:U});const ve=br(S?.directoryOverride);return S?.open&&G&&ve===G&&$&&(k(null),j({projectId:de.id,directoryOverride:$},{force:!0})),br(T)===G&&$&&Js.getState().setDirectory($,{showOverlay:!1}),!0}catch(ve){return ce.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle"),{description:wi(ve instanceof Error?ve.message:t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),!1}},[ae,T,u,H,S?.directoryOverride,S?.open,k,j,t]),ee=i.useCallback((ue,U)=>{const fe=u&&ae;(async()=>{if(!await se(ue,U))return;const G=t(fe?"sessions.sidebar.sessionDialogs.worktree.removedWithRemote":"sessions.sidebar.sessionDialogs.worktree.removed");ce.success(t("sessions.sidebar.sessionDialogs.worktree.removedTitle"),{description:wi(G)})})()},[ae,u,se,t]),Ne=i.useCallback(async()=>{if(a){p(!0);try{const ue=Se,U=ue&&u,fe=ue&&f;if(a.sessions.length===0&&me&&a.worktree){ee(a.worktree,fe),ge();return}if(a.sessions.length===1){const de=a.sessions[0];if(!(me?await A(de.id):await v(de.id,{archiveWorktree:!1,deleteRemoteBranch:U,deleteLocalBranch:fe}))){ce.error(t(me?"sessions.sidebar.session.archive.error":"sessions.sidebar.session.delete.error")),p(!1);return}const $=!me&&ue?t(U?"sessions.sidebar.sessionDialogs.worktree.removedWithRemote":"sessions.sidebar.sessionDialogs.worktree.attachedArchived"):void 0;ce.success(t(me?"sessions.sidebar.session.archive.success":"sessions.sidebar.session.delete.success"),{description:wi($),action:{label:t("sessions.sidebar.sessionDialogs.ok"),onClick:()=>{}}})}else{const de=a.sessions.map(ve=>ve.id);let G=[],$=[];if(me){const ve=await N(de);G=ve.archivedIds,$=ve.failedIds}else{const ve=await I(de);G=ve.deletedIds,$=ve.failedIds}if(me&&a.worktree&&$.length===0&&ee(a.worktree,fe),G.length>0){const ve=!me&&ue?t(U?"sessions.sidebar.sessionDialogs.worktree.archivedAndRemoteRemoved":"sessions.sidebar.sessionDialogs.worktree.attachedArchivedPlural"):void 0,z=[$.length>0?me?$.length===1?t("sessions.sidebar.dialogs.deleteResult.singleFailedToArchive",{count:$.length}):t("sessions.sidebar.dialogs.deleteResult.manyFailedToArchive",{count:$.length}):$.length===1?t("sessions.sidebar.dialogs.deleteResult.singleFailedToDelete",{count:$.length}):t("sessions.sidebar.dialogs.deleteResult.manyFailedToDelete",{count:$.length}):a.dateLabel?t("sessions.sidebar.dialogs.deleteResult.removedFromDate",{dateLabel:a.dateLabel}):void 0,ve].filter(Boolean).join(" ");ce.success(me?G.length===1?t("sessions.sidebar.bulkActions.archivedSingle",{count:G.length}):t("sessions.sidebar.bulkActions.archivedPlural",{count:G.length}):G.length===1?t("sessions.sidebar.bulkActions.deletedSingle",{count:G.length}):t("sessions.sidebar.bulkActions.deletedPlural",{count:G.length}),{description:wi(z||void 0),action:{label:t("sessions.sidebar.sessionDialogs.ok"),onClick:()=>{}}})}if($.length>0&&(ce.error(me?$.length===1?t("sessions.sidebar.bulkActions.failedArchiveSingle",{count:$.length}):t("sessions.sidebar.bulkActions.failedArchivePlural",{count:$.length}):$.length===1?t("sessions.sidebar.bulkActions.failedDeleteSingle",{count:$.length}):t("sessions.sidebar.bulkActions.failedDeletePlural",{count:$.length}),{description:wi(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),G.length===0)){p(!1);return}}me&&a.sessions.length===1&&a.worktree&&ee(a.worktree,fe),ge()}finally{p(!1)}}},[a,u,f,v,I,A,N,ge,Se,me,ee,t]),De=a?.worktree??l[0]?.metadata??null,Be=a?a.mode==="worktree"?a.sessions.length===0?t("sessions.sidebar.dialogs.worktreeDelete.descriptionNoLinked"):a.sessions.length===1?t("sessions.sidebar.dialogs.worktreeDelete.descriptionOneLinked",{count:a.sessions.length}):t("sessions.sidebar.dialogs.worktreeDelete.descriptionManyLinked",{count:a.sessions.length}):a.sessions.length===1?a.dateLabel?t("sessions.sidebar.dialogs.sessionDelete.descriptionOneWithDate",{dateLabel:a.dateLabel}):t("sessions.sidebar.dialogs.sessionDelete.descriptionOne"):a.dateLabel?t("sessions.sidebar.dialogs.sessionDelete.descriptionManyWithDate",{count:a.sessions.length,dateLabel:a.dateLabel}):t("sessions.sidebar.dialogs.sessionDelete.descriptionMany",{count:a.sessions.length}):"",Fe=a?s.jsxs("div",{className:Pe(me?"space-y-3":"space-y-2"),children:[a.sessions.length>0&&s.jsxs("div",{className:Pe(me?"rounded-lg bg-muted/30 p-3":"space-y-1.5 rounded-xl border border-border/40 bg-sidebar/60 p-3"),children:[me&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"typography-meta font-medium text-foreground",children:a.sessions.length===1?t("sessions.sidebar.sessionDialogs.linkedSessionSingle"):t("sessions.sidebar.sessionDialogs.linkedSessionPlural")}),s.jsx("span",{className:"typography-micro text-muted-foreground/70",children:a.sessions.length})]}),s.jsxs("ul",{className:Pe(me?"mt-2 space-y-1":"space-y-0.5"),children:[a.sessions.slice(0,5).map(ue=>s.jsxs("li",{className:Pe(me?"flex items-center gap-2 rounded-md px-2.5 py-1.5 text-sm text-muted-foreground":"typography-micro text-muted-foreground/80"),children:[s.jsx("span",{className:Pe(!me&&"hidden"),children:"•"}),s.jsx("span",{className:"truncate",children:ue.title||t("sessions.sidebar.session.untitled")})]},ue.id)),a.sessions.length>5&&s.jsx("li",{className:Pe(me?"px-2.5 py-1 text-xs text-muted-foreground/70":"typography-micro text-muted-foreground/70"),children:t("sessions.sidebar.dialogs.sessionList.more",{count:a.sessions.length-5})})]})]}),me?s.jsxs("div",{className:"space-y-2 rounded-lg bg-muted/30 p-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(D,{name:"git-branch",className:"h-4 w-4 text-muted-foreground"}),s.jsx("span",{className:"typography-meta font-medium text-foreground",children:t("sessions.sidebar.sessionDialogs.worktree.label")}),De?.label?s.jsx("span",{className:"typography-micro text-muted-foreground/70",children:De.label}):null]}),s.jsx("p",{className:"typography-micro text-muted-foreground/80 break-all",children:De?Na(De.path,L):t("sessions.sidebar.sessionDialogs.worktree.pathUnavailable")}),re&&s.jsx("p",{className:"typography-micro text-status-warning",children:t("sessions.sidebar.sessionDialogs.worktree.uncommittedWarning")})]}):s.jsx("div",{className:"rounded-xl border border-border/40 bg-sidebar/60 p-3",children:s.jsx("p",{className:"typography-meta text-muted-foreground/80",children:t("sessions.sidebar.sessionDialogs.delete.note")})})]}):null,Me=me?ae?s.jsxs("button",{type:"button",onClick:()=>{te||m(ue=>!ue)},disabled:te,className:Pe("flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors",te?"cursor-not-allowed opacity-60":"hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary"),children:[u?s.jsx(D,{name:"checkbox",className:"size-4 text-primary"}):s.jsx(D,{name:"checkbox-blank",className:"size-4"}),t("sessions.sidebar.sessionDialogs.actions.deleteRemoteBranch")]}):s.jsx("span",{className:"text-xs text-muted-foreground/70",children:t("sessions.sidebar.sessionDialogs.actions.remoteBranchInfoUnavailable")}):null,he=me?s.jsxs("button",{type:"button",onClick:()=>{ke||g(ue=>!ue)},disabled:ke,className:Pe("flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors",ke?"cursor-not-allowed opacity-60":"hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary"),children:[f?s.jsx(D,{name:"checkbox",className:"size-4 text-primary"}):s.jsx(D,{name:"checkbox-blank",className:"size-4"}),t("sessions.sidebar.sessionDialogs.actions.deleteLocalBranch")]}):null,Ae=me?s.jsxs("div",{className:"flex w-full items-center justify-between gap-3",children:[s.jsxs("div",{className:"flex flex-col items-start gap-1",children:[he,Me]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx($e,{variant:"ghost",onClick:ge,disabled:b,children:t("sessions.sidebar.dialogs.cancel")}),s.jsx($e,{variant:"destructive",onClick:Ne,disabled:b,children:t(b?"sessions.sidebar.sessionDialogs.actions.deleting":"sessions.sidebar.sessionDialogs.actions.deleteWorktree")})]})]}):s.jsxs("div",{className:"flex w-full items-center justify-between gap-3",children:[s.jsxs("button",{type:"button",onClick:()=>P(!O),className:"inline-flex items-center gap-1.5 typography-meta text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary/50","aria-pressed":!O,children:[O?s.jsx(D,{name:"checkbox-blank",className:"size-4"}):s.jsx(D,{name:"checkbox",className:"size-4 text-primary"}),t("sessions.sidebar.dialogs.neverAsk")]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx($e,{variant:"ghost",onClick:ge,disabled:b,children:t("sessions.sidebar.dialogs.cancel")}),s.jsx($e,{variant:"destructive",onClick:Ne,disabled:b,children:b?t("sessions.sidebar.sessionDialogs.actions.deleting"):a?.sessions.length===1?t("sessions.sidebar.dialogs.deleteSession.titleAction"):t("sessions.sidebar.dialogs.deleteSessions.titleAction")})]})]}),pe=me?t("sessions.sidebar.sessionDialogs.actions.deleteWorktree"):a?.sessions.length===1?t("sessions.sidebar.dialogs.deleteSession.titleAction"):t("sessions.sidebar.dialogs.deleteSessions.titleAction");return s.jsxs(s.Fragment,{children:[ne?s.jsx($a,{open:!!a,onClose:()=>{b||ge()},title:pe,footer:s.jsx("div",{className:"flex justify-end gap-2",children:Ae}),children:s.jsxs("div",{className:"space-y-2 pb-2",children:[Be&&s.jsx("p",{className:"typography-meta text-muted-foreground/80",children:Be}),Fe]})}):s.jsx($s,{open:!!a,onOpenChange:ue=>{if(!ue){if(b)return;ge()}},children:s.jsxs(_s,{className:Pe(me?"max-w-xl max-h-[70vh] flex flex-col overflow-hidden gap-3":"max-w-[min(520px,100vw-2rem)] space-y-2 pb-2"),children:[s.jsxs(Hs,{children:[s.jsxs(Us,{className:Pe(me&&"flex items-center gap-2"),children:[me&&s.jsx(D,{name:"delete-bin",className:"h-5 w-5"}),pe]}),Be&&s.jsx(on,{children:Be})]}),s.jsx("div",{className:Pe(me&&"flex-1 min-h-0 overflow-y-auto space-y-2"),children:Fe}),s.jsx(ir,{className:"mt-2 gap-2 pt-1 pb-1",children:Ae})]})}),s.jsx(Kx,{open:e,onOpenChange:n})]})},lc=t=>t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").substring(0,50),nk=(t,e)=>{const n=lc(t),r=lc(e);return`${n}-${r}`.substring(0,60)},yf=(t,e)=>`${t}/${e}`,rk=t=>{const e=t.replace(/\\/g,"/");return e==="/"?"/":e.length>1?e.replace(/\/+$/,""):e},wf=(t,e)=>{const n=rk(e),r=t.directory,o=typeof r=="string"&&r.trim().length>0?t:{...t,directory:n};sx(t.id,n),ut.getState().markSessionAsOpenChamberCreated(t.id),vr.getState().upsertSession(o);try{ka().ensureChild(n,{bootstrap:!1}).setState(c=>{const l=c.session.findIndex(u=>u.id===t.id);if(l>=0&&c.session[l]===o)return c;const d=l>=0?c.session.map((u,m)=>m===l?o:u):[...c.session,o].sort((u,m)=>u.id.localeCompare(m.id));return{session:d,sessionTotal:Math.max(c.sessionTotal,d.length),limit:Math.max(c.limit,d.length)}})}catch{}return o},ik=()=>{const t=ws.getState(),e=t.activeProjectId;if(!e)return null;const n=t.projects.find(o=>o.id===e);if(n?.path)return{id:n.id,path:n.path};const r=Js.getState().currentDirectory??null;if(r&&r.trim().length>0){const o=r.replace(/\\/g,"/").replace(/\/+$/,"")||r;return{id:`path:${o}`,path:o}}return null},Ml=ro()(Pf(t=>({isLoading:!1,error:null,createMultiRun:async e=>{const n=e.name.trim(),{groups:r,agent:o,files:a,setupCommands:c}=e;if(!n)return t({error:"Group name is required"}),null;if(!r||r.length===0)return t({error:"At least one run group is required"}),null;for(let l=0;l<r.length;l++){if(!r[l].prompt.trim())return t({error:`Group ${l+1}: prompt is required`}),null;if(r[l].models.length<1)return t({error:`Group ${l+1}: select at least 1 model`}),null;if(r[l].models.length>5)return t({error:`Group ${l+1}: maximum 5 models allowed`}),null}t({isLoading:!0,error:null});try{const l=ik();if(!l)return t({error:"Select a project",isLoading:!1}),null;const d=l.path,m=await lm(d)&&e.isolateRuns!==!1,f=lc(n),g=m?await Ua(d):void 0,b=m?await Yg(d):null,p=[],x=c?.filter(S=>S.trim().length>0)??[];for(let S=0;S<r.length;S++){const j=r[S],k=j.prompt,v=new Map;for(const I of j.models){const N=`${I.providerID}:${I.modelID}`;v.set(N,(v.get(N)||0)+1)}const A=new Map;for(const I of j.models){const N=`${I.providerID}:${I.modelID}`,O=v.get(N)||1,P=(A.get(N)||0)+1;A.set(N,P);const T=nk(I.providerID,I.modelID),L=r.length>1?`g${S+1}`:void 0,R=O>1?yf(f,`${T}/${P}`):yf(f,T),B=L?`${L}/${R}`:R,V=h2({groupSlug:f,runGroup:L,providerID:I.providerID,modelID:I.modelID,index:O>1?P:void 0});try{if(!m){const ne=await Vn.withDirectory(d,()=>Vn.createSession({title:V}));wf(ne,d),p.push({sessionId:ne.id,worktreePath:d,providerID:I.providerID,modelID:I.modelID,variant:I.variant,prompt:k});continue}const _=await Qg(l,{preferredName:B,mode:"new",branchName:B,worktreeName:B,startRef:e.worktreeBaseBranch||"HEAD",setupCommands:x,returnAfterDirectoryCreated:!0},{resolvedRootTrackingRemote:b}),E={..._,createdFromBranch:g,kind:"standard"};await Jg(l)&&await Xg(_.path);const Z=await Vn.withDirectory(_.path,()=>Vn.createSession({title:V}));wf(Z,_.path),ut.getState().setWorktreeMetadata(Z.id,E),p.push({sessionId:Z.id,worktreePath:_.path,providerID:I.providerID,modelID:I.modelID,variant:I.variant,prompt:k})}catch(_){console.warn("[MultiRun] Failed to create session:",_)}}}const y=c?.filter(S=>S.trim().length>0)??[];y.length>0&&Zg(l,y).catch(()=>{console.warn("[MultiRun] Failed to save worktree setup commands")});const h=p.map(S=>S.sessionId),C=p[0]?.sessionId??null;if(h.length===0)return t({error:"Failed to create any sessions",isLoading:!1}),null;const w=a?.map(S=>({type:"file",mime:S.mime,filename:S.filename,url:S.url}));return(async()=>{try{const S=ex.getState().expandText;await Promise.allSettled(p.map(async j=>{try{const k=await S(j.prompt).catch(()=>j.prompt);await tx({sessionId:j.sessionId,directory:j.worktreePath,content:k,providerID:j.providerID,modelID:j.modelID,variant:j.variant,agent:o,files:w})}catch(k){console.warn("[MultiRun] Failed to start run:",k)}}))}catch(S){console.warn("[MultiRun] Failed to start runs:",S)}})(),t({isLoading:!1}),{groupSlug:f,sessionIds:h,firstSessionId:C}}catch(l){return t({error:l instanceof Error?l.message:"Failed to create Multi-Run",isLoading:!1}),null}},clearError:()=>{t({error:null})}}),{name:"multirun-store"})),ok="oc:lastWorktreeSourceBranch";function bh(t){const e=mt.c(30),{git:n}=Jn(),r=Jf(t),o=Sc(t),a=Nc(t),c=nx(t),l=wn(uk),d=wn(dk);let u,m;e[0]!==t||e[1]!==d||e[2]!==n||e[3]!==o||e[4]!==a?(u=()=>{!t||!n||o!==null||a||d(t,n,{silent:!0})},m=[t,n,d,o,a],e[0]=t,e[1]=d,e[2]=n,e[3]=o,e[4]=a,e[5]=u,e[6]=m):(u=e[5],m=e[6]),i.useEffect(u,m);let f;e[7]!==r?.all||e[8]!==t||e[9]!==l||e[10]!==n||e[11]!==o?(f=()=>{!t||!n||o===!0&&(r?.all||l(t,n))},e[7]=r?.all,e[8]=t,e[9]=l,e[10]=n,e[11]=o,e[12]=f):f=e[12];const g=r?.all;let b;e[13]!==t||e[14]!==l||e[15]!==n||e[16]!==o||e[17]!==g?(b=[t,n,o,g,l],e[13]=t,e[14]=l,e[15]=n,e[16]=o,e[17]=g,e[18]=b):b=e[18],i.useEffect(f,b);const p=a||o===!0&&c;let x;e:{if(!r?.all){let v;e[19]===Symbol.for("react.memo_cache_sentinel")?(v=[],e[19]=v):v=e[19],x=v;break e}let k;e[20]!==r.all?(k=r.all.filter(ck).sort(),e[20]=r.all,e[21]=k):k=e[21],x=k}const y=x;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 k;e[23]!==r.all?(k=r.all.filter(lk).map(ak).sort(),e[23]=r.all,e[24]=k):k=e[24],h=k}const C=h;let w;e:{if(!t){w=null;break e}if(o!==null){w=o;break e}if(p){w=null;break e}w=r?.all?!0:null}const S=w;let j;return e[25]!==S||e[26]!==p||e[27]!==y||e[28]!==C?(j={localBranches:y,remoteBranches:C,isLoading:p,isGitRepository:S},e[25]=S,e[26]=p,e[27]=y,e[28]=C,e[29]=j):j=e[29],j}function ak(t){return t.replace(/^remotes\//,"")}function lk(t){return t.startsWith("remotes/")}function ck(t){return!t.startsWith("remotes/")}function dk(t){return t.fetchStatus}function uk(t){return t.fetchBranches}const fk=({directory:t,value:e,onChange:n,className:r,disabled:o,id:a})=>{const{t:c}=Nt(),{localBranches:l,remoteBranches:d,isLoading:u,isGitRepository:m}=bh(t),f=i.useMemo(()=>[...l,...d.map(b=>`remotes/${b}`)],[l,d]);i.useEffect(()=>{if(o||u||f.length===0||e&&f.includes(e))return;(async()=>{try{const p=t?await Ua(t).catch(()=>null):null,x=localStorage.getItem(ok);x&&f.includes(x)?n(x):p&&f.includes(p)?n(p):f.includes("main")?n("main"):f.includes("master")?n("master"):f[0]&&n(f[0])}catch{}})()},[f,t,o,u,n,e]);const g=o||!m||u;return s.jsxs("div",{children:[s.jsxs($n,{value:e,onValueChange:n,disabled:g,children:[s.jsx(zn,{id:a,size:"lg",className:r??"w-fit typography-meta text-foreground",children:s.jsx(Nn,{placeholder:c(u?"multiRun.branchSelector.status.loadingBranches":"multiRun.branchSelector.placeholder.selectSourceBranch")})}),s.jsx(Wn,{className:"max-h-[280px] max-w-[320px]",children:u?s.jsx("div",{className:"px-2 py-4 text-center typography-meta text-muted-foreground",children:c("multiRun.branchSelector.status.loadingBranches")}):l.length===0&&d.length===0?s.jsx("div",{className:"px-2 py-4 text-center typography-meta text-muted-foreground",children:c("multiRun.branchSelector.status.noBranchesFound")}):s.jsxs(s.Fragment,{children:[l.length>0&&s.jsxs(Wl,{children:[s.jsx(_d,{className:"font-semibold text-foreground",children:c("multiRun.branchSelector.groups.localBranches")}),l.map(b=>s.jsx(Ls,{value:b,className:"whitespace-normal break-all",children:b},b))]}),l.length>0&&d.length>0&&s.jsx(rx,{}),d.length>0&&s.jsxs(Wl,{children:[s.jsx(_d,{className:"font-semibold text-foreground",children:c("multiRun.branchSelector.groups.remoteBranches")}),d.map(b=>s.jsx(Ls,{value:`remotes/${b}`,className:"whitespace-normal break-all",children:b},`remotes/${b}`))]})]})})]}),m===!1&&s.jsx("p",{className:"typography-micro text-muted-foreground/70 mt-2",children:c("multiRun.branchSelector.status.notInGitRepository")})]})},mk=10*1024*1024,Fl=5,pa=t=>{const e=mt.c(3),{children:n}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=s.jsx(Mt,{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(D,{name:"information",className:"h-3.5 w-3.5"})})}),e[0]=r):r=e[0];let o;return e[1]!==n?(o=s.jsxs(Et,{children:[r,s.jsx(Ft,{side:"top",className:"max-w-[240px]",children:n})]}),e[1]=n,e[2]=o):o=e[2],o},Si=t=>{const e=mt.c(9),{htmlFor:n,required:r,children:o,info:a}=t;let c;e[0]!==r?(c=r&&s.jsx("span",{className:"text-destructive ml-0.5",children:"*"}),e[0]=r,e[1]=c):c=e[1];let l;e[2]!==o||e[3]!==n||e[4]!==c?(l=s.jsxs("label",{htmlFor:n,className:"typography-meta font-medium text-foreground",children:[o,c]}),e[2]=o,e[3]=n,e[4]=c,e[5]=l):l=e[5];const d=a&&a;let u;return e[6]!==l||e[7]!==d?(u=s.jsxs("div",{className:"flex items-center gap-1.5",children:[l,d]}),e[6]=l,e[7]=d,e[8]=u):u=e[8],u},hk=({initialPrompt:t,onCreated:e,onCancel:n,isWindowed:r=!1})=>{const{t:o}=Nt(),[a,c]=i.useState(""),[l,d]=i.useState(()=>[{id:Ao(),prompt:"",models:[]}]),[u,m]=i.useState(""),[f,g]=i.useState([]),[b,p]=i.useState(!1),[x,y]=i.useState([]),[h,C]=i.useState(!1),[w,S]=i.useState(!1),[j,k]=i.useState(!0),v=i.useRef(null),A=Js($=>$.currentDirectory??null),I=Js($=>$.homeDirectory??null),N=i.useMemo(()=>{if(typeof window>"u")return null;const $=window.__VSCODE_CONFIG__?.workspaceFolder;return typeof $=="string"&&$.trim().length>0?$.trim():null},[]),O=ws($=>$.activeProjectId),P=ws($=>$.setActiveProjectIdOnly),T=ws($=>$.projects),[L,R]=i.useState(()=>O??null);i.useEffect(()=>{if(O){R(O);return}!L&&T.length>0&&R(T[0].id)},[O,T,L]);const B=i.useMemo(()=>L?T.find($=>$.id===L)??null:null,[T,L]),V=B?.path??A,_=i.useCallback($=>{R($),$!==O&&P($)},[O,P]),{currentTheme:E}=Kr(),Z=i.useCallback($=>{const ve=$.label?.trim()||Ri($.path,I),be=$.icon?Ic[$.icon]:null,z=$.color?Ga[$.color]:void 0,xe=be?s.jsx(D,{name:be,className:"h-3.5 w-3.5 shrink-0",style:z?{color:z}:void 0}):s.jsx(D,{name:"folder",className:"h-3.5 w-3.5 shrink-0 text-muted-foreground/80",style:z?{color:z}:void 0});return s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5",children:[$.iconImage?s.jsx("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center overflow-hidden rounded-[3px]",style:$.iconBackground?{backgroundColor:$.iconBackground}:void 0,children:s.jsx(Ka,{project:{id:$.id,iconImage:$.iconImage??null},options:{themeVariant:E.metadata.variant,iconColor:E.colors.surface.foreground},className:"h-full w-full object-contain",fallback:xe})}):xe,s.jsx("span",{className:"truncate",children:ve})]})},[I,E.metadata.variant,E.colors.surface.foreground]),ne=i.useMemo(()=>{if(B?.path)return{id:B.id,path:B.path};const $=A??N;return $?{id:`path:${$}`,path:$}:null},[B,A,N]),[Y]=i.useState(()=>typeof window<"u"?dr():!1),H=i.useMemo(()=>typeof navigator>"u"?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||""),[]),re=$f(),ae=i.useMemo(()=>{if(typeof window>"u")return null;const $=window.__OPENCHAMBER_MACOS_MAJOR__;if(typeof $=="number"&&Number.isFinite($)&&$>0)return $;if(typeof navigator>"u")return null;const ve=(navigator.userAgent||"").match(/Mac OS X (\d+)[._](\d+)/);if(!ve)return null;const be=Number.parseInt(ve[1],10),z=Number.parseInt(ve[2],10);return Number.isNaN(be)?null:be===10?z:be},[]),me=i.useMemo(()=>Y&&H||re?"pl-[5.5rem]":"pl-3",[Y,H,re]),Se=i.useMemo(()=>!Y||!H||ae===null?"":ae>=26?"h-12":ae<=15?"h-14":"",[Y,H,ae]),te=i.useCallback(async $=>{$.target.closest("button, a, input, select, textarea")||$.button===0&&Y&&await ix()},[Y]);i.useEffect(()=>{if(!n)return;const $=ve=>{ve.key==="Escape"&&(ve.preventDefault(),ve.stopPropagation(),n())};return window.addEventListener("keydown",$,!0),()=>window.removeEventListener("keydown",$,!0)},[n]);const[ke,Q]=i.useState(""),{isLoading:ge,isGitRepository:F}=bh(V),se=i.useRef(!1),ee=F===!0,Ne=ee&&j;i.useEffect(()=>{if(F===!1){se.current=!0,k(!1);return}F===!0&&se.current&&(se.current=!1,k(!0))},[F]);const De=Ml($=>$.createMultiRun),Be=Ml($=>$.error),Fe=Ml($=>$.clearError);i.useEffect(()=>{typeof t=="string"&&t.trim().length>0&&d($=>{const ve=[...$];return ve.length>0&&!ve[0].prompt.trim()&&(ve[0]={...ve[0],prompt:t}),ve})},[t]),i.useEffect(()=>{if(!ne)return;let $=!1;return S(!0),(async()=>{try{const ve=await ox(ne);$||y(ve)}catch{}finally{$||S(!1)}})(),()=>{$=!0}},[ne]);const Me=i.useCallback(($,ve)=>{d(be=>be.map(z=>z.id===$?{...z,...ve}:z))},[]),he=i.useCallback($=>{d(ve=>ve.filter(be=>be.id!==$))},[]),Ae=i.useCallback(()=>{d($=>[...$,{id:Ao(),prompt:"",models:[]}])},[]),pe=async $=>{const ve=$.target.files;if(!ve)return;let be=0;for(let z=0;z<ve.length;z++){const xe=ve[z];if(xe.size>mk){ce.error(o("multirun.launcher.toast.fileTooLarge",{fileName:xe.name}));continue}try{const je=await new Promise((K,ye)=>{const Le=new FileReader;Le.onload=()=>K(Le.result),Le.onerror=ye,Le.readAsDataURL(xe)});g(K=>[...K,{id:Ao(),filename:xe.name,mimeType:xe.type||"application/octet-stream",size:xe.size,dataUrl:je}]),be++}catch(je){console.error("File attach failed",je),ce.error(o("multirun.launcher.toast.attachFailed",{fileName:xe.name}))}}be>0&&ce.success(be===1?o("multirun.launcher.toast.attachedSingle",{count:be}):o("multirun.launcher.toast.attachedPlural",{count:be})),v.current&&(v.current.value="")},ue=$=>{g(ve=>ve.filter(be=>be.id!==$))},U=i.useMemo(()=>l.reduce(($,ve)=>$+ve.models.length,0),[l]),fe=async $=>{$.preventDefault();const ve=l.filter(be=>be.prompt.trim()&&be.models.length>=1);if(ve.length!==0&&!(U<1)){p(!0),Fe();try{L&&L!==O&&P(L);const be=f.map(ye=>({mime:ye.mimeType,filename:ye.filename,url:ye.dataUrl})),z=x.filter(ye=>ye.trim().length>0),xe=ve.map(ye=>({prompt:ye.prompt.trim(),models:ye.models.map(Le=>({providerID:Le.providerID,modelID:Le.modelID,displayName:Le.displayName,variant:Le.variant}))})),je={name:a.trim(),groups:xe,agent:u||void 0,worktreeBaseBranch:Ne?ke:void 0,isolateRuns:Ne,files:be.length>0?be:void 0,setupCommands:z.length>0?z:void 0},K=await De(je);K&&(K.firstSessionId&&ut.getState().setCurrentSession(K.firstSessionId),e?.())}finally{p(!1)}}},de=!!(a.trim()&&l.some($=>$.prompt.trim()&&$.models.length>=1)&&U>=1&&V&&!ge&&(F===!1||!Ne||ke)),G=x.filter($=>$.trim()).length;return s.jsxs("form",{onSubmit:fe,className:"flex flex-col h-full bg-background",children:[r?null:s.jsxs("header",{onMouseDown:te,className:Pe("relative flex h-12 shrink-0 items-center justify-center border-b app-region-drag select-none",me,Se),style:{borderColor:"var(--interactive-border)"},children:[s.jsx("h1",{className:"typography-ui-label font-medium",children:o("multirun.launcher.title")}),n&&s.jsx("div",{className:"absolute right-0 flex items-center pr-3",children:s.jsxs(Et,{children:[s.jsx(Mt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:n,"aria-label":o("multirun.launcher.actions.closeEsc"),className:"inline-flex h-9 w-9 items-center justify-center p-2 rounded-lg text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary app-region-no-drag",children:s.jsx(D,{name:"close",className:"h-5 w-5"})})}),s.jsx(Ft,{children:s.jsx("p",{children:o("multirun.launcher.actions.closeEsc")})})]})})]}),s.jsx(za,{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(Si,{htmlFor:"multirun-project",required:!0,children:o("multirun.launcher.project.label")}),T.length>0?s.jsxs($n,{value:L??void 0,onValueChange:_,children:[s.jsx(zn,{id:"multirun-project",size:"lg",className:"w-fit max-w-full",children:B?s.jsx(Nn,{children:Z(B)}):s.jsx(Nn,{placeholder:o("multirun.launcher.project.placeholder")})}),s.jsx(Wn,{fitContent:!0,children:T.map($=>s.jsx(Ls,{value:$.id,className:"max-w-[24rem]",children:Z($)},$.id))})]}):s.jsx("p",{className:"typography-micro text-muted-foreground py-2",children:o("multirun.launcher.project.empty")})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Si,{htmlFor:"group-name",required:!0,info:s.jsx(pa,{children:o("multirun.launcher.groupName.info")}),children:o("multirun.launcher.groupName.label")}),s.jsx(vn,{id:"group-name",value:a,onChange:$=>c($.target.value),placeholder:o("multirun.launcher.groupName.placeholder"),className:"typography-meta w-full",required:!0})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Si,{htmlFor:"multirun-worktree-base-branch",info:s.jsx(pa,{children:o("multirun.launcher.baseBranch.info")}),children:o("multirun.launcher.baseBranch.label")}),s.jsx(fk,{directory:V,value:ke,onChange:Q,disabled:!Ne,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(Ti,{checked:j,onChange:k,disabled:!ee,ariaLabel:o("multirun.launcher.isolateRuns.label")}),s.jsx("span",{children:o("multirun.launcher.isolateRuns.label")})]})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Si,{htmlFor:"multirun-agent",info:s.jsx(pa,{children:o("multirun.launcher.agent.info")}),children:o("multirun.launcher.agent.label")}),s.jsx(hh,{value:u,onChange:m,id:"multirun-agent"})]})]}),s.jsxs(eo,{open:h,onOpenChange:C,children:[s.jsxs(Bo,{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(D,{name:"terminal",className:"h-3.5 w-3.5 text-muted-foreground/70"}),s.jsx("span",{className:"typography-meta font-medium text-muted-foreground group-hover:text-foreground transition-colors",children:o("multirun.launcher.setupCommands.label")}),G>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:G}),s.jsx(D,{name:"arrow-down-s",className:Pe("h-3.5 w-3.5 text-muted-foreground/50 transition-transform duration-200 ml-auto",h&&"rotate-180")})]}),s.jsx(to,{children:s.jsx("div",{className:"pt-2 space-y-1.5",children:w?s.jsx("p",{className:"typography-meta text-muted-foreground/70 px-2",children:o("multirun.launcher.setupCommands.loading")}):s.jsxs(s.Fragment,{children:[x.map(($,ve)=>s.jsxs("div",{className:"flex gap-1.5",children:[s.jsx(vn,{value:$,onChange:be=>{const z=[...x];z[ve]=be.target.value,y(z)},placeholder:o("multirun.launcher.setupCommands.commandPlaceholder"),className:"h-8 flex-1 font-mono text-xs"}),s.jsx("button",{type:"button",onClick:()=>y(x.filter((be,z)=>z!==ve)),className:"flex-shrink-0 flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:text-destructive hover:bg-destructive/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":o("multirun.launcher.setupCommands.removeCommandAria"),children:s.jsx(D,{name:"close",className:"h-3.5 w-3.5"})})]},`${$}-${ve}`)),s.jsxs("button",{type:"button",onClick:()=>y([...x,""]),className:"flex items-center gap-1 typography-meta text-muted-foreground hover:text-foreground transition-colors px-1",children:[s.jsx(D,{name:"add",className:"h-3 w-3"}),o("multirun.launcher.setupCommands.addCommand")]})]})})})]}),s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx(Si,{htmlFor:"prompt",required:!0,children:o("multirun.launcher.attachments.label")}),s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[s.jsx("input",{ref:v,type:"file",multiple:!0,className:"hidden",onChange:pe,accept:"*/*"}),s.jsxs(Et,{children:[s.jsx(Mt,{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(D,{name:"attachment-2",className:"h-3 w-3"}),o("multirun.launcher.attachments.attach")]})}),s.jsx(Ft,{children:o("multirun.launcher.attachments.tooltip")})]}),f.map($=>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:[$.mimeType.startsWith("image/")?s.jsx(D,{name:"file-image",className:"h-3 w-3 text-muted-foreground"}):s.jsx(D,{name:"file",className:"h-3 w-3 text-muted-foreground"}),s.jsx("span",{className:"truncate max-w-[100px]",title:$.filename,children:$.filename}),s.jsx("button",{type:"button",onClick:()=>ue($.id),className:"text-muted-foreground hover:text-destructive",children:s.jsx(D,{name:"close",className:"h-3 w-3"})})]},$.id))]})]}),l.map(($,ve)=>s.jsx(pk,{group:$,groupIndex:ve,canRemove:l.length>1,onUpdate:Me,onRemove:he},$.id)),s.jsxs("button",{type:"button",onClick:Ae,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(D,{name:"add",className:"h-3.5 w-3.5"}),o("multirun.launcher.groups.addGroup")]}),Be&&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:Be})]})})}),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:[!Ne&&F!==null?s.jsxs("div",{className:"mr-auto flex min-w-0 items-center gap-1.5 typography-micro text-muted-foreground",children:[s.jsx(D,{name:"information",className:"h-3.5 w-3.5 shrink-0"}),s.jsx("span",{className:"truncate",children:o("multirun.launcher.project.gitRequired")})]}):null,s.jsx($e,{type:"button",variant:"ghost",size:"sm",onClick:n,children:o("multirun.launcher.actions.cancel")}),s.jsx($e,{type:"submit",size:"sm",disabled:!de||b,children:b?o("multirun.launcher.actions.creating"):s.jsx(s.Fragment,{children:o("multirun.launcher.actions.startWithRunCount",{count:U})})})]})})]})},pk=t=>{const e=mt.c(99),{group:n,groupIndex:r,canRemove:o,onUpdate:a,onRemove:c}=t,{t:l}=Nt(),[d,u]=i.useState(!1),[m,f]=i.useState(""),[g,b]=i.useState(!1),[p,x]=i.useState(""),[y,h]=i.useState(!1),[C,w]=i.useState(""),S=i.useRef(null),j=i.useRef(null),k=i.useRef(null),v=i.useRef(null);let A;e[0]!==n.id||e[1]!==n.models||e[2]!==a?(A=z=>{n.models.length>=Fl||a(n.id,{models:[...n.models,z]})},e[0]=n.id,e[1]=n.models,e[2]=a,e[3]=A):A=e[3];const I=A;let N;e[4]!==n.id||e[5]!==n.models||e[6]!==a?(N=z=>{a(n.id,{models:n.models.filter((xe,je)=>je!==z)})},e[4]=n.id,e[5]=n.models,e[6]=a,e[7]=N):N=e[7];const O=N;let P;e[8]!==n.id||e[9]!==n.models||e[10]!==a?(P=(z,xe)=>{a(n.id,{models:n.models.map((je,K)=>K===z?xe:je)})},e[8]=n.id,e[9]=n.models,e[10]=a,e[11]=P):P=e[11];const T=P;let L;e[12]===Symbol.for("react.memo_cache_sentinel")?(L=(z,xe)=>{if(z.startsWith("/")){const Le=z.indexOf(" "),Re=z.indexOf(`
|
|
211
211
|
`),X=Math.min(Le===-1?z.length:Le,Re===-1?z.length:Re);if(xe<=X&&Le===-1){x(z.substring(1,X)),b(!0),u(!1),h(!1);return}}b(!1);const je=z.substring(0,xe),K=je.lastIndexOf("#");if(K!==-1){const Le=K>0?je[K-1]:null,Re=je.substring(K+1);if((!Le||/\s/.test(Le))&&!Re.includes(" ")&&!Re.includes(`
|
|
212
212
|
`)){w(Re),h(!0),u(!1);return}}h(!1);const ye=je.lastIndexOf("@");if(ye!==-1){const Le=ye>0?je[ye-1]:null,Re=je.substring(ye+1);(!Le||/\s/.test(Le))&&!Re.includes(" ")&&!Re.includes(`
|
|
213
|
-
`)?(f(Re),u(!0)):u(!1);return}u(!1)},e[12]=L):L=e[12];const R=L;let B;e[13]!==n.id||e[14]!==a?(B=z=>{a(n.id,{prompt:z})},e[13]=n.id,e[14]=a,e[15]=B):B=e[15];const V=B;let _;e[16]!==n.prompt||e[17]!==V?(_=z=>{const xe=n.prompt,K=S.current?.selectionStart??xe.length,Le=xe.substring(0,K).lastIndexOf("@"),Re=z.relativePath&&z.relativePath.trim().length>0?z.relativePath.trim():z.path||z.name,X=Le!==-1?Le:K,M=`${xe.substring(0,X)}@${Re} ${xe.substring(K)}`,le=X+Re.length+2;V(M),u(!1),f(""),requestAnimationFrame(()=>{const ie=S.current;ie&&(ie.selectionStart=le,ie.selectionEnd=le,ie.focus()),R(M,le)})},e[16]=n.prompt,e[17]=V,e[18]=_):_=e[18];const E=_;let Z;e[19]!==n.prompt||e[20]!==V?(Z=z=>{const xe=n.prompt,K=S.current?.selectionStart??xe.length,Le=xe.substring(0,K).lastIndexOf("@"),Re=Le!==-1?Le:K,X=`${xe.substring(0,Re)}@${z} ${xe.substring(K)}`,M=Re+z.length+2;V(X),u(!1),f(""),requestAnimationFrame(()=>{const le=S.current;le&&(le.selectionStart=M,le.selectionEnd=M,le.focus()),R(X,M)})},e[19]=n.prompt,e[20]=V,e[21]=Z):Z=e[21];const ne=Z;let Y;e[22]!==V?(Y=z=>{const xe=`/${z.name} `;V(xe),b(!1),x(""),h(!1),requestAnimationFrame(()=>{const je=S.current;je&&(je.focus(),je.selectionStart=je.value.length,je.selectionEnd=je.value.length),R(xe,xe.length)})},e[22]=V,e[23]=Y):Y=e[23];const H=Y;let re;e[24]!==n.prompt||e[25]!==V?(re=(z,xe)=>{const je=n.prompt,ye=S.current?.selectionStart??je.length,Re=je.substring(0,ye).lastIndexOf("#"),X=Re!==-1?Re:ye,M=`${je.substring(0,X)}#${xe} ${je.substring(ye)}`,le=X+xe.length+2;V(M),h(!1),w(""),requestAnimationFrame(()=>{const ie=S.current;ie&&(ie.selectionStart=le,ie.selectionEnd=le,ie.focus()),R(M,le)})},e[24]=n.prompt,e[25]=V,e[26]=re):re=e[26];const ae=re;let me;e[27]!==g||e[28]!==d||e[29]!==y?(me=z=>{if(g&&k.current&&(z.key==="Enter"||z.key==="ArrowUp"||z.key==="ArrowDown"||z.key==="Escape"||z.key==="Tab")){z.preventDefault(),k.current.handleKeyDown(z.key);return}d&&j.current&&(z.key==="Enter"||z.key==="ArrowUp"||z.key==="ArrowDown"||z.key==="Escape"||z.key==="Tab")&&(z.preventDefault(),j.current.handleKeyDown(z.key)),y&&v.current&&(z.key==="Enter"||z.key==="ArrowUp"||z.key==="ArrowDown"||z.key==="Escape"||z.key==="Tab")&&(z.preventDefault(),v.current.handleKeyDown(z.key))},e[27]=g,e[28]=d,e[29]=y,e[30]=me):me=e[30];const Se=me,te=r+1;let ke;e[31]!==l||e[32]!==te?(ke=l("multirun.launcher.groups.groupLabel",{index:te}),e[31]=l,e[32]=te,e[33]=ke):ke=e[33];let Q;e[34]!==ke?(Q=s.jsx("span",{className:"typography-meta font-medium text-foreground",children:ke}),e[34]=ke,e[35]=Q):Q=e[35];let ge;e[36]!==o||e[37]!==n.id||e[38]!==c||e[39]!==l?(ge=o&&s.jsx("button",{type:"button",onClick:()=>c(n.id),className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-destructive hover:bg-destructive/10","aria-label":l("multirun.launcher.groups.removeGroup"),children:s.jsx(D,{name:"close",className:"h-3.5 w-3.5"})}),e[36]=o,e[37]=n.id,e[38]=c,e[39]=l,e[40]=ge):ge=e[40];let F;e[41]!==Q||e[42]!==ge?(F=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[Q,ge]}),e[41]=Q,e[42]=ge,e[43]=F):F=e[43];let se;e[44]!==l?(se=l("multirun.launcher.groups.prompt.label"),e[44]=l,e[45]=se):se=e[45];let ee;e[46]!==se?(ee=s.jsx(Si,{required:!0,children:se}),e[46]=se,e[47]=ee):ee=e[47];const Ne=n.prompt;let De;e[48]!==V?(De=z=>{const xe=z.target.value;V(xe);const je=z.target.selectionStart??xe.length;R(xe,je)},e[48]=V,e[49]=De):De=e[49];let Be;e[50]!==l?(Be=l("multirun.launcher.groups.prompt.placeholder"),e[50]=l,e[51]=Be):Be=e[51];let Fe;e[52]!==n.prompt||e[53]!==Se||e[54]!==De||e[55]!==Be?(Fe=s.jsx(ki,{ref:S,value:Ne,onChange:De,onKeyDown:Se,placeholder:Be,className:"typography-meta min-h-[80px] max-h-[200px] resize-none overflow-y-auto field-sizing-content",required:!0}),e[52]=n.prompt,e[53]=Se,e[54]=De,e[55]=Be,e[56]=Fe):Fe=e[56];let Me;e[57]!==p||e[58]!==H||e[59]!==g?(Me=g?s.jsx(rm,{ref:k,searchQuery:p,onCommandSelect:H,onClose:()=>b(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,e[57]=p,e[58]=H,e[59]=g,e[60]=Me):Me=e[60];let he;e[61]!==ne||e[62]!==E||e[63]!==m||e[64]!==d?(he=d?s.jsx(im,{ref:j,searchQuery:m,onFileSelect:E,onAgentSelect:ne,onClose:()=>u(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,e[61]=ne,e[62]=E,e[63]=m,e[64]=d,e[65]=he):he=e[65];let Ae;e[66]!==ae||e[67]!==y||e[68]!==C?(Ae=y?s.jsx(om,{ref:v,searchQuery:C,onSnippetSelect:ae,onClose:()=>h(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,e[66]=ae,e[67]=y,e[68]=C,e[69]=Ae):Ae=e[69];let pe;e[70]!==Fe||e[71]!==Me||e[72]!==he||e[73]!==Ae?(pe=s.jsxs("div",{className:"relative",children:[Fe,Me,he,Ae]}),e[70]=Fe,e[71]=Me,e[72]=he,e[73]=Ae,e[74]=pe):pe=e[74];let ue;e[75]!==ee||e[76]!==pe?(ue=s.jsxs("div",{className:"flex flex-col gap-1.5",children:[ee,pe]}),e[75]=ee,e[76]=pe,e[77]=ue):ue=e[77];let U;e[78]!==l?(U=l("multirun.launcher.models.info",{max:Fl}),e[78]=l,e[79]=U):U=e[79];let fe;e[80]!==U?(fe=s.jsx(pa,{children:U}),e[80]=U,e[81]=fe):fe=e[81];let de;e[82]!==l?(de=l("multirun.launcher.models.label"),e[82]=l,e[83]=de):de=e[83];let G;e[84]!==fe||e[85]!==de?(G=s.jsx(Si,{required:!0,info:fe,children:de}),e[84]=fe,e[85]=de,e[86]=G):G=e[86];let $;e[87]!==n.models||e[88]!==I||e[89]!==O||e[90]!==T?($=s.jsx(gh,{selectedModels:n.models,onAdd:I,onRemove:O,onUpdate:T,minModels:1,maxModels:Fl}),e[87]=n.models,e[88]=I,e[89]=O,e[90]=T,e[91]=$):$=e[91];let ve;e[92]!==G||e[93]!==$?(ve=s.jsxs("div",{className:"flex flex-col gap-1.5",children:[G,$]}),e[92]=G,e[93]=$,e[94]=ve):ve=e[94];let be;return e[95]!==F||e[96]!==ue||e[97]!==ve?(be=s.jsxs("div",{className:"rounded-lg border border-border p-3 space-y-3",children:[F,ue,ve]}),e[95]=F,e[96]=ue,e[97]=ve,e[98]=be):be=e[98],be},gk=i.createContext(null),xk=t=>{const e=mt.c(3),{children:n,value:r}=t;let o;return e[0]!==n||e[1]!==r?(o=s.jsx(gk.Provider,{value:r,children:n}),e[0]=n,e[1]=r,e[2]=o):o=e[2],o},vf=oo(()=>io(()=>import("./TerminalView-ME5MOz7S.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8])).then(t=>({default:t.TerminalView}))),bk=oo(()=>io(()=>import("./DiagramView-BAoYIAGR.js"),__vite__mapDeps([9,1,2,4,5,3,6,7,8])).then(t=>({default:t.DiagramView}))),yk=oo(()=>io(()=>import("./NewWorktreeDialog-Bx-zQyBp.js").then(t=>t.a8),__vite__mapDeps([6,1,2,3,4,5,7])).then(t=>({default:t.SettingsView}))),wk=oo(()=>io(()=>import("./SettingsWindow-CSb8eo8p.js"),__vite__mapDeps([10,1,2,3,4,5,6,7])).then(t=>({default:t.SettingsWindow}))),vk=oo(()=>io(()=>import("./MultiRunWindow-BT4kt6aB.js"),__vite__mapDeps([11,1,2,3,4,5,6,7,8])).then(t=>({default:t.MultiRunWindow}))),jk=()=>{const o=Ee(re=>re.isSidebarOpen),a=Ee(re=>re.isRightSidebarOpen),c=Ee(re=>re.isBottomTerminalOpen),l=Ee(re=>re.setRightSidebarOpen),d=Ee(re=>re.setBottomTerminalOpen),u=Ee(re=>re.activeMainTab),m=Ee(re=>re.setIsMobile),f=Ee(re=>re.isSessionSwitcherOpen),g=Ee(re=>re.isSettingsDialogOpen),b=Ee(re=>re.setSettingsDialogOpen),p=Ee(re=>re.isMultiRunLauncherOpen),x=Ee(re=>re.setMultiRunLauncherOpen),y=Ee(re=>re.multiRunLauncherPrefillPrompt),{isMobile:h,isTablet:C}=Er(),w=i.useRef(!1),S=i.useRef(!1),j=i.useRef(!1),[k,v]=i.useState(!1),[A,I]=i.useState(!1),[N,O]=i.useState(!1),[P,T]=i.useState(!1),L=i.useCallback(re=>{v(re),Ee.getState().setSessionSwitcherOpen(re)},[]),R=i.useRef(!1),B=i.useRef(typeof window>"u"?0:window.innerWidth),V=md(-B.current),_=Xe.useRef(0),E=md(B.current),Z=Xe.useRef(0);Xe.useEffect(()=>{h&&(_.current=window.innerWidth,Z.current=window.innerWidth)},[h]),Xe.useEffect(()=>{if(!h){O(!1);return}k&&O(!0),hd(V,k?0:-_.current,{type:"spring",stiffness:400,damping:35,mass:.8})},[k,h,V]),Xe.useEffect(()=>{if(!h){T(!1);return}R.current=A,A&&T(!0),hd(E,A?0:Z.current,{type:"spring",stiffness:400,damping:35,mass:.8})},[h,A,E]),Xe.useEffect(()=>{if(h)return V.on("change",re=>{const ae=_.current||B.current,me=k||re>-ae+.5;O(Se=>Se===me?Se:me)})},[h,V,k]),Xe.useEffect(()=>{if(h)return E.on("change",re=>{const ae=Z.current||B.current,me=A||re<ae-.5;T(Se=>Se===me?Se:me)})},[h,A,E]),Xe.useEffect(()=>{h&&!f&&k&&L(!1)},[f,h,k,L]),Xe.useEffect(()=>{if(!h){j.current=!1;return}j.current||(j.current=!0,L(!1),I(!1),Ee.getState().isRightSidebarOpen&&l(!1))},[h,L,l]),Xe.useEffect(()=>{if(!h||u!=="chat"||k||A||g)return;let re=!1,ae;const me=Se=>{ae=window.setTimeout(()=>{if(re)return;const te=ut.getState(),ke=Ee.getState();if(!(ke.activeMainTab!=="chat"||ke.isSettingsDialogOpen||te.currentSessionId||te.newSessionDraft?.open)){if(te.isLoading){me(250);return}te.openNewSessionDraft()}},Se)};return me(500),()=>{re=!0,ae!==void 0&&window.clearTimeout(ae)}},[u,h,g,k,A]),Xe.useEffect(()=>{!h||!g||(L(!1),I(!1),a&&l(!1))},[h,g,a,L,l]),qx(),i.useEffect(()=>{Ee.getState().isMobile!==h&&m(h)},[h,m]),i.useEffect(()=>{if(typeof window>"u")return;let re;const ae=()=>{re===void 0&&(re=window.requestAnimationFrame(()=>{re=void 0,Ee.getState().updateProportionalSidebarWidths()}))};return window.addEventListener("resize",ae),()=>{window.removeEventListener("resize",ae),re!==void 0&&window.cancelAnimationFrame(re)}},[]),i.useEffect(()=>{if(typeof window>"u")return;let re;const ae=()=>{const Se=Ee.getState(),te=window.innerWidth,ke=window.innerHeight;if(!h&&!C){const Q=te<1140,ge=te>=1220;Q?Se.isRightSidebarOpen&&(l(!1),w.current=!0):ge&&w.current&&(l(!0),w.current=!1);const F=ke<640,se=ke>=700;F?Se.isBottomTerminalOpen&&(d(!1),S.current=!0):se&&S.current&&(d(!0),S.current=!1)}},me=()=>{re===void 0&&(re=window.requestAnimationFrame(()=>{re=void 0,ae()}))};return ae(),window.addEventListener("resize",me),()=>{window.removeEventListener("resize",me),re!==void 0&&window.cancelAnimationFrame(re)}},[h,C,d,l]),i.useEffect(()=>{if(typeof window>"u")return;const re=Ee.subscribe((ae,me)=>{const Se=window.innerWidth,te=window.innerHeight,ke=Se>=1220,Q=te>=700;ae.isRightSidebarOpen!==me.isRightSidebarOpen&&ke&&(w.current=!1),ae.isBottomTerminalOpen!==me.isBottomTerminalOpen&&Q&&(S.current=!1)});return()=>{re()}},[h,C,d,l]);const ne=i.useCallback(()=>{k&&L(!1),I(!A)},[k,A,L]),Y=i.useMemo(()=>{switch(u){case"plan":return s.jsx(i.Suspense,{fallback:null,children:s.jsx(Km,{})});case"git":return s.jsx(i.Suspense,{fallback:null,children:s.jsx(Xl,{isActive:!A})});case"diff":return s.jsx(i.Suspense,{fallback:null,children:s.jsx(zm,{})});case"terminal":return s.jsx(i.Suspense,{fallback:null,children:s.jsx(vf,{})});case"files":return s.jsx(i.Suspense,{fallback:null,children:s.jsx(Gm,{})});case"context":return s.jsx(i.Suspense,{fallback:null,children:s.jsx(Bm,{})});case"diagram":return s.jsx(i.Suspense,{fallback:null,children:s.jsx(bk,{})});default:return null}},[u,A]),H=u==="chat";return s.jsx(Yx,{children:s.jsxs("div",{"data-page-scroll-lock":"true",className:Pe("main-content-safe-area",h?"flex h-[100dvh] flex-col":"relative flex h-[100dvh]","bg-background"),children:[s.jsx(H0,{}),s.jsx(Rj,{}),s.jsx(Lj,{}),s.jsx(sk,{}),h?s.jsxs(xk,{value:{leftDrawerOpen:k,rightDrawerOpen:A,toggleLeftDrawer:()=>{const re=!k;A&&I(!1),L(re)},toggleRightDrawer:ne,leftDrawerX:V,rightDrawerX:E,leftDrawerWidth:_,rightDrawerWidth:Z,setMobileLeftDrawerOpen:L,setRightSidebarOpen:I},children:[!g&&s.jsx(Zd,{onToggleLeftDrawer:()=>{const re=!k;A&&I(!1),L(re)},onToggleRightDrawer:()=>{ne()},leftDrawerOpen:k,rightDrawerOpen:A}),s.jsx("div",{"data-page-scroll-lock":"true",className:Pe("flex flex-1 overflow-hidden relative",g&&"hidden"),children:s.jsxs("main",{className:"w-full h-full overflow-hidden bg-background relative","data-page-scroll-lock":"true",children:[s.jsx("div",{className:Pe("absolute inset-0",!H&&"invisible"),children:s.jsx(Zs,{children:s.jsx(Kl,{})})}),Y&&s.jsx("div",{className:"absolute inset-0",children:s.jsx(Zs,{children:Y})}),p&&s.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:s.jsx(Zs,{children:s.jsx(hk,{initialPrompt:y,onCreated:()=>x(!1),onCancel:()=>x(!1)})})}),N&&s.jsx(pd.div,{className:"absolute inset-0 z-20 bg-sidebar","data-page-scroll-lock":"true",style:{x:V},"aria-hidden":!k,children:s.jsx(Zs,{children:s.jsx(bf,{mobileVariant:!0})})}),P&&s.jsx(pd.div,{className:"absolute inset-0 z-20 bg-sidebar","data-page-scroll-lock":"true",style:{x:E},"aria-hidden":!A,children:s.jsx(Zs,{children:s.jsx(i.Suspense,{fallback:null,children:s.jsx(Xl,{isActive:A})})})})]})}),g&&s.jsx("div",{className:"absolute inset-0 z-10 bg-background",style:{paddingTop:"var(--oc-safe-area-top, 0px)"},children:s.jsx(Zs,{children:s.jsx(i.Suspense,{fallback:null,children:s.jsx(yk,{onClose:()=>b(!1)})})})})]}):s.jsxs(s.Fragment,{children:[s.jsx(ry,{}),s.jsxs("div",{className:"flex flex-1 overflow-hidden","data-page-scroll-lock":"true",children:[s.jsx(ty,{isOpen:o,isMobile:h,className:"border-border/50",topBar:s.jsx(sy,{}),children:s.jsx(bf,{})}),s.jsxs("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden bg-background","data-page-scroll-lock":"true",children:[s.jsx(Zd,{}),s.jsxs("div",{className:"relative flex flex-1 min-h-0 overflow-hidden bg-background","data-page-scroll-lock":"true",children:[s.jsxs("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden border-t border-border/50 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",children:[s.jsxs("main",{className:"flex-1 overflow-hidden bg-background relative","data-page-scroll-lock":"true",children:[s.jsx("div",{className:Pe("absolute inset-0",!H&&"invisible"),children:s.jsx(Zs,{children:s.jsx(Kl,{})})}),Y&&s.jsx("div",{className:"absolute inset-0",children:s.jsx(Zs,{children:Y})})]}),s.jsx(U0,{})]})}),s.jsx(Qb,{isOpen:c,isMobile:h,children:c?s.jsx(Zs,{children:s.jsx(i.Suspense,{fallback:null,children:s.jsx(vf,{})})}):null})]}),s.jsx(dy,{isOpen:a,className:"bg-background border-t border-border/50",children:s.jsx(Zs,{children:s.jsx(Dv,{})})})]})]})]}),s.jsx(i.Suspense,{fallback:null,children:s.jsx(wk,{open:g,onOpenChange:b})}),s.jsx(i.Suspense,{fallback:null,children:s.jsx(vk,{open:p,onOpenChange:x,initialPrompt:y})})]})]})})},Sk=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`},On=t=>{const e=mt.c(8),{label:n,value:r}=t;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o={backgroundColor:"color-mix(in srgb, var(--surface-muted) 55%, transparent)"},e[0]=o):o=e[0];let a;e[1]!==n?(a=s.jsx("div",{className:"typography-meta text-[var(--surface-muted-foreground)]",children:n}),e[1]=n,e[2]=a):a=e[2];let c;e[3]!==r?(c=s.jsx("div",{className:"typography-markdown font-semibold text-[var(--surface-foreground)]",children:r}),e[3]=r,e[4]=c):c=e[4];let l;return e[5]!==a||e[6]!==c?(l=s.jsxs("div",{className:"rounded-md p-2",style:o,children:[a,c]}),e[5]=a,e[6]=c,e[7]=l):l=e[7],l},jf=t=>{const e=mt.c(43),{title:n,snapshot:r,emptyLabel:o}=t,{t:a}=Nt();let c;if(e[0]!==o||e[1]!==r.durationMs||e[2]!==r.entries||e[3]!==r.lastUpdatedAt||e[4]!==r.startedAt||e[5]!==a||e[6]!==n){const l=r.entries.slice(0,12);let d;e[8]!==r.entries?(d=r.entries.reduce(Ck,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]!==a?(f=r.startedAt?Sk(r.durationMs):a("memoryDebugPanel.common.idle"),e[12]=r.durationMs,e[13]=r.startedAt,e[14]=a,e[15]=f):f=e[15];let g;e[16]!==f?(g=s.jsx("div",{className:"typography-meta text-[var(--surface-muted-foreground)]",children:f}),e[16]=f,e[17]=g):g=e[17];let b;e[18]!==m||e[19]!==g?(b=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[m,g]}),e[18]=m,e[19]=g,e[20]=b):b=e[20];let p;e[21]!==a?(p=a("memoryDebugPanel.metric.metrics"),e[21]=a,e[22]=p):p=e[22];let x;e[23]!==r.entries.length||e[24]!==p?(x=s.jsx(On,{label:p,value:r.entries.length}),e[23]=r.entries.length,e[24]=p,e[25]=x):x=e[25];let y;e[26]!==a?(y=a("memoryDebugPanel.metric.samples"),e[26]=a,e[27]=y):y=e[27];let h;e[28]!==y||e[29]!==u?(h=s.jsx(On,{label:y,value:u}),e[28]=y,e[29]=u,e[30]=h):h=e[30];let C;e[31]!==a?(C=a("memoryDebugPanel.metric.lastUpdate"),e[31]=a,e[32]=C):C=e[32];let w;e[33]!==r.lastUpdatedAt||e[34]!==a?(w=r.lastUpdatedAt?a("memoryDebugPanel.common.live"):a("memoryDebugPanel.common.notAvailable"),e[33]=r.lastUpdatedAt,e[34]=a,e[35]=w):w=e[35];let S;e[36]!==C||e[37]!==w?(S=s.jsx(On,{label:C,value:w}),e[36]=C,e[37]=w,e[38]=S):S=e[38];let j;e[39]!==h||e[40]!==S||e[41]!==x?(j=s.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[x,h,S]}),e[39]=h,e[40]=S,e[41]=x,e[42]=j):j=e[42],c=s.jsxs("div",{className:"space-y-2 border-t border-[var(--interactive-border)] pt-2 first:border-t-0 first:pt-0",children:[b,j,l.length===0?s.jsx("div",{className:"rounded-md p-3 typography-meta text-[var(--surface-muted-foreground)]",style:{backgroundColor:"color-mix(in srgb, var(--surface-muted) 45%, transparent)"},children:o}):s.jsx(_n,{outerClassName:"max-h-64",className:"pr-1",children:s.jsx("div",{className:"space-y-1",children:l.map(k=>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:k.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:a("memoryDebugPanel.metric.countValue",{value:k.count})}),s.jsx("span",{children:a("memoryDebugPanel.metric.avgValue",{value:k.avg})}),s.jsx("span",{children:a("memoryDebugPanel.metric.maxValue",{value:k.max})}),s.jsx("span",{children:a("memoryDebugPanel.metric.totalValue",{value:k.total})})]})]},k.metric))})})]}),e[0]=o,e[1]=r.durationMs,e[2]=r.entries,e[3]=r.lastUpdatedAt,e[4]=r.startedAt,e[5]=a,e[6]=n,e[7]=c}else c=e[7];return c},Nk=t=>{const e=mt.c(99),{onClose:n}=t,{t:r}=Nt(),[o,a]=i.useState("memory"),[c,l]=i.useState("idle"),d=ut(Ak),u=am(Dk),m=Cc(),f=ax(Ik),g=rr(Pk),[b,p]=i.useState(Tk),[x,y]=i.useState(Rk);let h;e[0]!==b.entries?(h=new Map,b.entries.forEach(de=>{h.set(de.metric,de.count)}),e[0]=b.entries,e[1]=h):h=e[1];let C;e[2]!==h?(C=h.get("ui.message_list.render")??0,e[2]=h,e[3]=C):C=e[3];let w;e[4]!==h?(w=h.get("ui.message_list.render.streaming")??0,e[4]=h,e[5]=w):w=e[5];let S;e[6]!==h?(S=h.get("ui.chat_message.render")??0,e[6]=h,e[7]=S):S=e[7];let j;e[8]!==h?(j=h.get("ui.chat_message.render.streaming")??0,e[8]=h,e[9]=j):j=e[9];let k;e[10]!==h?(k=h.get("ui.chat_message.render.static_during_stream")??0,e[10]=h,e[11]=k):k=e[11];let v;e[12]!==h?(v=h.get("ui.chat_message.render.static_outside_active_turn_during_stream")??0,e[12]=h,e[13]=v):v=e[13];let A;e[14]!==C||e[15]!==w||e[16]!==S||e[17]!==j||e[18]!==k||e[19]!==v?(A={messageListRender:C,messageListRenderStreaming:w,chatMessageRender:S,chatMessageRenderStreaming:j,chatMessageRenderStaticDuringStream:k,chatMessageRenderStaticOutsideActiveTurnDuringStream:v},e[14]=C,e[15]=w,e[16]=S,e[17]=j,e[18]=k,e[19]=v,e[20]=A):A=e[20];const I=A;let N,O;e[21]===Symbol.for("react.memo_cache_sentinel")?(N=()=>{const de=()=>{p(na()),y(ra())};de();const G=window.setInterval(de,500);return()=>window.clearInterval(G)},O=[],e[21]=N,e[22]=O):(N=e[21],O=e[22]),i.useEffect(N,O);let P,T;e[23]!==c?(P=()=>{if(c==="idle")return;const de=window.setTimeout(()=>{l("idle")},1500);return()=>window.clearTimeout(de)},T=[c],e[23]=c,e[24]=P,e[25]=T):(P=e[24],T=e[25]),i.useEffect(P,T);let L=0,R=0,B=0;for(const de of Object.keys(f)){const G=f[de]??[];R=R+G.length;for(const $ of G)$.role==="user"?B=B+1:$.role==="assistant"&&(L=L+1)}let V;e[26]!==L||e[27]!==R||e[28]!==B?(V={assistant:L,total:R,user:B},e[26]=L,e[27]=R,e[28]=B,e[29]=V):V=e[29];const _=V;let E;if(e[30]!==d||e[31]!==f||e[32]!==u||e[33]!==m||e[34]!==r){let de;e[36]!==d||e[37]!==f||e[38]!==u||e[39]!==r?(de=G=>{const $=f[G.id]??[];let ve=0,be=0;for(const xe of $)xe.role==="user"?be=be+1:xe.role==="assistant"&&(ve=ve+1);const z=u.get(G.id);return{id:G.id,title:G.title||r("memoryDebugPanel.common.untitled"),assistantMessageCount:ve,messageCount:$.length,userMessageCount:be,isStreaming:z?.isStreaming||!1,isZombie:z?.isZombie||!1,backgroundCount:z?.backgroundMessageCount||0,lastAccessed:z?.lastAccessedAt||0,isCurrent:G.id===d}},e[36]=d,e[37]=f,e[38]=u,e[39]=r,e[40]=de):de=e[40],E=m.map(de).sort(Ek),e[30]=d,e[31]=f,e[32]=u,e[33]=m,e[34]=r,e[35]=E}else E=e[35];const Z=E;let ne;e[41]!==f?(ne=Object.keys(f),e[41]=f,e[42]=ne):ne=e[42];const Y=ne.length;let H;e[43]===Symbol.for("react.memo_cache_sentinel")?(H=async()=>{try{const de={generatedAt:new Date().toISOString(),ui:na(),vscode:ra()};await navigator.clipboard.writeText(JSON.stringify(de,null,2)),l("copied")}catch{l("error")}},e[43]=H):H=e[43];const re=H;let ae;e[44]===Symbol.for("react.memo_cache_sentinel")?(ae={backgroundColor:"color-mix(in srgb, var(--surface-background) 94%, transparent)"},e[44]=ae):ae=e[44];let me;e[45]!==o?(me=o==="memory"?s.jsx(D,{name:"database-2",className:"h-4 w-4 text-[var(--surface-foreground)]"}):s.jsx(D,{name:"bar-chart-box",className:"h-4 w-4 text-[var(--surface-foreground)]"}),e[45]=o,e[46]=me):me=e[46];let Se;e[47]!==r?(Se=r("memoryDebugPanel.title"),e[47]=r,e[48]=Se):Se=e[48];let te;e[49]!==Se?(te=s.jsx("h3",{className:"typography-ui-label font-semibold text-[var(--surface-foreground)]",children:Se}),e[49]=Se,e[50]=te):te=e[50];let ke;e[51]!==me||e[52]!==te?(ke=s.jsxs("div",{className:"flex items-center gap-2",children:[me,te]}),e[51]=me,e[52]=te,e[53]=ke):ke=e[53];let Q;e[54]!==o?(Q=o==="streaming"?s.jsxs(s.Fragment,{children:[s.jsx($e,{size:"xs",variant:"ghost",onClick:re,children:s.jsx(D,{name:"file-copy",className:"h-3.5 w-3.5"})}),s.jsx($e,{size:"xs",variant:"ghost",onClick:()=>{mp(),p(na()),y(ra())},children:s.jsx(D,{name:"refresh",className:"h-3.5 w-3.5"})})]}):null,e[54]=o,e[55]=Q):Q=e[55];let ge;e[56]!==n?(ge=n?s.jsx($e,{size:"icon",variant:"ghost",className:"h-6 w-6",onClick:n,children:s.jsx(D,{name:"close",className:"h-4 w-4"})}):null,e[56]=n,e[57]=ge):ge=e[57];let F;e[58]!==Q||e[59]!==ge?(F=s.jsxs("div",{className:"flex items-center gap-1",children:[Q,ge]}),e[58]=Q,e[59]=ge,e[60]=F):F=e[60];let se;e[61]!==ke||e[62]!==F?(se=s.jsxs("div",{className:"mb-3 flex items-center justify-between gap-2",children:[ke,F]}),e[61]=ke,e[62]=F,e[63]=se):se=e[63];let ee;e[64]===Symbol.for("react.memo_cache_sentinel")?(ee={backgroundColor:"color-mix(in srgb, var(--surface-muted) 55%, transparent)"},e[64]=ee):ee=e[64];const Ne=o==="memory"?"secondary":"ghost";let De;e[65]===Symbol.for("react.memo_cache_sentinel")?(De=()=>a("memory"),e[65]=De):De=e[65];let Be;e[66]!==r?(Be=r("memoryDebugPanel.tabs.memory"),e[66]=r,e[67]=Be):Be=e[67];let Fe;e[68]!==Ne||e[69]!==Be?(Fe=s.jsx($e,{size:"sm",variant:Ne,className:"flex-1",onClick:De,children:Be}),e[68]=Ne,e[69]=Be,e[70]=Fe):Fe=e[70];const Me=o==="streaming"?"secondary":"ghost";let he;e[71]===Symbol.for("react.memo_cache_sentinel")?(he=()=>a("streaming"),e[71]=he):he=e[71];let Ae;e[72]!==r?(Ae=r("memoryDebugPanel.tabs.streaming"),e[72]=r,e[73]=Ae):Ae=e[73];let pe;e[74]!==Me||e[75]!==Ae?(pe=s.jsx($e,{size:"sm",variant:Me,className:"flex-1",onClick:he,children:Ae}),e[74]=Me,e[75]=Ae,e[76]=pe):pe=e[76];let ue;e[77]!==Fe||e[78]!==pe?(ue=s.jsxs("div",{className:"mb-3 flex gap-1 rounded-md p-1",style:ee,children:[Fe,pe]}),e[77]=Fe,e[78]=pe,e[79]=ue):ue=e[79];let U;e[80]!==o||e[81]!==Y||e[82]!==c||e[83]!==d||e[84]!==f||e[85]!==_||e[86]!==u||e[87]!==Z||e[88]!==m||e[89]!==I||e[90]!==b||e[91]!==r||e[92]!==g||e[93]!==x?(U=o==="memory"?s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-2 typography-meta",children:[s.jsx(On,{label:r("memoryDebugPanel.metric.totalMessages"),value:_.total}),s.jsx(On,{label:r("memoryDebugPanel.metric.cachedSessions"),value:`${Y} / ${$d.MAX_SESSIONS}`}),s.jsx(On,{label:r("memoryDebugPanel.metric.userMessages"),value:_.user}),s.jsx(On,{label:r("memoryDebugPanel.metric.assistantMessages"),value:_.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:lx()})})]}),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:$d.ZOMBIE_TIMEOUT/1e3/60})})]}),s.jsxs("div",{className:"flex justify-between gap-2",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.metric.githubTotalRequests")}),s.jsx("span",{className:"text-[var(--surface-foreground)]",children:g})]})]}),s.jsxs("div",{className:"border-t border-[var(--interactive-border)] pt-2",children:[s.jsx("div",{className:"mb-1 typography-meta font-semibold text-[var(--surface-foreground)]",children:r("memoryDebugPanel.section.sessionsInMemory")}),s.jsx(_n,{outerClassName:"max-h-48",className:"space-y-1 pr-1",children:Z.map(de=>s.jsxs("div",{className:"typography-meta flex items-center justify-between rounded p-1.5",style:{backgroundColor:de.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:de.title}),de.isStreaming?s.jsx(D,{name:"pulse",className:"h-3 w-3 animate-pulse text-[var(--status-info)]"}):null,de.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:de.assistantMessageCount,user:de.userMessageCount})}),s.jsx("span",{className:"font-mono text-[var(--surface-foreground)]",children:r("memoryDebugPanel.metric.msgsValue",{count:de.messageCount})}),de.backgroundCount>0?s.jsxs("span",{className:"text-[var(--status-info)]",children:["+",de.backgroundCount]}):null]})]},de.id))})]}),s.jsx("div",{className:"flex gap-2 border-t border-[var(--interactive-border)] pt-2",children:s.jsxs(Et,{children:[s.jsx(Mt,{asChild:!0,children:s.jsx($e,{size:"sm",variant:"outline",className:"typography-meta",onClick:()=>{console.log("[DebugPanel] Session store state:",{sessions:m.map(Mk),currentSessionId:d,cachedSessions:Object.keys(f),messageRoleCounts:_,sessionMessageRoleCounts:Z.map(Fk),memoryStates:Object.fromEntries(u)})},children:r("memoryDebugPanel.actions.logState")})}),s.jsx(Ft,{side:"top",children:r("memoryDebugPanel.tooltip.logCurrentState")})]})})]}):s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border border-[var(--interactive-border)] px-3 py-2 typography-meta text-[var(--surface-muted-foreground)]",children:[s.jsx("span",{children:r(c==="copied"?"memoryDebugPanel.streaming.copy.copied":c==="error"?"memoryDebugPanel.streaming.copy.failed":"memoryDebugPanel.streaming.copy.hint")}),s.jsx($e,{size:"xs",variant:"outline",onClick:re,children:r("memoryDebugPanel.actions.copyJson")})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsx(On,{label:r("memoryDebugPanel.metric.uiMetrics"),value:b.entries.length}),s.jsx(On,{label:r("memoryDebugPanel.metric.vscodeMetrics"),value:x.entries.length}),s.jsx(On,{label:r("memoryDebugPanel.metric.messageListRenders"),value:I.messageListRender}),s.jsx(On,{label:r("memoryDebugPanel.metric.messageListStreamRenders"),value:I.messageListRenderStreaming}),s.jsx(On,{label:r("memoryDebugPanel.metric.chatMessageRenders"),value:I.chatMessageRender}),s.jsx(On,{label:r("memoryDebugPanel.metric.chatMessageStreamRenders"),value:I.chatMessageRenderStreaming}),s.jsx(On,{label:r("memoryDebugPanel.metric.chatMessageStaticDuringStream"),value:I.chatMessageRenderStaticDuringStream}),s.jsx(On,{label:r("memoryDebugPanel.metric.chatMessageStaticOutsideActiveTurn"),value:I.chatMessageRenderStaticOutsideActiveTurnDuringStream})]}),s.jsx(jf,{title:r("memoryDebugPanel.section.uiStreamingMetrics"),snapshot:b,emptyLabel:r("memoryDebugPanel.section.noUiSamples")}),x.entries.length>0?s.jsx(jf,{title:r("memoryDebugPanel.section.vscodeBridgeMetrics"),snapshot:x,emptyLabel:r("memoryDebugPanel.section.noVscodeSamples")}):null]}),e[80]=o,e[81]=Y,e[82]=c,e[83]=d,e[84]=f,e[85]=_,e[86]=u,e[87]=Z,e[88]=m,e[89]=I,e[90]=b,e[91]=r,e[92]=g,e[93]=x,e[94]=U):U=e[94];let fe;return e[95]!==se||e[96]!==ue||e[97]!==U?(fe=s.jsxs(cx,{className:"fixed bottom-4 right-4 z-50 w-[28rem] p-4 shadow-none bottom-safe-area",style:ae,children:[se,ue,U]}),e[95]=se,e[96]=ue,e[97]=U,e[98]=fe):fe=e[98],fe},kk=Nk;function Ck(t,e){return t+e.count}function Ak(t){return t.currentSessionId}function Dk(t){return t.sessionMemoryState}function Ik(t){return t.message}function Pk(t){return t.totalRequestCount}function Tk(){return na()}function Rk(){return ra()}function Ek(t,e){return e.lastAccessed-t.lastAccessed}function Mk(t){return{id:t.id,title:t.title}}function Fk(t){return{id:t.id,title:t.title,total:t.messageCount,user:t.userMessageCount,assistant:t.assistantMessageCount}}const Lk=()=>{if(typeof document>"u")return"";const t=document.activeElement;if(t instanceof HTMLTextAreaElement)return t.value.slice(t.selectionStart??0,t.selectionEnd??0);if(t instanceof HTMLInputElement){const e=t.type?.toLowerCase()??"text";if(["text","search","url","tel","password"].includes(e))return t.value.slice(t.selectionStart??0,t.selectionEnd??0)}return t instanceof HTMLElement&&t.isContentEditable?t.ownerDocument.defaultView?.getSelection?.()?.toString()??"":""},Ok=async()=>{const t=Lk()||window.getSelection()?.toString()||"";if(!t.trim())return!1;try{if(typeof navigator<"u"&&navigator.clipboard?.writeText)return await navigator.clipboard.writeText(t),!0}catch{}return document.execCommand("copy")},Sf="openchamber:menu-action",Ll="openchamber:check-for-updates",Bk=t=>{const e=ut(v=>v.openNewSessionDraft),n=Ee(v=>v.toggleCommandPalette),r=Ee(v=>v.setCommandPaletteOpen),o=Ee(v=>v.toggleHelpDialog),a=Ee(v=>v.toggleSidebar),c=Ee(v=>v.setSessionSwitcherOpen),l=Ee(v=>v.setActiveMainTab),d=Ee(v=>v.setSettingsDialogOpen),u=Ee(v=>v.setAboutDialogOpen),m=Ee(v=>v.toggleRightSidebar),f=Ee(v=>v.setRightSidebarOpen),g=Ee(v=>v.setRightSidebarTab),b=Ee(v=>v.toggleBottomTerminal),p=Ee(v=>v.setBottomTerminalExpanded),x=wo(v=>v.checkForUpdates),{setThemeMode:y}=Kr(),h=i.useRef(!1),C=i.useCallback(()=>{h.current||(h.current=!0,x().then(()=>{const{available:v,error:A}=wo.getState();if(A){ce.error("Failed to check for updates",{description:A});return}v||ce.success("You are on the latest version")}).finally(()=>{h.current=!1}))},[x]),w=i.useCallback(()=>{Pr.requestDirectoryDialog()},[]),S=i.useCallback(v=>{const A=dx();if(A.length===0)return;const I=ut.getState().currentSessionId,N=A.findIndex(T=>T.id===I);let O=v>0?0:A.length-1;N>=0&&(O=(N+v+A.length)%A.length);const P=A[O];P&&(l("chat"),c(!1),ut.getState().setCurrentSession(P.id))},[l,c]),j=i.useCallback(v=>{const{activeProjectId:A,projects:I,setActiveProject:N}=ws.getState();if(I.length===0)return;const O=I.findIndex(L=>L.id===A);let P=v>0?0:I.length-1;O>=0&&(P=(O+v+I.length)%I.length);const T=I[P];T&&N(T.id)},[]),k=i.useCallback(v=>{switch(v){case"about":u(!0);break;case"settings":d(!0);break;case"command-palette":n();break;case"quick-open":r(!0);break;case"new-session":l("chat"),c(!1),e();break;case"new-worktree-session":l("chat"),c(!1),nm();break;case"change-workspace":w();break;case"toggle-right-sidebar":m();break;case"open-right-sidebar-git":f(!0),g("git");break;case"open-right-sidebar-files":f(!0),g("files");break;case"toggle-terminal":b();break;case"toggle-terminal-expanded":p(!Ee.getState().isBottomTerminalExpanded);break;case"copy":{const A=new Event("openchamber:copy",{cancelable:!0});!window.dispatchEvent(A)||Ok();break}case"theme-light":y("light");break;case"theme-dark":y("dark");break;case"theme-system":y("system");break;case"toggle-sidebar":a();break;case"toggle-memory-debug":t?.();break;case"go-back":Js.getState().goBack();break;case"go-forward":Js.getState().goForward();break;case"previous-session":S(-1);break;case"next-session":S(1);break;case"previous-project":j(-1);break;case"next-project":j(1);break;case"help-dialog":o();break;case"download-logs":{ux().catch(()=>{ce.error("Failed to collect OpenCode status")});break}}},[w,j,S,t,e,u,l,c,r,d,p,f,g,y,b,n,o,m,a]);i.useEffect(()=>{const v=I=>{const N=I.detail;N&&k(N)},A=()=>{C()};return window.addEventListener(Sf,v),window.addEventListener(Ll,A),()=>{window.removeEventListener(Sf,v),window.removeEventListener(Ll,A)}},[k,C]),i.useEffect(()=>{if(typeof window>"u")return;const A=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof A!="function")return;let I=null,N=null;return A("openchamber:menu-action",O=>{const P=O?.payload;typeof P=="string"&&k(P)}).then(O=>{I=O}).catch(()=>{}),A("openchamber:check-for-updates",()=>{window.dispatchEvent(new Event(Ll))}).then(O=>{N=O}).catch(()=>{}),()=>{(async()=>{try{const P=I?.();P instanceof Promise&&await P}catch{}try{const P=N?.();P instanceof Promise&&await P}catch{}})()}},[k])},Vk="openchamber:tray-action",Nf=5e3,_k=120,$k=45e3,yh=20,kf=()=>typeof window>"u"?!1:window.__OPENCHAMBER_PLATFORM__==="darwin",zk=t=>{const e=typeof t.permission=="string"?t.permission:"Permission",n=Array.isArray(t.patterns)?t.patterns.find(r=>typeof r=="string"&&r.trim()):"";return n?`${e}: ${n}`:e},Wk=t=>{const e=Array.isArray(t.questions)?t.questions[0]:void 0;return e?.header||e?.question||"Question"},Ma=t=>t.time?.updated??t.time?.created??0,Uk=t=>{const e=t.replace(/\\/g,"/").replace(/\/+$/,""),n=e.lastIndexOf("/");return n>=0?e.slice(n+1):e},Hk=(t,e,n,r,o)=>{if(!t)return"";const a=px(n,r,t),c=e.project?.name,l=a?.label?.trim()||c?.trim()||Uk(t),d=oa(t);let u=d&&o.get(d)||"";if(!u){for(const[m,f]of wn.getState().directories)if(oa(m)===d){u=f.status?.current??"";break}}if(!u)for(const m of r.values()){const f=m.find(g=>oa(g.path)===d);if(f?.branch){u=f.branch;break}}return u?`${l} · ${u}`:l},Gk=()=>{const{results:t,dropdownProviderIds:e,displayMode:n}=mn.getState(),r=n==="remaining"?"remaining":"usage";if(!e.length)return{mode:r,groups:[]};const o=new Map(t.map(c=>[c.providerId,c])),a=[];for(const c of pm){if(!e.includes(c.id))continue;const l=o.get(c.id);if(!l||l.configured!==!0)continue;const d=[];for(const[m,f]of Object.entries(l.usage?.windows??{})){const g=r==="remaining"?f.remainingPercent:f.usedPercent;d.push({label:gc(m),value:Io(f.valueLabel,g)})}const u=!l.ok&&l.error?l.error:d.length===0?"No rate limits reported":null;a.push({provider:c.name,rows:d,status:u})}return{mode:r,groups:a}},Kk=async()=>{try{if(Ji())return"Local OpenChamber";const t=window.__OPENCHAMBER_LOCAL_ORIGIN__||window.location.origin,e=Wr();if(e&&ja(e,t))return"Local OpenChamber";const r=(await zf()).hosts.find(o=>e?ja(e,Wf(o)):!1);return r?.label?.trim()?Uf(r.label.trim()):"Instance"}catch{return""}},qk=()=>{const t=new Map,e=new Map,n=[],r=new Map;let o;try{o=ka()}catch{return{statusById:t,branchByDirectory:e,approvals:n,titleById:r}}for(const[a,c]of o.children.entries()){const l=c.getState();l.vcs?.branch&&e.set(oa(a)??a,l.vcs.branch);for(const d of l.session)d?.id&&r.set(d.id,d.title);for(const[d,u]of Object.entries(l.session_status??{})){const m=u?.type,f=m==="busy"?"busy":m==="retry"?"retry":"idle",g=t.get(d);(!g||g==="idle")&&t.set(d,f)}for(const[d,u]of Object.entries(l.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:zk(m),directory:a})}for(const[d,u]of Object.entries(l.question??{}))for(const m of u??[]){if(!m?.id)continue;const f=m.sessionID||d;n.push({kind:"question",id:m.id,sessionId:f,sessionTitle:"",label:Wk(m),directory:a})}}return{statusById:t,branchByDirectory:e,approvals:n,titleById:r}},Yk=()=>{const t=vr.getState().activeSessions,e=new Set;t.filter(r=>r?.id&&!r.parentID).slice().sort((r,o)=>Ma(o)-Ma(r)).slice(0,yh).forEach(r=>{const o=Tr(r);o&&e.add(o)});const n=new Map;for(const r of t){if(!r?.id)continue;const o=Tr(r);if(!o||!e.has(o))continue;const a=n.get(o)??[];a.push(r.id),n.set(o,a)}return n},Qk=t=>{const e=qk(),n=cm.getState().index.session,r=vr.getState().activeSessions,o=new Map(e.titleById),a=new Map;for(const p of r)if(p?.id&&(p.title&&o.set(p.id,p.title),p.parentID)){const x=a.get(p.parentID)??[];x.push(p.id),a.set(p.parentID,x)}const c=p=>{const x=[],y=[...a.get(p)??[]],h=new Set;for(;y.length;){const C=y.pop();h.has(C)||(h.add(C),x.push(C),y.push(...a.get(C)??[]))}return x},l=dm.getState().statusById,d=p=>{const x=e.statusById.get(p);return x&&x!=="idle"?x:l.get(p)?.status??x??"idle"},u=p=>{const x=p.map(y=>d(y));return x.includes("busy")?"busy":x.includes("retry")?"retry":"idle"},m=ws.getState().projects,f=ut.getState().availableWorktreesByProject,g=r.filter(p=>p?.id&&!p.parentID).slice().sort((p,x)=>Ma(x)-Ma(p)).slice(0,yh).map(p=>{const x=[p.id,...c(p.id)],y=Tr(p)??"";return{id:p.id,title:p.title||"Untitled session",status:u(x),branch:y?e.branchByDirectory.get(y)??"":"",unseen:x.reduce((h,C)=>h+(n.unseenCount[C]??0),0),hasError:x.some(h=>n.unseenHasError[h]??!1),directory:y,subtitle:Hk(y,p,m,f,e.branchByDirectory)}}),b=e.approvals.map(p=>({...p,sessionTitle:o.get(p.sessionId)||""}));return{sessions:g,approvals:b,instanceName:t,usage:Gk()}},Jk=()=>{i.useEffect(()=>{if(!kf()||!Fa())return;let t=!1,e="",n=null,r="";const o=()=>{if(t)return;const j=Qk(r),k=JSON.stringify(j);k!==e&&(e=k,Ur("desktop_tray_update",j))};Kk().then(j=>{t||(r=j,o())});const a=async()=>{const j=Yk();await Promise.all([...j.entries()].map(async([k,v])=>{const A=await Vn.getSessionStatusForDirectory(k).catch(()=>null);t||A===null||mx(k,A,v)}))},c=()=>{t||n!==null||(n=window.setTimeout(()=>{n=null,o()},_k))},l=new Map,d=()=>{if(t)return;let j;try{j=ka()}catch{return}const k=new Set;for(const[v,A]of j.children.entries())k.add(v),l.has(v)||l.set(v,A.subscribe(()=>c()));for(const[v,A]of l)k.has(v)||(A(),l.delete(v))};let u=null;try{u=ka().subscribeRegistry(()=>{d(),c()})}catch{}d();const m=cm.subscribe(()=>c()),f=vr.subscribe(()=>c()),g=ws.subscribe(()=>c()),b=ut.subscribe(()=>c()),p=wn.subscribe(()=>c()),x=dm.subscribe(()=>c());fx(Hf());const y=window.setInterval(()=>{Sa()},$k);a();const h=window.setInterval(()=>{a()},Nf),C=mn.subscribe(()=>c());mn.getState().loadSettings().then(()=>{if(t)return;const{dropdownProviderIds:j,results:k}=mn.getState();j.length>0&&j.some(A=>!k.some(I=>I.providerId===A))&&mn.getState().fetchAllQuotas()});const w=window.setInterval(()=>{const j=mn.getState();j.autoRefresh&&j.dropdownProviderIds.length>0&&j.fetchAllQuotas()},Math.max(3e4,mn.getState().refreshIntervalMs||6e4)),S=window.setInterval(()=>{d(),o()},Nf);return o(),()=>{t=!0,n!==null&&window.clearTimeout(n),window.clearInterval(S),window.clearInterval(y),window.clearInterval(h),window.clearInterval(w),m(),f(),g(),b(),p(),x(),C(),u?.();for(const j of l.values())j();l.clear()}},[]),i.useEffect(()=>{if(!kf()||typeof window>"u")return;const e=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof e!="function")return;const n=o=>{o.type==="respond-permission"&&hx(o.sessionId,o.id,o.response).catch(()=>{ce.error("Failed to respond to permission request")})};let r=null;return e(Vk,o=>{const a=o?.payload;!a||typeof a!="object"||typeof a.type!="string"||n(a)}).then(o=>{r=o}).catch(()=>{}),()=>{try{const o=r?.();o instanceof Promise&&o.catch(()=>{})}catch{}}},[])},Xk="/api/notifications/stream",Zk=()=>typeof document>"u"?!0:document.visibilityState==="visible"&&document.hasFocus(),eC=t=>{if(!t||typeof t!="object")return null;const e=t,n=e.properties&&typeof e.properties=="object"?e.properties:null;return e.type!=="openchamber:notification"||!n?null:{title:typeof n.title=="string"?n.title:void 0,body:typeof n.body=="string"?n.body:void 0,tag:typeof n.tag=="string"?n.tag:void 0}},tC=t=>{const e=mt.c(3),n=t?.enabled??!0;let r,o;e[0]!==n?(r=()=>{if(!n||dr()||!pc()||typeof window>"u"||typeof EventSource>"u")return;const a=new EventSource(Ci().sse(Xk));return a.onmessage=sC,()=>{a.close()}},o=[n],e[0]=n,e[1]=r,e[2]=o):(r=e[1],o=e[2]),i.useEffect(r,o)};function sC(t){let e;try{e=JSON.parse(t.data)}catch{return}const n=Ee.getState();if(!n.nativeNotificationsEnabled||n.notificationMode!=="always"&&Zk())return;const r=eC(e);if(!r)return;Lo()?.notifications?.notifyAgentCompletion(r)}const Cf="pwa-install-toast-shown",Af="pwa-install-toast-dismissed",nC=()=>{const t=mt.c(6),{browserTab:e}=Qx(),{t:n}=Nt(),r=i.useRef(n);let o,a;t[0]!==n?(o=()=>{r.current=n},a=[n],t[0]=n,t[1]=o,t[2]=a):(o=t[1],a=t[2]),i.useEffect(o,a);let c,l;t[3]!==e?(c=()=>{if(typeof window>"u"||!pc()||!e)return;let d=null,u=null;const m=()=>{u!==null&&(ce.dismiss(u),u=null)},f=async()=>{if(!d)return;const p=d;d=null,m(),await p.prompt();const{outcome:x}=await p.userChoice;x==="accepted"&&ce.success(r.current("pwa.installPrompt.started"))},g=p=>{const x=p;if(typeof x.prompt!="function")return;x.preventDefault(),d=x;const y=Ni(),h=Mf();Jx({dismissed:y.getItem(Af),sessionShown:h.getItem(Cf),hasActiveToast:u!==null})&&(h.setItem(Cf,"true"),u=ce.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:()=>{Ni().setItem(Af,"true"),m()}}}))},b=()=>{d=null,m(),ce.success(r.current("pwa.installPrompt.installed"))};return window.addEventListener("beforeinstallprompt",g),window.addEventListener("appinstalled",b),()=>{m(),window.removeEventListener("beforeinstallprompt",g),window.removeEventListener("appinstalled",b)}},l=[e],t[3]=e,t[4]=c,t[5]=l):(c=t[4],l=t[5]),i.useEffect(c,l)},rC=({open:t,onOpenChange:e})=>{const{t:n}=Nt(),r=!1,[o,a]=i.useState(null),[c,l]=i.useState(null),[d,u]=i.useState(!1),[m,f]=i.useState(!1),[g,b]=i.useState(null),[p,x]=i.useState(!1);i.useCallback(async()=>{},[g,d,r,n]),i.useEffect(()=>{if(!t)return;(async()=>{try{const C=await As("/api/system/info");if(C.ok){const w=await C.json();if(typeof w.openchamberVersion=="string"&&w.openchamberVersion.trim()){a(w.openchamberVersion);return}}}catch{}a(await gx())})()},[t]),i.useEffect(()=>{if(!t)return;let h=!1;return(async()=>{try{const w=await As("/api/opencode/upgrade-status",{headers:{Accept:"application/json"}});if(!w.ok)return;const S=await w.json().catch(()=>null),j=typeof S?.currentVersion=="string"?S.currentVersion.trim():"";!h&&j&&l(j)}catch{}})(),()=>{h=!0}},[t]),i.useEffect(()=>{{b(null),x(!1);return}},[t,r]);const y=o;return s.jsx($s,{open:t,onOpenChange:e,children:s.jsx(_s,{className:"max-w-xs p-6",children:s.jsxs("div",{className:"flex flex-col items-center text-center space-y-4",children:[s.jsx(Dc,{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:[y&&s.jsx("p",{children:n("aboutDialog.openChamberVersionLabel",{version:y})}),c&&s.jsx("p",{children:n("aboutDialog.openCodeVersionLabel",{version:c})})]})]}),r,s.jsxs("div",{className:"flex flex-col items-center gap-2 pt-2",children:[s.jsxs("div",{className:"flex items-center justify-center gap-4",children:[s.jsxs("a",{href:"https://github.com/btriapitsyn/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(D,{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(D,{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(D,{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")})]})})})},Ol=(t,e)=>{const n=t.get(e);return typeof n!="string"?null:n.trim()||null},iC=(t,e)=>{const n=t instanceof Error?t.message:e;return/oauth state required/i.test(n)?"Authorization session expired or was cleared during reload. Return to OpenChamber and click Authorize again.":n},oC=()=>{const t=Xx(a=>a.completeAuth),[e,n]=i.useState("working"),[r,o]=i.useState("Completing MCP authorization...");return i.useEffect(()=>{if(typeof window>"u"){n("error"),o("Browser context unavailable.");return}const a=new URLSearchParams(window.location.search),c=Ol(a,"code"),l=Zx(a),d=eb(a),u=Ol(a,"error"),m=Ol(a,"error_description");if(u){d&&As(`/api/mcp/auth/pending?state=${encodeURIComponent(d)}`,{method:"DELETE"}).catch(()=>{}),n("error"),o(m??u);return}(async()=>{try{if(!c)throw new Error("Missing OAuth authorization code. Start authorization again from MCP Settings or paste the returned code into OpenChamber manually.");let f=l;if(!f&&d){const g=await As(`/api/mcp/auth/pending?state=${encodeURIComponent(d)}`);if(g.ok){const b=await g.json().catch(()=>null);b?.name?.trim()&&(f={name:b.name.trim(),directory:typeof b.directory=="string"&&b.directory.trim()?b.directory.trim():null})}}if(!f?.name)throw new Error("Authorization session details were not available. Start authorization again from MCP Settings or paste the returned code into OpenChamber manually.");await t(f.name,c,f.directory),d&&await As(`/api/mcp/auth/pending?state=${encodeURIComponent(d)}`,{method:"DELETE"}).catch(()=>{}),n("success"),o("Authorization completed. You can close this tab and return to OpenChamber.")}catch(f){d&&await As(`/api/mcp/auth/pending?state=${encodeURIComponent(d)}`,{method:"DELETE"}).catch(()=>{}),n("error"),o(iC(f,"Failed to complete MCP authorization."))}})()},[t]),s.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background px-6 py-12 text-foreground",children:s.jsxs("div",{className:"w-full max-w-xl rounded-xl border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-8 shadow-sm",children:[s.jsxs("div",{className:"space-y-3 text-center",children:[s.jsx("div",{className:e==="error"?"text-[var(--status-error)]":e==="success"?"text-[var(--status-success)]":"text-[var(--status-info)]",children:s.jsx("h1",{className:"typography-hero font-semibold",children:e==="working"?"Completing Authorization":e==="success"?"Authorization Complete":"Authorization Failed"})}),s.jsx("p",{className:"typography-body text-muted-foreground",children:r})]}),e!=="working"&&s.jsx("div",{className:"mt-8 flex justify-center",children:s.jsx($e,{type:"button",onClick:()=>{typeof window>"u"||window.location.replace("/")},children:"Return to OpenChamber"})})]})})},Df=oo(()=>io(()=>import("./OnboardingScreen-CbJOPUxm.js"),__vite__mapDeps([12,1,2,4,5,3])).then(t=>({default:t.OnboardingScreen}))),aC=()=>{const t=mt.c(3),e=Ee(mC),n=Ee(hC);let r;return t[0]!==e||t[1]!==n?(r=s.jsx(rC,{open:e,onOpenChange:n}),t[0]=e,t[1]=n,t[2]=r):r=t[2],r},lC=t=>{const e=mt.c(21),{onRetry:n,isRetrying:r}=t,{t:o}=Nt();let a;e[0]!==o?(a=o("startup.initRecovery.title"),e[0]=o,e[1]=a):a=e[1];let c;e[2]!==a?(c=s.jsx("h1",{className:"typography-title text-foreground",children:a}),e[2]=a,e[3]=c):c=e[3];let l;e[4]!==o?(l=o("startup.initRecovery.description"),e[4]=o,e[5]=l):l=e[5];let d;e[6]!==l?(d=s.jsx("p",{className:"typography-body text-muted-foreground",children:l}),e[6]=l,e[7]=d):d=e[7];let u;e[8]!==c||e[9]!==d?(u=s.jsxs("div",{className:"flex flex-col gap-2",children:[c,d]}),e[8]=c,e[9]=d,e[10]=u):u=e[10];let m;e[11]!==r||e[12]!==o?(m=o(r?"startup.initRecovery.retrying":"startup.initRecovery.retry"),e[11]=r,e[12]=o,e[13]=m):m=e[13];let f;e[14]!==r||e[15]!==n||e[16]!==m?(f=s.jsx($e,{type:"button",onClick:n,disabled:r,children:m}),e[14]=r,e[15]=n,e[16]=m,e[17]=f):f=e[17];let g;return e[18]!==u||e[19]!==f?(g=s.jsx("div",{className:"flex h-full items-center justify-center bg-background px-6 text-foreground",children:s.jsxs("div",{className:"flex max-w-md flex-col items-center gap-4 text-center",children:[u,f]})}),e[18]=u,e[19]=f,e[20]=g):g=e[20],g},If=t=>t?t.replace(/\\/g,"/").replace(/\/+$/g,""):"",cC=()=>{if(typeof window>"u")return null;const t=new URLSearchParams(window.location.search);if(t.get("ocPanel")!=="session-chat")return null;const e=t.get("sessionId"),n=typeof e=="string"?e.trim():"";if(!n)return null;const r=t.get("directory"),o=typeof r=="string"&&r.trim().length>0?r.trim():null;return{sessionId:n,directory:o,readOnly:t.get("readOnly")==="1"||t.get("readOnly")==="true"}},dC=()=>typeof window>"u"?!1:window.location.pathname===nb,uC=t=>{const e=mt.c(23),{embeddedSessionChat:n,isVSCodeRuntime:r,embeddedBackgroundWorkEnabled:o}=t,a=Js(pC),c=ut(gC),l=ut(xC),d=Pc(),u=i.useRef(null);let m;e[0]!==n.directory?(m=If(n.directory),e[0]=n.directory,e[1]=m):m=e[1];const f=m;let g;e[2]!==a?(g=If(a),e[2]=a,e[3]=g):g=e[3];const b=g;let p,x;if(e[4]!==b||e[5]!==c||e[6]!==n.directory||e[7]!==n.sessionId||e[8]!==f||e[9]!==r||e[10]!==l||e[11]!==d?(p=()=>{if(r||f&&b!==f)return;const j=`${f}
|
|
213
|
+
`)?(f(Re),u(!0)):u(!1);return}u(!1)},e[12]=L):L=e[12];const R=L;let B;e[13]!==n.id||e[14]!==a?(B=z=>{a(n.id,{prompt:z})},e[13]=n.id,e[14]=a,e[15]=B):B=e[15];const V=B;let _;e[16]!==n.prompt||e[17]!==V?(_=z=>{const xe=n.prompt,K=S.current?.selectionStart??xe.length,Le=xe.substring(0,K).lastIndexOf("@"),Re=z.relativePath&&z.relativePath.trim().length>0?z.relativePath.trim():z.path||z.name,X=Le!==-1?Le:K,M=`${xe.substring(0,X)}@${Re} ${xe.substring(K)}`,le=X+Re.length+2;V(M),u(!1),f(""),requestAnimationFrame(()=>{const ie=S.current;ie&&(ie.selectionStart=le,ie.selectionEnd=le,ie.focus()),R(M,le)})},e[16]=n.prompt,e[17]=V,e[18]=_):_=e[18];const E=_;let Z;e[19]!==n.prompt||e[20]!==V?(Z=z=>{const xe=n.prompt,K=S.current?.selectionStart??xe.length,Le=xe.substring(0,K).lastIndexOf("@"),Re=Le!==-1?Le:K,X=`${xe.substring(0,Re)}@${z} ${xe.substring(K)}`,M=Re+z.length+2;V(X),u(!1),f(""),requestAnimationFrame(()=>{const le=S.current;le&&(le.selectionStart=M,le.selectionEnd=M,le.focus()),R(X,M)})},e[19]=n.prompt,e[20]=V,e[21]=Z):Z=e[21];const ne=Z;let Y;e[22]!==V?(Y=z=>{const xe=`/${z.name} `;V(xe),b(!1),x(""),h(!1),requestAnimationFrame(()=>{const je=S.current;je&&(je.focus(),je.selectionStart=je.value.length,je.selectionEnd=je.value.length),R(xe,xe.length)})},e[22]=V,e[23]=Y):Y=e[23];const H=Y;let re;e[24]!==n.prompt||e[25]!==V?(re=(z,xe)=>{const je=n.prompt,ye=S.current?.selectionStart??je.length,Re=je.substring(0,ye).lastIndexOf("#"),X=Re!==-1?Re:ye,M=`${je.substring(0,X)}#${xe} ${je.substring(ye)}`,le=X+xe.length+2;V(M),h(!1),w(""),requestAnimationFrame(()=>{const ie=S.current;ie&&(ie.selectionStart=le,ie.selectionEnd=le,ie.focus()),R(M,le)})},e[24]=n.prompt,e[25]=V,e[26]=re):re=e[26];const ae=re;let me;e[27]!==g||e[28]!==d||e[29]!==y?(me=z=>{if(g&&k.current&&(z.key==="Enter"||z.key==="ArrowUp"||z.key==="ArrowDown"||z.key==="Escape"||z.key==="Tab")){z.preventDefault(),k.current.handleKeyDown(z.key);return}d&&j.current&&(z.key==="Enter"||z.key==="ArrowUp"||z.key==="ArrowDown"||z.key==="Escape"||z.key==="Tab")&&(z.preventDefault(),j.current.handleKeyDown(z.key)),y&&v.current&&(z.key==="Enter"||z.key==="ArrowUp"||z.key==="ArrowDown"||z.key==="Escape"||z.key==="Tab")&&(z.preventDefault(),v.current.handleKeyDown(z.key))},e[27]=g,e[28]=d,e[29]=y,e[30]=me):me=e[30];const Se=me,te=r+1;let ke;e[31]!==l||e[32]!==te?(ke=l("multirun.launcher.groups.groupLabel",{index:te}),e[31]=l,e[32]=te,e[33]=ke):ke=e[33];let Q;e[34]!==ke?(Q=s.jsx("span",{className:"typography-meta font-medium text-foreground",children:ke}),e[34]=ke,e[35]=Q):Q=e[35];let ge;e[36]!==o||e[37]!==n.id||e[38]!==c||e[39]!==l?(ge=o&&s.jsx("button",{type:"button",onClick:()=>c(n.id),className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-destructive hover:bg-destructive/10","aria-label":l("multirun.launcher.groups.removeGroup"),children:s.jsx(D,{name:"close",className:"h-3.5 w-3.5"})}),e[36]=o,e[37]=n.id,e[38]=c,e[39]=l,e[40]=ge):ge=e[40];let F;e[41]!==Q||e[42]!==ge?(F=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[Q,ge]}),e[41]=Q,e[42]=ge,e[43]=F):F=e[43];let se;e[44]!==l?(se=l("multirun.launcher.groups.prompt.label"),e[44]=l,e[45]=se):se=e[45];let ee;e[46]!==se?(ee=s.jsx(Si,{required:!0,children:se}),e[46]=se,e[47]=ee):ee=e[47];const Ne=n.prompt;let De;e[48]!==V?(De=z=>{const xe=z.target.value;V(xe);const je=z.target.selectionStart??xe.length;R(xe,je)},e[48]=V,e[49]=De):De=e[49];let Be;e[50]!==l?(Be=l("multirun.launcher.groups.prompt.placeholder"),e[50]=l,e[51]=Be):Be=e[51];let Fe;e[52]!==n.prompt||e[53]!==Se||e[54]!==De||e[55]!==Be?(Fe=s.jsx(ki,{ref:S,value:Ne,onChange:De,onKeyDown:Se,placeholder:Be,className:"typography-meta min-h-[80px] max-h-[200px] resize-none overflow-y-auto field-sizing-content",required:!0}),e[52]=n.prompt,e[53]=Se,e[54]=De,e[55]=Be,e[56]=Fe):Fe=e[56];let Me;e[57]!==p||e[58]!==H||e[59]!==g?(Me=g?s.jsx(rm,{ref:k,searchQuery:p,onCommandSelect:H,onClose:()=>b(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,e[57]=p,e[58]=H,e[59]=g,e[60]=Me):Me=e[60];let he;e[61]!==ne||e[62]!==E||e[63]!==m||e[64]!==d?(he=d?s.jsx(im,{ref:j,searchQuery:m,onFileSelect:E,onAgentSelect:ne,onClose:()=>u(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,e[61]=ne,e[62]=E,e[63]=m,e[64]=d,e[65]=he):he=e[65];let Ae;e[66]!==ae||e[67]!==y||e[68]!==C?(Ae=y?s.jsx(om,{ref:v,searchQuery:C,onSnippetSelect:ae,onClose:()=>h(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,e[66]=ae,e[67]=y,e[68]=C,e[69]=Ae):Ae=e[69];let pe;e[70]!==Fe||e[71]!==Me||e[72]!==he||e[73]!==Ae?(pe=s.jsxs("div",{className:"relative",children:[Fe,Me,he,Ae]}),e[70]=Fe,e[71]=Me,e[72]=he,e[73]=Ae,e[74]=pe):pe=e[74];let ue;e[75]!==ee||e[76]!==pe?(ue=s.jsxs("div",{className:"flex flex-col gap-1.5",children:[ee,pe]}),e[75]=ee,e[76]=pe,e[77]=ue):ue=e[77];let U;e[78]!==l?(U=l("multirun.launcher.models.info",{max:Fl}),e[78]=l,e[79]=U):U=e[79];let fe;e[80]!==U?(fe=s.jsx(pa,{children:U}),e[80]=U,e[81]=fe):fe=e[81];let de;e[82]!==l?(de=l("multirun.launcher.models.label"),e[82]=l,e[83]=de):de=e[83];let G;e[84]!==fe||e[85]!==de?(G=s.jsx(Si,{required:!0,info:fe,children:de}),e[84]=fe,e[85]=de,e[86]=G):G=e[86];let $;e[87]!==n.models||e[88]!==I||e[89]!==O||e[90]!==T?($=s.jsx(gh,{selectedModels:n.models,onAdd:I,onRemove:O,onUpdate:T,minModels:1,maxModels:Fl}),e[87]=n.models,e[88]=I,e[89]=O,e[90]=T,e[91]=$):$=e[91];let ve;e[92]!==G||e[93]!==$?(ve=s.jsxs("div",{className:"flex flex-col gap-1.5",children:[G,$]}),e[92]=G,e[93]=$,e[94]=ve):ve=e[94];let be;return e[95]!==F||e[96]!==ue||e[97]!==ve?(be=s.jsxs("div",{className:"rounded-lg border border-border p-3 space-y-3",children:[F,ue,ve]}),e[95]=F,e[96]=ue,e[97]=ve,e[98]=be):be=e[98],be},gk=i.createContext(null),xk=t=>{const e=mt.c(3),{children:n,value:r}=t;let o;return e[0]!==n||e[1]!==r?(o=s.jsx(gk.Provider,{value:r,children:n}),e[0]=n,e[1]=r,e[2]=o):o=e[2],o},vf=oo(()=>io(()=>import("./TerminalView-CMdqMpTy.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8])).then(t=>({default:t.TerminalView}))),bk=oo(()=>io(()=>import("./DiagramView-Bbj-QI7h.js"),__vite__mapDeps([9,1,2,4,5,3,6,7,8])).then(t=>({default:t.DiagramView}))),yk=oo(()=>io(()=>import("./NewWorktreeDialog-5TYBoMMA.js").then(t=>t.a8),__vite__mapDeps([6,1,2,3,4,5,7])).then(t=>({default:t.SettingsView}))),wk=oo(()=>io(()=>import("./SettingsWindow-BEfDro9b.js"),__vite__mapDeps([10,1,2,3,4,5,6,7])).then(t=>({default:t.SettingsWindow}))),vk=oo(()=>io(()=>import("./MultiRunWindow-DMMu53kw.js"),__vite__mapDeps([11,1,2,3,4,5,6,7,8])).then(t=>({default:t.MultiRunWindow}))),jk=()=>{const o=Ee(re=>re.isSidebarOpen),a=Ee(re=>re.isRightSidebarOpen),c=Ee(re=>re.isBottomTerminalOpen),l=Ee(re=>re.setRightSidebarOpen),d=Ee(re=>re.setBottomTerminalOpen),u=Ee(re=>re.activeMainTab),m=Ee(re=>re.setIsMobile),f=Ee(re=>re.isSessionSwitcherOpen),g=Ee(re=>re.isSettingsDialogOpen),b=Ee(re=>re.setSettingsDialogOpen),p=Ee(re=>re.isMultiRunLauncherOpen),x=Ee(re=>re.setMultiRunLauncherOpen),y=Ee(re=>re.multiRunLauncherPrefillPrompt),{isMobile:h,isTablet:C}=Er(),w=i.useRef(!1),S=i.useRef(!1),j=i.useRef(!1),[k,v]=i.useState(!1),[A,I]=i.useState(!1),[N,O]=i.useState(!1),[P,T]=i.useState(!1),L=i.useCallback(re=>{v(re),Ee.getState().setSessionSwitcherOpen(re)},[]),R=i.useRef(!1),B=i.useRef(typeof window>"u"?0:window.innerWidth),V=md(-B.current),_=Xe.useRef(0),E=md(B.current),Z=Xe.useRef(0);Xe.useEffect(()=>{h&&(_.current=window.innerWidth,Z.current=window.innerWidth)},[h]),Xe.useEffect(()=>{if(!h){O(!1);return}k&&O(!0),hd(V,k?0:-_.current,{type:"spring",stiffness:400,damping:35,mass:.8})},[k,h,V]),Xe.useEffect(()=>{if(!h){T(!1);return}R.current=A,A&&T(!0),hd(E,A?0:Z.current,{type:"spring",stiffness:400,damping:35,mass:.8})},[h,A,E]),Xe.useEffect(()=>{if(h)return V.on("change",re=>{const ae=_.current||B.current,me=k||re>-ae+.5;O(Se=>Se===me?Se:me)})},[h,V,k]),Xe.useEffect(()=>{if(h)return E.on("change",re=>{const ae=Z.current||B.current,me=A||re<ae-.5;T(Se=>Se===me?Se:me)})},[h,A,E]),Xe.useEffect(()=>{h&&!f&&k&&L(!1)},[f,h,k,L]),Xe.useEffect(()=>{if(!h){j.current=!1;return}j.current||(j.current=!0,L(!1),I(!1),Ee.getState().isRightSidebarOpen&&l(!1))},[h,L,l]),Xe.useEffect(()=>{if(!h||u!=="chat"||k||A||g)return;let re=!1,ae;const me=Se=>{ae=window.setTimeout(()=>{if(re)return;const te=ut.getState(),ke=Ee.getState();if(!(ke.activeMainTab!=="chat"||ke.isSettingsDialogOpen||te.currentSessionId||te.newSessionDraft?.open)){if(te.isLoading){me(250);return}te.openNewSessionDraft()}},Se)};return me(500),()=>{re=!0,ae!==void 0&&window.clearTimeout(ae)}},[u,h,g,k,A]),Xe.useEffect(()=>{!h||!g||(L(!1),I(!1),a&&l(!1))},[h,g,a,L,l]),qx(),i.useEffect(()=>{Ee.getState().isMobile!==h&&m(h)},[h,m]),i.useEffect(()=>{if(typeof window>"u")return;let re;const ae=()=>{re===void 0&&(re=window.requestAnimationFrame(()=>{re=void 0,Ee.getState().updateProportionalSidebarWidths()}))};return window.addEventListener("resize",ae),()=>{window.removeEventListener("resize",ae),re!==void 0&&window.cancelAnimationFrame(re)}},[]),i.useEffect(()=>{if(typeof window>"u")return;let re;const ae=()=>{const Se=Ee.getState(),te=window.innerWidth,ke=window.innerHeight;if(!h&&!C){const Q=te<1140,ge=te>=1220;Q?Se.isRightSidebarOpen&&(l(!1),w.current=!0):ge&&w.current&&(l(!0),w.current=!1);const F=ke<640,se=ke>=700;F?Se.isBottomTerminalOpen&&(d(!1),S.current=!0):se&&S.current&&(d(!0),S.current=!1)}},me=()=>{re===void 0&&(re=window.requestAnimationFrame(()=>{re=void 0,ae()}))};return ae(),window.addEventListener("resize",me),()=>{window.removeEventListener("resize",me),re!==void 0&&window.cancelAnimationFrame(re)}},[h,C,d,l]),i.useEffect(()=>{if(typeof window>"u")return;const re=Ee.subscribe((ae,me)=>{const Se=window.innerWidth,te=window.innerHeight,ke=Se>=1220,Q=te>=700;ae.isRightSidebarOpen!==me.isRightSidebarOpen&&ke&&(w.current=!1),ae.isBottomTerminalOpen!==me.isBottomTerminalOpen&&Q&&(S.current=!1)});return()=>{re()}},[h,C,d,l]);const ne=i.useCallback(()=>{k&&L(!1),I(!A)},[k,A,L]),Y=i.useMemo(()=>{switch(u){case"plan":return s.jsx(i.Suspense,{fallback:null,children:s.jsx(Km,{})});case"git":return s.jsx(i.Suspense,{fallback:null,children:s.jsx(Xl,{isActive:!A})});case"diff":return s.jsx(i.Suspense,{fallback:null,children:s.jsx(zm,{})});case"terminal":return s.jsx(i.Suspense,{fallback:null,children:s.jsx(vf,{})});case"files":return s.jsx(i.Suspense,{fallback:null,children:s.jsx(Gm,{})});case"context":return s.jsx(i.Suspense,{fallback:null,children:s.jsx(Bm,{})});case"diagram":return s.jsx(i.Suspense,{fallback:null,children:s.jsx(bk,{})});default:return null}},[u,A]),H=u==="chat";return s.jsx(Yx,{children:s.jsxs("div",{"data-page-scroll-lock":"true",className:Pe("main-content-safe-area",h?"flex h-[100dvh] flex-col":"relative flex h-[100dvh]","bg-background"),children:[s.jsx(H0,{}),s.jsx(Rj,{}),s.jsx(Lj,{}),s.jsx(sk,{}),h?s.jsxs(xk,{value:{leftDrawerOpen:k,rightDrawerOpen:A,toggleLeftDrawer:()=>{const re=!k;A&&I(!1),L(re)},toggleRightDrawer:ne,leftDrawerX:V,rightDrawerX:E,leftDrawerWidth:_,rightDrawerWidth:Z,setMobileLeftDrawerOpen:L,setRightSidebarOpen:I},children:[!g&&s.jsx(Zd,{onToggleLeftDrawer:()=>{const re=!k;A&&I(!1),L(re)},onToggleRightDrawer:()=>{ne()},leftDrawerOpen:k,rightDrawerOpen:A}),s.jsx("div",{"data-page-scroll-lock":"true",className:Pe("flex flex-1 overflow-hidden relative",g&&"hidden"),children:s.jsxs("main",{className:"w-full h-full overflow-hidden bg-background relative","data-page-scroll-lock":"true",children:[s.jsx("div",{className:Pe("absolute inset-0",!H&&"invisible"),children:s.jsx(Zs,{children:s.jsx(Kl,{})})}),Y&&s.jsx("div",{className:"absolute inset-0",children:s.jsx(Zs,{children:Y})}),p&&s.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:s.jsx(Zs,{children:s.jsx(hk,{initialPrompt:y,onCreated:()=>x(!1),onCancel:()=>x(!1)})})}),N&&s.jsx(pd.div,{className:"absolute inset-0 z-20 bg-sidebar","data-page-scroll-lock":"true",style:{x:V},"aria-hidden":!k,children:s.jsx(Zs,{children:s.jsx(bf,{mobileVariant:!0})})}),P&&s.jsx(pd.div,{className:"absolute inset-0 z-20 bg-sidebar","data-page-scroll-lock":"true",style:{x:E},"aria-hidden":!A,children:s.jsx(Zs,{children:s.jsx(i.Suspense,{fallback:null,children:s.jsx(Xl,{isActive:A})})})})]})}),g&&s.jsx("div",{className:"absolute inset-0 z-10 bg-background",style:{paddingTop:"var(--oc-safe-area-top, 0px)"},children:s.jsx(Zs,{children:s.jsx(i.Suspense,{fallback:null,children:s.jsx(yk,{onClose:()=>b(!1)})})})})]}):s.jsxs(s.Fragment,{children:[s.jsx(ry,{}),s.jsxs("div",{className:"flex flex-1 overflow-hidden","data-page-scroll-lock":"true",children:[s.jsx(ty,{isOpen:o,isMobile:h,className:"border-border/50",topBar:s.jsx(sy,{}),children:s.jsx(bf,{})}),s.jsxs("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden bg-background","data-page-scroll-lock":"true",children:[s.jsx(Zd,{}),s.jsxs("div",{className:"relative flex flex-1 min-h-0 overflow-hidden bg-background","data-page-scroll-lock":"true",children:[s.jsxs("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden border-t border-border/50 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",children:[s.jsxs("main",{className:"flex-1 overflow-hidden bg-background relative","data-page-scroll-lock":"true",children:[s.jsx("div",{className:Pe("absolute inset-0",!H&&"invisible"),children:s.jsx(Zs,{children:s.jsx(Kl,{})})}),Y&&s.jsx("div",{className:"absolute inset-0",children:s.jsx(Zs,{children:Y})})]}),s.jsx(U0,{})]})}),s.jsx(Qb,{isOpen:c,isMobile:h,children:c?s.jsx(Zs,{children:s.jsx(i.Suspense,{fallback:null,children:s.jsx(vf,{})})}):null})]}),s.jsx(dy,{isOpen:a,className:"bg-background border-t border-border/50",children:s.jsx(Zs,{children:s.jsx(Dv,{})})})]})]})]}),s.jsx(i.Suspense,{fallback:null,children:s.jsx(wk,{open:g,onOpenChange:b})}),s.jsx(i.Suspense,{fallback:null,children:s.jsx(vk,{open:p,onOpenChange:x,initialPrompt:y})})]})]})})},Sk=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`},On=t=>{const e=mt.c(8),{label:n,value:r}=t;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o={backgroundColor:"color-mix(in srgb, var(--surface-muted) 55%, transparent)"},e[0]=o):o=e[0];let a;e[1]!==n?(a=s.jsx("div",{className:"typography-meta text-[var(--surface-muted-foreground)]",children:n}),e[1]=n,e[2]=a):a=e[2];let c;e[3]!==r?(c=s.jsx("div",{className:"typography-markdown font-semibold text-[var(--surface-foreground)]",children:r}),e[3]=r,e[4]=c):c=e[4];let l;return e[5]!==a||e[6]!==c?(l=s.jsxs("div",{className:"rounded-md p-2",style:o,children:[a,c]}),e[5]=a,e[6]=c,e[7]=l):l=e[7],l},jf=t=>{const e=mt.c(43),{title:n,snapshot:r,emptyLabel:o}=t,{t:a}=Nt();let c;if(e[0]!==o||e[1]!==r.durationMs||e[2]!==r.entries||e[3]!==r.lastUpdatedAt||e[4]!==r.startedAt||e[5]!==a||e[6]!==n){const l=r.entries.slice(0,12);let d;e[8]!==r.entries?(d=r.entries.reduce(Ck,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]!==a?(f=r.startedAt?Sk(r.durationMs):a("memoryDebugPanel.common.idle"),e[12]=r.durationMs,e[13]=r.startedAt,e[14]=a,e[15]=f):f=e[15];let g;e[16]!==f?(g=s.jsx("div",{className:"typography-meta text-[var(--surface-muted-foreground)]",children:f}),e[16]=f,e[17]=g):g=e[17];let b;e[18]!==m||e[19]!==g?(b=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[m,g]}),e[18]=m,e[19]=g,e[20]=b):b=e[20];let p;e[21]!==a?(p=a("memoryDebugPanel.metric.metrics"),e[21]=a,e[22]=p):p=e[22];let x;e[23]!==r.entries.length||e[24]!==p?(x=s.jsx(On,{label:p,value:r.entries.length}),e[23]=r.entries.length,e[24]=p,e[25]=x):x=e[25];let y;e[26]!==a?(y=a("memoryDebugPanel.metric.samples"),e[26]=a,e[27]=y):y=e[27];let h;e[28]!==y||e[29]!==u?(h=s.jsx(On,{label:y,value:u}),e[28]=y,e[29]=u,e[30]=h):h=e[30];let C;e[31]!==a?(C=a("memoryDebugPanel.metric.lastUpdate"),e[31]=a,e[32]=C):C=e[32];let w;e[33]!==r.lastUpdatedAt||e[34]!==a?(w=r.lastUpdatedAt?a("memoryDebugPanel.common.live"):a("memoryDebugPanel.common.notAvailable"),e[33]=r.lastUpdatedAt,e[34]=a,e[35]=w):w=e[35];let S;e[36]!==C||e[37]!==w?(S=s.jsx(On,{label:C,value:w}),e[36]=C,e[37]=w,e[38]=S):S=e[38];let j;e[39]!==h||e[40]!==S||e[41]!==x?(j=s.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[x,h,S]}),e[39]=h,e[40]=S,e[41]=x,e[42]=j):j=e[42],c=s.jsxs("div",{className:"space-y-2 border-t border-[var(--interactive-border)] pt-2 first:border-t-0 first:pt-0",children:[b,j,l.length===0?s.jsx("div",{className:"rounded-md p-3 typography-meta text-[var(--surface-muted-foreground)]",style:{backgroundColor:"color-mix(in srgb, var(--surface-muted) 45%, transparent)"},children:o}):s.jsx(_n,{outerClassName:"max-h-64",className:"pr-1",children:s.jsx("div",{className:"space-y-1",children:l.map(k=>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:k.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:a("memoryDebugPanel.metric.countValue",{value:k.count})}),s.jsx("span",{children:a("memoryDebugPanel.metric.avgValue",{value:k.avg})}),s.jsx("span",{children:a("memoryDebugPanel.metric.maxValue",{value:k.max})}),s.jsx("span",{children:a("memoryDebugPanel.metric.totalValue",{value:k.total})})]})]},k.metric))})})]}),e[0]=o,e[1]=r.durationMs,e[2]=r.entries,e[3]=r.lastUpdatedAt,e[4]=r.startedAt,e[5]=a,e[6]=n,e[7]=c}else c=e[7];return c},Nk=t=>{const e=mt.c(99),{onClose:n}=t,{t:r}=Nt(),[o,a]=i.useState("memory"),[c,l]=i.useState("idle"),d=ut(Ak),u=am(Dk),m=Cc(),f=ax(Ik),g=rr(Pk),[b,p]=i.useState(Tk),[x,y]=i.useState(Rk);let h;e[0]!==b.entries?(h=new Map,b.entries.forEach(de=>{h.set(de.metric,de.count)}),e[0]=b.entries,e[1]=h):h=e[1];let C;e[2]!==h?(C=h.get("ui.message_list.render")??0,e[2]=h,e[3]=C):C=e[3];let w;e[4]!==h?(w=h.get("ui.message_list.render.streaming")??0,e[4]=h,e[5]=w):w=e[5];let S;e[6]!==h?(S=h.get("ui.chat_message.render")??0,e[6]=h,e[7]=S):S=e[7];let j;e[8]!==h?(j=h.get("ui.chat_message.render.streaming")??0,e[8]=h,e[9]=j):j=e[9];let k;e[10]!==h?(k=h.get("ui.chat_message.render.static_during_stream")??0,e[10]=h,e[11]=k):k=e[11];let v;e[12]!==h?(v=h.get("ui.chat_message.render.static_outside_active_turn_during_stream")??0,e[12]=h,e[13]=v):v=e[13];let A;e[14]!==C||e[15]!==w||e[16]!==S||e[17]!==j||e[18]!==k||e[19]!==v?(A={messageListRender:C,messageListRenderStreaming:w,chatMessageRender:S,chatMessageRenderStreaming:j,chatMessageRenderStaticDuringStream:k,chatMessageRenderStaticOutsideActiveTurnDuringStream:v},e[14]=C,e[15]=w,e[16]=S,e[17]=j,e[18]=k,e[19]=v,e[20]=A):A=e[20];const I=A;let N,O;e[21]===Symbol.for("react.memo_cache_sentinel")?(N=()=>{const de=()=>{p(na()),y(ra())};de();const G=window.setInterval(de,500);return()=>window.clearInterval(G)},O=[],e[21]=N,e[22]=O):(N=e[21],O=e[22]),i.useEffect(N,O);let P,T;e[23]!==c?(P=()=>{if(c==="idle")return;const de=window.setTimeout(()=>{l("idle")},1500);return()=>window.clearTimeout(de)},T=[c],e[23]=c,e[24]=P,e[25]=T):(P=e[24],T=e[25]),i.useEffect(P,T);let L=0,R=0,B=0;for(const de of Object.keys(f)){const G=f[de]??[];R=R+G.length;for(const $ of G)$.role==="user"?B=B+1:$.role==="assistant"&&(L=L+1)}let V;e[26]!==L||e[27]!==R||e[28]!==B?(V={assistant:L,total:R,user:B},e[26]=L,e[27]=R,e[28]=B,e[29]=V):V=e[29];const _=V;let E;if(e[30]!==d||e[31]!==f||e[32]!==u||e[33]!==m||e[34]!==r){let de;e[36]!==d||e[37]!==f||e[38]!==u||e[39]!==r?(de=G=>{const $=f[G.id]??[];let ve=0,be=0;for(const xe of $)xe.role==="user"?be=be+1:xe.role==="assistant"&&(ve=ve+1);const z=u.get(G.id);return{id:G.id,title:G.title||r("memoryDebugPanel.common.untitled"),assistantMessageCount:ve,messageCount:$.length,userMessageCount:be,isStreaming:z?.isStreaming||!1,isZombie:z?.isZombie||!1,backgroundCount:z?.backgroundMessageCount||0,lastAccessed:z?.lastAccessedAt||0,isCurrent:G.id===d}},e[36]=d,e[37]=f,e[38]=u,e[39]=r,e[40]=de):de=e[40],E=m.map(de).sort(Ek),e[30]=d,e[31]=f,e[32]=u,e[33]=m,e[34]=r,e[35]=E}else E=e[35];const Z=E;let ne;e[41]!==f?(ne=Object.keys(f),e[41]=f,e[42]=ne):ne=e[42];const Y=ne.length;let H;e[43]===Symbol.for("react.memo_cache_sentinel")?(H=async()=>{try{const de={generatedAt:new Date().toISOString(),ui:na(),vscode:ra()};await navigator.clipboard.writeText(JSON.stringify(de,null,2)),l("copied")}catch{l("error")}},e[43]=H):H=e[43];const re=H;let ae;e[44]===Symbol.for("react.memo_cache_sentinel")?(ae={backgroundColor:"color-mix(in srgb, var(--surface-background) 94%, transparent)"},e[44]=ae):ae=e[44];let me;e[45]!==o?(me=o==="memory"?s.jsx(D,{name:"database-2",className:"h-4 w-4 text-[var(--surface-foreground)]"}):s.jsx(D,{name:"bar-chart-box",className:"h-4 w-4 text-[var(--surface-foreground)]"}),e[45]=o,e[46]=me):me=e[46];let Se;e[47]!==r?(Se=r("memoryDebugPanel.title"),e[47]=r,e[48]=Se):Se=e[48];let te;e[49]!==Se?(te=s.jsx("h3",{className:"typography-ui-label font-semibold text-[var(--surface-foreground)]",children:Se}),e[49]=Se,e[50]=te):te=e[50];let ke;e[51]!==me||e[52]!==te?(ke=s.jsxs("div",{className:"flex items-center gap-2",children:[me,te]}),e[51]=me,e[52]=te,e[53]=ke):ke=e[53];let Q;e[54]!==o?(Q=o==="streaming"?s.jsxs(s.Fragment,{children:[s.jsx($e,{size:"xs",variant:"ghost",onClick:re,children:s.jsx(D,{name:"file-copy",className:"h-3.5 w-3.5"})}),s.jsx($e,{size:"xs",variant:"ghost",onClick:()=>{mp(),p(na()),y(ra())},children:s.jsx(D,{name:"refresh",className:"h-3.5 w-3.5"})})]}):null,e[54]=o,e[55]=Q):Q=e[55];let ge;e[56]!==n?(ge=n?s.jsx($e,{size:"icon",variant:"ghost",className:"h-6 w-6",onClick:n,children:s.jsx(D,{name:"close",className:"h-4 w-4"})}):null,e[56]=n,e[57]=ge):ge=e[57];let F;e[58]!==Q||e[59]!==ge?(F=s.jsxs("div",{className:"flex items-center gap-1",children:[Q,ge]}),e[58]=Q,e[59]=ge,e[60]=F):F=e[60];let se;e[61]!==ke||e[62]!==F?(se=s.jsxs("div",{className:"mb-3 flex items-center justify-between gap-2",children:[ke,F]}),e[61]=ke,e[62]=F,e[63]=se):se=e[63];let ee;e[64]===Symbol.for("react.memo_cache_sentinel")?(ee={backgroundColor:"color-mix(in srgb, var(--surface-muted) 55%, transparent)"},e[64]=ee):ee=e[64];const Ne=o==="memory"?"secondary":"ghost";let De;e[65]===Symbol.for("react.memo_cache_sentinel")?(De=()=>a("memory"),e[65]=De):De=e[65];let Be;e[66]!==r?(Be=r("memoryDebugPanel.tabs.memory"),e[66]=r,e[67]=Be):Be=e[67];let Fe;e[68]!==Ne||e[69]!==Be?(Fe=s.jsx($e,{size:"sm",variant:Ne,className:"flex-1",onClick:De,children:Be}),e[68]=Ne,e[69]=Be,e[70]=Fe):Fe=e[70];const Me=o==="streaming"?"secondary":"ghost";let he;e[71]===Symbol.for("react.memo_cache_sentinel")?(he=()=>a("streaming"),e[71]=he):he=e[71];let Ae;e[72]!==r?(Ae=r("memoryDebugPanel.tabs.streaming"),e[72]=r,e[73]=Ae):Ae=e[73];let pe;e[74]!==Me||e[75]!==Ae?(pe=s.jsx($e,{size:"sm",variant:Me,className:"flex-1",onClick:he,children:Ae}),e[74]=Me,e[75]=Ae,e[76]=pe):pe=e[76];let ue;e[77]!==Fe||e[78]!==pe?(ue=s.jsxs("div",{className:"mb-3 flex gap-1 rounded-md p-1",style:ee,children:[Fe,pe]}),e[77]=Fe,e[78]=pe,e[79]=ue):ue=e[79];let U;e[80]!==o||e[81]!==Y||e[82]!==c||e[83]!==d||e[84]!==f||e[85]!==_||e[86]!==u||e[87]!==Z||e[88]!==m||e[89]!==I||e[90]!==b||e[91]!==r||e[92]!==g||e[93]!==x?(U=o==="memory"?s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-2 typography-meta",children:[s.jsx(On,{label:r("memoryDebugPanel.metric.totalMessages"),value:_.total}),s.jsx(On,{label:r("memoryDebugPanel.metric.cachedSessions"),value:`${Y} / ${$d.MAX_SESSIONS}`}),s.jsx(On,{label:r("memoryDebugPanel.metric.userMessages"),value:_.user}),s.jsx(On,{label:r("memoryDebugPanel.metric.assistantMessages"),value:_.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:lx()})})]}),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:$d.ZOMBIE_TIMEOUT/1e3/60})})]}),s.jsxs("div",{className:"flex justify-between gap-2",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.metric.githubTotalRequests")}),s.jsx("span",{className:"text-[var(--surface-foreground)]",children:g})]})]}),s.jsxs("div",{className:"border-t border-[var(--interactive-border)] pt-2",children:[s.jsx("div",{className:"mb-1 typography-meta font-semibold text-[var(--surface-foreground)]",children:r("memoryDebugPanel.section.sessionsInMemory")}),s.jsx(_n,{outerClassName:"max-h-48",className:"space-y-1 pr-1",children:Z.map(de=>s.jsxs("div",{className:"typography-meta flex items-center justify-between rounded p-1.5",style:{backgroundColor:de.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:de.title}),de.isStreaming?s.jsx(D,{name:"pulse",className:"h-3 w-3 animate-pulse text-[var(--status-info)]"}):null,de.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:de.assistantMessageCount,user:de.userMessageCount})}),s.jsx("span",{className:"font-mono text-[var(--surface-foreground)]",children:r("memoryDebugPanel.metric.msgsValue",{count:de.messageCount})}),de.backgroundCount>0?s.jsxs("span",{className:"text-[var(--status-info)]",children:["+",de.backgroundCount]}):null]})]},de.id))})]}),s.jsx("div",{className:"flex gap-2 border-t border-[var(--interactive-border)] pt-2",children:s.jsxs(Et,{children:[s.jsx(Mt,{asChild:!0,children:s.jsx($e,{size:"sm",variant:"outline",className:"typography-meta",onClick:()=>{console.log("[DebugPanel] Session store state:",{sessions:m.map(Mk),currentSessionId:d,cachedSessions:Object.keys(f),messageRoleCounts:_,sessionMessageRoleCounts:Z.map(Fk),memoryStates:Object.fromEntries(u)})},children:r("memoryDebugPanel.actions.logState")})}),s.jsx(Ft,{side:"top",children:r("memoryDebugPanel.tooltip.logCurrentState")})]})})]}):s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border border-[var(--interactive-border)] px-3 py-2 typography-meta text-[var(--surface-muted-foreground)]",children:[s.jsx("span",{children:r(c==="copied"?"memoryDebugPanel.streaming.copy.copied":c==="error"?"memoryDebugPanel.streaming.copy.failed":"memoryDebugPanel.streaming.copy.hint")}),s.jsx($e,{size:"xs",variant:"outline",onClick:re,children:r("memoryDebugPanel.actions.copyJson")})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsx(On,{label:r("memoryDebugPanel.metric.uiMetrics"),value:b.entries.length}),s.jsx(On,{label:r("memoryDebugPanel.metric.vscodeMetrics"),value:x.entries.length}),s.jsx(On,{label:r("memoryDebugPanel.metric.messageListRenders"),value:I.messageListRender}),s.jsx(On,{label:r("memoryDebugPanel.metric.messageListStreamRenders"),value:I.messageListRenderStreaming}),s.jsx(On,{label:r("memoryDebugPanel.metric.chatMessageRenders"),value:I.chatMessageRender}),s.jsx(On,{label:r("memoryDebugPanel.metric.chatMessageStreamRenders"),value:I.chatMessageRenderStreaming}),s.jsx(On,{label:r("memoryDebugPanel.metric.chatMessageStaticDuringStream"),value:I.chatMessageRenderStaticDuringStream}),s.jsx(On,{label:r("memoryDebugPanel.metric.chatMessageStaticOutsideActiveTurn"),value:I.chatMessageRenderStaticOutsideActiveTurnDuringStream})]}),s.jsx(jf,{title:r("memoryDebugPanel.section.uiStreamingMetrics"),snapshot:b,emptyLabel:r("memoryDebugPanel.section.noUiSamples")}),x.entries.length>0?s.jsx(jf,{title:r("memoryDebugPanel.section.vscodeBridgeMetrics"),snapshot:x,emptyLabel:r("memoryDebugPanel.section.noVscodeSamples")}):null]}),e[80]=o,e[81]=Y,e[82]=c,e[83]=d,e[84]=f,e[85]=_,e[86]=u,e[87]=Z,e[88]=m,e[89]=I,e[90]=b,e[91]=r,e[92]=g,e[93]=x,e[94]=U):U=e[94];let fe;return e[95]!==se||e[96]!==ue||e[97]!==U?(fe=s.jsxs(cx,{className:"fixed bottom-4 right-4 z-50 w-[28rem] p-4 shadow-none bottom-safe-area",style:ae,children:[se,ue,U]}),e[95]=se,e[96]=ue,e[97]=U,e[98]=fe):fe=e[98],fe},kk=Nk;function Ck(t,e){return t+e.count}function Ak(t){return t.currentSessionId}function Dk(t){return t.sessionMemoryState}function Ik(t){return t.message}function Pk(t){return t.totalRequestCount}function Tk(){return na()}function Rk(){return ra()}function Ek(t,e){return e.lastAccessed-t.lastAccessed}function Mk(t){return{id:t.id,title:t.title}}function Fk(t){return{id:t.id,title:t.title,total:t.messageCount,user:t.userMessageCount,assistant:t.assistantMessageCount}}const Lk=()=>{if(typeof document>"u")return"";const t=document.activeElement;if(t instanceof HTMLTextAreaElement)return t.value.slice(t.selectionStart??0,t.selectionEnd??0);if(t instanceof HTMLInputElement){const e=t.type?.toLowerCase()??"text";if(["text","search","url","tel","password"].includes(e))return t.value.slice(t.selectionStart??0,t.selectionEnd??0)}return t instanceof HTMLElement&&t.isContentEditable?t.ownerDocument.defaultView?.getSelection?.()?.toString()??"":""},Ok=async()=>{const t=Lk()||window.getSelection()?.toString()||"";if(!t.trim())return!1;try{if(typeof navigator<"u"&&navigator.clipboard?.writeText)return await navigator.clipboard.writeText(t),!0}catch{}return document.execCommand("copy")},Sf="openchamber:menu-action",Ll="openchamber:check-for-updates",Bk=t=>{const e=ut(v=>v.openNewSessionDraft),n=Ee(v=>v.toggleCommandPalette),r=Ee(v=>v.setCommandPaletteOpen),o=Ee(v=>v.toggleHelpDialog),a=Ee(v=>v.toggleSidebar),c=Ee(v=>v.setSessionSwitcherOpen),l=Ee(v=>v.setActiveMainTab),d=Ee(v=>v.setSettingsDialogOpen),u=Ee(v=>v.setAboutDialogOpen),m=Ee(v=>v.toggleRightSidebar),f=Ee(v=>v.setRightSidebarOpen),g=Ee(v=>v.setRightSidebarTab),b=Ee(v=>v.toggleBottomTerminal),p=Ee(v=>v.setBottomTerminalExpanded),x=wo(v=>v.checkForUpdates),{setThemeMode:y}=Kr(),h=i.useRef(!1),C=i.useCallback(()=>{h.current||(h.current=!0,x().then(()=>{const{available:v,error:A}=wo.getState();if(A){ce.error("Failed to check for updates",{description:A});return}v||ce.success("You are on the latest version")}).finally(()=>{h.current=!1}))},[x]),w=i.useCallback(()=>{Pr.requestDirectoryDialog()},[]),S=i.useCallback(v=>{const A=dx();if(A.length===0)return;const I=ut.getState().currentSessionId,N=A.findIndex(T=>T.id===I);let O=v>0?0:A.length-1;N>=0&&(O=(N+v+A.length)%A.length);const P=A[O];P&&(l("chat"),c(!1),ut.getState().setCurrentSession(P.id))},[l,c]),j=i.useCallback(v=>{const{activeProjectId:A,projects:I,setActiveProject:N}=ws.getState();if(I.length===0)return;const O=I.findIndex(L=>L.id===A);let P=v>0?0:I.length-1;O>=0&&(P=(O+v+I.length)%I.length);const T=I[P];T&&N(T.id)},[]),k=i.useCallback(v=>{switch(v){case"about":u(!0);break;case"settings":d(!0);break;case"command-palette":n();break;case"quick-open":r(!0);break;case"new-session":l("chat"),c(!1),e();break;case"new-worktree-session":l("chat"),c(!1),nm();break;case"change-workspace":w();break;case"toggle-right-sidebar":m();break;case"open-right-sidebar-git":f(!0),g("git");break;case"open-right-sidebar-files":f(!0),g("files");break;case"toggle-terminal":b();break;case"toggle-terminal-expanded":p(!Ee.getState().isBottomTerminalExpanded);break;case"copy":{const A=new Event("openchamber:copy",{cancelable:!0});!window.dispatchEvent(A)||Ok();break}case"theme-light":y("light");break;case"theme-dark":y("dark");break;case"theme-system":y("system");break;case"toggle-sidebar":a();break;case"toggle-memory-debug":t?.();break;case"go-back":Js.getState().goBack();break;case"go-forward":Js.getState().goForward();break;case"previous-session":S(-1);break;case"next-session":S(1);break;case"previous-project":j(-1);break;case"next-project":j(1);break;case"help-dialog":o();break;case"download-logs":{ux().catch(()=>{ce.error("Failed to collect OpenCode status")});break}}},[w,j,S,t,e,u,l,c,r,d,p,f,g,y,b,n,o,m,a]);i.useEffect(()=>{const v=I=>{const N=I.detail;N&&k(N)},A=()=>{C()};return window.addEventListener(Sf,v),window.addEventListener(Ll,A),()=>{window.removeEventListener(Sf,v),window.removeEventListener(Ll,A)}},[k,C]),i.useEffect(()=>{if(typeof window>"u")return;const A=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof A!="function")return;let I=null,N=null;return A("openchamber:menu-action",O=>{const P=O?.payload;typeof P=="string"&&k(P)}).then(O=>{I=O}).catch(()=>{}),A("openchamber:check-for-updates",()=>{window.dispatchEvent(new Event(Ll))}).then(O=>{N=O}).catch(()=>{}),()=>{(async()=>{try{const P=I?.();P instanceof Promise&&await P}catch{}try{const P=N?.();P instanceof Promise&&await P}catch{}})()}},[k])},Vk="openchamber:tray-action",Nf=5e3,_k=120,$k=45e3,yh=20,kf=()=>typeof window>"u"?!1:window.__OPENCHAMBER_PLATFORM__==="darwin",zk=t=>{const e=typeof t.permission=="string"?t.permission:"Permission",n=Array.isArray(t.patterns)?t.patterns.find(r=>typeof r=="string"&&r.trim()):"";return n?`${e}: ${n}`:e},Wk=t=>{const e=Array.isArray(t.questions)?t.questions[0]:void 0;return e?.header||e?.question||"Question"},Ma=t=>t.time?.updated??t.time?.created??0,Uk=t=>{const e=t.replace(/\\/g,"/").replace(/\/+$/,""),n=e.lastIndexOf("/");return n>=0?e.slice(n+1):e},Hk=(t,e,n,r,o)=>{if(!t)return"";const a=px(n,r,t),c=e.project?.name,l=a?.label?.trim()||c?.trim()||Uk(t),d=oa(t);let u=d&&o.get(d)||"";if(!u){for(const[m,f]of wn.getState().directories)if(oa(m)===d){u=f.status?.current??"";break}}if(!u)for(const m of r.values()){const f=m.find(g=>oa(g.path)===d);if(f?.branch){u=f.branch;break}}return u?`${l} · ${u}`:l},Gk=()=>{const{results:t,dropdownProviderIds:e,displayMode:n}=mn.getState(),r=n==="remaining"?"remaining":"usage";if(!e.length)return{mode:r,groups:[]};const o=new Map(t.map(c=>[c.providerId,c])),a=[];for(const c of pm){if(!e.includes(c.id))continue;const l=o.get(c.id);if(!l||l.configured!==!0)continue;const d=[];for(const[m,f]of Object.entries(l.usage?.windows??{})){const g=r==="remaining"?f.remainingPercent:f.usedPercent;d.push({label:gc(m),value:Io(f.valueLabel,g)})}const u=!l.ok&&l.error?l.error:d.length===0?"No rate limits reported":null;a.push({provider:c.name,rows:d,status:u})}return{mode:r,groups:a}},Kk=async()=>{try{if(Ji())return"Local OpenChamber";const t=window.__OPENCHAMBER_LOCAL_ORIGIN__||window.location.origin,e=Wr();if(e&&ja(e,t))return"Local OpenChamber";const r=(await zf()).hosts.find(o=>e?ja(e,Wf(o)):!1);return r?.label?.trim()?Uf(r.label.trim()):"Instance"}catch{return""}},qk=()=>{const t=new Map,e=new Map,n=[],r=new Map;let o;try{o=ka()}catch{return{statusById:t,branchByDirectory:e,approvals:n,titleById:r}}for(const[a,c]of o.children.entries()){const l=c.getState();l.vcs?.branch&&e.set(oa(a)??a,l.vcs.branch);for(const d of l.session)d?.id&&r.set(d.id,d.title);for(const[d,u]of Object.entries(l.session_status??{})){const m=u?.type,f=m==="busy"?"busy":m==="retry"?"retry":"idle",g=t.get(d);(!g||g==="idle")&&t.set(d,f)}for(const[d,u]of Object.entries(l.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:zk(m),directory:a})}for(const[d,u]of Object.entries(l.question??{}))for(const m of u??[]){if(!m?.id)continue;const f=m.sessionID||d;n.push({kind:"question",id:m.id,sessionId:f,sessionTitle:"",label:Wk(m),directory:a})}}return{statusById:t,branchByDirectory:e,approvals:n,titleById:r}},Yk=()=>{const t=vr.getState().activeSessions,e=new Set;t.filter(r=>r?.id&&!r.parentID).slice().sort((r,o)=>Ma(o)-Ma(r)).slice(0,yh).forEach(r=>{const o=Tr(r);o&&e.add(o)});const n=new Map;for(const r of t){if(!r?.id)continue;const o=Tr(r);if(!o||!e.has(o))continue;const a=n.get(o)??[];a.push(r.id),n.set(o,a)}return n},Qk=t=>{const e=qk(),n=cm.getState().index.session,r=vr.getState().activeSessions,o=new Map(e.titleById),a=new Map;for(const p of r)if(p?.id&&(p.title&&o.set(p.id,p.title),p.parentID)){const x=a.get(p.parentID)??[];x.push(p.id),a.set(p.parentID,x)}const c=p=>{const x=[],y=[...a.get(p)??[]],h=new Set;for(;y.length;){const C=y.pop();h.has(C)||(h.add(C),x.push(C),y.push(...a.get(C)??[]))}return x},l=dm.getState().statusById,d=p=>{const x=e.statusById.get(p);return x&&x!=="idle"?x:l.get(p)?.status??x??"idle"},u=p=>{const x=p.map(y=>d(y));return x.includes("busy")?"busy":x.includes("retry")?"retry":"idle"},m=ws.getState().projects,f=ut.getState().availableWorktreesByProject,g=r.filter(p=>p?.id&&!p.parentID).slice().sort((p,x)=>Ma(x)-Ma(p)).slice(0,yh).map(p=>{const x=[p.id,...c(p.id)],y=Tr(p)??"";return{id:p.id,title:p.title||"Untitled session",status:u(x),branch:y?e.branchByDirectory.get(y)??"":"",unseen:x.reduce((h,C)=>h+(n.unseenCount[C]??0),0),hasError:x.some(h=>n.unseenHasError[h]??!1),directory:y,subtitle:Hk(y,p,m,f,e.branchByDirectory)}}),b=e.approvals.map(p=>({...p,sessionTitle:o.get(p.sessionId)||""}));return{sessions:g,approvals:b,instanceName:t,usage:Gk()}},Jk=()=>{i.useEffect(()=>{if(!kf()||!Fa())return;let t=!1,e="",n=null,r="";const o=()=>{if(t)return;const j=Qk(r),k=JSON.stringify(j);k!==e&&(e=k,Ur("desktop_tray_update",j))};Kk().then(j=>{t||(r=j,o())});const a=async()=>{const j=Yk();await Promise.all([...j.entries()].map(async([k,v])=>{const A=await Vn.getSessionStatusForDirectory(k).catch(()=>null);t||A===null||mx(k,A,v)}))},c=()=>{t||n!==null||(n=window.setTimeout(()=>{n=null,o()},_k))},l=new Map,d=()=>{if(t)return;let j;try{j=ka()}catch{return}const k=new Set;for(const[v,A]of j.children.entries())k.add(v),l.has(v)||l.set(v,A.subscribe(()=>c()));for(const[v,A]of l)k.has(v)||(A(),l.delete(v))};let u=null;try{u=ka().subscribeRegistry(()=>{d(),c()})}catch{}d();const m=cm.subscribe(()=>c()),f=vr.subscribe(()=>c()),g=ws.subscribe(()=>c()),b=ut.subscribe(()=>c()),p=wn.subscribe(()=>c()),x=dm.subscribe(()=>c());fx(Hf());const y=window.setInterval(()=>{Sa()},$k);a();const h=window.setInterval(()=>{a()},Nf),C=mn.subscribe(()=>c());mn.getState().loadSettings().then(()=>{if(t)return;const{dropdownProviderIds:j,results:k}=mn.getState();j.length>0&&j.some(A=>!k.some(I=>I.providerId===A))&&mn.getState().fetchAllQuotas()});const w=window.setInterval(()=>{const j=mn.getState();j.autoRefresh&&j.dropdownProviderIds.length>0&&j.fetchAllQuotas()},Math.max(3e4,mn.getState().refreshIntervalMs||6e4)),S=window.setInterval(()=>{d(),o()},Nf);return o(),()=>{t=!0,n!==null&&window.clearTimeout(n),window.clearInterval(S),window.clearInterval(y),window.clearInterval(h),window.clearInterval(w),m(),f(),g(),b(),p(),x(),C(),u?.();for(const j of l.values())j();l.clear()}},[]),i.useEffect(()=>{if(!kf()||typeof window>"u")return;const e=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof e!="function")return;const n=o=>{o.type==="respond-permission"&&hx(o.sessionId,o.id,o.response).catch(()=>{ce.error("Failed to respond to permission request")})};let r=null;return e(Vk,o=>{const a=o?.payload;!a||typeof a!="object"||typeof a.type!="string"||n(a)}).then(o=>{r=o}).catch(()=>{}),()=>{try{const o=r?.();o instanceof Promise&&o.catch(()=>{})}catch{}}},[])},Xk="/api/notifications/stream",Zk=()=>typeof document>"u"?!0:document.visibilityState==="visible"&&document.hasFocus(),eC=t=>{if(!t||typeof t!="object")return null;const e=t,n=e.properties&&typeof e.properties=="object"?e.properties:null;return e.type!=="openchamber:notification"||!n?null:{title:typeof n.title=="string"?n.title:void 0,body:typeof n.body=="string"?n.body:void 0,tag:typeof n.tag=="string"?n.tag:void 0}},tC=t=>{const e=mt.c(3),n=t?.enabled??!0;let r,o;e[0]!==n?(r=()=>{if(!n||dr()||!pc()||typeof window>"u"||typeof EventSource>"u")return;const a=new EventSource(Ci().sse(Xk));return a.onmessage=sC,()=>{a.close()}},o=[n],e[0]=n,e[1]=r,e[2]=o):(r=e[1],o=e[2]),i.useEffect(r,o)};function sC(t){let e;try{e=JSON.parse(t.data)}catch{return}const n=Ee.getState();if(!n.nativeNotificationsEnabled||n.notificationMode!=="always"&&Zk())return;const r=eC(e);if(!r)return;Lo()?.notifications?.notifyAgentCompletion(r)}const Cf="pwa-install-toast-shown",Af="pwa-install-toast-dismissed",nC=()=>{const t=mt.c(6),{browserTab:e}=Qx(),{t:n}=Nt(),r=i.useRef(n);let o,a;t[0]!==n?(o=()=>{r.current=n},a=[n],t[0]=n,t[1]=o,t[2]=a):(o=t[1],a=t[2]),i.useEffect(o,a);let c,l;t[3]!==e?(c=()=>{if(typeof window>"u"||!pc()||!e)return;let d=null,u=null;const m=()=>{u!==null&&(ce.dismiss(u),u=null)},f=async()=>{if(!d)return;const p=d;d=null,m(),await p.prompt();const{outcome:x}=await p.userChoice;x==="accepted"&&ce.success(r.current("pwa.installPrompt.started"))},g=p=>{const x=p;if(typeof x.prompt!="function")return;x.preventDefault(),d=x;const y=Ni(),h=Mf();Jx({dismissed:y.getItem(Af),sessionShown:h.getItem(Cf),hasActiveToast:u!==null})&&(h.setItem(Cf,"true"),u=ce.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:()=>{Ni().setItem(Af,"true"),m()}}}))},b=()=>{d=null,m(),ce.success(r.current("pwa.installPrompt.installed"))};return window.addEventListener("beforeinstallprompt",g),window.addEventListener("appinstalled",b),()=>{m(),window.removeEventListener("beforeinstallprompt",g),window.removeEventListener("appinstalled",b)}},l=[e],t[3]=e,t[4]=c,t[5]=l):(c=t[4],l=t[5]),i.useEffect(c,l)},rC=({open:t,onOpenChange:e})=>{const{t:n}=Nt(),r=!1,[o,a]=i.useState(null),[c,l]=i.useState(null),[d,u]=i.useState(!1),[m,f]=i.useState(!1),[g,b]=i.useState(null),[p,x]=i.useState(!1);i.useCallback(async()=>{},[g,d,r,n]),i.useEffect(()=>{if(!t)return;(async()=>{try{const C=await As("/api/system/info");if(C.ok){const w=await C.json();if(typeof w.openchamberVersion=="string"&&w.openchamberVersion.trim()){a(w.openchamberVersion);return}}}catch{}a(await gx())})()},[t]),i.useEffect(()=>{if(!t)return;let h=!1;return(async()=>{try{const w=await As("/api/opencode/upgrade-status",{headers:{Accept:"application/json"}});if(!w.ok)return;const S=await w.json().catch(()=>null),j=typeof S?.currentVersion=="string"?S.currentVersion.trim():"";!h&&j&&l(j)}catch{}})(),()=>{h=!0}},[t]),i.useEffect(()=>{{b(null),x(!1);return}},[t,r]);const y=o;return s.jsx($s,{open:t,onOpenChange:e,children:s.jsx(_s,{className:"max-w-xs p-6",children:s.jsxs("div",{className:"flex flex-col items-center text-center space-y-4",children:[s.jsx(Dc,{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:[y&&s.jsx("p",{children:n("aboutDialog.openChamberVersionLabel",{version:y})}),c&&s.jsx("p",{children:n("aboutDialog.openCodeVersionLabel",{version:c})})]})]}),r,s.jsxs("div",{className:"flex flex-col items-center gap-2 pt-2",children:[s.jsxs("div",{className:"flex items-center justify-center gap-4",children:[s.jsxs("a",{href:"https://github.com/btriapitsyn/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(D,{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(D,{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(D,{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")})]})})})},Ol=(t,e)=>{const n=t.get(e);return typeof n!="string"?null:n.trim()||null},iC=(t,e)=>{const n=t instanceof Error?t.message:e;return/oauth state required/i.test(n)?"Authorization session expired or was cleared during reload. Return to OpenChamber and click Authorize again.":n},oC=()=>{const t=Xx(a=>a.completeAuth),[e,n]=i.useState("working"),[r,o]=i.useState("Completing MCP authorization...");return i.useEffect(()=>{if(typeof window>"u"){n("error"),o("Browser context unavailable.");return}const a=new URLSearchParams(window.location.search),c=Ol(a,"code"),l=Zx(a),d=eb(a),u=Ol(a,"error"),m=Ol(a,"error_description");if(u){d&&As(`/api/mcp/auth/pending?state=${encodeURIComponent(d)}`,{method:"DELETE"}).catch(()=>{}),n("error"),o(m??u);return}(async()=>{try{if(!c)throw new Error("Missing OAuth authorization code. Start authorization again from MCP Settings or paste the returned code into OpenChamber manually.");let f=l;if(!f&&d){const g=await As(`/api/mcp/auth/pending?state=${encodeURIComponent(d)}`);if(g.ok){const b=await g.json().catch(()=>null);b?.name?.trim()&&(f={name:b.name.trim(),directory:typeof b.directory=="string"&&b.directory.trim()?b.directory.trim():null})}}if(!f?.name)throw new Error("Authorization session details were not available. Start authorization again from MCP Settings or paste the returned code into OpenChamber manually.");await t(f.name,c,f.directory),d&&await As(`/api/mcp/auth/pending?state=${encodeURIComponent(d)}`,{method:"DELETE"}).catch(()=>{}),n("success"),o("Authorization completed. You can close this tab and return to OpenChamber.")}catch(f){d&&await As(`/api/mcp/auth/pending?state=${encodeURIComponent(d)}`,{method:"DELETE"}).catch(()=>{}),n("error"),o(iC(f,"Failed to complete MCP authorization."))}})()},[t]),s.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background px-6 py-12 text-foreground",children:s.jsxs("div",{className:"w-full max-w-xl rounded-xl border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-8 shadow-sm",children:[s.jsxs("div",{className:"space-y-3 text-center",children:[s.jsx("div",{className:e==="error"?"text-[var(--status-error)]":e==="success"?"text-[var(--status-success)]":"text-[var(--status-info)]",children:s.jsx("h1",{className:"typography-hero font-semibold",children:e==="working"?"Completing Authorization":e==="success"?"Authorization Complete":"Authorization Failed"})}),s.jsx("p",{className:"typography-body text-muted-foreground",children:r})]}),e!=="working"&&s.jsx("div",{className:"mt-8 flex justify-center",children:s.jsx($e,{type:"button",onClick:()=>{typeof window>"u"||window.location.replace("/")},children:"Return to OpenChamber"})})]})})},Df=oo(()=>io(()=>import("./OnboardingScreen-BucKVBD7.js"),__vite__mapDeps([12,1,2,4,5,3])).then(t=>({default:t.OnboardingScreen}))),aC=()=>{const t=mt.c(3),e=Ee(mC),n=Ee(hC);let r;return t[0]!==e||t[1]!==n?(r=s.jsx(rC,{open:e,onOpenChange:n}),t[0]=e,t[1]=n,t[2]=r):r=t[2],r},lC=t=>{const e=mt.c(21),{onRetry:n,isRetrying:r}=t,{t:o}=Nt();let a;e[0]!==o?(a=o("startup.initRecovery.title"),e[0]=o,e[1]=a):a=e[1];let c;e[2]!==a?(c=s.jsx("h1",{className:"typography-title text-foreground",children:a}),e[2]=a,e[3]=c):c=e[3];let l;e[4]!==o?(l=o("startup.initRecovery.description"),e[4]=o,e[5]=l):l=e[5];let d;e[6]!==l?(d=s.jsx("p",{className:"typography-body text-muted-foreground",children:l}),e[6]=l,e[7]=d):d=e[7];let u;e[8]!==c||e[9]!==d?(u=s.jsxs("div",{className:"flex flex-col gap-2",children:[c,d]}),e[8]=c,e[9]=d,e[10]=u):u=e[10];let m;e[11]!==r||e[12]!==o?(m=o(r?"startup.initRecovery.retrying":"startup.initRecovery.retry"),e[11]=r,e[12]=o,e[13]=m):m=e[13];let f;e[14]!==r||e[15]!==n||e[16]!==m?(f=s.jsx($e,{type:"button",onClick:n,disabled:r,children:m}),e[14]=r,e[15]=n,e[16]=m,e[17]=f):f=e[17];let g;return e[18]!==u||e[19]!==f?(g=s.jsx("div",{className:"flex h-full items-center justify-center bg-background px-6 text-foreground",children:s.jsxs("div",{className:"flex max-w-md flex-col items-center gap-4 text-center",children:[u,f]})}),e[18]=u,e[19]=f,e[20]=g):g=e[20],g},If=t=>t?t.replace(/\\/g,"/").replace(/\/+$/g,""):"",cC=()=>{if(typeof window>"u")return null;const t=new URLSearchParams(window.location.search);if(t.get("ocPanel")!=="session-chat")return null;const e=t.get("sessionId"),n=typeof e=="string"?e.trim():"";if(!n)return null;const r=t.get("directory"),o=typeof r=="string"&&r.trim().length>0?r.trim():null;return{sessionId:n,directory:o,readOnly:t.get("readOnly")==="1"||t.get("readOnly")==="true"}},dC=()=>typeof window>"u"?!1:window.location.pathname===nb,uC=t=>{const e=mt.c(23),{embeddedSessionChat:n,isVSCodeRuntime:r,embeddedBackgroundWorkEnabled:o}=t,a=Js(pC),c=ut(gC),l=ut(xC),d=Pc(),u=i.useRef(null);let m;e[0]!==n.directory?(m=If(n.directory),e[0]=n.directory,e[1]=m):m=e[1];const f=m;let g;e[2]!==a?(g=If(a),e[2]=a,e[3]=g):g=e[3];const b=g;let p,x;if(e[4]!==b||e[5]!==c||e[6]!==n.directory||e[7]!==n.sessionId||e[8]!==f||e[9]!==r||e[10]!==l||e[11]!==d?(p=()=>{if(r||f&&b!==f)return;const j=`${f}
|
|
214
214
|
${n.sessionId}`;u.current===j&&c===n.sessionId||(u.current=j,l(n.sessionId,n.directory),d.ensureSessionRenderable(n.sessionId,!0))},x=[b,c,n.directory,n.sessionId,f,r,l,d],e[4]=b,e[5]=c,e[6]=n.directory,e[7]=n.sessionId,e[8]=f,e[9]=r,e[10]=l,e[11]=d,e[12]=p,e[13]=x):(p=e[12],x=e[13]),i.useEffect(p,x),f&&b!==f)return null;let y;e[14]!==o?(y=s.jsx(um,{embeddedBackgroundWorkEnabled:o}),e[14]=o,e[15]=y):y=e[15];let h;e[16]===Symbol.for("react.memo_cache_sentinel")?(h=s.jsx(jm,{}),e[16]=h):h=e[16];let C;e[17]!==n.readOnly?(C=s.jsx(Kl,{readOnly:n.readOnly}),e[17]=n.readOnly,e[18]=C):C=e[18];let w;e[19]===Symbol.for("react.memo_cache_sentinel")?(w=s.jsx(fm,{}),e[19]=w):w=e[19];let S;return e[20]!==y||e[21]!==C?(S=s.jsxs(s.Fragment,{children:[y,h,C,w]}),e[20]=y,e[21]=C,e[22]=S):S=e[22],S};function fC({apis:t}){i.useEffect(()=>{hp("App:mounted"),pp()&&console.info("[startup-trace] enabled. Run console.table(window.__OPENCHAMBER_STARTUP_TRACE__) after startup.")},[]);const e=ss(F=>F.initializeApp),n=ss(F=>F.isInitialized),r=ss(F=>F.isConnected),o=ss(F=>F.providers.length),a=ss(F=>F.agents.length),c=ss(F=>F.loadProviders),l=ss(F=>F.loadAgents),d=ut(F=>F.error),u=ut(F=>F.clearError),m=Js(F=>F.currentDirectory),f=Js(F=>F.setDirectory),g=Js(F=>F.isSwitchingDirectory),[b,p]=i.useState(!1),x=Pi(F=>F.refreshStatus),[y,h]=i.useState(()=>t.runtime.isVSCode),[C,w]=i.useState(!0),[S,j]=i.useState(!1),[k,v]=i.useState(0),[A,I]=i.useState(0),[N,O]=i.useState(!1),P=Ee(F=>F.wideChatLayoutEnabled),T=Ee(F=>F.mobileKeyboardMode),L=i.useMemo(()=>dr(),[]),R=bc(F=>F.setPlanModeEnabled),[B,V]=i.useState(()=>yd()),[_,E]=i.useState(()=>{const F=wd();return F!==null?vd({isDesktopShell:!0,bootOutcome:F}):null}),Z=i.useRef(!1),ne=i.useMemo(()=>cC(),[]),Y=!ne||C,H=i.useMemo(()=>dC(),[]);i.useEffect(()=>(jd(b),()=>{jd(!1)}),[b]),i.useEffect(()=>{gp(T)},[T]),i.useEffect(()=>{h(t.runtime.isVSCode)},[t.runtime.isVSCode]),i.useEffect(()=>Of(F=>{ut.getState().prepareForRuntimeSwitch(F.previousRuntimeKey),Ee.getState().prepareForRuntimeSwitch(F.previousRuntimeKey),F.previousRuntimeKey&&ol.getState().stopRunningRunsForRuntime(F.previousRuntimeKey),xp(),Vn.reconnectToRuntimeBaseUrl(),ss.setState({providers:[],agents:[],isConnected:!1,isInitialized:!1,connectionPhase:"connecting",lastDisconnectReason:null}),ws.getState().resetForRuntimeSwitch(),ut.getState().restoreForRuntimeSwitch(F.runtimeKey),Ee.getState().restoreForRuntimeSwitch(F.runtimeKey),xx(),I(se=>se+1),j(!1),v(se=>se+1)}),[]);const re=ol(F=>{const se=Sd();return Object.values(F.runsByOriginalSessionID).filter(ee=>ee.status==="running"&&ee.runtimeKey===se).map(ee=>`${ee.originalSessionID}:${ee.phase}:${ee.lastForwardedMessageID??""}:${ee.expectedAssistantParentID??""}`).sort().join("|")});i.useEffect(()=>{if(ne)return;const F=Sd(),se=Object.values(ol.getState().runsByOriginalSessionID).filter(ee=>ee.status==="running"&&ee.runtimeKey===F);for(const ee of se)bx(ee.originalSessionID)},[re,ne,A]),i.useEffect(()=>(document.documentElement.classList.toggle("wide-chat-layout",P),()=>{document.documentElement.classList.remove("wide-chat-layout")}),[P]),i.useEffect(()=>(Nd(t),()=>Nd(null)),[t]),i.useEffect(()=>{ne||x(t.github,{force:!0})},[t.github,ne,x]),yx();const ae=B==="valid",me=_?.screen==="main";i.useEffect(()=>{if(!bp({isDesktopShell:L,isInitialized:n,bootOutcomeKnown:ae,bootViewIsMain:me}))return;const F=setTimeout(()=>{const se=document.getElementById("initial-loading");se&&(se.classList.add("fade-out"),setTimeout(()=>{se.remove()},300))},150);return()=>clearTimeout(F)},[L,n,ae,me]),i.useEffect(()=>{if(!L||B!=="malformed")return;const F=document.getElementById("initial-loading");F&&(F.textContent="Desktop startup failed — please restart the app.")},[L,B]),i.useEffect(()=>{if(L)return;const F=setTimeout(()=>{const se=document.getElementById("initial-loading");se&&!n&&(se.classList.add("fade-out"),setTimeout(()=>{se.remove()},300))},5e3);return()=>clearTimeout(F)},[L,n]),i.useEffect(()=>{let F=!1;return(async()=>{const ee=await As("/health",{method:"GET"}).catch(()=>null);if(!ee||!ee.ok||F)return;const Ne=await ee.json().catch(()=>null);if(!Ne||F)return;const De=Ne.planModeExperimentalEnabled;R(De===!0||De===1||De==="1"||De==="true")})(),()=>{F=!0}},[R]),i.useEffect(()=>{y||e()},[e,y]),i.useEffect(()=>{if(y||n)return;let F=!0,se,ee=0;const Ne=10,De=1e3,Be=async()=>{if(!F)return;if(ee>=Ne){j(!0);return}const Fe=ss.getState();if(Fe.isInitialized){j(!1);return}ee+=1,await Fe.initializeApp();const Me=ss.getState();if(!F)return;if(Me.isInitialized){j(!1);return}if(ee>=Ne){j(!0);return}const he=Math.min(De*Math.pow(2,ee-1),16e3);se=setTimeout(Be,he)};return se=setTimeout(Be,De),()=>{F=!1,se&&clearTimeout(se)}},[k,n,y]),i.useEffect(()=>{n&&j(!1)},[n]),i.useEffect(()=>{if(!S)return;const F=document.getElementById("initial-loading");F&&(F.classList.add("fade-out"),setTimeout(()=>{F.remove()},300))},[S]),i.useEffect(()=>{if(y||!r||o>0&&a>0)return;let F=!0,se=0;const ee=15,Ne=async()=>{const Be=ss.getState();if(!(Be.providers.length>0&&Be.agents.length>0))try{Be.providers.length===0&&await c({source:"startupRecovery"}),ss.getState().agents.length===0&&await l({source:"startupRecovery"})}catch{}};Ne();const De=setInterval(()=>{if(F){if(++se>=ee){clearInterval(De);return}Ne()}},2e3);return()=>{F=!1,clearInterval(De)}},[r,y,l,c,o,a]),i.useEffect(()=>{g||y||r&&Vn.setDirectory(m)},[m,g,r,y]),i.useEffect(()=>{if(!ne||typeof window>"u")return;const F=Ne=>{const De=Ne?.visible===!0;w(De)},se=Ne=>{if(Ne.origin!==window.location.origin)return;const De=Ne.data;De?.type==="openchamber:embedded-visibility"&&F(De.payload)},ee=window;return ee.__openchamberSetEmbeddedVisibility=F,window.addEventListener("message",se),()=>{window.removeEventListener("message",se),ee.__openchamberSetEmbeddedVisibility===F&&delete ee.__openchamberSetEmbeddedVisibility}},[ne]),i.useEffect(()=>{!ne?.directory||y||m!==ne.directory&&f(ne.directory,{showOverlay:!1})},[m,ne,y,f]),i.useEffect(()=>{if(!ne||typeof window>"u")return;const F=se=>{se.storageArea===window.localStorage&&se.key==="ui-store"&&Ee.persist.rehydrate()};return window.addEventListener("storage",F),()=>{window.removeEventListener("storage",F)}},[ne]),i.useEffect(()=>{if(typeof window>"u")return;const F=se=>{const ee=se.detail,Ne=typeof ee?.sessionId=="string"?ee.sessionId.trim():"";if(!Ne)return;const De=typeof ee?.directory=="string"&&ee.directory.trim().length>0?ee.directory.trim():null;Ee.getState().setActiveMainTab("chat"),ut.getState().setCurrentSession(Ne,De)};return window.addEventListener("openchamber:open-session",F),()=>window.removeEventListener("openchamber:open-session",F)},[]),i.useEffect(()=>{if(typeof window>"u")return;const F=()=>{const se=Js.getState().currentDirectory,{activeProjectId:ee,projects:Ne}=ws.getState(),De=Ne.find(Be=>Be.id===ee)??null;Ur("desktop_open_draft_mini_chat_window",{directory:se||De?.path||"",projectId:De?.id??null})};return window.addEventListener("openchamber:open-mini-chat",F),()=>window.removeEventListener("openchamber:open-mini-chat",F)},[]),i.useEffect(()=>{if(typeof window>"u")return;const F=()=>{const se=ut.getState().currentSessionId;se&&Sx(se)};return window.addEventListener("focus",F),()=>window.removeEventListener("focus",F)},[]),i.useEffect(()=>{if(typeof window>"u")return;const F=se=>{const ee=se.detail,Ne=typeof ee?.directory=="string"&&ee.directory.trim().length>0?ee.directory.trim():null,De=typeof ee?.projectId=="string"&&ee.projectId.trim().length>0?ee.projectId.trim():null;Ee.getState().setActiveMainTab("chat"),Ee.getState().setSessionSwitcherOpen(!1),ut.getState().openNewSessionDraft({selectedProjectId:De,directoryOverride:Ne,preserveDirectoryOverride:!!Ne})};return window.addEventListener("openchamber:open-draft-session",F),()=>window.removeEventListener("openchamber:open-draft-session",F)},[]),i.useEffect(()=>{if(typeof window>"u")return;const F=se=>{const ee=se.detail,Ne=typeof ee?.projectPath=="string"?ee.projectPath.trim():"";if(!Ne)return;const De=ws.getState(),Be=De.projects.find(Fe=>Fe.path===Ne);Be?De.setActiveProject(Be.id):De.addProject(Ne)};return window.addEventListener("openchamber:open-project",F),()=>window.removeEventListener("openchamber:open-project",F)},[]),i.useEffect(()=>{typeof window>"u"||!n||g||Z.current||(Z.current=!0,window.__openchamberAppReady=!0,window.dispatchEvent(new Event("openchamber:app-ready")))},[n,g]),wx({enabled:Y}),tC({enabled:Y}),nC(),vx(),tb();const Se=i.useCallback(()=>{p(F=>!F)},[]);Bk(Se),Jk(),i.useEffect(()=>{if(ne)return;const F=se=>{yc(se)&&se.shiftKey&&!se.altKey&&(se.code==="KeyD"||se.key.toLowerCase()==="d")&&(se.preventDefault(),p(Ne=>!Ne))};return window.addEventListener("keydown",F,!0),()=>window.removeEventListener("keydown",F,!0)},[ne]),i.useEffect(()=>{ne||d&&setTimeout(()=>u(),5e3)},[u,ne,d]),i.useEffect(()=>{if(!L||B!=="not-injected")return;let F=!1,se=0;const ee=200,Ne=2e3,De=50,Be=()=>{if(F)return;se++;const Fe=yd();if(Fe!=="not-injected"){if(F=!0,V(Fe),Fe==="valid"){const he=wd();he&&E(vd({isDesktopShell:!0,bootOutcome:he}))}return}const Me=Math.min(ee*Math.pow(1.1,se),Ne);if(se>=De){const he=document.getElementById("initial-loading");he&&!he.textContent?.includes("taking longer")&&(he.textContent="Desktop startup is taking longer than expected...")}window.setTimeout(Be,Me)};return window.setTimeout(Be,ee),()=>{F=!0}},[L,B]);const te=i.useCallback(async()=>{if(yp({isDesktopShell:dr(),isDesktopLocalOriginActive:Ji()})){await wp();return}window.location.reload()},[]),ke=i.useCallback(async()=>{if(!N){j(!1),O(!0);try{await ss.getState().initializeApp()}finally{O(!1)}ss.getState().isInitialized||v(F=>F+1)}},[N]),Q=F=>{if(F.screen==="recovery")return F.variant};if(L&&_&&_.screen!=="main"){if(_.screen==="chooser")return s.jsx(Zs,{children:s.jsx("div",{className:"h-full text-foreground bg-transparent",children:s.jsx(i.Suspense,{fallback:s.jsx("div",{className:"h-full"}),children:s.jsx(Df,{mode:"first-launch",onCliAvailable:te,onChooseRemote:()=>{}})})})});const F=Q(_),se=_.screen==="recovery"&&"url"in _?_.url:void 0;return s.jsx(Zs,{children:s.jsx("div",{className:"h-full text-foreground bg-transparent",children:s.jsx(i.Suspense,{fallback:s.jsx("div",{className:"h-full"}),children:s.jsx(Df,{mode:"recovery",recoveryVariant:F,recoveryHostUrl:se,recoveryHostLabel:void 0,onCliAvailable:te})})})})}if(ne)return s.jsx(Zs,{children:s.jsx(zd,{sdk:Vn.getSdkClient(),directory:m||"",children:s.jsx(Wd,{apis:t,children:s.jsx(Ud,{delayDuration:300,skipDelayDuration:150,children:s.jsx("div",{className:"h-full text-foreground bg-background",children:s.jsx(uC,{embeddedSessionChat:ne,isVSCodeRuntime:y,embeddedBackgroundWorkEnabled:Y})})})})},A)});if(H)return s.jsx(Zs,{children:s.jsx(oC,{})});if(S&&!n&&!y&&!ne)return s.jsx(Zs,{children:s.jsx(lC,{onRetry:()=>{ke()},isRetrying:N})});const ge=!n&&!L;return s.jsx(Zs,{children:s.jsx(zd,{sdk:Vn.getSdkClient(),directory:m||"",children:s.jsx(Wd,{apis:t,children:s.jsx(Ey,{children:s.jsx(jx,{children:s.jsx(Ud,{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(um,{embeddedBackgroundWorkEnabled:Y}),s.jsx(jm,{}),s.jsx(jk,{}),s.jsx(fm,{}),!ge&&s.jsxs(s.Fragment,{children:[s.jsx(sb,{}),s.jsx(aC,{}),b&&s.jsx(kk,{onClose:()=>p(!1)})]})]})})})})})},A)})}function mC(t){return t.isAboutDialogOpen}function hC(t){return t.setAboutDialogOpen}function pC(t){return t.currentDirectory}function gC(t){return t.currentSessionId}function xC(t){return t.setCurrentSession}const bC=typeof window<"u"&&window.__OPENCHAMBER_RUNTIME_APIS__||(()=>{throw new Error("Runtime APIs not provided for legacy UI entrypoint.")})();Nx();vp().then(()=>{Promise.all([jp(),kx()]).catch(t=>{console.error("[main] settings init failed:",t)}),Cx(),Ax(),Dx()}).catch(t=>{console.error("[main] appearance init failed:",t)});const wh=document.getElementById("root");if(!wh)throw new Error("Root element not found");tp.createRoot(wh).render(s.jsx(Xe.StrictMode,{children:s.jsx(Ix,{children:s.jsx(Px,{children:s.jsx(Tx,{children:s.jsx(Rx,{children:s.jsx(fC,{apis:bC})})})})})}));const AC=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));export{d1 as D,hk as M,AC as m,Vs as u};
|