makecoder 4.0.56 → 4.0.58

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/dist/cc.mjs +2 -2
  2. package/dist/coder.js +39 -39
  3. package/dist/darwin-arm64/cc.js +2 -2
  4. package/dist/darwin-x64/cc.js +2 -2
  5. package/dist/gemini/{chunk-P6AAZN7C.js → chunk-266SNVZB.js} +1 -1
  6. package/dist/gemini/{chunk-C7WYZFGG.js → chunk-2AH4XFVC.js} +2 -2
  7. package/dist/gemini/{chunk-YHLOYN7E.js → chunk-2BCRFXVD.js} +1 -1
  8. package/dist/gemini/{chunk-GMCQZQGQ.js → chunk-2I73JSEP.js} +3 -3
  9. package/dist/gemini/{chunk-VVPG7N67.js → chunk-3AZIBTSH.js} +1 -1
  10. package/dist/gemini/{chunk-UC3K4MCZ.js → chunk-7U34TXLX.js} +1 -1
  11. package/dist/gemini/{chunk-LA23QQDZ.js → chunk-C7ISM6PN.js} +1 -1
  12. package/dist/gemini/{chunk-QQRA4YFW.js → chunk-FJ6IIWF5.js} +1 -1
  13. package/dist/gemini/{chunk-QCMDS3PD.js → chunk-JKCNEXJF.js} +3 -3
  14. package/dist/gemini/{chunk-JNCEWGIV.js → chunk-JX43KPLT.js} +1 -1
  15. package/dist/gemini/{chunk-RKJKHDZC.js → chunk-P6YMHMJL.js} +1 -1
  16. package/dist/gemini/{chunk-HCTUJMZR.js → chunk-PZSSXHHP.js} +1 -1
  17. package/dist/gemini/{chunk-YG6QM4WI.js → chunk-QTFKUXKM.js} +1 -1
  18. package/dist/gemini/{chunk-MUVQ2FAZ.js → chunk-QYJUTNIU.js} +1 -1
  19. package/dist/gemini/{chunk-ZJ2D6ILW.js → chunk-STX7FBUU.js} +1 -1
  20. package/dist/gemini/{chunk-NJ4BSMX7.js → chunk-YJXXYFOM.js} +2 -2
  21. package/dist/gemini/{cleanup-S2LRI2Y4.js → cleanup-HVASUFMM.js} +1 -1
  22. package/dist/gemini/{cleanup-ZZNAJRKJ.js → cleanup-MJ7HQT46.js} +1 -1
  23. package/dist/gemini/{core-C22BYMS6.js → core-EOYLD74V.js} +1 -1
  24. package/dist/gemini/{devtoolsService-EGQAB3JU.js → devtoolsService-B7SSRNHW.js} +2 -2
  25. package/dist/gemini/{devtoolsService-YXEESS76.js → devtoolsService-FLOV3S5Z.js} +2 -2
  26. package/dist/gemini/{dist-X3AUJEIX.js → dist-NVGK4PVU.js} +1 -1
  27. package/dist/gemini/{gemini-X6HMGNFO.js → gemini-2Z2AJTYC.js} +5 -5
  28. package/dist/gemini/{gemini-ENBHDO7W.js → gemini-DRGPGRHF.js} +5 -5
  29. package/dist/gemini/gemini.js +2 -2
  30. package/dist/gemini/{interactiveCli-SZJWTGR5.js → interactiveCli-4K2UKYKF.js} +3 -3
  31. package/dist/gemini/{interactiveCli-CI6V7WL5.js → interactiveCli-TAIO5CBT.js} +9 -9
  32. package/dist/gemini/{liteRtServerManager-J7BSXFBK.js → liteRtServerManager-TUTNSHFW.js} +1 -1
  33. package/dist/gemini/{liteRtServerManager-BDF74U3A.js → liteRtServerManager-XJXZSOE7.js} +1 -1
  34. package/dist/gemini/{oauth2-provider-P65NTFUD.js → oauth2-provider-NEH5B4N6.js} +1 -1
  35. package/dist/gemini/{oauth2-provider-3MTIBHLN.js → oauth2-provider-QU5NILIP.js} +1 -1
  36. package/dist/gemini/{start-DYZJFE46.js → start-SOY6W5ZY.js} +1 -1
  37. package/dist/gemini/{start-KAI6HBJ2.js → start-TUGBMFO3.js} +1 -1
  38. package/dist/linux-x64/cc.js +2 -2
  39. package/dist/win32-x64/cc.js +2 -2
  40. package/package.json +5 -5
  41. package/packages/mcp-channel/wecom/package-lock.json +1313 -0
  42. package/scripts/postinstall.js +12 -12
  43. package/claude/commands/dev/ultra-think.md +0 -153
  44. package/claude/commands/docs/generate-api-documentation.md +0 -80
  45. package/claude/commands/git/commit.md +0 -63
  46. package/claude/commands/git/status.md +0 -39
  47. package/claude/commands/setup/migrate-to-typescript.md +0 -76
  48. package/claude/commands/test/generate-test-cases.md +0 -76
  49. /package/{claude → packages}/mcp-channel/wecom/.mcp.json +0 -0
  50. /package/{claude → packages}/mcp-channel/wecom/package.json +0 -0
  51. /package/{claude → packages}/mcp-channel/wecom/server.js +0 -0
@@ -1,5 +1,5 @@
1
1
  const require = (await import('node:module')).createRequire(import.meta.url); const __chunk_filename = (await import('node:url')).fileURLToPath(import.meta.url); const __chunk_dirname = (await import('node:path')).dirname(__chunk_filename);
2
- import{$ as pd,$a as gC,$b as GC,Aa as Dr,Ab as wC,Ba as c,Bb as fl,Ca as oC,Cb as _C,Da as rC,Db as DC,Ea as nC,Eb as MC,Fa as Ke,Fb as Rd,G as il,Ga as gd,Gb as PC,H as OS,Ha as P,Hb as gl,I as md,Ia as iC,Ib as OC,J as Cf,Ja as me,Jb as un,K as Ec,Ka as vt,Kb as Id,L as sl,La as Ic,Lb as LC,M as aa,Ma as sC,Mb as Mo,N as LS,Na as aC,Nb as Ac,O as NS,Oa as Ze,Ob as NC,P as BS,Pa as lC,Pb as BC,Q as kS,Qa as hd,Qb as kC,R as HS,Ra as cn,Rb as ps,S as bf,Sa as yd,Sb as hl,T as FS,Ta as We,Tb as yl,U as US,Ua as cC,Ub as Ee,V as GS,Va as vf,Vb as dn,W as WS,Wa as uC,Wb as mn,X as gr,Xa as dC,Xb as HC,Y as Ef,Ya as mC,Yb as FC,Z as al,Za as pC,Zb as fs,_ as VS,_a as fC,_b as UC,aa as $S,ab as hC,ac as WC,ba as Jn,bb as yC,bc as da,ca as Rc,cb as pl,cc as vd,da as qS,db as la,dc as VC,e as wS,ea as ll,eb as TC,ec as $C,fa as cl,fb as Af,fc as pn,ga as ul,gb as xC,gc as wf,h as _S,ha as fd,hb as ca,hc as Ad,i as DS,ia as KS,ib as ua,ic as wd,j as nl,ja as jS,jb as vc,jc as qC,k as at,ka as Rf,kb as SC,kc as Pt,la as zS,lb as CC,lc as Go,ma as If,mb as Td,mc as KC,na as YS,nb as Ct,nc as _d,oa as XS,ob as bC,oc as jC,p as MS,pa as Zn,pb as EC,pc as zC,qa as QS,qb as xd,ra as u,rb as Ce,rc as Dd,sa as l,sb as RC,sc as YC,ta as JS,tb as IC,ua as ZS,ub as vC,va as eC,vb as Sd,wa as Uo,wb as Cd,xa as dl,xb as bd,y as PS,ya as tC,yb as Ed,za as ml,zb as AC}from"./chunk-QCMDS3PD.js";import{c as kt}from"./chunk-TU3BMADG.js";import{b as dd}from"./chunk-LA23QQDZ.js";import{$ as Co,A as gS,B as hS,C as yS,D as ia,E as TS,L as xS,M as SS,P as Xn,Q as ms,U as Mi,V as CS,W as sa,X as to,Y as ud,Z as Ut,_ as ln,aa as xf,b as na,ba as $r,c as nS,ca as bS,d as zn,e as Cc,f as Di,fa as ES,g as iS,ga as RS,h as yf,ha as Sf,i as sS,j as aS,ja as IS,ma as vS,o as lS,p as cS,q as Yn,r as uS,ra as Qn,s as dS,sa as AS,v as mS,w as Tf,x as bc,y as pS,z as fS}from"./chunk-UC3K4MCZ.js";import{a as eS,b as oS,c as rS,e as fr}from"./chunk-MUVQ2FAZ.js";import{a as z,b as ra,c as tS}from"./chunk-HCTUJMZR.js";import{a as ds,b as oa,h as jn,j as Zx}from"./chunk-RKJKHDZC.js";import{$c as jT,$f as dx,$l as rl,$n as zx,Ac as Ju,Ag as Tx,An as Vx,Ao as Xx,Bc as WT,Bd as cs,Bh as Ix,Bo as Qx,Cc as Zu,Cm as Nx,Cn as $x,Co as Jx,Dc as VT,Dd as JT,De as af,Eb as _i,Ef as lf,Ek as us,Fd as ZT,Ge as sx,Gk as Dx,Gn as qx,Hb as HT,Hd as ex,Ia as of,Jc as ed,Jd as tx,Je as ax,Kg as xx,Kk as id,Li as df,M as _T,Mc as $T,Mi as co,N as DT,Nd as ox,Ni as tl,Nm as Bx,O as Qa,Og as cf,Oh as _n,P as xc,Pb as rf,Pn as Kx,Qb as nf,Qg as uf,Ri as mf,Se as Js,U as tf,Vb as FT,Wa as PT,Xa as OT,Xc as qT,Y as MT,Ya as LT,Ye as lx,Yh as ea,Zc as sf,Zn as jx,_c as KT,_g as rd,_i as Ax,_l as Dn,ac as UT,ag as mx,ai as lo,ao as hf,bd as zT,cd as YT,cm as Px,dd as XT,dg as Zs,dm as Ox,eg as Za,fg as el,fm as Lx,gn as ad,hg as px,ig as fx,jh as Sx,jn as ld,kg as gx,lc as _r,le as rx,lh as Cx,lj as pf,lk as _x,ma as Yu,mh as bx,mj as wx,na as Xu,ne as nx,nh as Ex,nn as cd,oa as ie,oc as GT,of as Sc,on as kx,oo as Jo,pf as cx,ph as qe,pn as Hx,qc as as,qf as td,qn as Fx,rc as ls,rd as QT,rn as Ux,sk as nd,sn as ta,tb as NT,tf as od,ub as BT,uf as ux,ul as Mx,vg as hx,vj as qt,vn as Gx,we as ix,wi as vx,wj as ol,wn as gf,x as wT,xb as kT,xo as Yx,yc as Qu,yh as Rx,ym as ff,yn as Wx,zc as Ja,zg as yx}from"./chunk-C7WYZFGG.js";import{$a as Jp,$d as IT,Ab as mT,Bc as Ku,D as Ve,K as wi,Kd as ef,L as Qy,La as lT,Le as sd,M as Jy,Na as cT,Pa as uT,S as Zy,Sa as Xa,Sc as ju,Sd as yT,T as eT,Tc as zu,Td as TT,U as Xp,Uc as fT,Ud as xT,V as tT,Vc as gT,W as oT,Wc as hT,Wd as ST,X as Uu,Xd as CT,Y as je,Yd as bT,Z as an,Zd as ET,_a as Qp,_d as RT,aa as rT,ab as Zp,ac as pT,ae as vT,b as de,bb as fc,c as Yy,cb as gc,da as nT,db as hc,eb as ss,fa as iT,fb as yc,ga as sT,gb as Wu,hb as Vu,ia as aT,ib as dT,j as Xy,jb as $u,kb as Tc,ne as AT,re as Ge,t as Qo,tb as Bt,te as Se,va as Gu,vb as qu,xa as Vr}from"./chunk-CPZLOVAV.js";import"./chunk-TWIC4BKL.js";import"./chunk-JAFVB6DI.js";import"./chunk-A5A5SUZN.js";import{a as _t,c as Dt,d as dD,e as C}from"./chunk-YUXORC52.js";var cE=Dt((sF,lE)=>{"use strict";var KD="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";lE.exports=KD});var pE=Dt((aF,mE)=>{"use strict";var jD=cE();function uE(){}function dE(){}dE.resetWarningCache=uE;mE.exports=function(){function e(r,n,s,i,a,d){if(d!==jD){var m=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw m.name="Invariant Violation",m}}e.isRequired=e;function t(){return e}var o={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:dE,resetWarningCache:uE};return o.PropTypes=o,o}});var gE=Dt((uF,fE)=>{fE.exports=pE()();var lF,cF});var SE=Dt((dF,Qd)=>{"use strict";var yE=dd(),zD=fS(),hE=/\s/g;function $f(...e){let t=zD.apply(this,e),o=(r,n)=>YD(r?r.toString():"",t,n);return o.multiline=(r,n)=>XD(r?r.toString():"",t,n),o}var TE=(e,t,o)=>t.interpolation.toLowerCase()==="hsv"?e.hsv(o,t.hsvSpin.toLowerCase()):e.rgb(o);function YD(e,t,o){let r=xE(o),n=Math.max(e.replace(hE,"").length,t.stops.length),s=TE(t,r,n),i="";for(let a of e)i+=a.match(hE)?a:yE.hex(s.shift().toHex())(a);return i}function XD(e,t,o){let r=xE(o),n=e.split(`
2
+ import{$ as pd,$a as gC,$b as GC,Aa as Dr,Ab as wC,Ba as c,Bb as fl,Ca as oC,Cb as _C,Da as rC,Db as DC,Ea as nC,Eb as MC,Fa as Ke,Fb as Rd,G as il,Ga as gd,Gb as PC,H as OS,Ha as P,Hb as gl,I as md,Ia as iC,Ib as OC,J as Cf,Ja as me,Jb as un,K as Ec,Ka as vt,Kb as Id,L as sl,La as Ic,Lb as LC,M as aa,Ma as sC,Mb as Mo,N as LS,Na as aC,Nb as Ac,O as NS,Oa as Ze,Ob as NC,P as BS,Pa as lC,Pb as BC,Q as kS,Qa as hd,Qb as kC,R as HS,Ra as cn,Rb as ps,S as bf,Sa as yd,Sb as hl,T as FS,Ta as We,Tb as yl,U as US,Ua as cC,Ub as Ee,V as GS,Va as vf,Vb as dn,W as WS,Wa as uC,Wb as mn,X as gr,Xa as dC,Xb as HC,Y as Ef,Ya as mC,Yb as FC,Z as al,Za as pC,Zb as fs,_ as VS,_a as fC,_b as UC,aa as $S,ab as hC,ac as WC,ba as Jn,bb as yC,bc as da,ca as Rc,cb as pl,cc as vd,da as qS,db as la,dc as VC,e as wS,ea as ll,eb as TC,ec as $C,fa as cl,fb as Af,fc as pn,ga as ul,gb as xC,gc as wf,h as _S,ha as fd,hb as ca,hc as Ad,i as DS,ia as KS,ib as ua,ic as wd,j as nl,ja as jS,jb as vc,jc as qC,k as at,ka as Rf,kb as SC,kc as Pt,la as zS,lb as CC,lc as Go,ma as If,mb as Td,mc as KC,na as YS,nb as Ct,nc as _d,oa as XS,ob as bC,oc as jC,p as MS,pa as Zn,pb as EC,pc as zC,qa as QS,qb as xd,ra as u,rb as Ce,rc as Dd,sa as l,sb as RC,sc as YC,ta as JS,tb as IC,ua as ZS,ub as vC,va as eC,vb as Sd,wa as Uo,wb as Cd,xa as dl,xb as bd,y as PS,ya as tC,yb as Ed,za as ml,zb as AC}from"./chunk-JKCNEXJF.js";import{c as kt}from"./chunk-TU3BMADG.js";import{b as dd}from"./chunk-STX7FBUU.js";import{$ as Co,A as gS,B as hS,C as yS,D as ia,E as TS,L as xS,M as SS,P as Xn,Q as ms,U as Mi,V as CS,W as sa,X as to,Y as ud,Z as Ut,_ as ln,aa as xf,b as na,ba as $r,c as nS,ca as bS,d as zn,e as Cc,f as Di,fa as ES,g as iS,ga as RS,h as yf,ha as Sf,i as sS,j as aS,ja as IS,ma as vS,o as lS,p as cS,q as Yn,r as uS,ra as Qn,s as dS,sa as AS,v as mS,w as Tf,x as bc,y as pS,z as fS}from"./chunk-7U34TXLX.js";import{a as eS,b as oS,c as rS,e as fr}from"./chunk-QYJUTNIU.js";import{a as z,b as ra,c as tS}from"./chunk-PZSSXHHP.js";import{a as ds,b as oa,h as jn,j as Zx}from"./chunk-P6YMHMJL.js";import{$c as jT,$f as dx,$l as rl,$n as zx,Ac as Ju,Ag as Tx,An as Vx,Ao as Xx,Bc as WT,Bd as cs,Bh as Ix,Bo as Qx,Cc as Zu,Cm as Nx,Cn as $x,Co as Jx,Dc as VT,Dd as JT,De as af,Eb as _i,Ef as lf,Ek as us,Fd as ZT,Ge as sx,Gk as Dx,Gn as qx,Hb as HT,Hd as ex,Ia as of,Jc as ed,Jd as tx,Je as ax,Kg as xx,Kk as id,Li as df,M as _T,Mc as $T,Mi as co,N as DT,Nd as ox,Ni as tl,Nm as Bx,O as Qa,Og as cf,Oh as _n,P as xc,Pb as rf,Pn as Kx,Qb as nf,Qg as uf,Ri as mf,Se as Js,U as tf,Vb as FT,Wa as PT,Xa as OT,Xc as qT,Y as MT,Ya as LT,Ye as lx,Yh as ea,Zc as sf,Zn as jx,_c as KT,_g as rd,_i as Ax,_l as Dn,ac as UT,ag as mx,ai as lo,ao as hf,bd as zT,cd as YT,cm as Px,dd as XT,dg as Zs,dm as Ox,eg as Za,fg as el,fm as Lx,gn as ad,hg as px,ig as fx,jh as Sx,jn as ld,kg as gx,lc as _r,le as rx,lh as Cx,lj as pf,lk as _x,ma as Yu,mh as bx,mj as wx,na as Xu,ne as nx,nh as Ex,nn as cd,oa as ie,oc as GT,of as Sc,on as kx,oo as Jo,pf as cx,ph as $e,pn as Hx,qc as as,qf as td,qn as Fx,rc as ls,rd as QT,rn as Ux,sk as nd,sn as ta,tb as NT,tf as od,ub as BT,uf as ux,ul as Mx,vg as hx,vj as qt,vn as Gx,we as ix,wi as vx,wj as ol,wn as gf,x as wT,xb as kT,xo as Yx,yc as Qu,yh as Rx,ym as ff,yn as Wx,zc as Ja,zg as yx}from"./chunk-2AH4XFVC.js";import{$a as Jp,$d as IT,Ab as mT,Bc as Ku,D as Ve,K as wi,Kd as ef,L as Qy,La as lT,Le as sd,M as Jy,Na as cT,Pa as uT,S as Zy,Sa as Xa,Sc as ju,Sd as yT,T as eT,Tc as zu,Td as TT,U as Xp,Uc as fT,Ud as xT,V as tT,Vc as gT,W as oT,Wc as hT,Wd as ST,X as Uu,Xd as CT,Y as je,Yd as bT,Z as an,Zd as ET,_a as Qp,_d as RT,aa as rT,ab as Zp,ac as pT,ae as vT,b as de,bb as fc,c as Yy,cb as gc,da as nT,db as hc,eb as ss,fa as iT,fb as yc,ga as sT,gb as Wu,hb as Vu,ia as aT,ib as dT,j as Xy,jb as $u,kb as Tc,ne as AT,re as Ge,t as Qo,tb as Bt,te as Se,va as Gu,vb as qu,xa as Vr}from"./chunk-CPZLOVAV.js";import"./chunk-TWIC4BKL.js";import"./chunk-JAFVB6DI.js";import"./chunk-A5A5SUZN.js";import{a as _t,c as Dt,d as dD,e as C}from"./chunk-YUXORC52.js";var cE=Dt((sF,lE)=>{"use strict";var KD="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";lE.exports=KD});var pE=Dt((aF,mE)=>{"use strict";var jD=cE();function uE(){}function dE(){}dE.resetWarningCache=uE;mE.exports=function(){function e(r,n,s,i,a,d){if(d!==jD){var m=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw m.name="Invariant Violation",m}}e.isRequired=e;function t(){return e}var o={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:dE,resetWarningCache:uE};return o.PropTypes=o,o}});var gE=Dt((uF,fE)=>{fE.exports=pE()();var lF,cF});var SE=Dt((dF,Qd)=>{"use strict";var yE=dd(),zD=fS(),hE=/\s/g;function $f(...e){let t=zD.apply(this,e),o=(r,n)=>YD(r?r.toString():"",t,n);return o.multiline=(r,n)=>XD(r?r.toString():"",t,n),o}var TE=(e,t,o)=>t.interpolation.toLowerCase()==="hsv"?e.hsv(o,t.hsvSpin.toLowerCase()):e.rgb(o);function YD(e,t,o){let r=xE(o),n=Math.max(e.replace(hE,"").length,t.stops.length),s=TE(t,r,n),i="";for(let a of e)i+=a.match(hE)?a:yE.hex(s.shift().toHex())(a);return i}function XD(e,t,o){let r=xE(o),n=e.split(`
3
3
  `),s=Math.max.apply(null,n.map(d=>d.length).concat([t.stops.length])),i=TE(t,r,s),a=[];for(let d of n){let m=i.slice(0),f="";for(let h of d)f+=yE.hex(m.shift().toHex())(h);a.push(f)}return a.join(`
4
4
  `)}function xE(e){let t={interpolation:"rgb",hsvSpin:"short",...e};if(e!==void 0&&typeof e!="object")throw new TypeError(`Expected \`options\` to be an \`object\`, got \`${typeof e}\``);if(typeof t.interpolation!="string")throw new TypeError(`Expected \`options.interpolation\` to be a \`string\`, got \`${typeof t.interpolation}\``);if(t.interpolation.toLowerCase()==="hsv"&&typeof t.hsvSpin!="string")throw new TypeError(`Expected \`options.hsvSpin\` to be a \`string\`, got \`${typeof t.hsvSpin}\``);return t}var Nc={atlas:{colors:["#feac5e","#c779d0","#4bc0c8"],options:{}},cristal:{colors:["#bdfff3","#4ac29a"],options:{}},teen:{colors:["#77a1d3","#79cbca","#e684ae"],options:{}},mind:{colors:["#473b7b","#3584a7","#30d2be"],options:{}},morning:{colors:["#ff5f6d","#ffc371"],options:{interpolation:"hsv"}},vice:{colors:["#5ee7df","#b490ca"],options:{interpolation:"hsv"}},passion:{colors:["#f43b47","#453a94"],options:{}},fruit:{colors:["#ff4e50","#f9d423"],options:{}},instagram:{colors:["#833ab4","#fd1d1d","#fcb045"],options:{}},retro:{colors:["#3f51b1","#5a55ae","#7b5fac","#8f6aae","#a86aa4","#cc6b8e","#f18271","#f3a469","#f7c978"],options:{}},summer:{colors:["#fdbb2d","#22c1c3"],options:{}},rainbow:{colors:["#ff0000","#ff0100"],options:{interpolation:"hsv",hsvSpin:"long"}},pastel:{colors:["#74ebd5","#74ecd5"],options:{interpolation:"hsv",hsvSpin:"long"}}};Qd.exports=$f;for(let e in Nc)Qd.exports[e]=t=>new $f(Nc[e].colors)(t,Nc[e].options),Qd.exports[e].multiline=t=>new $f(Nc[e].colors).multiline(t,Nc[e].options)});var Gg=Dt(Na=>{Na.parse=Na.decode=IL;Na.stringify=Na.encode=BA;Na.safe=jl;Na.unsafe=ap;var Ug=typeof process<"u"&&process.platform==="win32"?`\r
5
5
  `:`
@@ -26,7 +26,7 @@ GFS4: `),console.error(e)});Yt[Ko]||(mw=global[Ko]||[],fw(Yt,mw),Yt.close=functi
26
26
  `:"")}}return{truncatedData:m,hiddenLinesCount:a}}if(Array.isArray(e)&&!o&&t!==void 0&&e.length>t){let m=Math.max(1,t-1),f=e.length-m;return{truncatedData:d==="bottom"?e.slice(0,m):e.slice(-m),hiddenLinesCount:f}}return{truncatedData:e,hiddenLinesCount:0}},[e,o,t,n.overflowDirection]);return(0,wb.jsx)(dn,{...n,additionalHiddenLinesCount:(n.additionalHiddenLinesCount??0)+i,children:r(s)})}function PD(e){if(e==null)return!1;let t=e.trim();return!(!t||!/^(?:\[|\{)/.test(t)||_n(t)!==t)}function _b(e){if(!PD(e))return null;let t=e.trim();try{let o=JSON.parse(t);return o===null||typeof o!="object"||Array.isArray(o)&&o.length===0||!Array.isArray(o)&&Object.keys(o).length===0?null:o}catch{return null}}var Mt=C(z(),1);var Lf=C(P(),1);var Od=({children:e,width:t,height:o,maxWidth:r,maxHeight:n,hasFocus:s,scrollToBottom:i,flexGrow:a,reportOverflow:d=!1,overflowToBackbuffer:m,scrollbar:f=!0,stableScrollback:h})=>{let p=Ze(),[y,g]=(0,Mt.useState)(0),x=(0,Mt.useRef)(null),S=(0,Mt.useRef)(null),I=ps(),A=(0,Mt.useId)(),[E,T]=(0,Mt.useState)({innerHeight:typeof o=="number"?o:0,scrollHeight:0}),v=(0,Mt.useRef)(E),R=(0,Mt.useRef)(y);(0,Mt.useLayoutEffect)(()=>{v.current=E},[E]),(0,Mt.useLayoutEffect)(()=>{R.current=y},[y]),(0,Mt.useEffect)(()=>{d&&E.scrollHeight>E.innerHeight?I?.addOverflowingId?.(A):I?.removeOverflowingId?.(A)},[d,E.scrollHeight,E.innerHeight,A,I]),(0,Mt.useEffect)(()=>()=>{I?.removeOverflowingId?.(A)},[A,I]);let b=(0,Mt.useRef)(null),_=(0,Mt.useRef)(null);(0,Mt.useEffect)(()=>()=>{b.current?.disconnect(),_.current?.disconnect()},[]);let w=(0,Mt.useCallback)(q=>{if(b.current?.disconnect(),x.current=q,q){let Z=new Zn(Y=>{let oe=Y[0];if(oe){let ce=Math.round(oe.contentRect.height);T(G=>{let ee=G.scrollHeight;return ee>G.innerHeight&&R.current>=ee-G.innerHeight-1&&g(Number.MAX_SAFE_INTEGER),{...G,innerHeight:ce}})}});Z.observe(q),b.current=Z}},[]),M=(0,Mt.useCallback)(q=>{if(_.current?.disconnect(),S.current=q,q){let Z=new Zn(Y=>{let oe=Y[0];if(oe){let ce=Math.round(oe.contentRect.height);T(G=>{let ee=G.innerHeight;return(G.scrollHeight>ee&&R.current>=G.scrollHeight-ee-1||i&&ce>G.scrollHeight)&&g(Number.MAX_SAFE_INTEGER),{...G,scrollHeight:ce}})}});Z.observe(q),_.current=Z}},[i]),{getScrollTop:D,setPendingScrollTop:N}=WC(y),O=(0,Mt.useCallback)(q=>{let{scrollHeight:Z,innerHeight:Y}=v.current,oe=Math.max(0,Z-Y),ce=Math.min(D(),oe),G=Math.max(0,ce+q);G>=oe&&(G=Number.MAX_SAFE_INTEGER),N(G),g(G)},[D,N]),{scrollbarColor:W,flashScrollbar:L,scrollByWithAnimation:k}=$C(s,O);me(q=>{let{scrollHeight:Z,innerHeight:Y}=v.current,oe=D(),ce=Math.max(0,Z-Y),G=Math.min(oe,ce);if(G>0){if(p["scroll.pageUp"](q))return k(-Y),!0;if(p["scroll.up"](q))return k(-1),!0}if(G<ce){if(p["scroll.pageDown"](q))return k(Y),!0;if(p["scroll.down"](q))return k(1),!0}return!1},{isActive:s});let F=(0,Mt.useCallback)(()=>{let q=Math.max(0,E.scrollHeight-E.innerHeight);return{scrollTop:Math.min(D(),q),scrollHeight:E.scrollHeight,innerHeight:E.innerHeight}},[D,E.scrollHeight,E.innerHeight]),B=(0,Mt.useCallback)(()=>s,[s]),K=(0,Mt.useMemo)(()=>({ref:x,getScrollState:F,scrollBy:k,hasFocus:B,flashScrollbar:L}),[F,k,B,L]);return VC(K,!0),(0,Lf.jsx)(u,{ref:w,maxHeight:n,width:t??r,height:o,flexDirection:"column",overflowY:"scroll",overflowX:"hidden",scrollTop:y,flexGrow:a,scrollbarThumbColor:W,overflowToBackbuffer:m,scrollbar:f,stableScrollback:h,children:(0,Lf.jsx)(u,{ref:M,flexShrink:0,paddingRight:1,flexDirection:"column",children:e})})};var Ld=1,OD=6,Dc=4,LD=2,_c=Ld+Dc;function Nd(e){let{availableTerminalHeight:t,isAlternateBuffer:o,maxLinesLimit:r}=e,n=o?OD:Dc,s=t!==void 0?Math.max(t-Ld-n,LD+1):void 0;return r!==void 0&&(s=s!==void 0?Math.min(s,r):r),s}function Db(e){let{status:t,isAlternateBuffer:o,isThisShellFocused:r,availableTerminalHeight:n,constrainHeight:s,isExpandable:i}=e;if(!s&&i)return;if(n===void 0)return o?Yn-_c:void 0;let a=Math.max(1,n-Dc);if(o&&r&&!s)return a;let m=t===ie.Executing?Yn-_c:uS-_c;return Math.min(a,m)}var Rl=C(z(),1);var Bd=C(z(),1);var El=(e,t,o=5e3)=>{let[r,n]=(0,Bd.useState)(!1);return(0,Bd.useEffect)(()=>{if(!e){n(!1);return}n(!1);let s=setTimeout(()=>{n(!0)},o);return()=>clearTimeout(s)},[e,t,o]),r};var Ht=C(P(),1);var Il=3;function Zo(e){let t=e.toLowerCase();return e===na||e===nS||e===pT||t==="shell"}function Hd(e,t,o){return!!(Zo(e)&&t===ie.Executing&&o?.getEnableInteractiveShell())}function Fd(e,t,o,r,n){return!!(Zo(e)&&t===ie.Executing&&o===r&&n)}function Ud(e,t,o){let[r,n]=(0,Rl.useState)(!1),s=typeof o=="string"||Array.isArray(o)?o.length:!!o,i=El(e,s,5e3);return(0,Rl.useEffect)(()=>{t&&n(!0)},[t]),{shouldShowFocusHint:e&&(i||r)}}var Gd=({shouldShowFocusHint:e,isThisShellFocused:t})=>e?(0,Ht.jsx)(u,{marginLeft:1,flexShrink:0,children:(0,Ht.jsx)(l,{color:t?c.ui.focus:c.ui.active,children:t?`(${Ee("app.unfocusShellInput")} to unfocus)`:`(${Ee("app.focusShellInput")} to focus)`})}):null,Mr=({status:e,name:t,isFocused:o})=>{let r=ra(e),n=Zo(t),s=o?c.ui.focus:n?c.ui.active:c.status.warning;return(0,Ht.jsxs)(u,{minWidth:Il,children:[r==="Pending"&&(0,Ht.jsx)(l,{color:c.status.success,children:zn.PENDING}),r==="Executing"&&(0,Ht.jsx)(l,{color:s,children:(0,Ht.jsx)(Mo,{type:"toggle"})}),r==="Success"&&(0,Ht.jsx)(l,{color:c.status.success,"aria-label":"Success:",children:zn.SUCCESS}),r==="Confirming"&&(0,Ht.jsx)(l,{color:s,"aria-label":"Confirming:",children:zn.CONFIRMING}),r==="Canceled"&&(0,Ht.jsx)(l,{color:s,"aria-label":"Canceled:",bold:!0,children:zn.CANCELED}),r==="Error"&&(0,Ht.jsx)(l,{color:c.status.error,"aria-label":"Error:",bold:!0,children:zn.ERROR})]})},xs=({name:e,description:t,status:o,emphasis:r,progressMessage:n,originalRequestName:s,isExpanded:i=!1})=>{let a=ra(o),d=Rl.default.useMemo(()=>{switch(r){case"high":return c.text.primary;case"medium":return c.text.primary;case"low":return c.text.secondary;default:return r}},[r]),m=vx(e,a);return(0,Ht.jsx)(u,{overflow:"hidden",height:i?void 0:1,flexGrow:1,flexShrink:1,children:(0,Ht.jsxs)(l,{strikethrough:a==="Canceled",wrap:i?"wrap":"truncate",children:[(0,Ht.jsx)(l,{color:d,bold:!0,children:e}),s&&s!==e&&(0,Ht.jsxs)(l,{color:c.text.secondary,italic:!0,children:[" ","(redirection from ",s,")"]}),!m&&(0,Ht.jsxs)(Ht.Fragment,{children:[" ",(0,Ht.jsx)(l,{color:c.text.secondary,children:t})]})]})})},Pb=({progress:e,total:t,message:o,barWidth:r})=>{let n=t&&t>0?Math.min(100,Math.round(e/t*100)):null,s;t&&t>0?s=Math.round(e/t*r):s=Math.floor(e)%(r+1);let i=Math.max(0,Math.min(Number.isFinite(s)?s:0,r)),a=Math.max(0,r-i),d="\u2588".repeat(i)+"\u2591".repeat(a);return(0,Ht.jsxs)(u,{flexDirection:"column",children:[(0,Ht.jsx)(u,{children:(0,Ht.jsxs)(l,{color:c.text.accent,children:[d," ",n!==null?`${n}%`:`${e}`]})}),o&&(0,Ht.jsx)(l,{color:c.text.secondary,wrap:"truncate",children:o})]})},Wd=()=>(0,Ht.jsxs)(l,{color:c.text.primary,wrap:"truncate",children:[" ","\u2190"]});var Ft=C(P(),1);var Nf=e=>{if(!e)return"";try{let t=JSON.parse(e);return typeof t!="object"||t===null?e:"description"in t&&typeof t.description=="string"&&t.description?t.description:"command"in t&&typeof t.command=="string"?t.command:"file_path"in t&&typeof t.file_path=="string"?t.file_path:"dir_path"in t&&typeof t.dir_path=="string"?t.dir_path:"query"in t&&typeof t.query=="string"?t.query:"url"in t&&typeof t.url=="string"?t.url:"target"in t&&typeof t.target=="string"?t.target:e}catch{return e}},Vd=({progress:e,terminalWidth:t,historyOverrides:o})=>{let r,n=c.text.secondary;return e.state===qt.CANCELLED?(r=`Subagent ${e.agentName} was cancelled.`,n=c.status.warning):e.state===qt.ERROR?(r=`Subagent ${e.agentName} failed.`,n=c.status.error):e.state===qt.COMPLETED?(r=`Subagent ${e.agentName} completed.`,n=c.status.success):(r=`Running subagent ${e.agentName}...`,n=c.text.primary),(0,Ft.jsxs)(u,{flexDirection:"column",paddingY:0,children:[r&&(0,Ft.jsx)(u,{marginBottom:1,children:(0,Ft.jsx)(l,{color:n,italic:!0,children:r})}),(0,Ft.jsx)(u,{flexDirection:"column",marginLeft:0,gap:0,children:(o??e.recentActivity).map(s=>{if(s.type==="thought"){let i=s.content==="Request cancelled.",a=i?"\u2139 ":"\u{1F4AD}",d=i?c.status.warning:c.text.secondary;return(0,Ft.jsxs)(u,{flexDirection:"row",children:[(0,Ft.jsx)(u,{minWidth:Il,children:(0,Ft.jsx)(l,{color:d,children:a})}),(0,Ft.jsx)(u,{flexGrow:1,children:(0,Ft.jsx)(l,{color:d,children:s.content})})]},s.id)}else if(s.type==="tool_call"){let i=s.status===qt.RUNNING?(0,Ft.jsx)(LC,{type:"dots"}):s.status===qt.COMPLETED?(0,Ft.jsx)(l,{color:c.status.success,children:zn.SUCCESS}):s.status===qt.CANCELLED?(0,Ft.jsx)(l,{color:c.status.warning,bold:!0,children:zn.CANCELED}):(0,Ft.jsx)(l,{color:c.status.error,children:zn.ERROR}),a=s.description||Nf(s.args),d=a.length>60?a.slice(0,60)+"...":a;return(0,Ft.jsxs)(u,{flexDirection:"row",children:[(0,Ft.jsx)(u,{minWidth:Il,children:i}),(0,Ft.jsxs)(u,{flexDirection:"row",flexGrow:1,flexWrap:"wrap",children:[(0,Ft.jsx)(l,{bold:!0,color:c.text.primary,strikethrough:s.status===qt.CANCELLED,children:s.displayName||s.content}),d&&(0,Ft.jsx)(u,{marginLeft:1,children:(0,Ft.jsx)(l,{color:c.text.secondary,wrap:"truncate",strikethrough:s.status===qt.CANCELLED,children:d})})]})]},s.id)}return null})}),e.result&&(0,Ft.jsxs)(u,{flexDirection:"column",marginTop:1,children:[e.terminateReason&&e.terminateReason!=="GOAL"&&(0,Ft.jsx)(u,{marginBottom:1,children:(0,Ft.jsxs)(l,{color:c.status.warning,bold:!0,children:["Agent Finished Early (",e.terminateReason,")"]})}),(0,Ft.jsx)(Oo,{text:Xy(e.result),isPending:e.state!==qt.COMPLETED,terminalWidth:t})]})]})};var Jt=C(P(),1);var $d=({resultDisplay:e,availableTerminalHeight:t,terminalWidth:o,renderOutputAsMarkdown:r=!0,maxLines:n,hasFocus:s=!1,overflowDirection:i="top"})=>{let{renderMarkdown:a,constrainHeight:d}=Ce(),m=Pt(),f=Nd({availableTerminalHeight:t,isAlternateBuffer:m,maxLinesLimit:n}),p=o-4,y=Bf.default.useCallback((S,I)=>I.toString(),[]),g=Bf.default.useCallback(({item:S})=>(0,Jt.jsx)(u,{height:1,overflow:"hidden",children:(0,Jt.jsx)(Pd,{line:S})}),[]);if(!e||typeof e=="object"&&"todos"in e)return null;let x=S=>{let I=typeof S=="string"?_b(S):null,A=I?JSON.stringify(I,null,2):null,E;return A?E=(0,Jt.jsx)(l,{wrap:"wrap",color:c.text.primary,children:A}):ol(S)?E=(0,Jt.jsx)(Vd,{progress:S,terminalWidth:p}):typeof S=="string"&&r?E=(0,Jt.jsx)(Oo,{text:S,terminalWidth:p,renderMarkdown:a,isPending:!1}):typeof S=="string"&&!r?E=(0,Jt.jsx)(l,{wrap:"wrap",color:c.text.primary,children:S}):Zy(S)?r?E=(0,Jt.jsx)(Oo,{text:S.summary,terminalWidth:p,renderMarkdown:a,isPending:!1}):E=(0,Jt.jsx)(l,{wrap:"wrap",color:c.text.primary,children:S.summary}):typeof S=="object"&&S!==null&&"fileDiff"in S?E=(0,Jt.jsx)(fs,{diffContent:S.fileDiff,filename:S.fileName,availableTerminalHeight:f,terminalWidth:p}):Array.isArray(S)?E=(0,Jt.jsx)(Ib,{data:S,availableTerminalHeight:m?void 0:f,width:p,maxLines:m?void 0:n,disableTruncation:m||t===void 0&&n===void 0}):typeof S=="object"&&S!==null?E=(0,Jt.jsx)(l,{wrap:"wrap",color:c.text.primary,children:JSON.stringify(S,null,2)}):E=null,m?(0,Jt.jsx)(Od,{width:p,maxHeight:n??f,hasFocus:s,scrollToBottom:!0,reportOverflow:!0,children:E}):E};if(Array.isArray(e)){let S=n??f??Yn,I=e,A=d?Math.min(I.length,S):I.length;if(m)return(0,Jt.jsx)(u,{width:p,flexDirection:"column",maxHeight:A,children:(0,Jt.jsx)(pn,{width:p,containerHeight:A,data:I,renderItem:g,estimatedItemHeight:()=>1,fixedItemHeight:!0,keyExtractor:y,initialScrollIndex:i==="bottom"?0:da,hasFocus:s})});{let E=I,T=0;return d&&I.length>A&&(T=I.length-A,i==="top"?E=I.slice(T):E=I.slice(0,A)),(0,Jt.jsx)(u,{width:p,flexDirection:"column",children:(0,Jt.jsx)(dn,{maxHeight:d?A:void 0,maxWidth:p,overflowDirection:i,additionalHiddenLinesCount:T,children:E.map((v,R)=>{let b=(i==="top"?T:0)+R;return(0,Jt.jsx)(u,{height:1,overflow:"hidden",children:(0,Jt.jsx)(Pd,{line:v})},y(v,b))})})})}}return m?(0,Jt.jsx)(u,{width:p,flexDirection:"column",children:x(e)}):(0,Jt.jsx)(u,{width:p,flexDirection:"column",children:(0,Jt.jsx)(Ab,{data:e,maxLines:n,isAlternateBuffer:m,maxHeight:f,maxWidth:p,overflowDirection:i,children:S=>x(S)})})};var kf=C(z(),1);var Ob={up:"\x1B[A",down:"\x1B[B",right:"\x1B[C",left:"\x1B[D",escape:"\x1B",tab:" ",backspace:"\x7F",delete:"\x1B[3~",home:"\x1B[H",end:"\x1B[F",pageup:"\x1B[5~",pagedown:"\x1B[6~",enter:"\r"};function Lb(e){return e.ctrl&&e.name>="a"&&e.name<="z"?String.fromCharCode(e.name.charCodeAt(0)-97+1):e.name in Ob?Ob[e.name]:!e.ctrl&&!e.cmd&&e.sequence?e.sequence:null}var qd=({activeShellPtyId:e,focus:t=!0,scrollPageSize:o=Yn})=>{let r=Ze(),n=(0,kf.useCallback)(i=>{e&&lo.writeToPty(e,i)},[e]),s=(0,kf.useCallback)(i=>{if(!t||!e||r["background.toggle"](i)||r["app.unfocusShellInput"](i))return!1;if(r["scroll.up"](i))return lo.scrollPty(e,-1),!0;if(r["scroll.down"](i))return lo.scrollPty(e,1),!0;if(r["scroll.pageUp"](i))return lo.scrollPty(e,-o),!0;if(r["scroll.pageDown"](i))return lo.scrollPty(e,o),!0;let a=Lb(i);return a?(n(a),!0):!1},[t,n,e,o,r]);return me(s,{isActive:t}),null};var fn=C(z(),1);var kb=C(P(),1);function ND(e){return!!e&&"onConfirm"in e&&typeof e.onConfirm=="function"}var Nb=(0,fn.createContext)(null),oi=()=>{let e=(0,fn.useContext)(Nb);if(!e)throw new Error("useToolActions must be used within a ToolActionsProvider");return e},Bb=e=>{let{children:t,config:o,toolCalls:r,isExpanded:n,toggleExpansion:s,toggleAllExpansion:i}=e,[a,d]=(0,fn.useState)(null),[m,f]=(0,fn.useState)(!1);(0,fn.useEffect)(()=>{let y=!0,g=null,x=()=>{y&&g&&f(g.isDiffingEnabled())};return o.getIdeMode()&&Zs.getInstance().then(S=>{y&&(g=S,d(S),f(S.isDiffingEnabled()),S.addStatusChangeListener(x))}).catch(S=>{de.error("Failed to get IdeClient instance:",S)}),()=>{y=!1,g&&g.removeStatusChangeListener(x)}},[o]);let h=(0,fn.useCallback)(async(y,g,x)=>{let S=r.find(A=>A.callId===y);if(!S){de.warn(`ToolActions: Tool ${y} not found`);return}let I=S.confirmationDetails;if(I?.type==="edit"&&m&&"filePath"in I){let A=g===je.Cancel?"rejected":"accepted";await a?.resolveDiffFromCli(I.filePath,A)}if(S.correlationId){await o.getMessageBus().publish({type:wi.TOOL_CONFIRMATION_RESPONSE,correlationId:S.correlationId,confirmed:g!==je.Cancel,requiresUserConfirmation:!1,outcome:g,payload:x});return}if(ND(I)){await I.onConfirm(g,x);return}de.warn(`ToolActions: No correlationId or callback for ${y}`)},[o,a,r,m]),p=(0,fn.useCallback)(async y=>{await h(y,je.Cancel)},[h]);return(0,kb.jsx)(Nb.Provider,{value:{confirm:h,cancel:p,isDiffingEnabled:m,isExpanded:n,toggleExpansion:s,toggleAllExpansion:i},children:t})};var Tr=C(P(),1);var Hb=({callId:e,name:t,description:o,resultDisplay:r,status:n,kind:s,availableTerminalHeight:i,terminalWidth:a,emphasis:d="medium",renderOutputAsMarkdown:m=!0,isFirst:f,borderColor:h,borderDimColor:p,activeShellPtyId:y,embeddedShellFocused:g,ptyId:x,config:S,progressMessage:I,originalRequestName:A,progress:E,progressTotal:T})=>{let{isExpanded:v}=oi(),R=(v?v(e):!1)||i===void 0,b=Fd(t,n,x,y,g),_=Hd(t,n,S),{shouldShowFocusHint:w}=Ud(_,b,r);return(0,Tr.jsxs)(Tr.Fragment,{children:[(0,Tr.jsxs)(Ts,{width:a,isFirst:f,borderColor:h,borderDimColor:p,children:[(0,Tr.jsx)(Mr,{status:n,name:t,isFocused:b}),(0,Tr.jsx)(xs,{name:t,status:n,description:o,emphasis:d,progressMessage:I,originalRequestName:A,isExpanded:R}),(0,Tr.jsx)(Gd,{shouldShowFocusHint:w,isThisShellFocused:b}),d==="high"&&(0,Tr.jsx)(Wd,{})]}),(0,Tr.jsxs)(u,{width:a,borderStyle:"round",borderColor:h,borderDimColor:p,borderTop:!1,borderBottom:!1,borderLeft:!0,borderRight:!0,paddingX:1,flexDirection:"column",children:[n===ie.Executing&&E!==void 0&&(0,Tr.jsx)(Pb,{progress:E,total:T,message:I,barWidth:20}),(0,Tr.jsx)($d,{resultDisplay:r,availableTerminalHeight:i,terminalWidth:a,renderOutputAsMarkdown:m,hasFocus:b,maxLines:s===an.Agent&&i!==void 0?dS:void 0,overflowDirection:s===an.Agent?"bottom":"top"}),b&&S&&(0,Tr.jsx)(u,{paddingLeft:Il,marginTop:1,children:(0,Tr.jsx)(qd,{activeShellPtyId:y??null,focus:g})})]})]})};var Al=C(z(),1);var Kd=C(z(),1);var Ss=C(P(),1);function Fb({ide:e,onComplete:t}){me(i=>i.name==="escape"?(t({userSelection:"no",isExtensionPreInstalled:!1}),!0):!1,{isActive:!0});let{displayName:o}=e,r=!!process.env.GEMINI_CLI_IDE_SERVER_PORT&&!!process.env.GEMINI_CLI_IDE_WORKSPACE_PATH,n=[{label:"Yes",value:{userSelection:"yes",isExtensionPreInstalled:r},key:"Yes"},{label:"No (esc)",value:{userSelection:"no",isExtensionPreInstalled:r},key:"No (esc)"},{label:"No, don't ask again",value:{userSelection:"dismiss",isExtensionPreInstalled:r},key:"No, don't ask again"}],s=r?`If you select Yes, the CLI will have access to your open files and display diffs directly in ${o??"your editor"}.`:`If you select Yes, we'll install an extension that allows the CLI to access your open files and display diffs directly in ${o??"your editor"}.`;return(0,Ss.jsxs)(u,{flexDirection:"column",borderStyle:"round",borderColor:c.status.warning,padding:1,width:"100%",marginLeft:1,children:[(0,Ss.jsxs)(u,{marginBottom:1,flexDirection:"column",children:[(0,Ss.jsxs)(l,{children:[(0,Ss.jsx)(l,{color:c.status.warning,children:"> "}),`Do you want to connect ${o??"your editor"} to Gemini CLI?`]}),(0,Ss.jsx)(l,{color:c.text.secondary,children:s})]}),(0,Ss.jsx)(We,{items:n,onSelect:t})]})}var vl=C(z(),1);import*as Mc from"node:process";import*as Pc from"node:path";var ze=C(P(),1);var Ub=({onSelect:e,isRestarting:t,discoveryResults:o})=>{let[r,n]=(0,vl.useState)(!1),{terminalHeight:s,terminalWidth:i,constrainHeight:a}=Ce(),d=Pt(),m=!a;(0,vl.useEffect)(()=>{let D;return t&&(D=setTimeout(fr,250)),()=>{D&&clearTimeout(D)}},[t]);let f=(0,vl.useCallback)(()=>{n(!0),setTimeout(async()=>{await jn(),Mc.exit(cd.FATAL_CANCELLATION_ERROR)},100)},[]);me(D=>D.name==="escape"?(f(),!0):!1,{isActive:!t});let h=Pc.basename(Mc.cwd()),p=Pc.basename(Pc.dirname(Mc.cwd())),y=[{label:`Trust folder (${h})`,value:"trust_folder",key:`Trust folder (${h})`},{label:`Trust parent folder (${p})`,value:"trust_parent",key:`Trust parent folder (${p})`},{label:"Don't trust",value:"do_not_trust",key:"Don't trust"}],g=o&&(o.commands.length>0||o.mcps.length>0||o.hooks.length>0||o.skills.length>0||o.settings.length>0),x=o&&o.securityWarnings.length>0,S=o&&o.discoveryErrors&&o.discoveryErrors.length>0,I=i-2,A=c.status.warning,E=3+y.length+2+1+2,T=Math.max(4,s-E),v=[{label:"Commands",items:o?.commands??[]},{label:"MCP Servers",items:o?.mcps??[]},{label:"Hooks",items:o?.hooks??[]},{label:"Skills",items:o?.skills??[]},{label:"Agents",items:o?.agents??[]},{label:"Setting overrides",items:o?.settings??[]}].filter(D=>D.items.length>0),R=(0,ze.jsxs)(u,{flexDirection:"column",children:[(0,ze.jsx)(u,{marginBottom:1,children:(0,ze.jsx)(l,{color:c.text.primary,children:"Trusting a folder allows Gemini CLI to load its local configurations, including custom commands, hooks, MCP servers, agent skills, and settings. These configurations could execute code on your behalf or change the behavior of the CLI."})}),S&&(0,ze.jsxs)(u,{flexDirection:"column",marginBottom:1,children:[(0,ze.jsx)(l,{color:c.status.error,bold:!0,children:"\u274C Discovery Errors:"}),o.discoveryErrors.map((D,N)=>(0,ze.jsx)(u,{marginLeft:2,children:(0,ze.jsxs)(l,{color:c.status.error,children:["\u2022 ",_n(D)]})},N))]}),x&&(0,ze.jsxs)(u,{flexDirection:"column",marginBottom:1,children:[(0,ze.jsx)(l,{color:c.status.warning,bold:!0,children:"\u26A0\uFE0F Security Warnings:"}),o.securityWarnings.map((D,N)=>(0,ze.jsx)(u,{marginLeft:2,children:(0,ze.jsxs)(l,{color:c.status.warning,children:["\u2022 ",_n(D)]})},N))]}),g&&(0,ze.jsxs)(u,{flexDirection:"column",marginBottom:1,children:[(0,ze.jsx)(l,{color:c.text.primary,bold:!0,children:"This folder contains:"}),v.map(D=>(0,ze.jsxs)(u,{flexDirection:"column",marginLeft:2,children:[(0,ze.jsxs)(l,{color:c.text.primary,bold:!0,children:["\u2022 ",D.label," (",D.items.length,"):"]}),D.items.map((N,O)=>(0,ze.jsx)(u,{marginLeft:2,children:(0,ze.jsxs)(l,{color:c.text.primary,children:["- ",_n(N)]})},O))]},D.label))]})]}),b=(0,ze.jsx)(l,{bold:!0,color:c.text.primary,children:"Do you trust the files in this folder?"}),_=(0,ze.jsx)(We,{items:y,onSelect:e,isFocused:!t}),M=(0,ze.jsxs)(u,{flexDirection:"column",width:"100%",children:[(0,ze.jsx)(u,{flexDirection:"column",marginLeft:1,marginRight:1,children:d?(0,ze.jsxs)(u,{flexDirection:"column",width:I,children:[(0,ze.jsx)(Ts,{width:I,isFirst:!0,borderColor:A,borderDimColor:!1,children:b}),(0,ze.jsxs)(u,{flexDirection:"column",borderLeft:!0,borderRight:!0,borderColor:A,borderStyle:"round",borderTop:!1,borderBottom:!1,width:I,children:[(0,ze.jsx)(Od,{hasFocus:!t,height:T,width:I-2,children:(0,ze.jsx)(u,{flexDirection:"column",paddingX:1,children:R})}),(0,ze.jsx)(u,{paddingX:1,marginY:1,children:_})]}),(0,ze.jsx)(u,{height:0,width:I,borderLeft:!0,borderRight:!0,borderTop:!1,borderBottom:!0,borderColor:A,borderStyle:"round"})]}):(0,ze.jsxs)(u,{flexDirection:"column",borderStyle:"round",borderColor:A,padding:1,width:"100%",children:[(0,ze.jsx)(u,{marginBottom:1,children:b}),(0,ze.jsx)(dn,{maxHeight:m?void 0:Math.max(4,s-12),overflowDirection:"bottom",children:R}),(0,ze.jsx)(u,{marginTop:1,children:_})]})}),(0,ze.jsx)(u,{paddingX:2,marginBottom:1,children:(0,ze.jsx)(wd,{constrainHeight:a})}),t&&(0,ze.jsx)(u,{marginLeft:1,marginTop:1,children:(0,ze.jsx)(l,{color:c.status.warning,children:"Gemini CLI is restarting to apply the trust changes..."})}),r&&(0,ze.jsx)(u,{marginLeft:1,marginTop:1,children:(0,ze.jsx)(l,{color:c.status.warning,children:"A folder trust level must be selected to continue. Exiting since escape was pressed."})})]});return(0,ze.jsx)(hl,{children:M})};import*as Wb from"node:process";import*as Lc from"node:path";var ri=C(z(),1);import*as Oc from"node:process";import*as Hf from"node:path";function BD(e,t,o){let n=Xn().user.config[t];if(!o)return{currentTrustLevel:n,isInheritedTrustFromParent:!1,isInheritedTrustFromIde:!1};let{isTrusted:s,source:i}=ms(e.merged,Oc.cwd()),a=s&&(!n||n===Jo.DO_NOT_TRUST);return{currentTrustLevel:n,isInheritedTrustFromParent:!!(i==="file"&&a),isInheritedTrustFromIde:!!(i==="ide"&&a)}}var Gb=(e,t,o)=>{let r=Ke(),n=o,s=Hf.resolve(o).toLowerCase()===Hf.resolve(Oc.cwd()).toLowerCase(),[i]=(0,ri.useState)(()=>BD(r,n,s)),[a]=(0,ri.useState)(i.currentTrustLevel),[d,m]=(0,ri.useState)(),[f]=(0,ri.useState)(i.isInheritedTrustFromParent),[h]=(0,ri.useState)(i.isInheritedTrustFromIde),[p,y]=(0,ri.useState)(!1),g=r.merged.security.folderTrust.enabled??!0,x=(0,ri.useCallback)(async I=>{if(!s){await Xn().setValue(n,I),e();return}let A=ms(r.merged,Oc.cwd()).isTrusted,T={...Xn().user.config,[n]:I},{isTrusted:v,source:R}=ms(r.merged,Oc.cwd(),T);if(I===Jo.DO_NOT_TRUST&&v){let b="Note: This folder is still trusted because the connected IDE workspace is trusted.";R==="file"&&(b="Note: This folder is still trusted because a parent folder is trusted."),t({type:"warning",text:b},Date.now())}if(A!==v)m(I),y(!0);else{let b=Xn();try{await b.setValue(n,I)}catch{Se.emitFeedback("error","Failed to save trust settings. Your changes may not persist.")}e()}},[n,r.merged,e,t,s]),S=(0,ri.useCallback)(async()=>{if(d){let I=Xn();try{return await I.setValue(n,d),!0}catch{return Se.emitFeedback("error","Failed to save trust settings. Your changes may not persist."),y(!1),m(void 0),!1}}return!0},[n,d]);return{cwd:n,currentTrustLevel:a,isInheritedTrustFromParent:f,isInheritedTrustFromIde:h,needsRestart:p,updateTrustLevel:x,commitTrustLevelChange:S,isFolderTrustEnabled:g}};var Eo=C(P(),1);function Vb({onExit:e,addItem:t,targetDirectory:o}){let r=o??Wb.cwd(),n=Lc.basename(r),s=Lc.basename(Lc.dirname(r)),i=[{label:`Trust this folder (${n})`,value:Jo.TRUST_FOLDER,key:Jo.TRUST_FOLDER},{label:`Trust parent folder (${s})`,value:Jo.TRUST_PARENT,key:Jo.TRUST_PARENT},{label:"Don't trust",value:Jo.DO_NOT_TRUST,key:Jo.DO_NOT_TRUST}],{cwd:a,currentTrustLevel:d,isInheritedTrustFromParent:m,isInheritedTrustFromIde:f,needsRestart:h,updateTrustLevel:p,commitTrustLevelChange:y}=Gb(e,t,r);me(S=>S.name==="escape"?(e(),!0):h&&S.name==="r"?((async()=>await y()?fr():e())(),!0):!1,{isActive:!0});let g=i.findIndex(S=>S.value===d),x=g===-1?0:g;return(0,Eo.jsxs)(Eo.Fragment,{children:[(0,Eo.jsxs)(u,{borderStyle:"round",borderColor:c.border.default,flexDirection:"column",padding:1,children:[(0,Eo.jsxs)(u,{flexDirection:"column",paddingBottom:1,children:[(0,Eo.jsxs)(l,{bold:!0,children:["> ","Modify Trust Level"]}),(0,Eo.jsx)(u,{marginTop:1}),(0,Eo.jsxs)(l,{children:["Folder: ",a]}),(0,Eo.jsxs)(l,{children:["Current Level: ",(0,Eo.jsx)(l,{bold:!0,children:d||"Not Set"})]}),m&&(0,Eo.jsx)(l,{color:c.text.secondary,children:"Note: This folder behaves as a trusted folder because one of the parent folders is trusted. It will remain trusted even if you set a different trust level here. To change this, you need to modify the trust setting in the parent folder."}),f&&(0,Eo.jsx)(l,{color:c.text.secondary,children:"Note: This folder behaves as a trusted folder because the connected IDE workspace is trusted. It will remain trusted even if you set a different trust level here."})]}),(0,Eo.jsx)(We,{items:i,onSelect:p,isFocused:!0,initialIndex:x}),(0,Eo.jsx)(u,{marginTop:1,children:(0,Eo.jsx)(l,{color:c.text.secondary,children:"(Use Enter to select, Esc to close)"})})]}),h&&(0,Eo.jsx)(u,{marginLeft:1,marginTop:1,children:(0,Eo.jsx)(l,{color:c.status.warning,children:"To apply the trust changes, Gemini CLI must be restarted. Press 'r' to restart CLI now."})})]})}var $b=C(z(),1);var uo=C(P(),1);var qb=({agents:e,onSelect:t})=>{let[o,r]=(0,$b.useState)(!1),n=[{label:"Acknowledge and Enable",value:"acknowledge",key:"acknowledge"},{label:"Do not enable (Ask again next time)",value:"ignore",key:"ignore"}],s=async m=>{r(!0);try{await t(m)}finally{r(!1)}},i=5,a=e.slice(0,i),d=e.length-i;return(0,uo.jsx)(u,{flexDirection:"column",width:"100%",children:(0,uo.jsxs)(u,{flexDirection:"column",borderStyle:"round",borderColor:c.status.warning,padding:1,marginLeft:1,marginRight:1,children:[(0,uo.jsxs)(u,{flexDirection:"column",marginBottom:1,children:[(0,uo.jsx)(l,{bold:!0,color:c.text.primary,children:"New Agents Discovered"}),(0,uo.jsx)(l,{color:c.text.primary,children:"The following agents were found in this project. Please review them:"}),(0,uo.jsxs)(u,{flexDirection:"column",marginTop:1,borderStyle:"single",padding:1,children:[a.map(m=>{let f=m.kind==="local"?m.mcpServers:void 0,h=f&&Object.keys(f).length>0;return(0,uo.jsxs)(u,{flexDirection:"column",children:[(0,uo.jsxs)(u,{children:[(0,uo.jsx)(u,{flexShrink:0,children:(0,uo.jsxs)(l,{bold:!0,color:c.text.primary,children:["- ",m.name,":"," "]})}),(0,uo.jsxs)(l,{color:c.text.secondary,children:[" ",m.description]})]}),h&&(0,uo.jsx)(u,{marginLeft:2,children:(0,uo.jsxs)(l,{color:c.text.secondary,children:["(Includes MCP servers:"," ",Object.keys(f).join(", "),")"]})})]},m.name)}),d>0&&(0,uo.jsxs)(l,{color:c.text.secondary,children:["... and ",d," more."]})]})]}),o?(0,uo.jsxs)(u,{children:[(0,uo.jsx)(Mo,{}),(0,uo.jsx)(l,{color:c.text.primary,children:" Processing..."})]}):(0,uo.jsx)(We,{items:n,onSelect:s,isFocused:!0})]})})};var Ff=(0,Kd.createContext)(null),Pr=()=>{let e=(0,Kd.useContext)(Ff);if(!e)throw new Error("useUIActions must be used within a UIActionsProvider");return e};var qr=C(P(),1);var Kb=({callId:e,name:t,description:o,resultDisplay:r,status:n,availableTerminalHeight:s,terminalWidth:i,emphasis:a="medium",renderOutputAsMarkdown:d=!0,ptyId:m,config:f,isFirst:h,borderColor:p,borderDimColor:y,isExpandable:g,originalRequestName:x})=>{let{isExpanded:S}=oi(),I=(S?S(e):!1)||s===void 0,{activePtyId:A,embeddedShellFocused:E,constrainHeight:T}=Ce(),v=Pt(),R=Fd(t,n,m,A,E),b=Db({status:n,isAlternateBuffer:v,isThisShellFocused:R,availableTerminalHeight:s,constrainHeight:T,isExpandable:g}),_=Nd({availableTerminalHeight:s,isAlternateBuffer:v,maxLinesLimit:b});Al.default.useEffect(()=>{if(n===ie.Executing&&m)try{let F=i-4,B=_??Yn-_c;lo.resizePty(m,Math.max(1,F),Math.max(1,B))}catch(F){if(!(F instanceof Error&&F.message.includes("Cannot resize a pty that has already exited")))throw F}},[m,n,i,_]);let{setEmbeddedShellFocused:w}=Pr(),M=Al.default.useRef(!1);Al.default.useEffect(()=>{R?M.current=!0:M.current&&(E&&w(!1),M.current=!1)},[R,E,w]);let D=Al.default.useRef(null),N=Al.default.useRef(null),O=Hd(t,n,f),W=()=>{O&&w(!0)};cn(D,W,{isActive:!!O}),cn(N,W,{isActive:!!O});let{shouldShowFocusHint:L}=Ud(O,R,r);return(0,qr.jsxs)(qr.Fragment,{children:[(0,qr.jsxs)(Ts,{width:i,isFirst:h,borderColor:p,borderDimColor:y,containerRef:D,children:[(0,qr.jsx)(Mr,{status:n,name:t,isFocused:R}),(0,qr.jsx)(xs,{name:t,status:n,description:o,emphasis:a,originalRequestName:x,isExpanded:I}),(0,qr.jsx)(Gd,{shouldShowFocusHint:L,isThisShellFocused:R}),a==="high"&&(0,qr.jsx)(Wd,{})]}),(0,qr.jsxs)(u,{ref:N,width:i,borderStyle:"round",borderColor:p,borderDimColor:y,borderTop:!1,borderBottom:!1,borderLeft:!0,borderRight:!0,paddingX:1,flexDirection:"column",children:[(0,qr.jsx)($d,{resultDisplay:r,availableTerminalHeight:s,terminalWidth:i,renderOutputAsMarkdown:d,hasFocus:R,maxLines:b}),R&&f&&(0,qr.jsx)(qd,{activeShellPtyId:A??null,focus:E,scrollPageSize:s??Yn})]})]})};var Cs=C(z(),1);var Oi=C(P(),1);var Li=e=>e===ju||e===zu,jb=({callId:e,args:t,availableTerminalHeight:o,isExpandable:r=!0})=>{let{isExpanded:n,toggleExpansion:s}=oi(),i=(n?n(e):!1)||o===void 0,a=ps(),m=`topic-${(0,Cs.useId)()}`,f=(0,Cs.useRef)(null),h=t?.[fT],p=typeof h=="string"?h:void 0,y=t?.[hT],g=typeof y=="string"?y:void 0,x=t?.[gT],S=typeof x=="string"?x:void 0,I=g||S,A=!!(g&&S&&g!==S),E=(0,Cs.useCallback)(()=>{s&&A&&s(e)},[s,A,e]);return cn(f,E,{isActive:r&&A}),(0,Cs.useEffect)(()=>(r&&A&&!i&&a?a.addOverflowingId(m):a&&a.removeOverflowingId(m),()=>{a?.removeOverflowingId(m)}),[r,A,i,a,m]),(0,Oi.jsxs)(u,{ref:f,flexDirection:"column",marginLeft:2,children:[(0,Oi.jsxs)(u,{flexDirection:"row",flexWrap:"wrap",children:[(0,Oi.jsxs)(l,{color:c.text.primary,bold:!0,wrap:"truncate-end",children:[p||"Topic",I&&(0,Oi.jsx)(l,{children:": "})]}),I&&(0,Oi.jsx)(l,{color:c.text.secondary,wrap:"wrap",children:I})]}),i&&A&&S&&(0,Oi.jsx)(u,{marginTop:1,marginLeft:0,children:(0,Oi.jsx)(l,{color:c.text.secondary,wrap:"wrap",children:S})})]})};var jd=C(z(),1);var At=C(P(),1);var zb=({toolCalls:e,availableTerminalHeight:t,terminalWidth:o,borderColor:r,borderDimColor:n,isFirst:s,isExpandable:i=!0})=>{let a=t===void 0,d=ps(),f=`subagent-${(0,jd.useId)()}`;if((0,jd.useEffect)(()=>(i&&d&&d.addOverflowingId(f),()=>{d&&d.removeOverflowingId(f)}),[i,d,f]),e.length===0)return null;let h="";if(e.length===1){let g=e[0].resultDisplay;if(ol(g))switch(g.state){case qt.COMPLETED:h="Agent Completed";break;case qt.CANCELLED:h="Agent Cancelled";break;case qt.ERROR:h="Agent Error";break;default:h="Running Agent...";break}else h="Running Agent..."}else{let g=0,x=0;for(let S of e){let I=S.resultDisplay;ol(I)?I.state===qt.COMPLETED?g++:I.state===qt.RUNNING&&x++:x++}g===e.length?h=`${e.length} Agents Completed`:g>0?h=`${e.length} Agents (${x} running, ${g} completed)...`:h=`Running ${e.length} Agents...`}let p=`(ctrl+o to ${a?"collapse":"expand"})`,y=(g,x,S,I,A)=>(0,At.jsxs)(u,{flexDirection:"row",marginLeft:0,marginTop:0,children:[(0,At.jsx)(u,{minWidth:2,flexShrink:0,children:S}),(0,At.jsx)(u,{flexShrink:0,children:(0,At.jsx)(l,{bold:!0,color:c.text.primary,wrap:"truncate",children:x})}),(0,At.jsx)(u,{flexShrink:0,children:(0,At.jsx)(l,{color:c.text.secondary,children:" \xB7 "})}),(0,At.jsx)(u,{flexShrink:1,minWidth:0,children:(0,At.jsxs)(l,{color:c.text.secondary,wrap:"truncate",children:[I,A&&` ${A}`]})})]},g);return(0,At.jsxs)(u,{flexDirection:"column",width:o,borderLeft:!0,borderRight:!0,borderTop:s,borderBottom:!1,borderColor:r,borderDimColor:n,borderStyle:"round",paddingLeft:1,paddingTop:0,paddingBottom:0,children:[(0,At.jsxs)(u,{flexDirection:"row",gap:1,marginBottom:a?1:0,children:[(0,At.jsx)(l,{color:c.text.secondary,children:"\u2261"}),(0,At.jsx)(l,{bold:!0,color:c.text.primary,children:h}),i&&(0,At.jsx)(l,{color:c.text.secondary,children:p})]}),e.map(g=>{let x=g.resultDisplay;if(!ol(x)){let A=g.name||"agent";return a?(0,At.jsxs)(u,{flexDirection:"column",marginLeft:0,marginBottom:1,children:[(0,At.jsxs)(u,{flexDirection:"row",gap:1,children:[(0,At.jsx)(l,{color:c.text.primary,children:"!"}),(0,At.jsx)(l,{bold:!0,color:c.text.primary,children:A})]}),(0,At.jsx)(u,{marginLeft:2,children:(0,At.jsx)(l,{color:c.text.secondary,children:"Starting..."})})]},g.callId):y(g.callId,A,(0,At.jsx)(l,{color:c.text.primary,children:"!"}),"Starting...")}let S=g.subagentHistory??x.recentActivity,I=S[S.length-1];if(!a){let A="Starting...",E;x.state===qt.COMPLETED?x.terminateReason&&x.terminateReason!=="GOAL"?A=`Finished Early (${x.terminateReason})`:A="Completed successfully":I&&(A=I.displayName||I.content,I.description?E=I.description:I.type==="tool_call"&&I.args&&(E=Nf(I.args)));let T=x.state===qt.COMPLETED?"":E,v=()=>{let R=x.state??qt.RUNNING;switch(R){case qt.RUNNING:return(0,At.jsx)(l,{color:c.text.primary,children:"!"});case qt.COMPLETED:return(0,At.jsx)(l,{color:c.status.success,children:"\u2713"});case qt.CANCELLED:return(0,At.jsx)(l,{color:c.status.warning,children:"\u2139"});case qt.ERROR:return(0,At.jsx)(l,{color:c.status.error,children:"\u2717"});default:return us(R)}};return y(g.callId,x.agentName,v(),I?.type==="thought"?`\u{1F4AD} ${A}`:A,T)}return(0,At.jsx)(u,{flexDirection:"column",marginLeft:0,marginBottom:1,children:(0,At.jsx)(Vd,{progress:x,terminalWidth:o,historyOverrides:g.subagentHistory})},g.callId)})]})};var ni=C(z(),1);var Ye=C(P(),1);var bs=6,kD=4,Qb=4,Yb=120+Qb,HD=e=>!eT(e)||!("payload"in e)?!1:typeof e.payload=="string";function FD(e,t,o,r,n,s){let i=(e.diffStat?.model_added_lines??0)+(e.diffStat?.user_added_lines??0),a=(e.diffStat?.model_removed_lines??0)+(e.diffStat?.user_removed_lines??0),d=t===ie.Success||t===ie.Executing||t===ie.AwaitingApproval,m=d?c.status.success:c.text.secondary,f=d?c.status.error:c.text.secondary,h=!!e.diffStat,p=(0,Ye.jsx)(u,{flexDirection:"row",children:(0,Ye.jsx)(l,{color:c.text.secondary,wrap:"truncate-end",children:e.fileName})}),y="",g=c.text.secondary;t===ie.AwaitingApproval?y="Confirming":t===ie.Success||t===ie.Executing?(y="Accepted",g=c.text.accent):t===ie.Cancelled?(y="Rejected",g=c.status.error):t===ie.Error&&(y=typeof o=="string"?o:"Failed",g=c.status.error);let x=(0,Ye.jsxs)(u,{flexDirection:"row",children:[y&&(0,Ye.jsxs)(l,{color:g,wrap:"truncate-end",children:["\u2192"," ",(0,Ye.jsx)(l,{underline:s,children:y.replace(/\n/g," ")})]}),h&&(0,Ye.jsx)(u,{marginLeft:1,marginRight:2,children:(0,Ye.jsxs)(l,{color:c.text.secondary,children:["(",(0,Ye.jsxs)(l,{color:m,children:["+",i]}),", ",(0,Ye.jsxs)(l,{color:f,children:["-",a]}),")"]})})]}),S=(0,Ye.jsx)(fs,{diffContent:e.fileDiff,filename:e.fileName,terminalWidth:r-bs,availableTerminalHeight:n,disableColor:t===ie.Cancelled});return{description:p,summary:x,payload:S}}function UD(e){let t=e.include?.join(", ")??"",o=(0,Ye.jsxs)(l,{color:c.text.secondary,wrap:"truncate-end",children:["Attempting to read files from ",t]}),r=e.skipped?.length??0,n=`Read ${e.files.length} file(s)${r>0?` (${r} ignored)`:""}`,s=(0,Ye.jsxs)(l,{color:c.text.accent,children:["\u2192 ",n]});return{description:o,summary:s,payload:void 0}}function GD(e,t){let o=t?(0,Ye.jsx)(l,{color:c.text.secondary,wrap:"truncate-end",children:t}):void 0,r=(0,Ye.jsxs)(l,{color:c.text.accent,children:["\u2192 ",e.summary]});return{description:o,summary:r,payload:void 0}}function WD(e,t){return oT(e)?UD(e):GD(e,t)}function Xb(e,t){let o,r,n=t?(0,Ye.jsx)(l,{color:c.text.secondary,wrap:"truncate-end",children:t}):void 0;if(typeof e=="string"){let s=e.replace(/\n/g," ").trim();o=(0,Ye.jsxs)(l,{color:c.text.accent,wrap:"truncate-end",children:["\u2192 ",s]})}else Xp(e)?o=(0,Ye.jsxs)(l,{color:c.text.accent,wrap:"truncate-end",children:["\u2192 ",e.summary]}):tS(e)?o=(0,Ye.jsx)(l,{color:c.text.accent,wrap:"wrap",children:"\u2192 Todos updated"}):HD(e)?(o=(0,Ye.jsxs)(l,{color:c.text.accent,children:["\u2192 ",e.summary]}),r=(0,Ye.jsx)(u,{marginLeft:2,children:(0,Ye.jsx)(l,{color:c.text.secondary,children:e.payload})})):o=(0,Ye.jsx)(l,{color:c.text.accent,wrap:"wrap",children:"\u2192 Returned (possible empty result)"});return{description:n,summary:o,payload:r}}var Jb=e=>{let{callId:t,name:o,status:r,resultDisplay:n,confirmationDetails:s,outputFile:i,terminalWidth:a,availableTerminalHeight:d,description:m}=e,f=Ke(),h=Pt(),{isExpanded:p,toggleExpansion:y}=oi(),[g,x]=(0,ni.useState)(!1),S=p?p(t):g,[I,A]=(0,ni.useState)(!1),E=(0,ni.useRef)(null),T=(0,ni.useMemo)(()=>{if(Uu(n))return n;if(s?.type==="edit"){let O=s;return{fileName:O.fileName,fileDiff:O.fileDiff,filePath:O.filePath,originalContent:O.originalContent,newContent:O.newContent,diffStat:O.diffStat}}},[n,s]);cn(E,()=>{let O=!S;A(!!O),y?y(t):x(O)},{isActive:h&&!!T});let R=(0,ni.useMemo)(()=>{if(T)return FD(T,r,n,a,d,h);if(tT(n))return WD(n,m);if(Xp(n)||r===ie.Success&&n)return Xb(n,m);if(r===ie.Error){let W=typeof n=="string"?n.replace(/\n/g," "):"Failed",L=(0,Ye.jsxs)(l,{color:c.status.error,wrap:"truncate-end",children:["\u2192 ",W]});return{description:m?(0,Ye.jsx)(l,{color:c.text.secondary,wrap:"truncate-end",children:m}):void 0,summary:L,payload:void 0}}return{description:m?(0,Ye.jsx)(l,{color:c.text.secondary,wrap:"truncate-end",children:m}):void 0,summary:void 0,payload:void 0}},[T,r,n,a,d,m,h]),{description:b,summary:_}=R,w=(0,ni.useMemo)(()=>{if(!T||!S||!h)return[];let O=FC(T.fileDiff);if(UC(O)){let L=O.filter(F=>F.type==="add").map(F=>F.content).join(`
27
27
  `),k=HC(T.fileName);return mn({code:L,language:k,maxWidth:a-bs,settings:f,disableColor:r===ie.Cancelled,returnLines:!0})}else return GC({parsedLines:O,filename:T.fileName,terminalWidth:a-bs,disableColor:r===ie.Cancelled})},[T,S,h,a,f,r]),M=(0,ni.useMemo)(()=>!h||!T||S?T?h?S&&w.length>0:!0:!!(R.payload||i):!1,[h,T,S,w.length,R.payload,i]),D=(O,W)=>`diff-line-${W}`,N=({item:O})=>(0,Ye.jsx)(u,{minHeight:1,children:O});return(0,Ye.jsxs)(u,{flexDirection:"column",children:[(0,Ye.jsxs)(u,{marginLeft:2,flexDirection:"row",flexWrap:"wrap",children:[(0,Ye.jsxs)(u,{flexDirection:"row",flexShrink:1,children:[(0,Ye.jsx)(Mr,{status:r,name:o}),(0,Ye.jsx)(u,{maxWidth:25,flexShrink:0,flexGrow:0,children:(0,Ye.jsxs)(l,{color:c.text.primary,bold:!0,wrap:"truncate-end",children:[o," "]})}),(0,Ye.jsx)(u,{marginLeft:1,flexShrink:1,flexGrow:0,children:b})]}),_&&(0,Ye.jsx)(u,{ref:h&&T?E:void 0,marginLeft:1,flexGrow:0,children:_},"tool-summary")]}),M&&h&&w.length>0&&(0,Ye.jsx)(u,{marginLeft:bs,marginTop:1,marginBottom:1,paddingX:1,flexDirection:"column",height:Math.min(w.length,Tf)+2,maxHeight:Tf+2,borderStyle:"round",borderColor:c.border.default,borderDimColor:!0,maxWidth:Math.min(Yb,a-bs),children:(0,Ye.jsx)(pn,{data:w,renderItem:N,keyExtractor:D,estimatedItemHeight:()=>1,hasFocus:I,width:Math.min(Yb,a-bs-kD-Qb)})}),M&&(!h||!T)&&R.payload&&(0,Ye.jsx)(u,{marginLeft:bs,marginTop:1,marginBottom:1,children:R.payload}),M&&i&&(0,Ye.jsx)(u,{marginLeft:bs,marginTop:1,marginBottom:1,children:(0,Ye.jsxs)(l,{color:c.text.secondary,children:["(Output saved to: ",i,")"]})})]})};function zd(e){return{name:e.originalRequestName??e.name,displayName:e.name,status:e.status,hasResult:!!e.resultDisplay,approvalMode:e.approvalMode,isClientInitiated:e.isClientInitiated,parentCallId:e.parentCallId}}function Zb(e,t){let o=[],r=-1;for(let n=e.length-1;n>=0;n--){let s=e[n].type;if(s==="user"||s==="user_shell"){r=n;break}}return e.forEach((n,s)=>{s>r&&n.type==="tool_group"&&n.tools.forEach(i=>{i.callId&&o.push(i.callId)})}),t.forEach(n=>{n.type==="tool_group"&&n.tools.forEach(s=>{s.callId&&o.push(s.callId)})}),o}function Uf(e){return e.some(t=>t&&t.type==="tool_group"?t.tools.some(o=>ie.Executing===o.status):!1)}function Yd(e){return e.filter(t=>t.type==="tool_group").some(t=>t.tools.some(o=>ie.AwaitingApproval===o.status))}function Xd(e){return e.filter(t=>t.type==="tool_group").flatMap(t=>t.tools)}function Gf(e){return"request"in e}function Es(e,t,o,r=[],n=new Map){if(e.type!=="tool_group")return{borderColor:"",borderDimColor:!1};let s=e.tools.length>0?e.tools:r.filter(x=>x!=null&&x.type==="tool_group"&&x.tools.length>0).slice(-1).flatMap(x=>x.tools),i=s.some(x=>Gf(x)?x.status!=="success"&&x.status!=="error"&&x.status!=="cancelled":x.status!==ie.Success&&x.status!==ie.Error&&x.status!==ie.Cancelled),a=s.some(x=>Gf(x)?Zo(x.request.name)&&x.status==="executing"&&x.pid===t&&!!o:Zo(x.name)&&x.status===ie.Executing&&x.ptyId===t&&!!o),d=s.some(x=>Gf(x)?Zo(x.request.name):Zo(x.name)),m=!!t&&!n.has(t),f=d||e.tools.length===0&&m,h=i||e.tools.length===0&&m,p=a||e.tools.length===0&&m&&!!o;return{borderColor:p?c.ui.focus:f&&h?c.ui.active:h?c.status.warning:c.border.default,borderDimColor:h&&(!f||!p)}}var Lo=C(P(),1);var VD=new Set([xT,CT,RT,ST,bT,ET,IT,TT,vT]),Or=(e,t)=>{let o=VD.has(e.name),r=ra(e.status);return t&&o&&r!=="Confirming"},$D=e=>{if(e.outputFile)return!0;let t=e.resultDisplay;return t?!!(Uu(t)||e.confirmationDetails?.type==="edit"||typeof t=="object"&&t!==null&&"summary"in t&&"payload"in t):!1},eE=4,tE=({item:e,toolCalls:t,availableTerminalHeight:o,terminalWidth:r,borderTop:n,borderBottom:s,isExpandable:i})=>{let a=Ke(),d=a.merged.ui?.errorVerbosity!=="full",m=a.merged.ui?.compactToolOutput===!0,f=(0,ha.useMemo)(()=>t.filter(M=>Ux(zd(M),d?"low":"full")),[t,d]),{activePtyId:h,embeddedShellFocused:p,backgroundTasks:y,pendingHistoryItems:g}=Ce(),x=Ct(),{borderColor:S,borderDimColor:I}=(0,ha.useMemo)(()=>Es(e,h,p,g,y),[e,h,p,g,y]),A=(0,ha.useMemo)(()=>{let M=[];for(let D of f)if(D.kind===an.Agent){let N=M[M.length-1];Array.isArray(N)?N.push(D):M.push([D])}else M.push(D);return M},[f]),E=(0,ha.useMemo)(()=>{let M=0;for(let D=0;D<A.length;D++){let N=A[D],O=D===A.length-1,W=D>0?A[D-1]:null,L=W&&!Array.isArray(W)&&Or(W,m),k=W&&!Array.isArray(W)&&Li(W.name),F=O?null:A[D+1],B=F&&!Array.isArray(F)&&Or(F,m),K=F&&!Array.isArray(F)&&Li(F.name),q=Array.isArray(N),Z=!q&&Or(N,m),Y=!q&&Li(N.name),oe=D===0;if(!oe){let ee=!0;for(let te=0;te<D;te++){let ae=A[te];if(Array.isArray(ae)||!Li(ae.name)){ee=!1;break}}oe=ee}let ce=!!(oe?n??!0:L||k),G=!Z&&!Y&&(B||K||O);q?M+=(ce?1:0)+1+N.length+(G?1:0):Y?M+=2+(G?1:0):Z?M+=1:M+=Dc-1+Ld+(N.outputFile?1:0)+(G?1:0)}return M},[A,m,n]),T=0;for(let M of f)M.kind!==an.Agent&&(Or(M,m)?$D(M)&&T++:M.resultDisplay!==void 0&&M.resultDisplay!==""&&T++);let v=o?Math.max(Math.floor((o-E)/Math.max(1,T)),1):void 0,R=r-eE,b=t.length===0;return f.length>0||b&&s===!0?(0,Lo.jsxs)(u,{flexDirection:"column",width:r,paddingRight:eE,marginBottom:0,children:[f.length===0&&b&&s===!0&&(0,Lo.jsx)(u,{width:R,borderLeft:!0,borderRight:!0,borderTop:!1,borderBottom:!0,borderColor:S,borderDimColor:I,borderStyle:"round"}),A.map((M,D)=>{let N=D===0;if(!N){let ae=!0;for(let ne=0;ne<D;ne++){let j=A[ne];if(Array.isArray(j)||!Li(j.name)){ae=!1;break}}N=ae}let O=D===A.length-1,W=D>0?A[D-1]:null,L=W&&!Array.isArray(W)&&Or(W,m),k=W&&!Array.isArray(W)&&Li(W.name),F=O?null:A[D+1],B=F&&!Array.isArray(F)&&Or(F,m),K=F&&!Array.isArray(F)&&Li(F.name),q=Array.isArray(M),Z=!q&&Or(M,m),Y=!q&&Li(M.name),oe=!!(N?n??!0:L||k),ce=!Z&&!Y&&(B||K||O);if(q)return(0,Lo.jsxs)(u,{flexDirection:"column",width:R,children:[(0,Lo.jsx)(zb,{toolCalls:M,availableTerminalHeight:o,terminalWidth:R,borderColor:S,borderDimColor:I,isFirst:oe,isExpandable:i}),ce&&(0,Lo.jsx)(u,{width:R,borderLeft:!0,borderRight:!0,borderTop:!1,borderBottom:O?s??!0:!0,borderColor:S,borderDimColor:I,borderStyle:"round"})]},M[0].callId);let G=M,ee=Zo(G.name),te={...G,availableTerminalHeight:v,terminalWidth:R,emphasis:"medium",isFirst:Z?!1:oe,borderColor:S,borderDimColor:I,isExpandable:i};return(0,Lo.jsxs)(ha.Fragment,{children:[(0,Lo.jsxs)(u,{flexDirection:"column",minHeight:1,width:R,children:[Z?(0,Lo.jsx)(Jb,{...te}):Y?(0,Lo.jsx)(u,{marginBottom:1,children:(0,Lo.jsx)(jb,{...te})}):ee?(0,Lo.jsx)(Kb,{...te,config:x}):(0,Lo.jsx)(Hb,{...te}),!Z&&G.outputFile&&(0,Lo.jsx)(u,{borderLeft:!0,borderRight:!0,borderTop:!1,borderBottom:!1,borderColor:S,borderDimColor:I,flexDirection:"column",borderStyle:"round",paddingLeft:1,paddingRight:1,children:(0,Lo.jsx)(u,{children:(0,Lo.jsxs)(l,{color:c.text.primary,children:["Output too long and was saved to: ",G.outputFile]})})})]}),ce&&(0,Lo.jsx)(u,{width:R,borderLeft:!0,borderRight:!0,borderTop:!1,borderBottom:O?s??!0:!0,borderColor:S,borderDimColor:I,borderStyle:"round"})]},G.callId)})]}):null};var rt=C(P(),1);var oE=({item:e,isToolGroupBoundary:t})=>{let r=Ke().merged.ui?.compactToolOutput===!0;if(e.type!=="tool_display_group")return null;let{tools:n,borderColor:s,borderDimColor:i,borderTop:a,borderBottom:d}=e,m=n.filter(S=>S.status!==ie.AwaitingApproval),f=m.filter(S=>S.format==="notice"),h=m.filter(S=>S.format!=="notice"&&S.format!=="hidden"),p=h.length>0,y=n.length===0&&d;if(m.length===0&&!y)return null;let g=(p||y)&&!r,x=a||f.length>0;return(0,rt.jsxs)(u,{flexDirection:"column",children:[f.map((S,I)=>{let A=I===0&&a,E=I===f.length-1&&!g&&d;return(0,rt.jsx)(u,{marginTop:A||I>0?1:0,marginBottom:E?1:0,children:(0,rt.jsx)(Wf,{tool:S})},`notice-${I}`)}),g?(0,rt.jsx)(u,{flexDirection:"column",borderStyle:"round",borderColor:s,borderDimColor:i,borderTop:x,borderBottom:d,borderLeft:!t,borderRight:!t,marginTop:x?1:0,marginBottom:d?1:0,paddingX:1,children:h.map((S,I)=>(0,rt.jsx)(Wf,{tool:S},`tool-${I}`))}):h.length>0?(0,rt.jsx)(u,{flexDirection:"column",marginTop:f.length>0?1:0,marginBottom:d?1:0,children:h.map((S,I)=>(0,rt.jsx)(Wf,{tool:S},`tool-${I}`))}):null]})},Wf=({tool:e})=>{let o=Ke().merged.ui?.compactToolOutput===!0;if(!e.name&&!e.description&&!e.result&&!e.resultSummary)return(0,rt.jsxs)(u,{paddingLeft:2,children:[(0,rt.jsx)(Mr,{status:e.status,name:e.originalRequestName||"unknown"}),(0,rt.jsx)(l,{color:c.status.error,children:" Error: Tool display missing"})]});let{status:r,format:n,name:s,description:i,resultSummary:a,result:d}=e,m=n||"auto";if(m==="hidden")return null;if(m==="notice"){let h=!!(s&&i?.includes(`"${s}"`));return(0,rt.jsxs)(u,{paddingLeft:2,flexDirection:"column",children:[s&&!h&&(0,rt.jsxs)(l,{color:c.text.primary,bold:!0,wrap:"truncate-end",children:[s,":"]}),i&&(0,rt.jsx)(l,{color:c.text.secondary,wrap:"wrap",children:i})]})}return m==="compact"||m==="auto"&&o?(0,rt.jsxs)(u,{paddingLeft:2,flexDirection:"row",flexWrap:"wrap",children:[(0,rt.jsx)(Mr,{status:r,name:s||e.originalRequestName||""}),(0,rt.jsxs)(l,{bold:!0,color:c.text.primary,children:[" ",s||e.originalRequestName," "]}),i&&(0,rt.jsx)(l,{color:c.text.secondary,children:i}),a&&(0,rt.jsxs)(l,{color:c.text.accent,children:[" ","\u2192 ",a.replace(/\n/g," ")]})]}):(0,rt.jsxs)(u,{flexDirection:"column",paddingLeft:0,children:[(0,rt.jsxs)(u,{flexDirection:"row",paddingLeft:1,children:[(0,rt.jsx)(Mr,{status:r,name:s||e.originalRequestName||""}),(0,rt.jsxs)(l,{bold:!0,color:c.text.primary,children:[" ",s||e.originalRequestName," "]}),i&&(0,rt.jsx)(l,{color:c.text.secondary,children:i})]}),a&&!d&&(0,rt.jsx)(u,{paddingLeft:1,marginTop:1,children:(0,rt.jsx)(l,{color:c.text.primary,children:a})}),d&&(0,rt.jsx)(u,{paddingLeft:1,marginTop:1,children:(0,rt.jsx)(qD,{content:d,summary:a})})]})},qD=({content:e,summary:t})=>{if(!e)return null;switch(e.type){case"text":return(0,rt.jsxs)(u,{flexDirection:"column",children:[(0,rt.jsx)(l,{color:c.text.primary,children:e.text}),t&&(0,rt.jsx)(u,{marginTop:0,children:(0,rt.jsx)(l,{color:c.text.primary,children:t})})]});case"diff":return(0,rt.jsxs)(u,{flexDirection:"column",children:[t&&(0,rt.jsx)(l,{color:c.text.primary,children:t}),(0,rt.jsx)(l,{color:c.text.secondary,children:`[Diff Display: ${e.beforeText.length} -> ${e.afterText.length} chars]`})]});case"terminal":return(0,rt.jsx)(l,{color:c.text.secondary,children:"[Terminal Output]"});case"agent":return(0,rt.jsxs)(l,{color:c.text.secondary,children:["[Subagent: ",e.threadId,"]"]});default:return null}};var Vf=C(P(),1);var rE=({text:e,isPending:t,availableTerminalHeight:o,terminalWidth:r})=>{let{renderMarkdown:n}=Ce(),i="\u2726 ".length;return(0,Vf.jsx)(u,{flexDirection:"column",paddingLeft:i,children:(0,Vf.jsx)(Oo,{text:e,isPending:t,availableTerminalHeight:o===void 0?void 0:Math.max(o-1,1),terminalWidth:Math.max(r-i,0),renderMarkdown:n})})};var Rs=C(P(),1);function nE({compression:e}){let{isPending:t,originalTokenCount:o,newTokenCount:r,compressionStatus:n}=e,s=o??0,i=r??0,d=(()=>{if(t)return"Compressing chat history";switch(n){case tl.COMPRESSED:return`Chat history compressed from ${s} to ${i} tokens.`;case tl.COMPRESSION_FAILED_INFLATED_TOKEN_COUNT:return s<5e4?"Compression was not beneficial for this history size.":"Chat history compression did not reduce size. This may indicate issues with the compression prompt.";case tl.COMPRESSION_FAILED_TOKEN_COUNT_ERROR:return"Could not compress chat history due to a token counting error.";case tl.COMPRESSION_FAILED_EMPTY_SUMMARY:return"Chat history compression failed: the model returned an empty summary.";case tl.NOOP:return"Nothing to compress.";default:return""}})();return(0,Rs.jsxs)(u,{flexDirection:"row",children:[(0,Rs.jsx)(u,{marginRight:1,children:t?(0,Rs.jsx)(Mo,{type:"dots"}):(0,Rs.jsx)(l,{color:c.text.accent,children:"\u2726"})}),(0,Rs.jsx)(u,{children:(0,Rs.jsx)(l,{color:e.isPending?c.text.accent:c.status.success,"aria-label":Md,children:d})})]})}var Is=C(P(),1);function iE({exportSession:e}){let{isPending:t,targetPath:o}=e;return(0,Is.jsxs)(u,{flexDirection:"row",marginTop:1,children:[(0,Is.jsx)(u,{marginRight:1,children:t?(0,Is.jsx)(Mo,{type:"dots"}):(0,Is.jsx)(l,{color:c.status.success,children:"\u2713"})}),(0,Is.jsx)(u,{children:(0,Is.jsx)(l,{color:t?c.text.accent:c.status.success,children:t?"Exporting session...":`Successfully exported session to ${o}`})})]})}var vs=C(P(),1);var wl=({text:e})=>(0,vs.jsxs)(u,{flexDirection:"row",marginTop:1,children:[(0,vs.jsx)(u,{width:3,children:(0,vs.jsx)(l,{color:c.status.warning,children:"\u26A0 "})}),(0,vs.jsx)(u,{flexGrow:1,children:(0,vs.jsx)(l,{wrap:"wrap",children:(0,vs.jsx)(bo,{text:e,defaultColor:c.status.warning})})})]});var ya=C(P(),1);var sE=({item:e,terminalWidth:t})=>(0,ya.jsxs)(u,{flexDirection:"column",width:t,marginBottom:1,children:[(0,ya.jsx)(u,{marginBottom:1,children:(0,ya.jsxs)(l,{bold:!0,color:"cyan",children:["\u{1F916} ",e.agentName," Trace (",e.history.length," items)"]})}),e.history.map(o=>(0,ya.jsx)(u,{marginLeft:2,marginBottom:0,children:(0,ya.jsxs)(l,{color:o.type==="thought"?"gray":"white",children:[o.type==="thought"?"\u{1F9E0}":"\u{1F6E0}\uFE0F"," ",o.content,o.status==="running"&&" (Running...)",o.status==="completed"&&" \u2705",o.status==="error"&&" \u274C"]})},o.id))]});var Le=C(P(),1);var aE=({cliVersion:e,osVersion:t,sandboxEnv:o,modelVersion:r,selectedAuthType:n,gcpProject:s,ideClient:i,userEmail:a,tier:d})=>{let f=Ke().merged.ui.showUserIdentity;return(0,Le.jsxs)(u,{borderStyle:"round",borderColor:c.border.default,flexDirection:"column",padding:1,marginY:1,width:"100%",children:[(0,Le.jsx)(u,{marginBottom:1,children:(0,Le.jsx)(l,{bold:!0,color:c.text.accent,children:"About Gemini CLI"})}),(0,Le.jsxs)(u,{flexDirection:"row",children:[(0,Le.jsx)(u,{width:"35%",children:(0,Le.jsx)(l,{bold:!0,color:c.text.link,children:"CLI Version"})}),(0,Le.jsx)(u,{children:(0,Le.jsx)(l,{color:c.text.primary,children:e})})]}),pd&&!["N/A"].includes(pd)&&(0,Le.jsxs)(u,{flexDirection:"row",children:[(0,Le.jsx)(u,{width:"35%",children:(0,Le.jsx)(l,{bold:!0,color:c.text.link,children:"Git Commit"})}),(0,Le.jsx)(u,{children:(0,Le.jsx)(l,{color:c.text.primary,children:pd})})]}),(0,Le.jsxs)(u,{flexDirection:"row",children:[(0,Le.jsx)(u,{width:"35%",children:(0,Le.jsx)(l,{bold:!0,color:c.text.link,children:"Model"})}),(0,Le.jsx)(u,{children:(0,Le.jsx)(l,{color:c.text.primary,children:Bt(r)})})]}),(0,Le.jsxs)(u,{flexDirection:"row",children:[(0,Le.jsx)(u,{width:"35%",children:(0,Le.jsx)(l,{bold:!0,color:c.text.link,children:"Sandbox"})}),(0,Le.jsx)(u,{children:(0,Le.jsx)(l,{color:c.text.primary,children:o})})]}),(0,Le.jsxs)(u,{flexDirection:"row",children:[(0,Le.jsx)(u,{width:"35%",children:(0,Le.jsx)(l,{bold:!0,color:c.text.link,children:"OS"})}),(0,Le.jsx)(u,{children:(0,Le.jsx)(l,{color:c.text.primary,children:t})})]}),f&&(0,Le.jsxs)(u,{flexDirection:"row",children:[(0,Le.jsx)(u,{width:"35%",children:(0,Le.jsx)(l,{bold:!0,color:c.text.link,children:"Auth Method"})}),(0,Le.jsx)(u,{children:(0,Le.jsx)(l,{color:c.text.primary,children:n.startsWith("oauth")?a?`Signed in with Google (${a})`:"Signed in with Google":n})})]}),f&&d&&(0,Le.jsxs)(u,{flexDirection:"row",children:[(0,Le.jsx)(u,{width:"35%",children:(0,Le.jsx)(l,{bold:!0,color:c.text.link,children:"Tier"})}),(0,Le.jsx)(u,{children:(0,Le.jsx)(l,{color:c.text.primary,children:d})})]}),s&&(0,Le.jsxs)(u,{flexDirection:"row",children:[(0,Le.jsx)(u,{width:"35%",children:(0,Le.jsx)(l,{bold:!0,color:c.text.link,children:"GCP Project"})}),(0,Le.jsx)(u,{children:(0,Le.jsx)(l,{color:c.text.primary,children:s})})]}),i&&(0,Le.jsxs)(u,{flexDirection:"row",children:[(0,Le.jsx)(u,{width:"35%",children:(0,Le.jsx)(l,{bold:!0,color:c.text.link,children:"IDE Client"})}),(0,Le.jsx)(u,{children:(0,Le.jsx)(l,{color:c.text.primary,children:i})})]})]})};var CE=C(z(),1);var ii=C(gE(),1),qf=C(SE(),1);var bE=e=>{if(e.name&&e.colors)throw new Error("The `name` and `colors` props are mutually exclusive");let t;if(e.name)t=qf.default[e.name];else if(e.colors)t=(0,qf.default)(e.colors);else throw new Error("Either `name` or `colors` prop must be provided");let o=r=>t.multiline(_n(r));return CE.default.createElement(eC,{transform:o},e.children)};bE.propTypes={children:ii.default.oneOfType([ii.default.arrayOf(ii.default.node),ii.default.node]).isRequired,name:ii.default.oneOf(["cristal","teen","mind","morning","vice","passion","fruit","instagram","atlas","retro","summer","pastel","rainbow"]),colors:ii.default.arrayOf(ii.default.oneOfType([ii.default.string,ii.default.object]))};var Jd=bE;var Bc=C(P(),1);var Ta=({children:e,...t})=>{let o=c.ui.gradient;return o&&o.length>=2?(0,Bc.jsx)(Jd,{colors:o,children:(0,Bc.jsx)(l,{...t,children:e})}):o&&o.length===1?(0,Bc.jsx)(l,{color:o[0],...t,children:e}):(0,Bc.jsx)(l,{color:c.text.accent,...t,children:e})};var Kr=C(z(),1);var IE=C(P(),1);function QD(e,t){return!(e.api.totalRequests!==t.api.totalRequests||e.api.totalErrors!==t.api.totalErrors||e.api.totalLatencyMs!==t.api.totalLatencyMs||e.tokens.input!==t.tokens.input||e.tokens.prompt!==t.tokens.prompt||e.tokens.candidates!==t.tokens.candidates||e.tokens.total!==t.tokens.total||e.tokens.cached!==t.tokens.cached||e.tokens.thoughts!==t.tokens.thoughts||e.tokens.tool!==t.tokens.tool)}function JD(e,t){return!(e.count!==t.count||e.success!==t.success||e.fail!==t.fail||e.durationMs!==t.durationMs||e.decisions.accept!==t.decisions.accept||e.decisions.reject!==t.decisions.reject||e.decisions.modify!==t.decisions.modify||e.decisions.auto_accept!==t.decisions.auto_accept)}function ZD(e,t){if(e===t)return!0;if(!e||!t||e.files.totalLinesAdded!==t.files.totalLinesAdded||e.files.totalLinesRemoved!==t.files.totalLinesRemoved)return!1;let o=e.tools,r=t.tools;if(o.totalCalls!==r.totalCalls||o.totalSuccess!==r.totalSuccess||o.totalFail!==r.totalFail||o.totalDurationMs!==r.totalDurationMs||o.totalDecisions.accept!==r.totalDecisions.accept||o.totalDecisions.reject!==r.totalDecisions.reject||o.totalDecisions.modify!==r.totalDecisions.modify||o.totalDecisions.auto_accept!==r.totalDecisions.auto_accept)return!1;let n=Object.keys(o.byName),s=Object.keys(r.byName);if(n.length!==s.length)return!1;for(let d of n){let m=o.byName[d],f=r.byName[d];if(!f||!JD(m,f))return!1}let i=Object.keys(e.models),a=Object.keys(t.models);if(i.length!==a.length)return!1;for(let d of i)if(!t.models[d]||!QD(e.models[d],t.models[d]))return!1;return!0}var EE=(0,Kr.createContext)(void 0),RE=({children:e,sessionId:t})=>{let[o,r]=(0,Kr.useState)({sessionId:t,sessionStartTime:new Date,metrics:cs.getMetrics(),lastPromptTokenCount:0,promptCount:0});(0,Kr.useEffect)(()=>{let a=({metrics:m,lastPromptTokenCount:f})=>{r(h=>h.lastPromptTokenCount===f&&ZD(h.metrics,m)?h:{...h,metrics:m,lastPromptTokenCount:f})},d=m=>{r(f=>({...f,sessionId:m||f.sessionId,sessionStartTime:new Date,promptCount:0}))};return cs.on("update",a),cs.on("clear",d),a({metrics:cs.getMetrics(),lastPromptTokenCount:cs.getLastPromptTokenCount()}),()=>{cs.off("update",a),cs.off("clear",d)}},[]);let n=(0,Kr.useCallback)(()=>{r(a=>({...a,promptCount:a.promptCount+1}))},[]),s=(0,Kr.useCallback)(()=>o.promptCount,[o.promptCount]),i=(0,Kr.useMemo)(()=>({stats:o,startNewPrompt:n,getPromptCount:s}),[o,n,s]);return(0,IE.jsx)(EE.Provider,{value:i,children:e})},er=()=>{let e=(0,Kr.useContext)(EE);if(e===void 0)throw new Error("useSessionStats must be used within a SessionStatsProvider");return e};function vE(e){return e.api.totalRequests===0?0:e.api.totalErrors/e.api.totalRequests*100}function AE(e){return e.api.totalRequests===0?0:e.api.totalLatencyMs/e.api.totalRequests}function wE(e){return e.tokens.prompt===0?0:e.tokens.cached/e.tokens.prompt*100}var _E=e=>{let{models:t,tools:o,files:r}=e,n=Object.values(t).reduce((S,I)=>S+I.api.totalLatencyMs,0),s=o.totalDurationMs,i=n+s,a=i>0?n/i*100:0,d=i>0?s/i*100:0,m=Object.values(t).reduce((S,I)=>S+I.tokens.cached,0),f=Object.values(t).reduce((S,I)=>S+I.tokens.input,0),h=Object.values(t).reduce((S,I)=>S+I.tokens.prompt,0),p=h>0?m/h*100:0,y=o.totalDecisions.accept+o.totalDecisions.reject+o.totalDecisions.modify+o.totalDecisions.auto_accept,g=o.totalCalls>0?o.totalSuccess/o.totalCalls*100:0,x=y>0?(o.totalDecisions.accept+o.totalDecisions.auto_accept)/y*100:0;return{totalApiTime:n,totalToolTime:s,agentActiveTime:i,apiTimePercent:a,toolTimePercent:d,cacheEfficiency:p,totalDecisions:y,successRate:g,agreementRate:x,totalCachedTokens:m,totalInputTokens:f,totalPromptTokens:h,totalLinesAdded:r.totalLinesAdded,totalLinesRemoved:r.totalLinesRemoved}};var fe=C(P(),1);var si=({title:e,children:t})=>(0,fe.jsxs)(u,{children:[(0,fe.jsx)(u,{width:28,children:(0,fe.jsx)(l,{color:c.text.link,children:e})}),t]}),DE=({title:e,children:t})=>(0,fe.jsxs)(u,{paddingLeft:2,children:[(0,fe.jsx)(u,{width:26,children:(0,fe.jsxs)(l,{color:c.text.secondary,children:["\xBB ",e]})}),t]}),ME=({title:e,children:t})=>(0,fe.jsxs)(u,{flexDirection:"column",marginBottom:1,children:[(0,fe.jsx)(l,{bold:!0,color:c.text.primary,children:e}),t]}),eM=({models:e})=>{let i=[];return Object.entries(e).forEach(([a,d])=>{if(i.push({name:a,displayName:a,requests:d.api.totalRequests,cachedTokens:d.tokens.cached.toLocaleString(),inputTokens:d.tokens.prompt.toLocaleString(),outputTokens:d.tokens.candidates.toLocaleString(),isSubRow:!1}),d.roles){let m=Object.entries(d.roles).filter(f=>f[1]!==void 0&&f[1].totalRequests>0);m.sort(([f],[h])=>f===h?0:f===_i.MAIN?-1:h===_i.MAIN?1:f.localeCompare(h)),m.forEach(([f,h])=>{i.push({name:`${a}-${f}`,displayName:` \u21B3 ${f}`,requests:h.totalRequests,cachedTokens:h.tokens.cached.toLocaleString(),inputTokens:h.tokens.prompt.toLocaleString(),outputTokens:h.tokens.candidates.toLocaleString(),isSubRow:!0})})}}),(0,fe.jsxs)(u,{flexDirection:"column",marginTop:1,children:[(0,fe.jsx)(l,{bold:!0,color:c.text.primary,children:"Model Usage"}),(0,fe.jsx)(l,{color:c.text.secondary,children:"Use /model to view model quota information"}),(0,fe.jsx)(u,{height:1}),(0,fe.jsxs)(u,{borderBottom:!0,borderStyle:"single",borderColor:c.border.default,borderTop:!1,borderLeft:!1,borderRight:!1,children:[(0,fe.jsx)(u,{width:28,children:(0,fe.jsx)(l,{bold:!0,color:c.text.secondary,children:"Model"})}),(0,fe.jsx)(u,{width:8,justifyContent:"flex-end",children:(0,fe.jsx)(l,{bold:!0,color:c.text.secondary,children:"Reqs"})}),(0,fe.jsx)(u,{width:14,justifyContent:"flex-end",children:(0,fe.jsx)(l,{bold:!0,color:c.text.secondary,children:"Input Tokens"})}),(0,fe.jsx)(u,{width:14,justifyContent:"flex-end",children:(0,fe.jsx)(l,{bold:!0,color:c.text.secondary,children:"Cache Reads"})}),(0,fe.jsx)(u,{width:14,justifyContent:"flex-end",children:(0,fe.jsx)(l,{bold:!0,color:c.text.secondary,children:"Output Tokens"})})]}),i.map(a=>(0,fe.jsxs)(u,{children:[(0,fe.jsx)(u,{width:28,children:(0,fe.jsx)(l,{color:a.isSubRow?c.text.secondary:c.text.primary,wrap:"truncate-end",children:a.displayName})}),(0,fe.jsx)(u,{width:8,justifyContent:"flex-end",children:(0,fe.jsx)(l,{color:a.isSubRow?c.text.secondary:c.text.primary,children:a.requests})}),(0,fe.jsx)(u,{width:14,justifyContent:"flex-end",children:(0,fe.jsx)(l,{color:a.isSubRow?c.text.secondary:c.text.primary,children:a.inputTokens})}),(0,fe.jsx)(u,{width:14,justifyContent:"flex-end",children:(0,fe.jsx)(l,{color:a.isSubRow?c.text.secondary:c.text.primary,children:a.cachedTokens})}),(0,fe.jsx)(u,{width:14,justifyContent:"flex-end",children:(0,fe.jsx)(l,{color:a.isSubRow?c.text.secondary:c.text.primary,children:a.outputTokens})})]},a.name))]})},Zd=({duration:e,title:t,footer:o,selectedAuthType:r,userEmail:n,tier:s,creditBalance:i})=>{let{stats:a}=er(),{metrics:d}=a,{tools:m,files:f,models:h}=d,p=_E(d),g=Ke().merged.ui.showUserIdentity,x={green:Sd,yellow:Cd},S={green:bd,yellow:Ed},I=fl(p.successRate,x),A=fl(p.agreementRate,S),E=()=>t?(0,fe.jsx)(Ta,{bold:!0,children:t}):(0,fe.jsx)(l,{bold:!0,color:c.text.accent,children:"Session Stats"}),T=()=>o?(0,fe.jsx)(Ta,{bold:!0,children:o}):null;return(0,fe.jsxs)(u,{borderStyle:"round",borderColor:c.border.default,flexDirection:"column",paddingTop:1,paddingX:2,overflow:"hidden",children:[E(),(0,fe.jsx)(u,{height:1}),(0,fe.jsxs)(ME,{title:"Interaction Summary",children:[(0,fe.jsx)(si,{title:"Session ID:",children:(0,fe.jsx)(l,{color:c.text.primary,children:a.sessionId})}),g&&r&&(0,fe.jsx)(si,{title:"Auth Method:",children:(0,fe.jsx)(l,{color:c.text.primary,children:r.startsWith("oauth")?n?`Signed in with Google (${n})`:"Signed in with Google":r})}),g&&s&&(0,fe.jsx)(si,{title:"Tier:",children:(0,fe.jsx)(l,{color:c.text.primary,children:s})}),g&&i!=null&&i>=0&&(0,fe.jsx)(si,{title:"Google AI Credits:",children:(0,fe.jsx)(l,{color:i>0?c.text.primary:c.text.secondary,children:i.toLocaleString()})}),(0,fe.jsx)(si,{title:"Tool Calls:",children:(0,fe.jsxs)(l,{color:c.text.primary,children:[m.totalCalls," ("," ",(0,fe.jsxs)(l,{color:c.status.success,children:["\u2713 ",m.totalSuccess]})," ",(0,fe.jsxs)(l,{color:c.status.error,children:["x ",m.totalFail]})," )"]})}),(0,fe.jsx)(si,{title:"Success Rate:",children:(0,fe.jsxs)(l,{color:I,children:[p.successRate.toFixed(1),"%"]})}),p.totalDecisions>0&&(0,fe.jsx)(si,{title:"User Agreement:",children:(0,fe.jsxs)(l,{color:A,children:[p.agreementRate.toFixed(1),"%"," ",(0,fe.jsxs)(l,{color:c.text.secondary,children:["(",p.totalDecisions," reviewed)"]})]})}),f&&(f.totalLinesAdded>0||f.totalLinesRemoved>0)&&(0,fe.jsx)(si,{title:"Code Changes:",children:(0,fe.jsxs)(l,{color:c.text.primary,children:[(0,fe.jsxs)(l,{color:c.status.success,children:["+",f.totalLinesAdded]})," ",(0,fe.jsxs)(l,{color:c.status.error,children:["-",f.totalLinesRemoved]})]})})]}),(0,fe.jsxs)(ME,{title:"Performance",children:[(0,fe.jsx)(si,{title:"Wall Time:",children:(0,fe.jsx)(l,{color:c.text.primary,children:e})}),(0,fe.jsx)(si,{title:"Agent Active:",children:(0,fe.jsx)(l,{color:c.text.primary,children:Jn(p.agentActiveTime)})}),(0,fe.jsx)(DE,{title:"API Time:",children:(0,fe.jsxs)(l,{color:c.text.primary,children:[Jn(p.totalApiTime)," ",(0,fe.jsxs)(l,{color:c.text.secondary,children:["(",p.apiTimePercent.toFixed(1),"%)"]})]})}),(0,fe.jsx)(DE,{title:"Tool Time:",children:(0,fe.jsxs)(l,{color:c.text.primary,children:[Jn(p.totalToolTime)," ",(0,fe.jsxs)(l,{color:c.text.secondary,children:["(",p.toolTimePercent.toFixed(1),"%)"]})]})})]}),Object.keys(h).length>0&&(0,fe.jsx)(eM,{models:h}),T()]})};var ai=C(P(),1);function PE({data:e,columns:t}){return(0,ai.jsxs)(u,{flexDirection:"column",children:[(0,ai.jsx)(u,{flexDirection:"row",children:t.map((o,r)=>(0,ai.jsx)(u,{width:o.width,flexGrow:o.flexGrow,flexShrink:o.flexShrink,flexBasis:o.flexBasis??(o.width?void 0:0),paddingRight:1,children:typeof o.header=="string"?(0,ai.jsx)(l,{bold:!0,color:c.text.primary,children:o.header}):o.header},`header-${r}`))}),(0,ai.jsx)(u,{borderStyle:"single",borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1,borderColor:c.border.default,marginBottom:0}),e.map((o,r)=>(0,ai.jsx)(u,{flexDirection:"row",children:t.map((n,s)=>(0,ai.jsx)(u,{width:n.width,flexGrow:n.flexGrow,flexShrink:n.flexShrink,flexBasis:n.flexBasis??(n.width?void 0:0),paddingRight:1,children:n.renderCell?n.renderCell(o):(0,ai.jsx)(l,{color:c.text.primary,children:String(o[n.key])})},`cell-${r}-${s}`))},`row-${r}`))]})}var li=C(P(),1);var OE=({remaining:e,limit:t,resetTime:o,showDetails:r=!0})=>{if(e===void 0||t===void 0||t===0)return null;let n=100-e/t*100,s=_C(n,{warning:AC,critical:wC});return(0,li.jsxs)(u,{flexDirection:"column",marginTop:0,marginBottom:0,children:[(0,li.jsx)(l,{color:s,children:e===0?`Limit reached${o?`, resets in ${Rc(o,"terse")}`:""}`:`${n.toFixed(0)}% used${o?` (Limit resets in ${Rc(o,"terse")})`:""}`}),r&&(0,li.jsxs)(li.Fragment,{children:[(0,li.jsxs)(l,{color:c.text.primary,children:["Usage limit: ",t.toLocaleString()]}),(0,li.jsx)(l,{color:c.text.primary,children:"Usage limits span all sessions and reset daily."}),e===0&&(0,li.jsx)(l,{color:c.text.primary,children:"Please /auth to upgrade or switch to an API key to continue."})]})]})};var gt=C(P(),1);var LE=({selectedAuthType:e,userEmail:t,tier:o,currentModel:r,quotaStats:n})=>{let{stats:s}=er(),i=n?.remaining,a=n?.limit,d=n?.resetTime,{models:m}=s.metrics,h=Ke().merged.ui.showUserIdentity,p=Object.entries(m).filter(([,b])=>b.api.totalRequests>0);if(p.length===0)return(0,gt.jsx)(u,{borderStyle:"round",borderColor:c.border.default,paddingTop:1,paddingX:2,children:(0,gt.jsx)(l,{color:c.text.primary,children:"No API calls have been made in this session."})});let y=p.map(([b])=>b),g=p.some(([,b])=>b.tokens.thoughts>0),x=p.some(([,b])=>b.tokens.tool>0),S=p.some(([,b])=>b.tokens.cached>0),I=[...new Set(p.flatMap(([,b])=>Object.keys(b.roles??{})))].filter(b=>Object.values(_i).includes(b)).sort((b,_)=>b===_?0:b===_i.MAIN?-1:_===_i.MAIN?1:b.localeCompare(_)),A=(b,_,w={})=>{let M={metric:b,isSection:w.isSection,isSubtle:w.isSubtle};return p.forEach(([D,N])=>{M[D]=_(N)}),M},E=[];E.push({metric:"API",isSection:!0}),E.push(A("Requests",b=>b.api.totalRequests.toLocaleString())),E.push(A("Errors",b=>{let _=vE(b);return(0,gt.jsxs)(l,{color:b.api.totalErrors>0?c.status.error:c.text.primary,children:[b.api.totalErrors.toLocaleString()," (",_.toFixed(1),"%)"]})})),E.push(A("Avg Latency",b=>Jn(AE(b)))),E.push({metric:""}),E.push({metric:"Tokens",isSection:!0}),E.push(A("Total",b=>(0,gt.jsx)(l,{color:c.text.secondary,children:b.tokens.total.toLocaleString()}))),E.push(A("Input",b=>(0,gt.jsx)(l,{color:c.text.primary,children:b.tokens.input.toLocaleString()}),{isSubtle:!0})),S&&E.push(A("Cache Reads",b=>{let _=wE(b);return(0,gt.jsxs)(l,{color:c.text.secondary,children:[b.tokens.cached.toLocaleString()," (",_.toFixed(1),"%)"]})},{isSubtle:!0})),g&&E.push(A("Thoughts",b=>(0,gt.jsx)(l,{color:c.text.primary,children:b.tokens.thoughts.toLocaleString()}),{isSubtle:!0})),x&&E.push(A("Tool",b=>(0,gt.jsx)(l,{color:c.text.primary,children:b.tokens.tool.toLocaleString()}),{isSubtle:!0})),E.push(A("Output",b=>(0,gt.jsx)(l,{color:c.text.primary,children:b.tokens.candidates.toLocaleString()}),{isSubtle:!0})),I.length>0&&(E.push({metric:""}),E.push({metric:"Roles",isSection:!0}),I.forEach(b=>{let _={metric:b,isSection:!0,color:c.text.primary};E.push(_);let w=(M,D)=>{let N={metric:M,isSubtle:!0};p.forEach(([O,W])=>{let L=W.roles?.[b];L?N[O]=D(L):N[O]=(0,gt.jsx)(l,{color:c.text.secondary,children:"-"})}),E.push(N)};w("Requests",M=>M.totalRequests.toLocaleString()),w("Input",M=>(0,gt.jsx)(l,{color:c.text.primary,children:M.tokens.input.toLocaleString()})),w("Output",M=>(0,gt.jsx)(l,{color:c.text.primary,children:M.tokens.candidates.toLocaleString()})),w("Cache Reads",M=>(0,gt.jsx)(l,{color:c.text.secondary,children:M.tokens.cached.toLocaleString()}))}));let T=[{key:"metric",header:"Metric",width:28,renderCell:b=>(0,gt.jsx)(l,{bold:b.isSection,color:b.isSection?c.text.primary:c.text.link,children:b.isSubtle?` \u21B3 ${b.metric}`:b.metric})},...y.map(b=>({key:b,header:b,flexGrow:1,renderCell:_=>{if(_.isSection)return null;let w=_[b];return w==null?null:typeof w=="string"||typeof w=="number"?(0,gt.jsx)(l,{color:c.text.primary,children:w}):w}}))],v=r&&mT(r),R=v?`${Bt(r)} Stats For Nerds`:"Model Stats For Nerds";return(0,gt.jsxs)(u,{borderStyle:"round",borderColor:c.border.default,flexDirection:"column",paddingTop:1,paddingX:2,children:[(0,gt.jsx)(l,{bold:!0,color:c.text.accent,children:R}),(0,gt.jsx)(u,{height:1}),h&&e&&(0,gt.jsxs)(u,{children:[(0,gt.jsx)(u,{width:28,children:(0,gt.jsx)(l,{color:c.text.link,children:"Auth Method:"})}),(0,gt.jsx)(l,{color:c.text.primary,children:e.startsWith("oauth")?t?`Signed in with Google (${t})`:"Signed in with Google":e})]}),h&&o&&(0,gt.jsxs)(u,{children:[(0,gt.jsx)(u,{width:28,children:(0,gt.jsx)(l,{color:c.text.link,children:"Tier:"})}),(0,gt.jsx)(l,{color:c.text.primary,children:o})]}),v&&i!==void 0&&a!==void 0&&a>0&&(0,gt.jsx)(OE,{remaining:i,limit:a,resetTime:d}),(h||v)&&(0,gt.jsx)(u,{height:1}),(0,gt.jsx)(PE,{data:E,columns:T})]})};var we=C(P(),1);var xa=25,Sa=8,Ca=15,ba=15,tM=({name:e,stats:t})=>{let o=t.count>0?t.success/t.count*100:0,r=t.count>0?t.durationMs/t.count:0,n=fl(o,{green:Sd,yellow:Cd});return(0,we.jsxs)(u,{children:[(0,we.jsx)(u,{width:xa,children:(0,we.jsx)(l,{color:c.text.link,children:e})}),(0,we.jsx)(u,{width:Sa,justifyContent:"flex-end",children:(0,we.jsx)(l,{color:c.text.primary,children:t.count})}),(0,we.jsx)(u,{width:Ca,justifyContent:"flex-end",children:(0,we.jsxs)(l,{color:n,children:[o.toFixed(1),"%"]})}),(0,we.jsx)(u,{width:ba,justifyContent:"flex-end",children:(0,we.jsx)(l,{color:c.text.primary,children:Jn(r)})})]})},NE=()=>{let{stats:e}=er(),{tools:t}=e.metrics,o=Object.entries(t.byName).filter(([,a])=>a.count>0);if(o.length===0)return(0,we.jsx)(u,{borderStyle:"round",borderColor:c.border.default,paddingTop:1,paddingX:2,children:(0,we.jsx)(l,{color:c.text.primary,children:"No tool calls have been made in this session."})});let r=Object.values(t.byName).reduce((a,d)=>(a.accept+=d.decisions.accept,a.reject+=d.decisions.reject,a.modify+=d.decisions.modify,a),{accept:0,reject:0,modify:0}),n=r.accept+r.reject+r.modify,s=n>0?r.accept/n*100:0,i=fl(s,{green:bd,yellow:Ed});return(0,we.jsxs)(u,{borderStyle:"round",borderColor:c.border.default,flexDirection:"column",paddingTop:1,paddingX:2,width:70,children:[(0,we.jsx)(l,{bold:!0,color:c.text.accent,children:"Tool Stats For Nerds"}),(0,we.jsx)(u,{height:1}),(0,we.jsxs)(u,{children:[(0,we.jsx)(u,{width:xa,children:(0,we.jsx)(l,{bold:!0,color:c.text.primary,children:"Tool Name"})}),(0,we.jsx)(u,{width:Sa,justifyContent:"flex-end",children:(0,we.jsx)(l,{bold:!0,color:c.text.primary,children:"Calls"})}),(0,we.jsx)(u,{width:Ca,justifyContent:"flex-end",children:(0,we.jsx)(l,{bold:!0,color:c.text.primary,children:"Success Rate"})}),(0,we.jsx)(u,{width:ba,justifyContent:"flex-end",children:(0,we.jsx)(l,{bold:!0,color:c.text.primary,children:"Avg Duration"})})]}),(0,we.jsx)(u,{borderStyle:"single",borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1,borderColor:c.border.default,width:"100%"}),o.map(([a,d])=>(0,we.jsx)(tM,{name:a,stats:d},a)),(0,we.jsx)(u,{height:1}),(0,we.jsx)(l,{bold:!0,color:c.text.primary,children:"User Decision Summary"}),(0,we.jsxs)(u,{children:[(0,we.jsx)(u,{width:xa+Sa+Ca,children:(0,we.jsx)(l,{color:c.text.link,children:"Total Reviewed Suggestions:"})}),(0,we.jsx)(u,{width:ba,justifyContent:"flex-end",children:(0,we.jsx)(l,{color:c.text.primary,children:n})})]}),(0,we.jsxs)(u,{children:[(0,we.jsx)(u,{width:xa+Sa+Ca,children:(0,we.jsx)(l,{color:c.text.primary,children:" \xBB Accepted:"})}),(0,we.jsx)(u,{width:ba,justifyContent:"flex-end",children:(0,we.jsx)(l,{color:c.status.success,children:r.accept})})]}),(0,we.jsxs)(u,{children:[(0,we.jsx)(u,{width:xa+Sa+Ca,children:(0,we.jsx)(l,{color:c.text.primary,children:" \xBB Rejected:"})}),(0,we.jsx)(u,{width:ba,justifyContent:"flex-end",children:(0,we.jsx)(l,{color:c.status.error,children:r.reject})})]}),(0,we.jsxs)(u,{children:[(0,we.jsx)(u,{width:xa+Sa+Ca,children:(0,we.jsx)(l,{color:c.text.primary,children:" \xBB Modified:"})}),(0,we.jsx)(u,{width:ba,justifyContent:"flex-end",children:(0,we.jsx)(l,{color:c.status.warning,children:r.modify})})]}),(0,we.jsx)(u,{borderStyle:"single",borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1,borderColor:c.border.default,width:"100%"}),(0,we.jsxs)(u,{children:[(0,we.jsx)(u,{width:xa+Sa+Ca,children:(0,we.jsx)(l,{color:c.text.primary,children:" Overall Agreement Rate:"})}),(0,we.jsx)(u,{width:ba,justifyContent:"flex-end",children:(0,we.jsx)(l,{bold:!0,color:n>0?i:void 0,children:n>0?`${s.toFixed(1)}%`:"--"})})]})]})};var kE=C(P(),1);var BE=({duration:e})=>{let{stats:t}=er(),o=Ct(),{shell:r}=_T(),n=o.getWorktreeSettings(),s=Qa(t.sessionId,r),i=DT()&&!s.startsWith('"')&&!s.startsWith("'")?`"${s}"`:s,a=`To resume this session: gemini --resume ${i}`;return n&&(a=`To resume work in this worktree: cd ${Qa(n.path,r)} && gemini --resume ${i}
28
28
  To remove manually: git worktree remove ${Qa(n.path,r)}`),(0,kE.jsx)(Zd,{title:"Agent powering down. Goodbye!",duration:e,footer:a})};var Me=C(P(),1);var HE=({commands:e})=>(0,Me.jsxs)(u,{flexDirection:"column",marginBottom:1,borderColor:c.border.default,borderStyle:"round",padding:1,children:[(0,Me.jsx)(l,{bold:!0,color:c.text.primary,children:"Basics:"}),(0,Me.jsxs)(l,{color:c.text.primary,children:[(0,Me.jsx)(l,{bold:!0,color:c.text.accent,children:"Add context"}),": Use"," ",(0,Me.jsx)(l,{bold:!0,color:c.text.accent,children:"@"})," ","to specify files for context (e.g.,"," ",(0,Me.jsx)(l,{bold:!0,color:c.text.accent,children:"@src/myFile.ts"}),") to target specific files or folders."]}),(0,Me.jsxs)(l,{color:c.text.primary,children:[(0,Me.jsx)(l,{bold:!0,color:c.text.accent,children:"Shell mode"}),": Execute shell commands via"," ",(0,Me.jsx)(l,{bold:!0,color:c.text.accent,children:"!"})," ","(e.g.,"," ",(0,Me.jsx)(l,{bold:!0,color:c.text.accent,children:"!npm run start"}),") or use natural language (e.g."," ",(0,Me.jsx)(l,{bold:!0,color:c.text.accent,children:"start server"}),")."]}),(0,Me.jsx)(u,{height:1}),(0,Me.jsx)(l,{bold:!0,color:c.text.primary,children:"Commands:"}),e.filter(t=>t.description&&!t.hidden).map(t=>(0,Me.jsxs)(u,{flexDirection:"column",children:[(0,Me.jsxs)(l,{color:c.text.primary,children:[(0,Me.jsxs)(l,{bold:!0,color:c.text.accent,children:[" ","/",t.name]}),t.kind==="mcp-prompt"&&(0,Me.jsx)(l,{color:c.text.secondary,children:" [MCP]"}),t.description&&" - "+Co(t.description,100)]}),t.subCommands&&t.subCommands.filter(o=>!o.hidden).map(o=>(0,Me.jsxs)(l,{color:c.text.primary,children:[(0,Me.jsxs)(l,{bold:!0,color:c.text.accent,children:[" ",o.name]}),o.description&&" - "+Co(o.description,100)]},o.name))]},t.name)),(0,Me.jsxs)(l,{color:c.text.primary,children:[(0,Me.jsxs)(l,{bold:!0,color:c.text.accent,children:[" ","!"," "]}),"- shell command"]}),(0,Me.jsxs)(l,{color:c.text.primary,children:[(0,Me.jsx)(l,{color:c.text.secondary,children:"[MCP]"})," - Model Context Protocol command (from external servers)"]}),(0,Me.jsx)(u,{height:1}),(0,Me.jsx)(l,{bold:!0,color:c.text.primary,children:"Keyboard Shortcuts:"}),(0,Me.jsxs)(l,{color:c.text.primary,children:[(0,Me.jsxs)(l,{bold:!0,color:c.text.accent,children:[Ee("cursor.wordLeft"),"/",Ee("cursor.wordRight")]})," ","- Jump through words in the input"]}),(0,Me.jsxs)(l,{color:c.text.primary,children:[(0,Me.jsx)(l,{bold:!0,color:c.text.accent,children:Ee("basic.quit")})," ","- Quit application"]}),(0,Me.jsxs)(l,{color:c.text.primary,children:[(0,Me.jsx)(l,{bold:!0,color:c.text.accent,children:Ee("input.newline")})," ","- New line"]}),(0,Me.jsxs)(l,{color:c.text.primary,children:[(0,Me.jsx)(l,{bold:!0,color:c.text.accent,children:Ee("app.clearScreen")})," ","- Clear the screen"]}),(0,Me.jsxs)(l,{color:c.text.primary,children:[(0,Me.jsx)(l,{bold:!0,color:c.text.accent,children:Ee("app.toggleCopyMode")})," ","- Enter selection mode to copy text"]}),(0,Me.jsxs)(l,{color:c.text.primary,children:[(0,Me.jsx)(l,{bold:!0,color:c.text.accent,children:Ee("input.openExternalEditor")})," ","- Open input in external editor"]}),(0,Me.jsxs)(l,{color:c.text.primary,children:[(0,Me.jsx)(l,{bold:!0,color:c.text.accent,children:Ee("app.toggleYolo")})," ","- Toggle YOLO mode"]}),(0,Me.jsxs)(l,{color:c.text.primary,children:[(0,Me.jsx)(l,{bold:!0,color:c.text.accent,children:Ee("input.submit")})," ","- Send message"]}),(0,Me.jsxs)(l,{color:c.text.primary,children:[(0,Me.jsx)(l,{bold:!0,color:c.text.accent,children:Ee("basic.cancel")})," ","- Cancel operation / Clear input (double press)"]}),(0,Me.jsxs)(l,{color:c.text.primary,children:[(0,Me.jsxs)(l,{bold:!0,color:c.text.accent,children:[Ee("scroll.pageUp"),"/",Ee("scroll.pageDown")]})," ","- Scroll page up/down"]}),(0,Me.jsxs)(l,{color:c.text.primary,children:[(0,Me.jsx)(l,{bold:!0,color:c.text.accent,children:Ee("app.cycleApprovalMode")})," ","- Toggle auto-accepting edits"]}),(0,Me.jsxs)(l,{color:c.text.primary,children:[(0,Me.jsxs)(l,{bold:!0,color:c.text.accent,children:[Ee("history.previous"),"/",Ee("history.next")]})," ","- Cycle through your prompt history"]}),(0,Me.jsx)(u,{height:1}),(0,Me.jsxs)(l,{color:c.text.primary,children:["For a full list of shortcuts, see"," ",(0,Me.jsx)(l,{bold:!0,color:c.text.accent,children:lS})]})]});var xr=C(P(),1);var FE=({extensions:e})=>{let{extensionsUpdateState:t}=Ce();return e.length===0?(0,xr.jsx)(l,{children:"No extensions installed."}):(0,xr.jsxs)(u,{flexDirection:"column",marginBottom:1,children:[(0,xr.jsx)(l,{children:"Installed extensions: "}),(0,xr.jsx)(u,{flexDirection:"column",paddingLeft:2,children:e.map(o=>{let r=t.get(o.name),n=o.isActive,s=n?"active":"disabled",i=n?"green":"grey",a="gray",d=r||"unknown state";switch(r){case"checking for updates":case"updating":a="cyan";break;case"update available":case"updated, needs restart":a="yellow";break;case"error":a="red";break;case"up to date":case"not updatable":case"updated":a="green";break;case void 0:break;default:de.warn(`Unhandled ExtensionUpdateState ${r}`);break}return(0,xr.jsxs)(u,{flexDirection:"column",marginBottom:1,children:[(0,xr.jsxs)(l,{children:[(0,xr.jsx)(l,{color:"cyan",children:`${o.name} (v${o.version})`}),(0,xr.jsx)(l,{color:i,children:` - ${s}`}),(0,xr.jsx)(l,{color:a,children:` (${d})`})]}),o.resolvedSettings&&o.resolvedSettings.length>0&&(0,xr.jsxs)(u,{flexDirection:"column",paddingLeft:2,children:[(0,xr.jsx)(l,{children:"settings:"}),o.resolvedSettings.map(m=>(0,xr.jsxs)(l,{children:["- ",m.name,": ",MS(m),m.scope&&(0,xr.jsxs)(l,{color:"gray",children:[" ","(",m.scope.charAt(0).toUpperCase()+m.scope.slice(1),m.source?` - ${m.source}`:"",")"]})]},m.name))]})]},o.name)})})]})};var Mn=C(P(),1);var UE=({tools:e,showDescriptions:t,terminalWidth:o})=>(0,Mn.jsxs)(u,{flexDirection:"column",marginBottom:1,children:[(0,Mn.jsx)(l,{bold:!0,color:c.text.primary,children:"Available Gemini CLI tools:"}),(0,Mn.jsx)(u,{height:1}),e.length>0?e.map(r=>(0,Mn.jsxs)(u,{flexDirection:"row",children:[(0,Mn.jsxs)(l,{color:c.text.primary,children:[" ","- "]}),(0,Mn.jsxs)(u,{flexDirection:"column",children:[(0,Mn.jsxs)(l,{bold:!0,color:c.text.accent,children:[r.displayName," (",r.name,")"]}),t&&r.description&&(0,Mn.jsx)(Oo,{terminalWidth:o,text:r.description,isPending:!1})]})]},r.name)):(0,Mn.jsx)(l,{color:c.text.primary,children:" No tools available"})]});var Gt=C(P(),1);var GE=({skills:e,showDescriptions:t})=>{let o=(i,a)=>i.isBuiltin===a.isBuiltin?i.name.localeCompare(a.name):i.isBuiltin?1:-1,r=e.filter(i=>!i.disabled).sort(o),n=e.filter(i=>i.disabled).sort(o),s=i=>(0,Gt.jsxs)(u,{flexDirection:"row",children:[(0,Gt.jsxs)(l,{color:c.text.primary,children:[" ","- "]}),(0,Gt.jsxs)(u,{flexDirection:"column",children:[(0,Gt.jsxs)(u,{flexDirection:"row",children:[(0,Gt.jsx)(l,{bold:!0,color:i.disabled?c.text.secondary:c.text.link,children:i.name}),i.isBuiltin&&(0,Gt.jsx)(l,{color:c.text.secondary,children:" [Built-in]"})]}),t&&i.description&&(0,Gt.jsx)(u,{marginLeft:2,children:(0,Gt.jsx)(l,{color:i.disabled?c.text.secondary:c.text.primary,children:i.description})})]})]},i.name);return(0,Gt.jsxs)(u,{flexDirection:"column",marginBottom:1,children:[r.length>0&&(0,Gt.jsxs)(u,{flexDirection:"column",children:[(0,Gt.jsx)(l,{bold:!0,color:c.text.primary,children:"Available Agent Skills:"}),(0,Gt.jsx)(u,{height:1}),r.map(s)]}),r.length>0&&n.length>0&&(0,Gt.jsx)(u,{marginY:1,children:(0,Gt.jsx)(l,{color:c.text.secondary,children:"-".repeat(20)})}),n.length>0&&(0,Gt.jsxs)(u,{flexDirection:"column",children:[(0,Gt.jsx)(l,{bold:!0,color:c.text.secondary,children:"Disabled Skills:"}),(0,Gt.jsx)(u,{height:1}),n.map(s)]}),e.length===0&&(0,Gt.jsxs)(u,{flexDirection:"column",children:[(0,Gt.jsx)(l,{color:c.text.primary,children:"No skills available."}),(0,Gt.jsxs)(u,{flexDirection:"row",children:[(0,Gt.jsx)(l,{color:c.text.primary,children:"Learn how to add skills: "}),(0,Gt.jsx)(l,{color:c.text.link,children:mS})]})]})]})};var Sr=C(P(),1);var WE=({agents:e,terminalWidth:t})=>{let o=e.filter(s=>s.kind==="local"),r=e.filter(s=>s.kind==="remote");if(e.length===0)return(0,Sr.jsx)(u,{flexDirection:"column",marginBottom:1,children:(0,Sr.jsx)(l,{children:"No agents available."})});let n=(s,i)=>i.length===0?null:(0,Sr.jsxs)(u,{flexDirection:"column",children:[(0,Sr.jsx)(l,{bold:!0,color:c.text.primary,children:s}),(0,Sr.jsx)(u,{height:1}),i.map(a=>(0,Sr.jsxs)(u,{flexDirection:"row",children:[(0,Sr.jsxs)(l,{color:c.text.primary,children:[" ","- "]}),(0,Sr.jsxs)(u,{flexDirection:"column",children:[(0,Sr.jsxs)(l,{bold:!0,color:c.text.accent,children:[a.displayName||a.name,a.displayName&&a.displayName!==a.name&&(0,Sr.jsxs)(l,{bold:!1,children:[" (",a.name,")"]})]}),a.description&&(0,Sr.jsx)(Oo,{terminalWidth:t,text:a.description,isPending:!1})]})]},a.name))]});return(0,Sr.jsxs)(u,{flexDirection:"column",marginBottom:1,children:[n("Local Agents",o),o.length>0&&r.length>0&&(0,Sr.jsx)(u,{height:1}),n("Remote Agents",r)]})};var Pe=C(P(),1);var VE=({servers:e,tools:t,prompts:o,resources:r,blockedServers:n,serverStatus:s,authStatus:i,enablementState:a,errors:d,discoveryInProgress:m,connectingServers:f,showDescriptions:h,showSchema:p})=>{let y=Object.keys(e).filter(g=>!n.some(x=>x.name===g));return y.length===0&&n.length===0?(0,Pe.jsxs)(u,{flexDirection:"column",children:[(0,Pe.jsx)(l,{children:"No MCP servers configured."}),(0,Pe.jsxs)(l,{children:["Please view MCP documentation in your browser:"," ",(0,Pe.jsx)(l,{color:c.text.link,children:"https://goo.gle/gemini-cli-docs-mcp"})," ","or use the cli /docs command"]})]}):(0,Pe.jsxs)(u,{flexDirection:"column",children:[m&&(0,Pe.jsxs)(u,{flexDirection:"column",marginBottom:1,children:[(0,Pe.jsxs)(l,{color:c.status.warning,children:["\u23F3 MCP servers are starting up (",f.length," ","initializing)..."]}),(0,Pe.jsx)(l,{color:c.text.primary,children:"Note: First startup may take longer. Tool availability will update automatically."})]}),(0,Pe.jsx)(l,{bold:!0,children:"Configured MCP servers:"}),(0,Pe.jsx)(u,{height:1}),y.map(g=>{let x=e[g],S=t.filter(B=>B.serverName===g),I=o.filter(B=>B.serverName===g),A=r.filter(B=>B.serverName===g),E=s(g),T=S.length>0||I.length>0||A.length>0,v=E===Dn.DISCONNECTED&&T?Dn.CONNECTED:E,R="",b="",_=c.text.primary,w=a[g];if(w&&!w.enabled)R="\u23F8\uFE0F",b=w.isSessionDisabled?"Disabled (session)":"Disabled",_=c.text.secondary;else switch(v){case Dn.CONNECTED:R="\u{1F7E2}",b="Ready",_=c.status.success;break;case Dn.CONNECTING:R="\u{1F504}",b="Starting... (first startup may take longer)",_=c.status.warning;break;case Dn.DISCONNECTED:default:R="\u{1F534}",b="Disconnected",_=c.status.error;break}let D=g;x.extension?.name&&(D+=` (from ${x.extension?.name})`);let N=S.length,O=I.length,W=A.length,L=[];N>0&&L.push(`${N} ${N===1?"tool":"tools"}`),O>0&&L.push(`${O} ${O===1?"prompt":"prompts"}`),W>0&&L.push(`${W} ${W===1?"resource":"resources"}`);let k=i[g],F=null;return k==="authenticated"?F=(0,Pe.jsx)(l,{children:" (OAuth)"}):k==="expired"?F=(0,Pe.jsx)(l,{color:c.status.error,children:" (OAuth expired)"}):k==="unauthenticated"&&(F=(0,Pe.jsx)(l,{color:c.status.warning,children:" (OAuth not authenticated)"})),(0,Pe.jsxs)(u,{flexDirection:"column",marginBottom:1,children:[(0,Pe.jsxs)(u,{children:[(0,Pe.jsxs)(l,{color:_,children:[R," "]}),(0,Pe.jsx)(l,{bold:!0,children:D}),(0,Pe.jsxs)(l,{children:[" - ",b,v===Dn.CONNECTED&&L.length>0&&` (${L.join(", ")})`]}),F]}),v===Dn.CONNECTING&&(0,Pe.jsx)(l,{children:" (tools and prompts will appear when ready)"}),v===Dn.DISCONNECTED&&N>0&&(0,Pe.jsxs)(l,{children:[" (",N," tools cached)"]}),d[g]&&(0,Pe.jsx)(u,{marginLeft:2,children:(0,Pe.jsxs)(l,{color:c.status.error,children:["Error: ",d[g]]})}),h&&x?.description&&(0,Pe.jsx)(l,{color:c.text.secondary,children:x.description.trim()}),S.length>0&&(0,Pe.jsxs)(u,{flexDirection:"column",marginLeft:2,children:[(0,Pe.jsx)(l,{color:c.text.primary,children:"Tools:"}),S.map(B=>{let K=p&&B.schema&&(B.schema.parametersJsonSchema||B.schema.parameters)?JSON.stringify(B.schema.parametersJsonSchema??B.schema.parameters,null,2):null;return(0,Pe.jsxs)(u,{flexDirection:"column",children:[(0,Pe.jsxs)(l,{children:["- ",(0,Pe.jsx)(l,{color:c.text.primary,children:B.name})]}),h&&B.description&&(0,Pe.jsx)(u,{marginLeft:2,children:(0,Pe.jsx)(l,{color:c.text.secondary,children:B.description.trim()})}),K&&(0,Pe.jsxs)(u,{flexDirection:"column",marginLeft:4,children:[(0,Pe.jsx)(l,{color:c.text.secondary,children:"Parameters:"}),(0,Pe.jsx)(l,{color:c.text.secondary,children:K})]})]},B.name)})]}),I.length>0&&(0,Pe.jsxs)(u,{flexDirection:"column",marginLeft:2,children:[(0,Pe.jsx)(l,{color:c.text.primary,children:"Prompts:"}),I.map(B=>(0,Pe.jsxs)(u,{flexDirection:"column",children:[(0,Pe.jsxs)(l,{children:["- ",(0,Pe.jsx)(l,{color:c.text.primary,children:B.name})]}),h&&B.description&&(0,Pe.jsx)(u,{marginLeft:2,children:(0,Pe.jsx)(l,{color:c.text.primary,children:B.description.trim()})})]},B.name))]}),A.length>0&&(0,Pe.jsxs)(u,{flexDirection:"column",marginLeft:2,children:[(0,Pe.jsx)(l,{color:c.text.primary,children:"Resources:"}),A.slice(0,Cc).map((B,K)=>{let q=B.name||B.uri||"resource";return(0,Pe.jsxs)(u,{flexDirection:"column",children:[(0,Pe.jsxs)(l,{children:["- ",(0,Pe.jsx)(l,{color:c.text.primary,children:q}),B.uri?` (${B.uri})`:"",B.mimeType?` [${B.mimeType}]`:""]}),h&&B.description&&(0,Pe.jsx)(u,{marginLeft:2,children:(0,Pe.jsx)(l,{color:c.text.secondary,children:B.description.trim()})})]},`${B.serverName}-resource-${K}`)}),A.length>Cc&&(0,Pe.jsxs)(l,{color:c.text.secondary,children:[" ","..."," ",A.length-Cc," ",A.length-Cc===1?"resource":"resources"," ","hidden"]})]})]},g)}),n.map(g=>(0,Pe.jsxs)(u,{marginBottom:1,children:[(0,Pe.jsx)(l,{color:c.status.error,children:"\u{1F534} "}),(0,Pe.jsxs)(l,{bold:!0,children:[g.name,g.extensionName?` (from ${g.extensionName})`:""]}),(0,Pe.jsx)(l,{children:" - Blocked"})]},g.name))]})};var Xe=C(P(),1);var tm=({ok:e})=>(0,Xe.jsx)(l,{color:e?c.status.success:c.status.error,children:e?"\u25CF":"\u25CB"}),$E=({binaryInstalled:e,binaryPath:t,modelName:o,modelDownloaded:r,serverRunning:n,serverPid:s,serverPort:i,settingsEnabled:a,allPassing:d})=>(0,Xe.jsxs)(u,{flexDirection:"column",children:[(0,Xe.jsx)(l,{bold:!0,children:"Gemma Local Model Routing"}),(0,Xe.jsx)(u,{height:1}),(0,Xe.jsxs)(u,{children:[(0,Xe.jsx)(tm,{ok:e}),(0,Xe.jsxs)(l,{children:[" ",(0,Xe.jsx)(l,{bold:!0,children:"Binary: "}),e?(0,Xe.jsx)(l,{color:c.text.secondary,children:t}):(0,Xe.jsx)(l,{color:c.status.error,children:"Not installed"})]})]}),(0,Xe.jsxs)(u,{children:[(0,Xe.jsx)(tm,{ok:r}),(0,Xe.jsxs)(l,{children:[" ",(0,Xe.jsx)(l,{bold:!0,children:"Model: "}),r?(0,Xe.jsx)(l,{children:o}):(0,Xe.jsxs)(l,{color:c.status.error,children:[o," not found"]})]})]}),(0,Xe.jsxs)(u,{children:[(0,Xe.jsx)(tm,{ok:n}),(0,Xe.jsxs)(l,{children:[" ",(0,Xe.jsx)(l,{bold:!0,children:"Server: "}),n?(0,Xe.jsxs)(l,{children:["port ",i,s?(0,Xe.jsxs)(l,{color:c.text.secondary,children:[" (PID ",s,")"]}):null]}):(0,Xe.jsxs)(l,{color:c.status.error,children:["not running on port ",i]})]})]}),(0,Xe.jsxs)(u,{children:[(0,Xe.jsx)(tm,{ok:a}),(0,Xe.jsxs)(l,{children:[" ",(0,Xe.jsx)(l,{bold:!0,children:"Settings: "}),a?(0,Xe.jsx)(l,{children:"enabled"}):(0,Xe.jsx)(l,{color:c.status.error,children:"not enabled"})]})]}),(0,Xe.jsxs)(u,{marginTop:1,children:[(0,Xe.jsx)(l,{bold:!0,children:"Active for: "}),d?(0,Xe.jsx)(l,{color:c.status.success,children:"[routing]"}):(0,Xe.jsx)(l,{color:c.text.secondary,children:"none"})]}),(0,Xe.jsx)(u,{marginTop:1,children:d?(0,Xe.jsxs)(u,{flexDirection:"column",children:[(0,Xe.jsx)(l,{color:c.text.secondary,children:"Simple requests route to Flash, complex requests to Pro."}),(0,Xe.jsx)(l,{color:c.text.secondary,children:"This happens automatically on every request."})]}):(0,Xe.jsx)(l,{color:c.status.warning,children:'Run "gemini gemma setup" to install and configure.'})})]});var hn=C(P(),1);var qE=({chats:e})=>e.length===0?(0,hn.jsx)(l,{children:"No saved conversation checkpoints found."}):(0,hn.jsxs)(u,{flexDirection:"column",children:[(0,hn.jsx)(l,{children:"List of saved conversations:"}),(0,hn.jsx)(u,{height:1}),e.map(t=>{let r=t.mtime.match(/(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}:\d{2})/),n=r?`${r[1]} ${r[2]}`:"Invalid Date";return(0,hn.jsx)(u,{flexDirection:"row",children:(0,hn.jsxs)(l,{children:[" ","- ",(0,hn.jsx)(l,{color:c.text.accent,children:t.name})," ",(0,hn.jsxs)(l,{color:c.text.secondary,children:["(",n,")"]})]})},t.name)}),(0,hn.jsx)(u,{height:1}),(0,hn.jsx)(l,{color:c.text.secondary,children:"Note: Newest last, oldest first"})]});var om=C(P(),1);var KE=({model:e})=>(0,om.jsx)(u,{marginLeft:2,children:(0,om.jsxs)(l,{color:c.ui.comment,italic:!0,children:["Responding with ",Bt(e)]})});var jE=C(z(),1);var As=C(P(),1);var oM=1;function rM(e){let t=xf(e.subject).trim(),o=xf(e.description).trim(),r=s=>{let i=s.trim();return!i||/^\.+$/.test(i)},n=[];if(t&&!r(t)&&n.push(t),o){let s=o.split(`
29
- `).map(i=>i.trim()).filter(i=>!r(i));n.push(...s)}return n}var zE=({thought:e,terminalWidth:t,isFirstThinking:o})=>{let r=(0,jE.useMemo)(()=>rM(e),[e]);return r.length===0?null:(0,As.jsxs)(u,{width:t,flexDirection:"column",children:[o&&(0,As.jsxs)(l,{color:c.text.primary,italic:!0,children:[" ","Thinking..."," "]}),(0,As.jsxs)(u,{marginLeft:oM,paddingLeft:1,borderStyle:"single",borderLeft:!0,borderRight:!1,borderTop:!1,borderBottom:!1,borderColor:c.text.secondary,flexDirection:"column",children:[(0,As.jsx)(l,{children:" "}),r.length>0&&(0,As.jsx)(l,{color:c.text.primary,bold:!0,italic:!0,children:r[0]}),r.slice(1).map((n,s)=>(0,As.jsx)(l,{color:c.text.secondary,italic:!0,children:n},`body-line-${s}`))]})]})};var ws=C(P(),1);var YE=({text:e})=>{let t="\u{1F4A1} ",o=t.length,s=Ct().getUseBackgroundColor()&&!!c.background.message;return(0,ws.jsx)(gs,{backgroundBaseColor:c.text.accent,backgroundOpacity:.1,useBackgroundColor:s,children:(0,ws.jsxs)(u,{flexDirection:"row",paddingY:0,marginY:s?0:1,paddingX:s?1:0,alignSelf:"flex-start",children:[(0,ws.jsx)(u,{width:o,flexShrink:0,children:(0,ws.jsx)(l,{color:c.text.accent,"aria-label":Tl,children:t})}),(0,ws.jsx)(u,{flexGrow:1,children:(0,ws.jsx)(l,{wrap:"wrap",italic:!0,color:c.text.accent,children:`Steering Hint: ${e}`})})]})})};function rm(e){return e.merged.ui?.inlineThinkingMode??"off"}var ht=C(P(),1);var _s=({item:e,availableTerminalHeight:t,terminalWidth:o,isPending:r,commands:n,availableTerminalHeightGemini:s,isExpandable:i,isFirstThinking:a=!1,isFirstAfterThinking:d=!1,isToolGroupBoundary:m=!1})=>{let f=Ke(),h=rm(f),p=(0,XE.useMemo)(()=>bS(e),[e]);return(0,ht.jsxs)(u,{flexDirection:"column",width:o,marginTop:!!(d&&h!=="off"||m)?1:0,children:[p.type==="thinking"&&h!=="off"&&(0,ht.jsx)(zE,{thought:p.thought,terminalWidth:o,isFirstThinking:a}),p.type==="hint"&&(0,ht.jsx)(YE,{text:p.text}),p.type==="user"&&(0,ht.jsx)(tb,{text:p.text,width:o}),p.type==="user_shell"&&(0,ht.jsx)(ob,{text:p.text,width:o}),p.type==="gemini"&&(0,ht.jsx)(bb,{text:p.text,isPending:r,availableTerminalHeight:s??t,terminalWidth:o}),p.type==="gemini_content"&&(0,ht.jsx)(rE,{text:p.text,isPending:r,availableTerminalHeight:s??t,terminalWidth:o}),p.type==="info"&&(0,ht.jsx)(Eb,{text:p.text,secondaryText:p.secondaryText,source:p.source,icon:p.icon,color:p.color,marginBottom:p.marginBottom}),p.type==="warning"&&(0,ht.jsx)(wl,{text:p.text}),p.type==="error"&&(0,ht.jsx)(Rb,{text:p.text}),p.type==="about"&&(0,ht.jsx)(aE,{cliVersion:p.cliVersion,osVersion:p.osVersion,sandboxEnv:p.sandboxEnv,modelVersion:p.modelVersion,selectedAuthType:p.selectedAuthType,gcpProject:p.gcpProject,ideClient:p.ideClient,userEmail:p.userEmail,tier:p.tier}),p.type==="help"&&n&&(0,ht.jsx)(HE,{commands:n}),p.type==="stats"&&(0,ht.jsx)(Zd,{duration:p.duration,selectedAuthType:p.selectedAuthType,userEmail:p.userEmail,tier:p.tier}),p.type==="model_stats"&&(0,ht.jsx)(LE,{selectedAuthType:p.selectedAuthType,userEmail:p.userEmail,tier:p.tier,currentModel:p.currentModel,quotaStats:p.pooledRemaining!==void 0||p.pooledLimit!==void 0||p.pooledResetTime!==void 0?{remaining:p.pooledRemaining,limit:p.pooledLimit,resetTime:p.pooledResetTime}:void 0}),p.type==="tool_stats"&&(0,ht.jsx)(NE,{}),p.type==="model"&&(0,ht.jsx)(KE,{model:p.model}),p.type==="quit"&&(0,ht.jsx)(BE,{duration:p.duration}),p.type==="tool_group"&&(0,ht.jsx)(tE,{item:p,toolCalls:p.tools,availableTerminalHeight:t,terminalWidth:o,borderTop:p.borderTop,borderBottom:p.borderBottom,isExpandable:i}),p.type==="tool_display_group"&&(0,ht.jsx)(oE,{item:p,isToolGroupBoundary:m}),p.type==="subagent"&&(0,ht.jsx)(sE,{item:p,terminalWidth:o}),p.type==="compression"&&(0,ht.jsx)(nE,{compression:p.compression}),p.type==="export_session"&&(0,ht.jsx)(iE,{exportSession:p.exportSession}),p.type==="extensions_list"&&(0,ht.jsx)(FE,{extensions:p.extensions}),p.type==="tools_list"&&(0,ht.jsx)(UE,{terminalWidth:o,tools:p.tools,showDescriptions:p.showDescriptions}),p.type==="skills_list"&&(0,ht.jsx)(GE,{skills:p.skills,showDescriptions:p.showDescriptions}),p.type==="agents_list"&&(0,ht.jsx)(WE,{agents:p.agents,terminalWidth:o}),p.type==="mcp_status"&&(0,ht.jsx)(VE,{...p,serverStatus:Lx}),p.type==="gemma_status"&&(0,ht.jsx)($E,{...p}),p.type==="chat_list"&&(0,ht.jsx)(qE,{chats:p.chats})]},p.id)};var nm=C(z(),1);function ci(){let[e,t]=(0,nm.useState)({columns:process.stdout.columns||60,rows:process.stdout.rows||20});return(0,nm.useEffect)(()=>{function o(){t({columns:process.stdout.columns||60,rows:process.stdout.rows||20})}return process.stdout.on("resize",o),()=>{process.stdout.off("resize",o)}},[]),e}var Kf=C(P(),1);var im=()=>{let e=Ce(),{rows:t,columns:o}=ci(),r=t;return e.quittingMessages?(0,Kf.jsx)(u,{flexDirection:"column",marginBottom:1,children:e.quittingMessages.map(n=>(0,Kf.jsx)(_s,{availableTerminalHeight:e.constrainHeight?r:void 0,terminalWidth:o,item:n,isPending:!1},n.id))}):null};var jr=C(z(),1);var sm=C(z(),1);var jf=(0,sm.createContext)(null),_l=()=>{let e=(0,sm.useContext)(jf);if(!e)throw new Error("useAppContext must be used within an AppProvider");return e};var zf=C(P(),1);var QE=({message:e})=>(0,zf.jsx)(u,{borderStyle:"round",borderColor:c.status.warning,paddingX:1,marginY:1,children:(0,zf.jsx)(l,{color:c.status.warning,children:e})});var tr=C(P(),1);import*as am from"node:fs/promises";import ZE from"node:path";var iM=ZE.join(nT(),rT,"settings.json"),JE=ZE.join(Xa.getGlobalTempDir(),"seen_screen_reader_nudge.json"),sM=3,lm=()=>{let{startupWarnings:e}=_l(),{initError:t,streamingState:o,updateInfo:r}=Ce(),n=Dr(),s=t&&o!=="responding",[i,a]=(0,jr.useState)(()=>Go.get("hasSeenScreenReaderNudge")),[d,m]=(0,jr.useState)(!1),f=(0,jr.useRef)(!1),h=(0,jr.useMemo)(()=>{if(d)return[];let x=Go.get("startupWarningCounts")||{};return e.filter(S=>S.priority===hf.Low?(x[S.id]||0)<sM:!0)},[e,d]),p=h.length>0;(0,jr.useEffect)(()=>{if(h.length>0&&!f.current){let x={...Go.get("startupWarningCounts")||{}},S=!1;h.forEach(I=>{I.priority===hf.Low&&(x[I.id]=(x[I.id]||0)+1,S=!0)}),S&&Go.set("startupWarningCounts",x),f.current=!0}},[h]);let y=(0,jr.useCallback)(()=>(p&&m(!0),!1),[p]);me(y,{isActive:p,priority:200}),(0,jr.useEffect)(()=>{n&&(async()=>{if(i===void 0)try{await am.access(JE),Go.set("hasSeenScreenReaderNudge",!0),a(!0),await am.unlink(JE).catch(()=>{})}catch{a(!1)}})()},[n,i]);let g=n&&i===!1;return(0,jr.useEffect)(()=>{g&&Go.set("hasSeenScreenReaderNudge",!0)},[g]),!p&&!s&&!r&&!g?null:(0,tr.jsxs)(tr.Fragment,{children:[g&&(0,tr.jsxs)(l,{children:["You are currently in screen reader-friendly view. To switch out, open"," ",iM," and remove the entry for ",'"screenReader"',". This will disappear on next run."]}),r&&(0,tr.jsx)(QE,{message:r.message}),p&&(0,tr.jsx)(u,{marginY:1,flexDirection:"column",children:h.map((x,S)=>(0,tr.jsxs)(u,{flexDirection:"row",children:[(0,tr.jsx)(u,{width:3,children:(0,tr.jsx)(l,{color:c.status.warning,children:"\u26A0 "})}),(0,tr.jsx)(u,{flexGrow:1,children:(0,tr.jsx)(l,{color:c.status.warning,children:x.message})})]},S))}),s&&(0,tr.jsxs)(u,{borderStyle:"round",borderColor:c.status.error,paddingX:1,marginBottom:1,children:[(0,tr.jsxs)(l,{color:c.status.error,children:["Initialization Error: ",t]}),(0,tr.jsxs)(l,{color:c.status.error,children:[" ","Please check API key and configuration."]})]})]})};var Ea=C(z(),1);var yn=C(P(),1);var eR=({config:e})=>{let t=e.getContentGeneratorConfig()?.authType,[o,r]=(0,Ea.useState)();(0,Ea.useEffect)(()=>{if(t){let i=new Yu;r(i.getCachedGoogleAccount()??void 0)}else r(void 0)},[t]);let n=(0,Ea.useMemo)(()=>t?e.getUserTierName():void 0,[e,t]),s=(0,Ea.useMemo)(()=>_d(n),[n]);return t?(0,yn.jsxs)(u,{flexDirection:"column",children:[(0,yn.jsxs)(u,{children:[(0,yn.jsx)(l,{color:c.text.primary,wrap:"truncate-end",children:t===qe.LOGIN_WITH_GOOGLE?(0,yn.jsxs)(l,{children:[(0,yn.jsxs)(l,{bold:!0,children:["Signed in with Google",o?":":""]}),o?` ${o}`:""]}):`Authenticated with ${t}`}),(0,yn.jsx)(l,{color:c.text.secondary,children:" /auth"})]}),n&&(0,yn.jsxs)(u,{children:[(0,yn.jsxs)(l,{color:c.text.primary,wrap:"truncate-end",children:[(0,yn.jsx)(l,{bold:!0,children:"Plan:"})," ",n]}),!s&&(0,yn.jsx)(l,{color:c.text.secondary,children:" /upgrade"})]})]}):null};var ui=C(P(),1);var tR=({config:e})=>{let t=e.getGeminiMdFileCount();return(0,ui.jsxs)(u,{flexDirection:"column",marginTop:1,children:[(0,ui.jsx)(l,{color:c.text.primary,children:"Tips for getting started:"}),t===0&&(0,ui.jsxs)(l,{color:c.text.primary,children:["1. Create ",(0,ui.jsx)(l,{bold:!0,children:"GEMINI.md"})," files to customize your interactions"]}),(0,ui.jsxs)(l,{color:c.text.primary,children:[t===0?"2.":"1."," ",(0,ui.jsx)(l,{color:c.text.secondary,children:"/help"})," for more information"]}),(0,ui.jsxs)(l,{color:c.text.primary,children:[t===0?"3.":"2."," Ask coding questions, edit code or run commands"]}),(0,ui.jsxs)(l,{color:c.text.primary,children:[t===0?"4.":"3."," Be specific for the best results"]})]})};var Dl=C(P(),1);function aM(e,t,o){return e.replace(/\\n/g,`
29
+ `).map(i=>i.trim()).filter(i=>!r(i));n.push(...s)}return n}var zE=({thought:e,terminalWidth:t,isFirstThinking:o})=>{let r=(0,jE.useMemo)(()=>rM(e),[e]);return r.length===0?null:(0,As.jsxs)(u,{width:t,flexDirection:"column",children:[o&&(0,As.jsxs)(l,{color:c.text.primary,italic:!0,children:[" ","Thinking..."," "]}),(0,As.jsxs)(u,{marginLeft:oM,paddingLeft:1,borderStyle:"single",borderLeft:!0,borderRight:!1,borderTop:!1,borderBottom:!1,borderColor:c.text.secondary,flexDirection:"column",children:[(0,As.jsx)(l,{children:" "}),r.length>0&&(0,As.jsx)(l,{color:c.text.primary,bold:!0,italic:!0,children:r[0]}),r.slice(1).map((n,s)=>(0,As.jsx)(l,{color:c.text.secondary,italic:!0,children:n},`body-line-${s}`))]})]})};var ws=C(P(),1);var YE=({text:e})=>{let t="\u{1F4A1} ",o=t.length,s=Ct().getUseBackgroundColor()&&!!c.background.message;return(0,ws.jsx)(gs,{backgroundBaseColor:c.text.accent,backgroundOpacity:.1,useBackgroundColor:s,children:(0,ws.jsxs)(u,{flexDirection:"row",paddingY:0,marginY:s?0:1,paddingX:s?1:0,alignSelf:"flex-start",children:[(0,ws.jsx)(u,{width:o,flexShrink:0,children:(0,ws.jsx)(l,{color:c.text.accent,"aria-label":Tl,children:t})}),(0,ws.jsx)(u,{flexGrow:1,children:(0,ws.jsx)(l,{wrap:"wrap",italic:!0,color:c.text.accent,children:`Steering Hint: ${e}`})})]})})};function rm(e){return e.merged.ui?.inlineThinkingMode??"off"}var ht=C(P(),1);var _s=({item:e,availableTerminalHeight:t,terminalWidth:o,isPending:r,commands:n,availableTerminalHeightGemini:s,isExpandable:i,isFirstThinking:a=!1,isFirstAfterThinking:d=!1,isToolGroupBoundary:m=!1})=>{let f=Ke(),h=rm(f),p=(0,XE.useMemo)(()=>bS(e),[e]);return(0,ht.jsxs)(u,{flexDirection:"column",width:o,marginTop:!!(d&&h!=="off"||m)?1:0,children:[p.type==="thinking"&&h!=="off"&&(0,ht.jsx)(zE,{thought:p.thought,terminalWidth:o,isFirstThinking:a}),p.type==="hint"&&(0,ht.jsx)(YE,{text:p.text}),p.type==="user"&&(0,ht.jsx)(tb,{text:p.text,width:o}),p.type==="user_shell"&&(0,ht.jsx)(ob,{text:p.text,width:o}),p.type==="gemini"&&(0,ht.jsx)(bb,{text:p.text,isPending:r,availableTerminalHeight:s??t,terminalWidth:o}),p.type==="gemini_content"&&(0,ht.jsx)(rE,{text:p.text,isPending:r,availableTerminalHeight:s??t,terminalWidth:o}),p.type==="info"&&(0,ht.jsx)(Eb,{text:p.text,secondaryText:p.secondaryText,source:p.source,icon:p.icon,color:p.color,marginBottom:p.marginBottom}),p.type==="warning"&&(0,ht.jsx)(wl,{text:p.text}),p.type==="error"&&(0,ht.jsx)(Rb,{text:p.text}),p.type==="about"&&(0,ht.jsx)(aE,{cliVersion:p.cliVersion,osVersion:p.osVersion,sandboxEnv:p.sandboxEnv,modelVersion:p.modelVersion,selectedAuthType:p.selectedAuthType,gcpProject:p.gcpProject,ideClient:p.ideClient,userEmail:p.userEmail,tier:p.tier}),p.type==="help"&&n&&(0,ht.jsx)(HE,{commands:n}),p.type==="stats"&&(0,ht.jsx)(Zd,{duration:p.duration,selectedAuthType:p.selectedAuthType,userEmail:p.userEmail,tier:p.tier}),p.type==="model_stats"&&(0,ht.jsx)(LE,{selectedAuthType:p.selectedAuthType,userEmail:p.userEmail,tier:p.tier,currentModel:p.currentModel,quotaStats:p.pooledRemaining!==void 0||p.pooledLimit!==void 0||p.pooledResetTime!==void 0?{remaining:p.pooledRemaining,limit:p.pooledLimit,resetTime:p.pooledResetTime}:void 0}),p.type==="tool_stats"&&(0,ht.jsx)(NE,{}),p.type==="model"&&(0,ht.jsx)(KE,{model:p.model}),p.type==="quit"&&(0,ht.jsx)(BE,{duration:p.duration}),p.type==="tool_group"&&(0,ht.jsx)(tE,{item:p,toolCalls:p.tools,availableTerminalHeight:t,terminalWidth:o,borderTop:p.borderTop,borderBottom:p.borderBottom,isExpandable:i}),p.type==="tool_display_group"&&(0,ht.jsx)(oE,{item:p,isToolGroupBoundary:m}),p.type==="subagent"&&(0,ht.jsx)(sE,{item:p,terminalWidth:o}),p.type==="compression"&&(0,ht.jsx)(nE,{compression:p.compression}),p.type==="export_session"&&(0,ht.jsx)(iE,{exportSession:p.exportSession}),p.type==="extensions_list"&&(0,ht.jsx)(FE,{extensions:p.extensions}),p.type==="tools_list"&&(0,ht.jsx)(UE,{terminalWidth:o,tools:p.tools,showDescriptions:p.showDescriptions}),p.type==="skills_list"&&(0,ht.jsx)(GE,{skills:p.skills,showDescriptions:p.showDescriptions}),p.type==="agents_list"&&(0,ht.jsx)(WE,{agents:p.agents,terminalWidth:o}),p.type==="mcp_status"&&(0,ht.jsx)(VE,{...p,serverStatus:Lx}),p.type==="gemma_status"&&(0,ht.jsx)($E,{...p}),p.type==="chat_list"&&(0,ht.jsx)(qE,{chats:p.chats})]},p.id)};var nm=C(z(),1);function ci(){let[e,t]=(0,nm.useState)({columns:process.stdout.columns||60,rows:process.stdout.rows||20});return(0,nm.useEffect)(()=>{function o(){t({columns:process.stdout.columns||60,rows:process.stdout.rows||20})}return process.stdout.on("resize",o),()=>{process.stdout.off("resize",o)}},[]),e}var Kf=C(P(),1);var im=()=>{let e=Ce(),{rows:t,columns:o}=ci(),r=t;return e.quittingMessages?(0,Kf.jsx)(u,{flexDirection:"column",marginBottom:1,children:e.quittingMessages.map(n=>(0,Kf.jsx)(_s,{availableTerminalHeight:e.constrainHeight?r:void 0,terminalWidth:o,item:n,isPending:!1},n.id))}):null};var jr=C(z(),1);var sm=C(z(),1);var jf=(0,sm.createContext)(null),_l=()=>{let e=(0,sm.useContext)(jf);if(!e)throw new Error("useAppContext must be used within an AppProvider");return e};var zf=C(P(),1);var QE=({message:e})=>(0,zf.jsx)(u,{borderStyle:"round",borderColor:c.status.warning,paddingX:1,marginY:1,children:(0,zf.jsx)(l,{color:c.status.warning,children:e})});var tr=C(P(),1);import*as am from"node:fs/promises";import ZE from"node:path";var iM=ZE.join(nT(),rT,"settings.json"),JE=ZE.join(Xa.getGlobalTempDir(),"seen_screen_reader_nudge.json"),sM=3,lm=()=>{let{startupWarnings:e}=_l(),{initError:t,streamingState:o,updateInfo:r}=Ce(),n=Dr(),s=t&&o!=="responding",[i,a]=(0,jr.useState)(()=>Go.get("hasSeenScreenReaderNudge")),[d,m]=(0,jr.useState)(!1),f=(0,jr.useRef)(!1),h=(0,jr.useMemo)(()=>{if(d)return[];let x=Go.get("startupWarningCounts")||{};return e.filter(S=>S.priority===hf.Low?(x[S.id]||0)<sM:!0)},[e,d]),p=h.length>0;(0,jr.useEffect)(()=>{if(h.length>0&&!f.current){let x={...Go.get("startupWarningCounts")||{}},S=!1;h.forEach(I=>{I.priority===hf.Low&&(x[I.id]=(x[I.id]||0)+1,S=!0)}),S&&Go.set("startupWarningCounts",x),f.current=!0}},[h]);let y=(0,jr.useCallback)(()=>(p&&m(!0),!1),[p]);me(y,{isActive:p,priority:200}),(0,jr.useEffect)(()=>{n&&(async()=>{if(i===void 0)try{await am.access(JE),Go.set("hasSeenScreenReaderNudge",!0),a(!0),await am.unlink(JE).catch(()=>{})}catch{a(!1)}})()},[n,i]);let g=n&&i===!1;return(0,jr.useEffect)(()=>{g&&Go.set("hasSeenScreenReaderNudge",!0)},[g]),!p&&!s&&!r&&!g?null:(0,tr.jsxs)(tr.Fragment,{children:[g&&(0,tr.jsxs)(l,{children:["You are currently in screen reader-friendly view. To switch out, open"," ",iM," and remove the entry for ",'"screenReader"',". This will disappear on next run."]}),r&&(0,tr.jsx)(QE,{message:r.message}),p&&(0,tr.jsx)(u,{marginY:1,flexDirection:"column",children:h.map((x,S)=>(0,tr.jsxs)(u,{flexDirection:"row",children:[(0,tr.jsx)(u,{width:3,children:(0,tr.jsx)(l,{color:c.status.warning,children:"\u26A0 "})}),(0,tr.jsx)(u,{flexGrow:1,children:(0,tr.jsx)(l,{color:c.status.warning,children:x.message})})]},S))}),s&&(0,tr.jsxs)(u,{borderStyle:"round",borderColor:c.status.error,paddingX:1,marginBottom:1,children:[(0,tr.jsxs)(l,{color:c.status.error,children:["Initialization Error: ",t]}),(0,tr.jsxs)(l,{color:c.status.error,children:[" ","Please check API key and configuration."]})]})]})};var Ea=C(z(),1);var yn=C(P(),1);var eR=({config:e})=>{let t=e.getContentGeneratorConfig()?.authType,[o,r]=(0,Ea.useState)();(0,Ea.useEffect)(()=>{if(t){let i=new Yu;r(i.getCachedGoogleAccount()??void 0)}else r(void 0)},[t]);let n=(0,Ea.useMemo)(()=>t?e.getUserTierName():void 0,[e,t]),s=(0,Ea.useMemo)(()=>_d(n),[n]);return t?(0,yn.jsxs)(u,{flexDirection:"column",children:[(0,yn.jsxs)(u,{children:[(0,yn.jsx)(l,{color:c.text.primary,wrap:"truncate-end",children:t===$e.LOGIN_WITH_GOOGLE?(0,yn.jsxs)(l,{children:[(0,yn.jsxs)(l,{bold:!0,children:["Signed in with Google",o?":":""]}),o?` ${o}`:""]}):`Authenticated with ${t}`}),(0,yn.jsx)(l,{color:c.text.secondary,children:" /auth"})]}),n&&(0,yn.jsxs)(u,{children:[(0,yn.jsxs)(l,{color:c.text.primary,wrap:"truncate-end",children:[(0,yn.jsx)(l,{bold:!0,children:"Plan:"})," ",n]}),!s&&(0,yn.jsx)(l,{color:c.text.secondary,children:" /upgrade"})]})]}):null};var ui=C(P(),1);var tR=({config:e})=>{let t=e.getGeminiMdFileCount();return(0,ui.jsxs)(u,{flexDirection:"column",marginTop:1,children:[(0,ui.jsx)(l,{color:c.text.primary,children:"Tips for getting started:"}),t===0&&(0,ui.jsxs)(l,{color:c.text.primary,children:["1. Create ",(0,ui.jsx)(l,{bold:!0,children:"GEMINI.md"})," files to customize your interactions"]}),(0,ui.jsxs)(l,{color:c.text.primary,children:[t===0?"2.":"1."," ",(0,ui.jsx)(l,{color:c.text.secondary,children:"/help"})," for more information"]}),(0,ui.jsxs)(l,{color:c.text.primary,children:[t===0?"3.":"2."," Ask coding questions, edit code or run commands"]}),(0,ui.jsxs)(l,{color:c.text.primary,children:[t===0?"4.":"3."," Be specific for the best results"]})]})};var Dl=C(P(),1);function aM(e,t,o){return e.replace(/\\n/g,`
30
30
  `).split(`
31
31
  `).map((s,i)=>i===0?t?(0,Dl.jsx)(l,{bold:!0,color:c.status.warning,children:s},i):(0,Dl.jsx)(Ta,{children:(0,Dl.jsx)(l,{bold:!0,children:s})},i):(0,Dl.jsx)(l,{color:o,children:s},i))}var oR=({bannerText:e,isWarning:t,width:o})=>{let r=c.text.primary,n=aM(e,t,r);return(0,Dl.jsx)(u,{flexDirection:"column",borderStyle:"round",borderColor:t?c.status.warning:c.border.default,width:o,paddingLeft:1,paddingRight:1,children:n})};var cm=C(z(),1);import lM from"node:crypto";var cM=5,rR=new Set;function um(e){let{defaultText:t,warningText:o}=e,[r]=(0,cm.useState)(()=>Go.get("defaultBannerShownCount")||{}),n=o||t,s=lM.createHash("sha256").update(n).digest("hex"),i=r[s]||0,a=n!==""&&i<cM,m=(a?n:"").replace(/\\n/g,`
32
32
  `);return(0,cm.useEffect)(()=>{if(a&&n&&!rR.has(n)){rR.add(n);let f=Go.get("defaultBannerShownCount")||{},h=f[s]||0;Go.set("defaultBannerShownCount",{...f,[s]:h+1})}},[a,n,s]),{bannerText:m}}var dm=C(z(),1);function nR(){let[e]=(0,dm.useState)(()=>Go.get("tipsShown")??0),t=e<10;return(0,dm.useEffect)(()=>{t&&Go.set("tipsShown",e+1)},[e,t]),{showTips:t}}var Yf=`
@@ -57,12 +57,12 @@ def fibonacci(n):
57
57
  @@ -1,2 +1,2 @@
58
58
  - print("Hello, " + name)
59
59
  + print(f"Hello, {name}!")
60
- `,availableTerminalHeight:i===!1?W:void 0,terminalWidth:b,theme:L})]}),eS&&(0,Rt.jsx)(u,{marginTop:1,children:(0,Rt.jsx)(hR,{activeTheme:L})})]})]}):(0,Rt.jsx)(gR,{onSelect:E,onHighlight:A,isFocused:T==="scope",initialScope:d}),(0,Rt.jsx)(u,{marginTop:1,children:(0,Rt.jsxs)(l,{color:c.text.secondary,wrap:"truncate",children:["(Use Enter to ",T==="theme"?"select":"apply scope",", Tab to"," ",T==="theme"?"configure scope":"select theme",", Esc to close)"]})})]})}var ro=C(z(),1);var ki=C(z(),1);var ig=C(dd(),1);var Ni=C(z(),1);function ng(e,t,o,r){t<e?e=t:t>=e+r&&(e=t-r+1);let n=Math.max(0,o-r),s=Math.min(e,n);return Math.max(0,s)}function FM(e,t){return function(r,n){if(e.length===0)return r;let s=e.findIndex(a=>a.key===r.activeItemKey),i=s!==-1?s:0;switch(n.type){case"MOVE_UP":{let a=i>0?i-1:e.length-1;return{activeItemKey:e[a].key,windowStart:ng(r.windowStart,a,e.length,t)}}case"MOVE_DOWN":{let a=i<e.length-1?i+1:0;return{activeItemKey:e[a].key,windowStart:ng(r.windowStart,a,e.length,t)}}default:return r}}}function SR({items:e,maxItemsToShow:t}){let o=(0,Ni.useMemo)(()=>FM(e,t),[e,t]),[r,n]=(0,Ni.useReducer)(o,{activeItemKey:e[0]?.key??null,windowStart:0}),s=(0,Ni.useMemo)(()=>{if(e.length===0)return 0;let m=e.findIndex(f=>f.key===r.activeItemKey);return m!==-1?m:0},[e,r.activeItemKey]),i=(0,Ni.useMemo)(()=>ng(r.windowStart,s,e.length,t),[r.windowStart,s,e.length,t]),a=(0,Ni.useCallback)(()=>n({type:"MOVE_UP"}),[]),d=(0,Ni.useCallback)(()=>n({type:"MOVE_DOWN"}),[]);return{activeItemKey:r.activeItemKey,activeIndex:s,windowStart:i,moveUp:a,moveDown:d}}var Bi=C(z(),1);var CR={editingKey:null,buffer:"",cursorPos:0};function UM(e,t){switch(t.type){case"START_EDIT":return{editingKey:t.key,buffer:t.initialValue,cursorPos:to(t.initialValue)};case"COMMIT_EDIT":return CR;case"MOVE_LEFT":return{...e,cursorPos:Math.max(0,e.cursorPos-1)};case"MOVE_RIGHT":return{...e,cursorPos:Math.min(to(e.buffer),e.cursorPos+1)};case"HOME":return{...e,cursorPos:0};case"END":return{...e,cursorPos:to(e.buffer)};case"DELETE_LEFT":{if(e.cursorPos===0)return e;let o=Ut(e.buffer,0,e.cursorPos-1),r=Ut(e.buffer,e.cursorPos);return{...e,buffer:o+r,cursorPos:e.cursorPos-1}}case"DELETE_RIGHT":{if(e.cursorPos===to(e.buffer))return e;let o=Ut(e.buffer,0,e.cursorPos),r=Ut(e.buffer,e.cursorPos+1);return{...e,buffer:o+r}}case"INSERT_CHAR":{let o=t.char,r=!1;if(t.isNumberType?r=/[0-9\-+.]/.test(o):(r=o.length===1&&o.charCodeAt(0)>=32,o=ln(o)),!r||o.length===0)return e;let n=Ut(e.buffer,0,e.cursorPos),s=Ut(e.buffer,e.cursorPos);return{...e,buffer:n+o+s,cursorPos:e.cursorPos+1}}default:return e}}function bR({onCommit:e}){let[t,o]=(0,Bi.useReducer)(UM,CR),[r,n]=(0,Bi.useState)(!0);(0,Bi.useEffect)(()=>{if(!t.editingKey){n(!0);return}n(!0);let a=setInterval(()=>{n(d=>!d)},500);return()=>clearInterval(a)},[t.editingKey,t.buffer,t.cursorPos]);let s=(0,Bi.useCallback)((a,d)=>{o({type:"START_EDIT",key:a,initialValue:d})},[]),i=(0,Bi.useCallback)(()=>{t.editingKey&&e(t.editingKey,t.buffer),o({type:"COMMIT_EDIT"})},[t.editingKey,t.buffer,e]);return{editState:t,editDispatch:o,startEditing:s,commitEdit:i,cursorVisible:r}}var et=C(P(),1);function ym({title:e,borderColor:t,searchEnabled:o=!0,searchPlaceholder:r="Search to filter",searchBuffer:n,items:s,showScopeSelector:i=!0,scopeItems:a,selectedScope:d,onScopeChange:m,maxItemsToShow:f,maxLabelWidth:h,onItemToggle:p,onEditCommit:y,onItemClear:g,onClose:x,onKeyPress:S,keyMatchers:I,availableHeight:A,footer:E}){let T=Ze(),v=I??T,R=(0,ki.useMemo)(()=>(a??Ml()).map(j=>({...j,key:j.value})),[a]),b=i&&R.length>1,{effectiveMaxItemsToShow:_,finalShowScopeSelector:w}=(0,ki.useMemo)(()=>{let j=b,$=f;if(!A)return{effectiveMaxItemsToShow:$,finalShowScopeSelector:j};let X=4,Q=1,be=o?5:1,De=2,ke=1,ue=5,Ue=1,Tt=E?.height??0,It=3,An=A-X,Jr=Q+be+De+ke+Ue+Tt,cr=Jr+ue,ko=An-cr,Zr=Math.max(1,Math.floor(ko/It)),Lt=An-Jr,ur=Math.max(1,Math.floor(Lt/It)),Fn=j,Si=j?Zr:ur;return j&&A<25&&ur>Zr+1&&(Fn=!1,Si=ur),{effectiveMaxItemsToShow:Math.min(Si,s.length),finalShowScopeSelector:Fn}},[A,f,s.length,o,b,E]),{activeIndex:M,windowStart:D,moveUp:N,moveDown:O}=SR({items:s,maxItemsToShow:_}),{editState:W,editDispatch:L,startEditing:k,commitEdit:F,cursorVisible:B}=bR({onCommit:(j,$)=>{let X=s.find(Q=>Q.key===j);X&&y(j,$,X)}}),{editingKey:K,buffer:q,cursorPos:Z}=W,[Y,oe]=(0,ki.useState)("settings"),ce=!w&&Y==="scope"?"settings":Y,G=s.slice(D,D+_),ee=s.length>_,te=s.length>_,ae=s[M],ne=(0,ki.useCallback)(j=>{m?.(j)},[m]);return me(j=>{if(!(!K&&S?.(j,ae))){if(K){let X=s.find(Q=>Q.key===K)?.type??"string";if(v["cursor.left"](j)){L({type:"MOVE_LEFT"});return}if(v["cursor.right"](j)){L({type:"MOVE_RIGHT"});return}if(v["cursor.home"](j)){L({type:"HOME"});return}if(v["cursor.end"](j)){L({type:"END"});return}if(v["edit.deleteLeft"](j)){L({type:"DELETE_LEFT"});return}if(v["edit.deleteRight"](j)){L({type:"DELETE_RIGHT"});return}if(v["basic.cancel"](j)){F();return}if(v["basic.confirm"](j)){F();return}if(v["nav.dialog.up"](j)&&!j.insertable){F(),N();return}if(v["nav.dialog.down"](j)&&!j.insertable){F(),O();return}j.sequence&&L({type:"INSERT_CHAR",char:j.sequence,isNumberType:X==="number"});return}if(ce==="settings"){if(v["nav.dialog.up"](j))return N(),!0;if(v["nav.dialog.down"](j))return O(),!0;if(v["basic.confirm"](j)&&ae){if(ae.type==="boolean"||ae.type==="enum")p(ae.key,ae);else{let $=ae.rawValue,X=ae.editValue??($!==void 0?String($):"");k(ae.key,X)}return!0}if(v["app.clearScreen"](j)&&ae)return g(ae.key,ae),!0;if(ae?.type==="number"&&/^[0-9]$/.test(j.sequence))return k(ae.key,j.sequence),!0}if(j.name==="tab"&&w){oe($=>$==="settings"?"scope":"settings");return}if(v["basic.cancel"](j)){x();return}}},{isActive:!0,priority:ce==="settings"}),(0,et.jsx)(u,{borderStyle:"round",borderColor:t??c.border.default,flexDirection:"row",padding:1,width:"100%",maxHeight:A,children:(0,et.jsxs)(u,{flexDirection:"column",flexGrow:1,children:[(0,et.jsx)(u,{marginX:1,children:(0,et.jsxs)(l,{bold:ce==="settings"&&!K,wrap:"truncate",children:[ce==="settings"?"> ":" ",e," "]})}),o&&n&&(0,et.jsx)(u,{borderStyle:"round",borderColor:K?c.border.default:ce==="settings"?c.ui.focus:c.border.default,paddingX:1,height:3,marginTop:1,children:(0,et.jsx)(ua,{focus:ce==="settings"&&!K,buffer:n,placeholder:r})}),(0,et.jsx)(u,{height:1}),G.length===0?(0,et.jsx)(u,{marginX:1,height:1,flexDirection:"column",children:(0,et.jsx)(l,{color:c.text.secondary,children:"No matches found."})}):(0,et.jsxs)(et.Fragment,{children:[ee&&(0,et.jsx)(u,{marginX:1,children:(0,et.jsx)(l,{color:c.text.secondary,children:"\u25B2"})}),G.map((j,$)=>{let X=$+D,Q=ce==="settings"&&M===X,be;if(K===j.key)if(B&&Z<to(q)){let De=Ut(q,0,Z),ke=Ut(q,Z,Z+1),ue=Ut(q,Z+1);be=De+ig.default.inverse(ke)+ue}else Z>=to(q)?be=q+(B?ig.default.inverse(" "):" "):be=q;else be=j.displayValue;return(0,et.jsxs)(ki.default.Fragment,{children:[(0,et.jsxs)(u,{marginX:1,flexDirection:"row",alignItems:"flex-start",backgroundColor:Q?c.background.focus:void 0,children:[(0,et.jsx)(u,{minWidth:2,flexShrink:0,children:(0,et.jsx)(l,{color:Q?c.ui.focus:c.text.secondary,children:Q?"\u25CF":""})}),(0,et.jsxs)(u,{flexDirection:"row",flexGrow:1,minWidth:0,alignItems:"flex-start",children:[(0,et.jsxs)(u,{flexDirection:"column",width:h,minWidth:0,children:[(0,et.jsxs)(l,{color:Q?c.ui.focus:c.text.primary,children:[j.label,j.scopeMessage&&(0,et.jsxs)(l,{color:c.text.secondary,children:[" ",j.scopeMessage]})]}),(0,et.jsx)(l,{color:c.text.secondary,wrap:"truncate",children:j.description??""})]}),(0,et.jsx)(u,{minWidth:3}),(0,et.jsx)(u,{flexShrink:0,children:(0,et.jsx)(l,{color:Q?c.ui.focus:j.isGreyedOut?c.text.secondary:c.text.primary,terminalCursorFocus:K===j.key&&B,terminalCursorPosition:ud(q,Z),children:be})})]})]}),(0,et.jsx)(u,{height:1})]},j.key)}),te&&(0,et.jsx)(u,{marginX:1,children:(0,et.jsx)(l,{color:c.text.secondary,children:"\u25BC"})})]}),(0,et.jsx)(u,{height:1}),w&&(0,et.jsxs)(u,{marginX:1,flexDirection:"column",children:[(0,et.jsxs)(l,{bold:ce==="scope",wrap:"truncate",children:[ce==="scope"?"> ":" ","Apply To"]}),(0,et.jsx)(We,{items:R,initialIndex:R.findIndex(j=>j.value===d),onSelect:ne,onHighlight:ne,isFocused:ce==="scope",showNumbers:ce==="scope",priority:ce==="scope"})]}),(0,et.jsx)(u,{height:1}),(0,et.jsx)(u,{marginX:1,children:(0,et.jsxs)(l,{color:c.text.secondary,children:["(Use Enter to select, ",Ee("app.clearScreen")," to reset",w?", Tab to change focus":"",", Esc to close)"]})}),E&&(0,et.jsx)(u,{marginX:1,children:E.content})]})})}var sg=C(P(),1);var GM=8,WM=new Ic("up"),VM=new Ic("ctrl+p"),$M=new Ic("down"),qM=new Ic("ctrl+n");function KM(e){let t=new Map,o=[["User",e.user.settings],["Workspace",e.workspace.settings],["System",e.system.settings]];for(let r of OS()){let n=new Map;for(let[s,i]of o){let a=aa(r,i)?Ec(r,i):void 0;n.set(s,JSON.stringify(a))}t.set(r,n)}return t}function ER({onSelect:e,onRestartRequest:t,availableTerminalHeight:o}){let{settings:r,setSetting:n}=gd(),[s,i]=(0,ro.useState)("User"),a=(0,ro.useMemo)(()=>Ml().filter(k=>{let F=r.forScope(k.value);return F.readOnly!==!0&&(k.value!=="Workspace"||F.path!==void 0)}),[r]),d=a.find(k=>k.value===s)?.value??a[0]?.value,m=d??"User";d&&s!==d&&i(d);let[f]=(0,ro.useState)(()=>KM(r)),[h,p]=(0,ro.useState)(""),[y,g]=(0,ro.useState)(()=>sl()),{fzfInstance:x,searchMap:S}=(0,ro.useMemo)(()=>{let k=sl(),F=new Map,B=[];return k.forEach(q=>{let Z=il(q);Z?.label&&(B.push(Z.label),F.set(Z.label.toLowerCase(),q))}),{fzfInstance:new ta(B,{fuzzy:"v2",casing:"case-insensitive"}),searchMap:F}},[]);(0,ro.useEffect)(()=>{let k=!0;if(!h.trim()||!x){g(sl());return}return(async()=>{let B=await x.find(h);if(!k)return;let K=new Set;B.forEach(q=>{let Z=S.get(q.item.toLowerCase());Z&&K.add(Z)}),g(Array.from(K))})(),()=>{k=!1}},[h,x,S]);let A=(0,ro.useMemo)(()=>{let k=new Set,F=[["User",r.user.settings],["Workspace",r.workspace.settings],["System",r.system.settings]];for(let[B,K]of f)for(let[q,Z]of F){let Y=aa(B,Z)?Ec(B,Z):void 0,oe=K.get(q);if(JSON.stringify(Y)!==oe){k.add(B);break}}return k},[r,f]).size>0,E=(0,ro.useMemo)(()=>{let k=sl(),F=0;for(let B of k){let K=il(B);if(!K)continue;let q=Uc(B,m,r),Y=(K.label||B)+(q?` ${q}`:""),oe=$r(Y),ce=K.description?$r(K.description):0;F=Math.max(F,oe,ce)}return F},[m,r]),T=RC({initialText:"",onChange:p}),v=h?y:sl(),R=(0,ro.useMemo)(()=>{let k=r.forScope(m).settings,F=r.merged;return v.map(B=>{let K=il(B),q=K?.type??"string",Z=LS(B,k,F),Y=Uc(B,m,r),oe=!aa(B,k),ce=Ec(B,k),G=BS(q,ce);return{key:B,label:K?.label||B,description:K?.description,type:q,displayValue:Z,isGreyedOut:oe,scopeMessage:Y,rawValue:ce,editValue:G}})},[v,m,r]),b=(0,ro.useCallback)(k=>{i(k)},[]),_=(0,ro.useCallback)((k,F)=>{if(!d)return;let B=il(k);if(!vS.has(B?.type))return;let K=r.forScope(d).settings,q=Ec(k,K),Z;if(B?.type==="boolean"){if(typeof q!="boolean")return;Z=!q}else if(B?.type==="enum"&&B.options){let Y=B.options;if(Y.length===0)return;let oe=Y?.findIndex(ce=>ce.value===q);oe!==-1&&oe<Y.length-1?Z=Y[oe+1].value:Z=Y[0].value}else return;de.log(`[DEBUG SettingsDialog] Saving ${k} immediately with value:`,Z),n(d,k,Z)},[r,d,n]),w=(0,ro.useCallback)((k,F,B)=>{if(!d)return;let q=il(k)?.type??"string",Z=NS(q,F);Z!==null&&n(d,k,Z)},[d,n]),M=(0,ro.useCallback)((k,F)=>{d&&n(d,k,void 0)},[d,n]),D=(0,ro.useCallback)(()=>{e(void 0,m)},[e,m]),N=Ze(),O=(0,ro.useMemo)(()=>({...N,"nav.dialog.up":k=>WM.matches(k)||VM.matches(k),"nav.dialog.down":k=>$M.matches(k)||qM.matches(k)}),[N]),W=(0,ro.useCallback)((k,F)=>A&&k.sequence==="r"?(t&&t(),!0):!1,[A,t]),L=!A;return(0,sg.jsx)(ym,{title:"Settings",borderColor:A?c.status.warning:void 0,searchEnabled:L,searchBuffer:T,items:R,showScopeSelector:a.length>1,scopeItems:a,selectedScope:m,onScopeChange:b,maxItemsToShow:GM,availableHeight:o,maxLabelWidth:E,onItemToggle:_,onEditCommit:w,onItemClear:M,onClose:D,onKeyPress:W,keyMatchers:O,footer:A?{content:(0,sg.jsx)(l,{color:c.status.warning,children:"Changes that require a restart have been modified. Press r to exit and apply changes now."}),height:1}:void 0})}var Tm=C(z(),1);var Ia=C(P(),1);function RR({onTimeout:e}){let[t,o]=(0,Tm.useState)(!1);return me(r=>{(r.name==="escape"||r.ctrl&&r.name==="c")&&e()},{isActive:!0}),(0,Tm.useEffect)(()=>{let r=setTimeout(()=>{o(!0),e()},18e4);return()=>clearTimeout(r)},[e]),(0,Ia.jsx)(u,{borderStyle:"round",borderColor:c.border.default,flexDirection:"column",padding:1,width:"100%",children:t?(0,Ia.jsx)(l,{color:c.status.error,children:"Authentication timed out. Please try again."}):(0,Ia.jsx)(u,{children:(0,Ia.jsxs)(l,{children:[(0,Ia.jsx)(Mo,{type:"dots"})," Waiting for authentication... (Press Esc or Ctrl+C to cancel)"]})})})}var xm=C(z(),1);var On=C(z(),1);function ag(e,t){let o=t.merged.security.auth.enforcedType;return o&&o!==e?`Authentication is enforced to be ${o}, but you are currently using ${e}.`:t.merged.security.auth.useExternal||e===qe.USE_GEMINI?null:Dd(e)}var vR=(e,t,o=null,r=null)=>{let[n,s]=(0,On.useState)(o?"updating":"unauthenticated"),[i,a]=(0,On.useState)(o),[d,m]=(0,On.useState)(r),[f,h]=(0,On.useState)(void 0),p=(0,On.useCallback)(g=>{a(g),g&&s("updating")},[a,s]),y=(0,On.useCallback)(async()=>{let g=process.env.GEMINI_API_KEY;if(g!==void 0)return h(g),g;let x=await Cx()??"";return h(x),x},[]);return(0,On.useEffect)(()=>{n==="awaiting_api_key_input"&&y()},[n,y]),(0,On.useEffect)(()=>{(async()=>{if(n!=="unauthenticated")return;let g=e.merged.security.auth.selectedType;if(!g){process.env.GEMINI_API_KEY?p('Existing API key detected (GEMINI_API_KEY). Select "Gemini API Key" option to use it.'):p("No authentication method selected.");return}if(g===qe.USE_GEMINI&&!await y()){s("awaiting_api_key_input");return}let x=ag(g,e);if(x){p(x);return}let S=process.env.GEMINI_DEFAULT_AUTH_TYPE;if(S&&!Object.values(qe).includes(S)){p(`Invalid value for GEMINI_DEFAULT_AUTH_TYPE: "${S}". Valid values are: ${Object.values(qe).join(", ")}.`);return}try{await t.refreshAuth(g),de.log(`Authenticated via "${g}".`),a(null),s("authenticated")}catch(I){let A=uT(I);A?m({message:A.message,appealUrl:A.appealUrl,appealLinkText:A.appealLinkText}):I instanceof rd?p(Vr(I)):p(`Failed to sign in. Message: ${Vr(I)}`)}})()},[e,t,n,s,a,p,y]),{authState:n,setAuthState:s,authError:i,onAuthError:p,apiKeyDefaultValue:f,reloadApiKey:y,accountSuspensionInfo:d,setAccountSuspensionInfo:m}};var mo=C(P(),1);function AR({config:e,settings:t,setAuthState:o,authError:r,onAuthError:n,setAuthContext:s}){let[i,a]=(0,xm.useState)(!1),d=[{label:"Sign in with Google",value:qe.LOGIN_WITH_GOOGLE,key:qe.LOGIN_WITH_GOOGLE},...process.env.CLOUD_SHELL==="true"?[{label:"Use Cloud Shell user credentials",value:qe.COMPUTE_ADC,key:qe.COMPUTE_ADC}]:process.env.GEMINI_CLI_USE_COMPUTE_ADC==="true"?[{label:"Use metadata server application default credentials",value:qe.COMPUTE_ADC,key:qe.COMPUTE_ADC}]:[],{label:"Use Gemini API Key",value:qe.USE_GEMINI,key:qe.USE_GEMINI},{label:"Vertex AI",value:qe.USE_VERTEX_AI,key:qe.USE_VERTEX_AI}];t.merged.security.auth.enforcedType&&(d=d.filter(g=>g.value===t.merged.security.auth.enforcedType));let m=null,f=process.env.GEMINI_DEFAULT_AUTH_TYPE;f&&Object.values(qe).includes(f)&&(m=f);let h=d.findIndex(g=>t.merged.security.auth.selectedType?g.value===t.merged.security.auth.selectedType:m?g.value===m:process.env.GEMINI_API_KEY?g.value===qe.USE_GEMINI:g.value===qe.LOGIN_WITH_GOOGLE);t.merged.security.auth.enforcedType&&(h=0);let p=(0,xm.useCallback)(async(g,x)=>{if(!i){if(g){let S=g===qe.LOGIN_WITH_GOOGLE||g===qe.USE_VERTEX_AI&&process.env.CLOUD_SHELL==="true";if(s(S?{requiresRestart:!0}:{}),await ed(),t.setValue(x,"security.auth.selectedType",g),g===qe.LOGIN_WITH_GOOGLE&&e.isBrowserLaunchSuppressed()){a(!0),setTimeout(fr,100);return}if(g===qe.USE_GEMINI){o("awaiting_api_key_input");return}}o("unauthenticated")}},[t,e,o,i,s]),y=g=>{let x=ag(g,t);x?n(x):p(g,"User")};return me(g=>g.name==="escape"?r?!0:t.merged.security.auth.selectedType===void 0?(n("You must select an auth method to proceed. Press Ctrl+C twice to exit."),!0):(p(void 0,"User"),!0):!1,{isActive:!0}),i?(0,mo.jsx)(u,{borderStyle:"round",borderColor:c.ui.focus,flexDirection:"row",padding:1,width:"100%",alignItems:"flex-start",children:(0,mo.jsx)(l,{color:c.text.primary,children:"Logging in with Google... Restarting Gemini CLI to continue."})}):(0,mo.jsxs)(u,{borderStyle:"round",borderColor:c.ui.focus,flexDirection:"row",padding:1,width:"100%",alignItems:"flex-start",children:[(0,mo.jsx)(l,{color:c.text.accent,children:"? "}),(0,mo.jsxs)(u,{flexDirection:"column",flexGrow:1,children:[(0,mo.jsx)(l,{bold:!0,color:c.text.primary,children:"Get started"}),(0,mo.jsx)(u,{marginTop:1,children:(0,mo.jsx)(l,{color:c.text.primary,children:"How would you like to authenticate for this project?"})}),(0,mo.jsx)(u,{marginTop:1,children:(0,mo.jsx)(We,{items:d,initialIndex:h,onSelect:y,onHighlight:()=>{n(null)}})}),r&&(0,mo.jsx)(u,{marginTop:1,children:(0,mo.jsx)(l,{color:c.status.error,children:r})}),(0,mo.jsx)(u,{marginTop:1,children:(0,mo.jsx)(l,{color:c.text.secondary,children:"(Use Enter to select)"})}),(0,mo.jsx)(u,{marginTop:1,children:(0,mo.jsx)(l,{color:c.text.primary,children:"Terms of Services and Privacy Notice for Gemini CLI"})}),(0,mo.jsx)(u,{marginTop:1,children:(0,mo.jsx)(l,{color:c.text.link,children:"https://geminicli.com/docs/resources/tos-privacy/"})})]})]})}var va=C(z(),1);var Ro=C(P(),1);function wR({accountSuspensionInfo:e,onExit:t,onChangeAuth:o}){let[r,n]=(0,va.useState)(null),s=e.appealUrl,i=e.appealLinkText??"Open the Google Form",a=(0,va.useMemo)(()=>{let f=[];return s&&f.push({label:i,value:"open_form",key:"open_form"}),f.push({label:"Change authentication",value:"change_auth",key:"change_auth"},{label:"Exit",value:"exit",key:"exit"}),f},[s,i]);me(f=>f.name==="escape"?(d(),!0):!1,{isActive:!0});let d=(0,va.useCallback)(async()=>{await jn(),t()},[t]),m=(0,va.useCallback)(async f=>{if(f==="open_form"&&s){if(!el()){n(`Please open this URL in a browser: ${s}`);return}try{await Za(s)}catch{n(`Failed to open browser. Please visit: ${s}`)}}else f==="change_auth"?o():await d()},[d,o,s]);return(0,Ro.jsxs)(u,{flexDirection:"column",padding:1,children:[(0,Ro.jsx)(l,{bold:!0,color:c.status.error,children:"Error: Account Suspended"}),(0,Ro.jsx)(u,{marginTop:1,children:(0,Ro.jsx)(l,{children:e.message})}),s&&(0,Ro.jsxs)(Ro.Fragment,{children:[(0,Ro.jsx)(u,{marginTop:1,children:(0,Ro.jsx)(l,{children:"Appeal URL:"})}),(0,Ro.jsx)(u,{children:(0,Ro.jsxs)(l,{color:c.text.link,children:["[",s,"]"]})})]}),r&&(0,Ro.jsx)(u,{marginTop:1,children:(0,Ro.jsx)(l,{color:c.status.error,children:r})}),(0,Ro.jsx)(u,{marginTop:1,children:(0,Ro.jsx)(We,{items:a,onSelect:f=>void m(f)})}),(0,Ro.jsx)(u,{marginTop:1,children:(0,Ro.jsx)(l,{dimColor:!0,children:"Escape to exit"})})]})}var Sm=C(z(),1);var Cr=C(P(),1);function _R({onSubmit:e,onCancel:t,error:o,defaultValue:r=""}){let n=Ze(),{terminalWidth:s}=Ce(),i=s-8,a=(0,Sm.useRef)(null);(0,Sm.useEffect)(()=>()=>{a.current?.cancel()},[]);let d=r,m=ca({initialText:d||"",initialCursorOffset:d?.length||0,viewport:{width:i,height:4},inputFilter:p=>p.replace(/[^a-zA-Z0-9_.-]/g,"").replace(/[\r\n]/g,""),singleLine:!0}),f=p=>{e(p)},h=()=>{a.current?.cancel();let p=!1,y=new Promise((g,x)=>{Ex().then(()=>!p&&g(),S=>!p&&x(S))});return a.current={cancel:()=>{p=!0}},y.then(()=>{m.setText("")}).catch(g=>{de.debug("Failed to clear API key:",g)})};return me(p=>n["edit.clear"](p)?(h(),!0):!1,{isActive:!0}),(0,Cr.jsxs)(u,{borderStyle:"round",borderColor:c.ui.focus,flexDirection:"column",padding:1,width:"100%",children:[(0,Cr.jsx)(l,{bold:!0,color:c.text.primary,children:"Enter Gemini API Key"}),(0,Cr.jsxs)(u,{marginTop:1,flexDirection:"column",children:[(0,Cr.jsx)(l,{color:c.text.primary,children:"Please enter your Gemini API key. It will be securely stored in your system keychain."}),(0,Cr.jsxs)(l,{color:c.text.secondary,children:["You can get an API key from"," ",(0,Cr.jsx)(l,{color:c.text.link,children:"https://aistudio.google.com/app/apikey"})]})]}),(0,Cr.jsx)(u,{marginTop:1,flexDirection:"row",children:(0,Cr.jsx)(u,{borderStyle:"round",borderColor:c.border.default,paddingX:1,flexGrow:1,children:(0,Cr.jsx)(ua,{buffer:m,onSubmit:f,onCancel:t,placeholder:"Paste your API key here"})})}),o&&(0,Cr.jsx)(u,{marginTop:1,children:(0,Cr.jsx)(l,{color:c.status.error,children:o})}),(0,Cr.jsx)(u,{marginTop:1,children:(0,Cr.jsx)(l,{color:c.text.secondary,children:"(Press Enter to submit, Esc to cancel, Ctrl+C to clear stored key)"})})]})}var cg=C(z(),1);var lg=class{availableEditors;constructor(){let t=Object.keys(Sc).sort();this.availableEditors=[{name:"None",type:"not_set",disabled:!1},...t.map(o=>{let r=td(o),n=od(o),s=n?"":" (Not available in sandbox)";return s=r?s:" (Not installed)",{name:Sc[o]+s,type:o,disabled:!r||!n}})]}getAvailableEditorDisplays(){return this.availableEditors}},DR=new lg;var No=C(P(),1);function MR({onSelect:e,settings:t,onExit:o}){let[r,n]=(0,cg.useState)("User"),[s,i]=(0,cg.useState)("editor");me(S=>S.name==="tab"?(i(I=>I==="editor"?"scope":"editor"),!0):S.name==="escape"?(o(),!0):!1,{isActive:!0});let a=DR.getAvailableEditorDisplays(),d=t.forScope(r).settings.general?.preferredEditor,m=d?a.findIndex(S=>S.type===d):0;m===-1&&(Se.emitFeedback("error",`Editor is not supported: ${d}`),m=0);let f=[{label:"User Settings",value:"User",key:"User"},{label:"Workspace Settings",value:"Workspace",key:"Workspace"}],h=S=>{if(S==="not_set"){e(void 0,r);return}e(S,r)},p=S=>{n(S),i("editor")},y="",g=r==="User"?"Workspace":"User";t.forScope(g).settings.general?.preferredEditor!==void 0&&(y=t.forScope(r).settings.general?.preferredEditor!==void 0?`(Also modified in ${g})`:`(Modified in ${g})`);let x="None";return t.merged.general.preferredEditor&&ux(t.merged.general.preferredEditor)&&(x=Sc[t.merged.general.preferredEditor]),(0,No.jsxs)(u,{borderStyle:"round",borderColor:c.border.default,flexDirection:"row",padding:1,width:"100%",children:[(0,No.jsxs)(u,{flexDirection:"column",width:"45%",paddingRight:2,children:[(0,No.jsxs)(l,{bold:s==="editor",children:[s==="editor"?"> ":" ","Select Editor"," ",(0,No.jsx)(l,{color:c.text.secondary,children:y})]}),(0,No.jsx)(We,{items:a.map(S=>({label:S.name,value:S.type,disabled:S.disabled,key:S.type})),initialIndex:m,onSelect:h,isFocused:s==="editor"},r),(0,No.jsxs)(u,{marginTop:1,flexDirection:"column",children:[(0,No.jsxs)(l,{bold:s==="scope",children:[s==="scope"?"> ":" ","Apply To"]}),(0,No.jsx)(We,{items:f,initialIndex:0,onSelect:p,isFocused:s==="scope"})]}),(0,No.jsx)(u,{marginTop:1,children:(0,No.jsx)(l,{color:c.text.secondary,children:"(Use Enter to select, Tab to change focus, Esc to close)"})})]}),(0,No.jsxs)(u,{flexDirection:"column",width:"55%",paddingLeft:2,children:[(0,No.jsx)(l,{bold:!0,color:c.text.primary,children:"Editor Preference"}),(0,No.jsxs)(u,{flexDirection:"column",gap:1,marginTop:1,children:[(0,No.jsx)(l,{color:c.text.secondary,children:"These editors are currently supported. Please note that some editors cannot be used in sandbox mode."}),(0,No.jsxs)(l,{color:c.text.secondary,children:["Your preferred editor is:"," ",(0,No.jsx)(l,{color:x==="None"?c.status.error:c.text.link,bold:!0,children:x}),"."]})]})]})]})}var no=C(P(),1);var PR=({onExit:e})=>(me(t=>t.name==="escape"?(e(),!0):!1,{isActive:!0}),(0,no.jsxs)(u,{flexDirection:"column",marginBottom:1,children:[(0,no.jsx)(l,{bold:!0,color:c.text.accent,children:"Gemini API Key Notice"}),(0,no.jsx)(Uo,{}),(0,no.jsxs)(l,{color:c.text.primary,children:["By using the Gemini API",(0,no.jsx)(l,{color:c.text.link,children:"[1]"}),", Google AI Studio",(0,no.jsx)(l,{color:c.status.error,children:"[2]"}),', and the other Google developer services that reference these terms (collectively, the "APIs" or "Services"), you are agreeing to Google APIs Terms of Service (the "API Terms")',(0,no.jsx)(l,{color:c.status.success,children:"[3]"}),', and the Gemini API Additional Terms of Service (the "Additional Terms")',(0,no.jsx)(l,{color:c.text.accent,children:"[4]"}),"."]}),(0,no.jsx)(Uo,{}),(0,no.jsxs)(l,{color:c.text.primary,children:[(0,no.jsx)(l,{color:c.text.link,children:"[1]"})," ","https://ai.google.dev/docs/gemini_api_overview"]}),(0,no.jsxs)(l,{color:c.text.primary,children:[(0,no.jsx)(l,{color:c.status.error,children:"[2]"})," https://aistudio.google.com/"]}),(0,no.jsxs)(l,{color:c.text.primary,children:[(0,no.jsx)(l,{color:c.status.success,children:"[3]"})," ","https://developers.google.com/terms"]}),(0,no.jsxs)(l,{color:c.text.primary,children:[(0,no.jsx)(l,{color:c.text.accent,children:"[4]"})," ","https://ai.google.dev/gemini-api/terms"]}),(0,no.jsx)(Uo,{}),(0,no.jsx)(l,{color:c.text.secondary,children:"Press Esc to exit."})]}));var br=C(P(),1);var OR=({onExit:e})=>(me(t=>t.name==="escape"?(e(),!0):!1,{isActive:!0}),(0,br.jsxs)(u,{flexDirection:"column",marginBottom:1,children:[(0,br.jsx)(l,{bold:!0,color:c.text.accent,children:"Vertex AI Notice"}),(0,br.jsx)(Uo,{}),(0,br.jsxs)(l,{color:c.text.primary,children:["Service Specific Terms",(0,br.jsx)(l,{color:c.text.link,children:"[1]"})," are incorporated into the agreement under which Google has agreed to provide Google Cloud Platform",(0,br.jsx)(l,{color:c.status.success,children:"[2]"})," to Customer (the \u201CAgreement\u201D). If the Agreement authorizes the resale or supply of Google Cloud Platform under a Google Cloud partner or reseller program, then except for in the section entitled \u201CPartner-Specific Terms\u201D, all references to Customer in the Service Specific Terms mean Partner or Reseller (as applicable), and all references to Customer Data in the Service Specific Terms mean Partner Data. Capitalized terms used but not defined in the Service Specific Terms have the meaning given to them in the Agreement."]}),(0,br.jsx)(Uo,{}),(0,br.jsxs)(l,{color:c.text.primary,children:[(0,br.jsx)(l,{color:c.text.link,children:"[1]"})," ","https://cloud.google.com/terms/service-terms"]}),(0,br.jsxs)(l,{color:c.text.primary,children:[(0,br.jsx)(l,{color:c.status.success,children:"[2]"})," ","https://cloud.google.com/terms/services"]}),(0,br.jsx)(Uo,{}),(0,br.jsx)(l,{color:c.text.secondary,children:"Press Esc to exit."})]}));var Pl=C(z(),1);var NR=e=>{let[t,o]=(0,Pl.useState)({isLoading:!0});(0,Pl.useEffect)(()=>{(async()=>{o({isLoading:!0});try{let s=LR(e),i=s.userTier;if(i===void 0)throw new Error("Could not determine user tier.");if(i!==$T.FREE){o({isLoading:!1,isFreeTier:!1});return}let a=await jM(s);o({isLoading:!1,isFreeTier:!0,dataCollectionOptIn:a})}catch(s){o({isLoading:!1,error:s instanceof Error?s.message:String(s)})}})()},[e]);let r=(0,Pl.useCallback)(async n=>{try{let s=LR(e),i=await zM(s,n);o({isLoading:!1,isFreeTier:!0,dataCollectionOptIn:i})}catch(s){o({isLoading:!1,error:s instanceof Error?s.message:String(s)})}},[e]);return{privacyState:t,updateDataCollectionOptIn:r}};function LR(e){let t=Sx(e);if(t===void 0)throw new Error("Oauth not being used");if(t.projectId===void 0)throw new Error("CodeAssist server is missing a project ID");return t}async function jM(e){try{let t=await e.getCodeAssistGlobalUserSetting();return t.freeTierDataCollectionOptin===void 0&&de.warn("Warning: Code Assist API did not return freeTierDataCollectionOptin. Defaulting to true."),t.freeTierDataCollectionOptin??!0}catch(t){if(t&&typeof t=="object"&&"response"in t&&t.response?.status===404)return!0;throw t}}async function zM(e,t){let o=await e.setCodeAssistGlobalUserSetting({cloudaicompanionProject:e.projectId,freeTierDataCollectionOptin:t});return o.freeTierDataCollectionOptin===void 0&&de.warn(`Warning: Code Assist API did not return freeTierDataCollectionOptin. Defaulting to ${t}.`),o.freeTierDataCollectionOptin??t}var bt=C(P(),1);var BR=({config:e,onExit:t})=>{let{privacyState:o,updateDataCollectionOptIn:r}=NR(e);if(me(s=>(o.error||o.isFreeTier===!1)&&s.name==="escape"?(t(),!0):!1,{isActive:!0}),o.isLoading)return(0,bt.jsx)(l,{color:c.text.secondary,children:"Loading..."});if(o.error)return(0,bt.jsxs)(u,{flexDirection:"column",marginY:1,children:[(0,bt.jsxs)(l,{color:c.status.error,children:["Error loading Opt-in settings: ",o.error]}),(0,bt.jsx)(l,{color:c.text.secondary,children:"Press Esc to exit."})]});if(o.isFreeTier===!1)return(0,bt.jsxs)(u,{flexDirection:"column",marginY:1,children:[(0,bt.jsx)(l,{bold:!0,color:c.text.accent,children:"Gemini Code Assist Privacy Notice"}),(0,bt.jsx)(Uo,{}),(0,bt.jsx)(l,{children:"https://developers.google.com/gemini-code-assist/resources/privacy-notices"}),(0,bt.jsx)(Uo,{}),(0,bt.jsx)(l,{color:c.text.secondary,children:"Press Esc to exit."})]});let n=[{label:"Yes",value:!0,key:"true"},{label:"No",value:!1,key:"false"}];return(0,bt.jsxs)(u,{flexDirection:"column",marginY:1,children:[(0,bt.jsx)(l,{bold:!0,color:c.text.accent,children:"Gemini Code Assist for Individuals Privacy Notice"}),(0,bt.jsx)(Uo,{}),(0,bt.jsxs)(l,{color:c.text.primary,children:["This notice and our Privacy Policy",(0,bt.jsx)(l,{color:c.text.link,children:"[1]"})," describe how Gemini Code Assist handles your data. Please read them carefully."]}),(0,bt.jsx)(Uo,{}),(0,bt.jsx)(l,{color:c.text.primary,children:"When you use Gemini Code Assist for individuals with Gemini CLI, Google collects your prompts, related code, generated output, code edits, related feature usage information, and your feedback to provide, improve, and develop Google products and services and machine learning technologies."}),(0,bt.jsx)(Uo,{}),(0,bt.jsx)(l,{color:c.text.primary,children:"To help with quality and improve our products (such as generative machine-learning models), human reviewers may read, annotate, and process the data collected above. We take steps to protect your privacy as part of this process. This includes disconnecting the data from your Google Account before reviewers see or annotate it, and storing those disconnected copies for up to 18 months. Please don't submit confidential information or any data you wouldn't want a reviewer to see or Google to use to improve our products, services and machine-learning technologies."}),(0,bt.jsx)(Uo,{}),(0,bt.jsxs)(u,{flexDirection:"column",children:[(0,bt.jsx)(l,{color:c.text.primary,children:"Allow Google to use this data to develop and improve our products?"}),(0,bt.jsx)(We,{items:n,initialIndex:o.dataCollectionOptIn?0:1,onSelect:s=>{r(s),o.error||t()}})]}),(0,bt.jsx)(Uo,{}),(0,bt.jsxs)(l,{children:[(0,bt.jsx)(l,{color:c.text.link,children:"[1]"})," ","https://policies.google.com/privacy"]}),(0,bt.jsx)(Uo,{}),(0,bt.jsx)(l,{color:c.text.secondary,children:"Press Enter to choose an option and exit."})]})};var Ol=C(P(),1);var YM=({config:e,onExit:t})=>{switch(e.getContentGeneratorConfig()?.authType){case qe.USE_GEMINI:return(0,Ol.jsx)(PR,{onExit:t});case qe.USE_VERTEX_AI:return(0,Ol.jsx)(OR,{onExit:t});case qe.LOGIN_WITH_GOOGLE:default:return(0,Ol.jsx)(BR,{config:e,onExit:t})}},kR=({onExit:e,config:t})=>(0,Ol.jsx)(u,{borderStyle:"round",padding:1,flexDirection:"column",children:(0,Ol.jsx)(YM,{config:t,onExit:e})});var Hi=C(P(),1);function HR({failedModel:e,fallbackModel:t,message:o,isTerminalQuotaError:r,isModelNotFoundError:n,authType:s,tierName:i,onChoice:a}){let d;if(e===t)d=[{label:"Keep trying",value:"retry_once",key:"retry_once"},{label:"Stop",value:"retry_later",key:"retry_later"}];else if(n||r){let h=_d(i);d=[{label:`Switch to ${t}`,value:"retry_always",key:"retry_always"},...s===qe.LOGIN_WITH_GOOGLE&&!h?[{label:"Upgrade for higher limits",value:"upgrade",key:"upgrade"}]:[],{label:"Stop",value:"retry_later",key:"retry_later"}]}else d=[{label:"Keep trying",value:"retry_once",key:"retry_once"},{label:`Switch to ${t}`,value:"retry_always",key:"retry_always"},{label:"Stop",value:"retry_later",key:"retry_later"}];let m=h=>{a(h)};return(0,Hi.jsxs)(u,{borderStyle:"round",flexDirection:"column",padding:1,children:[(0,Hi.jsx)(u,{marginBottom:1,children:(h=>{let p=h.split(/(\s+)/);return(0,Hi.jsx)(l,{children:p.map((y,g)=>y.startsWith("/")?(0,Hi.jsx)(l,{bold:!0,color:c.text.accent,children:y},g):(0,Hi.jsx)(l,{children:y},g))})})(o)}),(0,Hi.jsx)(u,{marginTop:1,marginBottom:1,children:(0,Hi.jsx)(We,{items:d,onSelect:m})})]})}var Aa=C(z(),1);var Vt=C(P(),1);function FR({validationLink:e,learnMoreUrl:t,onChoice:o}){let r=Ze(),[n,s]=(0,Aa.useState)("choosing"),[i,a]=(0,Aa.useState)(""),d=[{label:"Verify your account",value:"verify",key:"verify"},{label:"Change authentication",value:"change_auth",key:"change_auth"}];me(f=>r["basic.cancel"](f)||r["basic.quit"](f)?(o("cancel"),!0):n==="waiting"&&r["basic.confirm"](f)?(s("complete"),!0):!1,{isActive:n!=="complete"}),(0,Aa.useEffect)(()=>{if(n==="complete"){let f=setTimeout(()=>{o("verify")},500);return()=>clearTimeout(f)}},[n,o]);let m=(0,Aa.useCallback)(async f=>{if(f==="verify")if(e){if(!el()){a(`Please open this URL in a browser: ${e}`),s("waiting");return}try{await Za(e),s("waiting")}catch(h){a(h instanceof Error?h.message:"Failed to open browser"),s("error")}}else o("verify");else o(f)},[e,o]);return n==="error"?(0,Vt.jsxs)(u,{borderStyle:"round",flexDirection:"column",padding:1,children:[(0,Vt.jsx)(l,{color:c.status.error,children:i||"Failed to open verification link. Please try again or change authentication."}),(0,Vt.jsx)(u,{marginTop:1,children:(0,Vt.jsx)(We,{items:d,onSelect:f=>void m(f)})})]}):n==="waiting"?(0,Vt.jsxs)(u,{borderStyle:"round",flexDirection:"column",padding:1,children:[(0,Vt.jsxs)(u,{children:[(0,Vt.jsx)(Mo,{}),(0,Vt.jsxs)(l,{children:[" ","Waiting for verification... (Press Esc or Ctrl+C to cancel)"]})]}),i&&(0,Vt.jsx)(u,{marginTop:1,children:(0,Vt.jsx)(l,{children:i})}),(0,Vt.jsx)(u,{marginTop:1,children:(0,Vt.jsx)(l,{dimColor:!0,children:"Press Enter when verification is complete."})})]}):n==="complete"?(0,Vt.jsx)(u,{borderStyle:"round",flexDirection:"column",padding:1,children:(0,Vt.jsx)(l,{color:c.status.success,children:"Verification complete"})}):(0,Vt.jsxs)(u,{borderStyle:"round",flexDirection:"column",padding:1,children:[(0,Vt.jsx)(u,{marginBottom:1,children:(0,Vt.jsx)(l,{children:"Further action is required to use this service."})}),(0,Vt.jsx)(u,{marginTop:1,marginBottom:1,children:(0,Vt.jsx)(We,{items:d,onSelect:f=>void m(f)})}),t&&(0,Vt.jsx)(u,{marginTop:1,children:(0,Vt.jsxs)(l,{dimColor:!0,children:["Learn more: ",(0,Vt.jsx)(l,{color:c.text.accent,children:t})]})})]})}var Io=C(P(),1);function UR({failedModel:e,fallbackModel:t,resetTime:o,creditBalance:r,onChoice:n}){let s=[{label:"Use AI Credits - Continue this request (Overage)",value:"use_credits",key:"use_credits"},{label:"Manage - View balance and purchase more credits",value:"manage",key:"manage"}];return t&&s.push({label:`Switch to ${t}`,value:"use_fallback",key:"use_fallback"}),s.push({label:"Stop - Abort request",value:"stop",key:"stop"}),(0,Io.jsxs)(u,{borderStyle:"round",flexDirection:"column",padding:1,children:[(0,Io.jsxs)(u,{marginBottom:1,flexDirection:"column",children:[(0,Io.jsxs)(l,{color:c.status.warning,children:["Usage limit reached for ",e,"."]}),o&&(0,Io.jsxs)(l,{children:["Access resets at ",o,"."]}),(0,Io.jsxs)(l,{children:[(0,Io.jsx)(l,{bold:!0,color:c.text.accent,children:"/stats"})," ","model for usage details"]}),(0,Io.jsxs)(l,{children:[(0,Io.jsx)(l,{bold:!0,color:c.text.accent,children:"/model"})," ","to switch models."]}),(0,Io.jsxs)(l,{children:[(0,Io.jsx)(l,{bold:!0,color:c.text.accent,children:"/auth"})," ","to switch to API key."]})]}),(0,Io.jsx)(u,{marginBottom:1,children:(0,Io.jsxs)(l,{children:["You have"," ",(0,Io.jsx)(l,{bold:!0,color:c.status.success,children:r})," ","AI Credits available."]})}),(0,Io.jsx)(u,{marginBottom:1,children:(0,Io.jsx)(l,{children:"How would you like to proceed?"})}),(0,Io.jsx)(u,{marginTop:1,marginBottom:1,children:(0,Io.jsx)(We,{items:s,onSelect:n})})]})}var po=C(P(),1);function GR({failedModel:e,fallbackModel:t,resetTime:o,onGetCredits:r,onChoice:n}){let s=[{label:"Get AI Credits - Open browser to purchase credits",value:"get_credits",key:"get_credits"}];t&&s.push({label:`Switch to ${t}`,value:"use_fallback",key:"use_fallback"}),s.push({label:"Stop - Abort request",value:"stop",key:"stop"});let i=a=>{a==="get_credits"&&r?.(),n(a)};return(0,po.jsxs)(u,{borderStyle:"round",flexDirection:"column",padding:1,children:[(0,po.jsxs)(u,{marginBottom:1,flexDirection:"column",children:[(0,po.jsxs)(l,{color:c.status.warning,children:["Usage limit reached for ",e,"."]}),o&&(0,po.jsxs)(l,{children:["Access resets at ",o,"."]}),(0,po.jsxs)(l,{children:[(0,po.jsx)(l,{bold:!0,color:c.text.accent,children:"/stats"})," ","model for usage details"]}),(0,po.jsxs)(l,{children:[(0,po.jsx)(l,{bold:!0,color:c.text.accent,children:"/model"})," ","to switch models."]}),(0,po.jsxs)(l,{children:[(0,po.jsx)(l,{bold:!0,color:c.text.accent,children:"/auth"})," ","to switch to API key."]})]}),(0,po.jsx)(u,{marginBottom:1,children:(0,po.jsx)(l,{children:"To continue using this model now, purchase more AI Credits."})}),(0,po.jsx)(u,{marginBottom:1,children:(0,po.jsx)(l,{dimColor:!0,children:"Newly purchased AI credits may take a few minutes to update."})}),(0,po.jsx)(u,{marginBottom:1,children:(0,po.jsx)(l,{children:"How would you like to proceed?"})}),(0,po.jsx)(u,{marginTop:1,marginBottom:1,children:(0,po.jsx)(We,{items:s,onSelect:i})})]})}var eo=C(z(),1);var Fe={get type(){return at.getActiveTheme().colors.type},get Foreground(){return at.getActiveTheme().colors.Foreground},get Background(){return at.getColors().Background},get LightBlue(){return at.getActiveTheme().colors.LightBlue},get AccentBlue(){return at.getActiveTheme().colors.AccentBlue},get AccentPurple(){return at.getActiveTheme().colors.AccentPurple},get AccentCyan(){return at.getActiveTheme().colors.AccentCyan},get AccentGreen(){return at.getActiveTheme().colors.AccentGreen},get AccentYellow(){return at.getActiveTheme().colors.AccentYellow},get AccentRed(){return at.getActiveTheme().colors.AccentRed},get DiffAdded(){return at.getActiveTheme().colors.DiffAdded},get DiffRemoved(){return at.getActiveTheme().colors.DiffRemoved},get Comment(){return at.getActiveTheme().colors.Comment},get Gray(){return at.getActiveTheme().colors.Gray},get DarkGray(){return at.getColors().DarkGray},get InputBackground(){return at.getColors().InputBackground},get MessageBackground(){return at.getColors().MessageBackground},get GradientColors(){return at.getActiveTheme().colors.GradientColors}};import QR from"node:path";var jt=C(P(),1);var Ms=({name:e,shortcut:t})=>(0,jt.jsxs)(jt.Fragment,{children:[e,": ",(0,jt.jsx)(l,{bold:!0,children:t})]}),WR=()=>(0,jt.jsxs)(u,{flexDirection:"column",children:[(0,jt.jsxs)(l,{color:Fe.Gray,children:[(0,jt.jsx)(Ms,{name:"Navigate",shortcut:"\u2191/\u2193"})," ",(0,jt.jsx)(Ms,{name:"Resume",shortcut:"Enter"})," ",(0,jt.jsx)(Ms,{name:"Search",shortcut:"/"})," ",(0,jt.jsx)(Ms,{name:"Delete",shortcut:"x"})," ",(0,jt.jsx)(Ms,{name:"Quit",shortcut:"q"})]}),(0,jt.jsxs)(l,{color:Fe.Gray,children:[(0,jt.jsx)(Ms,{name:"Sort",shortcut:"s"})," ",(0,jt.jsx)(Ms,{name:"Reverse",shortcut:"r"})," ",(0,jt.jsx)(Ms,{name:"First/Last",shortcut:"g/G"})]})]}),VR=({state:e})=>(0,jt.jsxs)(u,{marginTop:1,children:[(0,jt.jsx)(l,{color:Fe.Gray,children:"Search: "}),(0,jt.jsx)(l,{color:Fe.AccentPurple,children:e.searchQuery}),(0,jt.jsx)(l,{color:Fe.Gray,children:" (Esc to cancel)"})]}),$R=({state:e})=>(0,jt.jsx)(u,{marginTop:1,children:(0,jt.jsxs)(l,{color:Fe.Gray,dimColor:!0,children:["No sessions found matching '",e.searchQuery,"'."]})});var Cm=C(P(),1);var qR=({state:e})=>(0,Cm.jsxs)(u,{flexDirection:"row",justifyContent:"space-between",children:[(0,Cm.jsxs)(l,{color:Fe.AccentPurple,children:["Chat Sessions (",e.totalSessions," total",e.searchQuery?", filtered":"",")"]}),(0,Cm.jsxs)(l,{color:Fe.Gray,children:["sorted by ",e.sortOrder," ",e.sortReverse?"asc":"desc"]})]});var ug=C(P(),1);var KR=()=>(0,ug.jsx)(u,{flexDirection:"column",paddingX:1,children:(0,ug.jsx)(l,{color:Fe.Gray,children:"Loading sessions\u2026"})});var Wc=C(P(),1);var jR=({state:e})=>(0,Wc.jsxs)(u,{flexDirection:"column",paddingX:1,children:[(0,Wc.jsxs)(l,{color:Fe.AccentRed,children:["Error: ",e.error]}),(0,Wc.jsx)(l,{color:Fe.Gray,children:"Press q to exit"})]});var Vc=C(P(),1);var zR=()=>(0,Vc.jsxs)(u,{flexDirection:"column",paddingX:1,children:[(0,Vc.jsx)(l,{color:Fe.Gray,children:"No auto-saved conversations found."}),(0,Vc.jsx)(l,{color:Fe.Gray,children:"Press q to exit"})]});var YR=(e,t,o)=>{let r=[...e].sort((n,s)=>{switch(t){case"date":return new Date(s.lastUpdated).getTime()-new Date(n.lastUpdated).getTime();case"messages":return s.messageCount-n.messageCount;case"name":return n.displayName.localeCompare(s.displayName);default:return 0}});return o?r.reverse():r},XM=(e,t)=>{if(!t.trim())return[];let o=t.toLowerCase(),r=[];for(let n of e){let s=ES(n.content),i=s.toLowerCase(),a=0;for(;;){let d=i.indexOf(o,a);if(d===-1)break;let m=Math.max(0,d-10),f=Math.min(s.length,d+t.length+10),h=s.slice(m,f),p=d-m,y=p+t.length,g=h.slice(0,p),x=h.slice(p,y),S=h.slice(y);m>0&&(g="\u2026"+g),f<s.length&&(S=S+"\u2026"),r.push({before:g,match:x,after:S,role:n.role}),a=d+1}}return r},XR=(e,t)=>{if(!t.trim())return e.map(r=>({...r,matchSnippets:void 0,matchCount:void 0}));let o=t.toLowerCase();return e.filter(r=>{let n=r.displayName.toLowerCase().includes(o)||r.id.toLowerCase().includes(o)||r.firstUserMessage.toLowerCase().includes(o),s=r.fullContent?.toLowerCase().includes(o);return n||s?(r.messages&&(r.matchSnippets=XM(r.messages,t),r.matchCount=r.matchSnippets.length),!0):!1})};var _e=C(P(),1);var Ps=20,QM=30,JM=({state:e})=>(0,_e.jsxs)(u,{flexDirection:"row",marginTop:1,children:[(0,_e.jsx)(l,{children:e.scrollOffset>0?(0,_e.jsx)(l,{children:"\u25B2 "}):" "}),(0,_e.jsx)(u,{width:5,flexShrink:0,children:(0,_e.jsx)(l,{color:Fe.Gray,bold:!0,children:"Index"})}),(0,_e.jsx)(l,{color:Fe.Gray,children:" \u2502 "}),(0,_e.jsx)(u,{width:4,flexShrink:0,children:(0,_e.jsx)(l,{color:Fe.Gray,bold:!0,children:"Msgs"})}),(0,_e.jsx)(l,{color:Fe.Gray,children:" \u2502 "}),(0,_e.jsx)(u,{width:4,flexShrink:0,children:(0,_e.jsx)(l,{color:Fe.Gray,bold:!0,children:"Age"})}),(0,_e.jsx)(l,{color:Fe.Gray,children:" \u2502 "}),(0,_e.jsx)(u,{flexShrink:0,children:(0,_e.jsx)(l,{color:Fe.Gray,bold:!0,children:e.searchQuery?"Match":"Name"})})]}),ZM=({session:e,textColor:t})=>{if(!e.matchSnippets||e.matchSnippets.length===0)return null;let o=e.matchSnippets[0],r=o.role==="user"?"You: ":"Gemini:",n=t(o.role==="user"?Fe.AccentGreen:Fe.AccentBlue);return(0,_e.jsxs)(_e.Fragment,{children:[(0,_e.jsxs)(l,{color:n,bold:!0,children:[r," "]}),o.before,(0,_e.jsx)(l,{color:t(Fe.AccentRed),bold:!0,children:o.match}),o.after]})},eP=({session:e,state:t,terminalWidth:o,formatRelativeTime:r})=>{let n=t.startIndex+t.visibleSessions.indexOf(e),s=n===t.activeIndex,i=e.isCurrentSession,a=(g=Fe.Foreground)=>i?Fe.Gray:s?c.ui.focus:g,d=s?"\u276F ":" ",m="",f=null;e.isCurrentSession&&(m=" (current)"),t.searchQuery&&e.matchSnippets&&e.matchSnippets.length>0&&(f=(0,_e.jsx)(ZM,{session:e,textColor:a}),e.matchCount&&e.matchCount>1&&(m+=` (+${e.matchCount-1} more)`));let h=m?m.length+1:0,p=Math.max(20,o-QM-h),y=f||(e.displayName.length===0?(0,_e.jsx)(l,{color:a(Fe.Gray),dimColor:!0,children:"(No messages)"}):e.displayName.length>p?e.displayName.slice(0,p-1)+"\u2026":e.displayName);return(0,_e.jsxs)(u,{flexDirection:"row",backgroundColor:s?c.background.focus:void 0,children:[(0,_e.jsx)(l,{color:a(),dimColor:i,children:d}),(0,_e.jsx)(u,{width:5,children:(0,_e.jsxs)(l,{color:a(),dimColor:i,children:["#",n+1]})}),(0,_e.jsxs)(l,{color:a(Fe.Gray),dimColor:i,children:[" ","\u2502"," "]}),(0,_e.jsx)(u,{width:4,children:(0,_e.jsx)(l,{color:a(),dimColor:i,children:e.messageCount})}),(0,_e.jsxs)(l,{color:a(Fe.Gray),dimColor:i,children:[" ","\u2502"," "]}),(0,_e.jsx)(u,{width:4,children:(0,_e.jsx)(l,{color:a(),dimColor:i,children:r(e.lastUpdated,"short")})}),(0,_e.jsxs)(l,{color:a(Fe.Gray),dimColor:i,children:[" ","\u2502"," "]}),(0,_e.jsx)(u,{flexGrow:1,children:(0,_e.jsxs)(l,{color:a(Fe.Comment),dimColor:i,children:[y,m&&(0,_e.jsx)(l,{color:a(Fe.Gray),dimColor:!0,bold:!1,children:m})]})})]})},tP=({state:e,formatRelativeTime:t})=>(0,_e.jsxs)(u,{flexDirection:"column",children:[(0,_e.jsxs)(u,{flexDirection:"column",children:[!e.isSearchMode&&(0,_e.jsx)(WR,{}),(0,_e.jsx)(JM,{state:e})]}),e.visibleSessions.map(o=>(0,_e.jsx)(eP,{session:o,state:e,terminalWidth:e.terminalWidth,formatRelativeTime:t},o.id)),(0,_e.jsx)(l,{color:Fe.Gray,children:e.endIndex<e.totalSessions?(0,_e.jsx)(_e.Fragment,{children:"\u25BC"}):(0,_e.jsx)(l,{dimColor:!0,children:"\u25BC"})})]}),oP=(e=[],t=!0,o=null)=>{let{columns:r}=ci(),[n,s]=(0,eo.useState)(e),[i,a]=(0,eo.useState)(t),[d,m]=(0,eo.useState)(o),[f,h]=(0,eo.useState)(0),[p,y]=(0,eo.useState)(0),[g,x]=(0,eo.useState)("date"),[S,I]=(0,eo.useState)(!1),[A,E]=(0,eo.useState)(""),[T,v]=(0,eo.useState)(!1),[R,b]=(0,eo.useState)(!1),_=(0,eo.useRef)(!1),w=(0,eo.useMemo)(()=>{let L=XR(n,A);return YR(L,g,S)},[n,A,g,S]);(0,eo.useEffect)(()=>{A||(b(!1),_.current=!1)},[A]);let M=w.length,D=p,N=Math.min(p+Ps,M),O=w.slice(D,N);return{sessions:n,setSessions:s,loading:i,setLoading:a,error:d,setError:m,activeIndex:f,setActiveIndex:h,scrollOffset:p,setScrollOffset:y,searchQuery:A,setSearchQuery:E,isSearchMode:T,setIsSearchMode:v,hasLoadedFullContent:R,setHasLoadedFullContent:b,sortOrder:g,setSortOrder:x,sortReverse:S,setSortReverse:I,terminalWidth:r,filteredAndSortedSessions:w,totalSessions:M,startIndex:D,endIndex:N,visibleSessions:O}},rP=(e,t)=>{let{setSessions:o,setLoading:r,setError:n,isSearchMode:s,hasLoadedFullContent:i,setHasLoadedFullContent:a}=t;(0,eo.useEffect)(()=>{(async()=>{try{let m=QR.join(e.storage.getProjectTempDir(),"chats"),f=await Sf(m,e.getSessionId());o(f),r(!1)}catch(m){n(m instanceof Error?m.message:"Failed to load sessions"),r(!1)}})()},[e,o,r,n]),(0,eo.useEffect)(()=>{(async()=>{if(s&&!i)try{let m=QR.join(e.storage.getProjectTempDir(),"chats"),f=await Sf(m,e.getSessionId(),{includeFullContent:!0});o(f),a(!0)}catch(m){n(m instanceof Error?m.message:"Failed to load full session content")}})()},[s,i,e,o,a,n])},nP=e=>{let{totalSessions:t,activeIndex:o,scrollOffset:r,setActiveIndex:n,setScrollOffset:s}=e;return(0,eo.useCallback)(i=>{let a=Math.max(0,Math.min(t-1,o+i));n(a),a<r?s(a):a>=r+Ps&&s(a-Ps+1)},[t,o,r,n,s])},iP=e=>{let{sortOrder:t,setSortOrder:o}=e;return(0,eo.useCallback)(()=>{let r=["date","messages","name"],s=(r.indexOf(t)+1)%r.length;o(r[s])},[t,o])},sP=(e,t,o,r,n,s)=>{me(i=>{if(e.isSearchMode){if(i.name==="escape")return e.setIsSearchMode(!1),e.setSearchQuery(""),e.setActiveIndex(0),e.setScrollOffset(0),!0;if(i.name==="backspace")return e.setSearchQuery(a=>a.slice(0,-1)),e.setActiveIndex(0),e.setScrollOffset(0),!0;if(i.name==="enter"){let a=e.filteredAndSortedSessions[e.activeIndex];return a&&!a.isCurrentSession&&r(a),!0}else if(i.sequence&&i.sequence.length===1&&!i.alt&&!i.ctrl&&!i.cmd)return e.setSearchQuery(a=>a+i.sequence),e.setActiveIndex(0),e.setScrollOffset(0),!0}else{if(i.sequence==="g")return e.setActiveIndex(0),e.setScrollOffset(0),!0;if(i.sequence==="G")return e.setActiveIndex(e.totalSessions-1),e.setScrollOffset(Math.max(0,e.totalSessions-Ps)),!0;if(i.sequence==="s")return o(),!0;if(i.sequence==="r")return e.setSortReverse(!e.sortReverse),!0;if(i.sequence==="/")return e.setIsSearchMode(!0),!0;if(i.sequence==="q"||i.sequence==="Q"||i.name==="escape")return s(),!0;if(i.sequence==="x"||i.sequence==="X"){let a=e.filteredAndSortedSessions[e.activeIndex];return a&&!a.isCurrentSession&&n(a).then(()=>{e.setSessions(e.sessions.filter(d=>d.id!==a.id)),e.activeIndex>=e.filteredAndSortedSessions.length-1&&e.setActiveIndex(Math.max(0,e.filteredAndSortedSessions.length-2))}).catch(d=>{e.setError(`Failed to delete session: ${d instanceof Error?d.message:"Unknown error"}`)}),!0}else{if(i.sequence==="u")return t(-Math.round(Ps/2)),!0;if(i.sequence==="d")return t(Math.round(Ps/2)),!0}}if(i.name==="enter"&&e.filteredAndSortedSessions[e.activeIndex]){let a=e.filteredAndSortedSessions[e.activeIndex];return a.isCurrentSession||r(a),!0}else{if(i.name==="up")return t(-1),!0;if(i.name==="down")return t(1),!0;if(i.name==="pageup")return t(-Ps),!0;if(i.name==="pagedown")return t(Ps),!0}return!1},{isActive:!0})};function aP({state:e}){return e.loading?(0,_e.jsx)(KR,{}):e.error?(0,_e.jsx)(jR,{state:e}):e.sessions.length===0?(0,_e.jsx)(zR,{}):(0,_e.jsxs)(u,{flexDirection:"column",paddingX:1,children:[(0,_e.jsx)(qR,{state:e}),e.isSearchMode&&(0,_e.jsx)(VR,{state:e}),e.totalSessions===0?(0,_e.jsx)($R,{state:e}):(0,_e.jsx)(tP,{state:e,formatRelativeTime:RS})]})}function JR({config:e,onResumeSession:t,onDeleteSession:o,onExit:r}){let n=oP();rP(e,n);let s=nP(n),i=iP(n);return sP(n,s,i,t,o,r),(0,_e.jsx)(aP,{state:n})}var Er=C(z(),1);var eI=C(z(),1);var $c=C(P(),1);var ZR=({value:e,width:t,warningThreshold:o=80})=>{let r=Math.min(Math.max(e,0),100),n=Math.ceil(r/100*t),s=t-n,i=c.status.success;return r>=100?i=c.status.error:r>=o&&(i=c.status.warning),(0,$c.jsxs)(u,{flexDirection:"row",children:[(0,$c.jsx)(l,{color:i,children:"\u25AC".repeat(n)}),(0,$c.jsx)(l,{color:c.border.default,children:"\u25AC".repeat(s)})]})};var Wo=C(P(),1);var lP=({row:e,availableWidth:t})=>{let{terminalWidth:o}=Ce(),r=12,n=4,s=26,i=e.usedPercentage,a=e.name,d=`${i.toFixed(0)}%`.padEnd(n),m=e.resetTime?Rc(e.resetTime,"column").slice(0,s).padEnd(s):"".padEnd(s),f=r,h=n+1,p=s+1,y=f+h+p,g=t??o,x=t!=null?0:4,I=Math.max(0,g-x-y-3),A=c.text.primary;return i>=100?A=c.status.error:i>=80&&(A=c.status.warning),(0,Wo.jsxs)(u,{flexDirection:"row",width:"100%",children:[(0,Wo.jsx)(u,{width:r,children:(0,Wo.jsx)(l,{color:c.text.primary,wrap:"truncate-end",children:a})}),(0,Wo.jsx)(u,{flexGrow:1,children:(0,Wo.jsx)(ZR,{value:i,width:I})}),(0,Wo.jsx)(u,{width:4,marginLeft:1,children:(0,Wo.jsx)(l,{color:A,children:d})}),(0,Wo.jsx)(u,{width:s,marginLeft:1,children:(0,Wo.jsx)(l,{color:c.text.secondary,children:m.trim()?`Resets: ${m}`:""})})]})},tI=({buckets:e,availableWidth:t,modelsToShow:o=["all"],title:r="Model usage"})=>{let n=Ct(),s=(0,eI.useMemo)(()=>{if(!e)return[];let i=e.filter(d=>d.modelId&&d.remainingFraction!=null);if(o.includes("current")){let d=n.getActiveModel?.()??n.getModel?.();i=i.filter(m=>m.modelId===d)}else o.includes("all")||(i=i.filter(d=>d.modelId&&o.includes(d.modelId)));let a=new Map;return i.forEach(d=>{let m=d.modelId,f=d.remainingFraction;if(!m||f==null)return;let h=n?.modelConfigService?.getModelDefinition(m)?.tier,p=h??m,y=a.get(p);if(!y||f<y.remainingFraction){let x=h?{pro:"Pro",flash:"Flash","flash-lite":"Flash Lite"}[h]??h:Bt(m,n);a.set(p,{modelId:m,remainingFraction:f,resetTime:d.resetTime,name:x})}}),Array.from(a.entries()).map(([d,m])=>{let f=1-m.remainingFraction,h=f*100;return{modelId:d,name:m.name,usedFraction:f,usedPercentage:h,resetTime:m.resetTime}})},[e,n,o]);return s.length===0?null:(0,Wo.jsxs)(u,{flexDirection:"column",marginTop:1,children:[(0,Wo.jsx)(u,{borderStyle:"single",borderTop:!0,borderBottom:!1,borderLeft:!1,borderRight:!1,borderColor:c.border.default}),(0,Wo.jsxs)(u,{flexDirection:"column",children:[(0,Wo.jsx)(u,{marginBottom:1,children:(0,Wo.jsx)(l,{bold:!0,color:c.text.primary,children:r})}),s.map(i=>(0,Wo.jsx)(lP,{row:i,availableWidth:t},i.modelId))]})]})};var Ll=C(P(),1);function qc({items:e,initialIndex:t=0,onSelect:o,onHighlight:r,isFocused:n=!0,showNumbers:s=!1,showScrollArrows:i=!1,maxItemsToShow:a=10}){return(0,Ll.jsx)(yd,{items:e,initialIndex:t,onSelect:o,onHighlight:r,isFocused:n,showNumbers:s,showScrollArrows:i,maxItemsToShow:a,renderItem:(d,{titleColor:m})=>(0,Ll.jsxs)(u,{flexDirection:"column",children:[(0,Ll.jsx)(l,{color:m,children:d.title}),d.description&&(0,Ll.jsx)(l,{color:c.text.secondary,children:d.description})]},d.key)})}var rr=C(P(),1);function oI({onClose:e}){let t=(0,Er.useContext)(Td),o=Ke(),{terminalWidth:r}=Ce(),[n,s]=(0,Er.useState)(()=>!(t?.getProModelNoAccessSync()??!1)),[i,a]=(0,Er.useState)(()=>t?.getProModelNoAccessSync()?"manual":"main"),[d,m]=(0,Er.useState)(!1);(0,Er.useEffect)(()=>{async function R(){if(!t)return;let b=await t.getProModelNoAccess();s(!b),b&&a("manual")}R()},[t]);let f=t?.getModel()||Tc,h=t?.getHasAccessToPreviewModel(),p=t?.getGemini31LaunchedSync?.()??!1,y=t?.getGemini31FlashLiteLaunchedSync?.()??!1,g=o.merged.security.auth.selectedType,x=p&&g===qe.USE_GEMINI,S=(0,Er.useMemo)(()=>{if(t?.getExperimentalDynamicModelConfiguration?.()===!0&&t.getModelConfigService){let b=t.getModelConfigService().getModelDefinition(f);return b&&b.tier!=="auto"&&b.isVisible===!0?f:""}return[hc,ss,yc,Qp,Jp,Zp,gc,fc].includes(f)?f:""},[f,t]);me(R=>R.name==="escape"?(i==="manual"&&n?a("main"):e(),!0):R.name==="tab"?(m(b=>!b),!0):!1,{isActive:!0});let I=(0,Er.useMemo)(()=>{if(t?.getExperimentalDynamicModelConfiguration?.()===!0&&t.getModelConfigService){let _=t.getModelConfigService().getAvailableModelOptions({useGemini3_1:p,useGemini3_1FlashLite:y,useCustomTools:x,hasAccessToPreview:h,hasAccessToProModel:n}).filter(w=>w.tier==="auto").map(w=>({value:w.modelId,title:w.name,description:w.description,key:w.modelId}));return _.push({value:"Manual",title:S?`Manual (${Bt(S,t??void 0)})`:"Manual",description:"Manually select a model",key:"Manual"}),_}let R=[{value:Tc,title:Bt(Tc),description:"Let Gemini CLI decide the best model for the task: gemini-2.5-pro, gemini-2.5-flash",key:Tc},{value:"Manual",title:S?`Manual (${Bt(S)})`:"Manual",description:"Manually select a model",key:"Manual"}];return h&&R.unshift({value:$u,title:Bt($u),description:p?"Let Gemini CLI decide the best model for the task: gemini-3.1-pro, gemini-3-flash":"Let Gemini CLI decide the best model for the task: gemini-3-pro, gemini-3-flash",key:$u}),R},[t,h,S,p,y,x,n]),A=(0,Er.useMemo)(()=>{if(t?.getExperimentalDynamicModelConfiguration?.()===!0&&t.getModelConfigService)return t.getModelConfigService().getAvailableModelOptions({useGemini3_1:p,useGemini3_1FlashLite:y,useCustomTools:x,hasAccessToPreview:h,hasAccessToProModel:n}).filter(w=>w.tier!=="auto").map(w=>({value:w.modelId,title:w.name,key:w.modelId}));let R=t?.getExperimentalGemma()??!1,b=[{value:hc,title:Bt(hc),key:hc},{value:ss,title:Bt(ss),key:ss},{value:yc,title:Bt(yc),key:yc}];if(R&&b.push({value:Wu,title:Bt(Wu),key:Wu},{value:Vu,title:Bt(Vu),key:Vu}),h){let _=p?Jp:Qp,M=[{value:x?Zp:_,title:Bt(_),key:_},{value:fc,title:Bt(fc),key:fc}];y&&M.push({value:gc,title:Bt(gc),key:gc}),b.unshift(...M)}return n?b:b.filter(_=>!qu(_.value))},[h,p,y,x,n,t]),E=i==="main"?I:A,T=(0,Er.useMemo)(()=>{let R=E.findIndex(b=>b.value===f);if(R!==-1)return R;if(i==="main"){let b=E.findIndex(_=>_.value==="Manual");return b!==-1?b:0}return 0},[f,E,i]),v=(0,Er.useCallback)(R=>{if(R==="Manual"){a("manual");return}if(t){t.setModel(R,!d);let b=new UT(R);ax(t,b)}e()},[t,e,d]);return(0,rr.jsxs)(u,{borderStyle:"round",borderColor:c.border.default,flexDirection:"column",padding:1,width:"100%",children:[(0,rr.jsx)(l,{bold:!0,children:"Select Model"}),(0,rr.jsx)(u,{marginTop:1,children:(0,rr.jsx)(qc,{items:E,onSelect:v,initialIndex:T,showNumbers:!0})}),(0,rr.jsx)(u,{marginTop:1,flexDirection:"column",children:(0,rr.jsxs)(u,{children:[(0,rr.jsxs)(l,{bold:!0,color:c.text.primary,children:["Remember model for future sessions:"," "]}),(0,rr.jsx)(l,{color:c.status.success,children:d?"true":"false"}),(0,rr.jsx)(l,{color:c.text.secondary,children:" (Press Tab to toggle)"})]})}),(0,rr.jsx)(u,{flexDirection:"column",children:(0,rr.jsx)(l,{color:c.text.secondary,children:"> To use a specific Gemini model on startup, use the --model flag."})}),(0,rr.jsx)(tI,{buckets:t?.getLastRetrievedQuota()?.buckets,availableWidth:r-2}),(0,rr.jsx)(u,{marginTop:1,flexDirection:"column",children:(0,rr.jsx)(l,{color:c.text.secondary,children:"(Press Esc to close)"})})]})}var Rr=C(z(),1);var io=C(P(),1);var cP=[{value:"ggml-tiny.en.bin",label:"Tiny (EN)",description:"Fastest, lower accuracy (~75MB)"},{value:"ggml-base.en.bin",label:"Base (EN)",description:"Balanced speed and accuracy (~142MB)"},{value:"ggml-large-v3-turbo-q5_0.bin",label:"Large v3 Turbo (Q5_0)",description:"High accuracy, quantized (~547MB)"},{value:"ggml-large-v3-turbo-q8_0.bin",label:"Large v3 Turbo (Q8_0)",description:"Maximum accuracy, high memory (~834MB)"}];function rI({onClose:e}){let{settings:t,setSetting:o}=gd(),[r,n]=(0,Rr.useState)("backend"),[s,i]=(0,Rr.useState)(null),[a,d]=(0,Rr.useState)(null),m=(0,Rr.useMemo)(()=>Jx("whisper-stream"),[]),f=(0,Rr.useMemo)(()=>new Qx,[]),h=t.merged.experimental.voice?.backend??"gemini-live",p=t.merged.experimental.voice?.whisperModel??"ggml-base.en.bin",[y,g]=(0,Rr.useState)(h),x=(0,Rr.useCallback)(v=>v.name==="escape"?(r==="whisper-models"?n("backend"):e(),!0):!1,[r,e]);me(x,{isActive:!0});let S=(0,Rr.useCallback)(v=>{v==="whisper"?n("whisper-models"):(o("User","experimental.voice.backend","gemini-live"),e())},[o,e]),I=(0,Rr.useCallback)(v=>{g(v)},[]),A=(0,Rr.useCallback)(async v=>{if(f.isModelInstalled(v))o("User","experimental.voice.backend","whisper"),o("User","experimental.voice.whisperModel",v),e();else{d(null);let R=b=>i(b);f.on("progress",R);try{await f.downloadModel(v),o("User","experimental.voice.backend","whisper"),o("User","experimental.voice.whisperModel",v),e()}catch(b){d(`Failed to download: ${b instanceof Error?b.message:String(b)}`)}finally{f.off("progress",R),i(null)}}},[f,o,e]),E=(0,Rr.useMemo)(()=>[{value:"gemini-live",title:"Gemini Live API (Cloud)",description:"Real-time cloud transcription via Gemini Live API.",key:"gemini-live"},{value:"whisper",title:"Whisper (Local)",description:m?"Local transcription using whisper.cpp.":"Local transcription (Requires: brew install whisper-cpp)",key:"whisper"}],[m]),T=(0,Rr.useMemo)(()=>cP.map(v=>({value:v.value,title:`${v.label}${f.isModelInstalled(v.value)?" (Installed)":" (Download)"}`,description:v.description,key:v.value})),[f]);return(0,io.jsxs)(u,{borderStyle:"round",borderColor:c.border.default,flexDirection:"column",padding:1,width:"100%",children:[(0,io.jsx)(l,{bold:!0,children:r==="backend"?"Select Voice Transcription Backend":"Select Whisper Model"}),a&&(0,io.jsx)(u,{marginTop:1,children:(0,io.jsx)(l,{color:c.status.error,children:a})}),s?(0,io.jsx)(u,{marginTop:1,flexDirection:"column",children:(0,io.jsxs)(u,{children:[(0,io.jsxs)(l,{children:["Downloading ",s.modelName,"... "]}),(0,io.jsx)(Mo,{}),(0,io.jsxs)(l,{children:[" ",Math.round(s.percentage*100),"%"]})]})}):(0,io.jsx)(u,{marginTop:1,flexDirection:"column",children:r==="backend"?(0,io.jsxs)(io.Fragment,{children:[(0,io.jsx)(qc,{items:E,onSelect:S,onHighlight:I,initialIndex:h==="whisper"?1:0,showNumbers:!0}),y==="gemini-live"&&(0,io.jsx)(u,{marginTop:1,children:(0,io.jsx)(wl,{text:"When using the Gemini Live backend, voice recordings are sent to Google Cloud for transcription. Enterprise users should verify this aligns with their data privacy and compliance requirements."})})]}):(0,io.jsx)(qc,{items:T,onSelect:A,initialIndex:T.findIndex(v=>v.value===p),showNumbers:!0})}),(0,io.jsx)(u,{marginTop:1,flexDirection:"column",children:(0,io.jsx)(l,{color:c.text.secondary,children:r==="whisper-models"?"(Press Esc to go back)":"(Press Esc to close)"})})]})}import uP from"node:process";var bm=C(P(),1);var nI=()=>{let e=Ze(),{handleRestart:t}=Pr();return me(r=>e["app.restart"](r)?(t(),!0):!1,{isActive:!0}),(0,bm.jsx)(u,{borderStyle:"round",borderColor:c.status.warning,paddingX:1,children:(0,bm.jsxs)(l,{color:c.status.warning,children:["Admin settings have changed. Please restart the session to apply new settings."," Press 'r' to restart, or 'Ctrl+C' twice to exit."]})})};var Em=C(P(),1);var iI=({reason:e})=>{me(o=>o.name==="r"||o.name==="R"?(fr(),!0):!1,{isActive:!0});let t="Workspace trust has changed.";return e==="NONE"?de.warn('IdeTrustChangeDialog rendered with unexpected reason "NONE"'):e==="CONNECTION_CHANGE"?t="Workspace trust has changed due to a change in the IDE connection.":e==="TRUST_CHANGE"&&(t="Workspace trust has changed due to a change in the IDE trust."),(0,Em.jsx)(u,{borderStyle:"round",borderColor:c.status.warning,paddingX:1,children:(0,Em.jsxs)(l,{color:c.status.warning,children:[t," Press 'r' to restart Gemini to apply the changes."]})})};var Ir=C(z(),1);var mg=C(P(),1);var Kc=[{key:"enabled",label:"Enabled",description:"Enable or disable this agent",type:"boolean",path:["enabled"],defaultValue:!0},{key:"model",label:"Model",description:"Model to use (e.g., 'gemini-2.0-flash' or 'inherit')",type:"string",path:["modelConfig","model"],defaultValue:"inherit"},{key:"temperature",label:"Temperature",description:"Sampling temperature (0.0 to 2.0)",type:"number",path:["modelConfig","generateContentConfig","temperature"],defaultValue:void 0},{key:"topP",label:"Top P",description:"Nucleus sampling parameter (0.0 to 1.0)",type:"number",path:["modelConfig","generateContentConfig","topP"],defaultValue:void 0},{key:"topK",label:"Top K",description:"Top-K sampling parameter",type:"number",path:["modelConfig","generateContentConfig","topK"],defaultValue:void 0},{key:"maxOutputTokens",label:"Max Output Tokens",description:"Maximum number of tokens to generate",type:"number",path:["modelConfig","generateContentConfig","maxOutputTokens"],defaultValue:void 0},{key:"maxTimeMinutes",label:"Max Time (minutes)",description:"Maximum execution time in minutes",type:"number",path:["runConfig","maxTimeMinutes"],defaultValue:void 0},{key:"maxTurns",label:"Max Turns",description:"Maximum number of conversational turns",type:"number",path:["runConfig","maxTurns"],defaultValue:void 0}];function dg(e,t,o){if(!md(e))return e;let r={...e},n=r;for(let i=0;i<t.length-1;i++){let a=t[i];n[a]===void 0||n[a]===null?n[a]={}:md(n[a])&&(n[a]={...n[a]});let d=n[a];if(md(d))n=d;else return r}let s=t[t.length-1];return o===void 0?delete n[s]:n[s]=o,r}function sI(e,t){return t.kind!=="local"?e.defaultValue:e.key==="enabled"?!t.experimental:e.key==="model"?t.modelConfig?.model??"inherit":e.key==="temperature"?t.modelConfig?.generateContentConfig?.temperature:e.key==="topP"?t.modelConfig?.generateContentConfig?.topP:e.key==="topK"?t.modelConfig?.generateContentConfig?.topK:e.key==="maxOutputTokens"?t.modelConfig?.generateContentConfig?.maxOutputTokens:e.key==="maxTimeMinutes"?t.runConfig?.maxTimeMinutes:e.key==="maxTurns"?t.runConfig?.maxTurns:e.defaultValue}function aI({agentName:e,displayName:t,definition:o,settings:r,onClose:n,onSave:s,availableTerminalHeight:i}){let[a,d]=(0,Ir.useState)("User"),[m,f]=(0,Ir.useState)(()=>{let R=r.forScope(a).settings.agents?.overrides?.[e];return R?structuredClone(R):{}}),[h,p]=(0,Ir.useState)(new Set);(0,Ir.useEffect)(()=>{let R=r.forScope(a).settings.agents?.overrides?.[e];f(R?structuredClone(R):{}),p(new Set)},[a,r,e]);let y=(0,Ir.useCallback)((v,R,b)=>{if(["__proto__","constructor","prototype"].includes(e))return;let _=["agents","overrides",e,...R].join(".");r.setValue(a,_,b),s?.()},[r,a,e,s]),g=(0,Ir.useMemo)(()=>{let v=0;for(let R of Kc){let b=$r(R.label),_=$r(R.description);v=Math.max(v,b,_)}return v},[]),x=(0,Ir.useMemo)(()=>Kc.map(v=>{let R=Cf(m,v.path),b=sI(v,o),_=R!==void 0?R:b,w;v.type==="boolean"?w=_?"true":"false":_!=null?w=String(_):w="(default)",(h.has(v.key)||R!==void 0)&&R!==void 0&&(w+="*");let D=R!==void 0?R:_;return{key:v.key,label:v.label,description:v.description,type:v.type,displayValue:w,isGreyedOut:R===void 0,scopeMessage:void 0,rawValue:D}}),[m,o,h]),S=8,I=(0,Ir.useCallback)(v=>{d(v)},[]),A=(0,Ir.useCallback)((v,R)=>{let b=Kc.find(O=>O.key===v);if(!b||b.type!=="boolean")return;let _=Cf(m,b.path),w=sI(b,o),D=!(_!==void 0?_:w),N=dg(m,b.path,D);f(N),p(O=>new Set(O).add(v)),y(b.key,b.path,D)},[m,o,y]),E=(0,Ir.useCallback)((v,R,b)=>{let _=Kc.find(D=>D.key===v);if(!_)return;let w;if(_.type==="number")if(R.trim()==="")w=void 0;else{let D=Number(R.trim());if(Number.isNaN(D))return;w=D}else w=R.trim()===""?void 0:R;let M=dg(m,_.path,w);f(M),p(D=>new Set(D).add(v)),y(_.key,_.path,w)},[m,y]),T=(0,Ir.useCallback)((v,R)=>{let b=Kc.find(w=>w.key===v);if(!b)return;let _=dg(m,b.path,void 0);f(_),p(w=>{let M=new Set(w);return M.delete(v),M}),y(b.key,b.path,void 0)},[m,y]);return(0,mg.jsx)(ym,{title:`Configure: ${t}`,searchEnabled:!1,items:x,showScopeSelector:!0,selectedScope:a,onScopeChange:I,maxItemsToShow:S,availableHeight:i,maxLabelWidth:g,onItemToggle:A,onEditCommit:E,onItemClear:T,onClose:n,footer:h.size>0?{content:(0,mg.jsx)(l,{color:c.text.secondary,children:"Changes saved automatically."}),height:1}:void 0})}var Rm=C(z(),1);var Fi=C(P(),1);var lI=({config:e,request:t,onClose:o})=>{let r=Ze(),n=(0,Rm.useRef)(!1),s=(0,Rm.useCallback)(async a=>{if(!n.current){n.current=!0;try{a==="accept"&&(await new Nx().acceptIntegrity(t.scope,t.identifier,t.newHash),await e.loadWorkspacePolicies(t.policyDir)),o()}finally{n.current=!1}}},[e,t,o]);me(a=>r["basic.cancel"](a)?(o(),!0):!1,{isActive:!0});let i=[{label:"Accept and Load",value:"accept",key:"accept"},{label:"Ignore (Use Default Policies)",value:"ignore",key:"ignore"}];return(0,Fi.jsx)(u,{flexDirection:"column",width:"100%",children:(0,Fi.jsxs)(u,{flexDirection:"column",borderStyle:"round",borderColor:c.status.warning,padding:1,marginLeft:1,marginRight:1,children:[(0,Fi.jsxs)(u,{flexDirection:"column",marginBottom:1,children:[(0,Fi.jsxs)(l,{bold:!0,color:c.text.primary,children:["New or changed ",t.scope," policies detected"]}),(0,Fi.jsxs)(l,{color:c.text.primary,children:["Location: ",t.identifier]}),(0,Fi.jsx)(l,{color:c.text.primary,children:"Do you want to accept and load these policies?"})]}),(0,Fi.jsx)(We,{items:i,onSelect:s,isFocused:!0})]})})};var jc=C(P(),1);var cI=({onDismiss:e,config:t,message:o})=>{me(n=>n.name==="escape"?(e(),!0):n.name==="r"||n.name==="R"?(setTimeout(async()=>{if(process.send){let s=t.getRemoteAdminSettings();s&&process.send({type:"admin-settings-update",settings:s})}await fr()},100),!0):!1,{isActive:!0});let r=o??"You've successfully signed in with Google. Gemini CLI needs to be restarted.";return(0,jc.jsxs)(u,{borderStyle:"round",borderColor:c.status.warning,paddingX:1,flexDirection:"column",children:[(0,jc.jsx)(l,{color:c.status.warning,children:r}),(0,jc.jsx)(l,{color:c.status.warning,children:"Press R to restart, or Esc to choose a different authentication method."})]})};var $e=C(P(),1);var Im=({addItem:e,terminalWidth:t})=>{let o=Ct(),r=Ke(),n=Ce(),s=Rd(),i=Pr(),{constrainHeight:a,terminalHeight:d,staticExtraHeight:m,terminalWidth:f}=n;if(n.adminSettingsChanged)return(0,$e.jsx)(nI,{});if(n.showIdeRestartPrompt)return(0,$e.jsx)(iI,{reason:n.ideTrustRestartReason});if(n.newAgents)return(0,$e.jsx)(qb,{agents:n.newAgents,onSelect:i.handleNewAgentsSelect});if(s.proQuotaRequest)return(0,$e.jsx)(HR,{failedModel:s.proQuotaRequest.failedModel,fallbackModel:s.proQuotaRequest.fallbackModel,message:s.proQuotaRequest.message,isTerminalQuotaError:s.proQuotaRequest.isTerminalQuotaError,isModelNotFoundError:!!s.proQuotaRequest.isModelNotFoundError,authType:s.proQuotaRequest.authType,tierName:o?.getUserTierName(),onChoice:i.handleProQuotaChoice});if(s.validationRequest)return(0,$e.jsx)(FR,{validationLink:s.validationRequest.validationLink,validationDescription:s.validationRequest.validationDescription,learnMoreUrl:s.validationRequest.learnMoreUrl,onChoice:i.handleValidationChoice});if(s.overageMenuRequest)return(0,$e.jsx)(UR,{failedModel:s.overageMenuRequest.failedModel,fallbackModel:s.overageMenuRequest.fallbackModel,resetTime:s.overageMenuRequest.resetTime,creditBalance:s.overageMenuRequest.creditBalance,onChoice:i.handleOverageMenuChoice});if(s.emptyWalletRequest)return(0,$e.jsx)(GR,{failedModel:s.emptyWalletRequest.failedModel,fallbackModel:s.emptyWalletRequest.fallbackModel,resetTime:s.emptyWalletRequest.resetTime,onGetCredits:s.emptyWalletRequest.onGetCredits,onChoice:i.handleEmptyWalletChoice});if(n.shouldShowIdePrompt)return(0,$e.jsx)(Fb,{ide:n.currentIDE,onComplete:i.handleIdePromptComplete});if(n.isFolderTrustDialogOpen)return(0,$e.jsx)(Ub,{onSelect:i.handleFolderTrustSelect,isRestarting:n.isRestarting,discoveryResults:n.folderDiscoveryResults});if(n.isPolicyUpdateDialogOpen)return(0,$e.jsx)(lI,{config:o,request:n.policyUpdateConfirmationRequest,onClose:()=>i.setIsPolicyUpdateDialogOpen(!1)});if(n.loopDetectionConfirmationRequest)return(0,$e.jsx)(fR,{onComplete:n.loopDetectionConfirmationRequest.onComplete});if(n.permissionConfirmationRequest){let p=n.permissionConfirmationRequest.files.map(y=>`- ${y}`).join(`
61
- `);return(0,$e.jsx)(Fc,{prompt:`The following files are outside your workspace:
60
+ `,availableTerminalHeight:i===!1?W:void 0,terminalWidth:b,theme:L})]}),eS&&(0,Rt.jsx)(u,{marginTop:1,children:(0,Rt.jsx)(hR,{activeTheme:L})})]})]}):(0,Rt.jsx)(gR,{onSelect:E,onHighlight:A,isFocused:T==="scope",initialScope:d}),(0,Rt.jsx)(u,{marginTop:1,children:(0,Rt.jsxs)(l,{color:c.text.secondary,wrap:"truncate",children:["(Use Enter to ",T==="theme"?"select":"apply scope",", Tab to"," ",T==="theme"?"configure scope":"select theme",", Esc to close)"]})})]})}var ro=C(z(),1);var ki=C(z(),1);var ig=C(dd(),1);var Ni=C(z(),1);function ng(e,t,o,r){t<e?e=t:t>=e+r&&(e=t-r+1);let n=Math.max(0,o-r),s=Math.min(e,n);return Math.max(0,s)}function FM(e,t){return function(r,n){if(e.length===0)return r;let s=e.findIndex(a=>a.key===r.activeItemKey),i=s!==-1?s:0;switch(n.type){case"MOVE_UP":{let a=i>0?i-1:e.length-1;return{activeItemKey:e[a].key,windowStart:ng(r.windowStart,a,e.length,t)}}case"MOVE_DOWN":{let a=i<e.length-1?i+1:0;return{activeItemKey:e[a].key,windowStart:ng(r.windowStart,a,e.length,t)}}default:return r}}}function SR({items:e,maxItemsToShow:t}){let o=(0,Ni.useMemo)(()=>FM(e,t),[e,t]),[r,n]=(0,Ni.useReducer)(o,{activeItemKey:e[0]?.key??null,windowStart:0}),s=(0,Ni.useMemo)(()=>{if(e.length===0)return 0;let m=e.findIndex(f=>f.key===r.activeItemKey);return m!==-1?m:0},[e,r.activeItemKey]),i=(0,Ni.useMemo)(()=>ng(r.windowStart,s,e.length,t),[r.windowStart,s,e.length,t]),a=(0,Ni.useCallback)(()=>n({type:"MOVE_UP"}),[]),d=(0,Ni.useCallback)(()=>n({type:"MOVE_DOWN"}),[]);return{activeItemKey:r.activeItemKey,activeIndex:s,windowStart:i,moveUp:a,moveDown:d}}var Bi=C(z(),1);var CR={editingKey:null,buffer:"",cursorPos:0};function UM(e,t){switch(t.type){case"START_EDIT":return{editingKey:t.key,buffer:t.initialValue,cursorPos:to(t.initialValue)};case"COMMIT_EDIT":return CR;case"MOVE_LEFT":return{...e,cursorPos:Math.max(0,e.cursorPos-1)};case"MOVE_RIGHT":return{...e,cursorPos:Math.min(to(e.buffer),e.cursorPos+1)};case"HOME":return{...e,cursorPos:0};case"END":return{...e,cursorPos:to(e.buffer)};case"DELETE_LEFT":{if(e.cursorPos===0)return e;let o=Ut(e.buffer,0,e.cursorPos-1),r=Ut(e.buffer,e.cursorPos);return{...e,buffer:o+r,cursorPos:e.cursorPos-1}}case"DELETE_RIGHT":{if(e.cursorPos===to(e.buffer))return e;let o=Ut(e.buffer,0,e.cursorPos),r=Ut(e.buffer,e.cursorPos+1);return{...e,buffer:o+r}}case"INSERT_CHAR":{let o=t.char,r=!1;if(t.isNumberType?r=/[0-9\-+.]/.test(o):(r=o.length===1&&o.charCodeAt(0)>=32,o=ln(o)),!r||o.length===0)return e;let n=Ut(e.buffer,0,e.cursorPos),s=Ut(e.buffer,e.cursorPos);return{...e,buffer:n+o+s,cursorPos:e.cursorPos+1}}default:return e}}function bR({onCommit:e}){let[t,o]=(0,Bi.useReducer)(UM,CR),[r,n]=(0,Bi.useState)(!0);(0,Bi.useEffect)(()=>{if(!t.editingKey){n(!0);return}n(!0);let a=setInterval(()=>{n(d=>!d)},500);return()=>clearInterval(a)},[t.editingKey,t.buffer,t.cursorPos]);let s=(0,Bi.useCallback)((a,d)=>{o({type:"START_EDIT",key:a,initialValue:d})},[]),i=(0,Bi.useCallback)(()=>{t.editingKey&&e(t.editingKey,t.buffer),o({type:"COMMIT_EDIT"})},[t.editingKey,t.buffer,e]);return{editState:t,editDispatch:o,startEditing:s,commitEdit:i,cursorVisible:r}}var et=C(P(),1);function ym({title:e,borderColor:t,searchEnabled:o=!0,searchPlaceholder:r="Search to filter",searchBuffer:n,items:s,showScopeSelector:i=!0,scopeItems:a,selectedScope:d,onScopeChange:m,maxItemsToShow:f,maxLabelWidth:h,onItemToggle:p,onEditCommit:y,onItemClear:g,onClose:x,onKeyPress:S,keyMatchers:I,availableHeight:A,footer:E}){let T=Ze(),v=I??T,R=(0,ki.useMemo)(()=>(a??Ml()).map(j=>({...j,key:j.value})),[a]),b=i&&R.length>1,{effectiveMaxItemsToShow:_,finalShowScopeSelector:w}=(0,ki.useMemo)(()=>{let j=b,$=f;if(!A)return{effectiveMaxItemsToShow:$,finalShowScopeSelector:j};let X=4,Q=1,be=o?5:1,De=2,ke=1,ue=5,Ue=1,Tt=E?.height??0,It=3,An=A-X,Jr=Q+be+De+ke+Ue+Tt,cr=Jr+ue,ko=An-cr,Zr=Math.max(1,Math.floor(ko/It)),Lt=An-Jr,ur=Math.max(1,Math.floor(Lt/It)),Fn=j,Si=j?Zr:ur;return j&&A<25&&ur>Zr+1&&(Fn=!1,Si=ur),{effectiveMaxItemsToShow:Math.min(Si,s.length),finalShowScopeSelector:Fn}},[A,f,s.length,o,b,E]),{activeIndex:M,windowStart:D,moveUp:N,moveDown:O}=SR({items:s,maxItemsToShow:_}),{editState:W,editDispatch:L,startEditing:k,commitEdit:F,cursorVisible:B}=bR({onCommit:(j,$)=>{let X=s.find(Q=>Q.key===j);X&&y(j,$,X)}}),{editingKey:K,buffer:q,cursorPos:Z}=W,[Y,oe]=(0,ki.useState)("settings"),ce=!w&&Y==="scope"?"settings":Y,G=s.slice(D,D+_),ee=s.length>_,te=s.length>_,ae=s[M],ne=(0,ki.useCallback)(j=>{m?.(j)},[m]);return me(j=>{if(!(!K&&S?.(j,ae))){if(K){let X=s.find(Q=>Q.key===K)?.type??"string";if(v["cursor.left"](j)){L({type:"MOVE_LEFT"});return}if(v["cursor.right"](j)){L({type:"MOVE_RIGHT"});return}if(v["cursor.home"](j)){L({type:"HOME"});return}if(v["cursor.end"](j)){L({type:"END"});return}if(v["edit.deleteLeft"](j)){L({type:"DELETE_LEFT"});return}if(v["edit.deleteRight"](j)){L({type:"DELETE_RIGHT"});return}if(v["basic.cancel"](j)){F();return}if(v["basic.confirm"](j)){F();return}if(v["nav.dialog.up"](j)&&!j.insertable){F(),N();return}if(v["nav.dialog.down"](j)&&!j.insertable){F(),O();return}j.sequence&&L({type:"INSERT_CHAR",char:j.sequence,isNumberType:X==="number"});return}if(ce==="settings"){if(v["nav.dialog.up"](j))return N(),!0;if(v["nav.dialog.down"](j))return O(),!0;if(v["basic.confirm"](j)&&ae){if(ae.type==="boolean"||ae.type==="enum")p(ae.key,ae);else{let $=ae.rawValue,X=ae.editValue??($!==void 0?String($):"");k(ae.key,X)}return!0}if(v["app.clearScreen"](j)&&ae)return g(ae.key,ae),!0;if(ae?.type==="number"&&/^[0-9]$/.test(j.sequence))return k(ae.key,j.sequence),!0}if(j.name==="tab"&&w){oe($=>$==="settings"?"scope":"settings");return}if(v["basic.cancel"](j)){x();return}}},{isActive:!0,priority:ce==="settings"}),(0,et.jsx)(u,{borderStyle:"round",borderColor:t??c.border.default,flexDirection:"row",padding:1,width:"100%",maxHeight:A,children:(0,et.jsxs)(u,{flexDirection:"column",flexGrow:1,children:[(0,et.jsx)(u,{marginX:1,children:(0,et.jsxs)(l,{bold:ce==="settings"&&!K,wrap:"truncate",children:[ce==="settings"?"> ":" ",e," "]})}),o&&n&&(0,et.jsx)(u,{borderStyle:"round",borderColor:K?c.border.default:ce==="settings"?c.ui.focus:c.border.default,paddingX:1,height:3,marginTop:1,children:(0,et.jsx)(ua,{focus:ce==="settings"&&!K,buffer:n,placeholder:r})}),(0,et.jsx)(u,{height:1}),G.length===0?(0,et.jsx)(u,{marginX:1,height:1,flexDirection:"column",children:(0,et.jsx)(l,{color:c.text.secondary,children:"No matches found."})}):(0,et.jsxs)(et.Fragment,{children:[ee&&(0,et.jsx)(u,{marginX:1,children:(0,et.jsx)(l,{color:c.text.secondary,children:"\u25B2"})}),G.map((j,$)=>{let X=$+D,Q=ce==="settings"&&M===X,be;if(K===j.key)if(B&&Z<to(q)){let De=Ut(q,0,Z),ke=Ut(q,Z,Z+1),ue=Ut(q,Z+1);be=De+ig.default.inverse(ke)+ue}else Z>=to(q)?be=q+(B?ig.default.inverse(" "):" "):be=q;else be=j.displayValue;return(0,et.jsxs)(ki.default.Fragment,{children:[(0,et.jsxs)(u,{marginX:1,flexDirection:"row",alignItems:"flex-start",backgroundColor:Q?c.background.focus:void 0,children:[(0,et.jsx)(u,{minWidth:2,flexShrink:0,children:(0,et.jsx)(l,{color:Q?c.ui.focus:c.text.secondary,children:Q?"\u25CF":""})}),(0,et.jsxs)(u,{flexDirection:"row",flexGrow:1,minWidth:0,alignItems:"flex-start",children:[(0,et.jsxs)(u,{flexDirection:"column",width:h,minWidth:0,children:[(0,et.jsxs)(l,{color:Q?c.ui.focus:c.text.primary,children:[j.label,j.scopeMessage&&(0,et.jsxs)(l,{color:c.text.secondary,children:[" ",j.scopeMessage]})]}),(0,et.jsx)(l,{color:c.text.secondary,wrap:"truncate",children:j.description??""})]}),(0,et.jsx)(u,{minWidth:3}),(0,et.jsx)(u,{flexShrink:0,children:(0,et.jsx)(l,{color:Q?c.ui.focus:j.isGreyedOut?c.text.secondary:c.text.primary,terminalCursorFocus:K===j.key&&B,terminalCursorPosition:ud(q,Z),children:be})})]})]}),(0,et.jsx)(u,{height:1})]},j.key)}),te&&(0,et.jsx)(u,{marginX:1,children:(0,et.jsx)(l,{color:c.text.secondary,children:"\u25BC"})})]}),(0,et.jsx)(u,{height:1}),w&&(0,et.jsxs)(u,{marginX:1,flexDirection:"column",children:[(0,et.jsxs)(l,{bold:ce==="scope",wrap:"truncate",children:[ce==="scope"?"> ":" ","Apply To"]}),(0,et.jsx)(We,{items:R,initialIndex:R.findIndex(j=>j.value===d),onSelect:ne,onHighlight:ne,isFocused:ce==="scope",showNumbers:ce==="scope",priority:ce==="scope"})]}),(0,et.jsx)(u,{height:1}),(0,et.jsx)(u,{marginX:1,children:(0,et.jsxs)(l,{color:c.text.secondary,children:["(Use Enter to select, ",Ee("app.clearScreen")," to reset",w?", Tab to change focus":"",", Esc to close)"]})}),E&&(0,et.jsx)(u,{marginX:1,children:E.content})]})})}var sg=C(P(),1);var GM=8,WM=new Ic("up"),VM=new Ic("ctrl+p"),$M=new Ic("down"),qM=new Ic("ctrl+n");function KM(e){let t=new Map,o=[["User",e.user.settings],["Workspace",e.workspace.settings],["System",e.system.settings]];for(let r of OS()){let n=new Map;for(let[s,i]of o){let a=aa(r,i)?Ec(r,i):void 0;n.set(s,JSON.stringify(a))}t.set(r,n)}return t}function ER({onSelect:e,onRestartRequest:t,availableTerminalHeight:o}){let{settings:r,setSetting:n}=gd(),[s,i]=(0,ro.useState)("User"),a=(0,ro.useMemo)(()=>Ml().filter(k=>{let F=r.forScope(k.value);return F.readOnly!==!0&&(k.value!=="Workspace"||F.path!==void 0)}),[r]),d=a.find(k=>k.value===s)?.value??a[0]?.value,m=d??"User";d&&s!==d&&i(d);let[f]=(0,ro.useState)(()=>KM(r)),[h,p]=(0,ro.useState)(""),[y,g]=(0,ro.useState)(()=>sl()),{fzfInstance:x,searchMap:S}=(0,ro.useMemo)(()=>{let k=sl(),F=new Map,B=[];return k.forEach(q=>{let Z=il(q);Z?.label&&(B.push(Z.label),F.set(Z.label.toLowerCase(),q))}),{fzfInstance:new ta(B,{fuzzy:"v2",casing:"case-insensitive"}),searchMap:F}},[]);(0,ro.useEffect)(()=>{let k=!0;if(!h.trim()||!x){g(sl());return}return(async()=>{let B=await x.find(h);if(!k)return;let K=new Set;B.forEach(q=>{let Z=S.get(q.item.toLowerCase());Z&&K.add(Z)}),g(Array.from(K))})(),()=>{k=!1}},[h,x,S]);let A=(0,ro.useMemo)(()=>{let k=new Set,F=[["User",r.user.settings],["Workspace",r.workspace.settings],["System",r.system.settings]];for(let[B,K]of f)for(let[q,Z]of F){let Y=aa(B,Z)?Ec(B,Z):void 0,oe=K.get(q);if(JSON.stringify(Y)!==oe){k.add(B);break}}return k},[r,f]).size>0,E=(0,ro.useMemo)(()=>{let k=sl(),F=0;for(let B of k){let K=il(B);if(!K)continue;let q=Uc(B,m,r),Y=(K.label||B)+(q?` ${q}`:""),oe=$r(Y),ce=K.description?$r(K.description):0;F=Math.max(F,oe,ce)}return F},[m,r]),T=RC({initialText:"",onChange:p}),v=h?y:sl(),R=(0,ro.useMemo)(()=>{let k=r.forScope(m).settings,F=r.merged;return v.map(B=>{let K=il(B),q=K?.type??"string",Z=LS(B,k,F),Y=Uc(B,m,r),oe=!aa(B,k),ce=Ec(B,k),G=BS(q,ce);return{key:B,label:K?.label||B,description:K?.description,type:q,displayValue:Z,isGreyedOut:oe,scopeMessage:Y,rawValue:ce,editValue:G}})},[v,m,r]),b=(0,ro.useCallback)(k=>{i(k)},[]),_=(0,ro.useCallback)((k,F)=>{if(!d)return;let B=il(k);if(!vS.has(B?.type))return;let K=r.forScope(d).settings,q=Ec(k,K),Z;if(B?.type==="boolean"){if(typeof q!="boolean")return;Z=!q}else if(B?.type==="enum"&&B.options){let Y=B.options;if(Y.length===0)return;let oe=Y?.findIndex(ce=>ce.value===q);oe!==-1&&oe<Y.length-1?Z=Y[oe+1].value:Z=Y[0].value}else return;de.log(`[DEBUG SettingsDialog] Saving ${k} immediately with value:`,Z),n(d,k,Z)},[r,d,n]),w=(0,ro.useCallback)((k,F,B)=>{if(!d)return;let q=il(k)?.type??"string",Z=NS(q,F);Z!==null&&n(d,k,Z)},[d,n]),M=(0,ro.useCallback)((k,F)=>{d&&n(d,k,void 0)},[d,n]),D=(0,ro.useCallback)(()=>{e(void 0,m)},[e,m]),N=Ze(),O=(0,ro.useMemo)(()=>({...N,"nav.dialog.up":k=>WM.matches(k)||VM.matches(k),"nav.dialog.down":k=>$M.matches(k)||qM.matches(k)}),[N]),W=(0,ro.useCallback)((k,F)=>A&&k.sequence==="r"?(t&&t(),!0):!1,[A,t]),L=!A;return(0,sg.jsx)(ym,{title:"Settings",borderColor:A?c.status.warning:void 0,searchEnabled:L,searchBuffer:T,items:R,showScopeSelector:a.length>1,scopeItems:a,selectedScope:m,onScopeChange:b,maxItemsToShow:GM,availableHeight:o,maxLabelWidth:E,onItemToggle:_,onEditCommit:w,onItemClear:M,onClose:D,onKeyPress:W,keyMatchers:O,footer:A?{content:(0,sg.jsx)(l,{color:c.status.warning,children:"Changes that require a restart have been modified. Press r to exit and apply changes now."}),height:1}:void 0})}var Tm=C(z(),1);var Ia=C(P(),1);function RR({onTimeout:e}){let[t,o]=(0,Tm.useState)(!1);return me(r=>{(r.name==="escape"||r.ctrl&&r.name==="c")&&e()},{isActive:!0}),(0,Tm.useEffect)(()=>{let r=setTimeout(()=>{o(!0),e()},18e4);return()=>clearTimeout(r)},[e]),(0,Ia.jsx)(u,{borderStyle:"round",borderColor:c.border.default,flexDirection:"column",padding:1,width:"100%",children:t?(0,Ia.jsx)(l,{color:c.status.error,children:"Authentication timed out. Please try again."}):(0,Ia.jsx)(u,{children:(0,Ia.jsxs)(l,{children:[(0,Ia.jsx)(Mo,{type:"dots"})," Waiting for authentication... (Press Esc or Ctrl+C to cancel)"]})})})}var xm=C(z(),1);var On=C(z(),1);function ag(e,t){let o=t.merged.security.auth.enforcedType;return o&&o!==e?`Authentication is enforced to be ${o}, but you are currently using ${e}.`:t.merged.security.auth.useExternal||e===$e.USE_GEMINI?null:Dd(e)}var vR=(e,t,o=null,r=null)=>{let[n,s]=(0,On.useState)(o?"updating":"unauthenticated"),[i,a]=(0,On.useState)(o),[d,m]=(0,On.useState)(r),[f,h]=(0,On.useState)(void 0),p=(0,On.useCallback)(g=>{a(g),g&&s("updating")},[a,s]),y=(0,On.useCallback)(async()=>{let g=process.env.GEMINI_API_KEY;if(g!==void 0)return h(g),g;let x=await Cx()??"";return h(x),x},[]);return(0,On.useEffect)(()=>{n==="awaiting_api_key_input"&&y()},[n,y]),(0,On.useEffect)(()=>{(async()=>{if(n!=="unauthenticated")return;let g=(process.env.USE_VERTEX?$e.USE_VERTEX_AI:void 0)||e.merged.security.auth.selectedType;if(!g){process.env.GEMINI_API_KEY?p('Existing API key detected (GEMINI_API_KEY). Select "Gemini API Key" option to use it.'):p("No authentication method selected.");return}if(g===$e.USE_GEMINI&&!await y()){s("awaiting_api_key_input");return}let x=ag(g,e);if(x){p(x);return}let S=process.env.GEMINI_DEFAULT_AUTH_TYPE;if(S&&!Object.values($e).includes(S)){p(`Invalid value for GEMINI_DEFAULT_AUTH_TYPE: "${S}". Valid values are: ${Object.values($e).join(", ")}.`);return}try{await t.refreshAuth(g),de.log(`Authenticated via "${g}".`),a(null),s("authenticated")}catch(I){let A=uT(I);A?m({message:A.message,appealUrl:A.appealUrl,appealLinkText:A.appealLinkText}):I instanceof rd?p(Vr(I)):p(`Failed to sign in. Message: ${Vr(I)}`)}})()},[e,t,n,s,a,p,y]),{authState:n,setAuthState:s,authError:i,onAuthError:p,apiKeyDefaultValue:f,reloadApiKey:y,accountSuspensionInfo:d,setAccountSuspensionInfo:m}};var mo=C(P(),1);function AR({config:e,settings:t,setAuthState:o,authError:r,onAuthError:n,setAuthContext:s}){let[i,a]=(0,xm.useState)(!1),d=[{label:"Sign in with Google",value:$e.LOGIN_WITH_GOOGLE,key:$e.LOGIN_WITH_GOOGLE},...process.env.CLOUD_SHELL==="true"?[{label:"Use Cloud Shell user credentials",value:$e.COMPUTE_ADC,key:$e.COMPUTE_ADC}]:process.env.GEMINI_CLI_USE_COMPUTE_ADC==="true"?[{label:"Use metadata server application default credentials",value:$e.COMPUTE_ADC,key:$e.COMPUTE_ADC}]:[],{label:"Use Gemini API Key",value:$e.USE_GEMINI,key:$e.USE_GEMINI},{label:"Vertex AI",value:$e.USE_VERTEX_AI,key:$e.USE_VERTEX_AI}];t.merged.security.auth.enforcedType&&(d=d.filter(g=>g.value===t.merged.security.auth.enforcedType));let m=null,f=process.env.GEMINI_DEFAULT_AUTH_TYPE;f&&Object.values($e).includes(f)&&(m=f);let h=d.findIndex(g=>t.merged.security.auth.selectedType?g.value===t.merged.security.auth.selectedType:m?g.value===m:process.env.GEMINI_API_KEY?g.value===$e.USE_GEMINI:g.value===$e.LOGIN_WITH_GOOGLE);t.merged.security.auth.enforcedType&&(h=0);let p=(0,xm.useCallback)(async(g,x)=>{if(!i){if(g){let S=g===$e.LOGIN_WITH_GOOGLE||g===$e.USE_VERTEX_AI&&process.env.CLOUD_SHELL==="true";if(s(S?{requiresRestart:!0}:{}),await ed(),t.setValue(x,"security.auth.selectedType",g),g===$e.LOGIN_WITH_GOOGLE&&e.isBrowserLaunchSuppressed()){a(!0),setTimeout(fr,100);return}if(g===$e.USE_GEMINI){o("awaiting_api_key_input");return}}o("unauthenticated")}},[t,e,o,i,s]),y=g=>{let x=ag(g,t);x?n(x):p(g,"User")};return me(g=>g.name==="escape"?r?!0:t.merged.security.auth.selectedType===void 0?(n("You must select an auth method to proceed. Press Ctrl+C twice to exit."),!0):(p(void 0,"User"),!0):!1,{isActive:!0}),i?(0,mo.jsx)(u,{borderStyle:"round",borderColor:c.ui.focus,flexDirection:"row",padding:1,width:"100%",alignItems:"flex-start",children:(0,mo.jsx)(l,{color:c.text.primary,children:"Logging in with Google... Restarting Gemini CLI to continue."})}):(0,mo.jsxs)(u,{borderStyle:"round",borderColor:c.ui.focus,flexDirection:"row",padding:1,width:"100%",alignItems:"flex-start",children:[(0,mo.jsx)(l,{color:c.text.accent,children:"? "}),(0,mo.jsxs)(u,{flexDirection:"column",flexGrow:1,children:[(0,mo.jsx)(l,{bold:!0,color:c.text.primary,children:"Get started"}),(0,mo.jsx)(u,{marginTop:1,children:(0,mo.jsx)(l,{color:c.text.primary,children:"How would you like to authenticate for this project?"})}),(0,mo.jsx)(u,{marginTop:1,children:(0,mo.jsx)(We,{items:d,initialIndex:h,onSelect:y,onHighlight:()=>{n(null)}})}),r&&(0,mo.jsx)(u,{marginTop:1,children:(0,mo.jsx)(l,{color:c.status.error,children:r})}),(0,mo.jsx)(u,{marginTop:1,children:(0,mo.jsx)(l,{color:c.text.secondary,children:"(Use Enter to select)"})}),(0,mo.jsx)(u,{marginTop:1,children:(0,mo.jsx)(l,{color:c.text.primary,children:"Terms of Services and Privacy Notice for Gemini CLI"})}),(0,mo.jsx)(u,{marginTop:1,children:(0,mo.jsx)(l,{color:c.text.link,children:"https://geminicli.com/docs/resources/tos-privacy/"})})]})]})}var va=C(z(),1);var Ro=C(P(),1);function wR({accountSuspensionInfo:e,onExit:t,onChangeAuth:o}){let[r,n]=(0,va.useState)(null),s=e.appealUrl,i=e.appealLinkText??"Open the Google Form",a=(0,va.useMemo)(()=>{let f=[];return s&&f.push({label:i,value:"open_form",key:"open_form"}),f.push({label:"Change authentication",value:"change_auth",key:"change_auth"},{label:"Exit",value:"exit",key:"exit"}),f},[s,i]);me(f=>f.name==="escape"?(d(),!0):!1,{isActive:!0});let d=(0,va.useCallback)(async()=>{await jn(),t()},[t]),m=(0,va.useCallback)(async f=>{if(f==="open_form"&&s){if(!el()){n(`Please open this URL in a browser: ${s}`);return}try{await Za(s)}catch{n(`Failed to open browser. Please visit: ${s}`)}}else f==="change_auth"?o():await d()},[d,o,s]);return(0,Ro.jsxs)(u,{flexDirection:"column",padding:1,children:[(0,Ro.jsx)(l,{bold:!0,color:c.status.error,children:"Error: Account Suspended"}),(0,Ro.jsx)(u,{marginTop:1,children:(0,Ro.jsx)(l,{children:e.message})}),s&&(0,Ro.jsxs)(Ro.Fragment,{children:[(0,Ro.jsx)(u,{marginTop:1,children:(0,Ro.jsx)(l,{children:"Appeal URL:"})}),(0,Ro.jsx)(u,{children:(0,Ro.jsxs)(l,{color:c.text.link,children:["[",s,"]"]})})]}),r&&(0,Ro.jsx)(u,{marginTop:1,children:(0,Ro.jsx)(l,{color:c.status.error,children:r})}),(0,Ro.jsx)(u,{marginTop:1,children:(0,Ro.jsx)(We,{items:a,onSelect:f=>void m(f)})}),(0,Ro.jsx)(u,{marginTop:1,children:(0,Ro.jsx)(l,{dimColor:!0,children:"Escape to exit"})})]})}var Sm=C(z(),1);var Cr=C(P(),1);function _R({onSubmit:e,onCancel:t,error:o,defaultValue:r=""}){let n=Ze(),{terminalWidth:s}=Ce(),i=s-8,a=(0,Sm.useRef)(null);(0,Sm.useEffect)(()=>()=>{a.current?.cancel()},[]);let d=r,m=ca({initialText:d||"",initialCursorOffset:d?.length||0,viewport:{width:i,height:4},inputFilter:p=>p.replace(/[^a-zA-Z0-9_.-]/g,"").replace(/[\r\n]/g,""),singleLine:!0}),f=p=>{e(p)},h=()=>{a.current?.cancel();let p=!1,y=new Promise((g,x)=>{Ex().then(()=>!p&&g(),S=>!p&&x(S))});return a.current={cancel:()=>{p=!0}},y.then(()=>{m.setText("")}).catch(g=>{de.debug("Failed to clear API key:",g)})};return me(p=>n["edit.clear"](p)?(h(),!0):!1,{isActive:!0}),(0,Cr.jsxs)(u,{borderStyle:"round",borderColor:c.ui.focus,flexDirection:"column",padding:1,width:"100%",children:[(0,Cr.jsx)(l,{bold:!0,color:c.text.primary,children:"Enter Gemini API Key"}),(0,Cr.jsxs)(u,{marginTop:1,flexDirection:"column",children:[(0,Cr.jsx)(l,{color:c.text.primary,children:"Please enter your Gemini API key. It will be securely stored in your system keychain."}),(0,Cr.jsxs)(l,{color:c.text.secondary,children:["You can get an API key from"," ",(0,Cr.jsx)(l,{color:c.text.link,children:"https://aistudio.google.com/app/apikey"})]})]}),(0,Cr.jsx)(u,{marginTop:1,flexDirection:"row",children:(0,Cr.jsx)(u,{borderStyle:"round",borderColor:c.border.default,paddingX:1,flexGrow:1,children:(0,Cr.jsx)(ua,{buffer:m,onSubmit:f,onCancel:t,placeholder:"Paste your API key here"})})}),o&&(0,Cr.jsx)(u,{marginTop:1,children:(0,Cr.jsx)(l,{color:c.status.error,children:o})}),(0,Cr.jsx)(u,{marginTop:1,children:(0,Cr.jsx)(l,{color:c.text.secondary,children:"(Press Enter to submit, Esc to cancel, Ctrl+C to clear stored key)"})})]})}var cg=C(z(),1);var lg=class{availableEditors;constructor(){let t=Object.keys(Sc).sort();this.availableEditors=[{name:"None",type:"not_set",disabled:!1},...t.map(o=>{let r=td(o),n=od(o),s=n?"":" (Not available in sandbox)";return s=r?s:" (Not installed)",{name:Sc[o]+s,type:o,disabled:!r||!n}})]}getAvailableEditorDisplays(){return this.availableEditors}},DR=new lg;var No=C(P(),1);function MR({onSelect:e,settings:t,onExit:o}){let[r,n]=(0,cg.useState)("User"),[s,i]=(0,cg.useState)("editor");me(S=>S.name==="tab"?(i(I=>I==="editor"?"scope":"editor"),!0):S.name==="escape"?(o(),!0):!1,{isActive:!0});let a=DR.getAvailableEditorDisplays(),d=t.forScope(r).settings.general?.preferredEditor,m=d?a.findIndex(S=>S.type===d):0;m===-1&&(Se.emitFeedback("error",`Editor is not supported: ${d}`),m=0);let f=[{label:"User Settings",value:"User",key:"User"},{label:"Workspace Settings",value:"Workspace",key:"Workspace"}],h=S=>{if(S==="not_set"){e(void 0,r);return}e(S,r)},p=S=>{n(S),i("editor")},y="",g=r==="User"?"Workspace":"User";t.forScope(g).settings.general?.preferredEditor!==void 0&&(y=t.forScope(r).settings.general?.preferredEditor!==void 0?`(Also modified in ${g})`:`(Modified in ${g})`);let x="None";return t.merged.general.preferredEditor&&ux(t.merged.general.preferredEditor)&&(x=Sc[t.merged.general.preferredEditor]),(0,No.jsxs)(u,{borderStyle:"round",borderColor:c.border.default,flexDirection:"row",padding:1,width:"100%",children:[(0,No.jsxs)(u,{flexDirection:"column",width:"45%",paddingRight:2,children:[(0,No.jsxs)(l,{bold:s==="editor",children:[s==="editor"?"> ":" ","Select Editor"," ",(0,No.jsx)(l,{color:c.text.secondary,children:y})]}),(0,No.jsx)(We,{items:a.map(S=>({label:S.name,value:S.type,disabled:S.disabled,key:S.type})),initialIndex:m,onSelect:h,isFocused:s==="editor"},r),(0,No.jsxs)(u,{marginTop:1,flexDirection:"column",children:[(0,No.jsxs)(l,{bold:s==="scope",children:[s==="scope"?"> ":" ","Apply To"]}),(0,No.jsx)(We,{items:f,initialIndex:0,onSelect:p,isFocused:s==="scope"})]}),(0,No.jsx)(u,{marginTop:1,children:(0,No.jsx)(l,{color:c.text.secondary,children:"(Use Enter to select, Tab to change focus, Esc to close)"})})]}),(0,No.jsxs)(u,{flexDirection:"column",width:"55%",paddingLeft:2,children:[(0,No.jsx)(l,{bold:!0,color:c.text.primary,children:"Editor Preference"}),(0,No.jsxs)(u,{flexDirection:"column",gap:1,marginTop:1,children:[(0,No.jsx)(l,{color:c.text.secondary,children:"These editors are currently supported. Please note that some editors cannot be used in sandbox mode."}),(0,No.jsxs)(l,{color:c.text.secondary,children:["Your preferred editor is:"," ",(0,No.jsx)(l,{color:x==="None"?c.status.error:c.text.link,bold:!0,children:x}),"."]})]})]})]})}var no=C(P(),1);var PR=({onExit:e})=>(me(t=>t.name==="escape"?(e(),!0):!1,{isActive:!0}),(0,no.jsxs)(u,{flexDirection:"column",marginBottom:1,children:[(0,no.jsx)(l,{bold:!0,color:c.text.accent,children:"Gemini API Key Notice"}),(0,no.jsx)(Uo,{}),(0,no.jsxs)(l,{color:c.text.primary,children:["By using the Gemini API",(0,no.jsx)(l,{color:c.text.link,children:"[1]"}),", Google AI Studio",(0,no.jsx)(l,{color:c.status.error,children:"[2]"}),', and the other Google developer services that reference these terms (collectively, the "APIs" or "Services"), you are agreeing to Google APIs Terms of Service (the "API Terms")',(0,no.jsx)(l,{color:c.status.success,children:"[3]"}),', and the Gemini API Additional Terms of Service (the "Additional Terms")',(0,no.jsx)(l,{color:c.text.accent,children:"[4]"}),"."]}),(0,no.jsx)(Uo,{}),(0,no.jsxs)(l,{color:c.text.primary,children:[(0,no.jsx)(l,{color:c.text.link,children:"[1]"})," ","https://ai.google.dev/docs/gemini_api_overview"]}),(0,no.jsxs)(l,{color:c.text.primary,children:[(0,no.jsx)(l,{color:c.status.error,children:"[2]"})," https://aistudio.google.com/"]}),(0,no.jsxs)(l,{color:c.text.primary,children:[(0,no.jsx)(l,{color:c.status.success,children:"[3]"})," ","https://developers.google.com/terms"]}),(0,no.jsxs)(l,{color:c.text.primary,children:[(0,no.jsx)(l,{color:c.text.accent,children:"[4]"})," ","https://ai.google.dev/gemini-api/terms"]}),(0,no.jsx)(Uo,{}),(0,no.jsx)(l,{color:c.text.secondary,children:"Press Esc to exit."})]}));var br=C(P(),1);var OR=({onExit:e})=>(me(t=>t.name==="escape"?(e(),!0):!1,{isActive:!0}),(0,br.jsxs)(u,{flexDirection:"column",marginBottom:1,children:[(0,br.jsx)(l,{bold:!0,color:c.text.accent,children:"Vertex AI Notice"}),(0,br.jsx)(Uo,{}),(0,br.jsxs)(l,{color:c.text.primary,children:["Service Specific Terms",(0,br.jsx)(l,{color:c.text.link,children:"[1]"})," are incorporated into the agreement under which Google has agreed to provide Google Cloud Platform",(0,br.jsx)(l,{color:c.status.success,children:"[2]"})," to Customer (the \u201CAgreement\u201D). If the Agreement authorizes the resale or supply of Google Cloud Platform under a Google Cloud partner or reseller program, then except for in the section entitled \u201CPartner-Specific Terms\u201D, all references to Customer in the Service Specific Terms mean Partner or Reseller (as applicable), and all references to Customer Data in the Service Specific Terms mean Partner Data. Capitalized terms used but not defined in the Service Specific Terms have the meaning given to them in the Agreement."]}),(0,br.jsx)(Uo,{}),(0,br.jsxs)(l,{color:c.text.primary,children:[(0,br.jsx)(l,{color:c.text.link,children:"[1]"})," ","https://cloud.google.com/terms/service-terms"]}),(0,br.jsxs)(l,{color:c.text.primary,children:[(0,br.jsx)(l,{color:c.status.success,children:"[2]"})," ","https://cloud.google.com/terms/services"]}),(0,br.jsx)(Uo,{}),(0,br.jsx)(l,{color:c.text.secondary,children:"Press Esc to exit."})]}));var Pl=C(z(),1);var NR=e=>{let[t,o]=(0,Pl.useState)({isLoading:!0});(0,Pl.useEffect)(()=>{(async()=>{o({isLoading:!0});try{let s=LR(e),i=s.userTier;if(i===void 0)throw new Error("Could not determine user tier.");if(i!==$T.FREE){o({isLoading:!1,isFreeTier:!1});return}let a=await jM(s);o({isLoading:!1,isFreeTier:!0,dataCollectionOptIn:a})}catch(s){o({isLoading:!1,error:s instanceof Error?s.message:String(s)})}})()},[e]);let r=(0,Pl.useCallback)(async n=>{try{let s=LR(e),i=await zM(s,n);o({isLoading:!1,isFreeTier:!0,dataCollectionOptIn:i})}catch(s){o({isLoading:!1,error:s instanceof Error?s.message:String(s)})}},[e]);return{privacyState:t,updateDataCollectionOptIn:r}};function LR(e){let t=Sx(e);if(t===void 0)throw new Error("Oauth not being used");if(t.projectId===void 0)throw new Error("CodeAssist server is missing a project ID");return t}async function jM(e){try{let t=await e.getCodeAssistGlobalUserSetting();return t.freeTierDataCollectionOptin===void 0&&de.warn("Warning: Code Assist API did not return freeTierDataCollectionOptin. Defaulting to true."),t.freeTierDataCollectionOptin??!0}catch(t){if(t&&typeof t=="object"&&"response"in t&&t.response?.status===404)return!0;throw t}}async function zM(e,t){let o=await e.setCodeAssistGlobalUserSetting({cloudaicompanionProject:e.projectId,freeTierDataCollectionOptin:t});return o.freeTierDataCollectionOptin===void 0&&de.warn(`Warning: Code Assist API did not return freeTierDataCollectionOptin. Defaulting to ${t}.`),o.freeTierDataCollectionOptin??t}var bt=C(P(),1);var BR=({config:e,onExit:t})=>{let{privacyState:o,updateDataCollectionOptIn:r}=NR(e);if(me(s=>(o.error||o.isFreeTier===!1)&&s.name==="escape"?(t(),!0):!1,{isActive:!0}),o.isLoading)return(0,bt.jsx)(l,{color:c.text.secondary,children:"Loading..."});if(o.error)return(0,bt.jsxs)(u,{flexDirection:"column",marginY:1,children:[(0,bt.jsxs)(l,{color:c.status.error,children:["Error loading Opt-in settings: ",o.error]}),(0,bt.jsx)(l,{color:c.text.secondary,children:"Press Esc to exit."})]});if(o.isFreeTier===!1)return(0,bt.jsxs)(u,{flexDirection:"column",marginY:1,children:[(0,bt.jsx)(l,{bold:!0,color:c.text.accent,children:"Gemini Code Assist Privacy Notice"}),(0,bt.jsx)(Uo,{}),(0,bt.jsx)(l,{children:"https://developers.google.com/gemini-code-assist/resources/privacy-notices"}),(0,bt.jsx)(Uo,{}),(0,bt.jsx)(l,{color:c.text.secondary,children:"Press Esc to exit."})]});let n=[{label:"Yes",value:!0,key:"true"},{label:"No",value:!1,key:"false"}];return(0,bt.jsxs)(u,{flexDirection:"column",marginY:1,children:[(0,bt.jsx)(l,{bold:!0,color:c.text.accent,children:"Gemini Code Assist for Individuals Privacy Notice"}),(0,bt.jsx)(Uo,{}),(0,bt.jsxs)(l,{color:c.text.primary,children:["This notice and our Privacy Policy",(0,bt.jsx)(l,{color:c.text.link,children:"[1]"})," describe how Gemini Code Assist handles your data. Please read them carefully."]}),(0,bt.jsx)(Uo,{}),(0,bt.jsx)(l,{color:c.text.primary,children:"When you use Gemini Code Assist for individuals with Gemini CLI, Google collects your prompts, related code, generated output, code edits, related feature usage information, and your feedback to provide, improve, and develop Google products and services and machine learning technologies."}),(0,bt.jsx)(Uo,{}),(0,bt.jsx)(l,{color:c.text.primary,children:"To help with quality and improve our products (such as generative machine-learning models), human reviewers may read, annotate, and process the data collected above. We take steps to protect your privacy as part of this process. This includes disconnecting the data from your Google Account before reviewers see or annotate it, and storing those disconnected copies for up to 18 months. Please don't submit confidential information or any data you wouldn't want a reviewer to see or Google to use to improve our products, services and machine-learning technologies."}),(0,bt.jsx)(Uo,{}),(0,bt.jsxs)(u,{flexDirection:"column",children:[(0,bt.jsx)(l,{color:c.text.primary,children:"Allow Google to use this data to develop and improve our products?"}),(0,bt.jsx)(We,{items:n,initialIndex:o.dataCollectionOptIn?0:1,onSelect:s=>{r(s),o.error||t()}})]}),(0,bt.jsx)(Uo,{}),(0,bt.jsxs)(l,{children:[(0,bt.jsx)(l,{color:c.text.link,children:"[1]"})," ","https://policies.google.com/privacy"]}),(0,bt.jsx)(Uo,{}),(0,bt.jsx)(l,{color:c.text.secondary,children:"Press Enter to choose an option and exit."})]})};var Ol=C(P(),1);var YM=({config:e,onExit:t})=>{switch(e.getContentGeneratorConfig()?.authType){case $e.USE_GEMINI:return(0,Ol.jsx)(PR,{onExit:t});case $e.USE_VERTEX_AI:return(0,Ol.jsx)(OR,{onExit:t});case $e.LOGIN_WITH_GOOGLE:default:return(0,Ol.jsx)(BR,{config:e,onExit:t})}},kR=({onExit:e,config:t})=>(0,Ol.jsx)(u,{borderStyle:"round",padding:1,flexDirection:"column",children:(0,Ol.jsx)(YM,{config:t,onExit:e})});var Hi=C(P(),1);function HR({failedModel:e,fallbackModel:t,message:o,isTerminalQuotaError:r,isModelNotFoundError:n,authType:s,tierName:i,onChoice:a}){let d;if(e===t)d=[{label:"Keep trying",value:"retry_once",key:"retry_once"},{label:"Stop",value:"retry_later",key:"retry_later"}];else if(n||r){let h=_d(i);d=[{label:`Switch to ${t}`,value:"retry_always",key:"retry_always"},...s===$e.LOGIN_WITH_GOOGLE&&!h?[{label:"Upgrade for higher limits",value:"upgrade",key:"upgrade"}]:[],{label:"Stop",value:"retry_later",key:"retry_later"}]}else d=[{label:"Keep trying",value:"retry_once",key:"retry_once"},{label:`Switch to ${t}`,value:"retry_always",key:"retry_always"},{label:"Stop",value:"retry_later",key:"retry_later"}];let m=h=>{a(h)};return(0,Hi.jsxs)(u,{borderStyle:"round",flexDirection:"column",padding:1,children:[(0,Hi.jsx)(u,{marginBottom:1,children:(h=>{let p=h.split(/(\s+)/);return(0,Hi.jsx)(l,{children:p.map((y,g)=>y.startsWith("/")?(0,Hi.jsx)(l,{bold:!0,color:c.text.accent,children:y},g):(0,Hi.jsx)(l,{children:y},g))})})(o)}),(0,Hi.jsx)(u,{marginTop:1,marginBottom:1,children:(0,Hi.jsx)(We,{items:d,onSelect:m})})]})}var Aa=C(z(),1);var Vt=C(P(),1);function FR({validationLink:e,learnMoreUrl:t,onChoice:o}){let r=Ze(),[n,s]=(0,Aa.useState)("choosing"),[i,a]=(0,Aa.useState)(""),d=[{label:"Verify your account",value:"verify",key:"verify"},{label:"Change authentication",value:"change_auth",key:"change_auth"}];me(f=>r["basic.cancel"](f)||r["basic.quit"](f)?(o("cancel"),!0):n==="waiting"&&r["basic.confirm"](f)?(s("complete"),!0):!1,{isActive:n!=="complete"}),(0,Aa.useEffect)(()=>{if(n==="complete"){let f=setTimeout(()=>{o("verify")},500);return()=>clearTimeout(f)}},[n,o]);let m=(0,Aa.useCallback)(async f=>{if(f==="verify")if(e){if(!el()){a(`Please open this URL in a browser: ${e}`),s("waiting");return}try{await Za(e),s("waiting")}catch(h){a(h instanceof Error?h.message:"Failed to open browser"),s("error")}}else o("verify");else o(f)},[e,o]);return n==="error"?(0,Vt.jsxs)(u,{borderStyle:"round",flexDirection:"column",padding:1,children:[(0,Vt.jsx)(l,{color:c.status.error,children:i||"Failed to open verification link. Please try again or change authentication."}),(0,Vt.jsx)(u,{marginTop:1,children:(0,Vt.jsx)(We,{items:d,onSelect:f=>void m(f)})})]}):n==="waiting"?(0,Vt.jsxs)(u,{borderStyle:"round",flexDirection:"column",padding:1,children:[(0,Vt.jsxs)(u,{children:[(0,Vt.jsx)(Mo,{}),(0,Vt.jsxs)(l,{children:[" ","Waiting for verification... (Press Esc or Ctrl+C to cancel)"]})]}),i&&(0,Vt.jsx)(u,{marginTop:1,children:(0,Vt.jsx)(l,{children:i})}),(0,Vt.jsx)(u,{marginTop:1,children:(0,Vt.jsx)(l,{dimColor:!0,children:"Press Enter when verification is complete."})})]}):n==="complete"?(0,Vt.jsx)(u,{borderStyle:"round",flexDirection:"column",padding:1,children:(0,Vt.jsx)(l,{color:c.status.success,children:"Verification complete"})}):(0,Vt.jsxs)(u,{borderStyle:"round",flexDirection:"column",padding:1,children:[(0,Vt.jsx)(u,{marginBottom:1,children:(0,Vt.jsx)(l,{children:"Further action is required to use this service."})}),(0,Vt.jsx)(u,{marginTop:1,marginBottom:1,children:(0,Vt.jsx)(We,{items:d,onSelect:f=>void m(f)})}),t&&(0,Vt.jsx)(u,{marginTop:1,children:(0,Vt.jsxs)(l,{dimColor:!0,children:["Learn more: ",(0,Vt.jsx)(l,{color:c.text.accent,children:t})]})})]})}var Io=C(P(),1);function UR({failedModel:e,fallbackModel:t,resetTime:o,creditBalance:r,onChoice:n}){let s=[{label:"Use AI Credits - Continue this request (Overage)",value:"use_credits",key:"use_credits"},{label:"Manage - View balance and purchase more credits",value:"manage",key:"manage"}];return t&&s.push({label:`Switch to ${t}`,value:"use_fallback",key:"use_fallback"}),s.push({label:"Stop - Abort request",value:"stop",key:"stop"}),(0,Io.jsxs)(u,{borderStyle:"round",flexDirection:"column",padding:1,children:[(0,Io.jsxs)(u,{marginBottom:1,flexDirection:"column",children:[(0,Io.jsxs)(l,{color:c.status.warning,children:["Usage limit reached for ",e,"."]}),o&&(0,Io.jsxs)(l,{children:["Access resets at ",o,"."]}),(0,Io.jsxs)(l,{children:[(0,Io.jsx)(l,{bold:!0,color:c.text.accent,children:"/stats"})," ","model for usage details"]}),(0,Io.jsxs)(l,{children:[(0,Io.jsx)(l,{bold:!0,color:c.text.accent,children:"/model"})," ","to switch models."]}),(0,Io.jsxs)(l,{children:[(0,Io.jsx)(l,{bold:!0,color:c.text.accent,children:"/auth"})," ","to switch to API key."]})]}),(0,Io.jsx)(u,{marginBottom:1,children:(0,Io.jsxs)(l,{children:["You have"," ",(0,Io.jsx)(l,{bold:!0,color:c.status.success,children:r})," ","AI Credits available."]})}),(0,Io.jsx)(u,{marginBottom:1,children:(0,Io.jsx)(l,{children:"How would you like to proceed?"})}),(0,Io.jsx)(u,{marginTop:1,marginBottom:1,children:(0,Io.jsx)(We,{items:s,onSelect:n})})]})}var po=C(P(),1);function GR({failedModel:e,fallbackModel:t,resetTime:o,onGetCredits:r,onChoice:n}){let s=[{label:"Get AI Credits - Open browser to purchase credits",value:"get_credits",key:"get_credits"}];t&&s.push({label:`Switch to ${t}`,value:"use_fallback",key:"use_fallback"}),s.push({label:"Stop - Abort request",value:"stop",key:"stop"});let i=a=>{a==="get_credits"&&r?.(),n(a)};return(0,po.jsxs)(u,{borderStyle:"round",flexDirection:"column",padding:1,children:[(0,po.jsxs)(u,{marginBottom:1,flexDirection:"column",children:[(0,po.jsxs)(l,{color:c.status.warning,children:["Usage limit reached for ",e,"."]}),o&&(0,po.jsxs)(l,{children:["Access resets at ",o,"."]}),(0,po.jsxs)(l,{children:[(0,po.jsx)(l,{bold:!0,color:c.text.accent,children:"/stats"})," ","model for usage details"]}),(0,po.jsxs)(l,{children:[(0,po.jsx)(l,{bold:!0,color:c.text.accent,children:"/model"})," ","to switch models."]}),(0,po.jsxs)(l,{children:[(0,po.jsx)(l,{bold:!0,color:c.text.accent,children:"/auth"})," ","to switch to API key."]})]}),(0,po.jsx)(u,{marginBottom:1,children:(0,po.jsx)(l,{children:"To continue using this model now, purchase more AI Credits."})}),(0,po.jsx)(u,{marginBottom:1,children:(0,po.jsx)(l,{dimColor:!0,children:"Newly purchased AI credits may take a few minutes to update."})}),(0,po.jsx)(u,{marginBottom:1,children:(0,po.jsx)(l,{children:"How would you like to proceed?"})}),(0,po.jsx)(u,{marginTop:1,marginBottom:1,children:(0,po.jsx)(We,{items:s,onSelect:i})})]})}var eo=C(z(),1);var Fe={get type(){return at.getActiveTheme().colors.type},get Foreground(){return at.getActiveTheme().colors.Foreground},get Background(){return at.getColors().Background},get LightBlue(){return at.getActiveTheme().colors.LightBlue},get AccentBlue(){return at.getActiveTheme().colors.AccentBlue},get AccentPurple(){return at.getActiveTheme().colors.AccentPurple},get AccentCyan(){return at.getActiveTheme().colors.AccentCyan},get AccentGreen(){return at.getActiveTheme().colors.AccentGreen},get AccentYellow(){return at.getActiveTheme().colors.AccentYellow},get AccentRed(){return at.getActiveTheme().colors.AccentRed},get DiffAdded(){return at.getActiveTheme().colors.DiffAdded},get DiffRemoved(){return at.getActiveTheme().colors.DiffRemoved},get Comment(){return at.getActiveTheme().colors.Comment},get Gray(){return at.getActiveTheme().colors.Gray},get DarkGray(){return at.getColors().DarkGray},get InputBackground(){return at.getColors().InputBackground},get MessageBackground(){return at.getColors().MessageBackground},get GradientColors(){return at.getActiveTheme().colors.GradientColors}};import QR from"node:path";var jt=C(P(),1);var Ms=({name:e,shortcut:t})=>(0,jt.jsxs)(jt.Fragment,{children:[e,": ",(0,jt.jsx)(l,{bold:!0,children:t})]}),WR=()=>(0,jt.jsxs)(u,{flexDirection:"column",children:[(0,jt.jsxs)(l,{color:Fe.Gray,children:[(0,jt.jsx)(Ms,{name:"Navigate",shortcut:"\u2191/\u2193"})," ",(0,jt.jsx)(Ms,{name:"Resume",shortcut:"Enter"})," ",(0,jt.jsx)(Ms,{name:"Search",shortcut:"/"})," ",(0,jt.jsx)(Ms,{name:"Delete",shortcut:"x"})," ",(0,jt.jsx)(Ms,{name:"Quit",shortcut:"q"})]}),(0,jt.jsxs)(l,{color:Fe.Gray,children:[(0,jt.jsx)(Ms,{name:"Sort",shortcut:"s"})," ",(0,jt.jsx)(Ms,{name:"Reverse",shortcut:"r"})," ",(0,jt.jsx)(Ms,{name:"First/Last",shortcut:"g/G"})]})]}),VR=({state:e})=>(0,jt.jsxs)(u,{marginTop:1,children:[(0,jt.jsx)(l,{color:Fe.Gray,children:"Search: "}),(0,jt.jsx)(l,{color:Fe.AccentPurple,children:e.searchQuery}),(0,jt.jsx)(l,{color:Fe.Gray,children:" (Esc to cancel)"})]}),$R=({state:e})=>(0,jt.jsx)(u,{marginTop:1,children:(0,jt.jsxs)(l,{color:Fe.Gray,dimColor:!0,children:["No sessions found matching '",e.searchQuery,"'."]})});var Cm=C(P(),1);var qR=({state:e})=>(0,Cm.jsxs)(u,{flexDirection:"row",justifyContent:"space-between",children:[(0,Cm.jsxs)(l,{color:Fe.AccentPurple,children:["Chat Sessions (",e.totalSessions," total",e.searchQuery?", filtered":"",")"]}),(0,Cm.jsxs)(l,{color:Fe.Gray,children:["sorted by ",e.sortOrder," ",e.sortReverse?"asc":"desc"]})]});var ug=C(P(),1);var KR=()=>(0,ug.jsx)(u,{flexDirection:"column",paddingX:1,children:(0,ug.jsx)(l,{color:Fe.Gray,children:"Loading sessions\u2026"})});var Wc=C(P(),1);var jR=({state:e})=>(0,Wc.jsxs)(u,{flexDirection:"column",paddingX:1,children:[(0,Wc.jsxs)(l,{color:Fe.AccentRed,children:["Error: ",e.error]}),(0,Wc.jsx)(l,{color:Fe.Gray,children:"Press q to exit"})]});var Vc=C(P(),1);var zR=()=>(0,Vc.jsxs)(u,{flexDirection:"column",paddingX:1,children:[(0,Vc.jsx)(l,{color:Fe.Gray,children:"No auto-saved conversations found."}),(0,Vc.jsx)(l,{color:Fe.Gray,children:"Press q to exit"})]});var YR=(e,t,o)=>{let r=[...e].sort((n,s)=>{switch(t){case"date":return new Date(s.lastUpdated).getTime()-new Date(n.lastUpdated).getTime();case"messages":return s.messageCount-n.messageCount;case"name":return n.displayName.localeCompare(s.displayName);default:return 0}});return o?r.reverse():r},XM=(e,t)=>{if(!t.trim())return[];let o=t.toLowerCase(),r=[];for(let n of e){let s=ES(n.content),i=s.toLowerCase(),a=0;for(;;){let d=i.indexOf(o,a);if(d===-1)break;let m=Math.max(0,d-10),f=Math.min(s.length,d+t.length+10),h=s.slice(m,f),p=d-m,y=p+t.length,g=h.slice(0,p),x=h.slice(p,y),S=h.slice(y);m>0&&(g="\u2026"+g),f<s.length&&(S=S+"\u2026"),r.push({before:g,match:x,after:S,role:n.role}),a=d+1}}return r},XR=(e,t)=>{if(!t.trim())return e.map(r=>({...r,matchSnippets:void 0,matchCount:void 0}));let o=t.toLowerCase();return e.filter(r=>{let n=r.displayName.toLowerCase().includes(o)||r.id.toLowerCase().includes(o)||r.firstUserMessage.toLowerCase().includes(o),s=r.fullContent?.toLowerCase().includes(o);return n||s?(r.messages&&(r.matchSnippets=XM(r.messages,t),r.matchCount=r.matchSnippets.length),!0):!1})};var _e=C(P(),1);var Ps=20,QM=30,JM=({state:e})=>(0,_e.jsxs)(u,{flexDirection:"row",marginTop:1,children:[(0,_e.jsx)(l,{children:e.scrollOffset>0?(0,_e.jsx)(l,{children:"\u25B2 "}):" "}),(0,_e.jsx)(u,{width:5,flexShrink:0,children:(0,_e.jsx)(l,{color:Fe.Gray,bold:!0,children:"Index"})}),(0,_e.jsx)(l,{color:Fe.Gray,children:" \u2502 "}),(0,_e.jsx)(u,{width:4,flexShrink:0,children:(0,_e.jsx)(l,{color:Fe.Gray,bold:!0,children:"Msgs"})}),(0,_e.jsx)(l,{color:Fe.Gray,children:" \u2502 "}),(0,_e.jsx)(u,{width:4,flexShrink:0,children:(0,_e.jsx)(l,{color:Fe.Gray,bold:!0,children:"Age"})}),(0,_e.jsx)(l,{color:Fe.Gray,children:" \u2502 "}),(0,_e.jsx)(u,{flexShrink:0,children:(0,_e.jsx)(l,{color:Fe.Gray,bold:!0,children:e.searchQuery?"Match":"Name"})})]}),ZM=({session:e,textColor:t})=>{if(!e.matchSnippets||e.matchSnippets.length===0)return null;let o=e.matchSnippets[0],r=o.role==="user"?"You: ":"Gemini:",n=t(o.role==="user"?Fe.AccentGreen:Fe.AccentBlue);return(0,_e.jsxs)(_e.Fragment,{children:[(0,_e.jsxs)(l,{color:n,bold:!0,children:[r," "]}),o.before,(0,_e.jsx)(l,{color:t(Fe.AccentRed),bold:!0,children:o.match}),o.after]})},eP=({session:e,state:t,terminalWidth:o,formatRelativeTime:r})=>{let n=t.startIndex+t.visibleSessions.indexOf(e),s=n===t.activeIndex,i=e.isCurrentSession,a=(g=Fe.Foreground)=>i?Fe.Gray:s?c.ui.focus:g,d=s?"\u276F ":" ",m="",f=null;e.isCurrentSession&&(m=" (current)"),t.searchQuery&&e.matchSnippets&&e.matchSnippets.length>0&&(f=(0,_e.jsx)(ZM,{session:e,textColor:a}),e.matchCount&&e.matchCount>1&&(m+=` (+${e.matchCount-1} more)`));let h=m?m.length+1:0,p=Math.max(20,o-QM-h),y=f||(e.displayName.length===0?(0,_e.jsx)(l,{color:a(Fe.Gray),dimColor:!0,children:"(No messages)"}):e.displayName.length>p?e.displayName.slice(0,p-1)+"\u2026":e.displayName);return(0,_e.jsxs)(u,{flexDirection:"row",backgroundColor:s?c.background.focus:void 0,children:[(0,_e.jsx)(l,{color:a(),dimColor:i,children:d}),(0,_e.jsx)(u,{width:5,children:(0,_e.jsxs)(l,{color:a(),dimColor:i,children:["#",n+1]})}),(0,_e.jsxs)(l,{color:a(Fe.Gray),dimColor:i,children:[" ","\u2502"," "]}),(0,_e.jsx)(u,{width:4,children:(0,_e.jsx)(l,{color:a(),dimColor:i,children:e.messageCount})}),(0,_e.jsxs)(l,{color:a(Fe.Gray),dimColor:i,children:[" ","\u2502"," "]}),(0,_e.jsx)(u,{width:4,children:(0,_e.jsx)(l,{color:a(),dimColor:i,children:r(e.lastUpdated,"short")})}),(0,_e.jsxs)(l,{color:a(Fe.Gray),dimColor:i,children:[" ","\u2502"," "]}),(0,_e.jsx)(u,{flexGrow:1,children:(0,_e.jsxs)(l,{color:a(Fe.Comment),dimColor:i,children:[y,m&&(0,_e.jsx)(l,{color:a(Fe.Gray),dimColor:!0,bold:!1,children:m})]})})]})},tP=({state:e,formatRelativeTime:t})=>(0,_e.jsxs)(u,{flexDirection:"column",children:[(0,_e.jsxs)(u,{flexDirection:"column",children:[!e.isSearchMode&&(0,_e.jsx)(WR,{}),(0,_e.jsx)(JM,{state:e})]}),e.visibleSessions.map(o=>(0,_e.jsx)(eP,{session:o,state:e,terminalWidth:e.terminalWidth,formatRelativeTime:t},o.id)),(0,_e.jsx)(l,{color:Fe.Gray,children:e.endIndex<e.totalSessions?(0,_e.jsx)(_e.Fragment,{children:"\u25BC"}):(0,_e.jsx)(l,{dimColor:!0,children:"\u25BC"})})]}),oP=(e=[],t=!0,o=null)=>{let{columns:r}=ci(),[n,s]=(0,eo.useState)(e),[i,a]=(0,eo.useState)(t),[d,m]=(0,eo.useState)(o),[f,h]=(0,eo.useState)(0),[p,y]=(0,eo.useState)(0),[g,x]=(0,eo.useState)("date"),[S,I]=(0,eo.useState)(!1),[A,E]=(0,eo.useState)(""),[T,v]=(0,eo.useState)(!1),[R,b]=(0,eo.useState)(!1),_=(0,eo.useRef)(!1),w=(0,eo.useMemo)(()=>{let L=XR(n,A);return YR(L,g,S)},[n,A,g,S]);(0,eo.useEffect)(()=>{A||(b(!1),_.current=!1)},[A]);let M=w.length,D=p,N=Math.min(p+Ps,M),O=w.slice(D,N);return{sessions:n,setSessions:s,loading:i,setLoading:a,error:d,setError:m,activeIndex:f,setActiveIndex:h,scrollOffset:p,setScrollOffset:y,searchQuery:A,setSearchQuery:E,isSearchMode:T,setIsSearchMode:v,hasLoadedFullContent:R,setHasLoadedFullContent:b,sortOrder:g,setSortOrder:x,sortReverse:S,setSortReverse:I,terminalWidth:r,filteredAndSortedSessions:w,totalSessions:M,startIndex:D,endIndex:N,visibleSessions:O}},rP=(e,t)=>{let{setSessions:o,setLoading:r,setError:n,isSearchMode:s,hasLoadedFullContent:i,setHasLoadedFullContent:a}=t;(0,eo.useEffect)(()=>{(async()=>{try{let m=QR.join(e.storage.getProjectTempDir(),"chats"),f=await Sf(m,e.getSessionId());o(f),r(!1)}catch(m){n(m instanceof Error?m.message:"Failed to load sessions"),r(!1)}})()},[e,o,r,n]),(0,eo.useEffect)(()=>{(async()=>{if(s&&!i)try{let m=QR.join(e.storage.getProjectTempDir(),"chats"),f=await Sf(m,e.getSessionId(),{includeFullContent:!0});o(f),a(!0)}catch(m){n(m instanceof Error?m.message:"Failed to load full session content")}})()},[s,i,e,o,a,n])},nP=e=>{let{totalSessions:t,activeIndex:o,scrollOffset:r,setActiveIndex:n,setScrollOffset:s}=e;return(0,eo.useCallback)(i=>{let a=Math.max(0,Math.min(t-1,o+i));n(a),a<r?s(a):a>=r+Ps&&s(a-Ps+1)},[t,o,r,n,s])},iP=e=>{let{sortOrder:t,setSortOrder:o}=e;return(0,eo.useCallback)(()=>{let r=["date","messages","name"],s=(r.indexOf(t)+1)%r.length;o(r[s])},[t,o])},sP=(e,t,o,r,n,s)=>{me(i=>{if(e.isSearchMode){if(i.name==="escape")return e.setIsSearchMode(!1),e.setSearchQuery(""),e.setActiveIndex(0),e.setScrollOffset(0),!0;if(i.name==="backspace")return e.setSearchQuery(a=>a.slice(0,-1)),e.setActiveIndex(0),e.setScrollOffset(0),!0;if(i.name==="enter"){let a=e.filteredAndSortedSessions[e.activeIndex];return a&&!a.isCurrentSession&&r(a),!0}else if(i.sequence&&i.sequence.length===1&&!i.alt&&!i.ctrl&&!i.cmd)return e.setSearchQuery(a=>a+i.sequence),e.setActiveIndex(0),e.setScrollOffset(0),!0}else{if(i.sequence==="g")return e.setActiveIndex(0),e.setScrollOffset(0),!0;if(i.sequence==="G")return e.setActiveIndex(e.totalSessions-1),e.setScrollOffset(Math.max(0,e.totalSessions-Ps)),!0;if(i.sequence==="s")return o(),!0;if(i.sequence==="r")return e.setSortReverse(!e.sortReverse),!0;if(i.sequence==="/")return e.setIsSearchMode(!0),!0;if(i.sequence==="q"||i.sequence==="Q"||i.name==="escape")return s(),!0;if(i.sequence==="x"||i.sequence==="X"){let a=e.filteredAndSortedSessions[e.activeIndex];return a&&!a.isCurrentSession&&n(a).then(()=>{e.setSessions(e.sessions.filter(d=>d.id!==a.id)),e.activeIndex>=e.filteredAndSortedSessions.length-1&&e.setActiveIndex(Math.max(0,e.filteredAndSortedSessions.length-2))}).catch(d=>{e.setError(`Failed to delete session: ${d instanceof Error?d.message:"Unknown error"}`)}),!0}else{if(i.sequence==="u")return t(-Math.round(Ps/2)),!0;if(i.sequence==="d")return t(Math.round(Ps/2)),!0}}if(i.name==="enter"&&e.filteredAndSortedSessions[e.activeIndex]){let a=e.filteredAndSortedSessions[e.activeIndex];return a.isCurrentSession||r(a),!0}else{if(i.name==="up")return t(-1),!0;if(i.name==="down")return t(1),!0;if(i.name==="pageup")return t(-Ps),!0;if(i.name==="pagedown")return t(Ps),!0}return!1},{isActive:!0})};function aP({state:e}){return e.loading?(0,_e.jsx)(KR,{}):e.error?(0,_e.jsx)(jR,{state:e}):e.sessions.length===0?(0,_e.jsx)(zR,{}):(0,_e.jsxs)(u,{flexDirection:"column",paddingX:1,children:[(0,_e.jsx)(qR,{state:e}),e.isSearchMode&&(0,_e.jsx)(VR,{state:e}),e.totalSessions===0?(0,_e.jsx)($R,{state:e}):(0,_e.jsx)(tP,{state:e,formatRelativeTime:RS})]})}function JR({config:e,onResumeSession:t,onDeleteSession:o,onExit:r}){let n=oP();rP(e,n);let s=nP(n),i=iP(n);return sP(n,s,i,t,o,r),(0,_e.jsx)(aP,{state:n})}var Er=C(z(),1);var eI=C(z(),1);var $c=C(P(),1);var ZR=({value:e,width:t,warningThreshold:o=80})=>{let r=Math.min(Math.max(e,0),100),n=Math.ceil(r/100*t),s=t-n,i=c.status.success;return r>=100?i=c.status.error:r>=o&&(i=c.status.warning),(0,$c.jsxs)(u,{flexDirection:"row",children:[(0,$c.jsx)(l,{color:i,children:"\u25AC".repeat(n)}),(0,$c.jsx)(l,{color:c.border.default,children:"\u25AC".repeat(s)})]})};var Wo=C(P(),1);var lP=({row:e,availableWidth:t})=>{let{terminalWidth:o}=Ce(),r=12,n=4,s=26,i=e.usedPercentage,a=e.name,d=`${i.toFixed(0)}%`.padEnd(n),m=e.resetTime?Rc(e.resetTime,"column").slice(0,s).padEnd(s):"".padEnd(s),f=r,h=n+1,p=s+1,y=f+h+p,g=t??o,x=t!=null?0:4,I=Math.max(0,g-x-y-3),A=c.text.primary;return i>=100?A=c.status.error:i>=80&&(A=c.status.warning),(0,Wo.jsxs)(u,{flexDirection:"row",width:"100%",children:[(0,Wo.jsx)(u,{width:r,children:(0,Wo.jsx)(l,{color:c.text.primary,wrap:"truncate-end",children:a})}),(0,Wo.jsx)(u,{flexGrow:1,children:(0,Wo.jsx)(ZR,{value:i,width:I})}),(0,Wo.jsx)(u,{width:4,marginLeft:1,children:(0,Wo.jsx)(l,{color:A,children:d})}),(0,Wo.jsx)(u,{width:s,marginLeft:1,children:(0,Wo.jsx)(l,{color:c.text.secondary,children:m.trim()?`Resets: ${m}`:""})})]})},tI=({buckets:e,availableWidth:t,modelsToShow:o=["all"],title:r="Model usage"})=>{let n=Ct(),s=(0,eI.useMemo)(()=>{if(!e)return[];let i=e.filter(d=>d.modelId&&d.remainingFraction!=null);if(o.includes("current")){let d=n.getActiveModel?.()??n.getModel?.();i=i.filter(m=>m.modelId===d)}else o.includes("all")||(i=i.filter(d=>d.modelId&&o.includes(d.modelId)));let a=new Map;return i.forEach(d=>{let m=d.modelId,f=d.remainingFraction;if(!m||f==null)return;let h=n?.modelConfigService?.getModelDefinition(m)?.tier,p=h??m,y=a.get(p);if(!y||f<y.remainingFraction){let x=h?{pro:"Pro",flash:"Flash","flash-lite":"Flash Lite"}[h]??h:Bt(m,n);a.set(p,{modelId:m,remainingFraction:f,resetTime:d.resetTime,name:x})}}),Array.from(a.entries()).map(([d,m])=>{let f=1-m.remainingFraction,h=f*100;return{modelId:d,name:m.name,usedFraction:f,usedPercentage:h,resetTime:m.resetTime}})},[e,n,o]);return s.length===0?null:(0,Wo.jsxs)(u,{flexDirection:"column",marginTop:1,children:[(0,Wo.jsx)(u,{borderStyle:"single",borderTop:!0,borderBottom:!1,borderLeft:!1,borderRight:!1,borderColor:c.border.default}),(0,Wo.jsxs)(u,{flexDirection:"column",children:[(0,Wo.jsx)(u,{marginBottom:1,children:(0,Wo.jsx)(l,{bold:!0,color:c.text.primary,children:r})}),s.map(i=>(0,Wo.jsx)(lP,{row:i,availableWidth:t},i.modelId))]})]})};var Ll=C(P(),1);function qc({items:e,initialIndex:t=0,onSelect:o,onHighlight:r,isFocused:n=!0,showNumbers:s=!1,showScrollArrows:i=!1,maxItemsToShow:a=10}){return(0,Ll.jsx)(yd,{items:e,initialIndex:t,onSelect:o,onHighlight:r,isFocused:n,showNumbers:s,showScrollArrows:i,maxItemsToShow:a,renderItem:(d,{titleColor:m})=>(0,Ll.jsxs)(u,{flexDirection:"column",children:[(0,Ll.jsx)(l,{color:m,children:d.title}),d.description&&(0,Ll.jsx)(l,{color:c.text.secondary,children:d.description})]},d.key)})}var rr=C(P(),1);function oI({onClose:e}){let t=(0,Er.useContext)(Td),o=Ke(),{terminalWidth:r}=Ce(),[n,s]=(0,Er.useState)(()=>!(t?.getProModelNoAccessSync()??!1)),[i,a]=(0,Er.useState)(()=>t?.getProModelNoAccessSync()?"manual":"main"),[d,m]=(0,Er.useState)(!1);(0,Er.useEffect)(()=>{async function R(){if(!t)return;let b=await t.getProModelNoAccess();s(!b),b&&a("manual")}R()},[t]);let f=t?.getModel()||Tc,h=t?.getHasAccessToPreviewModel(),p=t?.getGemini31LaunchedSync?.()??!1,y=t?.getGemini31FlashLiteLaunchedSync?.()??!1,g=o.merged.security.auth.selectedType,x=p&&g===$e.USE_GEMINI,S=(0,Er.useMemo)(()=>{if(t?.getExperimentalDynamicModelConfiguration?.()===!0&&t.getModelConfigService){let b=t.getModelConfigService().getModelDefinition(f);return b&&b.tier!=="auto"&&b.isVisible===!0?f:""}return[hc,ss,yc,Qp,Jp,Zp,gc,fc].includes(f)?f:""},[f,t]);me(R=>R.name==="escape"?(i==="manual"&&n?a("main"):e(),!0):R.name==="tab"?(m(b=>!b),!0):!1,{isActive:!0});let I=(0,Er.useMemo)(()=>{if(t?.getExperimentalDynamicModelConfiguration?.()===!0&&t.getModelConfigService){let _=t.getModelConfigService().getAvailableModelOptions({useGemini3_1:p,useGemini3_1FlashLite:y,useCustomTools:x,hasAccessToPreview:h,hasAccessToProModel:n}).filter(w=>w.tier==="auto").map(w=>({value:w.modelId,title:w.name,description:w.description,key:w.modelId}));return _.push({value:"Manual",title:S?`Manual (${Bt(S,t??void 0)})`:"Manual",description:"Manually select a model",key:"Manual"}),_}let R=[{value:Tc,title:Bt(Tc),description:"Let Gemini CLI decide the best model for the task: gemini-2.5-pro, gemini-2.5-flash",key:Tc},{value:"Manual",title:S?`Manual (${Bt(S)})`:"Manual",description:"Manually select a model",key:"Manual"}];return h&&R.unshift({value:$u,title:Bt($u),description:p?"Let Gemini CLI decide the best model for the task: gemini-3.1-pro, gemini-3-flash":"Let Gemini CLI decide the best model for the task: gemini-3-pro, gemini-3-flash",key:$u}),R},[t,h,S,p,y,x,n]),A=(0,Er.useMemo)(()=>{if(t?.getExperimentalDynamicModelConfiguration?.()===!0&&t.getModelConfigService)return t.getModelConfigService().getAvailableModelOptions({useGemini3_1:p,useGemini3_1FlashLite:y,useCustomTools:x,hasAccessToPreview:h,hasAccessToProModel:n}).filter(w=>w.tier!=="auto").map(w=>({value:w.modelId,title:w.name,key:w.modelId}));let R=t?.getExperimentalGemma()??!1,b=[{value:hc,title:Bt(hc),key:hc},{value:ss,title:Bt(ss),key:ss},{value:yc,title:Bt(yc),key:yc}];if(R&&b.push({value:Wu,title:Bt(Wu),key:Wu},{value:Vu,title:Bt(Vu),key:Vu}),h){let _=p?Jp:Qp,M=[{value:x?Zp:_,title:Bt(_),key:_},{value:fc,title:Bt(fc),key:fc}];y&&M.push({value:gc,title:Bt(gc),key:gc}),b.unshift(...M)}return n?b:b.filter(_=>!qu(_.value))},[h,p,y,x,n,t]),E=i==="main"?I:A,T=(0,Er.useMemo)(()=>{let R=E.findIndex(b=>b.value===f);if(R!==-1)return R;if(i==="main"){let b=E.findIndex(_=>_.value==="Manual");return b!==-1?b:0}return 0},[f,E,i]),v=(0,Er.useCallback)(R=>{if(R==="Manual"){a("manual");return}if(t){t.setModel(R,!d);let b=new UT(R);ax(t,b)}e()},[t,e,d]);return(0,rr.jsxs)(u,{borderStyle:"round",borderColor:c.border.default,flexDirection:"column",padding:1,width:"100%",children:[(0,rr.jsx)(l,{bold:!0,children:"Select Model"}),(0,rr.jsx)(u,{marginTop:1,children:(0,rr.jsx)(qc,{items:E,onSelect:v,initialIndex:T,showNumbers:!0})}),(0,rr.jsx)(u,{marginTop:1,flexDirection:"column",children:(0,rr.jsxs)(u,{children:[(0,rr.jsxs)(l,{bold:!0,color:c.text.primary,children:["Remember model for future sessions:"," "]}),(0,rr.jsx)(l,{color:c.status.success,children:d?"true":"false"}),(0,rr.jsx)(l,{color:c.text.secondary,children:" (Press Tab to toggle)"})]})}),(0,rr.jsx)(u,{flexDirection:"column",children:(0,rr.jsx)(l,{color:c.text.secondary,children:"> To use a specific Gemini model on startup, use the --model flag."})}),(0,rr.jsx)(tI,{buckets:t?.getLastRetrievedQuota()?.buckets,availableWidth:r-2}),(0,rr.jsx)(u,{marginTop:1,flexDirection:"column",children:(0,rr.jsx)(l,{color:c.text.secondary,children:"(Press Esc to close)"})})]})}var Rr=C(z(),1);var io=C(P(),1);var cP=[{value:"ggml-tiny.en.bin",label:"Tiny (EN)",description:"Fastest, lower accuracy (~75MB)"},{value:"ggml-base.en.bin",label:"Base (EN)",description:"Balanced speed and accuracy (~142MB)"},{value:"ggml-large-v3-turbo-q5_0.bin",label:"Large v3 Turbo (Q5_0)",description:"High accuracy, quantized (~547MB)"},{value:"ggml-large-v3-turbo-q8_0.bin",label:"Large v3 Turbo (Q8_0)",description:"Maximum accuracy, high memory (~834MB)"}];function rI({onClose:e}){let{settings:t,setSetting:o}=gd(),[r,n]=(0,Rr.useState)("backend"),[s,i]=(0,Rr.useState)(null),[a,d]=(0,Rr.useState)(null),m=(0,Rr.useMemo)(()=>Jx("whisper-stream"),[]),f=(0,Rr.useMemo)(()=>new Qx,[]),h=t.merged.experimental.voice?.backend??"gemini-live",p=t.merged.experimental.voice?.whisperModel??"ggml-base.en.bin",[y,g]=(0,Rr.useState)(h),x=(0,Rr.useCallback)(v=>v.name==="escape"?(r==="whisper-models"?n("backend"):e(),!0):!1,[r,e]);me(x,{isActive:!0});let S=(0,Rr.useCallback)(v=>{v==="whisper"?n("whisper-models"):(o("User","experimental.voice.backend","gemini-live"),e())},[o,e]),I=(0,Rr.useCallback)(v=>{g(v)},[]),A=(0,Rr.useCallback)(async v=>{if(f.isModelInstalled(v))o("User","experimental.voice.backend","whisper"),o("User","experimental.voice.whisperModel",v),e();else{d(null);let R=b=>i(b);f.on("progress",R);try{await f.downloadModel(v),o("User","experimental.voice.backend","whisper"),o("User","experimental.voice.whisperModel",v),e()}catch(b){d(`Failed to download: ${b instanceof Error?b.message:String(b)}`)}finally{f.off("progress",R),i(null)}}},[f,o,e]),E=(0,Rr.useMemo)(()=>[{value:"gemini-live",title:"Gemini Live API (Cloud)",description:"Real-time cloud transcription via Gemini Live API.",key:"gemini-live"},{value:"whisper",title:"Whisper (Local)",description:m?"Local transcription using whisper.cpp.":"Local transcription (Requires: brew install whisper-cpp)",key:"whisper"}],[m]),T=(0,Rr.useMemo)(()=>cP.map(v=>({value:v.value,title:`${v.label}${f.isModelInstalled(v.value)?" (Installed)":" (Download)"}`,description:v.description,key:v.value})),[f]);return(0,io.jsxs)(u,{borderStyle:"round",borderColor:c.border.default,flexDirection:"column",padding:1,width:"100%",children:[(0,io.jsx)(l,{bold:!0,children:r==="backend"?"Select Voice Transcription Backend":"Select Whisper Model"}),a&&(0,io.jsx)(u,{marginTop:1,children:(0,io.jsx)(l,{color:c.status.error,children:a})}),s?(0,io.jsx)(u,{marginTop:1,flexDirection:"column",children:(0,io.jsxs)(u,{children:[(0,io.jsxs)(l,{children:["Downloading ",s.modelName,"... "]}),(0,io.jsx)(Mo,{}),(0,io.jsxs)(l,{children:[" ",Math.round(s.percentage*100),"%"]})]})}):(0,io.jsx)(u,{marginTop:1,flexDirection:"column",children:r==="backend"?(0,io.jsxs)(io.Fragment,{children:[(0,io.jsx)(qc,{items:E,onSelect:S,onHighlight:I,initialIndex:h==="whisper"?1:0,showNumbers:!0}),y==="gemini-live"&&(0,io.jsx)(u,{marginTop:1,children:(0,io.jsx)(wl,{text:"When using the Gemini Live backend, voice recordings are sent to Google Cloud for transcription. Enterprise users should verify this aligns with their data privacy and compliance requirements."})})]}):(0,io.jsx)(qc,{items:T,onSelect:A,initialIndex:T.findIndex(v=>v.value===p),showNumbers:!0})}),(0,io.jsx)(u,{marginTop:1,flexDirection:"column",children:(0,io.jsx)(l,{color:c.text.secondary,children:r==="whisper-models"?"(Press Esc to go back)":"(Press Esc to close)"})})]})}import uP from"node:process";var bm=C(P(),1);var nI=()=>{let e=Ze(),{handleRestart:t}=Pr();return me(r=>e["app.restart"](r)?(t(),!0):!1,{isActive:!0}),(0,bm.jsx)(u,{borderStyle:"round",borderColor:c.status.warning,paddingX:1,children:(0,bm.jsxs)(l,{color:c.status.warning,children:["Admin settings have changed. Please restart the session to apply new settings."," Press 'r' to restart, or 'Ctrl+C' twice to exit."]})})};var Em=C(P(),1);var iI=({reason:e})=>{me(o=>o.name==="r"||o.name==="R"?(fr(),!0):!1,{isActive:!0});let t="Workspace trust has changed.";return e==="NONE"?de.warn('IdeTrustChangeDialog rendered with unexpected reason "NONE"'):e==="CONNECTION_CHANGE"?t="Workspace trust has changed due to a change in the IDE connection.":e==="TRUST_CHANGE"&&(t="Workspace trust has changed due to a change in the IDE trust."),(0,Em.jsx)(u,{borderStyle:"round",borderColor:c.status.warning,paddingX:1,children:(0,Em.jsxs)(l,{color:c.status.warning,children:[t," Press 'r' to restart Gemini to apply the changes."]})})};var Ir=C(z(),1);var mg=C(P(),1);var Kc=[{key:"enabled",label:"Enabled",description:"Enable or disable this agent",type:"boolean",path:["enabled"],defaultValue:!0},{key:"model",label:"Model",description:"Model to use (e.g., 'gemini-2.0-flash' or 'inherit')",type:"string",path:["modelConfig","model"],defaultValue:"inherit"},{key:"temperature",label:"Temperature",description:"Sampling temperature (0.0 to 2.0)",type:"number",path:["modelConfig","generateContentConfig","temperature"],defaultValue:void 0},{key:"topP",label:"Top P",description:"Nucleus sampling parameter (0.0 to 1.0)",type:"number",path:["modelConfig","generateContentConfig","topP"],defaultValue:void 0},{key:"topK",label:"Top K",description:"Top-K sampling parameter",type:"number",path:["modelConfig","generateContentConfig","topK"],defaultValue:void 0},{key:"maxOutputTokens",label:"Max Output Tokens",description:"Maximum number of tokens to generate",type:"number",path:["modelConfig","generateContentConfig","maxOutputTokens"],defaultValue:void 0},{key:"maxTimeMinutes",label:"Max Time (minutes)",description:"Maximum execution time in minutes",type:"number",path:["runConfig","maxTimeMinutes"],defaultValue:void 0},{key:"maxTurns",label:"Max Turns",description:"Maximum number of conversational turns",type:"number",path:["runConfig","maxTurns"],defaultValue:void 0}];function dg(e,t,o){if(!md(e))return e;let r={...e},n=r;for(let i=0;i<t.length-1;i++){let a=t[i];n[a]===void 0||n[a]===null?n[a]={}:md(n[a])&&(n[a]={...n[a]});let d=n[a];if(md(d))n=d;else return r}let s=t[t.length-1];return o===void 0?delete n[s]:n[s]=o,r}function sI(e,t){return t.kind!=="local"?e.defaultValue:e.key==="enabled"?!t.experimental:e.key==="model"?t.modelConfig?.model??"inherit":e.key==="temperature"?t.modelConfig?.generateContentConfig?.temperature:e.key==="topP"?t.modelConfig?.generateContentConfig?.topP:e.key==="topK"?t.modelConfig?.generateContentConfig?.topK:e.key==="maxOutputTokens"?t.modelConfig?.generateContentConfig?.maxOutputTokens:e.key==="maxTimeMinutes"?t.runConfig?.maxTimeMinutes:e.key==="maxTurns"?t.runConfig?.maxTurns:e.defaultValue}function aI({agentName:e,displayName:t,definition:o,settings:r,onClose:n,onSave:s,availableTerminalHeight:i}){let[a,d]=(0,Ir.useState)("User"),[m,f]=(0,Ir.useState)(()=>{let R=r.forScope(a).settings.agents?.overrides?.[e];return R?structuredClone(R):{}}),[h,p]=(0,Ir.useState)(new Set);(0,Ir.useEffect)(()=>{let R=r.forScope(a).settings.agents?.overrides?.[e];f(R?structuredClone(R):{}),p(new Set)},[a,r,e]);let y=(0,Ir.useCallback)((v,R,b)=>{if(["__proto__","constructor","prototype"].includes(e))return;let _=["agents","overrides",e,...R].join(".");r.setValue(a,_,b),s?.()},[r,a,e,s]),g=(0,Ir.useMemo)(()=>{let v=0;for(let R of Kc){let b=$r(R.label),_=$r(R.description);v=Math.max(v,b,_)}return v},[]),x=(0,Ir.useMemo)(()=>Kc.map(v=>{let R=Cf(m,v.path),b=sI(v,o),_=R!==void 0?R:b,w;v.type==="boolean"?w=_?"true":"false":_!=null?w=String(_):w="(default)",(h.has(v.key)||R!==void 0)&&R!==void 0&&(w+="*");let D=R!==void 0?R:_;return{key:v.key,label:v.label,description:v.description,type:v.type,displayValue:w,isGreyedOut:R===void 0,scopeMessage:void 0,rawValue:D}}),[m,o,h]),S=8,I=(0,Ir.useCallback)(v=>{d(v)},[]),A=(0,Ir.useCallback)((v,R)=>{let b=Kc.find(O=>O.key===v);if(!b||b.type!=="boolean")return;let _=Cf(m,b.path),w=sI(b,o),D=!(_!==void 0?_:w),N=dg(m,b.path,D);f(N),p(O=>new Set(O).add(v)),y(b.key,b.path,D)},[m,o,y]),E=(0,Ir.useCallback)((v,R,b)=>{let _=Kc.find(D=>D.key===v);if(!_)return;let w;if(_.type==="number")if(R.trim()==="")w=void 0;else{let D=Number(R.trim());if(Number.isNaN(D))return;w=D}else w=R.trim()===""?void 0:R;let M=dg(m,_.path,w);f(M),p(D=>new Set(D).add(v)),y(_.key,_.path,w)},[m,y]),T=(0,Ir.useCallback)((v,R)=>{let b=Kc.find(w=>w.key===v);if(!b)return;let _=dg(m,b.path,void 0);f(_),p(w=>{let M=new Set(w);return M.delete(v),M}),y(b.key,b.path,void 0)},[m,y]);return(0,mg.jsx)(ym,{title:`Configure: ${t}`,searchEnabled:!1,items:x,showScopeSelector:!0,selectedScope:a,onScopeChange:I,maxItemsToShow:S,availableHeight:i,maxLabelWidth:g,onItemToggle:A,onEditCommit:E,onItemClear:T,onClose:n,footer:h.size>0?{content:(0,mg.jsx)(l,{color:c.text.secondary,children:"Changes saved automatically."}),height:1}:void 0})}var Rm=C(z(),1);var Fi=C(P(),1);var lI=({config:e,request:t,onClose:o})=>{let r=Ze(),n=(0,Rm.useRef)(!1),s=(0,Rm.useCallback)(async a=>{if(!n.current){n.current=!0;try{a==="accept"&&(await new Nx().acceptIntegrity(t.scope,t.identifier,t.newHash),await e.loadWorkspacePolicies(t.policyDir)),o()}finally{n.current=!1}}},[e,t,o]);me(a=>r["basic.cancel"](a)?(o(),!0):!1,{isActive:!0});let i=[{label:"Accept and Load",value:"accept",key:"accept"},{label:"Ignore (Use Default Policies)",value:"ignore",key:"ignore"}];return(0,Fi.jsx)(u,{flexDirection:"column",width:"100%",children:(0,Fi.jsxs)(u,{flexDirection:"column",borderStyle:"round",borderColor:c.status.warning,padding:1,marginLeft:1,marginRight:1,children:[(0,Fi.jsxs)(u,{flexDirection:"column",marginBottom:1,children:[(0,Fi.jsxs)(l,{bold:!0,color:c.text.primary,children:["New or changed ",t.scope," policies detected"]}),(0,Fi.jsxs)(l,{color:c.text.primary,children:["Location: ",t.identifier]}),(0,Fi.jsx)(l,{color:c.text.primary,children:"Do you want to accept and load these policies?"})]}),(0,Fi.jsx)(We,{items:i,onSelect:s,isFocused:!0})]})})};var jc=C(P(),1);var cI=({onDismiss:e,config:t,message:o})=>{me(n=>n.name==="escape"?(e(),!0):n.name==="r"||n.name==="R"?(setTimeout(async()=>{if(process.send){let s=t.getRemoteAdminSettings();s&&process.send({type:"admin-settings-update",settings:s})}await fr()},100),!0):!1,{isActive:!0});let r=o??"You've successfully signed in with Google. Gemini CLI needs to be restarted.";return(0,jc.jsxs)(u,{borderStyle:"round",borderColor:c.status.warning,paddingX:1,flexDirection:"column",children:[(0,jc.jsx)(l,{color:c.status.warning,children:r}),(0,jc.jsx)(l,{color:c.status.warning,children:"Press R to restart, or Esc to choose a different authentication method."})]})};var qe=C(P(),1);var Im=({addItem:e,terminalWidth:t})=>{let o=Ct(),r=Ke(),n=Ce(),s=Rd(),i=Pr(),{constrainHeight:a,terminalHeight:d,staticExtraHeight:m,terminalWidth:f}=n;if(n.adminSettingsChanged)return(0,qe.jsx)(nI,{});if(n.showIdeRestartPrompt)return(0,qe.jsx)(iI,{reason:n.ideTrustRestartReason});if(n.newAgents)return(0,qe.jsx)(qb,{agents:n.newAgents,onSelect:i.handleNewAgentsSelect});if(s.proQuotaRequest)return(0,qe.jsx)(HR,{failedModel:s.proQuotaRequest.failedModel,fallbackModel:s.proQuotaRequest.fallbackModel,message:s.proQuotaRequest.message,isTerminalQuotaError:s.proQuotaRequest.isTerminalQuotaError,isModelNotFoundError:!!s.proQuotaRequest.isModelNotFoundError,authType:s.proQuotaRequest.authType,tierName:o?.getUserTierName(),onChoice:i.handleProQuotaChoice});if(s.validationRequest)return(0,qe.jsx)(FR,{validationLink:s.validationRequest.validationLink,validationDescription:s.validationRequest.validationDescription,learnMoreUrl:s.validationRequest.learnMoreUrl,onChoice:i.handleValidationChoice});if(s.overageMenuRequest)return(0,qe.jsx)(UR,{failedModel:s.overageMenuRequest.failedModel,fallbackModel:s.overageMenuRequest.fallbackModel,resetTime:s.overageMenuRequest.resetTime,creditBalance:s.overageMenuRequest.creditBalance,onChoice:i.handleOverageMenuChoice});if(s.emptyWalletRequest)return(0,qe.jsx)(GR,{failedModel:s.emptyWalletRequest.failedModel,fallbackModel:s.emptyWalletRequest.fallbackModel,resetTime:s.emptyWalletRequest.resetTime,onGetCredits:s.emptyWalletRequest.onGetCredits,onChoice:i.handleEmptyWalletChoice});if(n.shouldShowIdePrompt)return(0,qe.jsx)(Fb,{ide:n.currentIDE,onComplete:i.handleIdePromptComplete});if(n.isFolderTrustDialogOpen)return(0,qe.jsx)(Ub,{onSelect:i.handleFolderTrustSelect,isRestarting:n.isRestarting,discoveryResults:n.folderDiscoveryResults});if(n.isPolicyUpdateDialogOpen)return(0,qe.jsx)(lI,{config:o,request:n.policyUpdateConfirmationRequest,onClose:()=>i.setIsPolicyUpdateDialogOpen(!1)});if(n.loopDetectionConfirmationRequest)return(0,qe.jsx)(fR,{onComplete:n.loopDetectionConfirmationRequest.onComplete});if(n.permissionConfirmationRequest){let p=n.permissionConfirmationRequest.files.map(y=>`- ${y}`).join(`
61
+ `);return(0,qe.jsx)(Fc,{prompt:`The following files are outside your workspace:
62
62
 
63
63
  ${p}
64
64
 
65
- Do you want to allow this read?`,onConfirm:y=>{n.permissionConfirmationRequest?.onComplete({allowed:y})},terminalWidth:t})}if(n.commandConfirmationRequest)return(0,$e.jsx)(Fc,{prompt:n.commandConfirmationRequest.prompt,onConfirm:n.commandConfirmationRequest.onConfirm,terminalWidth:t});if(n.authConsentRequest)return(0,$e.jsx)(Fc,{prompt:n.authConsentRequest.prompt,onConfirm:n.authConsentRequest.onConfirm,terminalWidth:t});if(n.confirmUpdateExtensionRequests.length>0){let h=n.confirmUpdateExtensionRequests[0];return(0,$e.jsx)(Fc,{prompt:h.prompt,onConfirm:h.onConfirm,terminalWidth:t})}return n.isThemeDialogOpen?(0,$e.jsxs)(u,{flexDirection:"column",children:[n.themeError&&(0,$e.jsx)(u,{marginBottom:1,children:(0,$e.jsx)(l,{color:c.status.error,children:n.themeError})}),(0,$e.jsx)(xR,{onSelect:i.handleThemeSelect,onCancel:i.closeThemeDialog,onHighlight:i.handleThemeHighlight,settings:r,availableTerminalHeight:a?d-m:void 0,terminalWidth:f})]}):n.isSettingsDialogOpen?(0,$e.jsx)(u,{flexDirection:"column",children:(0,$e.jsx)(ER,{onSelect:()=>i.closeSettingsDialog(),onRestartRequest:fr,availableTerminalHeight:d-m})}):n.isModelDialogOpen?(0,$e.jsx)(oI,{onClose:i.closeModelDialog}):n.isVoiceModelDialogOpen?(0,$e.jsx)(rI,{onClose:i.closeVoiceModelDialog}):n.isAgentConfigDialogOpen&&n.selectedAgentName&&n.selectedAgentDisplayName&&n.selectedAgentDefinition?(0,$e.jsx)(u,{flexDirection:"column",children:(0,$e.jsx)(aI,{agentName:n.selectedAgentName,displayName:n.selectedAgentDisplayName,definition:n.selectedAgentDefinition,settings:r,availableTerminalHeight:d-m,onClose:i.closeAgentConfigDialog,onSave:async()=>{let h=o?.getAgentRegistry();h&&await h.reload()}})}):n.accountSuspensionInfo?(0,$e.jsx)(u,{flexDirection:"column",children:(0,$e.jsx)(wR,{accountSuspensionInfo:n.accountSuspensionInfo,onExit:()=>{uP.exit(1)},onChangeAuth:()=>{i.clearAccountSuspension()}})}):n.isAuthenticating?(0,$e.jsx)(RR,{onTimeout:()=>{i.onAuthError("Authentication cancelled.")}}):n.isAwaitingApiKeyInput?(0,$e.jsx)(u,{flexDirection:"column",children:(0,$e.jsx)(_R,{onSubmit:i.handleApiKeySubmit,onCancel:i.handleApiKeyCancel,error:n.authError,defaultValue:n.apiKeyDefaultValue},n.apiKeyDefaultValue)}):n.isAwaitingLoginRestart?(0,$e.jsx)(u,{flexDirection:"column",children:(0,$e.jsx)(cI,{onDismiss:i.dismissLoginRestart,config:o,message:n.loginRestartMessage})}):n.isAuthDialogOpen?(0,$e.jsx)(u,{flexDirection:"column",children:(0,$e.jsx)(AR,{config:o,settings:r,setAuthState:i.setAuthState,authError:n.authError,onAuthError:i.onAuthError,setAuthContext:i.setAuthContext})}):n.isEditorDialogOpen?(0,$e.jsxs)(u,{flexDirection:"column",children:[n.editorError&&(0,$e.jsx)(u,{marginBottom:1,children:(0,$e.jsx)(l,{color:c.status.error,children:n.editorError})}),(0,$e.jsx)(MR,{onSelect:i.handleEditorSelect,settings:r,onExit:i.exitEditorDialog})]}):n.showPrivacyNotice?(0,$e.jsx)(kR,{onExit:()=>i.exitPrivacyNotice(),config:o}):n.isSessionBrowserOpen?(0,$e.jsx)(JR,{config:o,onResumeSession:i.handleResumeSession,onDeleteSession:i.handleDeleteSession,onExit:i.closeSessionBrowser}):n.isPermissionsDialogOpen?(0,$e.jsx)(Vb,{onExit:i.closePermissionsDialog,addItem:e,targetDirectory:n.permissionsDialogProps?.targetDirectory}):null};var eu=C(z(),1);var Ui=C(P(),1);function uI(e,t){return e.ctrlCPressedOnce||!!e.transientMessage||e.ctrlDPressedOnce||t.showEscapePrompt&&(t.buffer.text.length>0||e.history.length>0)||!!e.queueErrorMessage||e.showIsExpandableHint}var dI=()=>{let e=Ce(),t=un();if(e.ctrlCPressedOnce)return(0,Ui.jsx)(l,{color:c.status.warning,children:"Press Ctrl+C again to exit."});if(e.transientMessage?.type==="warning"&&e.transientMessage.text)return(0,Ui.jsx)(l,{color:c.status.warning,children:e.transientMessage.text});if(e.ctrlDPressedOnce)return(0,Ui.jsx)(l,{color:c.status.warning,children:"Press Ctrl+D again to exit."});if(t.showEscapePrompt){let o=t.buffer.text.length===0,r=e.history.length>0;return o&&!r?null:(0,Ui.jsxs)(l,{color:c.text.secondary,children:["Press Esc again to ",o?"rewind":"clear prompt","."]})}if(e.transientMessage?.type==="hint"&&e.transientMessage.text)return(0,Ui.jsx)(l,{color:c.text.secondary,children:e.transientMessage.text});if(e.queueErrorMessage)return(0,Ui.jsx)(l,{color:c.status.error,children:e.queueErrorMessage});if(e.showIsExpandableHint){let o=e.constrainHeight?"show more":"collapse";return(0,Ui.jsxs)(l,{color:c.text.secondary,children:["Press Ctrl+O to ",o," lines of the last response"]})}return null};var Bl=C(z(),1);var Yc=C(z(),1);var mI=1e3,vm=[],Am=0,pg=new Set,zc=[],Nl=null;function gI(){Nl&&(clearTimeout(Nl),Nl=null),zc=[],vm=[],Am=0,fg(),Se.off(Ge.ConsoleLog,pI),Se.off(Ge.Output,fI),Se.on(Ge.ConsoleLog,pI),Se.on(Ge.Output,fI)}function fg(){for(let e of pg)e()}function dP(){if(zc.length===0)return;let e=[...vm];for(let t of zc){t.type==="error"&&Am++;let o=e[e.length-1];o&&o.type===t.type&&o.content===t.content?e[e.length-1]={...o,count:o.count+1}:e.push({...t,count:1})}vm=e.length>mI?e.slice(-mI):e,zc=[],Nl=null,fg()}function hI(e){zc.push(e),Nl||(Nl=setTimeout(dP,50))}function yI(e){return pg.add(e),()=>{pg.delete(e)}}function mP(){return vm}function pP(){return Am}var pI=e=>{let t=e.content,o=1e4;t.length>o&&(t=t.slice(0,o)+`... [Truncated ${t.length-o} characters]`),hI({type:e.type,content:t,count:1})},fI=e=>{let t=typeof e.chunk=="string"?e.chunk:new TextDecoder().decode(e.chunk),o=1e4;t.length>o&&(t=t.slice(0,o)+`... [Truncated ${t.length-o} characters]`),hI({type:"log",content:t,count:1})};function TI(){return(0,Yc.useSyncExternalStore)(yI,mP)}function xI(){let e=(0,Yc.useSyncExternalStore)(yI,pP),t=(0,Yc.useCallback)(()=>{Am=0,fg()},[]);return{errorCount:e,clearErrorCount:t}}var Yr=C(P(),1);var SI=3,CI=({maxHeight:e,width:t,hasFocus:o})=>{let r=(0,Bl.useRef)(null),n=TI(),s=Ct(),i=(0,Bl.useMemo)(()=>s.getDebugMode()?n:n.filter(m=>m.type!=="debug"),[n,s]),a=3,d=(0,Bl.useCallback)(m=>{let f=i[m];if(!f)return 1;let h=t-a-SI;if(h<=0)return 1;let p=Math.ceil((f.content?.length||1)/h);return Math.max(1,p)},[t,i]);return i.length===0?null:(0,Yr.jsxs)(u,{flexDirection:"column",marginTop:1,borderStyle:"round",borderColor:c.border.default,paddingLeft:1,width:t,height:e,flexShrink:0,flexGrow:0,overflow:"hidden",children:[(0,Yr.jsx)(u,{marginBottom:1,children:(0,Yr.jsxs)(l,{bold:!0,color:c.text.primary,children:["Debug Console ",(0,Yr.jsx)(l,{color:c.text.secondary,children:"(F12 to close)"})]})}),(0,Yr.jsx)(u,{height:e,width:t-a,children:(0,Yr.jsx)(pn,{ref:r,data:i,renderItem:({item:m})=>{let f=c.text.primary,h="\u2139";switch(m.type){case"warn":f=c.status.warning,h="\u26A0";break;case"error":f=c.status.error,h="\u2716";break;case"debug":f=c.text.secondary,h="\u{1F50D}";break;case"log":default:break}return(0,Yr.jsxs)(u,{flexDirection:"row",children:[(0,Yr.jsx)(u,{minWidth:SI,flexShrink:0,children:(0,Yr.jsx)(l,{color:f,children:h})}),(0,Yr.jsxs)(l,{color:f,wrap:"wrap",children:[m.content,m.count&&m.count>1&&(0,Yr.jsxs)(l,{color:c.text.secondary,children:[" (x",m.count,")"]})]})]})},keyExtractor:(m,f)=>`${m.content}-${f}`,estimatedItemHeight:d,hasFocus:o,initialScrollIndex:Number.MAX_SAFE_INTEGER})})]})};var wa=C(P(),1);var bI=({title:e,subtitle:t})=>(0,wa.jsxs)(u,{width:"100%",flexDirection:"column",overflow:"hidden",children:[(0,wa.jsx)(u,{width:"100%",borderStyle:"single",borderTop:!0,borderBottom:!1,borderLeft:!1,borderRight:!1,borderColor:c.text.secondary}),(0,wa.jsxs)(u,{flexDirection:"row",children:[(0,wa.jsx)(l,{color:c.text.primary,bold:!0,wrap:"truncate-end",children:e}),t&&(0,wa.jsx)(l,{color:c.text.secondary,wrap:"truncate-end",children:t})]})]});var Tn=C(P(),1);var fP=()=>[{key:"!",description:"shell mode"},{key:"@",description:"select file or folder"},{key:"Double Esc",description:"clear & rewind"},{key:Ee("app.focusShellInput"),description:"focus UI"},{key:Ee("app.toggleYolo"),description:"YOLO mode"},{key:Ee("app.cycleApprovalMode"),description:"cycle mode"},{key:Ee("input.paste"),description:"paste images"},{key:Ee("app.toggleMarkdown"),description:"raw markdown mode"},{key:Ee("history.search.start"),description:"reverse-search history"},{key:Ee("input.openExternalEditor"),description:"open external editor"}],gP=({item:e})=>(0,Tn.jsxs)(u,{flexDirection:"row",children:[(0,Tn.jsx)(u,{flexShrink:0,marginRight:1,children:(0,Tn.jsx)(l,{color:c.text.accent,children:e.key})}),(0,Tn.jsx)(u,{flexGrow:1,children:(0,Tn.jsx)(l,{color:c.text.primary,children:e.description})})]}),EI=()=>{let{terminalWidth:e}=Ce(),t=yl(e),o=fP(),r=t?o:[o[0],o[5],o[6],o[1],o[4],o[7],o[2],o[8],o[9],o[3]];return(0,Tn.jsxs)(u,{flexDirection:"column",width:"100%",children:[(0,Tn.jsx)(bI,{title:" Shortcuts",subtitle:" See /help for more"}),(0,Tn.jsx)(u,{flexDirection:"row",flexWrap:"wrap",paddingLeft:1,paddingRight:2,children:r.map((n,s)=>(0,Tn.jsx)(u,{width:t?"100%":"33%",paddingRight:t?0:2,children:(0,Tn.jsx)(gP,{item:n})},`${n.key}-${s}`))})]})};var tt=C(z(),1);var vo=C(P(),1);var Br=8;function RI({suggestions:e,activeIndex:t,isLoading:o,width:r,scrollOffset:n,userInput:s,mode:i,expandedIndex:a}){if(o)return(0,vo.jsx)(u,{paddingX:1,width:r,children:(0,vo.jsx)(l,{color:"gray",children:"Loading suggestions..."})});if(e.length===0)return null;let d=n,m=Math.min(n+Br,e.length),f=e.slice(d,m),h={"mcp-prompt":" [MCP]",agent:" [Agent]"},p=x=>x.label+(x.commandKind?h[x.commandKind]??"":""),y=Math.max(...e.map(x=>p(x).length)),g=i==="slash"?Math.min(y,Math.floor(r*.5)):0;return(0,vo.jsxs)(u,{flexDirection:"column",paddingX:1,width:r,children:[n>0&&(0,vo.jsx)(l,{color:c.text.primary,children:"\u25B2"}),f.map((x,S)=>{let I=d+S,A=I===t,E=I===a,T=A?c.ui.focus:c.text.secondary,v=x.value.length>=Ac,R=e[I-1]?.sectionTitle,b=i==="slash"&&!!x.sectionTitle&&x.sectionTitle!==R,_=(0,vo.jsx)(NC,{label:x.value,matchedIndex:x.matchedIndex,userInput:s,textColor:T,isExpanded:E});return(0,vo.jsxs)(u,{flexDirection:"column",children:[b&&(0,vo.jsxs)(l,{color:c.text.secondary,children:["-- ",x.sectionTitle," --"]}),(0,vo.jsxs)(u,{flexDirection:"row",backgroundColor:A?c.background.focus:void 0,children:[(0,vo.jsx)(u,{...i==="slash"?{width:g,flexShrink:0}:{flexShrink:1},children:(0,vo.jsxs)(u,{children:[_,x.commandKind&&h[x.commandKind]&&(0,vo.jsx)(l,{color:T,children:h[x.commandKind]})]})}),x.description&&(0,vo.jsx)(u,{flexGrow:1,paddingLeft:3,children:(0,vo.jsx)(l,{color:T,wrap:"truncate",children:Co(x.description,100)})}),A&&v&&(0,vo.jsx)(u,{width:3,flexShrink:0,children:(0,vo.jsx)(l,{color:Fe.Gray,children:E?" \u2190 ":" \u2192 "})})]})]},`${x.value}-${I}`)}),m<e.length&&(0,vo.jsx)(l,{color:"gray",children:"\u25BC"}),e.length>Br&&(0,vo.jsxs)(l,{color:"gray",children:["(",t+1,"/",e.length,")"]})]})}var Ln=C(z(),1);function II({userMessages:e,onSubmit:t,isActive:o,currentQuery:r,currentCursorOffset:n,onChange:s}){let[i,a]=(0,Ln.useState)(-1),d=(0,Ln.useRef)(void 0),m=(0,Ln.useRef)({}),f=(0,Ln.useCallback)(()=>{a(-1),d.current=void 0,m.current={}},[]),h=(0,Ln.useCallback)(x=>{let S=x.trim();S&&t(S),f()},[t,f]),p=(0,Ln.useCallback)((x,S)=>{let I=i;m.current[I]={text:r,offset:n},a(x);let A=m.current[x];if((x===-1||x===d.current)&&A&&A.offset>0&&A.offset<to(A.text))s(A.text,A.offset);else if(x===-1)s(A?A.text:"",S);else if(A)s(A.text,S);else{let T=e[e.length-1-x];s(T,S)}d.current=I},[i,r,n,e,s]),y=(0,Ln.useCallback)(()=>!o||e.length===0?!1:i<e.length-1?(p(i+1,"start"),!0):!1,[i,e,o,p]),g=(0,Ln.useCallback)(()=>!o||i===-1?!1:(p(i-1,"end"),!0),[i,o,p]);return{handleSubmit:h,navigateUp:y,navigateDown:g}}var wm=C(z(),1);var _m=C(P(),1);var hP=[" ","\u2582","\u2583","\u2584","\u2585","\u2586","\u2587","\u2588"],yP=.4,TP=1.2,xP=3.5,SP=40,vI=({color:e})=>{let[t,o]=(0,wm.useState)(0),r=Dr();if((0,wm.useEffect)(()=>{if(r)return;let s=setInterval(()=>o(i=>i+1),SP);return()=>clearInterval(s)},[r]),r)return(0,_m.jsx)(l,{color:e,children:"Listening... "});let n=Array.from({length:3}).map((s,i)=>{let a=t*yP+i*TP,d=Math.floor((Math.sin(a)+1)*xP);return hP[Math.max(0,Math.min(7,d))]??" "});return(0,_m.jsxs)(l,{color:e,children:[n.join("")," "]})};var Xc=C(dd(),1);var Nn=C(z(),1);import*as kl from"node:fs/promises";import*as AI from"node:path";var CP=100;async function bP(e,t){let o=t??new Xa(e);return await o.initialize(),o.getHistoryFilePath()}async function EP(e){try{let t=await kl.readFile(e,"utf-8"),o=[],r="";for(let n of t.split(/\r?\n/)){if(!n.trim())continue;let s=n,i=r.match(/(\\+)$/);i&&i[1].length%2?r=r.slice(0,-1)+" "+s:(r&&o.push(r),r=s)}return r&&o.push(r),o}catch(t){return Gu(t)&&t.code==="ENOENT"?[]:(de.error("Error reading history:",t),[])}}async function RP(e,t){try{await kl.mkdir(AI.dirname(e),{recursive:!0}),await kl.writeFile(e,t.join(`
65
+ Do you want to allow this read?`,onConfirm:y=>{n.permissionConfirmationRequest?.onComplete({allowed:y})},terminalWidth:t})}if(n.commandConfirmationRequest)return(0,qe.jsx)(Fc,{prompt:n.commandConfirmationRequest.prompt,onConfirm:n.commandConfirmationRequest.onConfirm,terminalWidth:t});if(n.authConsentRequest)return(0,qe.jsx)(Fc,{prompt:n.authConsentRequest.prompt,onConfirm:n.authConsentRequest.onConfirm,terminalWidth:t});if(n.confirmUpdateExtensionRequests.length>0){let h=n.confirmUpdateExtensionRequests[0];return(0,qe.jsx)(Fc,{prompt:h.prompt,onConfirm:h.onConfirm,terminalWidth:t})}return n.isThemeDialogOpen?(0,qe.jsxs)(u,{flexDirection:"column",children:[n.themeError&&(0,qe.jsx)(u,{marginBottom:1,children:(0,qe.jsx)(l,{color:c.status.error,children:n.themeError})}),(0,qe.jsx)(xR,{onSelect:i.handleThemeSelect,onCancel:i.closeThemeDialog,onHighlight:i.handleThemeHighlight,settings:r,availableTerminalHeight:a?d-m:void 0,terminalWidth:f})]}):n.isSettingsDialogOpen?(0,qe.jsx)(u,{flexDirection:"column",children:(0,qe.jsx)(ER,{onSelect:()=>i.closeSettingsDialog(),onRestartRequest:fr,availableTerminalHeight:d-m})}):n.isModelDialogOpen?(0,qe.jsx)(oI,{onClose:i.closeModelDialog}):n.isVoiceModelDialogOpen?(0,qe.jsx)(rI,{onClose:i.closeVoiceModelDialog}):n.isAgentConfigDialogOpen&&n.selectedAgentName&&n.selectedAgentDisplayName&&n.selectedAgentDefinition?(0,qe.jsx)(u,{flexDirection:"column",children:(0,qe.jsx)(aI,{agentName:n.selectedAgentName,displayName:n.selectedAgentDisplayName,definition:n.selectedAgentDefinition,settings:r,availableTerminalHeight:d-m,onClose:i.closeAgentConfigDialog,onSave:async()=>{let h=o?.getAgentRegistry();h&&await h.reload()}})}):n.accountSuspensionInfo?(0,qe.jsx)(u,{flexDirection:"column",children:(0,qe.jsx)(wR,{accountSuspensionInfo:n.accountSuspensionInfo,onExit:()=>{uP.exit(1)},onChangeAuth:()=>{i.clearAccountSuspension()}})}):n.isAuthenticating?(0,qe.jsx)(RR,{onTimeout:()=>{i.onAuthError("Authentication cancelled.")}}):n.isAwaitingApiKeyInput?(0,qe.jsx)(u,{flexDirection:"column",children:(0,qe.jsx)(_R,{onSubmit:i.handleApiKeySubmit,onCancel:i.handleApiKeyCancel,error:n.authError,defaultValue:n.apiKeyDefaultValue},n.apiKeyDefaultValue)}):n.isAwaitingLoginRestart?(0,qe.jsx)(u,{flexDirection:"column",children:(0,qe.jsx)(cI,{onDismiss:i.dismissLoginRestart,config:o,message:n.loginRestartMessage})}):n.isAuthDialogOpen?(0,qe.jsx)(u,{flexDirection:"column",children:(0,qe.jsx)(AR,{config:o,settings:r,setAuthState:i.setAuthState,authError:n.authError,onAuthError:i.onAuthError,setAuthContext:i.setAuthContext})}):n.isEditorDialogOpen?(0,qe.jsxs)(u,{flexDirection:"column",children:[n.editorError&&(0,qe.jsx)(u,{marginBottom:1,children:(0,qe.jsx)(l,{color:c.status.error,children:n.editorError})}),(0,qe.jsx)(MR,{onSelect:i.handleEditorSelect,settings:r,onExit:i.exitEditorDialog})]}):n.showPrivacyNotice?(0,qe.jsx)(kR,{onExit:()=>i.exitPrivacyNotice(),config:o}):n.isSessionBrowserOpen?(0,qe.jsx)(JR,{config:o,onResumeSession:i.handleResumeSession,onDeleteSession:i.handleDeleteSession,onExit:i.closeSessionBrowser}):n.isPermissionsDialogOpen?(0,qe.jsx)(Vb,{onExit:i.closePermissionsDialog,addItem:e,targetDirectory:n.permissionsDialogProps?.targetDirectory}):null};var eu=C(z(),1);var Ui=C(P(),1);function uI(e,t){return e.ctrlCPressedOnce||!!e.transientMessage||e.ctrlDPressedOnce||t.showEscapePrompt&&(t.buffer.text.length>0||e.history.length>0)||!!e.queueErrorMessage||e.showIsExpandableHint}var dI=()=>{let e=Ce(),t=un();if(e.ctrlCPressedOnce)return(0,Ui.jsx)(l,{color:c.status.warning,children:"Press Ctrl+C again to exit."});if(e.transientMessage?.type==="warning"&&e.transientMessage.text)return(0,Ui.jsx)(l,{color:c.status.warning,children:e.transientMessage.text});if(e.ctrlDPressedOnce)return(0,Ui.jsx)(l,{color:c.status.warning,children:"Press Ctrl+D again to exit."});if(t.showEscapePrompt){let o=t.buffer.text.length===0,r=e.history.length>0;return o&&!r?null:(0,Ui.jsxs)(l,{color:c.text.secondary,children:["Press Esc again to ",o?"rewind":"clear prompt","."]})}if(e.transientMessage?.type==="hint"&&e.transientMessage.text)return(0,Ui.jsx)(l,{color:c.text.secondary,children:e.transientMessage.text});if(e.queueErrorMessage)return(0,Ui.jsx)(l,{color:c.status.error,children:e.queueErrorMessage});if(e.showIsExpandableHint){let o=e.constrainHeight?"show more":"collapse";return(0,Ui.jsxs)(l,{color:c.text.secondary,children:["Press Ctrl+O to ",o," lines of the last response"]})}return null};var Bl=C(z(),1);var Yc=C(z(),1);var mI=1e3,vm=[],Am=0,pg=new Set,zc=[],Nl=null;function gI(){Nl&&(clearTimeout(Nl),Nl=null),zc=[],vm=[],Am=0,fg(),Se.off(Ge.ConsoleLog,pI),Se.off(Ge.Output,fI),Se.on(Ge.ConsoleLog,pI),Se.on(Ge.Output,fI)}function fg(){for(let e of pg)e()}function dP(){if(zc.length===0)return;let e=[...vm];for(let t of zc){t.type==="error"&&Am++;let o=e[e.length-1];o&&o.type===t.type&&o.content===t.content?e[e.length-1]={...o,count:o.count+1}:e.push({...t,count:1})}vm=e.length>mI?e.slice(-mI):e,zc=[],Nl=null,fg()}function hI(e){zc.push(e),Nl||(Nl=setTimeout(dP,50))}function yI(e){return pg.add(e),()=>{pg.delete(e)}}function mP(){return vm}function pP(){return Am}var pI=e=>{let t=e.content,o=1e4;t.length>o&&(t=t.slice(0,o)+`... [Truncated ${t.length-o} characters]`),hI({type:e.type,content:t,count:1})},fI=e=>{let t=typeof e.chunk=="string"?e.chunk:new TextDecoder().decode(e.chunk),o=1e4;t.length>o&&(t=t.slice(0,o)+`... [Truncated ${t.length-o} characters]`),hI({type:"log",content:t,count:1})};function TI(){return(0,Yc.useSyncExternalStore)(yI,mP)}function xI(){let e=(0,Yc.useSyncExternalStore)(yI,pP),t=(0,Yc.useCallback)(()=>{Am=0,fg()},[]);return{errorCount:e,clearErrorCount:t}}var Yr=C(P(),1);var SI=3,CI=({maxHeight:e,width:t,hasFocus:o})=>{let r=(0,Bl.useRef)(null),n=TI(),s=Ct(),i=(0,Bl.useMemo)(()=>s.getDebugMode()?n:n.filter(m=>m.type!=="debug"),[n,s]),a=3,d=(0,Bl.useCallback)(m=>{let f=i[m];if(!f)return 1;let h=t-a-SI;if(h<=0)return 1;let p=Math.ceil((f.content?.length||1)/h);return Math.max(1,p)},[t,i]);return i.length===0?null:(0,Yr.jsxs)(u,{flexDirection:"column",marginTop:1,borderStyle:"round",borderColor:c.border.default,paddingLeft:1,width:t,height:e,flexShrink:0,flexGrow:0,overflow:"hidden",children:[(0,Yr.jsx)(u,{marginBottom:1,children:(0,Yr.jsxs)(l,{bold:!0,color:c.text.primary,children:["Debug Console ",(0,Yr.jsx)(l,{color:c.text.secondary,children:"(F12 to close)"})]})}),(0,Yr.jsx)(u,{height:e,width:t-a,children:(0,Yr.jsx)(pn,{ref:r,data:i,renderItem:({item:m})=>{let f=c.text.primary,h="\u2139";switch(m.type){case"warn":f=c.status.warning,h="\u26A0";break;case"error":f=c.status.error,h="\u2716";break;case"debug":f=c.text.secondary,h="\u{1F50D}";break;case"log":default:break}return(0,Yr.jsxs)(u,{flexDirection:"row",children:[(0,Yr.jsx)(u,{minWidth:SI,flexShrink:0,children:(0,Yr.jsx)(l,{color:f,children:h})}),(0,Yr.jsxs)(l,{color:f,wrap:"wrap",children:[m.content,m.count&&m.count>1&&(0,Yr.jsxs)(l,{color:c.text.secondary,children:[" (x",m.count,")"]})]})]})},keyExtractor:(m,f)=>`${m.content}-${f}`,estimatedItemHeight:d,hasFocus:o,initialScrollIndex:Number.MAX_SAFE_INTEGER})})]})};var wa=C(P(),1);var bI=({title:e,subtitle:t})=>(0,wa.jsxs)(u,{width:"100%",flexDirection:"column",overflow:"hidden",children:[(0,wa.jsx)(u,{width:"100%",borderStyle:"single",borderTop:!0,borderBottom:!1,borderLeft:!1,borderRight:!1,borderColor:c.text.secondary}),(0,wa.jsxs)(u,{flexDirection:"row",children:[(0,wa.jsx)(l,{color:c.text.primary,bold:!0,wrap:"truncate-end",children:e}),t&&(0,wa.jsx)(l,{color:c.text.secondary,wrap:"truncate-end",children:t})]})]});var Tn=C(P(),1);var fP=()=>[{key:"!",description:"shell mode"},{key:"@",description:"select file or folder"},{key:"Double Esc",description:"clear & rewind"},{key:Ee("app.focusShellInput"),description:"focus UI"},{key:Ee("app.toggleYolo"),description:"YOLO mode"},{key:Ee("app.cycleApprovalMode"),description:"cycle mode"},{key:Ee("input.paste"),description:"paste images"},{key:Ee("app.toggleMarkdown"),description:"raw markdown mode"},{key:Ee("history.search.start"),description:"reverse-search history"},{key:Ee("input.openExternalEditor"),description:"open external editor"}],gP=({item:e})=>(0,Tn.jsxs)(u,{flexDirection:"row",children:[(0,Tn.jsx)(u,{flexShrink:0,marginRight:1,children:(0,Tn.jsx)(l,{color:c.text.accent,children:e.key})}),(0,Tn.jsx)(u,{flexGrow:1,children:(0,Tn.jsx)(l,{color:c.text.primary,children:e.description})})]}),EI=()=>{let{terminalWidth:e}=Ce(),t=yl(e),o=fP(),r=t?o:[o[0],o[5],o[6],o[1],o[4],o[7],o[2],o[8],o[9],o[3]];return(0,Tn.jsxs)(u,{flexDirection:"column",width:"100%",children:[(0,Tn.jsx)(bI,{title:" Shortcuts",subtitle:" See /help for more"}),(0,Tn.jsx)(u,{flexDirection:"row",flexWrap:"wrap",paddingLeft:1,paddingRight:2,children:r.map((n,s)=>(0,Tn.jsx)(u,{width:t?"100%":"33%",paddingRight:t?0:2,children:(0,Tn.jsx)(gP,{item:n})},`${n.key}-${s}`))})]})};var tt=C(z(),1);var vo=C(P(),1);var Br=8;function RI({suggestions:e,activeIndex:t,isLoading:o,width:r,scrollOffset:n,userInput:s,mode:i,expandedIndex:a}){if(o)return(0,vo.jsx)(u,{paddingX:1,width:r,children:(0,vo.jsx)(l,{color:"gray",children:"Loading suggestions..."})});if(e.length===0)return null;let d=n,m=Math.min(n+Br,e.length),f=e.slice(d,m),h={"mcp-prompt":" [MCP]",agent:" [Agent]"},p=x=>x.label+(x.commandKind?h[x.commandKind]??"":""),y=Math.max(...e.map(x=>p(x).length)),g=i==="slash"?Math.min(y,Math.floor(r*.5)):0;return(0,vo.jsxs)(u,{flexDirection:"column",paddingX:1,width:r,children:[n>0&&(0,vo.jsx)(l,{color:c.text.primary,children:"\u25B2"}),f.map((x,S)=>{let I=d+S,A=I===t,E=I===a,T=A?c.ui.focus:c.text.secondary,v=x.value.length>=Ac,R=e[I-1]?.sectionTitle,b=i==="slash"&&!!x.sectionTitle&&x.sectionTitle!==R,_=(0,vo.jsx)(NC,{label:x.value,matchedIndex:x.matchedIndex,userInput:s,textColor:T,isExpanded:E});return(0,vo.jsxs)(u,{flexDirection:"column",children:[b&&(0,vo.jsxs)(l,{color:c.text.secondary,children:["-- ",x.sectionTitle," --"]}),(0,vo.jsxs)(u,{flexDirection:"row",backgroundColor:A?c.background.focus:void 0,children:[(0,vo.jsx)(u,{...i==="slash"?{width:g,flexShrink:0}:{flexShrink:1},children:(0,vo.jsxs)(u,{children:[_,x.commandKind&&h[x.commandKind]&&(0,vo.jsx)(l,{color:T,children:h[x.commandKind]})]})}),x.description&&(0,vo.jsx)(u,{flexGrow:1,paddingLeft:3,children:(0,vo.jsx)(l,{color:T,wrap:"truncate",children:Co(x.description,100)})}),A&&v&&(0,vo.jsx)(u,{width:3,flexShrink:0,children:(0,vo.jsx)(l,{color:Fe.Gray,children:E?" \u2190 ":" \u2192 "})})]})]},`${x.value}-${I}`)}),m<e.length&&(0,vo.jsx)(l,{color:"gray",children:"\u25BC"}),e.length>Br&&(0,vo.jsxs)(l,{color:"gray",children:["(",t+1,"/",e.length,")"]})]})}var Ln=C(z(),1);function II({userMessages:e,onSubmit:t,isActive:o,currentQuery:r,currentCursorOffset:n,onChange:s}){let[i,a]=(0,Ln.useState)(-1),d=(0,Ln.useRef)(void 0),m=(0,Ln.useRef)({}),f=(0,Ln.useCallback)(()=>{a(-1),d.current=void 0,m.current={}},[]),h=(0,Ln.useCallback)(x=>{let S=x.trim();S&&t(S),f()},[t,f]),p=(0,Ln.useCallback)((x,S)=>{let I=i;m.current[I]={text:r,offset:n},a(x);let A=m.current[x];if((x===-1||x===d.current)&&A&&A.offset>0&&A.offset<to(A.text))s(A.text,A.offset);else if(x===-1)s(A?A.text:"",S);else if(A)s(A.text,S);else{let T=e[e.length-1-x];s(T,S)}d.current=I},[i,r,n,e,s]),y=(0,Ln.useCallback)(()=>!o||e.length===0?!1:i<e.length-1?(p(i+1,"start"),!0):!1,[i,e,o,p]),g=(0,Ln.useCallback)(()=>!o||i===-1?!1:(p(i-1,"end"),!0),[i,o,p]);return{handleSubmit:h,navigateUp:y,navigateDown:g}}var wm=C(z(),1);var _m=C(P(),1);var hP=[" ","\u2582","\u2583","\u2584","\u2585","\u2586","\u2587","\u2588"],yP=.4,TP=1.2,xP=3.5,SP=40,vI=({color:e})=>{let[t,o]=(0,wm.useState)(0),r=Dr();if((0,wm.useEffect)(()=>{if(r)return;let s=setInterval(()=>o(i=>i+1),SP);return()=>clearInterval(s)},[r]),r)return(0,_m.jsx)(l,{color:e,children:"Listening... "});let n=Array.from({length:3}).map((s,i)=>{let a=t*yP+i*TP,d=Math.floor((Math.sin(a)+1)*xP);return hP[Math.max(0,Math.min(7,d))]??" "});return(0,_m.jsxs)(l,{color:e,children:[n.join("")," "]})};var Xc=C(dd(),1);var Nn=C(z(),1);import*as kl from"node:fs/promises";import*as AI from"node:path";var CP=100;async function bP(e,t){let o=t??new Xa(e);return await o.initialize(),o.getHistoryFilePath()}async function EP(e){try{let t=await kl.readFile(e,"utf-8"),o=[],r="";for(let n of t.split(/\r?\n/)){if(!n.trim())continue;let s=n,i=r.match(/(\\+)$/);i&&i[1].length%2?r=r.slice(0,-1)+" "+s:(r&&o.push(r),r=s)}return r&&o.push(r),o}catch(t){return Gu(t)&&t.code==="ENOENT"?[]:(de.error("Error reading history:",t),[])}}async function RP(e,t){try{await kl.mkdir(AI.dirname(e),{recursive:!0}),await kl.writeFile(e,t.join(`
66
66
  `))}catch(o){de.error("Error writing shell history:",o)}}function wI(e,t){let[o,r]=(0,Nn.useState)([]),[n,s]=(0,Nn.useState)(-1),[i,a]=(0,Nn.useState)(null);(0,Nn.useEffect)(()=>{async function p(){let y=await bP(e,t);a(y);let g=await EP(y);r(g.reverse())}p()},[e,t]);let d=(0,Nn.useCallback)(p=>{if(!p.trim()||!i)return;let y=[p,...o.filter(g=>g!==p)].slice(0,CP).filter(Boolean);r(y),RP(i,[...y].reverse()),s(-1)},[o,i]),m=(0,Nn.useCallback)(()=>{if(o.length===0)return null;let p=Math.min(n+1,o.length-1);return s(p),o[p]??null},[o,n]),f=(0,Nn.useCallback)(()=>{if(n<0)return null;let p=n-1;return s(p),p<0?"":o[p]??null},[o,n]),h=(0,Nn.useCallback)(()=>{s(-1)},[]);return{history:o,addCommandToHistory:d,getPreviousCommand:m,getNextCommand:f,resetHistoryPosition:h}}var vr=C(z(),1);var pi=C(z(),1);function Dm(){let[e,t]=(0,pi.useState)([]),[o,r]=(0,pi.useState)(-1),[n,s]=(0,pi.useState)(0),[i,a]=(0,pi.useState)(!1),[d,m]=(0,pi.useState)(!1),f=(0,pi.useCallback)(()=>{t([]),r(-1),s(0),a(!1),m(!1)},[]),h=(0,pi.useCallback)(()=>{e.length!==0&&r(y=>{let g=y<=0?e.length-1:y-1;return s(x=>g===e.length-1&&e.length>Br?Math.max(0,e.length-Br):g<x?g:x),g})},[e.length]),p=(0,pi.useCallback)(()=>{e.length!==0&&r(y=>{let g=y>=e.length-1?0:y+1;return s(x=>{if(g===0&&e.length>Br)return 0;let S=x+Br;return g>=S?g-Br+1:x}),g})},[e.length]);return{suggestions:e,activeSuggestionIndex:o,visibleStartIndex:n,isLoadingSuggestions:i,isPerfectMatch:d,setSuggestions:t,setActiveSuggestionIndex:r,setVisibleStartIndex:s,setIsLoadingSuggestions:a,setIsPerfectMatch:m,resetCompletionState:f,navigateUp:h,navigateDown:p}}function IP(e,t=200){let[o,r]=(0,vr.useState)(e);return(0,vr.useEffect)(()=>{let n=setTimeout(()=>r(e),t);return()=>clearTimeout(n)},[e,t]),o}function gg(e,t,o){let{suggestions:r,activeSuggestionIndex:n,visibleStartIndex:s,isLoadingSuggestions:i,setSuggestions:a,setActiveSuggestionIndex:d,resetCompletionState:m,navigateUp:f,navigateDown:h,setVisibleStartIndex:p}=Dm(),y=IP(e.text,100),g=(0,vr.useRef)(""),x=(0,vr.useRef)([]);(0,vr.useEffect)(()=>{o&&(g.current="",x.current=[])},[o]),(0,vr.useEffect)(()=>{g.current="",x.current=[]},[t]);let S=(0,vr.useCallback)((T,v)=>{let R=[];for(let b=0;b<v.length;b++){let _=v[b],w=_.toLowerCase().indexOf(T);w!==-1&&R.push({label:_,value:_,matchedIndex:w})}return R},[]),I=(0,vr.useMemo)(()=>{if(!o)return[];if(y.length===0)return t.map(b=>({label:b,value:b,matchedIndex:-1}));let T=y.toLowerCase(),R=g.current&&T.startsWith(g.current)&&x.current.length>0?x.current.map(b=>b.value):t;return S(T,R)},[y,t,o,S]);(0,vr.useEffect)(()=>{if(!o){m();return}a(I);let T=I.length>0;d(T?0:-1),p(0),g.current=y.toLowerCase(),x.current=I},[y,I,o,a,d,p,m]);let A=o&&(i||r.length>0),E=(0,vr.useCallback)(T=>{T<0||T>=r.length||(e.setText(r[T].value),m())},[e,r,m]);return{suggestions:r,activeSuggestionIndex:n,visibleStartIndex:s,showSuggestions:A,isLoadingSuggestions:i,navigateUp:f,navigateDown:h,handleAutocomplete:E,resetCompletionState:m}}var xn=C(z(),1);var Bo=C(z(),1);import{setTimeout as vP}from"node:timers/promises";import*as _I from"node:path";var AP=5e3;var DI={status:"idle",suggestions:[],isLoading:!1,pattern:null};function wP(e,t){switch(t.type){case"INITIALIZE":return{...e,status:"initializing",isLoading:!0};case"INITIALIZE_SUCCESS":return{...e,status:"ready",isLoading:!1};case"SEARCH":return{...e,status:"searching",pattern:t.payload};case"SEARCH_SUCCESS":return{...e,status:"ready",suggestions:t.payload,isLoading:!1};case"SET_LOADING":return e.status==="searching"?{...e,isLoading:t.payload,suggestions:[]}:e;case"ERROR":return{...e,status:"error",isLoading:!1,suggestions:[]};case"RESET":return DI;default:return e}}function _P(e){let t=e?.getResourceRegistry?.();return t?t.getAllResources().map(r=>{let n=`${r.serverName}:${r.uri}`;return{searchKey:`${n} ${r.name??""}`.toLowerCase(),suggestion:{label:n,value:n}}}):[]}function DP(e){let t=e?.getAgentRegistry?.();return t?t.getAllDefinitions().map(o=>({label:o.name,value:o.name,commandKind:"agent"})):[]}async function MP(e,t){if(t.length===0)return[];let o=e.toLowerCase();return o?(await new ta(t,{selector:s=>s.searchKey}).find(o,{limit:Br*3})).map(s=>s.item.suggestion):t.slice(0,Br).map(s=>s.suggestion)}async function PP(e,t){if(t.length===0)return[];let o=e.toLowerCase();return o?(await new ta(t,{selector:s=>s.label}).find(o,{limit:Br})).map(s=>s.item):t.slice(0,Br)}function MI(e){let{enabled:t,pattern:o,config:r,cwd:n,setSuggestions:s,setIsLoadingSuggestions:i}=e,[a,d]=(0,Bo.useReducer)(wP,DI),m=(0,Bo.useRef)(new Map),f=(0,Bo.useRef)(0),h=(0,Bo.useRef)(null),p=(0,Bo.useRef)(null);(0,Bo.useEffect)(()=>{s(a.suggestions)},[a.suggestions,s]),(0,Bo.useEffect)(()=>{i(a.isLoading)},[a.isLoading,i]);let y=(0,Bo.useCallback)(async()=>{let x=[...m.current.values()];m.current.clear(),f.current+=1;let S=[];for(let I of x)I.close&&S.push(I.close());await Promise.all(S)},[]),g=(0,Bo.useCallback)(()=>{y(),d({type:"RESET"})},[y]);(0,Bo.useEffect)(()=>{g()},[n,r,g]),(0,Bo.useEffect)(()=>{let x=r?.getWorkspaceContext?.();return x?x.onDirectoriesChanged(g):void 0},[r,g]),(0,Bo.useEffect)(()=>()=>{y(),h.current?.abort(),p.current&&clearTimeout(p.current)},[y]),(0,Bo.useEffect)(()=>{if(!t){(a.status==="ready"||a.status==="error")&&d({type:"RESET"});return}if(o===null){d({type:"RESET"});return}a.status==="idle"?d({type:"INITIALIZE"}):(a.status==="ready"||a.status==="searching")&&o.toLowerCase()!==a.pattern&&d({type:"SEARCH",payload:o.toLowerCase()})},[t,o,a.status,a.pattern]),(0,Bo.useEffect)(()=>{let x=async()=>{let I=f.current;try{let A=r?.getWorkspaceContext?.()?.getDirectories()??[n],E=[];for(let T of A){if(m.current.has(T))continue;let v=Gx.create({projectRoot:T,ignoreDirs:[],fileDiscoveryService:new Ix(T,r?.getFileFilteringOptions()),cache:!0,cacheTtl:30,enableFileWatcher:r?.getFileFilteringOptions()?.enableFileWatcher??!1,enableRecursiveFileSearch:r?.getEnableRecursiveFileSearch()??!0,enableFuzzySearch:r?.getFileFilteringEnableFuzzySearch()??!0,maxFiles:r?.getFileFilteringOptions()?.maxFileCount});E.push(v.initialize().then(()=>{f.current===I&&m.current.set(T,v)}))}if(await Promise.all(E),f.current!==I)return;d({type:"INITIALIZE_SUCCESS"}),a.pattern!==null&&d({type:"SEARCH",payload:a.pattern})}catch{f.current===I&&d({type:"ERROR"})}},S=async()=>{if(m.current.size===0||a.pattern===null)return;let I=a.pattern;p.current&&clearTimeout(p.current);let A=new AbortController;h.current=A,p.current=setTimeout(()=>{d({type:"SET_LOADING",payload:!0})},200);let E=r?.getFileFilteringOptions()?.searchTimeout??AP;(async()=>{try{await vP(E,void 0,{signal:A.signal}),A.abort()}catch{}})();try{let v=(r?.getWorkspaceContext?.()?.getDirectories()??[n])[0],R=[...m.current.entries()].map(async([L,k])=>{let F=await k.search(I,{signal:A.signal,maxResults:Br*3});return L!==v?F.map(B=>_I.join(L,B)):F}),b=await Promise.all(R);if(p.current&&clearTimeout(p.current),A.signal.aborted)return;let w=b.flat().map(L=>({label:L,value:aT(L)})),M=_P(r),D=(await MP(I??"",M)).map(L=>({...L,label:L.label.replace(/^@/,""),value:L.value.replace(/^@/,"")})),N=DP(r),O=await PP(I??"",N);if(A.signal.aborted)return;let W=[...O,...w,...D];d({type:"SEARCH_SUCCESS",payload:W})}catch(T){T instanceof Error&&T.name==="AbortError"||d({type:"ERROR"})}finally{A.abort()}};return a.status==="initializing"?x():a.status==="searching"&&S(),()=>{h.current?.abort(),p.current&&clearTimeout(p.current)}},[a.status,a.pattern,r,n])}var nr=C(z(),1);function Mm(e,t){e instanceof Error?de.warn(`[${t}]`,e):de.warn(`[${t}] Non-error thrown:`,e)}function Pm(e,t){return e.name.toLowerCase()===t.toLowerCase()||e.altNames?.some(o=>o.toLowerCase()===t.toLowerCase())||!1}function OP(e,t){return(0,nr.useMemo)(()=>{if(!e)return{hasTrailingSpace:!1,commandPathParts:[],partial:"",currentLevel:t,leafCommand:null,isArgumentCompletion:!1};let o=e.substring(1)||"",r=!!e.endsWith(" "),n=o.split(/\s+/).filter(h=>h),s=n,i="";!r&&n.length>0&&(i=n[n.length-1],s=n.slice(0,-1));let a=t,d=null;for(let h of s){if(!a){d=null,a=[];break}let p=a.find(y=>Pm(y,h));if(p){if(d=p,a=p.subCommands,p.kind==="mcp-prompt")break}else{d=null,a=[];break}}let m=s.length,f=!!(d?.completion&&(r||n.length>m&&m>0&&i!==""));return{hasTrailingSpace:r,commandPathParts:s,partial:i,currentLevel:a,leafCommand:d,isArgumentCompletion:f}},[e,t])}function LP(e,t,o,r,n){let[s,i]=(0,nr.useState)([]),[a,d]=(0,nr.useState)(!1);return(0,nr.useEffect)(()=>{let m=new AbortController,{signal:f}=m,{isArgumentCompletion:h,leafCommand:p,commandPathParts:y,partial:g,currentLevel:x}=t;if(h)return(async()=>{if(f.aborted)return;if(!p?.completion){de.warn("Attempted argument completion without completion function");return}p.showCompletionLoading!==!1&&d(!0);try{let E=[...y];g&&E.push(g);let T=y.length,v=E.slice(T).join(" "),R=await p.completion({...o,invocation:{raw:e||`/${E.join(" ")}`,name:p.name,args:v}},v)||[];if(!f.aborted){let b=R.map(_=>({label:_,value:_}));i(b),d(!1)}}catch(E){f.aborted||(Mm(E,"Argument completion"),i([]),d(!1))}})(),()=>m.abort();let S=x||[];return S.length>0?((async()=>{if(f.aborted)return;let A=[];if(g==="")A=S.filter(E=>E.description&&!E.hidden);else{let E=r(S);if(E)try{let T=await E.fzf.find(g);if(f.aborted)return;let v=new Set;T.forEach(R=>{let b=E.commandMap.get(R.item);b&&b.description&&v.add(b)}),A=Array.from(v)}catch(T){Mm(T,"Fuzzy search - falling back to prefix matching"),A=n(S,g)}else A=n(S,g)}if(!f.aborted){let E=g.toLowerCase(),v=[...A].sort((b,_)=>{let w=b.name.toLowerCase()===E,M=_.name.toLowerCase()===E;if(w&&!M)return-1;if(!w&&M)return 1;let D=b.altNames?.some(F=>F.toLowerCase()===E)||!1,N=_.altNames?.some(F=>F.toLowerCase()===E)||!1;if(D&&!N)return-1;if(!D&&N)return 1;let O=b.name.toLowerCase().startsWith(E),W=_.name.toLowerCase().startsWith(E);if(O&&!W)return-1;if(!O&&W)return 1;let L=b.altNames?.some(F=>F.toLowerCase().startsWith(E))||!1,k=_.altNames?.some(F=>F.toLowerCase().startsWith(E))||!1;return L&&!k?-1:!L&&k?1:0}).map(b=>{let _={label:b.name,value:b.name,description:b.description,commandKind:b.kind};return b.suggestionGroup&&(_.sectionTitle=b.suggestionGroup),_});if(!!(p&&(p.name==="chat"||p.name==="resume")&&(y.length===0||y.length===1&&Pm(p,y[0])))){let b=p.name,_="list";if(g===""||_.toLowerCase().startsWith(g.toLowerCase())){let w={label:_,value:_,insertValue:b,description:"Browse auto-saved chats",commandKind:"built-in",sectionTitle:"auto",submitValue:`/${b}`};i([w,...v]);return}}i(v)}})().catch(A=>{Mm(A,"Unexpected fuzzy search error"),f.aborted||i([])}),()=>m.abort()):(i([]),()=>m.abort())},[e,t,o,r,n]),{suggestions:s,isLoading:a}}function NP(e,t){return(0,nr.useMemo)(()=>{if(!e)return{start:-1,end:-1};let{hasTrailingSpace:o,partial:r}=t;return o?{start:e.length,end:e.length}:r?t.isArgumentCompletion?{start:`/${t.commandPathParts.join(" ")}`.length+(t.commandPathParts.length>0?1:0),end:e.length}:{start:e.length-r.length,end:e.length}:{start:1,end:e.length}},[e,t])}function BP(e){return(0,nr.useMemo)(()=>{let{hasTrailingSpace:t,partial:o,leafCommand:r,currentLevel:n}=e;return t?{isPerfectMatch:!1}:r&&o===""&&r.action?{isPerfectMatch:!0}:n&&n.find(i=>Pm(i,o)&&i.action)?{isPerfectMatch:!0}:{isPerfectMatch:!1}},[e])}function kP(e,t){let{currentLevel:o}=t;return o?o.find(n=>Pm(n,e.value)):void 0}function PI(e){let{enabled:t,query:o,slashCommands:r,commandContext:n,setSuggestions:s,setIsLoadingSuggestions:i,setIsPerfectMatch:a}=e,[d,m]=(0,nr.useState)(-1),[f,h]=(0,nr.useState)(-1),p=(0,nr.useMemo)(()=>new WeakMap,[]),y=(0,nr.useMemo)(()=>v=>{if(!v||v.length===0)return null;let R=p.get(v);if(R)return R;let b=[],_=new Map;if(v.forEach(w=>{w.description&&!w.hidden&&(b.push(w.name),_.set(w.name,w),w.altNames&&w.altNames.forEach(M=>{b.push(M),_.set(M,w)}))}),b.length===0)return null;try{let w={fzf:new ta(b,{fuzzy:"v2",casing:"case-insensitive"}),commandMap:_};return p.set(v,w),w}catch(w){return Mm(w,"FZF instance creation"),null}},[p]),g=(0,nr.useMemo)(()=>(v,R)=>v.filter(b=>b.description&&!b.hidden&&(b.name.toLowerCase().startsWith(R.toLowerCase())||b.altNames?.some(_=>_.toLowerCase().startsWith(R.toLowerCase())))),[]),x=OP(o,r),{suggestions:S,isLoading:I}=LP(o,x,n,y,g),{start:A,end:E}=NP(o,x),{isPerfectMatch:T}=BP(x);return(0,nr.useEffect)(()=>{t||(s([]),i(!1),a(!1),m(-1),h(-1))},[t,s,i,a]),(0,nr.useEffect)(()=>{!t||o===null||(s(S),i(I),a(T),m(A),h(E))},[t,o,S,I,T,A,E,s,i,a]),{completionStart:d,completionEnd:f,getCommandFromSuggestion:v=>kP(v,x),isArgumentCompletion:x.isArgumentCompletion,leafCommand:x.leafCommand}}var ir=C(z(),1);import*as Os from"node:fs/promises";import*as Vo from"node:path";import*as yg from"node:os";import{execFile as HP}from"node:child_process";import{promisify as FP}from"node:util";var UP=FP(HP),GP=["add","branch","checkout","commit","diff","merge","pull","push","rebase","status","switch"],OI={command:"git",async getCompletions(e,t,o,r){if(t===1){let n=e[1]||"";return{suggestions:GP.filter(s=>s.startsWith(n)).map(s=>({label:s,value:s,description:"git command"})),exclusive:!0}}if(t===2){let n=e[1];if(n==="checkout"||n==="switch"||n==="merge"||n==="branch"){let s=e[2]||"";try{let{stdout:i}=await UP("git",["branch","--format=%(refname:short)"],{cwd:o,signal:r});return{suggestions:i.split(`
67
67
  `).map(d=>d.trim()).filter(Boolean).filter(d=>d.startsWith(s)).map(d=>({label:d,value:Hl(d),description:"branch"})),exclusive:!0}}catch{return{suggestions:[],exclusive:!0}}}}return{suggestions:[],exclusive:!1}}};import*as LI from"node:fs/promises";import*as NI from"node:path";var WP=["build","ci","dev","install","publish","run","start","test"],BI={command:"npm",async getCompletions(e,t,o,r){if(t===1){let n=e[1]||"";return{suggestions:WP.filter(s=>s.startsWith(n)).map(s=>({label:s,value:s,description:"npm command"})),exclusive:!0}}if(t===2&&e[1]==="run"){let n=e[2]||"";try{if(r?.aborted)return{suggestions:[],exclusive:!0};let s=NI.join(o,"package.json"),i=await LI.readFile(s,"utf8"),a=JSON.parse(i);return{suggestions:(a&&typeof a=="object"&&"scripts"in a&&a.scripts&&typeof a.scripts=="object"?Object.keys(a.scripts):[]).filter(m=>m.startsWith(n)).map(m=>({label:m,value:Hl(m),description:"npm script"})),exclusive:!0}}catch{return{suggestions:[],exclusive:!0}}}return{suggestions:[],exclusive:!1}}};var VP=[OI,BI];async function kI(e,t,o,r,n){let s=VP.find(i=>i.command===e);return s?s.getCompletions(t,o,r,n):null}var hg=100,$P=50,qP=/[ \t\n\r'"()&|;<>!#$`{}[\]*?\\]/g;function Hl(e){return process.platform==="win32"?e:e.replace(qP,"\\$&")}function KP(e,t){let o=[],r=0;for(;r<e.length;){if(e[r]===" "||e[r]===" "){r++;continue}let d=r,m="";for(;r<e.length;){let f=e[r];if(f==="\\"&&r+1<e.length){m+=e[r+1],r+=2;continue}if(f==="'"){for(r++;r<e.length&&e[r]!=="'";)m+=e[r],r++;r<e.length&&r++;continue}if(f==='"'){for(r++;r<e.length&&e[r]!=='"';)e[r]==="\\"&&r+1<e.length?(m+=e[r+1],r+=2):(m+=e[r],r++);r<e.length&&r++;continue}if(f===" "||f===" ")break;m+=f,r++}o.push({token:m,start:d,end:r})}let n=o.map(d=>d.token),s=n.length>0?n[0]:"";if(o.length===0)return{token:"",start:t,end:t,isFirstToken:!0,tokens:[""],cursorIndex:0,commandToken:""};for(let d=0;d<o.length;d++){let m=o[d];if(t>=m.start&&t<=m.end)return{token:m.token,start:m.start,end:m.end,isFirstToken:d===0,tokens:n,cursorIndex:d,commandToken:s}}let i=o.length;for(let d=0;d<o.length;d++)if(t<o[d].start){i=d;break}let a=[...n.slice(0,i),"",...n.slice(i)];return{token:"",start:t,end:t,isFirstToken:i===0,tokens:a,cursorIndex:i,commandToken:a.length>0?a[0]:""}}async function jP(e){let o=(process.env.PATH??"").split(Vo.delimiter).filter(Boolean),r=process.platform==="win32",n=r?(process.env.PATHEXT??".EXE;.CMD;.BAT;.COM").split(";").filter(Boolean).map(d=>d.toLowerCase()):[],s=new Set,i=[];if(r){let d=["assoc","break","call","cd","chcp","chdir","cls","color","copy","date","del","dir","echo","endlocal","erase","exit","for","ftype","goto","if","md","mkdir","mklink","move","path","pause","popd","prompt","pushd","rd","rem","ren","rename","rmdir","set","setlocal","shift","start","time","title","type","ver","verify","vol"];for(let m of d)s.add(m),i.push(m)}let a=await Promise.all(o.map(async d=>{if(e?.aborted)return[];try{let m=await Os.readdir(d,{withFileTypes:!0}),f=[];return await Promise.all(m.map(async h=>{if(e?.aborted||!h.isFile()&&!h.isSymbolicLink())return;let p=h.name;if(r){let y=Vo.extname(p).toLowerCase();if(n.length>0&&!n.includes(y))return}try{await Os.access(Vo.join(d,p),Os.constants.R_OK|Os.constants.X_OK),f.push(p)}catch{}})),f}catch{return[]}}));for(let d of a)for(let m of d)s.has(m)||(s.add(m),i.push(m));return i.sort(),i}function zP(e){return e==="~"||e.startsWith("~/")||e.startsWith("~"+Vo.sep)?[Vo.join(yg.homedir(),e.slice(1)),!0]:[e,!1]}async function YP(e,t,o){if(e==null)return[];let r=e;(r.startsWith('"')||r.startsWith("'"))&&(r=r.slice(1)),(r.endsWith('"')||r.endsWith("'"))&&(r=r.slice(0,-1));let n=r.replace(/\\/g,"/"),[s,i]=zP(n),a=n.endsWith("/")||n==="",d=a?Vo.resolve(t,s):Vo.resolve(t,Vo.dirname(s)),m=a?"":Vo.basename(s),f=m.toLowerCase(),h=m.startsWith("."),p;try{if(o?.aborted)return[];p=await Os.readdir(d,{withFileTypes:!0})}catch{return[]}if(o?.aborted)return[];let y=[];for(let g of p){if(o?.aborted)break;let x=g.name;if(x.startsWith(".")&&!h||!x.toLowerCase().startsWith(f))continue;let S=g.isDirectory(),I=S?x+"/":x,A;if(a?A=n+I:A=n.slice(0,n.length-Vo.basename(n).length)+I,i){let T=yg.homedir().replace(/\\/g,"/");A.startsWith(T)&&(A="~"+A.slice(T.length))}let E=Hl(A);if(y.push({label:I,value:E,description:S?"directory":"file"}),y.length>=hg)break}return y.sort((g,x)=>{let S=g.description==="directory",I=x.description==="directory";return S!==I?S?-1:1:g.label.localeCompare(x.label)}),y}var XP=[];function HI({enabled:e,line:t,cursorCol:o,cwd:r,setSuggestions:n,setIsLoadingSuggestions:s}){let i=(0,ir.useRef)(null),a=(0,ir.useRef)(process.env.PATH??""),d=(0,ir.useRef)(null),m=(0,ir.useRef)(null),[f,h]=(0,ir.useState)(-1),p=(0,ir.useMemo)(()=>e?KP(t,o):null,[e,t,o]),{token:y="",start:g=-1,end:x=-1,isFirstToken:S=!1,tokens:I=XP,cursorIndex:A=-1,commandToken:E=""}=p||{};e&&f!==-1&&g!==f&&(n([]),h(-1)),(0,ir.useEffect)(()=>{let v=process.env.PATH??"";v!==a.current&&(i.current=null,a.current=v)});let T=(0,ir.useCallback)(async()=>{if(!e||!p){n([]);return}if(y.startsWith("-")){n([]);return}d.current&&d.current.abort();let v=new AbortController;d.current=v;let{signal:R}=v;try{let b;if(S){s(!0),i.current||(i.current=jP());let _=await i.current;if(R.aborted)return;let w=y.toLowerCase();b=_.filter(M=>M.toLowerCase().startsWith(w)).sort((M,D)=>M.length!==D.length?M.length-D.length:M.localeCompare(D)).slice(0,hg).map(M=>({label:M,value:Hl(M),description:"command"}))}else{let _=await kI(E,I,A,r,R);if(R.aborted)return;if(_?.exclusive)b=_.suggestions;else{let w=await YP(y,r,R);if(R.aborted)return;b=[..._?.suggestions??[],...w].slice(0,hg)}}if(R.aborted)return;n(b),h(g)}catch(b){R.aborted||b instanceof Error&&b.name==="AbortError"||de.warn(`[WARN] shell completion failed: ${b instanceof Error?b.message:String(b)}`),R.aborted||(n([]),h(g))}finally{R.aborted||s(!1)}},[e,p,y,S,I,A,E,r,g,n,s]);return(0,ir.useEffect)(()=>{e||(d.current?.abort(),n([]),h(-1),s(!1))},[e,n,s]),(0,ir.useEffect)(()=>{if(e)return m.current&&clearTimeout(m.current),m.current=setTimeout(()=>{T()},$P),()=>{m.current&&clearTimeout(m.current)}},[e,T]),(0,ir.useEffect)(()=>()=>{d.current?.abort(),m.current&&clearTimeout(m.current)},[]),{completionStart:g,completionEnd:x,query:y,activeStart:f}}var so=C(z(),1);var Om=5,QP=250;function FI({buffer:e,config:t}){let[o,r]=(0,so.useState)(""),[n,s]=(0,so.useState)(!1),i=(0,so.useRef)(null),[a,d]=(0,so.useState)(!1),m=(0,so.useRef)(""),f=(0,so.useRef)(""),h=!1,p=(0,so.useCallback)(()=>{r(""),s(!1)},[]),y=(0,so.useCallback)(()=>{o&&o.length>e.text.length&&(e.setText(o),r(""),d(!0),m.current=o)},[o,e]),g=(0,so.useCallback)(E=>{d(!0),m.current=E},[]),x=(0,so.useCallback)(async()=>{let E=e.text.trim(),T=t?.getGeminiClient();if(E===f.current)return;if(i.current&&i.current.abort(),E.length<Om||!T||gr(E)||E.includes("@")||!h){p(),f.current="";return}f.current=E,s(!0),i.current=new AbortController;let v=i.current.signal;try{let R=[{role:"user",parts:[{text:`You are a professional prompt engineering assistant. Complete the user's partial prompt with expert precision and clarity. User's input: "${E}" Continue this prompt by adding specific, actionable details that align with the user's intent. Focus on: clear, precise language; structured requirements; professional terminology; measurable outcomes. Length Guidelines: Keep suggestions concise (ideally 10-20 characters); prioritize brevity while maintaining clarity; use essential keywords only; avoid redundant phrases. Start your response with the exact user text ("${E}") followed by your completion. Provide practical, implementation-focused suggestions rather than creative interpretations. Format: Plain text only. Single completion. Match the user's language. Emphasize conciseness over elaboration.`}]}],b=await T.generateContent({model:"prompt-completion"},R,v,_i.UTILITY_AUTOCOMPLETE);if(v.aborted)return;if(b){let _=lx(b);if(_){let w=_.trim();w.length>0&&w.startsWith(E)?r(w):p()}}}catch(R){v.aborted||R instanceof Error&&R.name==="AbortError"||de.warn(`[WARN] prompt completion failed: : (${R instanceof Error?R.message:String(R)})`),p()}finally{v.aborted||s(!1)}},[e.text,t,p,h]),S=(0,so.useCallback)(()=>{let[E,T]=e.cursor,v=e.lines.length;if(E!==v-1)return!1;let R=e.lines[E]||"";return T===R.length},[e.cursor,e.lines]),I=(0,so.useCallback)(()=>{if(!S()){p();return}let E=e.text.trim();a&&E===m.current||(E!==m.current&&(d(!1),m.current=""),x())},[e.text,x,a,S,p]);(0,so.useEffect)(()=>{let E=setTimeout(I,QP);return()=>clearTimeout(E)},[e.text,e.cursor,I]),(0,so.useEffect)(()=>{let E=e.text.trim();if(o&&!S()){p();return}o&&E.length>0&&!o.startsWith(E)&&p()},[e.text,e.cursor,o,p,S]),(0,so.useEffect)(()=>()=>i.current?.abort(),[]);let A=(0,so.useMemo)(()=>{if(!h||!S())return!1;let E=e.text.trim();return E.length>=Om&&!gr(E)&&!E.includes("@")},[e.text,h,S]);return{text:o,isLoading:n,isActive:A,accept:y,clear:p,markSelected:g}}function UI({buffer:e,cwd:t,slashCommands:o,commandContext:r,reverseSearchActive:n=!1,shellModeActive:s,config:i,active:a}){let[d,m]=(0,xn.useState)(!1),{suggestions:f,activeSuggestionIndex:h,visibleStartIndex:p,isLoadingSuggestions:y,isPerfectMatch:g,setSuggestions:x,setActiveSuggestionIndex:S,setIsLoadingSuggestions:I,setIsPerfectMatch:A,setVisibleStartIndex:E,resetCompletionState:T,navigateUp:v,navigateDown:R}=Dm(),b=(0,xn.useCallback)(()=>{T(),m(!1)},[T]),_=e.cursor[0],w=e.cursor[1],{completionMode:M,query:D,completionStart:N,completionEnd:O}=(0,xn.useMemo)(()=>{let oe=e.lines[_]||"",ce=sa(oe);if(s)return{completionMode:oe.trim().length===0?"IDLE":"SHELL",query:"",completionStart:-1,completionEnd:-1};for(let te=w-1;te>=0;te--){let ae=ce[te];if(ae===" "){let ne=0;for(let j=te-1;j>=0&&ce[j]==="\\";j--)ne++;if(ne%2===0)break}else if(ae==="@"){let ne=ce.length;for(let X=w;X<ce.length;X++)if(ce[X]===" "){let Q=0;for(let be=X-1;be>=0&&ce[be]==="\\";be--)Q++;if(Q%2===0){ne=X;break}}let j=te+1;return{completionMode:"AT",query:oe.substring(j,ne),completionStart:j,completionEnd:ne}}}if(_===0&&gr(oe.trim()))return{completionMode:"SLASH",query:oe,completionStart:0,completionEnd:oe.length};let G=e.text.trim();return!1&&G.length>=Om&&!gr(G)&&!G.includes("@")?{completionMode:"PROMPT",query:G,completionStart:0,completionEnd:G.length}:{completionMode:"IDLE",query:null,completionStart:-1,completionEnd:-1}},[_,w,e.lines,e.text,s]);MI({enabled:a&&M==="AT",pattern:D||"",config:i,cwd:t,setSuggestions:x,setIsLoadingSuggestions:I});let W=PI({enabled:a&&M==="SLASH"&&!s,query:D,slashCommands:o,commandContext:r,setSuggestions:x,setIsLoadingSuggestions:I,setIsPerfectMatch:A}),L=HI({enabled:a&&M==="SHELL",line:e.lines[_]||"",cursorCol:w,cwd:t,setSuggestions:x,setIsLoadingSuggestions:I}),k=M==="SHELL"?L.query:D,F=FI({buffer:e}),B=M!=="SHELL"||d,K=(0,xn.useMemo)(()=>{if(M==="SHELL"&&f.length===1&&k!=null&&L.completionStart===L.activeStart){let ce=f[0].value;if(ce.startsWith(k)&&ce.length>k.length){let G=e.lines[_]||"",ee=L.completionStart,te=L.completionEnd,ae=ce;return G[te]!==" "&&!ae.endsWith("/")&&!ae.endsWith("\\")&&(ae+=" "),{text:G.substring(0,ee)+ae+G.substring(te),isActive:!0,isLoading:!1,accept:()=>{e.replaceRangeByOffset(la(e.lines,_,ee),la(e.lines,_,te),ae)},clear:()=>{},markSelected:()=>{}}}}return F},[M,f,k,F,e,_,L]);(0,xn.useEffect)(()=>{if(S(f.length>0?0:-1),E(0),M!=="SLASH")if(f.length>0){let oe=f[0];A(oe.value===k)}else A(!1)},[f,S,E,M,k,A]),(0,xn.useEffect)(()=>{(!a||M==="IDLE"||n)&&b()},[a,M,n,b]);let q=a&&M!=="IDLE"&&!n&&B&&(y||f.length>0),Z=(0,xn.useCallback)(oe=>{let ce=e.lines[_]||"",G=N,ee=O;if(M==="SLASH"?(G=W.completionStart,ee=W.completionEnd):M==="SHELL"&&(G=L.completionStart,ee=L.completionEnd),G===-1||ee===-1)return null;let te=oe.insertValue??oe.value;return M==="SLASH"&&G===ee&&G>1&&ce[G-1]!==" "&&(te=" "+te),ce.substring(0,G)+te+ce.substring(ee)},[_,e.lines,M,N,O,W,L]),Y=(0,xn.useCallback)(oe=>{if(oe<0||oe>=f.length)return;let ce=f[oe];if(Z(ce)===null)return;let ee=N,te=O;M==="SLASH"?(ee=W.completionStart,te=W.completionEnd):M==="SHELL"&&(ee=L.completionStart,te=L.completionEnd);let ae=ce.insertValue??ce.value;M==="SLASH"&&ee===te&&ee>1&&(e.lines[_]||"")[ee-1]!==" "&&(ae=" "+ae);let j=sa(e.lines[_]||"")[te],$=!0;if(M==="SLASH"){let X=W.getCommandFromSuggestion(ce),Q=!!(X&&X.action),be=!!(X&&X.completion);$=!Q||be}j!==" "&&!ae.endsWith("/")&&!ae.endsWith("\\")&&$&&(ae+=" "),e.replaceRangeByOffset(la(e.lines,_,ee),la(e.lines,_,te),ae)},[_,e,f,M,N,O,W,L,Z]);return{suggestions:f,activeSuggestionIndex:h,visibleStartIndex:p,showSuggestions:q,isLoadingSuggestions:y,isPerfectMatch:g,forceShowShellSuggestions:d,setForceShowShellSuggestions:m,isShellSuggestionsVisible:B,setActiveSuggestionIndex:S,resetCompletionState:b,navigateUp:v,navigateDown:R,handleAutocomplete:Y,promptCompletion:K,getCommandFromSuggestion:W.getCommandFromSuggestion,slashCompletionRange:W,getCompletedText:Z,completionMode:M}}var $t=C(z(),1);var JP=600,GI=300;function WI({buffer:e,config:t,settings:o,setQueueErrorMessage:r,isVoiceModeEnabled:n,setVoiceModeEnabled:s,keyMatchers:i}){let[a,d]=(0,$t.useState)(!1),[m,f]=(0,$t.useState)(!1),h=(0,$t.useRef)(""),p=(0,$t.useRef)(!1),y=(0,$t.useRef)(!1),g=(0,$t.useRef)(0),x=(0,$t.useRef)(!1),S=(0,$t.useRef)(null),I=(0,$t.useRef)(null),A=(0,$t.useRef)(null),E=(0,$t.useRef)(null),T=(0,$t.useRef)(0),v=(0,$t.useRef)("idle"),R=(0,$t.useRef)(null),b=(0,$t.useRef)(null),_=(0,$t.useRef)(e);_.current=e;let w=(0,$t.useCallback)(()=>{if(p.current)return;de.debug("[Voice] Stop requested"),p.current=!0,d(!1),y.current=!1,f(!1),I.current&&(I.current.stop(),I.current=null);let N=A.current;if(N){let O=o.experimental.voice.stopGracePeriodMs;de.debug(`[Voice] Draining transcription for ${O}ms`),b.current&&clearTimeout(b.current),b.current=setTimeout(()=>{de.debug("[Voice] Grace period ended, disconnecting service"),N.disconnect(),A.current===N&&(A.current=null),b.current=null,h.current=""},O)}else h.current="";v.current="idle"},[o.experimental.voice]),M=(0,$t.useCallback)(()=>{if(y.current||Date.now()-g.current<2e3)return;b.current&&(clearTimeout(b.current),b.current=null),x.current=!0,E.current=_.current.text,T.current=_.current.getOffset(),f(!0),d(!0),y.current=!0,h.current="",p.current=!1;let N=t.getContentGeneratorConfig()?.apiKey||process.env.GEMINI_API_KEY||"";(async()=>{b.current&&(clearTimeout(b.current),b.current=null),A.current&&(A.current.disconnect(),A.current=null);let W=()=>p.current?(I.current&&(I.current.stop(),I.current=null),A.current&&(A.current.disconnect(),A.current=null),d(!1),y.current=!1,f(!1),x.current=!1,!0):!1;if(W())return;let L=o.experimental.voice?.backend??"gemini-live";if(!N&&L==="gemini-live"){r("Cloud voice mode requires a GEMINI_API_KEY. Please set it in your environment or ~/.gemini/.env."),d(!1),y.current=!1,f(!1),x.current=!1,g.current=Date.now();return}L==="gemini-live"&&(I.current=new Yx);let k=Xx.createProvider(o.experimental.voice,N);A.current=k,k.on("transcription",F=>{if(!(A.current!==k&&p.current)){if(F){let B=E.current??"",K=T.current,q=B.slice(0,K),Z=B.slice(K),Y=q.length>0&&!/\s$/.test(q)?q+" ":q,oe=F.length>0&&Z.length>0&&!/^\s/.test(Z)?" ":"",ce=Y+F+oe+Z;_.current.setText(ce,Y.length+F.length)}h.current=F}}),k.on("turnComplete",()=>{A.current!==k&&p.current||(E.current=_.current.text,T.current=_.current.getOffset(),h.current="")}),k.on("error",F=>{A.current===k&&(de.error("[Voice] Transcription error:",F),g.current=Date.now(),x.current=!1)}),k.on("close",()=>{A.current===k&&(p.current||(d(!1),y.current=!1,f(!1),x.current=!1,g.current=Date.now()))});try{if(await k.connect(),W()||(await I.current?.start(),W()))return;f(!1);let F=o.experimental.voice?.backend??"gemini-live";I.current?.on("data",B=>{F==="gemini-live"&&k.sendAudioChunk(B)}),I.current?.on("error",B=>{de.error("[Voice] Recorder error:",B),w(),g.current=Date.now()})}catch(F){if(A.current!==k)return;let B=F instanceof Error?F.message:String(F);r(`Voice mode failure: ${B}`),d(!1),y.current=!1,f(!1),x.current=!1,g.current=Date.now(),I.current&&(I.current.stop(),I.current=null),A.current&&(A.current.disconnect(),A.current=null)}})()},[t,o.experimental.voice,r,w]);(0,$t.useEffect)(()=>()=>{S.current&&clearTimeout(S.current),I.current&&(I.current.stop(),I.current=null),A.current&&(A.current.disconnect(),A.current=null),R.current&&clearTimeout(R.current),b.current&&clearTimeout(b.current)},[]);let D=(0,$t.useCallback)(N=>{if(a||y.current){let W=o.experimental.voice?.activationMode??"push-to-talk";return i["basic.cancel"](N)?(w(),!0):i["app.voiceModePTT"](N)?W==="push-to-talk"?(R.current&&clearTimeout(R.current),R.current=setTimeout(()=>{w(),R.current=null},GI),!0):(w(),!0):!0}if(n){let W=o.experimental.voice?.activationMode??"push-to-talk";if(i["basic.cancel"](N)&&e.text==="")return s(!1),!0;if(i["app.voiceModePTT"](N)&&N.name==="space"&&!N.ctrl&&!N.alt&&!N.shift&&!N.cmd){if(W==="toggle")return M(),!0;if(v.current==="idle")return e.insert(" "),v.current="possible-hold",R.current&&clearTimeout(R.current),R.current=setTimeout(()=>{v.current="idle",R.current=null},JP),!0;if(v.current==="possible-hold")return R.current&&clearTimeout(R.current),e.backspace(),v.current="recording",M(),R.current=setTimeout(()=>{w(),R.current=null},GI),!0}v.current==="possible-hold"&&(v.current="idle",R.current&&(clearTimeout(R.current),R.current=null))}return!1},[a,n,o.experimental.voice,i,w,M,e,s]);return{isRecording:a,isConnecting:m,startVoiceRecording:M,stopVoiceRecording:w,handleVoiceInput:D,resetTurnBaseline:()=>{E.current=null}}}var Tg=new RegExp(`(^/[a-zA-Z0-9_-]+|(?<!\\\\)@${FS}|${yC.source})`,"g"),VI=new MT.default(cS);function $I(e,t,o=[],r){let n=!1;if(r!==void 0){for(let p of o)if(r>=p.logStart&&r<=p.logEnd){n=!0;break}}let s=`${t===0?"F":"N"}:${n?r:"NC"}:${e}`,i=VI.get(s);if(i!==void 0)return i;if(Tg.lastIndex=0,!e)return[{text:"",type:"default"}];let a=p=>{let y=[];if(!p)return y;Tg.lastIndex=0;let g=0,x;for(;(x=Tg.exec(p))!==null;){let[S]=x,I=x.index;I>g&&y.push({text:p.slice(g,I),type:"default"});let A=S.startsWith("/")?"command":S.startsWith("@")?"file":"paste";A==="command"&&t!==0?y.push({text:S,type:"default"}):y.push({text:S,type:A}),g=I+S.length}return g<p.length&&y.push({text:p.slice(g),type:"default"}),y},d=[],m=0,f=(o??[]).slice().sort((p,y)=>p.logStart-y.logStart);for(let p of f){let y=Ut(e,m,p.logStart);d.push(...a(y));let x=r!==void 0&&r>=p.logStart&&r<=p.logEnd?p.logicalText:p.collapsedText;d.push({text:x,type:"file"}),m=p.logEnd}let h=Ut(e,m);return d.push(...a(h)),VI.set(s,d),d}function qI(e,t,o){if(t>=o)return[];let r=[],n=0;for(let s of e){let i=to(s.text),a=n,d=a+i,m=Math.max(a,t),f=Math.min(d,o);if(m<f){let h=m-a,p=f-a,y=Ut(s.text,h,p),g=r[r.length-1];g&&g.type===s.type?g.text+=y:r.push({type:s.type,text:y})}n+=i}return r}var KI=C(z(),1);function Lm(){let[e]=(0,KI.useState)({enabled:cl.isKittyProtocolEnabled(),checking:!1});return e}import*as YI from"node:path";var Nm=C(z(),1);var xg=(0,Nm.createContext)(!0),jI=()=>(0,Nm.useContext)(xg);function Bm(){let e=Ze();return t=>Object.values(vt).some(o=>e[o](t))}var Sn=C(z(),1);function Fl(e){let[t,o]=(0,Sn.useState)(0),r=(0,Sn.useRef)(0),n=(0,Sn.useRef)(null),s=(0,Sn.useRef)(e);(0,Sn.useEffect)(()=>{s.current=e},[e]);let i=(0,Sn.useCallback)(()=>{n.current&&(clearTimeout(n.current),n.current=null),r.current>0&&(r.current=0,o(0),s.current.onReset?.())},[]),a=(0,Sn.useCallback)(()=>{let d=r.current+1;return r.current=d,o(d),n.current&&clearTimeout(n.current),n.current=setTimeout(()=>{r.current=0,o(0),n.current=null,s.current.onReset?.()},s.current.windowMs),s.current.onRepeat?.(d),d},[]);return(0,Sn.useEffect)(()=>()=>{n.current&&clearTimeout(n.current)},[]),{pressCount:t,handlePress:a,resetCount:i}}var yt=C(P(),1);var ZP=1;var XI=e=>{let n=Math.max(20,e);return{inputWidth:Math.max(e-6,1),containerWidth:e,suggestionsWidth:n,frameOverhead:6}};function zI(e){return e.split(`
68
68
  `).length>gC||e.length>hC}var eO=350;function tO(e){if(!e.pastedContent||Object.keys(e.pastedContent).length===0)return!1;let[t,o]=e.cursor,r=Af(t,o,e.transformationsByLine,{includeEdge:!0});if(r?.type==="paste"&&r.id)return e.togglePasteExpansion(r.id,t,o),!0;let n=e.getExpandedPasteAtLine(t);return n?(e.togglePasteExpansion(n,t,o),!0):(kt.emit("transient-message",{message:"Move cursor within placeholder to expand",type:"hint"}),!0)}var QI=({onSubmit:e,onClearScreen:t,config:o,slashCommands:r,commandContext:n,placeholder:s=" Type your message or @path/to/file",focus:i=!0,setShellModeActive:a,approvalMode:d,onEscapePromptChange:m,onSuggestionsVisibilityChange:f,vimHandleInput:h,isEmbeddedShellFocused:p,setQueueErrorMessage:y,streamingState:g,popAllMessages:x,onQueueMessage:S,suggestionsPosition:I="below",setBannerVisible:A})=>{let E=un(),{buffer:T,userMessages:v,shellModeActive:R,copyModeEnabled:b,inputWidth:_,suggestionsWidth:w}=E,M=Bm(),D=Ze(),{stdout:N}=ml(),{merged:O}=Ke(),W=Lm(),L=jI(),{setEmbeddedShellFocused:k,setShortcutsHelpVisible:F,toggleCleanUiDetailsVisible:B,setVoiceModeEnabled:K}=Pr(),{terminalWidth:q,activePtyId:Z,history:Y,backgroundTasks:oe,backgroundTaskHeight:ce,shortcutsHelpVisible:G,isVoiceModeEnabled:ee}=Ce(),[te,ae]=(0,tt.useState)(!1),{handlePress:ne,resetCount:j}=Fl({windowMs:eO}),[$,X]=(0,tt.useState)(!1),{handlePress:Q,resetCount:be}=Fl({windowMs:500,onRepeat:H=>{H===1?X(!0):H===2&&(be(),T.text.length>0?(T.setText(""),cr(),Ur()):Y.length>0?e("/rewind"):Se.emitFeedback("info","Nothing to rewind to"))},onReset:()=>X(!1)}),[De,ke]=(0,tt.useState)(null),ue=(0,tt.useRef)(null),Ue=(0,tt.useRef)(null),Tt=(0,tt.useRef)(!1),It=(0,tt.useRef)(null),{isRecording:An,handleVoiceInput:Jr,resetTurnBaseline:cr}=WI({buffer:T,config:o,settings:O,setQueueErrorMessage:y,isVoiceModeEnabled:ee,setVoiceModeEnabled:K,keyMatchers:D}),[ko,Zr]=(0,tt.useState)(!1),[Lt,ur]=(0,tt.useState)(!1),[Fn,Si]=(0,tt.useState)(""),[Ci,$a]=(0,tt.useState)([0,0]),[Ws,ao]=(0,tt.useState)(-1),go=wI(o.getProjectRoot(),o.storage),ho=go.history,ve=UI({buffer:T,cwd:o.getTargetDir(),slashCommands:r,commandContext:n,reverseSearchActive:ko,shellModeActive:R,config:o,active:!te}),yo=gg(T,ho,ko),Vs=(0,tt.useMemo)(()=>[...v].reverse(),[v]),To=gg(T,Vs,Lt),Ur=ve.resetCompletionState,Un=yo.resetCompletionState,$s=To.resetCompletionState,dr=(0,tt.useCallback)(()=>Lt?To:ko?yo:ve,[Lt,To,ko,yo,ve])(),xo=dr.showSuggestions,{forceShowShellSuggestions:Yi,setForceShowShellSuggestions:Xi,isShellSuggestionsVisible:jo}=ve,en=(0,tt.useMemo)(()=>ee?` Type your message or ${(O.experimental.voice?.activationMode??"push-to-talk")==="push-to-talk"?"hold space to talk":"space to talk"} (Esc to exit)`:s,[ee,s,O.experimental.voice?.activationMode]),wr=i&&L&&!p&&!b;(0,tt.useEffect)(()=>{kt.emit("scroll-to-bottom")},[T.text,T.cursor]),(0,tt.useEffect)(()=>{m&&m($)},[$,m]),(0,tt.useEffect)(()=>()=>{ue.current&&clearTimeout(ue.current)},[]);let bi=(0,tt.useCallback)(H=>{let Ie=H;T.pastedContent&&(Ie=pl(Ie,T.pastedContent)),R&&go.addCommandToHistory(Ie),T.setText(""),cr(),e(Ie),Ur(),Un()},[T,e,Ur,R,go,Un,cr]),Qi=(0,tt.useCallback)((H,Ie)=>{T.setText(H,Ie),ae(!0)},[T,ae]),mr=II({userMessages:v,onSubmit:bi,isActive:(!(ve.showSuggestions&&jo)||ve.suggestions.length===1)&&!R,currentQuery:T.text,currentCursorOffset:T.getOffset(),onChange:Qi}),zo=(0,tt.useCallback)(H=>{let Ie=H.trim(),ot=gr(Ie),xt=R;if((ot||xt)&&g==="responding"){if(ot){let{commandToExecute:it}=al(Ie,r);if(it?.isSafeConcurrent){bi(Ie);return}}y(`${xt?"Shell":"Slash"} commands cannot be queued`);return}mr.handleSubmit(Ie)},[mr,R,g,y,r,bi]);(0,tt.useEffect)(()=>{te&&(Ur(),Un(),$s(),ao(-1))},[te,T.text,Ur,ae,Un,$s,ao]);let Ji=(0,tt.useCallback)(()=>{if(T.text.trim()===""&&x){let H=x();return H?(T.setText(H),!0):(mr.navigateUp(),!0)}return!1},[T,x,mr]),Zi=(0,tt.useCallback)(async()=>{G&&F(!1);try{if(await dC()){let H=await mC(o.getTargetDir());if(H){pC(o.getTargetDir()).catch(()=>{});let ot=`@${YI.relative(o.getTargetDir(),H)}`,xt=T.text,it=T.getOffset(),st=ot,dt=it>0?xt[it-1]:"",Ao=it<xt.length?xt[it]:"";dt&&dt!==" "&&dt!==`
@@ -91,7 +91,7 @@ ${te}`:ne(te,Q),ee=`${Q}
91
91
 
92
92
  ${ee}`}}let $={...B,status:ae,resultDisplay:te};ae!==ie.Cancelled&&e({type:"tool_group",tools:[$]},_),lO(s,R,ee)}catch(Z){t(null);let Y=Z instanceof Error?Z.message:String(Z);e({type:"error",text:`An unexpected error occurred: ${Y}`},_)}finally{if(b.removeEventListener("abort",q),O){let Z=wg.dirname(O);try{_a.existsSync(O)&&_a.unlinkSync(O),_a.existsSync(Z)&&_a.rmSync(Z,{recursive:!0,force:!0})}catch{}}p({type:"SET_ACTIVE_PTY",pid:null}),i(!1)}})()),!0},[n,r,e,t,o,s,i,d,a,E,g,p]),v=Array.from(h.backgroundTasks.values()).filter(R=>R.status==="running").length;return{handleShellCommand:T,activeShellPtyId:h.activeShellPtyId,lastShellOutputTime:h.lastShellOutputTime,backgroundTaskCount:v,isBackgroundTaskVisible:h.isBackgroundTaskVisible,toggleBackgroundTasks:S,backgroundCurrentExecution:I,registerBackgroundTask:E,dismissBackgroundTask:A,backgroundTasks:h.backgroundTasks}};var Ot=C(P(),1);var _g=1,Iv=2,cO=2,uO=1,dO=1,vv=cO+uO+dO,mO=3,pO=4,fO=7,Dg=(e,t)=>{let o=e.split(`
93
93
  `)[0];return to(o)>t?`${Ut(o,0,t-3)}...`:o},Av=({shells:e,activePid:t,width:o,height:r,isFocused:n,isListOpenProp:s})=>{let i=Ze(),{dismissBackgroundTask:a,setActiveBackgroundTaskPid:d,setIsBackgroundTaskListOpen:m}=Pr(),f=e.get(t),[h,p]=(0,hi.useState)(f?.output||""),[y,g]=(0,hi.useState)(t),x=(0,hi.useRef)(null),S=(0,hi.useRef)(!1);(0,hi.useEffect)(()=>{if(!t)return;let _=Math.max(1,o-Iv-_g*2),w=Math.max(1,r-vv);lo.resizePty(t,_,w)},[t,o,r]),(0,hi.useEffect)(()=>{if(!t){p("");return}let _=e.get(t);_&&p(_.output),S.current=!1;let w=lo.subscribe(t,M=>{M.type==="data"&&(typeof M.chunk=="string"&&S.current?p(D=>typeof D=="string"?D+M.chunk:M.chunk):p(M.chunk))});return S.current=!0,()=>{w(),S.current=!1}},[t,e]),(0,hi.useEffect)(()=>{s&&g(t)},[s,t]),me(_=>{if(f)return s?i["background.escape"](_)?(m(!1),!0):i["background.kill"](_)?(y&&a(y),!0):i["background.toggleList"](_)?(y&&d(y),m(!1),!0):!1:i["background.toggle"](_)?!1:i["background.kill"](_)?(a(f.pid),!0):i["background.toggleList"](_)?(m(!0),!0):i["background.select"](_)?(lo.writeToPty(f.pid,"\r"),!0):i["edit.deleteLeft"](_)?(lo.writeToPty(f.pid,"\b"),!0):_.sequence?(lo.writeToPty(f.pid,_.sequence),!0):!1},{isActive:n&&!!f});let I=[{label:"Close",command:"background.toggle"},{label:"Kill",command:"background.kill"},{label:"List",command:"background.toggleList"}],A=I.map(_=>`${_.label} (${Ee(_.command)})`).join(" | "),E=()=>(0,Ot.jsx)(l,{children:I.map((_,w)=>(0,Ot.jsxs)(l,{children:[w>0?" | ":"",_.label," (",(0,Ot.jsx)(l,{color:c.text.accent,children:Ee(_.command)}),")"]},_.label))}),T=()=>{let _=Array.from(e.values()).filter(O=>O.status==="running"),w=$r(` (PID: ${t}) ${n?"(Focused)":""}`),M=o-pO-$r(A)-w,D=0,N=[];for(let O=0;O<_.length;O++){let W=_[O],L=4+(O+1).toString().length,k=Math.max(1,Math.floor(M/_.length)-L),F=Dg(W.command,k),B=` ${O+1}: ${F} `,K=$r(B);if(O>0&&D+K>M)break;let q=W.pid===t;N.push((0,Ot.jsx)(l,{color:q?c.text.primary:c.text.secondary,bold:q,children:B},W.pid)),D+=K}if(_.length>N.length&&!s){let O=` ... (${Ee("background.toggleList")}) `,W=$r(O);(N.length>1||M-D>=W)&&N.push((0,Ot.jsx)(l,{color:c.status.warning,bold:!0,children:O},"overflow"))}return N},v=()=>{let _=Math.max(0,o-Iv-_g*2-10),w=Array.from(e.values()).map((D,N)=>{let O=Dg(D.command,_),W=`${N+1}: ${O} (PID: ${D.pid})`;return D.status==="exited"&&(W+=` (Exit Code: ${D.exitCode})`),{key:D.pid.toString(),value:D.pid,label:W}}),M=w.findIndex(D=>D.value===t);return(0,Ot.jsxs)(u,{flexDirection:"column",height:"100%",width:"100%",children:[(0,Ot.jsx)(u,{flexShrink:0,marginBottom:1,paddingTop:1,children:(0,Ot.jsx)(l,{bold:!0,children:`Select Process (${Ee("background.select")} to select, ${Ee("background.kill")} to kill, ${Ee("background.escape")} to cancel):`})}),(0,Ot.jsx)(u,{flexGrow:1,width:"100%",children:(0,Ot.jsx)(We,{items:w,initialIndex:M>=0?M:0,onSelect:D=>{d(D),m(!1)},onHighlight:D=>g(D),isFocused:n,maxItemsToShow:Math.max(1,r-vv-mO),renderItem:(D,{isSelected:N,titleColor:O})=>{let W=e.get(D.value);if(!W)return(0,Ot.jsx)(l,{children:D.label});let L=Dg(W.command,_);return(0,Ot.jsxs)(l,{children:[L," (PID: ",W.pid,")",W.status==="exited"?(0,Ot.jsxs)(l,{color:W.exitCode===0?c.status.success:c.status.error,children:[" ","(Exit Code: ",W.exitCode,")"]}):null]})}})})]})},R=()=>{let _=s?y??t:t;if(!_)return null;let w=lo.getLogFilePath(_),M=sT(iT(w),o-fO);return(0,Ot.jsx)(u,{paddingX:1,children:(0,Ot.jsxs)(l,{color:c.text.secondary,children:["Log: ",M]})})},b=()=>{let _=typeof h=="string"?h.split(`
94
- `):h;return(0,Ot.jsx)(pn,{ref:x,data:_,renderItem:({item:w,index:M})=>typeof w=="string"?(0,Ot.jsx)(l,{children:w},M):(0,Ot.jsx)(l,{wrap:"truncate",children:w.length>0?w.map((D,N)=>(0,Ot.jsx)(l,{color:D.fg,backgroundColor:D.bg,inverse:D.inverse,dimColor:D.dim,bold:D.bold,italic:D.italic,underline:D.underline,children:D.text},N)):null},M),estimatedItemHeight:()=>1,keyExtractor:(w,M)=>M.toString(),hasFocus:n,initialScrollIndex:da})};return(0,Ot.jsxs)(u,{flexDirection:"column",height:"100%",width:"100%",borderStyle:"single",borderColor:n?c.ui.focus:void 0,children:[(0,Ot.jsxs)(u,{flexDirection:"row",justifyContent:"space-between",borderStyle:"single",borderBottom:!1,borderLeft:!1,borderRight:!1,borderTop:!1,paddingX:1,borderColor:n?c.ui.focus:void 0,children:[(0,Ot.jsxs)(u,{flexDirection:"row",children:[T(),(0,Ot.jsxs)(l,{bold:!0,children:[" ","(PID: ",f?.pid,") ",n?"(Focused)":""]})]}),E()]}),(0,Ot.jsx)(u,{flexGrow:1,overflow:"hidden",paddingX:_g,children:s?v():b()}),R()]})};var bn=C(P(),1);var wv=()=>{let e=Ce(),{copyModeEnabled:t}=un(),o=Pt(),{rootUiRef:r,terminalHeight:n}=e;return qm(r,n),(0,bn.jsxs)(u,{flexDirection:"column",width:e.terminalWidth,height:o?n:void 0,paddingBottom:o?1:void 0,flexShrink:0,flexGrow:0,ref:e.rootUiRef,children:[(0,bn.jsx)(gm,{}),e.isBackgroundTaskVisible&&e.backgroundTasks.size>0&&e.activeBackgroundTaskPid&&e.backgroundTaskHeight>0&&e.streamingState!=="waiting_for_confirmation"&&(0,bn.jsx)(u,{height:e.backgroundTaskHeight,flexShrink:0,children:(0,bn.jsx)(Av,{shells:e.backgroundTasks,activePid:e.activeBackgroundTaskPid,width:e.terminalWidth,height:e.backgroundTaskHeight,isFocused:e.embeddedShellFocused&&!e.dialogsVisible,isListOpenProp:e.isBackgroundTaskListOpen})}),(0,bn.jsxs)(u,{flexDirection:"column",ref:e.mainControlsRef,flexShrink:0,flexGrow:0,width:e.terminalWidth,height:t?e.stableControlsHeight:void 0,children:[(0,bn.jsx)(lm,{}),(0,bn.jsx)(xv,{}),e.customDialog?e.customDialog:e.dialogsVisible?(0,bn.jsx)(Im,{terminalWidth:e.terminalWidth,addItem:e.historyManager.addItem}):(0,bn.jsx)(Vm,{isFocused:!0}),(0,bn.jsx)($m,{})]})]})};var En=C(P(),1);var _v=()=>{let{version:e}=_l(),t=Ce(),o=pm(),r=o!==null;return(0,En.jsxs)(u,{flexDirection:"column",flexShrink:0,flexGrow:0,width:t.terminalWidth,children:[(0,En.jsx)(kc,{version:e},"app-header"),t.history.map(n=>(0,En.jsx)(_s,{terminalWidth:t.mainAreaWidth,availableTerminalHeight:void 0,availableTerminalHeightGemini:65536,item:n,isPending:!1,commands:t.slashCommands},n.id)),t.pendingHistoryItems.map((n,s)=>(0,En.jsx)(_s,{availableTerminalHeight:void 0,terminalWidth:t.mainAreaWidth,item:{...n,id:0},isPending:!0},s)),r&&(0,En.jsxs)(u,{flexDirection:"column",marginTop:1,marginBottom:1,children:[(0,En.jsx)(l,{color:c.status.warning,bold:!0,children:"Action Required (was prompted):"}),(0,En.jsxs)(u,{marginTop:1,children:[(0,En.jsx)(Mr,{status:o.tool.status,name:o.tool.name}),(0,En.jsx)(xs,{name:o.tool.name,status:o.tool.status,description:o.tool.description,emphasis:"high"})]})]}),(0,En.jsx)(im,{})]})};var Da=C(P(),1);var Dv=()=>{let e=Ce(),t=Pt(),o=Dr();return e.quittingMessages?t?(0,Da.jsx)(wf.Provider,{value:e.streamingState,children:(0,Da.jsx)(_v,{})}):(0,Da.jsx)(im,{}):(0,Da.jsx)(wf.Provider,{value:e.streamingState,children:o?(0,Da.jsx)(Tv,{}):(0,Da.jsx)(wv,{})})};import mh from"node:process";var Mv=C(z(),1);import gO from"node:process";var hO=7*1024*1024*1024,yO=60*1e3,Pv=({addItem:e})=>{(0,Mv.useEffect)(()=>{let t=setInterval(()=>{let o=gO.memoryUsage().rss;o>hO&&(e({type:"warning",text:`High memory usage detected: ${(o/1073741824).toFixed(2)} GB. If you experience a crash, please file a bug report by running \`/bug\``},Date.now()),clearInterval(t))},yO);return()=>clearInterval(t)},[e])};var Ls=C(z(),1);import TO from"node:process";var Qr=C(z(),1);var Nv=C(P(),1);var Ov=(0,Qr.createContext)(void 0);function Km(){let e=(0,Qr.useContext)(Ov);if(!e)throw new Error("useTerminalContext must be used within a TerminalProvider");return e}function Lv({children:e}){let{stdin:t}=dl(),{stdout:o}=ml(),r=(0,Qr.useRef)(new Set).current,n=(0,Qr.useRef)(""),s=(0,Qr.useCallback)(d=>{r.add(d)},[r]),i=(0,Qr.useCallback)(d=>{r.delete(d)},[r]),a=(0,Qr.useCallback)(async()=>new Promise(d=>{let m=()=>{i(m),d()};s(m),ll.queryBackgroundColor(o),setTimeout(()=>{i(m),d()},100)}),[o,s,i]);return(0,Qr.useEffect)(()=>{let d=m=>{n.current+=typeof m=="string"?m:m.toString("utf-8");let f=n.current.match(ll.OSC_11_REGEX);if(f){let h=`rgb:${f[1]}/${f[2]}/${f[3]}`;for(let p of r)p(h);f.index!==void 0&&(n.current=n.current.slice(f.index+f[0].length))}else n.current.length>4096&&(n.current=n.current.slice(-1024))};return t.on("data",d),()=>{t.removeListener("data",d)}},[t,r]),(0,Nv.jsx)(Ov.Provider,{value:{subscribe:s,unsubscribe:i,queryTerminalBackground:a},children:e})}var Bv=(e,t,o,r,n)=>{let[s,i]=(0,Ls.useState)(!!r),{queryTerminalBackground:a}=Km(),d=(0,Ls.useCallback)(async()=>{if(TO.env.NO_COLOR){o({type:"info",text:"Theme configuration unavailable due to NO_COLOR env variable."},Date.now());return}await a(),i(!0)},[o,a]),m=(0,Ls.useCallback)(y=>{at.setActiveTheme(y)?t(null):(i(!0),t(`Theme "${y}" not found.`))},[t]),f=(0,Ls.useCallback)(y=>{m(y)},[m]),h=(0,Ls.useCallback)(()=>{m(e.merged.ui.theme),i(!1)},[m,e]),p=(0,Ls.useCallback)(async(y,g)=>{try{let x={...e.user.settings.ui?.customThemes||{},...e.workspace.settings.ui?.customThemes||{}},S=at.findThemeByName(y),I=y&&x[y];if(!S&&!I){t(`Theme "${y}" not found in selected scope.`),i(!0);return}e.setValue(g,"ui.theme",y),e.merged.ui.customThemes&&at.loadCustomThemes(e.merged.ui.customThemes),m(e.merged.ui.theme),n(),t(null)}finally{i(!1)}},[m,e,n,t]);return{isThemeDialogOpen:s,openThemeDialog:d,closeThemeDialog:h,handleThemeSelect:p,handleThemeHighlight:f}};var ar=C(z(),1);async function kv(e){let t=jT(e.paidTier);if(t==null)return null;let{overageStrategy:o}=e;return zT(o,t)?null:YT(o,t)?xO(e,t):XT(o,t)?SO(e):null}async function xO(e,t){let{config:o,fallbackModel:r,usageLimitReachedModel:n,overageStrategy:s,resetTime:i,isDialogPending:a,setOverageMenuRequest:d,setModelSwitchedFromQuotaError:m}=e;if(Js(o,new JT(n,t,s)),a.current)return"stop";a.current=!0,m(!0),o.setQuotaErrorOccurred(!0);let f=await new Promise(h=>{d({failedModel:n,fallbackModel:r,resetTime:i,creditBalance:t,resolve:h})});switch(d(null),a.current=!1,CO(o,n,f,t),f){case"use_credits":return m(!1),o.setQuotaErrorOccurred(!1),o.setOverageStrategy("always"),"retry_with_credits";case"use_fallback":return"retry_always";case"manage":{Hv(o,"manage",n);let h=await Fv("activity",sf.MANAGE_ACTIVITY);return h&&e.historyManager.addItem({type:"info",text:`Please open this URL in a browser: ${h}`},Date.now()),"stop"}case"stop":default:return"stop"}}async function SO(e){let{config:t,fallbackModel:o,usageLimitReachedModel:r,resetTime:n,isDialogPending:s,setEmptyWalletRequest:i,setModelSwitchedFromQuotaError:a}=e;if(Js(t,new ex(r)),s.current)return"stop";s.current=!0,a(!0),t.setQuotaErrorOccurred(!0);let d=await new Promise(m=>{i({failedModel:r,fallbackModel:o,resetTime:n,onGetCredits:async()=>{Hv(t,"empty_wallet_menu",r);let f=await Fv("credits",sf.EMPTY_WALLET_ADD_CREDITS);f&&e.historyManager.addItem({type:"info",text:`Please open this URL in a browser: ${f}`},Date.now())},resolve:m})});switch(i(null),s.current=!1,d){case"get_credits":return e.historyManager.addItem({type:"info",text:"Newly purchased AI credits may take a few minutes to update. Run /stats to check your balance."},Date.now()),"stop";case"use_fallback":return"retry_always";case"stop":default:return"stop"}}function CO(e,t,o,r){Js(e,new ZT(t,o,r)),NT(e,{selected_option:o,model:t})}function Hv(e,t,o){Js(e,new tx(t,o)),BT(e,{source:t,model:o})}async function Fv(e,t){try{let o=new Yu().getCachedGoogleAccount()??"",r=KT(e,o,t);if(!el())return r;await Za(r)}catch{}}function Gv({config:e,historyManager:t,userTier:o,paidTier:r,settings:n,setModelSwitchedFromQuotaError:s,onShowAuthSelection:i,errorVerbosity:a="full"}){let[d,m]=(0,ar.useState)(null),[f,h]=(0,ar.useState)(null),[p,y]=(0,ar.useState)(null),[g,x]=(0,ar.useState)(null),S=(0,ar.useRef)(!1),I=(0,ar.useRef)(!1);(0,ar.useEffect)(()=>{let R=async(b,_,w)=>{let M=e.getContentGeneratorConfig(),D,N=!1,O=!1,W=qu(b)?"all Pro models":b;if(w instanceof fx){if(N=!0,!w.isInsufficientCredits&&r?.availableCredits&&qT(b)){let B=w.retryDelayMs?Uv(w.retryDelayMs):void 0,K=e.getBillingSettings().overageStrategy,q=await kv({config:e,paidTier:r,overageStrategy:K,failedModel:b,fallbackModel:_,usageLimitReachedModel:W,resetTime:B,historyManager:t,setModelSwitchedFromQuotaError:s,isDialogPending:S,setOverageMenuRequest:y,setEmptyWalletRequest:x});if(q)return q}D=[`Usage limit reached for ${W}.`,w.retryDelayMs?`Access resets at ${Uv(w.retryDelayMs)}.`:null,"/stats model for usage details","/model to switch models.",M?.authType===qe.LOGIN_WITH_GOOGLE?"/auth to switch to API key.":null].filter(Boolean).join(`
94
+ `):h;return(0,Ot.jsx)(pn,{ref:x,data:_,renderItem:({item:w,index:M})=>typeof w=="string"?(0,Ot.jsx)(l,{children:w},M):(0,Ot.jsx)(l,{wrap:"truncate",children:w.length>0?w.map((D,N)=>(0,Ot.jsx)(l,{color:D.fg,backgroundColor:D.bg,inverse:D.inverse,dimColor:D.dim,bold:D.bold,italic:D.italic,underline:D.underline,children:D.text},N)):null},M),estimatedItemHeight:()=>1,keyExtractor:(w,M)=>M.toString(),hasFocus:n,initialScrollIndex:da})};return(0,Ot.jsxs)(u,{flexDirection:"column",height:"100%",width:"100%",borderStyle:"single",borderColor:n?c.ui.focus:void 0,children:[(0,Ot.jsxs)(u,{flexDirection:"row",justifyContent:"space-between",borderStyle:"single",borderBottom:!1,borderLeft:!1,borderRight:!1,borderTop:!1,paddingX:1,borderColor:n?c.ui.focus:void 0,children:[(0,Ot.jsxs)(u,{flexDirection:"row",children:[T(),(0,Ot.jsxs)(l,{bold:!0,children:[" ","(PID: ",f?.pid,") ",n?"(Focused)":""]})]}),E()]}),(0,Ot.jsx)(u,{flexGrow:1,overflow:"hidden",paddingX:_g,children:s?v():b()}),R()]})};var bn=C(P(),1);var wv=()=>{let e=Ce(),{copyModeEnabled:t}=un(),o=Pt(),{rootUiRef:r,terminalHeight:n}=e;return qm(r,n),(0,bn.jsxs)(u,{flexDirection:"column",width:e.terminalWidth,height:o?n:void 0,paddingBottom:o?1:void 0,flexShrink:0,flexGrow:0,ref:e.rootUiRef,children:[(0,bn.jsx)(gm,{}),e.isBackgroundTaskVisible&&e.backgroundTasks.size>0&&e.activeBackgroundTaskPid&&e.backgroundTaskHeight>0&&e.streamingState!=="waiting_for_confirmation"&&(0,bn.jsx)(u,{height:e.backgroundTaskHeight,flexShrink:0,children:(0,bn.jsx)(Av,{shells:e.backgroundTasks,activePid:e.activeBackgroundTaskPid,width:e.terminalWidth,height:e.backgroundTaskHeight,isFocused:e.embeddedShellFocused&&!e.dialogsVisible,isListOpenProp:e.isBackgroundTaskListOpen})}),(0,bn.jsxs)(u,{flexDirection:"column",ref:e.mainControlsRef,flexShrink:0,flexGrow:0,width:e.terminalWidth,height:t?e.stableControlsHeight:void 0,children:[(0,bn.jsx)(lm,{}),(0,bn.jsx)(xv,{}),e.customDialog?e.customDialog:e.dialogsVisible?(0,bn.jsx)(Im,{terminalWidth:e.terminalWidth,addItem:e.historyManager.addItem}):(0,bn.jsx)(Vm,{isFocused:!0}),(0,bn.jsx)($m,{})]})]})};var En=C(P(),1);var _v=()=>{let{version:e}=_l(),t=Ce(),o=pm(),r=o!==null;return(0,En.jsxs)(u,{flexDirection:"column",flexShrink:0,flexGrow:0,width:t.terminalWidth,children:[(0,En.jsx)(kc,{version:e},"app-header"),t.history.map(n=>(0,En.jsx)(_s,{terminalWidth:t.mainAreaWidth,availableTerminalHeight:void 0,availableTerminalHeightGemini:65536,item:n,isPending:!1,commands:t.slashCommands},n.id)),t.pendingHistoryItems.map((n,s)=>(0,En.jsx)(_s,{availableTerminalHeight:void 0,terminalWidth:t.mainAreaWidth,item:{...n,id:0},isPending:!0},s)),r&&(0,En.jsxs)(u,{flexDirection:"column",marginTop:1,marginBottom:1,children:[(0,En.jsx)(l,{color:c.status.warning,bold:!0,children:"Action Required (was prompted):"}),(0,En.jsxs)(u,{marginTop:1,children:[(0,En.jsx)(Mr,{status:o.tool.status,name:o.tool.name}),(0,En.jsx)(xs,{name:o.tool.name,status:o.tool.status,description:o.tool.description,emphasis:"high"})]})]}),(0,En.jsx)(im,{})]})};var Da=C(P(),1);var Dv=()=>{let e=Ce(),t=Pt(),o=Dr();return e.quittingMessages?t?(0,Da.jsx)(wf.Provider,{value:e.streamingState,children:(0,Da.jsx)(_v,{})}):(0,Da.jsx)(im,{}):(0,Da.jsx)(wf.Provider,{value:e.streamingState,children:o?(0,Da.jsx)(Tv,{}):(0,Da.jsx)(wv,{})})};import mh from"node:process";var Mv=C(z(),1);import gO from"node:process";var hO=7*1024*1024*1024,yO=60*1e3,Pv=({addItem:e})=>{(0,Mv.useEffect)(()=>{let t=setInterval(()=>{let o=gO.memoryUsage().rss;o>hO&&(e({type:"warning",text:`High memory usage detected: ${(o/1073741824).toFixed(2)} GB. If you experience a crash, please file a bug report by running \`/bug\``},Date.now()),clearInterval(t))},yO);return()=>clearInterval(t)},[e])};var Ls=C(z(),1);import TO from"node:process";var Qr=C(z(),1);var Nv=C(P(),1);var Ov=(0,Qr.createContext)(void 0);function Km(){let e=(0,Qr.useContext)(Ov);if(!e)throw new Error("useTerminalContext must be used within a TerminalProvider");return e}function Lv({children:e}){let{stdin:t}=dl(),{stdout:o}=ml(),r=(0,Qr.useRef)(new Set).current,n=(0,Qr.useRef)(""),s=(0,Qr.useCallback)(d=>{r.add(d)},[r]),i=(0,Qr.useCallback)(d=>{r.delete(d)},[r]),a=(0,Qr.useCallback)(async()=>new Promise(d=>{let m=()=>{i(m),d()};s(m),ll.queryBackgroundColor(o),setTimeout(()=>{i(m),d()},100)}),[o,s,i]);return(0,Qr.useEffect)(()=>{let d=m=>{n.current+=typeof m=="string"?m:m.toString("utf-8");let f=n.current.match(ll.OSC_11_REGEX);if(f){let h=`rgb:${f[1]}/${f[2]}/${f[3]}`;for(let p of r)p(h);f.index!==void 0&&(n.current=n.current.slice(f.index+f[0].length))}else n.current.length>4096&&(n.current=n.current.slice(-1024))};return t.on("data",d),()=>{t.removeListener("data",d)}},[t,r]),(0,Nv.jsx)(Ov.Provider,{value:{subscribe:s,unsubscribe:i,queryTerminalBackground:a},children:e})}var Bv=(e,t,o,r,n)=>{let[s,i]=(0,Ls.useState)(!!r),{queryTerminalBackground:a}=Km(),d=(0,Ls.useCallback)(async()=>{if(TO.env.NO_COLOR){o({type:"info",text:"Theme configuration unavailable due to NO_COLOR env variable."},Date.now());return}await a(),i(!0)},[o,a]),m=(0,Ls.useCallback)(y=>{at.setActiveTheme(y)?t(null):(i(!0),t(`Theme "${y}" not found.`))},[t]),f=(0,Ls.useCallback)(y=>{m(y)},[m]),h=(0,Ls.useCallback)(()=>{m(e.merged.ui.theme),i(!1)},[m,e]),p=(0,Ls.useCallback)(async(y,g)=>{try{let x={...e.user.settings.ui?.customThemes||{},...e.workspace.settings.ui?.customThemes||{}},S=at.findThemeByName(y),I=y&&x[y];if(!S&&!I){t(`Theme "${y}" not found in selected scope.`),i(!0);return}e.setValue(g,"ui.theme",y),e.merged.ui.customThemes&&at.loadCustomThemes(e.merged.ui.customThemes),m(e.merged.ui.theme),n(),t(null)}finally{i(!1)}},[m,e,n,t]);return{isThemeDialogOpen:s,openThemeDialog:d,closeThemeDialog:h,handleThemeSelect:p,handleThemeHighlight:f}};var ar=C(z(),1);async function kv(e){let t=jT(e.paidTier);if(t==null)return null;let{overageStrategy:o}=e;return zT(o,t)?null:YT(o,t)?xO(e,t):XT(o,t)?SO(e):null}async function xO(e,t){let{config:o,fallbackModel:r,usageLimitReachedModel:n,overageStrategy:s,resetTime:i,isDialogPending:a,setOverageMenuRequest:d,setModelSwitchedFromQuotaError:m}=e;if(Js(o,new JT(n,t,s)),a.current)return"stop";a.current=!0,m(!0),o.setQuotaErrorOccurred(!0);let f=await new Promise(h=>{d({failedModel:n,fallbackModel:r,resetTime:i,creditBalance:t,resolve:h})});switch(d(null),a.current=!1,CO(o,n,f,t),f){case"use_credits":return m(!1),o.setQuotaErrorOccurred(!1),o.setOverageStrategy("always"),"retry_with_credits";case"use_fallback":return"retry_always";case"manage":{Hv(o,"manage",n);let h=await Fv("activity",sf.MANAGE_ACTIVITY);return h&&e.historyManager.addItem({type:"info",text:`Please open this URL in a browser: ${h}`},Date.now()),"stop"}case"stop":default:return"stop"}}async function SO(e){let{config:t,fallbackModel:o,usageLimitReachedModel:r,resetTime:n,isDialogPending:s,setEmptyWalletRequest:i,setModelSwitchedFromQuotaError:a}=e;if(Js(t,new ex(r)),s.current)return"stop";s.current=!0,a(!0),t.setQuotaErrorOccurred(!0);let d=await new Promise(m=>{i({failedModel:r,fallbackModel:o,resetTime:n,onGetCredits:async()=>{Hv(t,"empty_wallet_menu",r);let f=await Fv("credits",sf.EMPTY_WALLET_ADD_CREDITS);f&&e.historyManager.addItem({type:"info",text:`Please open this URL in a browser: ${f}`},Date.now())},resolve:m})});switch(i(null),s.current=!1,d){case"get_credits":return e.historyManager.addItem({type:"info",text:"Newly purchased AI credits may take a few minutes to update. Run /stats to check your balance."},Date.now()),"stop";case"use_fallback":return"retry_always";case"stop":default:return"stop"}}function CO(e,t,o,r){Js(e,new ZT(t,o,r)),NT(e,{selected_option:o,model:t})}function Hv(e,t,o){Js(e,new tx(t,o)),BT(e,{source:t,model:o})}async function Fv(e,t){try{let o=new Yu().getCachedGoogleAccount()??"",r=KT(e,o,t);if(!el())return r;await Za(r)}catch{}}function Gv({config:e,historyManager:t,userTier:o,paidTier:r,settings:n,setModelSwitchedFromQuotaError:s,onShowAuthSelection:i,errorVerbosity:a="full"}){let[d,m]=(0,ar.useState)(null),[f,h]=(0,ar.useState)(null),[p,y]=(0,ar.useState)(null),[g,x]=(0,ar.useState)(null),S=(0,ar.useRef)(!1),I=(0,ar.useRef)(!1);(0,ar.useEffect)(()=>{let R=async(b,_,w)=>{let M=e.getContentGeneratorConfig(),D,N=!1,O=!1,W=qu(b)?"all Pro models":b;if(w instanceof fx){if(N=!0,!w.isInsufficientCredits&&r?.availableCredits&&qT(b)){let B=w.retryDelayMs?Uv(w.retryDelayMs):void 0,K=e.getBillingSettings().overageStrategy,q=await kv({config:e,paidTier:r,overageStrategy:K,failedModel:b,fallbackModel:_,usageLimitReachedModel:W,resetTime:B,historyManager:t,setModelSwitchedFromQuotaError:s,isDialogPending:S,setOverageMenuRequest:y,setEmptyWalletRequest:x});if(q)return q}D=[`Usage limit reached for ${W}.`,w.retryDelayMs?`Access resets at ${Uv(w.retryDelayMs)}.`:null,"/stats model for usage details","/model to switch models.",M?.authType===$e.LOGIN_WITH_GOOGLE?"/auth to switch to API key.":null].filter(Boolean).join(`
95
95
  `)}else w instanceof px?(O=!0,dT.has(b)?D=[`It seems like you don't have access to ${Bt(b)}.`,"Your admin might have disabled the access. Contact them to enable the Preview Release Channel."].join(`
96
96
  `):D=[`Model "${b}" was not found or is invalid.`,"/model to switch models."].join(`
97
97
  `)):D=["We are currently experiencing high demand.","We apologize and appreciate your patience.","/model to switch models."].join(`
@@ -109,14 +109,14 @@ ${q.subCommands.map(ee=>` - ${ee.name}: ${ee.description||""}`).join(`
109
109
  `)})}function l_(e,t,o,r){let{addItem:n}=o;(0,a_.useEffect)(()=>{if(t===void 0||!e)return;let s=e.getPendingIncludeDirectories();if(s.length===0)return;if(e.getFolderTrust()===!1||t===!1){let y=[],g=[],x=e.getWorkspaceContext(),S=vf(x,s);y.push(...S.added),g.push(...S.errors),(y.length>0||g.length>0)&&sh(e,n,y,g),e.clearPendingIncludeDirectories();return}let i=Xn(),a=[],d=[],m=[],f=[],h=[];for(let y of s){let g=cC(y.trim()),x=i.isPathTrusted(g);x===!1?a.push(y.trim()):x===void 0?d.push(y.trim()):m.push(y.trim())}a.length>0&&h.push(`The following directories are explicitly untrusted and cannot be added to a trusted workspace:
110
110
  - ${a.join(`
111
111
  - `)}
112
- Please use the permissions command to modify their trust level.`);let p=e.getWorkspaceContext();if(m.length>0){let y=vf(p,m);f.push(...y.added),h.push(...y.errors)}d.length>0?(de.log("Creating custom dialog with undecidedDirs:",d),r((0,c_.jsx)(uC,{folders:d,onComplete:()=>{r(null),e.clearPendingIncludeDirectories()},trustedDirs:f,errors:h,finishAddingDirectories:sh,config:e,addItem:n}))):(f.length>0||h.length>0)&&(sh(e,n,f,h),e.clearPendingIncludeDirectories())},[t,e,n,r])}var zi=C(z(),1);function u_(){let[e,t]=(0,zi.useState)([]),[o,r]=(0,zi.useState)([]),[n,s]=(0,zi.useState)([]),[i,a]=(0,zi.useState)(!1),d=(0,zi.useCallback)((h,p)=>{let y=[...h,...p],g=[];if(y.length>0){g.push(y[0]);for(let x=1;x<y.length;x++)y[x]!==y[x-1]&&g.push(y[x])}t(g.reverse())},[]),m=(0,zi.useCallback)(async h=>{if(!(i||!h))try{let p=await h.getPreviousUserMessages()||[];r(p),d([],p),a(!0)}catch(p){de.warn("Failed to initialize input history from logger:",p),r([]),d([],[]),a(!0)}},[i,d]),f=(0,zi.useCallback)(h=>{let p=h.trim();p&&s(y=>{let g=[...y,p];return r(x=>(d(g.slice().reverse(),x),x)),g})},[d]);return{inputHistory:e,addInput:f,initializeFromLogger:m}}var Va=C(z(),1);var d_=()=>{let[e,t]=(0,Va.useState)([]),o=(0,Va.useRef)(new Map),r=(0,Va.useRef)(new Set);return(0,Va.useEffect)(()=>{let n=r.current,s=o.current,i=d=>{let m=`${d.hookName}:${d.eventName}`,f=Date.now();s.has(m)||s.set(m,[]),s.get(m).push(f),t(h=>[...h,{name:d.hookName,eventName:d.eventName,source:d.source,index:d.hookIndex,total:d.totalHooks}])},a=d=>{let m=`${d.hookName}:${d.eventName}`,f=s.get(m),h=f?.shift();f&&f.length===0&&s.delete(m);let p=Date.now(),y=h?p-h:Di,g=Di-y,x=()=>{t(S=>{let I=S.findIndex(E=>E.name===d.hookName&&E.eventName===d.eventName);if(I===-1)return S;let A=[...S];return A.splice(I,1),A})};if(g>0){let S=setTimeout(()=>{x(),n.delete(S)},g);n.add(S)}else x()};return Se.on(Ge.HookStart,i),Se.on(Ge.HookEnd,a),()=>{Se.off(Ge.HookStart,i),Se.off(Ge.HookEnd,a),n.forEach(clearTimeout),n.clear()}},[]),e};var Us=C(z(),1);function m_({backgroundTasks:e,backgroundTaskCount:t,isBackgroundTaskVisible:o,activePtyId:r,embeddedShellFocused:n,setEmbeddedShellFocused:s,terminalHeight:i}){let[a,d]=(0,Us.useState)(!1),[m,f]=(0,Us.useState)(null);(0,Us.useEffect)(()=>{e.size===0?(m!==null&&f(null),a&&d(!1)):(m===null||!e.has(m))&&f(e.keys().next().value??null)},[e,m,t,a]),(0,Us.useEffect)(()=>{if(n){let p=!!r,y=o&&e.size>0;!p&&!y&&s(!1)}},[o,e,n,t,r,s]);let h=(0,Us.useMemo)(()=>o&&e.size>0?Math.max(Math.floor(i*.3),5):0,[o,e.size,i]);return{isBackgroundTaskListOpen:a,setIsBackgroundTaskListOpen:d,activeBackgroundTaskPid:m,setActiveBackgroundTaskPid:f,backgroundTaskHeight:h}}var p_=C(z(),1);function f_(e,t,o){let r=Ke(),{subscribe:n,unsubscribe:s,queryTerminalBackground:i}=Km();(0,p_.useEffect)(()=>{if(r.merged.ui.autoThemeSwitching===!1||t.getTerminalBackground()===void 0)return;let a=setInterval(()=>{let m=r.merged.ui.theme;at.isDefaultTheme(m)&&i()},r.merged.ui.terminalBackgroundPollingInterval*1e3),d=m=>{let f=/^rgb:([0-9a-fA-F]{1,4})\/([0-9a-fA-F]{1,4})\/([0-9a-fA-F]{1,4})$/.exec(m);if(!f)return;let h=DS(f[1],f[2],f[3]);if(!h)return;let p=t.getTerminalBackground(),y=yS(h),g=r.merged.ui.theme,x=_S(g,y,nl.name,SS.name);if(p===h){x&&e(x,"User");return}t.setTerminalBackground(h),at.setTerminalBackground(h),x?e(x,"User"):o()};return n(d),()=>{clearInterval(a),s(d)}},[r.merged.ui.theme,r.merged.ui.autoThemeSwitching,r.merged.ui.terminalBackgroundPollingInterval,t,e,n,s,i,o])}var Gs=C(z(),1);function xp(e){let[t,o]=(0,Gs.useState)(null),r=(0,Gs.useRef)(null),n=(0,Gs.useCallback)(s=>{o(s),r.current&&clearTimeout(r.current),s!==null&&(r.current=setTimeout(()=>{o(null)},e))},[e]);return(0,Gs.useEffect)(()=>()=>{r.current&&clearTimeout(r.current)},[]),[t,n]}var Ti=C(z(),1);import In from"node:process";function g_({handleWarning:e,setRawMode:t,refreshStatic:o,setForceRerenderKey:r,shouldUseAlternateScreen:n}){let[s,i]=(0,Ti.useState)(0),a=(0,Ti.useRef)(null),d=(0,Ti.useRef)(null);return(0,Ti.useEffect)(()=>()=>{a.current&&(clearTimeout(a.current),a.current=null),d.current&&(In.off("SIGCONT",d.current),d.current=null)},[]),(0,Ti.useEffect)(()=>{a.current&&(clearTimeout(a.current),a.current=null);let f=Ee("app.suspend");if(s>1){if(i(0),In.platform==="win32"){e(`${f} suspend is not supported on Windows.`);return}n&&(WT(),Qu(),_r("\x1B[2J\x1B[H")),_r("\x1B[?25h"),ls(),qS(),In.stdin.isTTY&&In.stdin.setRawMode(!1),t(!1);let h=()=>{try{In.stdin.isTTY&&(In.stdin.setRawMode(!0),In.stdin.resume(),In.stdin.ref()),t(!0),n&&(Ju(),Ja(),_r("\x1B[2J\x1B[H")),cl.enableSupportedModes(),_r("\x1B[?25l"),n&&as(),In.stdout.emit("resize"),setImmediate(()=>{o(),r(p=>p+1)})}finally{d.current===h&&(d.current=null)}};d.current&&In.off("SIGCONT",d.current),d.current=h,In.once("SIGCONT",h),In.kill(0,"SIGTSTP")}else if(s>0){let h=Ee("edit.undo");e(`Press ${f} again to suspend. Undo has moved to ${h}.`),a.current=setTimeout(()=>{i(0),a.current=null},Di)}},[s,e,t,o,r,n]),{handleSuspend:(0,Ti.useCallback)(()=>{i(f=>f+1)},[])}}var xi=C(z(),1);var CZ=C(z(),1);var BN=48,kN=64,HN=180,ah="\x07",FN="\x1B]9;",UN="\x1B]777;notify;",x_=" | ";function Sp(e){let t=Co(e.title,BN),o=e.subtitle?Co(e.subtitle,kN):void 0,r=Co(e.body,HN);return{title:t||"Gemini CLI",subtitle:o||void 0,body:r||"Open Gemini CLI for details."}}function lh(e){return e.type==="attention"?Sp({title:"Gemini CLI needs your attention",subtitle:e.heading??"Action required",body:e.detail??"Open Gemini CLI to continue."}):Sp({title:"Gemini CLI session complete",subtitle:"Run finished",body:e.detail??"The session finished successfully."})}function S_(e){return e.merged.general?.enableNotifications===!0}function C_(e){switch(e.merged.general?.notificationMethod){case"osc9":return"osc9";case"osc777":return"osc777";case"bell":return"bell";default:return"auto"}}function b_(e){let t=ll.getInstance();return t.isTmux()?`\x1BPtmux;${e.replace(/\x1b/g,"\x1B\x1B")}\x1B\\`:t.isScreen()?`\x1BP${e}\x1B\\`:e}function h_(e){let t=Sp(e),r=[t.title,t.subtitle,t.body].filter(Boolean).join(x_);_r(b_(`${FN}${r}${ah}`))}function y_(e){let t=Sp(e),r=[t.subtitle,t.body].filter(Boolean).join(x_),n=t.title.replace(/;/g,":"),s=r.replace(/;/g,":");_r(b_(`${UN}${n};${s}${ah}`))}function T_(){_r(ah)}async function ch(e,t,o="auto"){if(!e)return!1;try{if(o==="osc9")h_(t);else if(o==="osc777")y_(t);else if(o==="bell")T_();else{let r=ll.getInstance();r.isITerm2()?h_(t):r.isAlacritty()||r.isAppleTerminal()||r.isVSCodeTerminal()||r.isWindowsTerminal()?T_():y_(t)}return!0}catch(r){return de.debug("Failed to emit terminal notification:",r),!1}}function uh(e){return typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(t=>uh(t)).join("|"):"react-node"}function E_(e,t,o,r,n,s){let i=mm(e);if(i){let a=i.tool.confirmationDetails;if(a?.type==="ask_user"){let m=a.questions.at(0)?.header;return{key:`ask_user:${i.tool.callId}`,event:{type:"attention",heading:"Answer requested by agent",detail:m||"The agent needs your response to continue."}}}let d=a?.title||i.tool.description;return{key:`tool_confirmation:${i.tool.callId}`,event:{type:"attention",heading:"Approval required",detail:d?`Approve tool action: ${d}`:"Approve a pending tool action to continue."}}}return t?{key:`command_confirmation:${uh(t.prompt)}`,event:{type:"attention",heading:"Confirmation required",detail:"A command is waiting for your confirmation."}}:o?{key:`auth_consent:${uh(o.prompt)}`,event:{type:"attention",heading:"Authentication confirmation required",detail:"Authentication is waiting for your confirmation."}}:r?{key:`filesystem_permission_confirmation:${r.files.join("|")}`,event:{type:"attention",heading:"Filesystem permission required",detail:"Read-only path access is waiting for your confirmation."}}:n?{key:"extension_update_confirmation",event:{type:"attention",heading:"Extension update confirmation required",detail:"An extension update is waiting for your confirmation."}}:s?{key:"loop_detection_confirmation",event:{type:"attention",heading:"Loop detection confirmation required",detail:"A loop detection prompt is waiting for your response."}}:null}var GN=2e4;function R_({notificationsEnabled:e,notificationMethod:t,isFocused:o,hasReceivedFocusEvent:r,streamingState:n,hasPendingActionRequired:s,pendingHistoryItems:i,commandConfirmationRequest:a,authConsentRequest:d,permissionConfirmationRequest:m,hasConfirmUpdateExtensionRequests:f,hasLoopDetectionConfirmationRequest:h}){let p=(0,xi.useMemo)(()=>E_(i,a,d,m,f,h),[i,a,d,m,f,h]),y=(0,xi.useRef)(!1),g=(0,xi.useRef)(o),x=(0,xi.useRef)(n),S=(0,xi.useRef)(null);(0,xi.useEffect)(()=>{if(!e)return;let I=g.current;g.current=o;let A=p!==null,E=y.current;if(y.current=A,!A){S.current=null;return}if(r&&o)return;let v=!E,R=I&&!o,b=Date.now(),_=p.key,w=S.current,M=!w||w.key!==_,D=!!w&&w.key===_&&b-w.sentAt<GN;!(r?v||R||M:v||M)||D||(S.current={key:_,sentAt:b},ch(e,lh(p.event),t))},[o,r,e,t,p]),(0,xi.useEffect)(()=>{if(!e)return;let I=x.current;x.current=n,!(!(I==="responding"&&n==="idle")||r&&o||s)&&ch(e,lh({type:"session_complete",detail:"Gemini CLI finished responding."}),t)},[n,o,r,e,t,s])}var Hr=C(z(),1);var dh=1200,I_="focusUiEnabled";function v_(){let[e]=(0,Hr.useState)(()=>Go.get(I_)===!0),[t,o]=(0,Hr.useState)(!e),r=(0,Hr.useRef)(null),n=(0,Hr.useRef)(!e),s=(0,Hr.useCallback)(()=>{r.current&&(clearTimeout(r.current),r.current=null)},[]),i=(0,Hr.useCallback)(f=>{Go.set(I_,!f)},[]),a=(0,Hr.useCallback)(f=>{s(),n.current=f,o(f),i(f)},[s,i]),d=(0,Hr.useCallback)(()=>{s(),o(f=>{let h=!f;return n.current=h,i(h),h})},[s,i]),m=(0,Hr.useCallback)((f=dh)=>{n.current||(s(),o(!0),r.current=setTimeout(()=>{n.current||o(!1),r.current=null},f))},[s]);return(0,Hr.useEffect)(()=>()=>s(),[s]),{cleanUiDetailsVisible:t,setCleanUiDetailsVisible:a,toggleCleanUiDetailsVisible:d,revealCleanUiDetailsTemporarily:m}}var vn=C(P(),1);var VN=.89,$N=10,A_=e=>{let t=Bm(),o=Ze(),{config:r,initializationResult:n,resumedSessionData:s}=e,i=Ke(),{reset:a}=ps(),d=S_(i),m=C_(i),{setOptions:f,dumpCurrentFrame:h,startRecording:p,stopRecording:y}=(0,V.useContext)(QS),g=(0,V.useRef)(null),x=bC({chatRecordingService:r.getGeminiClient()?.getChatRecordingService()});Pv(x);let S=r.getUseAlternateBuffer(),[I,A]=(0,V.useState)(()=>r.getUseAlternateBuffer());(0,V.useEffect)(()=>{f({stickyHeadersInBackbuffer:I}),I?as():ls()},[I,f]);let[E,T]=(0,V.useState)(!1),[v,R]=(0,V.useState)(0),[b,_]=(0,V.useState)(""),[w,M]=(0,V.useState)(null),[D,N]=(0,V.useState)(!1),[O,W]=(0,V.useState)(n.themeError),[L,k]=(0,V.useState)(!1),[F,B]=(0,V.useState)(!1),[K,q]=(0,V.useState)(!1),[Z,Y]=(0,V.useState)(null),[oe,ce]=(0,V.useState)(!1),[G,ee]=(0,V.useState)(!1),te=(0,V.useRef)(()=>{}),ae=(0,V.useRef)(!1),ne=(0,V.useRef)(new Map),[j,$]=(0,V.useState)(!1),[X,Q]=(0,V.useState)(new Set),be=(0,V.useCallback)(U=>{Q(ge=>{let pe=new Set(ge);return pe.has(U)?pe.delete(U):pe.add(U),pe})},[]),De=(0,V.useCallback)(U=>{Q(ge=>{let pe=new Set(ge);return U.some(ft=>!pe.has(ft))?U.forEach(ft=>pe.add(ft)):U.forEach(ft=>pe.delete(ft)),pe})},[]),ke=(0,V.useCallback)(U=>X.has(U),[X]),[ue,Ue]=(0,V.useState)(!1),[Tt,It]=(0,V.useState)(!1),[An,Jr]=(0,V.useState)(!1),[cr,ko]=(0,V.useState)(0),[Zr,Lt]=(0,V.useState)(0),ur=d_(),[Fn,Si]=(0,V.useState)(null),[Ci,$a]=(0,V.useState)(()=>ms(i.merged).isTrusted),[Ws,ao]=xp(iS),[go,ho]=(0,V.useState)(null),[ve,yo]=(0,V.useState)(!0),[Vs,To]=xp(aS),Ur=!!Vs,$s=kC()?.overflowingIds.size??0,qa=$s>0||!ve;(0,V.useEffect)(()=>{qa&&To(!0)},[qa,$s,To]);let[dr,xo]=(0,V.useState)(""),[Yi,Xi]=(0,V.useState)(""),[jo,en]=(0,V.useState)(!0),wr=(0,V.useMemo)(()=>({defaultText:dr,warningText:Yi}),[dr,Yi]),{bannerText:bi}=um(wr),Qi=r.getExtensionLoader();Qi.setRequestConsent(U=>wS(U,mr)),Qi.setRequestSetting();let{addConfirmUpdateExtensionRequest:mr,confirmUpdateExtensionRequests:zo}=SC(),{extensionsUpdateState:Ji,extensionsUpdateStateInternal:Zi,dispatchExtensionStateUpdate:qs}=CC(Qi,x.addItem,r.getEnableExtensionReloading()),[es,ts]=(0,V.useState)(!1),[tn,Ei]=(0,V.useState)(null),Ri=(0,V.useCallback)(U=>{ts(!0),Ei(U??null)},[]),Ks=(0,V.useCallback)(()=>{ts(!1),Ei(null)},[]),[Gn,js]=(0,V.useState)(!1),[se,re]=(0,V.useState)(),[le,xe]=(0,V.useState)(),[Te,he]=(0,V.useState)(),Re=(0,V.useCallback)((U,ge,pe)=>{re(U),xe(ge),he(pe),js(!0)},[]),Et=(0,V.useCallback)(()=>{js(!1),re(void 0),xe(void 0),he(void 0)},[]),Qe=(0,V.useCallback)(()=>q(U=>!U),[]),[ct,Ho]=(0,V.useState)(r.getModel()),[Gr,H]=(0,V.useState)(void 0),[Ie,ot]=(0,V.useState)(()=>{let U=r.getQuotaRemaining(),ge=r.getQuotaLimit(),pe=r.getQuotaResetTime();return U!==void 0||ge!==void 0||pe!==void 0?{remaining:U,limit:ge,resetTime:pe}:void 0}),[xt,it]=(0,V.useState)(void 0),[st,dt]=(0,V.useState)(!1),Ao=Jm(r),{inputHistory:wo,addInput:Fo,initializeFromLogger:pr}=u_(),{columns:Je,rows:St}=ci(),{stdin:Nt,setRawMode:Xt}=dl(),{stdout:Yo}=ml(),mt=tC(),{stats:_o}=er(),wn=i_(r.getTargetDir()),on=(0,V.useRef)(null),rn=(0,V.useRef)(null),nn=3;(0,V.useEffect)(()=>{(async()=>{r.isInitialized()||await r.initialize(),dt(!0),nx.flush(r),YC(r);let ge=s?pf.Resume:pf.Startup,pe=await r.getHookSystem()?.fireSessionStartEvent(ge);if(pe){let Ae=pe.getAdditionalContext(),ft=r.getGeminiClient();Ae&&ft&&await ft.addHistory({role:"user",parts:[{text:`<hook_context>${Ae}</hook_context>`}]})}$x(r).catch(Ae=>{de.warn("Background summary generation failed:",Ae)})})();let U=async()=>{ls(),await Promise.all(Array.from(ne.current.keys()).map(pe=>lo.kill(pe))),await(await Zs.getInstance()).disconnect(),await r?.getHookSystem()?.fireSessionEndEvent(wx.Exit)};return ds(U),()=>{oa(U),U().catch(ge=>de.error("Error during cleanup:",ge))}},[r,s]),(0,V.useEffect)(()=>rS(x.addItem,Si),[x.addItem]),(0,V.useEffect)(()=>{let U=()=>{Ho(r.getModel())},ge=pe=>{ot({remaining:pe.remaining,limit:pe.limit,resetTime:pe.resetTime})};return Se.on(Ge.ModelChanged,U),Se.on(Ge.QuotaChanged,ge),()=>{Se.off(Ge.ModelChanged,U),Se.off(Ge.QuotaChanged,ge)}},[r]),(0,V.useEffect)(()=>{let U=()=>{Lt(Ae=>Ae+1)},ge=()=>{$(!0)},pe=Ae=>{ho(Ae.agents)};return Se.on(Ge.SettingsChanged,U),Se.on(Ge.AdminSettingsChanged,ge),Se.on(Ge.AgentsDiscovered,pe),()=>{Se.off(Ge.SettingsChanged,U),Se.off(Ge.AdminSettingsChanged,ge),Se.off(Ge.AgentsDiscovered,pe)}},[i]);let{errorCount:sn,clearErrorCount:os}=xI(),Wn=Xv(Je,r),{inputWidth:Vn,suggestionsWidth:Zl}=(0,V.useMemo)(()=>{let{inputWidth:U,suggestionsWidth:ge}=XI(Wn);return{inputWidth:U,suggestionsWidth:ge}},[Wn]),ec=Math.max(St*4,100),Ka=(0,V.useCallback)(()=>i.merged.general.preferredEditor,[i.merged.general.preferredEditor]),Ii=ca({initialText:"",viewport:{height:10,width:Vn},stdin:Nt,setRawMode:Xt,escapePastedPaths:!0,shellModeActive:ue,getPreferredEditor:Ka}),Cp=(0,V.useRef)(Ii);(0,V.useEffect)(()=>{Cp.current=Ii},[Ii]);let ph=(0,V.useCallback)(U=>{Cp.current.setText(U)},[]);(0,V.useEffect)(()=>{pr(Ao)},[Ao,pr]),KC({addConfirmUpdateExtensionRequest:mr,addItem:x.addItem});let Qt=(0,V.useCallback)(()=>{!S&&!r.getUseTerminalBuffer()&&(Yo.write(Ym.clearTerminal),ko(U=>U+1))},[ko,S,Yo,r]),bp=Zu(S,r.getScreenReader()),Ep=(0,V.useCallback)(()=>{bp&&(Ju(),as(),Ja(),mt.rerender()),cl.enableSupportedModes(),Qt()},[Qt,bp,mt]),[fh,__]=(0,V.useState)(null),{isEditorDialogOpen:tc,openEditorDialog:oc,handleEditorSelect:gh,exitEditorDialog:hh}=Vv(i,__,x.addItem);(0,V.useEffect)(()=>(Se.on(Ge.ExternalEditorClosed,Ep),Se.on(Ge.RequestEditorSelection,oc),()=>{Se.off(Ge.ExternalEditorClosed,Ep),Se.off(Ge.RequestEditorSelection,oc)}),[Ep,oc]),(0,V.useEffect)(()=>{!(i.merged.ui.hideBanner||r.getScreenReader())&&jo&&bi&&Qt()},[jo,bi,i,r,Qt]);let{isSettingsDialogOpen:Rp,openSettingsDialog:yh,closeSettingsDialog:Th}=$v(),{isThemeDialogOpen:rc,openThemeDialog:xh,closeThemeDialog:hu,handleThemeSelect:Ip,handleThemeHighlight:Sh}=Bv(i,W,x.addItem,n.themeError,Qt);f_(Ip,r,Qt);let{authState:$n,setAuthState:Xo,authError:Ch,onAuthError:Wr,apiKeyDefaultValue:bh,reloadApiKey:Eh,accountSuspensionInfo:Rh,setAccountSuspensionInfo:Ih}=vR(i,r,n.authError,n.accountSuspensionInfo),[vh,zs]=(0,V.useState)({});(0,V.useEffect)(()=>{$n==="authenticated"&&vh.requiresRestart&&(Xo("awaiting_login_restart"),zs({}))},[$n,vh,Xo]);let{proQuotaRequest:nc,handleProQuotaChoice:Ah,validationRequest:yu,handleValidationChoice:wh,overageMenuRequest:Tu,handleOverageMenuChoice:_h,emptyWalletRequest:xu,handleEmptyWalletChoice:Dh}=Gv({config:r,historyManager:x,userTier:Gr,paidTier:xt,settings:i,setModelSwitchedFromQuotaError:Jr,onShowAuthSelection:()=>Xo("updating"),errorVerbosity:i.merged.ui.errorVerbosity}),ic=$n==="updating",ja=$n==="unauthenticated"&&i.merged.security.auth.selectedType!==qe.USE_GEMINI,D_=r.getGeminiClient()?.isInitialized(),{loadHistoryForResume:M_,isResuming:vp}=s_({config:r,historyManager:x,refreshStatic:Qt,isGeminiClientInitialized:D_,setQuittingMessages:M,resumedSessionData:s,isAuthenticating:ja}),{isSessionBrowserOpen:Ap,openSessionBrowser:Su,closeSessionBrowser:Mh,handleResumeSession:Ph,handleDeleteSession:Oh}=BC(r,M_),Lh=(0,V.useCallback)(async U=>{await Oh(U)},[Oh]),Nh=(0,V.useCallback)(async(U,ge)=>{if(U){let pe=r.getContentGeneratorConfig()?.authType??"unknown";U===qe.LOGIN_WITH_GOOGLE?zs({requiresRestart:!0}):zs({}),await ed(),i.setValue(ge,"security.auth.selectedType",U);try{r.setRemoteAdminSettings(void 0),await r.refreshAuth(U),Xo("authenticated"),Js(r,new ox(pe,U))}catch(Ae){if(Ae instanceof cT)return;if(Ae instanceof rd){Wr(Vr(Ae));return}Wr(`Failed to authenticate: ${Ae instanceof Error?Ae.message:String(Ae)}`);return}U===qe.LOGIN_WITH_GOOGLE&&r.isBrowserLaunchSuppressed()&&(_r(`
112
+ Please use the permissions command to modify their trust level.`);let p=e.getWorkspaceContext();if(m.length>0){let y=vf(p,m);f.push(...y.added),h.push(...y.errors)}d.length>0?(de.log("Creating custom dialog with undecidedDirs:",d),r((0,c_.jsx)(uC,{folders:d,onComplete:()=>{r(null),e.clearPendingIncludeDirectories()},trustedDirs:f,errors:h,finishAddingDirectories:sh,config:e,addItem:n}))):(f.length>0||h.length>0)&&(sh(e,n,f,h),e.clearPendingIncludeDirectories())},[t,e,n,r])}var zi=C(z(),1);function u_(){let[e,t]=(0,zi.useState)([]),[o,r]=(0,zi.useState)([]),[n,s]=(0,zi.useState)([]),[i,a]=(0,zi.useState)(!1),d=(0,zi.useCallback)((h,p)=>{let y=[...h,...p],g=[];if(y.length>0){g.push(y[0]);for(let x=1;x<y.length;x++)y[x]!==y[x-1]&&g.push(y[x])}t(g.reverse())},[]),m=(0,zi.useCallback)(async h=>{if(!(i||!h))try{let p=await h.getPreviousUserMessages()||[];r(p),d([],p),a(!0)}catch(p){de.warn("Failed to initialize input history from logger:",p),r([]),d([],[]),a(!0)}},[i,d]),f=(0,zi.useCallback)(h=>{let p=h.trim();p&&s(y=>{let g=[...y,p];return r(x=>(d(g.slice().reverse(),x),x)),g})},[d]);return{inputHistory:e,addInput:f,initializeFromLogger:m}}var Va=C(z(),1);var d_=()=>{let[e,t]=(0,Va.useState)([]),o=(0,Va.useRef)(new Map),r=(0,Va.useRef)(new Set);return(0,Va.useEffect)(()=>{let n=r.current,s=o.current,i=d=>{let m=`${d.hookName}:${d.eventName}`,f=Date.now();s.has(m)||s.set(m,[]),s.get(m).push(f),t(h=>[...h,{name:d.hookName,eventName:d.eventName,source:d.source,index:d.hookIndex,total:d.totalHooks}])},a=d=>{let m=`${d.hookName}:${d.eventName}`,f=s.get(m),h=f?.shift();f&&f.length===0&&s.delete(m);let p=Date.now(),y=h?p-h:Di,g=Di-y,x=()=>{t(S=>{let I=S.findIndex(E=>E.name===d.hookName&&E.eventName===d.eventName);if(I===-1)return S;let A=[...S];return A.splice(I,1),A})};if(g>0){let S=setTimeout(()=>{x(),n.delete(S)},g);n.add(S)}else x()};return Se.on(Ge.HookStart,i),Se.on(Ge.HookEnd,a),()=>{Se.off(Ge.HookStart,i),Se.off(Ge.HookEnd,a),n.forEach(clearTimeout),n.clear()}},[]),e};var Us=C(z(),1);function m_({backgroundTasks:e,backgroundTaskCount:t,isBackgroundTaskVisible:o,activePtyId:r,embeddedShellFocused:n,setEmbeddedShellFocused:s,terminalHeight:i}){let[a,d]=(0,Us.useState)(!1),[m,f]=(0,Us.useState)(null);(0,Us.useEffect)(()=>{e.size===0?(m!==null&&f(null),a&&d(!1)):(m===null||!e.has(m))&&f(e.keys().next().value??null)},[e,m,t,a]),(0,Us.useEffect)(()=>{if(n){let p=!!r,y=o&&e.size>0;!p&&!y&&s(!1)}},[o,e,n,t,r,s]);let h=(0,Us.useMemo)(()=>o&&e.size>0?Math.max(Math.floor(i*.3),5):0,[o,e.size,i]);return{isBackgroundTaskListOpen:a,setIsBackgroundTaskListOpen:d,activeBackgroundTaskPid:m,setActiveBackgroundTaskPid:f,backgroundTaskHeight:h}}var p_=C(z(),1);function f_(e,t,o){let r=Ke(),{subscribe:n,unsubscribe:s,queryTerminalBackground:i}=Km();(0,p_.useEffect)(()=>{if(r.merged.ui.autoThemeSwitching===!1||t.getTerminalBackground()===void 0)return;let a=setInterval(()=>{let m=r.merged.ui.theme;at.isDefaultTheme(m)&&i()},r.merged.ui.terminalBackgroundPollingInterval*1e3),d=m=>{let f=/^rgb:([0-9a-fA-F]{1,4})\/([0-9a-fA-F]{1,4})\/([0-9a-fA-F]{1,4})$/.exec(m);if(!f)return;let h=DS(f[1],f[2],f[3]);if(!h)return;let p=t.getTerminalBackground(),y=yS(h),g=r.merged.ui.theme,x=_S(g,y,nl.name,SS.name);if(p===h){x&&e(x,"User");return}t.setTerminalBackground(h),at.setTerminalBackground(h),x?e(x,"User"):o()};return n(d),()=>{clearInterval(a),s(d)}},[r.merged.ui.theme,r.merged.ui.autoThemeSwitching,r.merged.ui.terminalBackgroundPollingInterval,t,e,n,s,i,o])}var Gs=C(z(),1);function xp(e){let[t,o]=(0,Gs.useState)(null),r=(0,Gs.useRef)(null),n=(0,Gs.useCallback)(s=>{o(s),r.current&&clearTimeout(r.current),s!==null&&(r.current=setTimeout(()=>{o(null)},e))},[e]);return(0,Gs.useEffect)(()=>()=>{r.current&&clearTimeout(r.current)},[]),[t,n]}var Ti=C(z(),1);import In from"node:process";function g_({handleWarning:e,setRawMode:t,refreshStatic:o,setForceRerenderKey:r,shouldUseAlternateScreen:n}){let[s,i]=(0,Ti.useState)(0),a=(0,Ti.useRef)(null),d=(0,Ti.useRef)(null);return(0,Ti.useEffect)(()=>()=>{a.current&&(clearTimeout(a.current),a.current=null),d.current&&(In.off("SIGCONT",d.current),d.current=null)},[]),(0,Ti.useEffect)(()=>{a.current&&(clearTimeout(a.current),a.current=null);let f=Ee("app.suspend");if(s>1){if(i(0),In.platform==="win32"){e(`${f} suspend is not supported on Windows.`);return}n&&(WT(),Qu(),_r("\x1B[2J\x1B[H")),_r("\x1B[?25h"),ls(),qS(),In.stdin.isTTY&&In.stdin.setRawMode(!1),t(!1);let h=()=>{try{In.stdin.isTTY&&(In.stdin.setRawMode(!0),In.stdin.resume(),In.stdin.ref()),t(!0),n&&(Ju(),Ja(),_r("\x1B[2J\x1B[H")),cl.enableSupportedModes(),_r("\x1B[?25l"),n&&as(),In.stdout.emit("resize"),setImmediate(()=>{o(),r(p=>p+1)})}finally{d.current===h&&(d.current=null)}};d.current&&In.off("SIGCONT",d.current),d.current=h,In.once("SIGCONT",h),In.kill(0,"SIGTSTP")}else if(s>0){let h=Ee("edit.undo");e(`Press ${f} again to suspend. Undo has moved to ${h}.`),a.current=setTimeout(()=>{i(0),a.current=null},Di)}},[s,e,t,o,r,n]),{handleSuspend:(0,Ti.useCallback)(()=>{i(f=>f+1)},[])}}var xi=C(z(),1);var CZ=C(z(),1);var BN=48,kN=64,HN=180,ah="\x07",FN="\x1B]9;",UN="\x1B]777;notify;",x_=" | ";function Sp(e){let t=Co(e.title,BN),o=e.subtitle?Co(e.subtitle,kN):void 0,r=Co(e.body,HN);return{title:t||"Gemini CLI",subtitle:o||void 0,body:r||"Open Gemini CLI for details."}}function lh(e){return e.type==="attention"?Sp({title:"Gemini CLI needs your attention",subtitle:e.heading??"Action required",body:e.detail??"Open Gemini CLI to continue."}):Sp({title:"Gemini CLI session complete",subtitle:"Run finished",body:e.detail??"The session finished successfully."})}function S_(e){return e.merged.general?.enableNotifications===!0}function C_(e){switch(e.merged.general?.notificationMethod){case"osc9":return"osc9";case"osc777":return"osc777";case"bell":return"bell";default:return"auto"}}function b_(e){let t=ll.getInstance();return t.isTmux()?`\x1BPtmux;${e.replace(/\x1b/g,"\x1B\x1B")}\x1B\\`:t.isScreen()?`\x1BP${e}\x1B\\`:e}function h_(e){let t=Sp(e),r=[t.title,t.subtitle,t.body].filter(Boolean).join(x_);_r(b_(`${FN}${r}${ah}`))}function y_(e){let t=Sp(e),r=[t.subtitle,t.body].filter(Boolean).join(x_),n=t.title.replace(/;/g,":"),s=r.replace(/;/g,":");_r(b_(`${UN}${n};${s}${ah}`))}function T_(){_r(ah)}async function ch(e,t,o="auto"){if(!e)return!1;try{if(o==="osc9")h_(t);else if(o==="osc777")y_(t);else if(o==="bell")T_();else{let r=ll.getInstance();r.isITerm2()?h_(t):r.isAlacritty()||r.isAppleTerminal()||r.isVSCodeTerminal()||r.isWindowsTerminal()?T_():y_(t)}return!0}catch(r){return de.debug("Failed to emit terminal notification:",r),!1}}function uh(e){return typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(t=>uh(t)).join("|"):"react-node"}function E_(e,t,o,r,n,s){let i=mm(e);if(i){let a=i.tool.confirmationDetails;if(a?.type==="ask_user"){let m=a.questions.at(0)?.header;return{key:`ask_user:${i.tool.callId}`,event:{type:"attention",heading:"Answer requested by agent",detail:m||"The agent needs your response to continue."}}}let d=a?.title||i.tool.description;return{key:`tool_confirmation:${i.tool.callId}`,event:{type:"attention",heading:"Approval required",detail:d?`Approve tool action: ${d}`:"Approve a pending tool action to continue."}}}return t?{key:`command_confirmation:${uh(t.prompt)}`,event:{type:"attention",heading:"Confirmation required",detail:"A command is waiting for your confirmation."}}:o?{key:`auth_consent:${uh(o.prompt)}`,event:{type:"attention",heading:"Authentication confirmation required",detail:"Authentication is waiting for your confirmation."}}:r?{key:`filesystem_permission_confirmation:${r.files.join("|")}`,event:{type:"attention",heading:"Filesystem permission required",detail:"Read-only path access is waiting for your confirmation."}}:n?{key:"extension_update_confirmation",event:{type:"attention",heading:"Extension update confirmation required",detail:"An extension update is waiting for your confirmation."}}:s?{key:"loop_detection_confirmation",event:{type:"attention",heading:"Loop detection confirmation required",detail:"A loop detection prompt is waiting for your response."}}:null}var GN=2e4;function R_({notificationsEnabled:e,notificationMethod:t,isFocused:o,hasReceivedFocusEvent:r,streamingState:n,hasPendingActionRequired:s,pendingHistoryItems:i,commandConfirmationRequest:a,authConsentRequest:d,permissionConfirmationRequest:m,hasConfirmUpdateExtensionRequests:f,hasLoopDetectionConfirmationRequest:h}){let p=(0,xi.useMemo)(()=>E_(i,a,d,m,f,h),[i,a,d,m,f,h]),y=(0,xi.useRef)(!1),g=(0,xi.useRef)(o),x=(0,xi.useRef)(n),S=(0,xi.useRef)(null);(0,xi.useEffect)(()=>{if(!e)return;let I=g.current;g.current=o;let A=p!==null,E=y.current;if(y.current=A,!A){S.current=null;return}if(r&&o)return;let v=!E,R=I&&!o,b=Date.now(),_=p.key,w=S.current,M=!w||w.key!==_,D=!!w&&w.key===_&&b-w.sentAt<GN;!(r?v||R||M:v||M)||D||(S.current={key:_,sentAt:b},ch(e,lh(p.event),t))},[o,r,e,t,p]),(0,xi.useEffect)(()=>{if(!e)return;let I=x.current;x.current=n,!(!(I==="responding"&&n==="idle")||r&&o||s)&&ch(e,lh({type:"session_complete",detail:"Gemini CLI finished responding."}),t)},[n,o,r,e,t,s])}var Hr=C(z(),1);var dh=1200,I_="focusUiEnabled";function v_(){let[e]=(0,Hr.useState)(()=>Go.get(I_)===!0),[t,o]=(0,Hr.useState)(!e),r=(0,Hr.useRef)(null),n=(0,Hr.useRef)(!e),s=(0,Hr.useCallback)(()=>{r.current&&(clearTimeout(r.current),r.current=null)},[]),i=(0,Hr.useCallback)(f=>{Go.set(I_,!f)},[]),a=(0,Hr.useCallback)(f=>{s(),n.current=f,o(f),i(f)},[s,i]),d=(0,Hr.useCallback)(()=>{s(),o(f=>{let h=!f;return n.current=h,i(h),h})},[s,i]),m=(0,Hr.useCallback)((f=dh)=>{n.current||(s(),o(!0),r.current=setTimeout(()=>{n.current||o(!1),r.current=null},f))},[s]);return(0,Hr.useEffect)(()=>()=>s(),[s]),{cleanUiDetailsVisible:t,setCleanUiDetailsVisible:a,toggleCleanUiDetailsVisible:d,revealCleanUiDetailsTemporarily:m}}var vn=C(P(),1);var VN=.89,$N=10,A_=e=>{let t=Bm(),o=Ze(),{config:r,initializationResult:n,resumedSessionData:s}=e,i=Ke(),{reset:a}=ps(),d=S_(i),m=C_(i),{setOptions:f,dumpCurrentFrame:h,startRecording:p,stopRecording:y}=(0,V.useContext)(QS),g=(0,V.useRef)(null),x=bC({chatRecordingService:r.getGeminiClient()?.getChatRecordingService()});Pv(x);let S=r.getUseAlternateBuffer(),[I,A]=(0,V.useState)(()=>r.getUseAlternateBuffer());(0,V.useEffect)(()=>{f({stickyHeadersInBackbuffer:I}),I?as():ls()},[I,f]);let[E,T]=(0,V.useState)(!1),[v,R]=(0,V.useState)(0),[b,_]=(0,V.useState)(""),[w,M]=(0,V.useState)(null),[D,N]=(0,V.useState)(!1),[O,W]=(0,V.useState)(n.themeError),[L,k]=(0,V.useState)(!1),[F,B]=(0,V.useState)(!1),[K,q]=(0,V.useState)(!1),[Z,Y]=(0,V.useState)(null),[oe,ce]=(0,V.useState)(!1),[G,ee]=(0,V.useState)(!1),te=(0,V.useRef)(()=>{}),ae=(0,V.useRef)(!1),ne=(0,V.useRef)(new Map),[j,$]=(0,V.useState)(!1),[X,Q]=(0,V.useState)(new Set),be=(0,V.useCallback)(U=>{Q(ge=>{let pe=new Set(ge);return pe.has(U)?pe.delete(U):pe.add(U),pe})},[]),De=(0,V.useCallback)(U=>{Q(ge=>{let pe=new Set(ge);return U.some(ft=>!pe.has(ft))?U.forEach(ft=>pe.add(ft)):U.forEach(ft=>pe.delete(ft)),pe})},[]),ke=(0,V.useCallback)(U=>X.has(U),[X]),[ue,Ue]=(0,V.useState)(!1),[Tt,It]=(0,V.useState)(!1),[An,Jr]=(0,V.useState)(!1),[cr,ko]=(0,V.useState)(0),[Zr,Lt]=(0,V.useState)(0),ur=d_(),[Fn,Si]=(0,V.useState)(null),[Ci,$a]=(0,V.useState)(()=>ms(i.merged).isTrusted),[Ws,ao]=xp(iS),[go,ho]=(0,V.useState)(null),[ve,yo]=(0,V.useState)(!0),[Vs,To]=xp(aS),Ur=!!Vs,$s=kC()?.overflowingIds.size??0,qa=$s>0||!ve;(0,V.useEffect)(()=>{qa&&To(!0)},[qa,$s,To]);let[dr,xo]=(0,V.useState)(""),[Yi,Xi]=(0,V.useState)(""),[jo,en]=(0,V.useState)(!0),wr=(0,V.useMemo)(()=>({defaultText:dr,warningText:Yi}),[dr,Yi]),{bannerText:bi}=um(wr),Qi=r.getExtensionLoader();Qi.setRequestConsent(U=>wS(U,mr)),Qi.setRequestSetting();let{addConfirmUpdateExtensionRequest:mr,confirmUpdateExtensionRequests:zo}=SC(),{extensionsUpdateState:Ji,extensionsUpdateStateInternal:Zi,dispatchExtensionStateUpdate:qs}=CC(Qi,x.addItem,r.getEnableExtensionReloading()),[es,ts]=(0,V.useState)(!1),[tn,Ei]=(0,V.useState)(null),Ri=(0,V.useCallback)(U=>{ts(!0),Ei(U??null)},[]),Ks=(0,V.useCallback)(()=>{ts(!1),Ei(null)},[]),[Gn,js]=(0,V.useState)(!1),[se,re]=(0,V.useState)(),[le,xe]=(0,V.useState)(),[Te,he]=(0,V.useState)(),Re=(0,V.useCallback)((U,ge,pe)=>{re(U),xe(ge),he(pe),js(!0)},[]),Et=(0,V.useCallback)(()=>{js(!1),re(void 0),xe(void 0),he(void 0)},[]),Qe=(0,V.useCallback)(()=>q(U=>!U),[]),[ct,Ho]=(0,V.useState)(r.getModel()),[Gr,H]=(0,V.useState)(void 0),[Ie,ot]=(0,V.useState)(()=>{let U=r.getQuotaRemaining(),ge=r.getQuotaLimit(),pe=r.getQuotaResetTime();return U!==void 0||ge!==void 0||pe!==void 0?{remaining:U,limit:ge,resetTime:pe}:void 0}),[xt,it]=(0,V.useState)(void 0),[st,dt]=(0,V.useState)(!1),Ao=Jm(r),{inputHistory:wo,addInput:Fo,initializeFromLogger:pr}=u_(),{columns:Je,rows:St}=ci(),{stdin:Nt,setRawMode:Xt}=dl(),{stdout:Yo}=ml(),mt=tC(),{stats:_o}=er(),wn=i_(r.getTargetDir()),on=(0,V.useRef)(null),rn=(0,V.useRef)(null),nn=3;(0,V.useEffect)(()=>{(async()=>{r.isInitialized()||await r.initialize(),dt(!0),nx.flush(r),YC(r);let ge=s?pf.Resume:pf.Startup,pe=await r.getHookSystem()?.fireSessionStartEvent(ge);if(pe){let Ae=pe.getAdditionalContext(),ft=r.getGeminiClient();Ae&&ft&&await ft.addHistory({role:"user",parts:[{text:`<hook_context>${Ae}</hook_context>`}]})}$x(r).catch(Ae=>{de.warn("Background summary generation failed:",Ae)})})();let U=async()=>{ls(),await Promise.all(Array.from(ne.current.keys()).map(pe=>lo.kill(pe))),await(await Zs.getInstance()).disconnect(),await r?.getHookSystem()?.fireSessionEndEvent(wx.Exit)};return ds(U),()=>{oa(U),U().catch(ge=>de.error("Error during cleanup:",ge))}},[r,s]),(0,V.useEffect)(()=>rS(x.addItem,Si),[x.addItem]),(0,V.useEffect)(()=>{let U=()=>{Ho(r.getModel())},ge=pe=>{ot({remaining:pe.remaining,limit:pe.limit,resetTime:pe.resetTime})};return Se.on(Ge.ModelChanged,U),Se.on(Ge.QuotaChanged,ge),()=>{Se.off(Ge.ModelChanged,U),Se.off(Ge.QuotaChanged,ge)}},[r]),(0,V.useEffect)(()=>{let U=()=>{Lt(Ae=>Ae+1)},ge=()=>{$(!0)},pe=Ae=>{ho(Ae.agents)};return Se.on(Ge.SettingsChanged,U),Se.on(Ge.AdminSettingsChanged,ge),Se.on(Ge.AgentsDiscovered,pe),()=>{Se.off(Ge.SettingsChanged,U),Se.off(Ge.AdminSettingsChanged,ge),Se.off(Ge.AgentsDiscovered,pe)}},[i]);let{errorCount:sn,clearErrorCount:os}=xI(),Wn=Xv(Je,r),{inputWidth:Vn,suggestionsWidth:Zl}=(0,V.useMemo)(()=>{let{inputWidth:U,suggestionsWidth:ge}=XI(Wn);return{inputWidth:U,suggestionsWidth:ge}},[Wn]),ec=Math.max(St*4,100),Ka=(0,V.useCallback)(()=>i.merged.general.preferredEditor,[i.merged.general.preferredEditor]),Ii=ca({initialText:"",viewport:{height:10,width:Vn},stdin:Nt,setRawMode:Xt,escapePastedPaths:!0,shellModeActive:ue,getPreferredEditor:Ka}),Cp=(0,V.useRef)(Ii);(0,V.useEffect)(()=>{Cp.current=Ii},[Ii]);let ph=(0,V.useCallback)(U=>{Cp.current.setText(U)},[]);(0,V.useEffect)(()=>{pr(Ao)},[Ao,pr]),KC({addConfirmUpdateExtensionRequest:mr,addItem:x.addItem});let Qt=(0,V.useCallback)(()=>{!S&&!r.getUseTerminalBuffer()&&(Yo.write(Ym.clearTerminal),ko(U=>U+1))},[ko,S,Yo,r]),bp=Zu(S,r.getScreenReader()),Ep=(0,V.useCallback)(()=>{bp&&(Ju(),as(),Ja(),mt.rerender()),cl.enableSupportedModes(),Qt()},[Qt,bp,mt]),[fh,__]=(0,V.useState)(null),{isEditorDialogOpen:tc,openEditorDialog:oc,handleEditorSelect:gh,exitEditorDialog:hh}=Vv(i,__,x.addItem);(0,V.useEffect)(()=>(Se.on(Ge.ExternalEditorClosed,Ep),Se.on(Ge.RequestEditorSelection,oc),()=>{Se.off(Ge.ExternalEditorClosed,Ep),Se.off(Ge.RequestEditorSelection,oc)}),[Ep,oc]),(0,V.useEffect)(()=>{!(i.merged.ui.hideBanner||r.getScreenReader())&&jo&&bi&&Qt()},[jo,bi,i,r,Qt]);let{isSettingsDialogOpen:Rp,openSettingsDialog:yh,closeSettingsDialog:Th}=$v(),{isThemeDialogOpen:rc,openThemeDialog:xh,closeThemeDialog:hu,handleThemeSelect:Ip,handleThemeHighlight:Sh}=Bv(i,W,x.addItem,n.themeError,Qt);f_(Ip,r,Qt);let{authState:$n,setAuthState:Xo,authError:Ch,onAuthError:Wr,apiKeyDefaultValue:bh,reloadApiKey:Eh,accountSuspensionInfo:Rh,setAccountSuspensionInfo:Ih}=vR(i,r,n.authError,n.accountSuspensionInfo),[vh,zs]=(0,V.useState)({});(0,V.useEffect)(()=>{$n==="authenticated"&&vh.requiresRestart&&(Xo("awaiting_login_restart"),zs({}))},[$n,vh,Xo]);let{proQuotaRequest:nc,handleProQuotaChoice:Ah,validationRequest:yu,handleValidationChoice:wh,overageMenuRequest:Tu,handleOverageMenuChoice:_h,emptyWalletRequest:xu,handleEmptyWalletChoice:Dh}=Gv({config:r,historyManager:x,userTier:Gr,paidTier:xt,settings:i,setModelSwitchedFromQuotaError:Jr,onShowAuthSelection:()=>Xo("updating"),errorVerbosity:i.merged.ui.errorVerbosity}),ic=$n==="updating",ja=$n==="unauthenticated"&&i.merged.security.auth.selectedType!==$e.USE_GEMINI,D_=r.getGeminiClient()?.isInitialized(),{loadHistoryForResume:M_,isResuming:vp}=s_({config:r,historyManager:x,refreshStatic:Qt,isGeminiClientInitialized:D_,setQuittingMessages:M,resumedSessionData:s,isAuthenticating:ja}),{isSessionBrowserOpen:Ap,openSessionBrowser:Su,closeSessionBrowser:Mh,handleResumeSession:Ph,handleDeleteSession:Oh}=BC(r,M_),Lh=(0,V.useCallback)(async U=>{await Oh(U)},[Oh]),Nh=(0,V.useCallback)(async(U,ge)=>{if(U){let pe=r.getContentGeneratorConfig()?.authType??"unknown";U===$e.LOGIN_WITH_GOOGLE?zs({requiresRestart:!0}):zs({}),await ed(),i.setValue(ge,"security.auth.selectedType",U);try{r.setRemoteAdminSettings(void 0),await r.refreshAuth(U),Xo("authenticated"),Js(r,new ox(pe,U))}catch(Ae){if(Ae instanceof cT)return;if(Ae instanceof rd){Wr(Vr(Ae));return}Wr(`Failed to authenticate: ${Ae instanceof Error?Ae.message:String(Ae)}`);return}U===$e.LOGIN_WITH_GOOGLE&&r.isBrowserLaunchSuppressed()&&(_r(`
113
113
  ----------------------------------------------------------------
114
114
  Logging in with Google... Restarting Gemini CLI to continue.
115
115
  ----------------------------------------------------------------
116
- `),await fr())}Xo("authenticated")},[i,r,Xo,Wr,zs]),Bh=(0,V.useCallback)(async U=>{try{if(Wr(null),!U.trim()){Wr("API key cannot be empty or whitespace only.");return}await bx(U),await Eh(),await r.refreshAuth(qe.USE_GEMINI),Xo("authenticated")}catch(ge){Wr(`Failed to save API key: ${ge instanceof Error?ge.message:String(ge)}`)}},[Xo,Wr,Eh,r]),kh=(0,V.useCallback)(()=>{Xo("updating")},[Xo]);(0,V.useEffect)(()=>{$n==="authenticated"&&(H(r.getUserTier()),it(r.getUserPaidTier()))},[r,$n]),(0,V.useEffect)(()=>{if(i.merged.security.auth.enforcedType&&i.merged.security.auth.selectedType&&i.merged.security.auth.enforcedType!==i.merged.security.auth.selectedType)Wr(`Authentication is enforced to be ${i.merged.security.auth.enforcedType}, but you are currently using ${i.merged.security.auth.selectedType}.`);else if(i.merged.security.auth.selectedType&&!i.merged.security.auth.useExternal){if(i.merged.security.auth.selectedType===qe.USE_GEMINI)return;let U=Dd(i.merged.security.auth.selectedType);U&&Wr(U)}},[i.merged.security.auth.selectedType,i.merged.security.auth.enforcedType,i.merged.security.auth.useExternal,Wr]);let{isModelDialogOpen:wp,openModelDialog:Hh,closeModelDialog:Fh}=qv(),{isVoiceModelDialogOpen:_p,openVoiceModelDialog:Cu,closeVoiceModelDialog:Uh}=Kv(),{toggleVimEnabled:P_}=gl(),Dp=(0,V.useRef)(()=>{}),[za,Ys]=(0,V.useState)(!1),{cleanUiDetailsVisible:bu,setCleanUiDetailsVisible:Gh,toggleCleanUiDetailsVisible:Wh,revealCleanUiDetailsTemporarily:Eu}=v_(),O_=(0,V.useMemo)(()=>({openAuthDialog:()=>Xo("updating"),openThemeDialog:xh,openEditorDialog:oc,openPrivacyNotice:()=>N(!0),openSettingsDialog:yh,openSessionBrowser:Su,openModelDialog:Hh,openVoiceModelDialog:Cu,openAgentConfigDialog:Re,openPermissionsDialog:Ri,quit:U=>{hu(),M(U),setTimeout(async()=>{await jn(),mh.exit(0)},100)},setDebugMessage:_,toggleCorgiMode:()=>T(U=>!U),toggleVoiceMode:()=>It(U=>!U),toggleDebugProfiler:Qe,dispatchExtensionStateUpdate:qs,addConfirmUpdateExtensionRequest:mr,toggleBackgroundTasks:()=>{te.current(),ae.current||(B(!0),ne.current.size>1?Dp.current(!0):Dp.current(!1))},toggleShortcutsHelp:()=>Ys(U=>!U),setText:ph}),[Xo,xh,hu,oc,yh,Su,Hh,Cu,Re,M,_,N,T,qs,Ri,mr,Qe,Ys,ph]),{handleSlashCommand:vi,slashCommands:Ru,pendingHistoryItems:Iu,commandContext:Vh,confirmationRequest:Xs}=Yv(r,i,x.addItem,x.clearItems,x.loadHistory,Qt,P_,k,O_,Zi,st,en,Y),[sc,$h]=(0,V.useState)(null),[vu,qh]=(0,V.useState)(null);(0,V.useEffect)(()=>{let U=ge=>{$h({prompt:ge.prompt,onConfirm:pe=>{$h(null),ge.onConfirm(pe)}})};return Se.on(Ge.ConsentRequest,U),()=>{Se.off(Ge.ConsentRequest,U)}},[]);let L_=(0,V.useCallback)(async()=>{x.addItem({type:"info",text:"Refreshing hierarchical memory (GEMINI.md or other context files)..."},Date.now());try{let U,ge;if(r.isJitContextEnabled())await r.getMemoryContextManager()?.refresh(),r.updateSystemInstructionIfInitialized(),U=ff(r.getUserMemory()),ge=r.getGeminiMdFileCount();else{let pe=await sd(r);U=ff(pe.memoryContent),ge=pe.fileCount}x.addItem({type:"info",text:`Memory reloaded successfully. ${U.length>0?`Loaded ${U.length} characters from ${ge} file(s)`:"No memory content found"}`},Date.now()),r.getDebugMode()&&de.log(`[DEBUG] Refreshed memory content in config: ${U.substring(0,200)}...`)}catch(U){let ge=Vr(U);x.addItem({type:"error",text:`Error refreshing memory: ${ge}`},Date.now()),de.warn("Error refreshing memory:",U)}},[r,x]),Mp=(0,V.useRef)(()=>{}),Kh=(0,V.useCallback)((U,ge=!1)=>{U?ee(!0):(ee(!1),Mp.current(!1,ge))},[]);(0,V.useEffect)(()=>{if(G){let U=x.history.findLast(pe=>pe.type==="user"),ge=wo.at(-1);(!U||typeof U.text=="string"&&U.text===ge)&&(Mp.current(!0),ee(!1))}},[G,wo,x.history]);let Au=(0,V.useRef)([]),[N_,jh]=(0,V.useState)(0),Pp=(0,V.useCallback)(()=>{if(Au.current.length===0)return null;let U=Au.current.join(`
116
+ `),await fr())}Xo("authenticated")},[i,r,Xo,Wr,zs]),Bh=(0,V.useCallback)(async U=>{try{if(Wr(null),!U.trim()){Wr("API key cannot be empty or whitespace only.");return}await bx(U),await Eh(),await r.refreshAuth($e.USE_GEMINI),Xo("authenticated")}catch(ge){Wr(`Failed to save API key: ${ge instanceof Error?ge.message:String(ge)}`)}},[Xo,Wr,Eh,r]),kh=(0,V.useCallback)(()=>{Xo("updating")},[Xo]);(0,V.useEffect)(()=>{$n==="authenticated"&&(H(r.getUserTier()),it(r.getUserPaidTier()))},[r,$n]),(0,V.useEffect)(()=>{if(i.merged.security.auth.enforcedType&&i.merged.security.auth.selectedType&&i.merged.security.auth.enforcedType!==i.merged.security.auth.selectedType)Wr(`Authentication is enforced to be ${i.merged.security.auth.enforcedType}, but you are currently using ${i.merged.security.auth.selectedType}.`);else if(i.merged.security.auth.selectedType&&!i.merged.security.auth.useExternal){if(i.merged.security.auth.selectedType===$e.USE_GEMINI)return;let U=Dd(i.merged.security.auth.selectedType);U&&Wr(U)}},[i.merged.security.auth.selectedType,i.merged.security.auth.enforcedType,i.merged.security.auth.useExternal,Wr]);let{isModelDialogOpen:wp,openModelDialog:Hh,closeModelDialog:Fh}=qv(),{isVoiceModelDialogOpen:_p,openVoiceModelDialog:Cu,closeVoiceModelDialog:Uh}=Kv(),{toggleVimEnabled:P_}=gl(),Dp=(0,V.useRef)(()=>{}),[za,Ys]=(0,V.useState)(!1),{cleanUiDetailsVisible:bu,setCleanUiDetailsVisible:Gh,toggleCleanUiDetailsVisible:Wh,revealCleanUiDetailsTemporarily:Eu}=v_(),O_=(0,V.useMemo)(()=>({openAuthDialog:()=>Xo("updating"),openThemeDialog:xh,openEditorDialog:oc,openPrivacyNotice:()=>N(!0),openSettingsDialog:yh,openSessionBrowser:Su,openModelDialog:Hh,openVoiceModelDialog:Cu,openAgentConfigDialog:Re,openPermissionsDialog:Ri,quit:U=>{hu(),M(U),setTimeout(async()=>{await jn(),mh.exit(0)},100)},setDebugMessage:_,toggleCorgiMode:()=>T(U=>!U),toggleVoiceMode:()=>It(U=>!U),toggleDebugProfiler:Qe,dispatchExtensionStateUpdate:qs,addConfirmUpdateExtensionRequest:mr,toggleBackgroundTasks:()=>{te.current(),ae.current||(B(!0),ne.current.size>1?Dp.current(!0):Dp.current(!1))},toggleShortcutsHelp:()=>Ys(U=>!U),setText:ph}),[Xo,xh,hu,oc,yh,Su,Hh,Cu,Re,M,_,N,T,qs,Ri,mr,Qe,Ys,ph]),{handleSlashCommand:vi,slashCommands:Ru,pendingHistoryItems:Iu,commandContext:Vh,confirmationRequest:Xs}=Yv(r,i,x.addItem,x.clearItems,x.loadHistory,Qt,P_,k,O_,Zi,st,en,Y),[sc,$h]=(0,V.useState)(null),[vu,qh]=(0,V.useState)(null);(0,V.useEffect)(()=>{let U=ge=>{$h({prompt:ge.prompt,onConfirm:pe=>{$h(null),ge.onConfirm(pe)}})};return Se.on(Ge.ConsentRequest,U),()=>{Se.off(Ge.ConsentRequest,U)}},[]);let L_=(0,V.useCallback)(async()=>{x.addItem({type:"info",text:"Refreshing hierarchical memory (GEMINI.md or other context files)..."},Date.now());try{let U,ge;if(r.isJitContextEnabled())await r.getMemoryContextManager()?.refresh(),r.updateSystemInstructionIfInitialized(),U=ff(r.getUserMemory()),ge=r.getGeminiMdFileCount();else{let pe=await sd(r);U=ff(pe.memoryContent),ge=pe.fileCount}x.addItem({type:"info",text:`Memory reloaded successfully. ${U.length>0?`Loaded ${U.length} characters from ${ge} file(s)`:"No memory content found"}`},Date.now()),r.getDebugMode()&&de.log(`[DEBUG] Refreshed memory content in config: ${U.substring(0,200)}...`)}catch(U){let ge=Vr(U);x.addItem({type:"error",text:`Error refreshing memory: ${ge}`},Date.now()),de.warn("Error refreshing memory:",U)}},[r,x]),Mp=(0,V.useRef)(()=>{}),Kh=(0,V.useCallback)((U,ge=!1)=>{U?ee(!0):(ee(!1),Mp.current(!1,ge))},[]);(0,V.useEffect)(()=>{if(G){let U=x.history.findLast(pe=>pe.type==="user"),ge=wo.at(-1);(!U||typeof U.text=="string"&&U.text===ge)&&(Mp.current(!0),ee(!1))}},[G,wo,x.history]);let Au=(0,V.useRef)([]),[N_,jh]=(0,V.useState)(0),Pp=(0,V.useCallback)(()=>{if(Au.current.length===0)return null;let U=Au.current.join(`
117
117
  `);return Au.current=[],jh(0),U},[]);(0,V.useEffect)(()=>{let U=(ge,pe)=>{pe!=="user_steering"&&pe!=="background_completion"||(Au.current.push(ge),jh(Ae=>Ae+1))};return r.injectionService.onInjection(U),()=>{r.injectionService.offInjection(U)}},[r]);let zh=(0,V.useMemo)(()=>r?.getAgentSessionInteractiveEnabled()?new Kx({config:r,getPreferredEditor:Ka}):void 0,[r,Ka]),B_=zh?uA({agent:zh,addItem:x.addItem,onCancelSubmit:Kh,isShellFocused:F,logger:Ao}):lA(r.getGeminiClient(),x.history,x.addItem,r,i,_,vi,ue,Ka,Wr,L_,An,Jr,Kh,B,Je,St,F,Pp),{streamingState:So,submitQuery:Ya,initError:Op,pendingHistoryItems:wu,thought:ac,cancelOngoingRequest:Yh,pendingToolCalls:k_,handleApprovalModeChange:Xh,activePtyId:rs,loopDetectionConfirmationRequest:_u,lastOutputTime:Lp,backgroundTaskCount:Np,isBackgroundTaskVisible:qn,toggleBackgroundTasks:Du,backgroundCurrentExecution:Qh,backgroundTasks:Kn,dismissBackgroundTask:Jh,retryStatus:H_}=B_,Do=(0,V.useMemo)(()=>[...Iu,...wu],[Iu,wu]);te.current=Du,ae.current=qn,ne.current=Kn;let{activeBackgroundTaskPid:Zh,setIsBackgroundTaskListOpen:Qs,isBackgroundTaskListOpen:ey,setActiveBackgroundTaskPid:ty,backgroundTaskHeight:Bp}=m_({backgroundTasks:Kn,backgroundTaskCount:Np,isBackgroundTaskVisible:qn,activePtyId:rs,embeddedShellFocused:F,setEmbeddedShellFocused:B,terminalHeight:St});Dp.current=Qs;let lc=(0,V.useRef)(0);(0,V.useEffect)(()=>{lc.current=Lp},[Lp]);let{shouldShowFocusHint:F_,inactivityStatus:oy}=gA({activePtyId:rs,lastOutputTime:Lp,streamingState:So,pendingToolCalls:k_,embeddedShellFocused:F,isInteractiveShellEnabled:r.isInteractiveShellEnabled()}),ry=oy==="action_required",ny=oy==="silent_working",U_=(0,V.useCallback)(U=>{Xh(U),bu||Eu(dh)},[Xh,bu,Eu]),{isMcpReady:cc}=o_(r),Mu=(0,V.useMemo)(()=>Do.some(U=>U.type==="compression"&&U.compression.isPending),[Do]),{messageQueue:Pu,addMessage:Ou,clearQueue:iy,getQueuedMessagesText:sy,popAllMessages:ay}=t_({isConfigInitialized:st,streamingState:So,submitQuery:Ya,isMcpReady:cc,isCompressing:Mu});Mp.current=(0,V.useCallback)((U=!0,ge=!1)=>{if(!ge&&Yd(Do))return;if(!U){ge&&Ii.setText("");return}let Ae=wo.at(-1)||"",ft=sy();ft&&(Ae=Ae?`${Ae}
118
118
 
119
- ${ft}`:ft,iy()),Ae&&Ii.setText(Ae)},[Ii,wo,sy,iy,Do]);let ly=(0,V.useCallback)(U=>{let ge=U.trim();ge&&(r.injectionService.addInjection(ge,"user_steering"),x.addItem({type:"hint",text:ge}))},[r,x]),uc=(0,V.useCallback)(async U=>{a(),To(null),ve||(yo(!0),S||Qt());let ge=gr(U.trim()),pe=So==="idle",Ae=So==="responding"||Uf(Do);if(ge&&Ae){let{commandToExecute:is}=al(U,Ru??[]);if(is?.isSafeConcurrent){vi(U),Fo(U);return}}if(r.isModelSteeringEnabled()&&Ae&&!ge){ly(U),Fo(U);return}let ft=st&&cc;if(ge&&st||!Mu&&pe&&ft){if(!ge){let is=await US(U,r);if(is.length>0){qh({files:is,onComplete:cD=>{qh(null),cD.allowed&&is.forEach(uD=>r.getWorkspaceContext().addReadOnlyPath(uD)),Ya(U)}}),Fo(U);return}}Ya(U)}else pe&&!Mu&&!ft&&Pu.length===0&&Se.emitFeedback("info",st?"Waiting for MCP servers to initialize... Slash commands are still available and prompts will be queued.":"Initializing... Prompts will be queued."),Ou(U);Fo(U)},[Ou,Fo,Ya,vi,Ru,cc,So,Mu,Pu.length,Do,r,ve,yo,S,Qt,a,ly,st,To]),cy=(0,V.useCallback)(()=>{a(),To(null),x.clearItems(),os(),Qt()},[x,os,Qt,a,To]),{handleInput:uy}=mA(Ii,uc),kp=!Op&&!L&&!vp&&(So==="idle"||So==="responding"||So==="waiting_for_confirmation")&&!nc,dc=(0,V.useRef)(null);(0,V.useEffect)(()=>()=>{dc.current?.disconnect()},[]);let[Lu,G_]=(0,V.useState)(0),[dy,W_]=(0,V.useState)(0);(0,V.useLayoutEffect)(()=>{!oe&&Lu>0&&W_(Lu)},[oe,Lu]);let Hp=oe&&dy>0?dy:Lu,my=(0,V.useCallback)(U=>{if(dc.current&&(dc.current.disconnect(),dc.current=null),U){let ge=new Zn(pe=>{let Ae=pe[0];if(Ae){let ft=Math.round(Ae.contentRect.height);G_(is=>ft!==is?ft:is)}});ge.observe(U),dc.current=ge}},[]),Fp=Math.max(0,St-Hp-Bp-1);r.setShellExecutionConfig({terminalWidth:Math.floor(Je*VN),terminalHeight:Math.max(Math.floor(Fp-$N),1),pager:i.merged.tools.shell.pager,showColor:i.merged.tools.shell.showColor,sanitizationConfig:r.sanitizationConfig,sandboxManager:r.sandboxManager});let{isFocused:Nu,hasReceivedFocusEvent:V_}=rC(),py=(0,V.useMemo)(()=>{let U=i.merged.context.fileName;return U?Array.isArray(U)?U:[U]:AT()},[i.merged.context.fileName]),Up=(0,V.useMemo)(()=>r.getQuestion(),[r]),fy=(0,V.useRef)(!1),gy=r.getGeminiClient();(0,V.useEffect)(()=>{Up&&st&&!fy.current&&!ja&&!ic&&!rc&&!tc&&!D&&gy?.isInitialized?.()&&(uc(Up),fy.current=!0)},[Up,st,uc,ja,ic,rc,tc,D,gy]);let[$_,q_]=(0,V.useState)(!1),[Gp,K_]=(0,V.useState)(null);(0,V.useEffect)(()=>{(async()=>{let pe=(await Zs.getInstance()).getCurrentIde();K_(pe||null)})()},[]);let Wp=!!(Gp&&!r.getIdeMode()&&!i.merged.ide.hasSeenNudge&&!$_),[Bu,mc]=(0,V.useState)(!1),[hy,j_]=(0,V.useState)(!1),[yy,z_]=(0,V.useState)(!0),Ty=(0,V.useCallback)(U=>{U>2&&OT(r),U>1&&vi("/quit",void 0,void 0,!1)},[r,vi]),{pressCount:xy,handlePress:Sy}=Fl({windowMs:Di,onRepeat:Ty}),{pressCount:Cy,handlePress:by}=Fl({windowMs:Di,onRepeat:Ty}),[ku,Ey]=(0,V.useState)(),[Ry,Y_]=(0,V.useState)(!1),[Vp,X_]=(0,V.useState)(!1),[Iy,Ai]=xp(Di),{isFolderTrustDialogOpen:$p,discoveryResults:vy,handleFolderTrustSelect:Ay,isRestarting:wy}=hA(i,$a,x.addItem),qp=r.getPolicyUpdateConfirmationRequest(),[Kp,_y]=(0,V.useState)(!!qp),{needsRestart:Dy,restartReason:My}=EC(),Py=(0,V.useRef)(!0);l_(r,Ci,x,Y);let ns=(0,V.useRef)(null);(0,V.useEffect)(()=>{let U=Ae=>{Ai({text:Ae.message,type:Ae.type})},ge=()=>{Ai({text:"Press Ctrl-S to enter selection mode to copy text.",type:"warning"})},pe=()=>{Ai({text:"Paste Timed out. Possibly due to slow connection.",type:"warning"})};return kt.on("transient-message",U),kt.on("selection-warning",ge),kt.on("paste-timeout",pe),()=>{kt.off("transient-message",U),kt.off("selection-warning",ge),kt.off("paste-timeout",pe),ns.current&&clearTimeout(ns.current)}},[Ai]);let jp=(0,V.useCallback)(U=>{Ai({text:U,type:"warning"})},[Ai]),{handleSuspend:Oy}=g_({handleWarning:jp,setRawMode:Xt,refreshStatic:Qt,setForceRerenderKey:R,shouldUseAlternateScreen:bp});(0,V.useEffect)(()=>{Dy&&X_(!0)},[Dy]),(0,V.useEffect)(()=>{if(Py.current){Py.current=!1;return}let U=setTimeout(()=>{Qt()},300);return()=>{clearTimeout(U)}},[Je,Qt]),(0,V.useEffect)(()=>{let U=lf.subscribe(Ey);return Ey(lf.get()),U},[]),(0,V.useEffect)(()=>{let U=()=>{mc(!0),yo(!1)};return kt.on("open-debug-console",U),()=>{kt.off("open-debug-console",U)}},[r]);let Ly=(0,V.useCallback)(U=>{Y_(U)},[]),Ny=(0,V.useCallback)(U=>{U.userSelection==="yes"?(vi("/ide install"),i.setValue("User","ide.hasSeenNudge",!0)):U.userSelection==="dismiss"&&i.setValue("User","ide.hasSeenNudge",!0),q_(!0)},[vi,i]),Q_=(0,V.useCallback)(U=>{if(i.merged.general.debugKeystrokeLogging&&de.log("[DEBUG] Keystroke:",JSON.stringify(U)),za&&t(U)&&Ys(!1),o["app.toggleMouseMode"](U))return A(Ae=>!Ae),I&&!S&&kt.emit("scroll-to-bottom"),!0;if(S&&o["app.toggleCopyMode"](U))return ce(!0),ls(),!0;if(o["basic.quit"](U))return Yh?.(),Sy(),!0;if(o["basic.exit"](U))return Cp.current.text.length>0?!1:(by(),!0);if(o["app.suspend"](U))Oy();else if(o["app.dumpFrame"](U)){let ft=`snapshot-${new Date().toISOString().replace(/[:.]/g,"-")}.json`;return h&&(h(ft),de.log(`Dumped frame to: ${ft}`)),!0}else if(o["app.startRecording"](U)){let ft=`recording-${new Date().toISOString().replace(/[:.]/g,"-")}.json`;return p&&(p(ft),g.current=ft,de.log(`Started recording to: ${ft}`)),!0}else{if(o["app.stopRecording"](U))return y&&(y(),de.log(`Stopped recording, saved to: ${g.current??"unknown"}`),g.current=null),!0;if(o["app.toggleCopyMode"](U)&&!S)return Ai({text:"Use Ctrl+O to expand and collapse blocks of content.",type:"warning"}),!0}let ge=()=>{To(!0);let Ae=Zb(x.history,Do);Ae.length>0&&De(Ae)},pe=!1;if(ve||(pe=!0,yo(!0),o["app.showMoreLines"](U)&&ge(),S||Qt()),o["app.showErrorDetails"](U))return i.merged.general.devtools?(async()=>{let{toggleDevToolsPanel:Ae}=await import("./devtoolsService-YXEESS76.js");await Ae(r,Bu,()=>mc(ft=>!ft),()=>mc(!0))})():mc(Ae=>!Ae),!0;if(o["app.showFullTodos"](U))return j_(Ae=>!Ae),!0;if(o["app.toggleMarkdown"](U))return z_(Ae=>{let ft=!Ae;return Qt(),ft}),!0;if(o["app.showIdeContextDetail"](U)&&r.getIdeMode()&&ku)return vi("/ide status"),!0;if(o["app.showMoreLines"](U)&&!pe)return yo(!1),ge(),Qt(),!0;if((o["app.focusShellInput"](U)||o["background.unfocusList"](U))&&(rs||qn&&Kn.size>0)){if(F){let ft=lc.current;return ns.current&&clearTimeout(ns.current),ns.current=setTimeout(()=>{lc.current===ft?B(!1):Ai({text:"Use Shift+Tab to unfocus",type:"warning"})},150),!1}return Date.now()-lc.current>=100&&!rs&&!qn?(ns.current&&clearTimeout(ns.current),Du(),B(!0),Kn.size>1&&Qs(!0),!0):(B(!0),!0)}else{if(o["app.unfocusShellInput"](U)||o["background.unfocus"](U))return F?(B(!1),!0):!1;if(o["background.toggle"](U))return rs?Qh():(Du(),!qn&&Kn.size>0?(B(!0),Kn.size>1&&Qs(!0)):B(!1)),!0;if(o["background.toggleList"](U))return Kn.size>0&&qn&&(F||B(!0),Qs(!0)),!0}return!1},[ve,yo,mc,r,ku,Sy,by,vi,Yh,rs,Oy,F,i.merged.general.debugKeystrokeLogging,Qt,ce,ns,S,za,Qh,Du,Kn,qn,Qs,lc,Ai,i.merged.general.devtools,Bu,To,o,t,x.history,Do,De,h,p,y,I]);me(Q_,{isActive:!0,priority:!0}),me(U=>o["scroll.up"](U)||o["scroll.down"](U)||o["scroll.pageUp"](U)||o["scroll.pageDown"](U)||o["scroll.home"](U)||o["scroll.end"](U)?!1:(ce(!1),I&&as(),!0),{isActive:oe,priority:200}),(0,V.useEffect)(()=>{if(i.merged.ui.hideWindowTitle)return;let U=Xm({streamingState:So,thoughtSubject:ac?.subject,isConfirming:!!Xs||ry,isSilentWorking:ny,folderName:WN(r.getTargetDir()),showThoughts:!!i.merged.ui.showStatusInTitle,useDynamicTitle:i.merged.ui.dynamicWindowTitle});rn.current!==U&&(rn.current=U,Yo.write(`\x1B]0;${U}\x07`))},[So,ac,Xs,ry,ny,i.merged.ui.showStatusInTitle,i.merged.ui.dynamicWindowTitle,i.merged.ui.hideWindowTitle,r,Yo]),(0,V.useEffect)(()=>{let U=pe=>{let Ae;switch(pe.severity){case"error":Ae="error";break;case"warning":Ae="warning";break;case"info":Ae="info";break;default:throw new Error(`Unexpected severity for user feedback: ${pe.severity}`)}x.addItem({type:Ae,text:pe.message},Date.now()),pe.error&&de.warn(`[Feedback Details for "${pe.message}"]`,pe.error)},ge=pe=>{x.addItem({type:"info",text:pe.message,source:pe.hookName},Date.now())};return Se.on(Ge.UserFeedback,U),Se.on(Ge.HookSystemMessage,ge),Se.drainBacklogs(),()=>{Se.off(Ge.UserFeedback,U),Se.off(Ge.HookSystemMessage,ge)}},[x]);let By=e.version.includes("nightly"),zp=$n==="awaiting_login_restart",ky=i.merged.security.auth.selectedType===qe.USE_VERTEX_AI?"Authenticating to Vertex AI in Cloud Shell requires a restart to apply project settings.":void 0,Hy=Wp||$p||Kp||j||!!Xs||!!sc||!!vu||!!Z||zo.length>0||!!_u||rc||Rp||wp||_p||Gn||es||ja||ic||tc||D||Vp||!!nc||!!yu||!!Tu||!!xu||Ap||$n==="awaiting_api_key_input"||zp||!!go,J_=(0,V.useMemo)(()=>Yd(Do),[Do]),Fy=zo.length>0,Uy=!!_u,pc=J_||!!Xs||!!sc||Fy||Uy||!!nc||!!yu||!!Tu||!!xu||!!Z,Hu=i.merged.ui.loadingPhrases,Z_=Hu==="tips"||Hu==="all",eD=Hu==="witty"||Hu==="all",tD=(!F||qn)&&So==="responding"&&!pc,Fu=0;if(ur.length>0&&i.merged.hooksConfig.notifications){let U=ur.length>1?"Executing Hooks":"Executing Hook",ge=ur.map(pe=>pe.name+(pe.index&&pe.total&&pe.total>1?` (${pe.index}/${pe.total})`:"")).join(", ");Fu=U.length+ge.length+10}else tD?Fu=(ac?.subject||"Waiting for model...").length+25:pc&&(Fu=35);let oD=Je-Fu-5,{elapsedTime:Gy,currentLoadingPhrase:Wy,currentTip:Vy,currentWittyPhrase:$y}=fA({streamingState:So,shouldShowFocusHint:F_,retryStatus:H_,showTips:Z_,showWit:eD,customWittyPhrases:i.merged.ui.customWittyPhrases,errorVerbosity:i.merged.ui.errorVerbosity,maxLength:oD}),Yp=r.isPlanEnabled()&&So==="idle"&&!pc,qy=r_({config:r,addItem:x.addItem,onApprovalModeChange:U_,isActive:!F,allowPlanMode:Yp});R_({notificationsEnabled:d,notificationMethod:m,isFocused:Nu,hasReceivedFocusEvent:V_,streamingState:So,hasPendingActionRequired:pc,pendingHistoryItems:Do,commandConfirmationRequest:Xs,authConsentRequest:sc,permissionConfirmationRequest:vu,hasConfirmUpdateExtensionRequests:Fy,hasLoopDetectionConfirmationRequest:Uy});let Ky=kp&&So==="idle"&&!pc;(0,V.useEffect)(()=>{za&&!Ky&&Ys(!1)},[za,Ky,Ys]),(0,V.useEffect)(()=>{if(!st||!r.isModelSteeringEnabled()||So!=="idle"||!cc||Yd(Do))return;let U=Pp();U&&Ya([{text:nd(U)}])},[r,x,st,cc,So,Ya,Pp,Do,N_]);let rD=(0,V.useMemo)(()=>Xd(Do),[Do]),[jy,nD]=(0,V.useState)(r.getGeminiMdFileCount());(0,V.useEffect)(()=>{let U=ge=>{nD(ge.fileCount)};return Se.on(Ge.MemoryChanged,U),()=>{Se.off(Ge.MemoryChanged,U)}},[]),(0,V.useEffect)(()=>{let U=!0;return(async()=>{let[pe,Ae]=await Promise.all([r.getBannerTextNoCapacityIssues(),r.getBannerTextCapacityIssues()]);U&&(xo(pe),Xi(Ae),en(!0))})(),()=>{U=!1}},[r,Qt]);let iD=(0,V.useMemo)(()=>({buffer:Ii,userMessages:wo,shellModeActive:ue,showEscapePrompt:Ry,copyModeEnabled:oe,inputWidth:Vn,suggestionsWidth:Zl}),[Ii,wo,ue,Ry,oe,Vn,Zl]),sD=(0,V.useMemo)(()=>({userTier:Gr,stats:Ie,proQuotaRequest:nc,validationRequest:yu,overageMenuRequest:Tu,emptyWalletRequest:xu}),[Gr,Ie,nc,yu,Tu,xu]),aD=(0,V.useMemo)(()=>({history:x.history,historyManager:x,isThemeDialogOpen:rc,themeError:O,isAuthenticating:ja,isConfigInitialized:st,authError:Ch,accountSuspensionInfo:Rh,isAuthDialogOpen:ic,isAwaitingApiKeyInput:$n==="awaiting_api_key_input",isAwaitingLoginRestart:zp,loginRestartMessage:ky,apiKeyDefaultValue:bh,editorError:fh,isEditorDialogOpen:tc,showPrivacyNotice:D,mouseMode:I,corgiMode:E,debugMessage:b,quittingMessages:w,isSettingsDialogOpen:Rp,isSessionBrowserOpen:Ap,isModelDialogOpen:wp,isVoiceModelDialogOpen:_p,isAgentConfigDialogOpen:Gn,selectedAgentName:se,selectedAgentDisplayName:le,selectedAgentDefinition:Te,isPermissionsDialogOpen:es,permissionsDialogProps:tn,slashCommands:Ru,pendingSlashCommandHistoryItems:Iu,commandContext:Vh,commandConfirmationRequest:Xs,authConsentRequest:sc,confirmUpdateExtensionRequests:zo,loopDetectionConfirmationRequest:_u,permissionConfirmationRequest:vu,geminiMdFileCount:jy,streamingState:So,initError:Op,pendingGeminiHistoryItems:wu,thought:ac,isInputActive:kp,isVoiceModeEnabled:Tt,isResuming:vp,shouldShowIdePrompt:Wp,isFolderTrustDialogOpen:$p??!1,folderDiscoveryResults:vy,isPolicyUpdateDialogOpen:Kp,policyUpdateConfirmationRequest:qp,isTrustedFolder:Ci,constrainHeight:ve,showErrorDetails:Bu,showFullTodos:hy,ideContextState:ku,renderMarkdown:yy,ctrlCPressedOnce:xy>=1,ctrlDPressedOnce:Cy>=1,shortcutsHelpVisible:za,cleanUiDetailsVisible:bu,isFocused:Nu,elapsedTime:Gy,currentLoadingPhrase:Wy,currentTip:Vy,currentWittyPhrase:$y,historyRemountKey:cr,activeHooks:ur,messageQueue:Pu,queueErrorMessage:Ws,showApprovalModeIndicator:qy,allowPlanMode:Yp,currentModel:ct,contextFileNames:py,errorCount:sn,availableTerminalHeight:Fp,stableControlsHeight:Hp,mainAreaWidth:Wn,staticAreaMaxItemHeight:ec,staticExtraHeight:nn,dialogsVisible:Hy,pendingHistoryItems:Do,nightly:By,branchName:wn,sessionStats:_o,terminalWidth:Je,terminalHeight:St,mainControlsRef:my,rootUiRef:on,currentIDE:Gp,updateInfo:Fn,showIdeRestartPrompt:Vp,ideTrustRestartReason:My,isRestarting:wy,extensionsUpdateState:Ji,activePtyId:rs,backgroundTaskCount:Np,isBackgroundTaskVisible:qn,embeddedShellFocused:F,showDebugProfiler:K,customDialog:Z,transientMessage:Iy,bannerData:wr,bannerVisible:jo,terminalBackgroundColor:r.getTerminalBackground(),settingsNonce:Zr,backgroundTasks:Kn,activeBackgroundTaskPid:Zh,backgroundTaskHeight:Bp,isBackgroundTaskListOpen:ey,adminSettingsChanged:j,newAgents:go,showIsExpandableHint:Ur,hintMode:r.isModelSteeringEnabled()&&Uf(Do),hintBuffer:""}),[rc,O,ja,st,Ch,Rh,ic,fh,tc,D,I,E,b,w,Rp,Ap,wp,_p,Gn,se,le,Te,es,tn,Ru,Iu,Vh,Xs,sc,zo,_u,vu,jy,So,Op,wu,ac,kp,Tt,vp,Wp,$p,vy,Kp,qp,Ci,ve,Bu,hy,ku,yy,xy,Cy,za,bu,Nu,Gy,Wy,Vy,$y,cr,ur,Pu,Ws,qy,Yp,py,sn,Fp,Hp,Wn,ec,nn,Hy,Do,By,wn,_o,Je,St,my,on,Gp,Fn,Vp,My,wy,ct,Ji,rs,Np,qn,x,F,K,Z,bh,$n,zp,ky,Iy,wr,jo,r,Zr,Bp,ey,Zh,Kn,j,go,Ur]),zy=(0,V.useCallback)(()=>N(!1),[N]),lD=(0,V.useMemo)(()=>({handleThemeSelect:Ip,closeThemeDialog:hu,handleThemeHighlight:Sh,handleAuthSelect:Nh,setAuthState:Xo,onAuthError:Wr,handleEditorSelect:gh,exitEditorDialog:hh,exitPrivacyNotice:zy,closeSettingsDialog:Th,closeModelDialog:Fh,openVoiceModelDialog:Cu,closeVoiceModelDialog:Uh,openAgentConfigDialog:Re,closeAgentConfigDialog:Et,openPermissionsDialog:Ri,closePermissionsDialog:Ks,setShellModeActive:Ue,vimHandleInput:uy,handleIdePromptComplete:Ny,handleFolderTrustSelect:Ay,setIsPolicyUpdateDialogOpen:_y,setConstrainHeight:yo,onEscapePromptChange:Ly,refreshStatic:Qt,handleFinalSubmit:uc,handleClearScreen:cy,handleProQuotaChoice:Ah,handleValidationChoice:wh,handleOverageMenuChoice:_h,handleEmptyWalletChoice:Dh,openSessionBrowser:Su,closeSessionBrowser:Mh,handleResumeSession:Ph,handleDeleteSession:Lh,setQueueErrorMessage:ao,addMessage:Ou,popAllMessages:ay,handleApiKeySubmit:Bh,handleApiKeyCancel:kh,setBannerVisible:en,setShortcutsHelpVisible:Ys,setCleanUiDetailsVisible:Gh,toggleCleanUiDetailsVisible:Wh,revealCleanUiDetailsTemporarily:Eu,handleWarning:jp,setEmbeddedShellFocused:B,dismissBackgroundTask:Jh,setActiveBackgroundTaskPid:ty,setIsBackgroundTaskListOpen:Qs,setAuthContext:zs,dismissLoginRestart:()=>{zs({}),Xo("updating")},onHintInput:()=>{},onHintBackspace:()=>{},onHintClear:()=>{},onHintSubmit:()=>{},handleRestart:async()=>{if(mh.send){let U=r.getRemoteAdminSettings();U&&mh.send({type:"admin-settings-update",settings:U})}await fr()},handleNewAgentsSelect:async U=>{if(go&&U==="acknowledge"){let ge=r.getAgentRegistry();try{await Promise.all(go.map(pe=>ge.acknowledgeAgent(pe)))}catch(pe){de.error("Failed to acknowledge agents:",pe),x.addItem({type:"error",text:`Failed to acknowledge agents: ${Vr(pe)}`},Date.now())}}ho(null)},getPreferredEditor:Ka,clearAccountSuspension:()=>{Ih(null),Xo("updating")},setVoiceModeEnabled:U=>{It(U)}}),[Ip,hu,Sh,Nh,Xo,Wr,gh,hh,zy,Th,Fh,Cu,Uh,Re,Et,Ri,Ks,Ue,uy,Ny,Ay,_y,yo,Ly,Qt,uc,cy,Ah,wh,_h,Dh,Su,Mh,Ph,Lh,ao,Ou,ay,Bh,kh,en,Ys,Gh,Wh,Eu,jp,B,Jh,ty,Qs,zs,Ih,go,r,x,Ka,It]);return(0,vn.jsx)(xd.Provider,{value:aD,children:(0,vn.jsx)(MC.Provider,{value:sD,children:(0,vn.jsx)(OC.Provider,{value:iD,children:(0,vn.jsx)(Ff.Provider,{value:lD,children:(0,vn.jsx)(Td.Provider,{value:r,children:(0,vn.jsx)(jf.Provider,{value:{version:e.version,startupWarnings:e.startupWarnings||[]},children:(0,vn.jsx)(Bb,{config:r,toolCalls:rD,isExpanded:ke,toggleExpansion:be,toggleAllExpansion:De,children:(0,vn.jsx)(xg.Provider,{value:Nu,children:(0,vn.jsx)(hd,{mouseEventsEnabled:I,children:(0,vn.jsx)(vd,{children:(0,vn.jsx)(Dv,{},`app-${v}`)})})})})})})})})})})};var Fr=C(P(),1);var KN=200;async function Ute(e,t,o,r=process.cwd(),n,s){gI();let i=Zu(e.getUseAlternateBuffer(),e.getScreenReader()),a=i;a&&(as(),ds(()=>{ls()}));let{matchers:d,errors:m}=await sC();m.forEach(v=>{Se.emitFeedback("warning",v)});let f=await mx();jN(qN(r),t);let h=new kS({onNewMessage:v=>{Se.emitConsoleLog(v.type,v.content)},debugMode:e.getDebugMode()});h.patch();let{stdout:p,stderr:y}=GT(),g=!!process.env.SHPOOL_SESSION_NAME,x=()=>(Lm(),(0,Fr.jsx)(nC.Provider,{value:t,children:(0,Fr.jsx)(aC,{value:d,children:(0,Fr.jsx)(iC,{config:e,children:(0,Fr.jsx)(hd,{mouseEventsEnabled:a,children:(0,Fr.jsx)(Lv,{children:(0,Fr.jsx)(vd,{children:(0,Fr.jsx)(hl,{children:(0,Fr.jsx)(RE,{sessionId:e.getSessionId(),children:(0,Fr.jsx)(PC,{children:(0,Fr.jsx)(A_,{config:e,startupWarnings:o,version:f,resumedSessionData:n,initializationResult:s})})})})})})})})})}));g&&await new Promise(v=>setTimeout(v,100));let S=JS(process.env.DEBUG?(0,Fr.jsx)(w_.default.StrictMode,{children:(0,Fr.jsx)(x,{})}):(0,Fr.jsx)(x,{}),{stdout:p,stderr:y,stdin:process.stdin,exitOnCtrlC:!1,isScreenReaderEnabled:e.getScreenReader(),onRender:({renderTime:v})=>{v>KN&&LT(e,Math.round(v)),DC.reportFrameRendered()},standardReactLayoutTiming:i||e.getUseTerminalBuffer(),patchConsole:!1,alternateBuffer:i,terminalBuffer:e.getUseTerminalBuffer(),renderProcess:e.getUseRenderProcess()&&e.getUseTerminalBuffer(),incrementalRendering:t.merged.ui.incrementalRendering!==!1&&i&&!g,debugRainbow:t.merged.ui.debugRainbow===!0}),I;i&&(Ja(),I=()=>Qu(),ds(I)),e_(t).then(v=>{oS(v,t,e.getProjectRoot(),e.getSandboxEnabled())}).catch(v=>{e.getDebugMode()&&de.warn("Update check failed:",v)});let A=()=>S.unmount();ds(A);let E=Zx();ds(E);let T=()=>h.cleanup();ds(T);try{await S.waitUntilExit()}finally{try{oa(T),T()}catch(v){de.error("Error cleaning up console patcher:",v)}try{oa(A),S.unmount()}catch(v){de.error("Error unmounting Ink instance:",v)}try{oa(E),E()}catch(v){de.error("Error in TTY cleanup:",v)}if(I)try{oa(I),I()}catch(v){de.error("Error restoring line wrapping:",v)}}}function jN(e,t){if(!t.merged.ui.hideWindowTitle){let o=Xm({streamingState:"idle",isConfirming:!1,isSilentWorking:!1,folderName:e,showThoughts:!!t.merged.ui.showStatusInTitle,useDynamicTitle:t.merged.ui.dynamicWindowTitle});_r(`\x1B]0;${o}\x07`),process.on("exit",()=>{_r("\x1B]0;\x07")})}}export{Ute as startInteractiveUI};
119
+ ${ft}`:ft,iy()),Ae&&Ii.setText(Ae)},[Ii,wo,sy,iy,Do]);let ly=(0,V.useCallback)(U=>{let ge=U.trim();ge&&(r.injectionService.addInjection(ge,"user_steering"),x.addItem({type:"hint",text:ge}))},[r,x]),uc=(0,V.useCallback)(async U=>{a(),To(null),ve||(yo(!0),S||Qt());let ge=gr(U.trim()),pe=So==="idle",Ae=So==="responding"||Uf(Do);if(ge&&Ae){let{commandToExecute:is}=al(U,Ru??[]);if(is?.isSafeConcurrent){vi(U),Fo(U);return}}if(r.isModelSteeringEnabled()&&Ae&&!ge){ly(U),Fo(U);return}let ft=st&&cc;if(ge&&st||!Mu&&pe&&ft){if(!ge){let is=await US(U,r);if(is.length>0){qh({files:is,onComplete:cD=>{qh(null),cD.allowed&&is.forEach(uD=>r.getWorkspaceContext().addReadOnlyPath(uD)),Ya(U)}}),Fo(U);return}}Ya(U)}else pe&&!Mu&&!ft&&Pu.length===0&&Se.emitFeedback("info",st?"Waiting for MCP servers to initialize... Slash commands are still available and prompts will be queued.":"Initializing... Prompts will be queued."),Ou(U);Fo(U)},[Ou,Fo,Ya,vi,Ru,cc,So,Mu,Pu.length,Do,r,ve,yo,S,Qt,a,ly,st,To]),cy=(0,V.useCallback)(()=>{a(),To(null),x.clearItems(),os(),Qt()},[x,os,Qt,a,To]),{handleInput:uy}=mA(Ii,uc),kp=!Op&&!L&&!vp&&(So==="idle"||So==="responding"||So==="waiting_for_confirmation")&&!nc,dc=(0,V.useRef)(null);(0,V.useEffect)(()=>()=>{dc.current?.disconnect()},[]);let[Lu,G_]=(0,V.useState)(0),[dy,W_]=(0,V.useState)(0);(0,V.useLayoutEffect)(()=>{!oe&&Lu>0&&W_(Lu)},[oe,Lu]);let Hp=oe&&dy>0?dy:Lu,my=(0,V.useCallback)(U=>{if(dc.current&&(dc.current.disconnect(),dc.current=null),U){let ge=new Zn(pe=>{let Ae=pe[0];if(Ae){let ft=Math.round(Ae.contentRect.height);G_(is=>ft!==is?ft:is)}});ge.observe(U),dc.current=ge}},[]),Fp=Math.max(0,St-Hp-Bp-1);r.setShellExecutionConfig({terminalWidth:Math.floor(Je*VN),terminalHeight:Math.max(Math.floor(Fp-$N),1),pager:i.merged.tools.shell.pager,showColor:i.merged.tools.shell.showColor,sanitizationConfig:r.sanitizationConfig,sandboxManager:r.sandboxManager});let{isFocused:Nu,hasReceivedFocusEvent:V_}=rC(),py=(0,V.useMemo)(()=>{let U=i.merged.context.fileName;return U?Array.isArray(U)?U:[U]:AT()},[i.merged.context.fileName]),Up=(0,V.useMemo)(()=>r.getQuestion(),[r]),fy=(0,V.useRef)(!1),gy=r.getGeminiClient();(0,V.useEffect)(()=>{Up&&st&&!fy.current&&!ja&&!ic&&!rc&&!tc&&!D&&gy?.isInitialized?.()&&(uc(Up),fy.current=!0)},[Up,st,uc,ja,ic,rc,tc,D,gy]);let[$_,q_]=(0,V.useState)(!1),[Gp,K_]=(0,V.useState)(null);(0,V.useEffect)(()=>{(async()=>{let pe=(await Zs.getInstance()).getCurrentIde();K_(pe||null)})()},[]);let Wp=!!(Gp&&!r.getIdeMode()&&!i.merged.ide.hasSeenNudge&&!$_),[Bu,mc]=(0,V.useState)(!1),[hy,j_]=(0,V.useState)(!1),[yy,z_]=(0,V.useState)(!0),Ty=(0,V.useCallback)(U=>{U>2&&OT(r),U>1&&vi("/quit",void 0,void 0,!1)},[r,vi]),{pressCount:xy,handlePress:Sy}=Fl({windowMs:Di,onRepeat:Ty}),{pressCount:Cy,handlePress:by}=Fl({windowMs:Di,onRepeat:Ty}),[ku,Ey]=(0,V.useState)(),[Ry,Y_]=(0,V.useState)(!1),[Vp,X_]=(0,V.useState)(!1),[Iy,Ai]=xp(Di),{isFolderTrustDialogOpen:$p,discoveryResults:vy,handleFolderTrustSelect:Ay,isRestarting:wy}=hA(i,$a,x.addItem),qp=r.getPolicyUpdateConfirmationRequest(),[Kp,_y]=(0,V.useState)(!!qp),{needsRestart:Dy,restartReason:My}=EC(),Py=(0,V.useRef)(!0);l_(r,Ci,x,Y);let ns=(0,V.useRef)(null);(0,V.useEffect)(()=>{let U=Ae=>{Ai({text:Ae.message,type:Ae.type})},ge=()=>{Ai({text:"Press Ctrl-S to enter selection mode to copy text.",type:"warning"})},pe=()=>{Ai({text:"Paste Timed out. Possibly due to slow connection.",type:"warning"})};return kt.on("transient-message",U),kt.on("selection-warning",ge),kt.on("paste-timeout",pe),()=>{kt.off("transient-message",U),kt.off("selection-warning",ge),kt.off("paste-timeout",pe),ns.current&&clearTimeout(ns.current)}},[Ai]);let jp=(0,V.useCallback)(U=>{Ai({text:U,type:"warning"})},[Ai]),{handleSuspend:Oy}=g_({handleWarning:jp,setRawMode:Xt,refreshStatic:Qt,setForceRerenderKey:R,shouldUseAlternateScreen:bp});(0,V.useEffect)(()=>{Dy&&X_(!0)},[Dy]),(0,V.useEffect)(()=>{if(Py.current){Py.current=!1;return}let U=setTimeout(()=>{Qt()},300);return()=>{clearTimeout(U)}},[Je,Qt]),(0,V.useEffect)(()=>{let U=lf.subscribe(Ey);return Ey(lf.get()),U},[]),(0,V.useEffect)(()=>{let U=()=>{mc(!0),yo(!1)};return kt.on("open-debug-console",U),()=>{kt.off("open-debug-console",U)}},[r]);let Ly=(0,V.useCallback)(U=>{Y_(U)},[]),Ny=(0,V.useCallback)(U=>{U.userSelection==="yes"?(vi("/ide install"),i.setValue("User","ide.hasSeenNudge",!0)):U.userSelection==="dismiss"&&i.setValue("User","ide.hasSeenNudge",!0),q_(!0)},[vi,i]),Q_=(0,V.useCallback)(U=>{if(i.merged.general.debugKeystrokeLogging&&de.log("[DEBUG] Keystroke:",JSON.stringify(U)),za&&t(U)&&Ys(!1),o["app.toggleMouseMode"](U))return A(Ae=>!Ae),I&&!S&&kt.emit("scroll-to-bottom"),!0;if(S&&o["app.toggleCopyMode"](U))return ce(!0),ls(),!0;if(o["basic.quit"](U))return Yh?.(),Sy(),!0;if(o["basic.exit"](U))return Cp.current.text.length>0?!1:(by(),!0);if(o["app.suspend"](U))Oy();else if(o["app.dumpFrame"](U)){let ft=`snapshot-${new Date().toISOString().replace(/[:.]/g,"-")}.json`;return h&&(h(ft),de.log(`Dumped frame to: ${ft}`)),!0}else if(o["app.startRecording"](U)){let ft=`recording-${new Date().toISOString().replace(/[:.]/g,"-")}.json`;return p&&(p(ft),g.current=ft,de.log(`Started recording to: ${ft}`)),!0}else{if(o["app.stopRecording"](U))return y&&(y(),de.log(`Stopped recording, saved to: ${g.current??"unknown"}`),g.current=null),!0;if(o["app.toggleCopyMode"](U)&&!S)return Ai({text:"Use Ctrl+O to expand and collapse blocks of content.",type:"warning"}),!0}let ge=()=>{To(!0);let Ae=Zb(x.history,Do);Ae.length>0&&De(Ae)},pe=!1;if(ve||(pe=!0,yo(!0),o["app.showMoreLines"](U)&&ge(),S||Qt()),o["app.showErrorDetails"](U))return i.merged.general.devtools?(async()=>{let{toggleDevToolsPanel:Ae}=await import("./devtoolsService-FLOV3S5Z.js");await Ae(r,Bu,()=>mc(ft=>!ft),()=>mc(!0))})():mc(Ae=>!Ae),!0;if(o["app.showFullTodos"](U))return j_(Ae=>!Ae),!0;if(o["app.toggleMarkdown"](U))return z_(Ae=>{let ft=!Ae;return Qt(),ft}),!0;if(o["app.showIdeContextDetail"](U)&&r.getIdeMode()&&ku)return vi("/ide status"),!0;if(o["app.showMoreLines"](U)&&!pe)return yo(!1),ge(),Qt(),!0;if((o["app.focusShellInput"](U)||o["background.unfocusList"](U))&&(rs||qn&&Kn.size>0)){if(F){let ft=lc.current;return ns.current&&clearTimeout(ns.current),ns.current=setTimeout(()=>{lc.current===ft?B(!1):Ai({text:"Use Shift+Tab to unfocus",type:"warning"})},150),!1}return Date.now()-lc.current>=100&&!rs&&!qn?(ns.current&&clearTimeout(ns.current),Du(),B(!0),Kn.size>1&&Qs(!0),!0):(B(!0),!0)}else{if(o["app.unfocusShellInput"](U)||o["background.unfocus"](U))return F?(B(!1),!0):!1;if(o["background.toggle"](U))return rs?Qh():(Du(),!qn&&Kn.size>0?(B(!0),Kn.size>1&&Qs(!0)):B(!1)),!0;if(o["background.toggleList"](U))return Kn.size>0&&qn&&(F||B(!0),Qs(!0)),!0}return!1},[ve,yo,mc,r,ku,Sy,by,vi,Yh,rs,Oy,F,i.merged.general.debugKeystrokeLogging,Qt,ce,ns,S,za,Qh,Du,Kn,qn,Qs,lc,Ai,i.merged.general.devtools,Bu,To,o,t,x.history,Do,De,h,p,y,I]);me(Q_,{isActive:!0,priority:!0}),me(U=>o["scroll.up"](U)||o["scroll.down"](U)||o["scroll.pageUp"](U)||o["scroll.pageDown"](U)||o["scroll.home"](U)||o["scroll.end"](U)?!1:(ce(!1),I&&as(),!0),{isActive:oe,priority:200}),(0,V.useEffect)(()=>{if(i.merged.ui.hideWindowTitle)return;let U=Xm({streamingState:So,thoughtSubject:ac?.subject,isConfirming:!!Xs||ry,isSilentWorking:ny,folderName:WN(r.getTargetDir()),showThoughts:!!i.merged.ui.showStatusInTitle,useDynamicTitle:i.merged.ui.dynamicWindowTitle});rn.current!==U&&(rn.current=U,Yo.write(`\x1B]0;${U}\x07`))},[So,ac,Xs,ry,ny,i.merged.ui.showStatusInTitle,i.merged.ui.dynamicWindowTitle,i.merged.ui.hideWindowTitle,r,Yo]),(0,V.useEffect)(()=>{let U=pe=>{let Ae;switch(pe.severity){case"error":Ae="error";break;case"warning":Ae="warning";break;case"info":Ae="info";break;default:throw new Error(`Unexpected severity for user feedback: ${pe.severity}`)}x.addItem({type:Ae,text:pe.message},Date.now()),pe.error&&de.warn(`[Feedback Details for "${pe.message}"]`,pe.error)},ge=pe=>{x.addItem({type:"info",text:pe.message,source:pe.hookName},Date.now())};return Se.on(Ge.UserFeedback,U),Se.on(Ge.HookSystemMessage,ge),Se.drainBacklogs(),()=>{Se.off(Ge.UserFeedback,U),Se.off(Ge.HookSystemMessage,ge)}},[x]);let By=e.version.includes("nightly"),zp=$n==="awaiting_login_restart",ky=i.merged.security.auth.selectedType===$e.USE_VERTEX_AI?"Authenticating to Vertex AI in Cloud Shell requires a restart to apply project settings.":void 0,Hy=Wp||$p||Kp||j||!!Xs||!!sc||!!vu||!!Z||zo.length>0||!!_u||rc||Rp||wp||_p||Gn||es||ja||ic||tc||D||Vp||!!nc||!!yu||!!Tu||!!xu||Ap||$n==="awaiting_api_key_input"||zp||!!go,J_=(0,V.useMemo)(()=>Yd(Do),[Do]),Fy=zo.length>0,Uy=!!_u,pc=J_||!!Xs||!!sc||Fy||Uy||!!nc||!!yu||!!Tu||!!xu||!!Z,Hu=i.merged.ui.loadingPhrases,Z_=Hu==="tips"||Hu==="all",eD=Hu==="witty"||Hu==="all",tD=(!F||qn)&&So==="responding"&&!pc,Fu=0;if(ur.length>0&&i.merged.hooksConfig.notifications){let U=ur.length>1?"Executing Hooks":"Executing Hook",ge=ur.map(pe=>pe.name+(pe.index&&pe.total&&pe.total>1?` (${pe.index}/${pe.total})`:"")).join(", ");Fu=U.length+ge.length+10}else tD?Fu=(ac?.subject||"Waiting for model...").length+25:pc&&(Fu=35);let oD=Je-Fu-5,{elapsedTime:Gy,currentLoadingPhrase:Wy,currentTip:Vy,currentWittyPhrase:$y}=fA({streamingState:So,shouldShowFocusHint:F_,retryStatus:H_,showTips:Z_,showWit:eD,customWittyPhrases:i.merged.ui.customWittyPhrases,errorVerbosity:i.merged.ui.errorVerbosity,maxLength:oD}),Yp=r.isPlanEnabled()&&So==="idle"&&!pc,qy=r_({config:r,addItem:x.addItem,onApprovalModeChange:U_,isActive:!F,allowPlanMode:Yp});R_({notificationsEnabled:d,notificationMethod:m,isFocused:Nu,hasReceivedFocusEvent:V_,streamingState:So,hasPendingActionRequired:pc,pendingHistoryItems:Do,commandConfirmationRequest:Xs,authConsentRequest:sc,permissionConfirmationRequest:vu,hasConfirmUpdateExtensionRequests:Fy,hasLoopDetectionConfirmationRequest:Uy});let Ky=kp&&So==="idle"&&!pc;(0,V.useEffect)(()=>{za&&!Ky&&Ys(!1)},[za,Ky,Ys]),(0,V.useEffect)(()=>{if(!st||!r.isModelSteeringEnabled()||So!=="idle"||!cc||Yd(Do))return;let U=Pp();U&&Ya([{text:nd(U)}])},[r,x,st,cc,So,Ya,Pp,Do,N_]);let rD=(0,V.useMemo)(()=>Xd(Do),[Do]),[jy,nD]=(0,V.useState)(r.getGeminiMdFileCount());(0,V.useEffect)(()=>{let U=ge=>{nD(ge.fileCount)};return Se.on(Ge.MemoryChanged,U),()=>{Se.off(Ge.MemoryChanged,U)}},[]),(0,V.useEffect)(()=>{let U=!0;return(async()=>{let[pe,Ae]=await Promise.all([r.getBannerTextNoCapacityIssues(),r.getBannerTextCapacityIssues()]);U&&(xo(pe),Xi(Ae),en(!0))})(),()=>{U=!1}},[r,Qt]);let iD=(0,V.useMemo)(()=>({buffer:Ii,userMessages:wo,shellModeActive:ue,showEscapePrompt:Ry,copyModeEnabled:oe,inputWidth:Vn,suggestionsWidth:Zl}),[Ii,wo,ue,Ry,oe,Vn,Zl]),sD=(0,V.useMemo)(()=>({userTier:Gr,stats:Ie,proQuotaRequest:nc,validationRequest:yu,overageMenuRequest:Tu,emptyWalletRequest:xu}),[Gr,Ie,nc,yu,Tu,xu]),aD=(0,V.useMemo)(()=>({history:x.history,historyManager:x,isThemeDialogOpen:rc,themeError:O,isAuthenticating:ja,isConfigInitialized:st,authError:Ch,accountSuspensionInfo:Rh,isAuthDialogOpen:ic,isAwaitingApiKeyInput:$n==="awaiting_api_key_input",isAwaitingLoginRestart:zp,loginRestartMessage:ky,apiKeyDefaultValue:bh,editorError:fh,isEditorDialogOpen:tc,showPrivacyNotice:D,mouseMode:I,corgiMode:E,debugMessage:b,quittingMessages:w,isSettingsDialogOpen:Rp,isSessionBrowserOpen:Ap,isModelDialogOpen:wp,isVoiceModelDialogOpen:_p,isAgentConfigDialogOpen:Gn,selectedAgentName:se,selectedAgentDisplayName:le,selectedAgentDefinition:Te,isPermissionsDialogOpen:es,permissionsDialogProps:tn,slashCommands:Ru,pendingSlashCommandHistoryItems:Iu,commandContext:Vh,commandConfirmationRequest:Xs,authConsentRequest:sc,confirmUpdateExtensionRequests:zo,loopDetectionConfirmationRequest:_u,permissionConfirmationRequest:vu,geminiMdFileCount:jy,streamingState:So,initError:Op,pendingGeminiHistoryItems:wu,thought:ac,isInputActive:kp,isVoiceModeEnabled:Tt,isResuming:vp,shouldShowIdePrompt:Wp,isFolderTrustDialogOpen:$p??!1,folderDiscoveryResults:vy,isPolicyUpdateDialogOpen:Kp,policyUpdateConfirmationRequest:qp,isTrustedFolder:Ci,constrainHeight:ve,showErrorDetails:Bu,showFullTodos:hy,ideContextState:ku,renderMarkdown:yy,ctrlCPressedOnce:xy>=1,ctrlDPressedOnce:Cy>=1,shortcutsHelpVisible:za,cleanUiDetailsVisible:bu,isFocused:Nu,elapsedTime:Gy,currentLoadingPhrase:Wy,currentTip:Vy,currentWittyPhrase:$y,historyRemountKey:cr,activeHooks:ur,messageQueue:Pu,queueErrorMessage:Ws,showApprovalModeIndicator:qy,allowPlanMode:Yp,currentModel:ct,contextFileNames:py,errorCount:sn,availableTerminalHeight:Fp,stableControlsHeight:Hp,mainAreaWidth:Wn,staticAreaMaxItemHeight:ec,staticExtraHeight:nn,dialogsVisible:Hy,pendingHistoryItems:Do,nightly:By,branchName:wn,sessionStats:_o,terminalWidth:Je,terminalHeight:St,mainControlsRef:my,rootUiRef:on,currentIDE:Gp,updateInfo:Fn,showIdeRestartPrompt:Vp,ideTrustRestartReason:My,isRestarting:wy,extensionsUpdateState:Ji,activePtyId:rs,backgroundTaskCount:Np,isBackgroundTaskVisible:qn,embeddedShellFocused:F,showDebugProfiler:K,customDialog:Z,transientMessage:Iy,bannerData:wr,bannerVisible:jo,terminalBackgroundColor:r.getTerminalBackground(),settingsNonce:Zr,backgroundTasks:Kn,activeBackgroundTaskPid:Zh,backgroundTaskHeight:Bp,isBackgroundTaskListOpen:ey,adminSettingsChanged:j,newAgents:go,showIsExpandableHint:Ur,hintMode:r.isModelSteeringEnabled()&&Uf(Do),hintBuffer:""}),[rc,O,ja,st,Ch,Rh,ic,fh,tc,D,I,E,b,w,Rp,Ap,wp,_p,Gn,se,le,Te,es,tn,Ru,Iu,Vh,Xs,sc,zo,_u,vu,jy,So,Op,wu,ac,kp,Tt,vp,Wp,$p,vy,Kp,qp,Ci,ve,Bu,hy,ku,yy,xy,Cy,za,bu,Nu,Gy,Wy,Vy,$y,cr,ur,Pu,Ws,qy,Yp,py,sn,Fp,Hp,Wn,ec,nn,Hy,Do,By,wn,_o,Je,St,my,on,Gp,Fn,Vp,My,wy,ct,Ji,rs,Np,qn,x,F,K,Z,bh,$n,zp,ky,Iy,wr,jo,r,Zr,Bp,ey,Zh,Kn,j,go,Ur]),zy=(0,V.useCallback)(()=>N(!1),[N]),lD=(0,V.useMemo)(()=>({handleThemeSelect:Ip,closeThemeDialog:hu,handleThemeHighlight:Sh,handleAuthSelect:Nh,setAuthState:Xo,onAuthError:Wr,handleEditorSelect:gh,exitEditorDialog:hh,exitPrivacyNotice:zy,closeSettingsDialog:Th,closeModelDialog:Fh,openVoiceModelDialog:Cu,closeVoiceModelDialog:Uh,openAgentConfigDialog:Re,closeAgentConfigDialog:Et,openPermissionsDialog:Ri,closePermissionsDialog:Ks,setShellModeActive:Ue,vimHandleInput:uy,handleIdePromptComplete:Ny,handleFolderTrustSelect:Ay,setIsPolicyUpdateDialogOpen:_y,setConstrainHeight:yo,onEscapePromptChange:Ly,refreshStatic:Qt,handleFinalSubmit:uc,handleClearScreen:cy,handleProQuotaChoice:Ah,handleValidationChoice:wh,handleOverageMenuChoice:_h,handleEmptyWalletChoice:Dh,openSessionBrowser:Su,closeSessionBrowser:Mh,handleResumeSession:Ph,handleDeleteSession:Lh,setQueueErrorMessage:ao,addMessage:Ou,popAllMessages:ay,handleApiKeySubmit:Bh,handleApiKeyCancel:kh,setBannerVisible:en,setShortcutsHelpVisible:Ys,setCleanUiDetailsVisible:Gh,toggleCleanUiDetailsVisible:Wh,revealCleanUiDetailsTemporarily:Eu,handleWarning:jp,setEmbeddedShellFocused:B,dismissBackgroundTask:Jh,setActiveBackgroundTaskPid:ty,setIsBackgroundTaskListOpen:Qs,setAuthContext:zs,dismissLoginRestart:()=>{zs({}),Xo("updating")},onHintInput:()=>{},onHintBackspace:()=>{},onHintClear:()=>{},onHintSubmit:()=>{},handleRestart:async()=>{if(mh.send){let U=r.getRemoteAdminSettings();U&&mh.send({type:"admin-settings-update",settings:U})}await fr()},handleNewAgentsSelect:async U=>{if(go&&U==="acknowledge"){let ge=r.getAgentRegistry();try{await Promise.all(go.map(pe=>ge.acknowledgeAgent(pe)))}catch(pe){de.error("Failed to acknowledge agents:",pe),x.addItem({type:"error",text:`Failed to acknowledge agents: ${Vr(pe)}`},Date.now())}}ho(null)},getPreferredEditor:Ka,clearAccountSuspension:()=>{Ih(null),Xo("updating")},setVoiceModeEnabled:U=>{It(U)}}),[Ip,hu,Sh,Nh,Xo,Wr,gh,hh,zy,Th,Fh,Cu,Uh,Re,Et,Ri,Ks,Ue,uy,Ny,Ay,_y,yo,Ly,Qt,uc,cy,Ah,wh,_h,Dh,Su,Mh,Ph,Lh,ao,Ou,ay,Bh,kh,en,Ys,Gh,Wh,Eu,jp,B,Jh,ty,Qs,zs,Ih,go,r,x,Ka,It]);return(0,vn.jsx)(xd.Provider,{value:aD,children:(0,vn.jsx)(MC.Provider,{value:sD,children:(0,vn.jsx)(OC.Provider,{value:iD,children:(0,vn.jsx)(Ff.Provider,{value:lD,children:(0,vn.jsx)(Td.Provider,{value:r,children:(0,vn.jsx)(jf.Provider,{value:{version:e.version,startupWarnings:e.startupWarnings||[]},children:(0,vn.jsx)(Bb,{config:r,toolCalls:rD,isExpanded:ke,toggleExpansion:be,toggleAllExpansion:De,children:(0,vn.jsx)(xg.Provider,{value:Nu,children:(0,vn.jsx)(hd,{mouseEventsEnabled:I,children:(0,vn.jsx)(vd,{children:(0,vn.jsx)(Dv,{},`app-${v}`)})})})})})})})})})})};var Fr=C(P(),1);var KN=200;async function Ute(e,t,o,r=process.cwd(),n,s){gI();let i=Zu(e.getUseAlternateBuffer(),e.getScreenReader()),a=i;a&&(as(),ds(()=>{ls()}));let{matchers:d,errors:m}=await sC();m.forEach(v=>{Se.emitFeedback("warning",v)});let f=await mx();jN(qN(r),t);let h=new kS({onNewMessage:v=>{Se.emitConsoleLog(v.type,v.content)},debugMode:e.getDebugMode()});h.patch();let{stdout:p,stderr:y}=GT(),g=!!process.env.SHPOOL_SESSION_NAME,x=()=>(Lm(),(0,Fr.jsx)(nC.Provider,{value:t,children:(0,Fr.jsx)(aC,{value:d,children:(0,Fr.jsx)(iC,{config:e,children:(0,Fr.jsx)(hd,{mouseEventsEnabled:a,children:(0,Fr.jsx)(Lv,{children:(0,Fr.jsx)(vd,{children:(0,Fr.jsx)(hl,{children:(0,Fr.jsx)(RE,{sessionId:e.getSessionId(),children:(0,Fr.jsx)(PC,{children:(0,Fr.jsx)(A_,{config:e,startupWarnings:o,version:f,resumedSessionData:n,initializationResult:s})})})})})})})})})}));g&&await new Promise(v=>setTimeout(v,100));let S=JS(process.env.DEBUG?(0,Fr.jsx)(w_.default.StrictMode,{children:(0,Fr.jsx)(x,{})}):(0,Fr.jsx)(x,{}),{stdout:p,stderr:y,stdin:process.stdin,exitOnCtrlC:!1,isScreenReaderEnabled:e.getScreenReader(),onRender:({renderTime:v})=>{v>KN&&LT(e,Math.round(v)),DC.reportFrameRendered()},standardReactLayoutTiming:i||e.getUseTerminalBuffer(),patchConsole:!1,alternateBuffer:i,terminalBuffer:e.getUseTerminalBuffer(),renderProcess:e.getUseRenderProcess()&&e.getUseTerminalBuffer(),incrementalRendering:t.merged.ui.incrementalRendering!==!1&&i&&!g,debugRainbow:t.merged.ui.debugRainbow===!0}),I;i&&(Ja(),I=()=>Qu(),ds(I)),e_(t).then(v=>{oS(v,t,e.getProjectRoot(),e.getSandboxEnabled())}).catch(v=>{e.getDebugMode()&&de.warn("Update check failed:",v)});let A=()=>S.unmount();ds(A);let E=Zx();ds(E);let T=()=>h.cleanup();ds(T);try{await S.waitUntilExit()}finally{try{oa(T),T()}catch(v){de.error("Error cleaning up console patcher:",v)}try{oa(A),S.unmount()}catch(v){de.error("Error unmounting Ink instance:",v)}try{oa(E),E()}catch(v){de.error("Error in TTY cleanup:",v)}if(I)try{oa(I),I()}catch(v){de.error("Error restoring line wrapping:",v)}}}function jN(e,t){if(!t.merged.ui.hideWindowTitle){let o=Xm({streamingState:"idle",isConfirming:!1,isSilentWorking:!1,folderName:e,showThoughts:!!t.merged.ui.showStatusInTitle,useDynamicTitle:t.merged.ui.dynamicWindowTitle});_r(`\x1B]0;${o}\x07`),process.on("exit",()=>{_r("\x1B]0;\x07")})}}export{Ute as startInteractiveUI};
120
120
  /**
121
121
  * @license
122
122
  * Copyright 2025 Google LLC