@kimuson/claude-code-viewer 0.4.14 → 0.4.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -7
- package/dist/main.js +5 -3
- package/dist/main.js.map +2 -2
- package/dist/static/assets/{ProtectedRoute-BzJk3rey.js → ProtectedRoute-C5fRf9hh.js} +1 -1
- package/dist/static/assets/{eye-B5gmioqG.js → eye-BpyPAB62.js} +1 -1
- package/dist/static/assets/{index-CD2UAYAO.js → index-CGQpot94.js} +1 -1
- package/dist/static/assets/{index-BmfDiIO7.js → index-D07oc57n.js} +1 -1
- package/dist/static/assets/{index-Bnpk63z-.js → index-DZukx-uT.js} +3 -3
- package/dist/static/assets/{label-CZmxYtll.js → label-BhzS1w7s.js} +1 -1
- package/dist/static/assets/{login-zJ8NgNeJ.js → login-DpxCwKVk.js} +1 -1
- package/dist/static/assets/{session-17BtrmxA.js → session-CEMQzyS6.js} +1 -1
- package/dist/static/assets/{session-DXbcjdEx.js → session-DmyweLUZ.js} +2 -2
- package/dist/static/index.html +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as oe,Q as _S,y as dc,z as NS,A as IS,E as TS,F as AS,G as F,H as K,J as Eu,K as RS,$ as db,M as CS,O as OS,P as DS,R as LS,S as $S,U as jS,V as MS,W as PS,X as US,Y as FS,Z as BS,_ as zS,a0 as qS,a1 as GS,a2 as HS,a3 as VS,a4 as WS,a5 as KS,a6 as YS,a7 as ZS,a8 as XS,a9 as JS,aa as QS,ab as eE,ac as tE,ad as nE,ae as rE,af as aE,ag as iE,ah as oE,ai as sE,aj as lE,ak as uE,al as cE,am as dE,an as pE,ao as mE,ap as gE,aq as fE,ar as hE,as as bE,at as yE,au as vE,av as SE,aw as EE,ax as xE,ay as kE,az as wE,aA as _E,aB as NE,aC as IE,aD as TE,aE as AE,aF as RE,aG as CE,aH as OE,aI as DE,aJ as LE,aK as $E,aL as jE,aM as ME,aN as PE,aO as UE,aP as FE,aQ as BE,aR as zE,aS as qE,aT as GE,aU as HE,aV as VE,aW as WE,aX as KE,aY as YE,aZ as ZE,a_ as XE,a$ as JE,b0 as QE,b1 as ex,b2 as tx,b3 as nx,b4 as rx,b5 as ax,b6 as ix,b7 as ox,b8 as sx,b9 as lx,ba as ux,bb as cx,bc as dx,bd as px,be as mx,bf as gx,bg as fx,bh as hx,bi as bx,bj as yx,bk as vx,bl as pb,bm as Sx,bn as mb,bo as gb,bp as Ex,bq as fb,br as hb,bs as xx,bt as kx,bu as wx,bv as _x,bw as Nx,bx as Ix,by as Tx,bz as Ax,bA as Rx,bB as Cx,bC as bb,bD as yb,bE as vb,bF as Sb,bG as Eb,bH as Ox,bI as Dx,bJ as Lx,bK as $x,bL as jx,bM as Mx,bN as Px,bO as Ux,bP as Fx,bQ as Bx,bR as zx,bS as qx,bT as Gx,bU as xb,bV as Hx,bW as Vx,bX as Wx,bY as Kx,bZ as kb,b_ as Ql,b$ as Yx,c0 as wb,c1 as Zx,c2 as Xx,c3 as Jx,c4 as Qx,c5 as ek,c6 as tk,c7 as nk,c8 as rk,c9 as ak,ca as ik,cb as ok,cc as sk,cd as lk,ce as _b,cf as uk,cg as Nb,ch as Ib,ci as eu,cj as ck,ck as dk,cl as Tb,cm as Ab,cn as Rb,co as Cb,cp as Ob,cq as Db,cr as pk,cs as mk,ct as gk,cu as Lb,cv as fk,cw as $b,cx as hk,cy as jb,cz as Mb,cA as bk,cB as yk,cC as vk,cD as Sk,cE as Pb,cF as Ek,cG as xk,cH as kk,cI as Ub,cJ as wk,cK as Fb,cL as _k,cM as Nk,cN as Ik,cO as Bb,cP as Tk,cQ as Ak,cR as Rk,cS as Ck,cT as Ok,cU as Dk,cV as Lk,cW as zb,cX as qb,cY as Gb,cZ as $k,c_ as jk,c$ as Mk,d0 as Pk,d1 as Uk,d2 as Fk,d3 as Bk,d4 as Hb,d5 as Vb,d6 as zk,d7 as Wb,d8 as qk,d9 as Gk,da as Hk,db as Vk,dc as Wk,dd as Kk,de as Yk,df as Kb,dg as Zk,dh as Xk,di as Jk,dj as Qk,dk as ew,dl as tw,dm as nw,dn as Yb,dp as un,dq as rw,dr as aw,ds as iw,dt as ow,du as sw,dv as Zb,dw as Xb,dx as lw,dy as uw,dz as cw,dA as dw,dB as pw,dC as mw,dD as gw,dE as Jb,dF as Qb,dG as ey,dH as fw,dI as hw,dJ as bw,dK as yw,dL as vw,dM as Sw,dN as Ew,dO as ty,dP as ny,dQ as xw,dR as ry,dS as ay,dT as iy,dU as oy,dV as sy,dW as kw,dX as ww,dY as _w,dZ as Nw,d_ as Iw,d$ as Tw,e0 as Aw,e1 as Rw,e2 as Cw,e3 as Ow,e4 as Dw,e5 as Lw,e6 as $w,e7 as jw,e8 as Mw,e9 as Pw,ea as Uw,eb as Fw,ec as Bw,ed as zw,ee as qw,ef as Gw,eg as Hw,eh as Vw,ei as Ww,ej as Kw,ek as Yw,el as Zw,em as Xw,en as Jw,eo as Qw,ep as e_,eq as t_,er as n_,es as r_,et as a_,eu as i_,ev as o_,ew as s_,ex as l_,ey as u_,ez as c_,eA as d_,eB as p_,eC as m_,eD as g_,eE as f_,eF as h_,eG as b_,eH as y_,eI as v_,eJ as S_,eK as E_,eL as x_,eM as k_,eN as w_,eO as __,eP as N_,eQ as I_,eR as T_,eS as A_,eT as R_,eU as C_,eV as O_,eW as D_,eX as L_,eY as $_,eZ as j_,e_ as M_,e$ as pc,f0 as P_,f1 as tu,f2 as U_,f3 as F_,f4 as B_,f5 as z_,f6 as q_,f7 as G_,f8 as H_,f9 as V_,fa as W_,fb as K_,fc as Y_,fd as Z_,fe as X_,ff as J_,fg as Q_,fh as eN,fi as tN,fj as nN,fk as rN,fl as aN,fm as iN,fn as oN,fo as Nn,fp as sN,fq as lN,fr as uN,fs as cN,ft as dN,fu as pN,fv as mN,fw as gN,fx as fN,fy as hN,fz as bN,fA as yN,fB as vN,fC as SN,fD as EN,fE as xN,fF as kN,fG as wN,fH as _N,fI as NN,fJ as IN,fK as ct,fL as TN,fM as AN,fN as RN,fO as CN,fP as ON,fQ as DN,fR as LN,fS as $N,fT as jN,fU as MN,fV as PN,fW as UN,fX as FN,fY as Je,fZ as BN,f_ as zN,f$ as qN,g0 as GN,g1 as HN,g2 as VN,g3 as WN,g4 as KN,g5 as YN,g6 as ZN,g7 as XN,g8 as JN,g9 as QN,ga as eI,gb as tI,gc as nI,gd as rI,ge as aI,gf as iI,gg as He,gh as oI,gi as sI,gj as lI,gk as uI,gl as cI,gm as dI,gn as pI,go as mI,gp as gI,gq as fI,gr as hI,gs as bI,gt as xu,gu as yI,gv as vI,gw as SI,gx as EI,gy as xI,gz as kI,gA as wI,gB as _I,gC as mc,k as Pt,m as et,n as ze,gD as gc,r as C,h as kt,j as s,D as cn,q as dn,s as jn,v as Mn,w as Pn,B as ne,gE as NI,gF as II,gG as TI,gH as ly,gI as uy,gJ as Jt,gK as cy,gL as AI,gM as RI,gN as CI,gO as OI,gP as DI,gQ as LI,gR as $I,gS as ce,gT as jI,t as de,gU as In,g as MI,gV as fc,gW as dy,gX as ft,gY as Tn,gZ as ku,g_ as wu,g$ as py,o as PI,T as R,h0 as pn,L as Tt,h1 as UI,C as ut,b as nn,d as rn,f as hc,h2 as nu,e as bc,h3 as FI,h4 as BI,h5 as zI,h6 as Ke,a as my,h7 as _u,h8 as Un,h9 as yc,ha as vc,I as ht,hb as gy,hc as Xn,hd as qI,i as An,he as GI,x as fy,hf as Sc,hg as HI}from"./index-
|
|
1
|
+
import{c as oe,Q as _S,y as dc,z as NS,A as IS,E as TS,F as AS,G as F,H as K,J as Eu,K as RS,$ as db,M as CS,O as OS,P as DS,R as LS,S as $S,U as jS,V as MS,W as PS,X as US,Y as FS,Z as BS,_ as zS,a0 as qS,a1 as GS,a2 as HS,a3 as VS,a4 as WS,a5 as KS,a6 as YS,a7 as ZS,a8 as XS,a9 as JS,aa as QS,ab as eE,ac as tE,ad as nE,ae as rE,af as aE,ag as iE,ah as oE,ai as sE,aj as lE,ak as uE,al as cE,am as dE,an as pE,ao as mE,ap as gE,aq as fE,ar as hE,as as bE,at as yE,au as vE,av as SE,aw as EE,ax as xE,ay as kE,az as wE,aA as _E,aB as NE,aC as IE,aD as TE,aE as AE,aF as RE,aG as CE,aH as OE,aI as DE,aJ as LE,aK as $E,aL as jE,aM as ME,aN as PE,aO as UE,aP as FE,aQ as BE,aR as zE,aS as qE,aT as GE,aU as HE,aV as VE,aW as WE,aX as KE,aY as YE,aZ as ZE,a_ as XE,a$ as JE,b0 as QE,b1 as ex,b2 as tx,b3 as nx,b4 as rx,b5 as ax,b6 as ix,b7 as ox,b8 as sx,b9 as lx,ba as ux,bb as cx,bc as dx,bd as px,be as mx,bf as gx,bg as fx,bh as hx,bi as bx,bj as yx,bk as vx,bl as pb,bm as Sx,bn as mb,bo as gb,bp as Ex,bq as fb,br as hb,bs as xx,bt as kx,bu as wx,bv as _x,bw as Nx,bx as Ix,by as Tx,bz as Ax,bA as Rx,bB as Cx,bC as bb,bD as yb,bE as vb,bF as Sb,bG as Eb,bH as Ox,bI as Dx,bJ as Lx,bK as $x,bL as jx,bM as Mx,bN as Px,bO as Ux,bP as Fx,bQ as Bx,bR as zx,bS as qx,bT as Gx,bU as xb,bV as Hx,bW as Vx,bX as Wx,bY as Kx,bZ as kb,b_ as Ql,b$ as Yx,c0 as wb,c1 as Zx,c2 as Xx,c3 as Jx,c4 as Qx,c5 as ek,c6 as tk,c7 as nk,c8 as rk,c9 as ak,ca as ik,cb as ok,cc as sk,cd as lk,ce as _b,cf as uk,cg as Nb,ch as Ib,ci as eu,cj as ck,ck as dk,cl as Tb,cm as Ab,cn as Rb,co as Cb,cp as Ob,cq as Db,cr as pk,cs as mk,ct as gk,cu as Lb,cv as fk,cw as $b,cx as hk,cy as jb,cz as Mb,cA as bk,cB as yk,cC as vk,cD as Sk,cE as Pb,cF as Ek,cG as xk,cH as kk,cI as Ub,cJ as wk,cK as Fb,cL as _k,cM as Nk,cN as Ik,cO as Bb,cP as Tk,cQ as Ak,cR as Rk,cS as Ck,cT as Ok,cU as Dk,cV as Lk,cW as zb,cX as qb,cY as Gb,cZ as $k,c_ as jk,c$ as Mk,d0 as Pk,d1 as Uk,d2 as Fk,d3 as Bk,d4 as Hb,d5 as Vb,d6 as zk,d7 as Wb,d8 as qk,d9 as Gk,da as Hk,db as Vk,dc as Wk,dd as Kk,de as Yk,df as Kb,dg as Zk,dh as Xk,di as Jk,dj as Qk,dk as ew,dl as tw,dm as nw,dn as Yb,dp as un,dq as rw,dr as aw,ds as iw,dt as ow,du as sw,dv as Zb,dw as Xb,dx as lw,dy as uw,dz as cw,dA as dw,dB as pw,dC as mw,dD as gw,dE as Jb,dF as Qb,dG as ey,dH as fw,dI as hw,dJ as bw,dK as yw,dL as vw,dM as Sw,dN as Ew,dO as ty,dP as ny,dQ as xw,dR as ry,dS as ay,dT as iy,dU as oy,dV as sy,dW as kw,dX as ww,dY as _w,dZ as Nw,d_ as Iw,d$ as Tw,e0 as Aw,e1 as Rw,e2 as Cw,e3 as Ow,e4 as Dw,e5 as Lw,e6 as $w,e7 as jw,e8 as Mw,e9 as Pw,ea as Uw,eb as Fw,ec as Bw,ed as zw,ee as qw,ef as Gw,eg as Hw,eh as Vw,ei as Ww,ej as Kw,ek as Yw,el as Zw,em as Xw,en as Jw,eo as Qw,ep as e_,eq as t_,er as n_,es as r_,et as a_,eu as i_,ev as o_,ew as s_,ex as l_,ey as u_,ez as c_,eA as d_,eB as p_,eC as m_,eD as g_,eE as f_,eF as h_,eG as b_,eH as y_,eI as v_,eJ as S_,eK as E_,eL as x_,eM as k_,eN as w_,eO as __,eP as N_,eQ as I_,eR as T_,eS as A_,eT as R_,eU as C_,eV as O_,eW as D_,eX as L_,eY as $_,eZ as j_,e_ as M_,e$ as pc,f0 as P_,f1 as tu,f2 as U_,f3 as F_,f4 as B_,f5 as z_,f6 as q_,f7 as G_,f8 as H_,f9 as V_,fa as W_,fb as K_,fc as Y_,fd as Z_,fe as X_,ff as J_,fg as Q_,fh as eN,fi as tN,fj as nN,fk as rN,fl as aN,fm as iN,fn as oN,fo as Nn,fp as sN,fq as lN,fr as uN,fs as cN,ft as dN,fu as pN,fv as mN,fw as gN,fx as fN,fy as hN,fz as bN,fA as yN,fB as vN,fC as SN,fD as EN,fE as xN,fF as kN,fG as wN,fH as _N,fI as NN,fJ as IN,fK as ct,fL as TN,fM as AN,fN as RN,fO as CN,fP as ON,fQ as DN,fR as LN,fS as $N,fT as jN,fU as MN,fV as PN,fW as UN,fX as FN,fY as Je,fZ as BN,f_ as zN,f$ as qN,g0 as GN,g1 as HN,g2 as VN,g3 as WN,g4 as KN,g5 as YN,g6 as ZN,g7 as XN,g8 as JN,g9 as QN,ga as eI,gb as tI,gc as nI,gd as rI,ge as aI,gf as iI,gg as He,gh as oI,gi as sI,gj as lI,gk as uI,gl as cI,gm as dI,gn as pI,go as mI,gp as gI,gq as fI,gr as hI,gs as bI,gt as xu,gu as yI,gv as vI,gw as SI,gx as EI,gy as xI,gz as kI,gA as wI,gB as _I,gC as mc,k as Pt,m as et,n as ze,gD as gc,r as C,h as kt,j as s,D as cn,q as dn,s as jn,v as Mn,w as Pn,B as ne,gE as NI,gF as II,gG as TI,gH as ly,gI as uy,gJ as Jt,gK as cy,gL as AI,gM as RI,gN as CI,gO as OI,gP as DI,gQ as LI,gR as $I,gS as ce,gT as jI,t as de,gU as In,g as MI,gV as fc,gW as dy,gX as ft,gY as Tn,gZ as ku,g_ as wu,g$ as py,o as PI,T as R,h0 as pn,L as Tt,h1 as UI,C as ut,b as nn,d as rn,f as hc,h2 as nu,e as bc,h3 as FI,h4 as BI,h5 as zI,h6 as Ke,a as my,h7 as _u,h8 as Un,h9 as yc,ha as vc,I as ht,hb as gy,hc as Xn,hd as qI,i as An,he as GI,x as fy,hf as Sc,hg as HI}from"./index-DZukx-uT.js";import{B as pe,f as Nu,c as Le,d as We,e as $e,a as hy,g as je,h as by,R as VI,A as yy,i as WI,j as KI,n as YI,s as ZI,p as XI,k as JI,l as QI,C as eT,S as Ot,m as Dt,o as Lt,q as $t,r as Ve,P as Iu,t as vy,F as tT,T as Ye,u as Ze,v as Xe,I as Sy,L as an,w as Ey,x as nT,y as rT,z as aT,N as iT,G as oT,b as sT}from"./ProtectedRoute-C5fRf9hh.js";import{E as lT}from"./eye-BpyPAB62.js";import{L as Ie}from"./label-BhzS1w7s.js";/**
|
|
2
2
|
* @license lucide-react v0.548.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -184,4 +184,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
184
184
|
`,...i.current()});return/^[\t ]/.test(c)&&(c=ln(c.charCodeAt(0))+c.slice(1)),c=c?o+" "+c:o,r.options.closeAtx&&(c+=" "+o),u(),l(),c}Wv.peek=NB;function Wv(e){return e.value||""}function NB(){return"<"}Kv.peek=IB;function Kv(e,n,r,a){const t=rc(r),i=t==='"'?"Quote":"Apostrophe",o=r.enter("image");let l=r.enter("label");const u=r.createTracker(a);let c=u.move("![");return c+=u.move(r.safe(e.alt,{before:c,after:"]",...u.current()})),c+=u.move("]("),l(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(l=r.enter("destinationLiteral"),c+=u.move("<"),c+=u.move(r.safe(e.url,{before:c,after:">",...u.current()})),c+=u.move(">")):(l=r.enter("destinationRaw"),c+=u.move(r.safe(e.url,{before:c,after:e.title?" ":")",...u.current()}))),l(),e.title&&(l=r.enter(`title${i}`),c+=u.move(" "+t),c+=u.move(r.safe(e.title,{before:c,after:t,...u.current()})),c+=u.move(t),l()),c+=u.move(")"),o(),c}function IB(){return"!"}Yv.peek=TB;function Yv(e,n,r,a){const t=e.referenceType,i=r.enter("imageReference");let o=r.enter("label");const l=r.createTracker(a);let u=l.move("![");const c=r.safe(e.alt,{before:u,after:"]",...l.current()});u+=l.move(c+"]["),o();const p=r.stack;r.stack=[],o=r.enter("reference");const d=r.safe(r.associationId(e),{before:u,after:"]",...l.current()});return o(),r.stack=p,i(),t==="full"||!c||c!==d?u+=l.move(d+"]"):t==="shortcut"?u=u.slice(0,-1):u+=l.move("]"),u}function TB(){return"!"}Zv.peek=AB;function Zv(e,n,r){let a=e.value||"",t="`",i=-1;for(;new RegExp("(^|[^`])"+t+"([^`]|$)").test(a);)t+="`";for(/[^ \r\n]/.test(a)&&(/^[ \r\n]/.test(a)&&/[ \r\n]$/.test(a)||/^`|`$/.test(a))&&(a=" "+a+" ");++i<r.unsafe.length;){const o=r.unsafe[i],l=r.compilePattern(o);let u;if(o.atBreak)for(;u=l.exec(a);){let c=u.index;a.charCodeAt(c)===10&&a.charCodeAt(c-1)===13&&c--,a=a.slice(0,c)+" "+a.slice(u.index+1)}}return t+a+t}function AB(){return"`"}function Xv(e,n){const r=Ku(e);return!!(!n.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type==="text"&&(r===e.url||"mailto:"+r===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}Jv.peek=RB;function Jv(e,n,r,a){const t=rc(r),i=t==='"'?"Quote":"Apostrophe",o=r.createTracker(a);let l,u;if(Xv(e,r)){const p=r.stack;r.stack=[],l=r.enter("autolink");let d=o.move("<");return d+=o.move(r.containerPhrasing(e,{before:d,after:">",...o.current()})),d+=o.move(">"),l(),r.stack=p,d}l=r.enter("link"),u=r.enter("label");let c=o.move("[");return c+=o.move(r.containerPhrasing(e,{before:c,after:"](",...o.current()})),c+=o.move("]("),u(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(u=r.enter("destinationLiteral"),c+=o.move("<"),c+=o.move(r.safe(e.url,{before:c,after:">",...o.current()})),c+=o.move(">")):(u=r.enter("destinationRaw"),c+=o.move(r.safe(e.url,{before:c,after:e.title?" ":")",...o.current()}))),u(),e.title&&(u=r.enter(`title${i}`),c+=o.move(" "+t),c+=o.move(r.safe(e.title,{before:c,after:t,...o.current()})),c+=o.move(t),u()),c+=o.move(")"),l(),c}function RB(e,n,r){return Xv(e,r)?"<":"["}Qv.peek=CB;function Qv(e,n,r,a){const t=e.referenceType,i=r.enter("linkReference");let o=r.enter("label");const l=r.createTracker(a);let u=l.move("[");const c=r.containerPhrasing(e,{before:u,after:"]",...l.current()});u+=l.move(c+"]["),o();const p=r.stack;r.stack=[],o=r.enter("reference");const d=r.safe(r.associationId(e),{before:u,after:"]",...l.current()});return o(),r.stack=p,i(),t==="full"||!c||c!==d?u+=l.move(d+"]"):t==="shortcut"?u=u.slice(0,-1):u+=l.move("]"),u}function CB(){return"["}function ac(e){const n=e.options.bullet||"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bullet`, expected `*`, `+`, or `-`");return n}function OB(e){const n=ac(e),r=e.options.bulletOther;if(!r)return n==="*"?"-":"*";if(r!=="*"&&r!=="+"&&r!=="-")throw new Error("Cannot serialize items with `"+r+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(r===n)throw new Error("Expected `bullet` (`"+n+"`) and `bulletOther` (`"+r+"`) to be different");return r}function DB(e){const n=e.options.bulletOrdered||".";if(n!=="."&&n!==")")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOrdered`, expected `.` or `)`");return n}function eS(e){const n=e.options.rule||"*";if(n!=="*"&&n!=="-"&&n!=="_")throw new Error("Cannot serialize rules with `"+n+"` for `options.rule`, expected `*`, `-`, or `_`");return n}function LB(e,n,r,a){const t=r.enter("list"),i=r.bulletCurrent;let o=e.ordered?DB(r):ac(r);const l=e.ordered?o==="."?")":".":OB(r);let u=n&&r.bulletLastUsed?o===r.bulletLastUsed:!1;if(!e.ordered){const p=e.children?e.children[0]:void 0;if((o==="*"||o==="-")&&p&&(!p.children||!p.children[0])&&r.stack[r.stack.length-1]==="list"&&r.stack[r.stack.length-2]==="listItem"&&r.stack[r.stack.length-3]==="list"&&r.stack[r.stack.length-4]==="listItem"&&r.indexStack[r.indexStack.length-1]===0&&r.indexStack[r.indexStack.length-2]===0&&r.indexStack[r.indexStack.length-3]===0&&(u=!0),eS(r)===o&&p){let d=-1;for(;++d<e.children.length;){const g=e.children[d];if(g&&g.type==="listItem"&&g.children&&g.children[0]&&g.children[0].type==="thematicBreak"){u=!0;break}}}}u&&(o=l),r.bulletCurrent=o;const c=r.containerFlow(e,a);return r.bulletLastUsed=o,r.bulletCurrent=i,t(),c}function $B(e){const n=e.options.listItemIndent||"one";if(n!=="tab"&&n!=="one"&&n!=="mixed")throw new Error("Cannot serialize items with `"+n+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return n}function jB(e,n,r,a){const t=$B(r);let i=r.bulletCurrent||ac(r);n&&n.type==="list"&&n.ordered&&(i=(typeof n.start=="number"&&n.start>-1?n.start:1)+(r.options.incrementListMarker===!1?0:n.children.indexOf(e))+i);let o=i.length+1;(t==="tab"||t==="mixed"&&(n&&n.type==="list"&&n.spread||e.spread))&&(o=Math.ceil(o/4)*4);const l=r.createTracker(a);l.move(i+" ".repeat(o-i.length)),l.shift(o);const u=r.enter("listItem"),c=r.indentLines(r.containerFlow(e,l.current()),p);return u(),c;function p(d,g,m){return g?(m?"":" ".repeat(o))+d:(m?i:i+" ".repeat(o-i.length))+d}}function MB(e,n,r,a){const t=r.enter("paragraph"),i=r.enter("phrasing"),o=r.containerPhrasing(e,a);return i(),t(),o}const PB=Kn(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function UB(e,n,r,a){return(e.children.some(function(o){return PB(o)})?r.containerPhrasing:r.containerFlow).call(r,e,a)}function FB(e){const n=e.options.strong||"*";if(n!=="*"&&n!=="_")throw new Error("Cannot serialize strong with `"+n+"` for `options.strong`, expected `*`, or `_`");return n}tS.peek=BB;function tS(e,n,r,a){const t=FB(r),i=r.enter("strong"),o=r.createTracker(a),l=o.move(t+t);let u=o.move(r.containerPhrasing(e,{after:t,before:l,...o.current()}));const c=u.charCodeAt(0),p=$n(a.before.charCodeAt(a.before.length-1),c,t);p.inside&&(u=ln(c)+u.slice(1));const d=u.charCodeAt(u.length-1),g=$n(a.after.charCodeAt(0),d,t);g.inside&&(u=u.slice(0,-1)+ln(d));const m=o.move(t+t);return i(),r.attentionEncodeSurroundingInfo={after:g.outside,before:p.outside},l+u+m}function BB(e,n,r){return r.options.strong||"*"}function zB(e,n,r,a){return r.safe(e.value,a)}function qB(e){const n=e.options.ruleRepetition||3;if(n<3)throw new Error("Cannot serialize rules with repetition `"+n+"` for `options.ruleRepetition`, expected `3` or more");return n}function GB(e,n,r){const a=(eS(r)+(r.options.ruleSpaces?" ":"")).repeat(qB(r));return r.options.ruleSpaces?a.slice(0,-1):a}const nS={blockquote:mB,break:tb,code:vB,definition:EB,emphasis:Vv,hardBreak:tb,heading:_B,html:Wv,image:Kv,imageReference:Yv,inlineCode:Zv,link:Jv,linkReference:Qv,list:LB,listItem:jB,paragraph:MB,root:UB,strong:tS,text:zB,thematicBreak:GB};function HB(){return{enter:{table:VB,tableData:nb,tableHeader:nb,tableRow:KB},exit:{codeText:YB,table:WB,tableData:Jl,tableHeader:Jl,tableRow:Jl}}}function VB(e){const n=e._align;this.enter({type:"table",align:n.map(function(r){return r==="none"?null:r}),children:[]},e),this.data.inTable=!0}function WB(e){this.exit(e),this.data.inTable=void 0}function KB(e){this.enter({type:"tableRow",children:[]},e)}function Jl(e){this.exit(e)}function nb(e){this.enter({type:"tableCell",children:[]},e)}function YB(e){let n=this.resume();this.data.inTable&&(n=n.replace(/\\([\\|])/g,ZB));const r=this.stack[this.stack.length-1];r.type,r.value=n,this.exit(e)}function ZB(e,n){return n==="|"?n:e}function XB(e){const n=e||{},r=n.tableCellPadding,a=n.tablePipeAlign,t=n.stringLength,i=r?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
|
|
185
185
|
`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:g,table:o,tableCell:u,tableRow:l}};function o(m,f,h,v){return c(p(m,h,v),m.align)}function l(m,f,h,v){const S=d(m,h,v),E=c([S]);return E.slice(0,E.indexOf(`
|
|
186
186
|
`))}function u(m,f,h,v){const S=h.enter("tableCell"),E=h.enter("phrasing"),y=h.containerPhrasing(m,{...v,before:i,after:i});return E(),S(),y}function c(m,f){return dB(m,{align:f,alignDelimiters:a,padding:r,stringLength:t})}function p(m,f,h){const v=m.children;let S=-1;const E=[],y=f.enter("table");for(;++S<v.length;)E[S]=d(v[S],f,h);return y(),E}function d(m,f,h){const v=m.children;let S=-1;const E=[],y=f.enter("tableRow");for(;++S<v.length;)E[S]=u(v[S],m,f,h);return y(),E}function g(m,f,h){let v=nS.inlineCode(m,f,h);return h.stack.includes("tableCell")&&(v=v.replace(/\|/g,"\\$&")),v}}function JB(){return{exit:{taskListCheckValueChecked:rb,taskListCheckValueUnchecked:rb,paragraph:e4}}}function QB(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:t4}}}function rb(e){const n=this.stack[this.stack.length-2];n.type,n.checked=e.type==="taskListCheckValueChecked"}function e4(e){const n=this.stack[this.stack.length-2];if(n&&n.type==="listItem"&&typeof n.checked=="boolean"){const r=this.stack[this.stack.length-1];r.type;const a=r.children[0];if(a&&a.type==="text"){const t=n.children;let i=-1,o;for(;++i<t.length;){const l=t[i];if(l.type==="paragraph"){o=l;break}}o===r&&(a.value=a.value.slice(1),a.value.length===0?r.children.shift():r.position&&a.position&&typeof a.position.start.offset=="number"&&(a.position.start.column++,a.position.start.offset++,r.position.start=Object.assign({},a.position.start)))}}this.exit(e)}function t4(e,n,r,a){const t=e.children[0],i=typeof e.checked=="boolean"&&t&&t.type==="paragraph",o="["+(e.checked?"x":" ")+"] ",l=r.createTracker(a);i&&l.move(o);let u=nS.listItem(e,n,r,{...a,...l.current()});return i&&(u=u.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,c)),u;function c(p){return p+o}}function n4(){return[L2(),tB(),iB(),HB(),JB()]}function r4(e){return{extensions:[$2(),nB(e),oB(),XB(e),QB()]}}const a4={tokenize:c4,partial:!0},rS={tokenize:d4,partial:!0},aS={tokenize:p4,partial:!0},iS={tokenize:m4,partial:!0},i4={tokenize:g4,partial:!0},oS={name:"wwwAutolink",tokenize:l4,previous:lS},sS={name:"protocolAutolink",tokenize:u4,previous:uS},dt={name:"emailAutolink",tokenize:s4,previous:cS},at={};function o4(){return{text:at}}let Et=48;for(;Et<123;)at[Et]=dt,Et++,Et===58?Et=65:Et===91&&(Et=97);at[43]=dt;at[45]=dt;at[46]=dt;at[95]=dt;at[72]=[dt,sS];at[104]=[dt,sS];at[87]=[dt,oS];at[119]=[dt,oS];function s4(e,n,r){const a=this;let t,i;return o;function o(d){return!Su(d)||!cS.call(a,a.previous)||ic(a.events)?r(d):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),l(d))}function l(d){return Su(d)?(e.consume(d),l):d===64?(e.consume(d),u):r(d)}function u(d){return d===46?e.check(i4,p,c)(d):d===45||d===95||ve(d)?(i=!0,e.consume(d),u):p(d)}function c(d){return e.consume(d),t=!0,u}function p(d){return i&&t&&Te(a.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),n(d)):r(d)}}function l4(e,n,r){const a=this;return t;function t(o){return o!==87&&o!==119||!lS.call(a,a.previous)||ic(a.events)?r(o):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(a4,e.attempt(rS,e.attempt(aS,i),r),r)(o))}function i(o){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),n(o)}}function u4(e,n,r){const a=this;let t="",i=!1;return o;function o(d){return(d===72||d===104)&&uS.call(a,a.previous)&&!ic(a.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),t+=String.fromCodePoint(d),e.consume(d),l):r(d)}function l(d){if(Te(d)&&t.length<5)return t+=String.fromCodePoint(d),e.consume(d),l;if(d===58){const g=t.toLowerCase();if(g==="http"||g==="https")return e.consume(d),u}return r(d)}function u(d){return d===47?(e.consume(d),i?c:(i=!0,u)):r(d)}function c(d){return d===null||On(d)||se(d)||xt(d)||Hn(d)?r(d):e.attempt(rS,e.attempt(aS,p),r)(d)}function p(d){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),n(d)}}function c4(e,n,r){let a=0;return t;function t(o){return(o===87||o===119)&&a<3?(a++,e.consume(o),t):o===46&&a===3?(e.consume(o),i):r(o)}function i(o){return o===null?r(o):n(o)}}function d4(e,n,r){let a,t,i;return o;function o(c){return c===46||c===95?e.check(iS,u,l)(c):c===null||se(c)||xt(c)||c!==45&&Hn(c)?u(c):(i=!0,e.consume(c),o)}function l(c){return c===95?a=!0:(t=a,a=void 0),e.consume(c),o}function u(c){return t||a||!i?r(c):n(c)}}function p4(e,n){let r=0,a=0;return t;function t(o){return o===40?(r++,e.consume(o),t):o===41&&a<r?i(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(iS,n,i)(o):o===null||se(o)||xt(o)?n(o):(e.consume(o),t)}function i(o){return o===41&&a++,e.consume(o),t}}function m4(e,n,r){return a;function a(l){return l===33||l===34||l===39||l===41||l===42||l===44||l===46||l===58||l===59||l===63||l===95||l===126?(e.consume(l),a):l===38?(e.consume(l),i):l===93?(e.consume(l),t):l===60||l===null||se(l)||xt(l)?n(l):r(l)}function t(l){return l===null||l===40||l===91||se(l)||xt(l)?n(l):a(l)}function i(l){return Te(l)?o(l):r(l)}function o(l){return l===59?(e.consume(l),a):Te(l)?(e.consume(l),o):r(l)}}function g4(e,n,r){return a;function a(i){return e.consume(i),t}function t(i){return ve(i)?r(i):n(i)}}function lS(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||se(e)}function uS(e){return!Te(e)}function cS(e){return!(e===47||Su(e))}function Su(e){return e===43||e===45||e===46||e===95||ve(e)}function ic(e){let n=e.length,r=!1;for(;n--;){const a=e[n][1];if((a.type==="labelLink"||a.type==="labelImage")&&!a._balanced){r=!0;break}if(a._gfmAutolinkLiteralWalkedInto){r=!1;break}}return e.length>0&&!r&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),r}const f4={tokenize:k4,partial:!0};function h4(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:S4,continuation:{tokenize:E4},exit:x4}},text:{91:{name:"gfmFootnoteCall",tokenize:v4},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:b4,resolveTo:y4}}}}function b4(e,n,r){const a=this;let t=a.events.length;const i=a.parser.gfmFootnotes||(a.parser.gfmFootnotes=[]);let o;for(;t--;){const u=a.events[t][1];if(u.type==="labelImage"){o=u;break}if(u.type==="gfmFootnoteCall"||u.type==="labelLink"||u.type==="label"||u.type==="image"||u.type==="link")break}return l;function l(u){if(!o||!o._balanced)return r(u);const c=Qe(a.sliceSerialize({start:o.end,end:a.now()}));return c.codePointAt(0)!==94||!i.includes(c.slice(1))?r(u):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(u),e.exit("gfmFootnoteCallLabelMarker"),n(u))}}function y4(e,n){let r=e.length;for(;r--;)if(e[r][1].type==="labelImage"&&e[r][0]==="enter"){e[r][1];break}e[r+1][1].type="data",e[r+3][1].type="gfmFootnoteCallLabelMarker";const a={type:"gfmFootnoteCall",start:Object.assign({},e[r+3][1].start),end:Object.assign({},e[e.length-1][1].end)},t={type:"gfmFootnoteCallMarker",start:Object.assign({},e[r+3][1].end),end:Object.assign({},e[r+3][1].end)};t.end.column++,t.end.offset++,t.end._bufferIndex++;const i={type:"gfmFootnoteCallString",start:Object.assign({},t.end),end:Object.assign({},e[e.length-1][1].start)},o={type:"chunkString",contentType:"string",start:Object.assign({},i.start),end:Object.assign({},i.end)},l=[e[r+1],e[r+2],["enter",a,n],e[r+3],e[r+4],["enter",t,n],["exit",t,n],["enter",i,n],["enter",o,n],["exit",o,n],["exit",i,n],e[e.length-2],e[e.length-1],["exit",a,n]];return e.splice(r,e.length-r+1,...l),e}function v4(e,n,r){const a=this,t=a.parser.gfmFootnotes||(a.parser.gfmFootnotes=[]);let i=0,o;return l;function l(d){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),u}function u(d){return d!==94?r(d):(e.enter("gfmFootnoteCallMarker"),e.consume(d),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",c)}function c(d){if(i>999||d===93&&!o||d===null||d===91||se(d))return r(d);if(d===93){e.exit("chunkString");const g=e.exit("gfmFootnoteCallString");return t.includes(Qe(a.sliceSerialize(g)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),n):r(d)}return se(d)||(o=!0),i++,e.consume(d),d===92?p:c}function p(d){return d===91||d===92||d===93?(e.consume(d),i++,c):c(d)}}function S4(e,n,r){const a=this,t=a.parser.gfmFootnotes||(a.parser.gfmFootnotes=[]);let i,o=0,l;return u;function u(f){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(f),e.exit("gfmFootnoteDefinitionLabelMarker"),c}function c(f){return f===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(f),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",p):r(f)}function p(f){if(o>999||f===93&&!l||f===null||f===91||se(f))return r(f);if(f===93){e.exit("chunkString");const h=e.exit("gfmFootnoteDefinitionLabelString");return i=Qe(a.sliceSerialize(h)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(f),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),g}return se(f)||(l=!0),o++,e.consume(f),f===92?d:p}function d(f){return f===91||f===92||f===93?(e.consume(f),o++,p):p(f)}function g(f){return f===58?(e.enter("definitionMarker"),e.consume(f),e.exit("definitionMarker"),t.includes(i)||t.push(i),ae(e,m,"gfmFootnoteDefinitionWhitespace")):r(f)}function m(f){return n(f)}}function E4(e,n,r){return e.check(hn,n,e.attempt(f4,n,r))}function x4(e){e.exit("gfmFootnoteDefinition")}function k4(e,n,r){const a=this;return ae(e,t,"gfmFootnoteDefinitionIndent",5);function t(i){const o=a.events[a.events.length-1];return o&&o[1].type==="gfmFootnoteDefinitionIndent"&&o[2].sliceSerialize(o[1],!0).length===4?n(i):r(i)}}function w4(e){let r=(e||{}).singleTilde;const a={name:"strikethrough",tokenize:i,resolveAll:t};return r==null&&(r=!0),{text:{126:a},insideSpan:{null:[a]},attentionMarkers:{null:[126]}};function t(o,l){let u=-1;for(;++u<o.length;)if(o[u][0]==="enter"&&o[u][1].type==="strikethroughSequenceTemporary"&&o[u][1]._close){let c=u;for(;c--;)if(o[c][0]==="exit"&&o[c][1].type==="strikethroughSequenceTemporary"&&o[c][1]._open&&o[u][1].end.offset-o[u][1].start.offset===o[c][1].end.offset-o[c][1].start.offset){o[u][1].type="strikethroughSequence",o[c][1].type="strikethroughSequence";const p={type:"strikethrough",start:Object.assign({},o[c][1].start),end:Object.assign({},o[u][1].end)},d={type:"strikethroughText",start:Object.assign({},o[c][1].end),end:Object.assign({},o[u][1].start)},g=[["enter",p,l],["enter",o[c][1],l],["exit",o[c][1],l],["enter",d,l]],m=l.parser.constructs.insideSpan.null;m&&Be(g,g.length,0,Vn(m,o.slice(c+1,u),l)),Be(g,g.length,0,[["exit",d,l],["enter",o[u][1],l],["exit",o[u][1],l],["exit",p,l]]),Be(o,c-1,u-c+3,g),u=c+g.length-2;break}}for(u=-1;++u<o.length;)o[u][1].type==="strikethroughSequenceTemporary"&&(o[u][1].type="data");return o}function i(o,l,u){const c=this.previous,p=this.events;let d=0;return g;function g(f){return c===126&&p[p.length-1][1].type!=="characterEscape"?u(f):(o.enter("strikethroughSequenceTemporary"),m(f))}function m(f){const h=Mt(c);if(f===126)return d>1?u(f):(o.consume(f),d++,m);if(d<2&&!r)return u(f);const v=o.exit("strikethroughSequenceTemporary"),S=Mt(f);return v._open=!S||S===2&&!!h,v._close=!h||h===2&&!!S,l(f)}}}class _4{constructor(){this.map=[]}add(n,r,a){N4(this,n,r,a)}consume(n){if(this.map.sort(function(i,o){return i[0]-o[0]}),this.map.length===0)return;let r=this.map.length;const a=[];for(;r>0;)r-=1,a.push(n.slice(this.map[r][0]+this.map[r][1]),this.map[r][2]),n.length=this.map[r][0];a.push(n.slice()),n.length=0;let t=a.pop();for(;t;){for(const i of t)n.push(i);t=a.pop()}this.map.length=0}}function N4(e,n,r,a){let t=0;if(!(r===0&&a.length===0)){for(;t<e.map.length;){if(e.map[t][0]===n){e.map[t][1]+=r,e.map[t][2].push(...a);return}t+=1}e.map.push([n,r,a])}}function I4(e,n){let r=!1;const a=[];for(;n<e.length;){const t=e[n];if(r){if(t[0]==="enter")t[1].type==="tableContent"&&a.push(e[n+1][1].type==="tableDelimiterMarker"?"left":"none");else if(t[1].type==="tableContent"){if(e[n-1][1].type==="tableDelimiterMarker"){const i=a.length-1;a[i]=a[i]==="left"?"center":"right"}}else if(t[1].type==="tableDelimiterRow")break}else t[0]==="enter"&&t[1].type==="tableDelimiterRow"&&(r=!0);n+=1}return a}function T4(){return{flow:{null:{name:"table",tokenize:A4,resolveAll:R4}}}}function A4(e,n,r){const a=this;let t=0,i=0,o;return l;function l(k){let A=a.events.length-1;for(;A>-1;){const P=a.events[A][1].type;if(P==="lineEnding"||P==="linePrefix")A--;else break}const j=A>-1?a.events[A][1].type:null,$=j==="tableHead"||j==="tableRow"?b:u;return $===b&&a.parser.lazy[a.now().line]?r(k):$(k)}function u(k){return e.enter("tableHead"),e.enter("tableRow"),c(k)}function c(k){return k===124||(o=!0,i+=1),p(k)}function p(k){return k===null?r(k):V(k)?i>1?(i=0,a.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(k),e.exit("lineEnding"),m):r(k):re(k)?ae(e,p,"whitespace")(k):(i+=1,o&&(o=!1,t+=1),k===124?(e.enter("tableCellDivider"),e.consume(k),e.exit("tableCellDivider"),o=!0,p):(e.enter("data"),d(k)))}function d(k){return k===null||k===124||se(k)?(e.exit("data"),p(k)):(e.consume(k),k===92?g:d)}function g(k){return k===92||k===124?(e.consume(k),d):d(k)}function m(k){return a.interrupt=!1,a.parser.lazy[a.now().line]?r(k):(e.enter("tableDelimiterRow"),o=!1,re(k)?ae(e,f,"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(k):f(k))}function f(k){return k===45||k===58?v(k):k===124?(o=!0,e.enter("tableCellDivider"),e.consume(k),e.exit("tableCellDivider"),h):I(k)}function h(k){return re(k)?ae(e,v,"whitespace")(k):v(k)}function v(k){return k===58?(i+=1,o=!0,e.enter("tableDelimiterMarker"),e.consume(k),e.exit("tableDelimiterMarker"),S):k===45?(i+=1,S(k)):k===null||V(k)?w(k):I(k)}function S(k){return k===45?(e.enter("tableDelimiterFiller"),E(k)):I(k)}function E(k){return k===45?(e.consume(k),E):k===58?(o=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(k),e.exit("tableDelimiterMarker"),y):(e.exit("tableDelimiterFiller"),y(k))}function y(k){return re(k)?ae(e,w,"whitespace")(k):w(k)}function w(k){return k===124?f(k):k===null||V(k)?!o||t!==i?I(k):(e.exit("tableDelimiterRow"),e.exit("tableHead"),n(k)):I(k)}function I(k){return r(k)}function b(k){return e.enter("tableRow"),T(k)}function T(k){return k===124?(e.enter("tableCellDivider"),e.consume(k),e.exit("tableCellDivider"),T):k===null||V(k)?(e.exit("tableRow"),n(k)):re(k)?ae(e,T,"whitespace")(k):(e.enter("data"),D(k))}function D(k){return k===null||k===124||se(k)?(e.exit("data"),T(k)):(e.consume(k),k===92?_:D)}function _(k){return k===92||k===124?(e.consume(k),D):D(k)}}function R4(e,n){let r=-1,a=!0,t=0,i=[0,0,0,0],o=[0,0,0,0],l=!1,u=0,c,p,d;const g=new _4;for(;++r<e.length;){const m=e[r],f=m[1];m[0]==="enter"?f.type==="tableHead"?(l=!1,u!==0&&(ab(g,n,u,c,p),p=void 0,u=0),c={type:"table",start:Object.assign({},f.start),end:Object.assign({},f.end)},g.add(r,0,[["enter",c,n]])):f.type==="tableRow"||f.type==="tableDelimiterRow"?(a=!0,d=void 0,i=[0,0,0,0],o=[0,r+1,0,0],l&&(l=!1,p={type:"tableBody",start:Object.assign({},f.start),end:Object.assign({},f.end)},g.add(r,0,[["enter",p,n]])),t=f.type==="tableDelimiterRow"?2:p?3:1):t&&(f.type==="data"||f.type==="tableDelimiterMarker"||f.type==="tableDelimiterFiller")?(a=!1,o[2]===0&&(i[1]!==0&&(o[0]=o[1],d=kn(g,n,i,t,void 0,d),i=[0,0,0,0]),o[2]=r)):f.type==="tableCellDivider"&&(a?a=!1:(i[1]!==0&&(o[0]=o[1],d=kn(g,n,i,t,void 0,d)),i=o,o=[i[1],r,0,0])):f.type==="tableHead"?(l=!0,u=r):f.type==="tableRow"||f.type==="tableDelimiterRow"?(u=r,i[1]!==0?(o[0]=o[1],d=kn(g,n,i,t,r,d)):o[1]!==0&&(d=kn(g,n,o,t,r,d)),t=0):t&&(f.type==="data"||f.type==="tableDelimiterMarker"||f.type==="tableDelimiterFiller")&&(o[3]=r)}for(u!==0&&ab(g,n,u,c,p),g.consume(n.events),r=-1;++r<n.events.length;){const m=n.events[r];m[0]==="enter"&&m[1].type==="table"&&(m[1]._align=I4(n.events,r))}return e}function kn(e,n,r,a,t,i){const o=a===1?"tableHeader":a===2?"tableDelimiter":"tableData",l="tableContent";r[0]!==0&&(i.end=Object.assign({},At(n.events,r[0])),e.add(r[0],0,[["exit",i,n]]));const u=At(n.events,r[1]);if(i={type:o,start:Object.assign({},u),end:Object.assign({},u)},e.add(r[1],0,[["enter",i,n]]),r[2]!==0){const c=At(n.events,r[2]),p=At(n.events,r[3]),d={type:l,start:Object.assign({},c),end:Object.assign({},p)};if(e.add(r[2],0,[["enter",d,n]]),a!==2){const g=n.events[r[2]],m=n.events[r[3]];if(g[1].end=Object.assign({},m[1].end),g[1].type="chunkText",g[1].contentType="text",r[3]>r[2]+1){const f=r[2]+1,h=r[3]-r[2]-1;e.add(f,h,[])}}e.add(r[3]+1,0,[["exit",d,n]])}return t!==void 0&&(i.end=Object.assign({},At(n.events,t)),e.add(t,0,[["exit",i,n]]),i=void 0),i}function ab(e,n,r,a,t){const i=[],o=At(n.events,r);t&&(t.end=Object.assign({},o),i.push(["exit",t,n])),a.end=Object.assign({},o),i.push(["exit",a,n]),e.add(r+1,0,i)}function At(e,n){const r=e[n],a=r[0]==="enter"?"start":"end";return r[1][a]}const C4={name:"tasklistCheck",tokenize:D4};function O4(){return{text:{91:C4}}}function D4(e,n,r){const a=this;return t;function t(u){return a.previous!==null||!a._gfmTasklistFirstContentOfListItem?r(u):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(u),e.exit("taskListCheckMarker"),i)}function i(u){return se(u)?(e.enter("taskListCheckValueUnchecked"),e.consume(u),e.exit("taskListCheckValueUnchecked"),o):u===88||u===120?(e.enter("taskListCheckValueChecked"),e.consume(u),e.exit("taskListCheckValueChecked"),o):r(u)}function o(u){return u===93?(e.enter("taskListCheckMarker"),e.consume(u),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),l):r(u)}function l(u){return V(u)?n(u):re(u)?e.check({tokenize:L4},n,r)(u):r(u)}}function L4(e,n,r){return ae(e,a,"whitespace");function a(t){return t===null?r(t):n(t)}}function $4(e){return Ev([o4(),h4(),w4(e),T4(),O4()])}const j4={};function M4(e){const n=this,r=e||j4,a=n.data(),t=a.micromarkExtensions||(a.micromarkExtensions=[]),i=a.fromMarkdownExtensions||(a.fromMarkdownExtensions=[]),o=a.toMarkdownExtensions||(a.toMarkdownExtensions=[]);t.push($4(r)),i.push(n4()),o.push(r4(r))}function P4(e){if(!e)return!1;try{return new URL(e),!0}catch{return!1}}const U4=({href:e,children:n})=>{const[r,a]=C.useState(!1),{openPreview:t}=wu(),i=P4(e),o=l=>{l.preventDefault(),l.stopPropagation(),e&&t(e)};return i?s.jsxs("span",{className:"relative inline-block pr-8",onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),children:[s.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:text-primary/80 underline underline-offset-4 decoration-primary/30 hover:decoration-primary/60 transition-colors",children:n}),r&&s.jsx("button",{type:"button",onClick:o,className:"absolute right-0 top-1/2 -translate-y-1/2 p-1 bg-primary text-primary-foreground rounded hover:bg-primary/90 transition-colors shadow-md z-10","aria-label":"Preview in browser",children:s.jsxs("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",role:"img","aria-labelledby":"preview-icon-title",children:[s.jsx("title",{id:"preview-icon-title",children:"Preview"}),s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"}),s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"})]})})]}):s.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:text-primary/80 underline underline-offset-4 decoration-primary/30 hover:decoration-primary/60 transition-colors",children:n})},dS=({content:e,className:n=""})=>{const{resolvedTheme:r}=py(),a=r==="dark"?iv:ov;return s.jsx("div",{className:`prose prose-neutral dark:prose-invert max-w-none ${n}`,children:s.jsx(w2,{remarkPlugins:[M4],components:{h1({children:t,...i}){return s.jsx("h1",{className:"text-3xl font-bold mb-6 mt-8 pb-3 border-b border-border text-foreground",...i,children:t})},h2({children:t,...i}){return s.jsx("h2",{className:"text-2xl font-semibold mb-4 mt-8 pb-2 border-b border-border/50 text-foreground",...i,children:t})},h3({children:t,...i}){return s.jsx("h3",{className:"text-xl font-semibold mb-3 mt-6 text-foreground",...i,children:t})},h4({children:t,...i}){return s.jsx("h4",{className:"text-lg font-medium mb-2 mt-4 text-foreground",...i,children:t})},h5({children:t,...i}){return s.jsx("h5",{className:"text-base font-medium mb-2 mt-4 text-foreground",...i,children:t})},h6({children:t,...i}){return s.jsx("h6",{className:"text-sm font-medium mb-2 mt-4 text-muted-foreground",...i,children:t})},p({children:t,...i}){return s.jsx("p",{className:"mb-4 leading-7 text-foreground break-all",...i,children:t})},ul({children:t,...i}){return s.jsx("ul",{className:"mb-4 ml-6 list-disc space-y-2",...i,children:t})},ol({children:t,...i}){return s.jsx("ol",{className:"mb-4 ml-6 list-decimal space-y-2",...i,children:t})},li({children:t,...i}){return s.jsx("li",{className:"leading-7 text-foreground",...i,children:t})},code({className:t,children:i,...o}){const l=/language-(\w+)/.exec(t||"");return l?s.jsxs("div",{className:"relative my-6",children:[s.jsx("div",{className:"flex items-center justify-between bg-muted/30 px-4 py-2 border-b border-border rounded-t-lg",children:s.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:l[1]})}),s.jsx(Bu,{style:a,language:l[1],PreTag:"div",className:"!mt-0 !rounded-t-none !rounded-b-lg !border-t-0 !border !border-border",customStyle:{margin:0,borderTopLeftRadius:0,borderTopRightRadius:0},children:String(i).replace(/\n$/,"")})]}):s.jsx("code",{className:"bg-muted/70 px-2 py-1 rounded-md text-sm font-mono text-foreground border break-all",...o,children:i})},pre({children:t,...i}){return s.jsx("pre",{...i,children:t})},blockquote({children:t,...i}){return s.jsx("blockquote",{className:"border-l-4 border-primary/30 bg-muted/30 pl-6 pr-4 py-4 my-6 italic rounded-r-lg",...i,children:s.jsx("div",{className:"text-muted-foreground",children:t})})},a({children:t,href:i,...o}){return s.jsx(U4,{href:i,...o,children:t})},table({children:t,...i}){return s.jsx("div",{className:"overflow-x-auto my-6 rounded-lg border border-border max-w-full",children:s.jsx("table",{className:"w-full border-collapse",...i,children:t})})},thead({children:t,...i}){return s.jsx("thead",{className:"bg-muted/50",...i,children:t})},th({children:t,...i}){return s.jsx("th",{className:"border-b border-border px-4 py-3 text-left font-semibold text-foreground",...i,children:t})},td({children:t,...i}){return s.jsx("td",{className:"border-b border-border px-4 py-3 text-foreground",...i,children:t})},hr({...t}){return s.jsx("hr",{className:"my-8 border-t border-border",...t})},strong({children:t,...i}){return s.jsx("strong",{className:"font-semibold text-foreground",...i,children:t})},em({children:t,...i}){return s.jsx("em",{className:"italic text-foreground",...i,children:t})}},children:e})})},F4=e=>e.type!=="user"?null:typeof e.message.content=="string"?e.message.content:(()=>{const r=e.message.content.at(0);return r===void 0?null:typeof r=="string"?r:r.type==="text"?r.text:null})(),B4=({prompt:e,projectId:n,sessionId:r,agentId:a,getSidechainConversationByPrompt:t,getSidechainConversations:i,getToolResult:o})=>{const[l,u]=C.useState(!1),c=t(e),p=c!==void 0?i(c.uuid):[],d=p.length>0,g=l&&!d&&a!==void 0,{data:m,isLoading:f,error:h,refetch:v}=Pt({...UI(n,a??""),enabled:g,staleTime:0}),S=d?p.map(k=>({...k,isSidechain:!1})):m?.conversations??[],E=d?void 0:m?.agentSessionId,y=d?c?.uuid:E,w=(()=>{const k=S.at(0);return k?F4(k)??e:e.length>60?`${e.slice(0,60)}...`:e})(),I=g&&f,b=g&&h!==null,T=!I&&!b&&S.length===0&&l,D=!I&&!b&&S.length>0,_=C.useMemo(()=>S.find(k=>k.type==="user"||k.type==="assistant"||k.type==="system"),[S]);return s.jsxs(cn,{open:l,onOpenChange:u,children:[s.jsx(PI,{asChild:!0,children:s.jsxs(ne,{variant:"ghost",size:"sm",className:"h-auto py-1.5 px-3 text-xs hover:bg-blue-100 dark:hover:bg-blue-900/30 rounded-none flex items-center gap-1","data-testid":"task-modal-button",children:[s.jsx(lT,{className:"h-3 w-3"}),s.jsx(R,{id:"assistant.tool.view_task_details"})]})}),s.jsxs(dn,{className:"w-[95vw] md:w-[90vw] lg:w-[85vw] max-w-[1400px] h-[85vh] max-h-[85vh] flex flex-col p-0","data-testid":"task-modal",children:[s.jsx(jn,{className:"px-6 py-4 border-b bg-muted/30",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("div",{className:"flex-shrink-0 mt-1",children:s.jsx("div",{className:"h-10 w-10 rounded-lg bg-primary/10 flex items-center justify-center",children:s.jsx(pn,{className:"h-5 w-5 text-primary"})})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx(Mn,{className:"text-lg font-semibold leading-tight mb-1",children:w.length>120?`${w.slice(0,120)}...`:w}),s.jsxs(Pn,{className:"text-xs flex items-center gap-2 flex-wrap",children:[y!=null&&s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(R,{id:"assistant.tool.task_id"}),":"," ",s.jsx("code",{className:"px-1.5 py-0.5 bg-muted rounded text-[10px] font-mono",children:y.slice(0,8)})]}),s.jsx("span",{className:"text-muted-foreground",children:"|"})]}),s.jsx("span",{children:s.jsx(R,{id:"assistant.tool.message_count",values:{count:S.length}})})]})]})]})}),s.jsxs("div",{className:"flex-1 overflow-auto px-6 py-4",children:[I&&s.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4",children:[s.jsx(Tt,{className:"h-8 w-8 animate-spin text-primary"}),s.jsx("p",{className:"text-sm text-muted-foreground",children:s.jsx(R,{id:"assistant.tool.loading_task"})})]}),b&&s.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4",children:[s.jsx(JI,{className:"h-8 w-8 text-destructive"}),s.jsx("p",{className:"text-sm text-destructive",children:s.jsx(R,{id:"assistant.tool.error_loading_task"})}),s.jsx(ne,{variant:"outline",size:"sm",onClick:()=>v(),children:s.jsx(R,{id:"assistant.tool.retry"})})]}),T&&s.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4",children:[s.jsx(pe,{variant:"secondary",className:"text-sm",children:s.jsx(R,{id:"assistant.tool.no_task_data"})}),s.jsx("p",{className:"text-xs text-muted-foreground max-w-md text-center",children:s.jsx(R,{id:"assistant.tool.no_task_data_description"})})]}),D&&s.jsx(mS,{conversations:[...d?[]:[{type:"user",message:{role:"user",content:e},isSidechain:!1,userType:"external",cwd:_?.cwd??"dummy",sessionId:r,version:_?.version??"dummy",uuid:"dummy",timestamp:_?.timestamp??"dummy",parentUuid:null,isMeta:!1,toolUseResult:void 0,gitBranch:_?.gitBranch??"dummy",isCompactSummary:!1}],...S.map(k=>({...k,isSidechain:!1}))],getToolResult:o,projectId:n,sessionId:r})]})]})]})},z4=({input:e})=>{const n=Object.entries(e);return n.length===0?null:s.jsx("span",{children:n.map(([r,a],t)=>{const i=typeof a=="string"?a:JSON.stringify(a).replace(/^"|"$/g,"");return s.jsxs("span",{children:[t>0&&s.jsx("span",{className:"text-muted-foreground",children:", "}),s.jsxs("span",{className:"text-muted-foreground",children:[r,"="]}),s.jsx("span",{children:i})]},r)})})},pS=Nc.object({prompt:Nc.string()}),q4=({content:e,getToolResult:n,getAgentIdForToolUse:r,getSidechainConversationByPrompt:a,getSidechainConversations:t,projectId:i,sessionId:o})=>{const{resolvedTheme:l}=py(),u=l==="dark"?iv:ov;if(e.type==="text")return s.jsx("div",{className:"w-full mx-1 sm:mx-2 my-4 sm:my-6",children:s.jsx(dS,{content:e.text})});if(e.type==="thinking")return s.jsx(ut,{className:"bg-muted/50 border-dashed gap-2 py-3 mb-2 hover:shadow-sm transition-all duration-200",children:s.jsxs(Le,{children:[s.jsx(We,{asChild:!0,children:s.jsx(nn,{className:"cursor-pointer hover:bg-muted/80 rounded-t-lg transition-all duration-200 py-0 px-4 group",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(DT,{className:"h-4 w-4 text-muted-foreground group-hover:text-yellow-600 transition-colors"}),s.jsx(rn,{className:"text-sm font-medium group-hover:text-foreground transition-colors",children:s.jsx(R,{id:"assistant.thinking"})}),s.jsx($e,{className:"h-4 w-4 text-muted-foreground transition-transform duration-200 group-data-[state=open]:rotate-180"})]})})}),s.jsx(je,{children:s.jsx("div",{className:"py-2 px-4",children:s.jsx("div",{className:"text-sm text-muted-foreground whitespace-pre-wrap font-mono",children:e.thinking})})})]})});if(e.type==="tool_use"){const c=n(e.id),p=(()=>{const d=e.name==="Task"?pS.safeParse(e.input):void 0;if(d===void 0||d.success===!1)return;const g=r(e.id);return s.jsx(B4,{prompt:d.data.prompt,projectId:i,sessionId:o,agentId:g,getSidechainConversationByPrompt:a,getSidechainConversations:t,getToolResult:n})})();return s.jsx(ut,{className:"border-blue-200 bg-blue-50/50 dark:border-blue-800 dark:bg-blue-950/20 mb-2 p-0 overflow-hidden",children:s.jsxs(Le,{children:[s.jsxs("div",{className:"flex items-center min-w-0",children:[s.jsx(We,{asChild:!0,children:s.jsx("div",{className:"flex-1 min-w-0 cursor-pointer hover:bg-blue-100/50 dark:hover:bg-blue-900/20 transition-all duration-200 px-3 py-1.5 group",children:s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx(tA,{className:"h-4 w-4 text-blue-600 dark:text-blue-400 flex-shrink-0"}),s.jsxs("div",{className:"w-full min-w-0 text-sm font-medium group-hover:text-foreground transition-colors overflow-hidden text-ellipsis whitespace-nowrap",children:[e.name,Object.keys(e.input).length>0&&s.jsxs("span",{className:"font-normal",children:[" ","(",s.jsx(z4,{input:e.input}),")"]})]}),s.jsx($e,{className:"h-4 w-4 text-muted-foreground transition-transform duration-200 group-data-[state=open]:rotate-180 flex-shrink-0"})]})})}),p&&s.jsx("div",{className:"flex-shrink-0 border-l border-blue-200 dark:border-blue-800 flex items-center",children:p})]}),s.jsx(je,{children:s.jsxs("div",{className:"space-y-3 py-3 px-4 border-t border-blue-200 dark:border-blue-800",children:[s.jsxs("div",{children:[s.jsx("h4",{className:"text-xs font-medium text-muted-foreground mb-1",children:s.jsx(R,{id:"assistant.tool.tool_id"})}),s.jsx("code",{className:"text-xs bg-background/50 px-2 py-1 rounded border border-blue-200 dark:border-blue-800 font-mono",children:e.id})]}),s.jsxs("div",{children:[s.jsx("h4",{className:"text-xs font-medium text-muted-foreground mb-2",children:s.jsx(R,{id:"assistant.tool.input_parameters"})}),s.jsx(Bu,{style:u,language:"json",PreTag:"div",className:"text-xs rounded",children:JSON.stringify(e.input,null,2)})]}),c&&s.jsxs("div",{children:[s.jsx("h4",{className:"text-xs font-medium text-muted-foreground mb-2",children:s.jsx(R,{id:"assistant.tool.result"})}),s.jsx("div",{className:"bg-background rounded border p-3",children:typeof c.content=="string"?s.jsx("pre",{className:"text-xs overflow-x-auto whitespace-pre-wrap break-words",children:c.content}):c.content.map(d=>{if(d.type==="image")return s.jsx("img",{src:`data:${d.source.media_type};base64,${d.source.data}`,alt:"Tool Result"},d.source.data);if(d.type==="text")return s.jsx("pre",{className:"text-xs overflow-x-auto whitespace-pre-wrap break-words",children:d.text},d.text);throw new Error("Unexpected tool result content type")})})]})]})})]})})}return e.type==="tool_result",null},G4=e=>{const n=e.filter(d=>d.type!=="summary"&&d.type!=="file-history-snapshot"&&d.type!=="queue-operation").filter(d=>d.isSidechain===!0),r=C.useMemo(()=>new Map(n.map(d=>[d.uuid,d])),[n]),a=C.useMemo(()=>new Map(n.filter(d=>d.type==="user").filter(d=>d.parentUuid===null&&typeof d.message.content=="string").map(d=>[d.message.content,d])),[n]),t=C.useMemo(()=>new Set(e.filter(d=>d.type==="assistant").flatMap(d=>[...d.message.content.filter(g=>g.type==="tool_use")]).flatMap(d=>{if(d.name!=="Task")return[];const g=pS.safeParse(d.input);return g.success===!1?[]:[g.data.prompt]})),[e]),i=C.useCallback(d=>{if(d.parentUuid===null)return d;const g=r.get(d.parentUuid);return g===void 0?d:i(g)},[r]),o=C.useMemo(()=>{const d=new Map;for(const g of n){const m=i(g);d.has(m.uuid)?d.get(m.uuid)?.push(g):d.set(m.uuid,[g])}return d},[n,i]),l=C.useCallback(d=>d.type==="summary"||d.type==="file-history-snapshot"||d.type==="queue-operation"?!1:o.has(d.uuid),[o]),u=C.useCallback(d=>o.get(d)??[],[o]),c=C.useCallback(d=>a.get(d),[a]);return{isRootSidechain:l,getSidechainConversations:u,getSidechainConversationByPrompt:c,existsRelatedTaskCall:d=>t.has(d)}},H4=({conversation:e})=>{const n=Object.keys(e.snapshot.trackedFileBackups).length,{config:r}=kt();return s.jsxs(Le,{children:[s.jsx(We,{asChild:!0,children:s.jsxs("div",{className:"flex items-center justify-between cursor-pointer hover:bg-muted/50 rounded p-2 -mx-2",children:[s.jsxs("h4",{className:"text-xs font-medium text-muted-foreground",children:["File History Snapshot ",n>0&&`(${n} files)`]}),s.jsx($e,{className:"h-3 w-3 text-muted-foreground transition-transform group-data-[state=open]:rotate-180"})]})}),s.jsx(je,{children:s.jsx("div",{className:"bg-background rounded border p-3 mt-2",children:s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"text-xs",children:[s.jsx("span",{className:"text-muted-foreground",children:"Timestamp: "}),s.jsx("span",{children:Nu(e.snapshot.timestamp,{locale:r.locale})})]}),s.jsxs("div",{className:"text-xs",children:[s.jsx("span",{className:"text-muted-foreground",children:"Message ID: "}),s.jsx("span",{className:"font-mono",children:e.messageId})]}),s.jsxs("div",{className:"text-xs",children:[s.jsxs("span",{className:"text-muted-foreground",children:["Is Snapshot Update:"," "]}),s.jsx("span",{children:e.isSnapshotUpdate?"Yes":"No"})]}),n>0&&s.jsxs("div",{className:"text-xs",children:[s.jsx("div",{className:"text-muted-foreground mb-1",children:"Tracked Files:"}),s.jsx("ul",{className:"list-disc list-inside space-y-1",children:Object.keys(e.snapshot.trackedFileBackups).map(a=>s.jsx("li",{className:"font-mono text-xs break-all",children:a},a))})]})]})})})]})},V4=({children:e})=>s.jsxs(Le,{children:[s.jsx(We,{asChild:!0,children:s.jsxs("div",{className:"flex items-center justify-between cursor-pointer hover:bg-muted/50 rounded p-2 -mx-2 mb-2",children:[s.jsx("h4",{className:"text-xs font-medium text-muted-foreground",children:"Meta Information"}),s.jsx($e,{className:"h-3 w-3 text-muted-foreground transition-transform group-data-[state=open]:rotate-180"})]})}),s.jsx(je,{children:s.jsx("div",{className:"bg-background rounded border p-3 mt-2",children:e})})]}),W4=e=>typeof e=="string"?e:e.map(n=>typeof n=="string"?n:n.type==="text"?n.text:n.type==="image"?"[Image]":n.type==="document"?"[Document]":n.type==="tool_result"?"[Tool Result]":n).join(`
|
|
187
|
-
`),K4=({conversation:e})=>{const n=e.operation==="enqueue"?"Queue Operation: Enqueue":"Queue Operation: Dequeue";return s.jsxs(Le,{children:[s.jsx(We,{asChild:!0,children:s.jsxs("div",{className:"flex items-center justify-between cursor-pointer hover:bg-muted/50 rounded p-2 -mx-2",children:[s.jsx("h4",{className:"text-xs font-medium text-muted-foreground",children:n}),s.jsx($e,{className:"h-3 w-3 text-muted-foreground transition-transform group-data-[state=open]:rotate-180"})]})}),s.jsx(je,{children:s.jsx("div",{className:"bg-background rounded border p-3 mt-2",children:s.jsxs("div",{className:"space-y-2 text-xs",children:[s.jsxs("div",{children:[s.jsx("span",{className:"font-medium text-muted-foreground",children:"Operation:"})," ",e.operation]}),s.jsxs("div",{children:[s.jsx("span",{className:"font-medium text-muted-foreground",children:"Session ID:"})," ",e.sessionId]}),s.jsxs("div",{children:[s.jsx("span",{className:"font-medium text-muted-foreground",children:"Timestamp:"})," ",e.timestamp]}),e.operation==="enqueue"&&s.jsxs("div",{children:[s.jsx("span",{className:"font-medium text-muted-foreground",children:"Content:"}),s.jsx("pre",{className:"mt-1 overflow-x-auto whitespace-pre-wrap",children:W4(e.content)})]})]})})})]})},Y4=({children:e})=>s.jsxs(Le,{children:[s.jsx(We,{asChild:!0,children:s.jsxs("div",{className:"flex items-center justify-between cursor-pointer hover:bg-muted/50 rounded p-2 -mx-2 mb-2",children:[s.jsx("h4",{className:"text-xs font-medium text-muted-foreground",children:"Summarized"}),s.jsx($e,{className:"h-3 w-3 text-muted-foreground transition-transform group-data-[state=open]:rotate-180"})]})}),s.jsx(je,{children:s.jsx("div",{className:"bg-background rounded border p-3 mt-2",children:s.jsx("pre",{className:"text-xs overflow-x-auto",children:e})})})]}),Z4=({children:e})=>s.jsxs(Le,{children:[s.jsx(We,{asChild:!0,children:s.jsxs("div",{className:"flex items-center justify-between cursor-pointer hover:bg-muted/50 rounded p-2 -mx-2",children:[s.jsx("h4",{className:"text-xs font-medium text-muted-foreground",children:"System Message"}),s.jsx($e,{className:"h-3 w-3 text-muted-foreground transition-transform group-data-[state=open]:rotate-180"})]})}),s.jsx(je,{children:s.jsx("div",{className:"bg-background rounded border p-3 mt-2",children:s.jsx("pre",{className:"text-xs overflow-x-auto",children:e})})})]}),X4=/<(?<tag>[^>]+)>(?<content>\s*[^<]*?\s*)<\/\k<tag>>/g,J4=Je({tag:He(),content:He()});xu([Je({kind:ct("command"),commandName:He(),commandArgs:He().optional(),commandMessage:He().optional()}),Je({kind:ct("local-command"),stdout:He()}),Je({kind:ct("text"),content:He()})]);const Q4=e=>{const n=Array.from(e.matchAll(X4)).map(o=>J4.safeParse(o.groups)).filter(o=>o.success).map(o=>o.data);if(n.length===0)return{kind:"text",content:e};const r=n.find(o=>o.tag==="command-name")?.content,a=n.find(o=>o.tag==="command-args")?.content,t=n.find(o=>o.tag==="command-message")?.content,i=n.find(o=>o.tag==="local-command-stdout")?.content;switch(!0){case r!==void 0:return{kind:"command",commandName:r,commandArgs:a,commandMessage:t};case i!==void 0:return{kind:"local-command",stdout:i};default:return{kind:"text",content:e}}},ib=({text:e,id:n})=>{const r=Q4(e);return r.kind==="command"?s.jsxs(ut,{className:"border-green-200 bg-green-50/50 dark:border-green-800 dark:bg-green-950/20 gap-2 py-3 mb-3",id:n,children:[s.jsx(nn,{className:"py-0 px-4",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(au,{className:"h-4 w-4 text-green-600 dark:text-green-400"}),s.jsx(rn,{className:"text-sm font-medium",children:"Claude Code Command"}),s.jsx(pe,{variant:"outline",className:"border-green-300 text-green-700 dark:border-green-700 dark:text-green-300",children:r.commandName})]})}),r.commandArgs||r.commandMessage?s.jsx(hc,{className:"py-0 px-4",children:s.jsx("div",{className:"space-y-2",children:s.jsxs("div",{children:[r.commandArgs&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Arguments:"}),s.jsx("div",{className:"bg-background rounded border p-2 mt-1",children:s.jsx("code",{className:"text-xs whitespace-pre-line break-all",children:r.commandArgs})})]}),r.commandMessage&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Message:"}),s.jsx("div",{className:"bg-background rounded border p-2 mt-1",children:s.jsx("code",{className:"text-xs whitespace-pre-line break-all",children:r.commandMessage})})]})]})})}):null]}):r.kind==="local-command"?s.jsxs(ut,{className:"border-green-200 bg-green-50/50 dark:border-green-800 dark:bg-green-950/20 gap-2 py-3 mb-3",children:[s.jsx(nn,{className:"py-0 px-4",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(au,{className:"h-4 w-4 text-green-600 dark:text-green-400"}),s.jsx(rn,{className:"text-sm font-medium",children:"Local Command"})]})}),s.jsx(hc,{className:"py-0 px-4",children:s.jsx("pre",{className:"text-xs overflow-x-auto whitespace-pre-wrap break-words",children:r.stdout})})]}):s.jsx(dS,{className:"w-full px-3 py-3 mb-5 border border-border rounded-lg bg-slate-50 dark:bg-slate-900/50",content:r.content})},ob=({content:e,id:n})=>typeof e=="string"?s.jsx(ib,{text:e,id:n}):e.type==="text"?s.jsx(ib,{text:e.text,id:n}):e.type==="image"?e.source.type==="base64"?s.jsx(ut,{className:"border-purple-200 bg-purple-50/50 dark:border-purple-800 dark:bg-purple-950/20 mb-2 p-0 overflow-hidden",id:n,children:s.jsxs(Le,{children:[s.jsx(We,{asChild:!0,children:s.jsx("div",{className:"cursor-pointer hover:bg-purple-100/50 dark:hover:bg-purple-900/20 transition-colors px-3 py-1.5 group",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(CT,{className:"h-4 w-4 text-purple-600 dark:text-purple-400"}),s.jsx("span",{className:"text-sm font-medium",children:s.jsx(R,{id:"user.content.image"})}),s.jsx(pe,{variant:"outline",className:"border-purple-300 text-purple-700 dark:border-purple-700 dark:text-purple-300",children:e.source.media_type}),s.jsx($e,{className:"h-4 w-4 text-muted-foreground transition-transform group-data-[state=open]:rotate-180 ml-auto"})]})})}),s.jsx(je,{children:s.jsx("div",{className:"py-3 px-4 border-t border-purple-200 dark:border-purple-800",children:s.jsx("div",{className:"rounded-lg border overflow-hidden bg-background",children:s.jsx("img",{src:`data:${e.source.media_type};base64,${e.source.data}`,alt:"User uploaded content",className:"max-w-full h-auto max-h-96 object-contain"})})})})]})}):s.jsx(ut,{className:"border-red-200 bg-red-50/50 dark:border-red-800 dark:bg-red-950/20",id:n,children:s.jsxs(nn,{children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(nu,{className:"h-4 w-4 text-red-600 dark:text-red-400"}),s.jsx(rn,{className:"text-sm font-medium",children:s.jsx(R,{id:"user.content.unsupported_media"})}),s.jsx(pe,{variant:"destructive",children:s.jsx(R,{id:"common.error"})})]}),s.jsx(bc,{className:"text-xs",children:s.jsx(R,{id:"user.content.unsupported_media.description"})})]})}):e.type==="document"?e.source.type==="base64"&&e.source.media_type==="application/pdf"?s.jsx(ut,{className:"border-blue-200 bg-blue-50/50 dark:border-blue-800 dark:bg-blue-950/20 mb-2 p-0 overflow-hidden",id:n,children:s.jsxs(Le,{children:[s.jsx(We,{asChild:!0,children:s.jsx("div",{className:"cursor-pointer hover:bg-blue-100/50 dark:hover:bg-blue-900/20 transition-colors px-3 py-1.5 group",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ru,{className:"h-4 w-4 text-blue-600 dark:text-blue-400"}),s.jsx("span",{className:"text-sm font-medium",children:s.jsx(R,{id:"user.content.document.pdf"})}),s.jsx(pe,{variant:"outline",className:"border-blue-300 text-blue-700 dark:border-blue-700 dark:text-blue-300",children:e.source.media_type}),s.jsx($e,{className:"h-4 w-4 text-muted-foreground transition-transform group-data-[state=open]:rotate-180 ml-auto"})]})})}),s.jsx(je,{children:s.jsx("div",{className:"py-3 px-4 border-t border-blue-200 dark:border-blue-800",children:s.jsx("div",{className:"rounded-lg border overflow-hidden bg-background",children:s.jsx("embed",{src:`data:${e.source.media_type};base64,${e.source.data}`,type:"application/pdf",className:"w-full h-[600px]"})})})})]})}):e.source.type==="text"?s.jsx(ut,{className:"border-green-200 bg-green-50/50 dark:border-green-800 dark:bg-green-950/20 mb-2 p-0 overflow-hidden",id:n,children:s.jsxs(Le,{children:[s.jsx(We,{asChild:!0,children:s.jsx("div",{className:"cursor-pointer hover:bg-green-100/50 dark:hover:bg-green-900/20 transition-colors px-3 py-1.5 group",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ru,{className:"h-4 w-4 text-green-600 dark:text-green-400"}),s.jsx("span",{className:"text-sm font-medium",children:s.jsx(R,{id:"user.content.document.text"})}),s.jsx(pe,{variant:"outline",className:"border-green-300 text-green-700 dark:border-green-700 dark:text-green-300",children:e.source.media_type}),s.jsx($e,{className:"h-4 w-4 text-muted-foreground transition-transform group-data-[state=open]:rotate-180 ml-auto"})]})})}),s.jsx(je,{children:s.jsx("div",{className:"py-3 px-4 border-t border-green-200 dark:border-green-800",children:s.jsx("div",{className:"rounded-lg border overflow-hidden bg-background",children:s.jsx("pre",{className:"p-4 text-sm overflow-auto max-h-96",children:e.source.data})})})})]})}):s.jsx(ut,{className:"border-red-200 bg-red-50/50 dark:border-red-800 dark:bg-red-950/20",id:n,children:s.jsxs(nn,{children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(nu,{className:"h-4 w-4 text-red-600 dark:text-red-400"}),s.jsx(rn,{className:"text-sm font-medium",children:s.jsx(R,{id:"user.content.unsupported_document"})}),s.jsx(pe,{variant:"destructive",children:s.jsx(R,{id:"common.error"})})]}),s.jsx(bc,{className:"text-xs",children:s.jsx(R,{id:"user.content.unsupported_document.description"})})]})}):(e.type==="tool_result",null),ez=({conversation:e,getToolResult:n,getAgentIdForToolUse:r,getSidechainConversationByPrompt:a,getSidechainConversations:t,projectId:i,sessionId:o})=>{if(e.type==="summary")return s.jsx(Y4,{children:e.summary});if(e.type==="system")return s.jsx(Z4,{children:e.content});if(e.type==="file-history-snapshot")return s.jsx(H4,{conversation:e});if(e.type==="queue-operation")return s.jsx(K4,{conversation:e});if(e.type==="user"){const l=typeof e.message.content=="string"?s.jsx(ob,{content:e.message.content,id:`message-${e.uuid}`}):s.jsx("ul",{className:"w-full",id:`message-${e.uuid}`,children:e.message.content.map(u=>s.jsx("li",{children:s.jsx(ob,{content:u})},u.toString()))});return e.isMeta===!0?s.jsx(V4,{children:l}):l}return e.type==="assistant"?s.jsx("ul",{className:"w-full",children:e.message.content.map(l=>s.jsx("li",{children:s.jsx(q4,{content:l,getToolResult:n,getAgentIdForToolUse:r,getSidechainConversationByPrompt:a,getSidechainConversations:t,projectId:i,sessionId:o})},l.toString()))}):null},tz=e=>typeof e=="object"&&e!==null&&"agentId"in e&&typeof e.agentId=="string",sb=e=>{if(e.type==="user")return`user_${e.uuid}`;if(e.type==="assistant")return`assistant_${e.uuid}`;if(e.type==="system")return`system_${e.uuid}`;if(e.type==="summary")return`summary_${e.leafUuid}`;if(e.type==="file-history-snapshot")return`file-history-snapshot_${e.messageId}`;if(e.type==="queue-operation")return`queue-operation_${e.operation}_${e.sessionId}_${e.timestamp}`;throw new Error(`Unknown conversation type: ${e}`)},nz=({errorLine:e})=>s.jsx("li",{className:"w-full flex justify-start",children:s.jsx("div",{className:"w-full max-w-3xl lg:max-w-4xl sm:w-[90%] md:w-[85%] px-2",children:s.jsxs(Le,{children:[s.jsx(We,{asChild:!0,children:s.jsxs("div",{className:"flex items-center justify-between cursor-pointer hover:bg-muted/50 rounded p-2 -mx-2 border-l-2 border-red-400",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(xc,{className:"h-3 w-3 text-red-500"}),s.jsx("span",{className:"text-xs font-medium text-red-600",children:s.jsx(R,{id:"conversation.error.schema"})})]}),s.jsx($e,{className:"h-3 w-3 text-muted-foreground transition-transform group-data-[state=open]:rotate-180"})]})}),s.jsx(je,{children:s.jsx("div",{className:"bg-background rounded border border-red-200 p-3 mt-2",children:s.jsxs("div",{className:"space-y-3",children:[s.jsxs(FI,{variant:"destructive",className:"border-red-200 bg-red-50",children:[s.jsx(xc,{className:"h-4 w-4"}),s.jsx(BI,{className:"text-red-800",children:s.jsx(R,{id:"conversation.error.schema_validation"})}),s.jsxs(zI,{className:"text-red-700",children:[s.jsx(R,{id:"conversation.error.schema_validation.description"})," ",s.jsxs("a",{href:"https://github.com/d-kimuson/claude-code-viewer/issues",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-red-600 hover:text-red-800 underline underline-offset-4",children:[s.jsx(R,{id:"conversation.error.report_issue"}),s.jsx(xT,{className:"h-3 w-3"})]})]})]}),s.jsxs("div",{className:"bg-gray-50 border rounded px-3 py-2",children:[s.jsx("h5",{className:"text-xs font-medium text-gray-700 mb-2",children:s.jsx(R,{id:"conversation.error.raw_content"})}),s.jsx("pre",{className:"text-xs overflow-x-auto whitespace-pre-wrap break-all font-mono text-gray-800",children:e})]})]})})})]})})}),mS=({conversations:e,getToolResult:n,projectId:r,sessionId:a})=>{const t=C.useMemo(()=>e.filter(d=>d.type!=="x-error"),[e]),{isRootSidechain:i,getSidechainConversations:o,getSidechainConversationByPrompt:l,existsRelatedTaskCall:u}=G4(t),c=C.useMemo(()=>{const d=new Map;for(const g of t){if(g.type!=="user")continue;const m=g.message.content;if(typeof m!="string"){for(const f of m)if(typeof f!="string"&&f.type==="tool_result"){const h=g.toolUseResult;tz(h)&&d.set(f.tool_use_id,h.agentId)}}}return d},[t]),p=C.useCallback(d=>c.get(d),[c]);return s.jsx("ul",{children:e.flatMap(d=>{if(d.type==="x-error")return s.jsx(nz,{errorLine:d.line},`error_${d.line}`);const g=s.jsx(ez,{conversation:d,getToolResult:n,getAgentIdForToolUse:p,isRootSidechain:i,getSidechainConversations:o,getSidechainConversationByPrompt:l,existsRelatedTaskCall:u,projectId:r,sessionId:a},sb(d)),m=d.type!=="summary"&&d.type!=="file-history-snapshot"&&d.type!=="queue-operation"&&d.isSidechain;return m?[]:[s.jsx("li",{className:`w-full flex ${m||d.type==="assistant"||d.type==="system"||d.type==="summary"?"justify-start":"justify-end"} animate-in fade-in slide-in-from-bottom-2 duration-300`,children:s.jsx("div",{className:"w-full max-w-3xl lg:max-w-4xl sm:w-[90%] md:w-[85%]",children:g})},sb(d))]})})};function oc({className:e,...n}){return s.jsx("textarea",{"data-slot":"textarea",className:ce("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input flex min-h-[60px] w-full min-w-0 resize-none rounded-md border bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm","focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",e),...n})}const rz=({hunk:e})=>s.jsxs("div",{className:"relative flex overflow-x-auto",children:[s.jsxs("div",{className:"flex-shrink-0 sticky left-0 z-10 bg-white dark:bg-gray-900",children:[s.jsx("div",{className:"float-left w-10 bg-gray-50 dark:bg-gray-800/50 border-r border-gray-200 dark:border-gray-700",children:e.lines.map((n,r)=>s.jsx("div",{className:"px-1 py-0.5 text-xs text-gray-400 dark:text-gray-600 font-mono text-right leading-tight",children:n.type!=="added"&&n.type!=="hunk"&&n.oldLineNumber?n.oldLineNumber:" "},`old-${n.oldLineNumber}-${r}`))}),s.jsx("div",{className:"float-left w-10 bg-gray-50 dark:bg-gray-800/50 border-r border-gray-200 dark:border-gray-700",children:e.lines.map((n,r)=>s.jsx("div",{className:"px-1 py-0.5 text-xs text-gray-400 dark:text-gray-600 font-mono text-right leading-tight",children:n.type!=="deleted"&&n.type!=="hunk"&&n.newLineNumber?n.newLineNumber:" "},`new-${n.newLineNumber}-${r}`))})]}),s.jsx("div",{className:"flex-1 min-w-0",children:e.lines.map((n,r)=>s.jsx("div",{className:ce("flex border-l-4",{"bg-green-50 dark:bg-green-950/30 border-green-200 dark:border-green-800/50 border-l-green-400":n.type==="added","bg-red-50 dark:bg-red-950/30 border-red-200 dark:border-red-800/50 border-l-red-400":n.type==="deleted","bg-blue-50 dark:bg-blue-950/30 border-blue-200 dark:border-blue-800/50 border-l-blue-400":n.type==="hunk","bg-white dark:bg-gray-900 border-gray-100 dark:border-gray-800 border-l-transparent":n.type==="unchanged"}),children:s.jsx("div",{className:"flex-1 px-2 py-0.5",children:s.jsxs("span",{className:"font-mono text-xs whitespace-pre block leading-tight",children:[s.jsx("span",{className:ce({"text-green-600 dark:text-green-400":n.type==="added","text-red-600 dark:text-red-400":n.type==="deleted","text-blue-600 dark:text-blue-400 font-medium":n.type==="hunk","text-gray-400 dark:text-gray-600":n.type==="unchanged"}),children:n.type==="added"?"+":n.type==="deleted"?"-":n.type==="hunk"?"":" "}),n.content||" "]})})},`content-${n.content}-${n.oldLineNumber}-${n.newLineNumber}-${r}`))})]}),lb=({fileDiff:e,isCollapsed:n,onToggleCollapse:r})=>{const a=()=>e.isNew?s.jsx("span",{className:"text-green-600 dark:text-green-400",children:"A"}):e.isDeleted?s.jsx("span",{className:"text-red-600 dark:text-red-400",children:"D"}):e.isRenamed?s.jsx("span",{className:"text-blue-600 dark:text-blue-400",children:"R"}):s.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"M"}),t=async i=>{i.stopPropagation();try{await navigator.clipboard.writeText(e.filename),de.success("ファイル名をコピーしました")}catch(o){console.error("Failed to copy filename:",o),de.error("ファイル名のコピーに失敗しました")}};return s.jsxs(ne,{onClick:r,className:"w-full bg-gray-50 dark:bg-gray-800 px-3 py-1.5 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors sticky top-0 z-20",children:[s.jsxs("div",{className:"w-full flex items-center gap-2",children:[n?s.jsx(hy,{className:"w-4 h-4 text-gray-500 flex-shrink-0"}):s.jsx($e,{className:"w-4 h-4 text-gray-500 flex-shrink-0"}),s.jsx("div",{className:"w-5 h-5 rounded-full bg-gray-100 dark:bg-gray-700 flex items-center justify-center text-xs font-mono flex-shrink-0",children:a()}),s.jsx("span",{className:"font-mono text-xs font-medium text-black dark:text-white text-left truncate flex-1 min-w-0",children:e.filename}),s.jsxs("div",{className:"flex items-center gap-3 text-xs text-gray-500 dark:text-gray-400 flex-shrink-0",children:[e.linesAdded>0&&s.jsxs("span",{className:"text-green-600 dark:text-green-400",children:["+",e.linesAdded]}),e.linesDeleted>0&&s.jsxs("span",{className:"text-red-600 dark:text-red-400",children:["-",e.linesDeleted]})]}),s.jsx(ne,{onClick:t,variant:"ghost",size:"sm",className:"flex-shrink-0 p-1 h-5 w-5 hover:bg-gray-200 dark:hover:bg-gray-600",children:s.jsx(ky,{className:"w-3 h-3 text-gray-500 dark:text-gray-400"})})]}),e.isBinary&&s.jsx("div",{className:"mt-2 text-xs text-gray-500 dark:text-gray-400 text-left",children:"Binary file (content not shown)"})]})},az=({fileDiff:e,className:n})=>{const[r,a]=C.useState(!1),t=()=>{a(!r)};return e.isBinary?s.jsxs("div",{className:ce("border border-gray-200 dark:border-gray-700 rounded-lg",n),children:[s.jsx(lb,{fileDiff:e,isCollapsed:r,onToggleCollapse:t}),!r&&s.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400 text-sm",children:"Binary file cannot be displayed"})]}):s.jsxs("div",{className:ce("border border-gray-200 dark:border-gray-700 rounded-lg",n),children:[s.jsx(lb,{fileDiff:e,isCollapsed:r,onToggleCollapse:t}),!r&&s.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700",children:e.hunks.map((i,o)=>s.jsx(rz,{hunk:i},`${i.oldStart}-${i.newStart}-${o}`))})]})},iz=({summary:e,className:n})=>s.jsx("div",{className:ce("bg-gray-50 dark:bg-gray-800 rounded-lg p-2 border border-gray-200 dark:border-gray-700",n),children:s.jsxs("div",{className:"flex items-center justify-between text-sm",children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(ru,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),s.jsxs("span",{className:"font-medium",children:[s.jsxs("span",{className:"hidden sm:inline",children:[e.filesChanged," ",s.jsx(R,{id:"diff.files.changed"})]}),s.jsxs("span",{className:"sm:hidden",children:[e.filesChanged," ",s.jsx(R,{id:"diff.files"})]})]})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[e.insertions>0&&s.jsxs("span",{className:"text-green-600 dark:text-green-400 font-medium",children:["+",e.insertions]}),e.deletions>0&&s.jsxs("span",{className:"text-red-600 dark:text-red-400 font-medium",children:["-",e.deletions]})]})]})}),ub=({label:e,value:n,onValueChange:r,refs:a})=>{const t=C.useId(),i=o=>{switch(o){case"branch":return s.jsx(Rn,{className:"h-4 w-4"});case"commit":return s.jsx("span",{className:"text-xs",children:"📝"});case"working":return s.jsx("span",{className:"text-xs",children:"🚧"});default:return s.jsx(Rn,{className:"h-4 w-4"})}};return s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{htmlFor:t,className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:e}),s.jsxs(Ot,{value:n,onValueChange:r,children:[s.jsx(Dt,{className:"w-full sm:w-80",children:s.jsx(Lt,{})}),s.jsx($t,{id:t,children:a.map(o=>s.jsx(Ve,{value:o.name,children:s.jsxs("div",{className:"flex items-center gap-2",children:[i(o.type),s.jsx("span",{children:o.displayName}),o.sha&&s.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400 font-mono",children:o.sha.substring(0,7)})]})},o.name))})]})]})},oz=({isOpen:e,onOpenChange:n,projectId:r,defaultCompareFrom:a="HEAD",defaultCompareTo:t="working",revisionsData:i})=>{const{i18n:o}=Ke(),l=C.useId(),[u,c]=C.useState(a),[p,d]=C.useState(t),[g,m]=C.useState(new Map),[f,h]=C.useState(""),[v,S]=C.useState(!1),{data:E,isLoading:y}=Au(r),w=i??E,{mutate:I,data:b,isPending:T,error:D}=rC(),_=aC(r),k=iC(r),A=oC(r),j=w?.success&&w.data?[{name:"working",type:"working",displayName:o._("Uncommitted changes")},{name:"HEAD",type:"commit",displayName:"HEAD"},...w.data.baseBranch?[{name:`branch:${w.data.baseBranch.name}`,type:"branch",displayName:`${w.data.baseBranch.name} (base)`,sha:w.data.baseBranch.commit}]:[],...w.data.currentBranch?[{name:`branch:${w.data.currentBranch.name}`,type:"branch",displayName:`${w.data.currentBranch.name} (current)`,sha:w.data.currentBranch.commit}]:[],...w.data.commits.map(x=>({name:`commit:${x.sha}`,type:"commit",displayName:`${x.message.substring(0,50)}${x.message.length>50?"...":""}`,sha:x.sha}))]:[],$=C.useCallback(()=>{u&&p&&u!==p&&I({projectId:r,fromRef:u,toRef:p})},[u,p,I,r]);C.useEffect(()=>{if(b?.success&&b.data.files.length>0){const x=new Map(b.data.files.map(O=>[O.filePath,!0]));m(x)}},[b]),C.useEffect(()=>{e&&u&&p&&$()},[e,u,p,$]);const P=()=>{$()},z=x=>{m(O=>{const B=new Map(O),H=!O.get(x);return B.set(x,H),B})},ee=()=>{b?.success&&b.data.files.length>0&&m(new Map(b.data.files.map(x=>[x.filePath,!0])))},X=()=>{b?.success&&b.data.files.length>0&&m(new Map(b.data.files.map(x=>[x.filePath,!1])))},G=async()=>{const x=Array.from(g.entries()).filter(([O,B])=>B).map(([O])=>O);console.log("[DiffModal.handleCommit] Selected files state:",g),console.log("[DiffModal.handleCommit] Filtered selected files:",x),console.log("[DiffModal.handleCommit] Total files:",b?.success?b.data.files.length:0);try{const O=await _.mutateAsync({files:x,message:f});console.log("[DiffModal.handleCommit] Commit result:",O),O.success?(de.success(`Committed ${O.filesCommitted} files (${O.commitSha.slice(0,7)})`),h(""),$()):de.error(O.error,{description:O.details})}catch(O){console.error("[DiffModal.handleCommit] Error:",O),de.error(o._("Failed to commit"))}},te=async()=>{try{const x=await k.mutateAsync();console.log("[DiffModal.handlePush] Push result:",x),x.success?de.success(`Pushed to ${x.remote}/${x.branch}`):de.error(x.error,{description:x.details})}catch(x){console.error("[DiffModal.handlePush] Error:",x),de.error(o._("Failed to push"))}},N=async()=>{const x=Array.from(g.entries()).filter(([O,B])=>B).map(([O])=>O);console.log("[DiffModal.handleCommitAndPush] Selected files:",x);try{const O=await A.mutateAsync({files:x,message:f});console.log("[DiffModal.handleCommitAndPush] Result:",O),O.success?(de.success(`Committed and pushed (${O.commitSha.slice(0,7)})`),h(""),$()):O.success===!1&&"commitSucceeded"in O&&O.commitSucceeded?(de.warning(`Committed (${O.commitSha?.slice(0,7)}), but push failed: ${O.error}`,{action:{label:o._("Retry Push"),onClick:te}}),h(""),$()):de.error(O.error,{description:O.details})}catch(O){console.error("[DiffModal.handleCommitAndPush] Error:",O),de.error(o._("Failed to commit and push"))}},Y=Array.from(g.values()).filter(Boolean).length,Z=Y===0||f.trim().length===0||_.isPending;return s.jsx(cn,{open:e,onOpenChange:n,children:s.jsxs(dn,{className:"max-w-7xl w-[95vw] h-[90vh] overflow-hidden flex flex-col px-2 md:px-8",children:[s.jsxs("div",{className:"flex flex-col sm:flex-row gap-2 sm:items-end",children:[s.jsxs("div",{className:"flex flex-col sm:flex-row gap-2 flex-1",children:[s.jsx(ub,{label:o._("Compare from"),value:u,onValueChange:c,refs:j.filter(x=>x.name!=="working")}),s.jsx(ub,{label:o._("Compare to"),value:p,onValueChange:d,refs:j})]}),s.jsx(ne,{onClick:P,disabled:T||y||u===p,className:"sm:self-end w-full sm:w-auto",children:T?s.jsxs(s.Fragment,{children:[s.jsx(Tt,{className:"w-4 h-4 mr-2 animate-spin"}),s.jsx(R,{id:"common.loading"})]}):s.jsx(qT,{className:"w-4 h-4"})})]}),D&&s.jsx("div",{className:"bg-red-50 dark:bg-red-900/10 border border-red-200 dark:border-red-800 rounded-lg p-4",children:s.jsx("p",{className:"text-red-600 dark:text-red-400 text-sm",children:D.message})}),b?.success&&s.jsxs("div",{className:"flex-1 overflow-auto",children:[s.jsx(iz,{summary:{filesChanged:b.data.files.length,insertions:b.data.summary.totalAdditions,deletions:b.data.summary.totalDeletions,files:b.data.diffs.map(x=>({filename:x.file.filePath,oldFilename:x.file.oldPath,isNew:x.file.status==="added",isDeleted:x.file.status==="deleted",isRenamed:x.file.status==="renamed",isBinary:!1,hunks:x.hunks,linesAdded:x.file.additions,linesDeleted:x.file.deletions}))},className:"mb-3"}),p==="working"&&s.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900 rounded-lg mb-4 border border-gray-200 dark:border-gray-700",children:[s.jsxs("button",{type:"button",onClick:()=>S(!v),className:"w-full flex items-center justify-between p-2 hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors rounded-t-lg",children:[s.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:s.jsx(R,{id:"diff.commit.changes"})}),v?s.jsx(QI,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}):s.jsx($e,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"})]}),v&&s.jsxs("div",{className:"p-4 pt-0 space-y-3",children:[s.jsx("div",{className:"flex items-center justify-between",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ne,{size:"sm",variant:"ghost",onClick:ee,disabled:_.isPending,children:s.jsx(R,{id:"diff.select.all"})}),s.jsx(ne,{size:"sm",variant:"ghost",onClick:X,disabled:_.isPending,children:s.jsx(R,{id:"diff.deselect.all"})}),s.jsxs("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:[Y," / ",b.data.files.length," files selected"]})]})}),s.jsx("div",{className:"space-y-2 max-h-40 overflow-y-auto border border-gray-200 dark:border-gray-700 rounded p-2",children:b.data.files.map(x=>s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(eT,{id:`file-${x.filePath}`,checked:g.get(x.filePath)??!1,onCheckedChange:()=>z(x.filePath),disabled:_.isPending}),s.jsx("label",{htmlFor:`file-${x.filePath}`,className:"text-sm font-mono cursor-pointer flex-1",children:x.filePath})]},x.filePath))}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{htmlFor:l,className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:s.jsx(R,{id:"diff.commit.message"})}),s.jsx(oc,{id:l,placeholder:"Enter commit message...",value:f,onChange:x=>h(x.target.value),disabled:_.isPending,className:"resize-none",rows:3})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx(ne,{onClick:G,disabled:Z,className:"w-full sm:w-auto",children:_.isPending?s.jsxs(s.Fragment,{children:[s.jsx(Tt,{className:"w-4 h-4 mr-2 animate-spin"}),s.jsx(R,{id:"diff.committing"})]}):s.jsx(R,{id:"diff.commit"})}),s.jsx(ne,{onClick:te,disabled:k.isPending,variant:"outline",className:"w-full sm:w-auto",children:k.isPending?s.jsxs(s.Fragment,{children:[s.jsx(Tt,{className:"w-4 h-4 mr-2 animate-spin"}),s.jsx(R,{id:"diff.pushing"})]}):s.jsx(R,{id:"diff.push"})}),s.jsx(ne,{onClick:N,disabled:Z||A.isPending,variant:"secondary",className:"w-full sm:w-auto",children:A.isPending?s.jsxs(s.Fragment,{children:[s.jsx(Tt,{className:"w-4 h-4 mr-2 animate-spin"}),s.jsx(R,{id:"diff.committing.pushing"})]}):s.jsx(R,{id:"diff.commit.push"})}),Z&&!_.isPending&&!A.isPending&&s.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:Y===0?s.jsx(R,{id:"diff.select.file"}):s.jsx(R,{id:"diff.enter.message"})})]})]})]}),s.jsx("div",{className:"space-y-3",children:b.data.diffs.map(x=>s.jsx(az,{fileDiff:{filename:x.file.filePath,oldFilename:x.file.oldPath,isNew:x.file.status==="added",isDeleted:x.file.status==="deleted",isRenamed:x.file.status==="renamed",isBinary:!1,hunks:x.hunks,linesAdded:x.file.additions,linesDeleted:x.file.deletions}},x.file.filePath))})]}),T&&s.jsx("div",{className:"flex-1 flex items-center justify-center",children:s.jsxs("div",{className:"text-center space-y-2",children:[s.jsx(Tt,{className:"w-8 h-8 animate-spin mx-auto"}),s.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:s.jsx(R,{id:"diff.loading"})})]})})]})})},sz=({projectId:e,isPending:n=!1,onScrollToTop:r,onScrollToBottom:a,onOpenDiffModal:t,sessionProcess:i,abortTask:o,isNewChat:l=!1})=>{const{i18n:u}=Ke(),c=my(),{openPreview:p}=wu(),d=()=>{c({to:"/projects/$projectId/session",params:{projectId:e},search:g=>{const{sessionId:m,...f}=g;return f}})};return s.jsx("div",{className:"px-4 sm:px-6 md:px-8 lg:px-12 xl:px-16 mb-1",children:s.jsxs("div",{className:"py-0 flex items-center gap-1.5 flex-wrap",children:[t&&s.jsxs(ne,{type:"button",variant:"ghost",size:"sm",onClick:t,disabled:n,className:"h-7 px-2 gap-1.5 text-xs bg-muted/20 rounded-lg border border-border/40",title:u._({id:"control.open_git_dialog",message:"Open Git Dialog"}),children:[s.jsx(IT,{className:"w-3.5 h-3.5"}),s.jsx("span",{children:s.jsx(R,{id:"control.git"})})]}),s.jsx(ne,{type:"button",variant:"ghost",size:"sm",onClick:()=>p("about:blank"),disabled:n,className:"h-7 px-2 text-xs bg-muted/20 rounded-lg border border-border/40",title:u._({id:"control.open_browser",message:"Open Browser"}),children:s.jsx(AT,{className:"w-3.5 h-3.5"})}),s.jsxs(ne,{type:"button",variant:"ghost",size:"sm",disabled:n||l,className:"h-7 px-2 gap-1.5 text-xs bg-muted/20 rounded-lg border border-border/40",onClick:d,title:u._({id:"control.new_chat",message:"New Chat"}),children:[s.jsx(Iu,{className:"w-3.5 h-3.5"}),s.jsx("span",{children:s.jsx(R,{id:"control.new"})})]}),r&&s.jsx(ne,{type:"button",variant:"ghost",size:"sm",onClick:r,disabled:n,className:"h-7 px-2 gap-1.5 text-xs bg-muted/20 rounded-lg border border-border/40",title:u._({id:"control.scroll_to_top",message:"Scroll to Top"}),children:s.jsx(mT,{className:"w-3.5 h-3.5"})}),a&&s.jsx(ne,{type:"button",variant:"ghost",size:"sm",onClick:a,disabled:n,className:"h-7 px-2 gap-1.5 text-xs bg-muted/20 rounded-lg border border-border/40",title:u._({id:"control.scroll_to_bottom",message:"Scroll to Bottom"}),children:s.jsx(cT,{className:"w-3.5 h-3.5"})}),i&&o&&s.jsxs(ne,{type:"button",variant:"destructive",size:"sm",onClick:()=>{o.mutate(i.id)},disabled:o.isPending||n,className:"h-7 px-2 gap-1.5 text-xs rounded-lg",children:[o.isPending?s.jsx(Cn,{className:"w-3.5 h-3.5 animate-spin"}):s.jsx(_u,{className:"w-3.5 h-3.5"}),s.jsx("span",{children:s.jsx(R,{id:"session.conversation.abort"})})]})]})})},yt={all:["scheduler"],jobs:()=>[...yt.all,"jobs"],job:e=>[...yt.all,"job",e]},lz=()=>Pt({queryKey:yt.jobs(),queryFn:async()=>{const e=await ze.api.scheduler.jobs.$get();if(!e.ok)throw new Error("Failed to fetch scheduler jobs");return e.json()}}),gS=()=>{const e=Un();return et({mutationFn:async n=>{const r=await ze.api.scheduler.jobs.$post({json:n});if(!r.ok)throw new Error("Failed to create scheduler job");return r.json()},onSuccess:()=>{e.invalidateQueries({queryKey:yt.jobs()})}})},uz=()=>{const e=Un();return et({mutationFn:async({id:n,updates:r})=>{const a=await ze.api.scheduler.jobs[":id"].$patch({param:{id:n},json:r});if(!a.ok)throw a.status===404?new Error("Job not found"):new Error("Failed to update scheduler job");return a.json()},onSuccess:n=>{e.invalidateQueries({queryKey:yt.job(n.id)}),e.invalidateQueries({queryKey:yt.jobs()})}})},cz=()=>{const e=Un();return et({mutationFn:async n=>{const r=await ze.api.scheduler.jobs[":id"].$delete({param:{id:n}});if(!r.ok)throw r.status===404?new Error("Job not found"):new Error("Failed to delete scheduler job");return r.json()},onSuccess:(n,r)=>{e.invalidateQueries({queryKey:yt.job(r)}),e.invalidateQueries({queryKey:yt.jobs()})}})},fS=Nn(["image/png","image/jpeg","image/gif","image/webp"]),dz=Je({type:ct("image"),source:Je({type:ct("base64"),media_type:fS,data:He()})}),pz=Je({type:ct("document"),source:xu([Je({type:ct("text"),media_type:Nn(["text/plain"]),data:He()}),Je({type:ct("base64"),media_type:Nn(["application/pdf"]),data:He()})])});Je({text:He().min(1),images:tu(dz).optional(),documents:tu(pz).optional()});const mz=e=>e.startsWith("image/")?"image":e==="application/pdf"?"pdf":"text",gz=e=>new Promise((n,r)=>{const a=new FileReader;a.onload=()=>{const t=a.result;if(typeof t=="string"){const i=t.split(",")[1];n(i??"")}else r(new Error("Failed to read file as base64"))},a.onerror=()=>{r(new Error("Failed to read file"))},a.readAsDataURL(e)}),fz=e=>new Promise((n,r)=>{const a=new FileReader;a.onload=()=>{const t=a.result;typeof t=="string"?n(t):r(new Error("Failed to read file as text"))},a.onerror=()=>{r(new Error("Failed to read file"))},a.readAsText(e)}),hz=async e=>{const n=mz(e.type);if(n==="text")return{type:"text",content:await fz(e)};const r=await gz(e);if(n==="image"){const a=fS.safeParse(e.type);return a.success?{type:"image",block:{type:"image",source:{type:"base64",media_type:a.data,data:r}}}:null}return{type:"document",block:{type:"document",source:{type:"base64",media_type:"application/pdf",data:r}}}},bz=C.forwardRef(({projectId:e,inputValue:n,onCommandSelect:r,className:a},t)=>{const{i18n:i}=Ke(),[o,l]=C.useState(!1),[u,c]=C.useState(-1),p=C.useRef(null),d=C.useRef(null),{data:g}=Pt({queryKey:yc(e).queryKey,queryFn:yc(e).queryFn,staleTime:1e3*60*5}),{shouldShowCompletion:m,filteredCommands:f}=C.useMemo(()=>{const y=[...g?.defaultCommands||[],...g?.globalCommands||[],...g?.projectCommands||[]],w=n.startsWith("/"),I=w?n.slice(1).toLowerCase():"",b=w?y.filter(T=>T.toLowerCase().includes(I)):[];return{shouldShowCompletion:w,filteredCommands:b}},[g,n]),h=m&&f.length>0;o!==h&&(l(h),c(-1));const v=C.useCallback(y=>{r(`/${y} `),l(!1),c(-1)},[r]),S=C.useCallback(y=>{if(y>=0&&d.current){const I=d.current.querySelectorAll('button[role="option"]')[y];I&&I.scrollIntoView({block:"nearest",behavior:"smooth"})}},[]),E=C.useCallback(y=>{if(!o||f.length===0)return!1;switch(y.key){case"ArrowDown":return y.preventDefault(),c(w=>{const I=w<f.length-1?w+1:0;return requestAnimationFrame(()=>S(I)),I}),!0;case"ArrowUp":return y.preventDefault(),c(w=>{const I=w>0?w-1:f.length-1;return requestAnimationFrame(()=>S(I)),I}),!0;case"Enter":case"Tab":if(u>=0&&u<f.length){y.preventDefault();const w=f[u];return w&&v(w),!0}break;case"Escape":return y.preventDefault(),l(!1),c(-1),!0}return!1},[o,f.length,u,v,S,f]);return C.useEffect(()=>{const y=w=>{p.current&&!p.current.contains(w.target)&&(l(!1),c(-1))};return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[]),C.useImperativeHandle(t,()=>({handleKeyDown:E}),[E]),!m||f.length===0?null:s.jsx("div",{ref:p,className:ce("relative",a),children:s.jsx(Le,{open:o,onOpenChange:l,children:s.jsx(je,{children:s.jsx("div",{ref:d,className:"absolute z-50 w-full bg-popover border border-border rounded-lg shadow-xl overflow-hidden",style:{height:"15rem"},role:"listbox","aria-label":i._("Available commands"),children:s.jsx("div",{className:"h-full overflow-y-auto",children:f.length>0&&s.jsxs("div",{className:"p-1.5",children:[s.jsxs("div",{className:"px-3 py-2 text-xs font-semibold text-muted-foreground/80 border-b border-border/50 mb-1 flex items-center gap-2",role:"presentation",children:[s.jsx(au,{className:"w-3.5 h-3.5"}),"Available Commands (",f.length,")"]}),f.map((y,w)=>s.jsxs(ne,{variant:"ghost",size:"sm",className:ce("w-full justify-start text-left font-mono text-sm h-9 px-3 min-w-0 transition-colors duration-150",w===u?"bg-gradient-to-r from-blue-500/10 to-purple-500/10 text-foreground border border-blue-500/20":"hover:bg-accent/50"),onClick:()=>v(y),onMouseEnter:()=>c(w),role:"option","aria-selected":w===u,"aria-label":`Command: /${y}`,title:`/${y}`,children:[s.jsx("span",{className:"text-muted-foreground mr-1.5 flex-shrink-0",children:"/"}),s.jsx("span",{className:"font-medium truncate min-w-0",children:y}),w===u&&s.jsx(vy,{className:"w-3.5 h-3.5 ml-auto text-blue-600 dark:text-blue-400 flex-shrink-0"})]},y))]})})})})})})}),yz=(e,n,r=!0)=>Pt({queryKey:vc(e,n).queryKey,queryFn:vc(e,n).queryFn,enabled:r&&!!e,staleTime:1e3*60*5}),vz=e=>{const n=e.lastIndexOf("@");if(n===-1)return{shouldShow:!1,searchPath:"",beforeAt:"",afterAt:""};const r=e.slice(0,n),a=e.slice(n+1),t=a.split(/\s/),i=t[0]||"";return{shouldShow:!(t.length>1),searchPath:i,beforeAt:r,afterAt:a}},hS=C.forwardRef(({projectId:e,inputValue:n,onFileSelect:r,className:a},t)=>{const{i18n:i}=Ke(),[o,l]=C.useState(!1),[u,c]=C.useState(-1),p=C.useRef(null),d=C.useRef(null),{shouldShow:g,searchPath:m,beforeAt:f,afterAt:h}=C.useMemo(()=>vz(n),[n]),{basePath:v,filterTerm:S}=C.useMemo(()=>{if(!m)return{basePath:"/",filterTerm:""};const _=m.lastIndexOf("/");if(_===-1)return{basePath:"/",filterTerm:m};const k=m.slice(0,_+1),A=m.slice(_+1);return{basePath:k==="/"?"/":k,filterTerm:A}},[m]),{data:E,isLoading:y}=yz(e,v,g),w=C.useMemo(()=>E?.entries?S?E.entries.filter(_=>_.name.toLowerCase().includes(S.toLowerCase())):E.entries:[],[E?.entries,S]),I=g&&!y&&w.length>0;o!==I&&(l(I),c(-1));const b=C.useCallback((_,k=!1)=>{const A=_.path,j=h.split(/\s/).slice(1).join(" "),$=`${f}@${A}${j}`.trim()+(_.type==="directory"&&!k?"/":" ");r($),(_.type==="file"||k)&&(l(!1),c(-1))},[f,h,r]),T=C.useCallback(_=>{if(_>=0&&d.current){const A=d.current.querySelectorAll('button[role="option"]')[_];A&&A.scrollIntoView({block:"nearest",behavior:"smooth"})}},[]),D=C.useCallback(_=>{if(!o||w.length===0)return!1;switch(_.key){case"ArrowDown":return _.preventDefault(),c(k=>{const A=k<w.length-1?k+1:0;return requestAnimationFrame(()=>T(A)),A}),!0;case"ArrowUp":return _.preventDefault(),c(k=>{const A=k>0?k-1:w.length-1;return requestAnimationFrame(()=>T(A)),A}),!0;case"Enter":if(u>=0&&u<w.length){_.preventDefault();const k=w[u];return k&&b(k,!0),!0}break;case"Tab":if(u>=0&&u<w.length){_.preventDefault();const k=w[u];return k&&b(k,k.type==="file"),!0}break;case"Escape":return _.preventDefault(),l(!1),c(-1),!0}return!1},[o,w.length,u,b,T,w]);return C.useEffect(()=>{const _=k=>{p.current&&!p.current.contains(k.target)&&(l(!1),c(-1))};return document.addEventListener("mousedown",_),()=>document.removeEventListener("mousedown",_)},[]),C.useImperativeHandle(t,()=>({handleKeyDown:D}),[D]),!g||y||w.length===0?null:s.jsx("div",{ref:p,className:ce("relative",a),children:s.jsx(Le,{open:o,onOpenChange:l,children:s.jsx(je,{children:s.jsx("div",{ref:d,className:"absolute z-50 w-full bg-popover border border-border rounded-lg shadow-xl overflow-hidden",style:{height:"15rem"},role:"listbox","aria-label":i._("Available files and directories"),children:s.jsx("div",{className:"h-full overflow-y-auto",children:w.length>0&&s.jsxs("div",{className:"p-1.5",children:[s.jsxs("div",{className:"px-3 py-2 text-xs font-semibold text-muted-foreground/80 border-b border-border/50 mb-1 flex items-center gap-2",role:"presentation",children:[s.jsx(Ec,{className:"w-3.5 h-3.5"}),"Files & Directories (",w.length,")",v!=="/"&&s.jsxs("span",{className:"text-xs font-mono text-muted-foreground/70",children:["in ",v]})]}),w.map((_,k)=>s.jsxs(ne,{variant:"ghost",size:"sm",className:ce("w-full justify-start text-left font-mono text-sm h-9 px-3 min-w-0 transition-colors duration-150",k===u?"bg-gradient-to-r from-blue-500/10 to-purple-500/10 text-foreground border border-blue-500/20":"hover:bg-accent/50"),onClick:()=>b(_,_.type==="file"),onMouseEnter:()=>c(k),role:"option","aria-selected":k===u,"aria-label":`${_.type}: ${_.name}`,title:_.path,children:[_.type==="directory"?s.jsx(tT,{className:"w-3.5 h-3.5 mr-2 text-blue-500 dark:text-blue-400 flex-shrink-0"}):s.jsx(Ec,{className:"w-3.5 h-3.5 mr-2 text-gray-500 dark:text-gray-400 flex-shrink-0"}),s.jsx("span",{className:"font-medium truncate min-w-0",children:_.name}),_.type==="directory"&&s.jsx("span",{className:"text-muted-foreground ml-1 flex-shrink-0",children:"/"}),k===u&&s.jsx(vy,{className:"w-3.5 h-3.5 ml-auto text-blue-600 dark:text-blue-400 flex-shrink-0"})]},_.path))]})})})})})})});hS.displayName="FileCompletion";const Sz=(e,n,r)=>{const a=typeof window<"u"?window.innerHeight:800,t=a/2,i=48,o=36,l=12,c=Math.min(r,5),p=i+o*c+l,d=n.top<t,g=a-n.top,m=n.top;let f,h;d&&g>=p+20?(f="below",h=e.top+24):!d&&m>=p+20?(f="above",h=e.top-p-16):g>m?(f="below",h=e.top+24):(f="above",h=e.top-p-16);const E=(typeof window<"u"?window.innerWidth:1200)-512-16,y=Math.max(16,Math.min(e.left-16,E));return{top:h,left:y,placement:f}},bS=({projectId:e,message:n,commandCompletionRef:r,fileCompletionRef:a,handleCommandSelect:t,handleFileSelect:i,cursorPosition:o})=>{const l=C.useMemo(()=>Sz(o.relative,o.absolute,5),[o]);return s.jsxs("div",{className:"absolute w-full max-w-sm sm:max-w-md lg:max-w-lg xl:max-w-xl z-50",style:{top:l.top,left:l.left,maxWidth:typeof window<"u"?Math.min(512,window.innerWidth*.8):512},children:[s.jsx(bz,{ref:r,projectId:e,inputValue:n,onCommandSelect:t,className:`absolute left-0 right-0 ${l.placement==="above"?"bottom-full mb-2":"top-full mt-1"}`}),s.jsx(hS,{ref:a,projectId:e,inputValue:n,onFileSelect:i,className:`absolute left-0 right-0 ${l.placement==="above"?"bottom-full mb-2":"top-full mt-1"}`})]})},sc=({projectId:e,onSubmit:n,isPending:r,error:a,placeholder:t,buttonText:i,minHeight:o="min-h-[64px]",containerClassName:l="",disabled:u=!1,buttonSize:c="lg",enableScheduledSend:p=!1,baseSessionId:d=null})=>{const m=(O=>{const B=O.match(/(\d+)px/);if(B?.[1]){const H=parseInt(B[1],10);if(!Number.isNaN(H))return H}return 48})(o),{i18n:f}=Ke(),[h,v]=C.useState(""),[S,E]=C.useState([]),[y,w]=C.useState({relative:{top:0,left:0},absolute:{top:0,left:0}}),[I,b]=C.useState("immediate"),[T,D]=C.useState(()=>{const O=new Date;O.setHours(O.getHours()+1);const B=O.getFullYear(),H=String(O.getMonth()+1).padStart(2,"0"),Q=String(O.getDate()).padStart(2,"0"),ue=String(O.getHours()).padStart(2,"0"),me=String(O.getMinutes()).padStart(2,"0");return`${B}-${H}-${Q}T${ue}:${me}`}),_=C.useRef(null),k=C.useRef(null),A=C.useRef(null),j=C.useRef(null),$=C.useRef(null),P=C.useId(),{config:z}=kt(),ee=gS();C.useEffect(()=>{const O=k.current;if(!O)return;O.style.height="auto";const B=O.scrollHeight,H=200;O.style.height=`${Math.max(m,Math.min(B,H))}px`},[h,m]),C.useEffect(()=>{const O=k.current;O&&(O.style.height=`${m}px`)},[m]);const X=async()=>{if(!h.trim()&&S.length===0)return;const O=[],B=[];for(const{file:H}of S){const Q=await hz(H);Q!==null&&(Q.type==="text"?B.push({type:"document",source:{type:"text",media_type:"text/plain",data:Q.content}}):Q.type==="image"?O.push(Q.block):Q.type==="document"&&B.push(Q.block))}if(p&&I==="scheduled"){const H=T.match(/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})$/);if(!H)throw new Error("Invalid datetime format");const Q=Number(H[1]),ue=Number(H[2]),me=Number(H[3]),he=Number(H[4]),fe=Number(H[5]),Ae=new Date(Q,ue-1,me,he,fe);try{await ee.mutateAsync({name:`Scheduled message at ${T}`,schedule:{type:"reserved",reservedExecutionTime:Ae.toISOString()},message:{content:h,projectId:e,baseSessionId:d},enabled:!0}),de.success(f._({id:"chat.scheduled_send.success",message:"Message scheduled successfully"}),{description:f._({id:"chat.scheduled_send.success_description",message:"You can view and manage it in the Scheduler tab"})}),v(""),E([])}catch(Re){de.error(f._({id:"chat.scheduled_send.failed",message:"Failed to schedule message"}),{description:Re instanceof Error?Re.message:void 0})}}else await n({text:h,images:O.length>0?O:void 0,documents:B.length>0?B:void 0}),v(""),E([])},G=O=>{const B=O.target.files;if(!B)return;const H=Array.from(B).map(Q=>({file:Q,id:`${Q.name}-${Date.now()}-${Math.random()}`}));E(Q=>[...Q,...H]),A.current&&(A.current.value="")},te=O=>{E(B=>B.filter(H=>H.id!==O))},N=O=>{if(!$.current?.handleKeyDown(O)&&!j.current?.handleKeyDown(O)&&O.key==="Enter"&&!O.nativeEvent.isComposing){const B=z?.enterKeyBehavior;(B==="enter-send"&&!O.shiftKey&&!O.metaKey||B==="shift-enter-send"&&O.shiftKey&&!O.metaKey||B==="command-enter-send"&&O.metaKey&&!O.shiftKey)&&(O.preventDefault(),X())}},Y=C.useCallback(()=>{const O=k.current,B=_.current;if(O===null||B===null)return;const H=O.selectionStart,Q=O.value.substring(0,H),ue=O.value.substring(H),me=document.createTextNode(Q),he=document.createTextNode(ue),fe=document.createElement("span");fe.innerHTML=" ";const Ae=document.createElement("div");Ae.innerHTML="",Ae.append(me,fe,he);const Re=window.getComputedStyle(O);for(const Ce of["border","boxSizing","fontFamily","fontSize","fontWeight","letterSpacing","lineHeight","padding","textDecoration","textIndent","textTransform","whiteSpace","wordSpacing","wordWrap"])Ae.style[Ce]=Re[Ce];Ae.style.visibility="hidden",B.prepend(Ae);const pt=fe.getBoundingClientRect(),it=B.getBoundingClientRect();return B.removeChild(Ae),{relative:{top:pt.top-it.top-O.scrollTop,left:pt.left-it.left-O.scrollLeft},absolute:{top:pt.top-O.scrollTop,left:pt.left-O.scrollLeft}}},[]),Z=O=>{v(O),k.current?.focus()},x=O=>{v(O),k.current?.focus()};return s.jsxs("div",{className:l,children:[a&&s.jsxs("div",{className:"flex items-center gap-2.5 px-4 py-3 text-sm text-red-600 dark:text-red-400 bg-gradient-to-r from-red-50 to-red-100/50 dark:from-red-950/30 dark:to-red-900/20 border border-red-200/50 dark:border-red-800/50 rounded-xl mb-4 animate-in fade-in slide-in-from-top-2 duration-300 shadow-sm",children:[s.jsx(nu,{className:"w-4 h-4 shrink-0 mt-0.5"}),s.jsx("span",{className:"font-medium",children:s.jsx(R,{id:"chat.error.send_failed"})})]}),s.jsxs("div",{className:"relative group",children:[s.jsx("div",{className:"absolute -inset-0.5 bg-gradient-to-r from-blue-500/20 via-purple-500/20 to-pink-500/20 rounded-2xl blur opacity-0 group-hover:opacity-100 transition-opacity duration-500","aria-hidden":"true"}),s.jsxs("div",{className:"relative bg-background border border-border/40 rounded-2xl shadow-lg hover:shadow-xl transition-all duration-300 overflow-hidden",children:[s.jsx("div",{className:"relative",ref:_,children:s.jsx(oc,{ref:k,value:h,onChange:O=>{if(O.target.value.endsWith("@")||O.target.value.endsWith("/")){const B=Y();B&&w(B)}v(O.target.value)},onKeyDown:N,placeholder:t,className:"resize-none border-0 focus-visible:ring-0 focus-visible:ring-offset-0 bg-transparent px-5 py-2 text-base transition-all duration-200 placeholder:text-muted-foreground/60 overflow-y-auto leading-6",style:{minHeight:`${m}px`},disabled:r||u,"aria-label":f._("Message input with completion support"),"aria-describedby":P,"aria-expanded":h.startsWith("/")||h.includes("@"),"aria-haspopup":"listbox",role:"combobox","aria-autocomplete":"list"})}),S.length>0&&s.jsx("div",{className:"px-5 py-3 flex flex-wrap gap-2 border-t border-border/40",children:S.map(({file:O,id:B})=>s.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-muted rounded-lg text-sm",children:[s.jsx("span",{className:"truncate max-w-[200px]",children:O.name}),s.jsx("button",{type:"button",onClick:()=>te(B),className:"text-muted-foreground hover:text-foreground transition-colors",disabled:r,children:s.jsx(_u,{className:"w-3.5 h-3.5"})})]},B))}),s.jsxs("div",{className:"flex items-center justify-between gap-3 px-5 py-1 bg-muted/30 border-t border-border/40",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{ref:A,type:"file",multiple:!0,onChange:G,className:"hidden"}),s.jsxs(ne,{type:"button",variant:"ghost",size:"sm",onClick:()=>A.current?.click(),disabled:r||u,className:"gap-1.5",children:[s.jsx(PT,{className:"w-4 h-4"}),s.jsx("span",{className:"text-xs",children:s.jsx(R,{id:"chat.attach_file"})})]}),s.jsx("span",{className:"text-xs font-medium text-muted-foreground/80",id:P,children:h.length}),(h.startsWith("/")||h.includes("@"))&&s.jsxs("span",{className:"text-xs text-blue-600 dark:text-blue-400 font-medium flex items-center gap-1",children:[s.jsx(WT,{className:"w-3 h-3"}),s.jsx(R,{id:"chat.autocomplete.active"})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[p&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ie,{htmlFor:"send-mode",className:"text-xs sr-only",children:s.jsx(R,{id:"chat.send_mode.label"})}),s.jsxs(Ot,{value:I,onValueChange:O=>b(O),disabled:r||u,children:[s.jsx(Dt,{id:"send-mode",className:"h-8 w-[140px] text-xs",children:s.jsx(Lt,{})}),s.jsxs($t,{children:[s.jsx(Ve,{value:"immediate",children:s.jsx(R,{id:"chat.send_mode.immediate"})}),s.jsx(Ve,{value:"scheduled",children:s.jsx(R,{id:"chat.send_mode.scheduled"})})]})]}),I==="scheduled"&&s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(Ie,{htmlFor:"scheduled-time",className:"text-xs sr-only",children:s.jsx(R,{id:"chat.send_mode.scheduled_time"})}),s.jsx(ht,{id:"scheduled-time",type:"datetime-local",value:T,onChange:O=>D(O.target.value),disabled:r||u,className:"h-8 w-[180px] text-xs"})]})]}),s.jsx(ne,{onClick:X,disabled:!h.trim()&&S.length===0||r||u,size:c,className:"gap-2 transition-all duration-200 hover:shadow-md hover:scale-105 active:scale-95 bg-gradient-to-r from-blue-600 to-purple-600 hover:from-blue-500 hover:to-purple-500 disabled:from-muted disabled:to-muted",children:r?s.jsxs(s.Fragment,{children:[s.jsx(Cn,{className:"w-4 h-4 animate-spin"}),s.jsx("span",{children:s.jsx(R,{id:"chat.status.processing"})})]}):s.jsxs(s.Fragment,{children:[s.jsx(HT,{className:"w-4 h-4"}),i]})})]})]})]}),s.jsx(bS,{projectId:e,message:h,commandCompletionRef:j,fileCompletionRef:$,handleCommandSelect:Z,handleFileSelect:x,cursorPosition:y})]})]})},yS=(e,n)=>{const r=my();return et({mutationFn:async a=>{const t=await ze.api.cc["session-processes"].$post({json:{projectId:e,baseSessionId:a.baseSessionId,input:a.input}},{init:{signal:AbortSignal.timeout(2e4)}});if(!t.ok)throw new Error(t.statusText);return t.json()},onSuccess:async a=>{r({to:"/projects/$projectId/session",params:{projectId:e},search:t=>({...t,sessionId:a.sessionProcess.sessionId})})}})},Ez=(e,n)=>et({mutationFn:async r=>{const a=await ze.api.cc["session-processes"][":sessionProcessId"].continue.$post({param:{sessionProcessId:r.sessionProcessId},json:{projectId:e,baseSessionId:n,input:r.input}},{init:{signal:AbortSignal.timeout(2e4)}});if(!a.ok)throw new Error(a.statusText);return a.json()}});function xz(){const[e,n]=C.useState({relative:{top:0,left:0},absolute:{top:0,left:0}}),r=C.useRef(null),a=C.useRef(null),t=C.useRef(null),i=C.useRef(null),o=C.useCallback(()=>{const d=a.current,g=r.current;if(d===null||g===null)return;const m=d.selectionStart,f=d.value.substring(0,m),h=d.value.substring(m),v=document.createTextNode(f),S=document.createTextNode(h),E=document.createElement("span");E.innerHTML=" ";const y=document.createElement("div");y.innerHTML="",y.append(v,E,S);const w=window.getComputedStyle(d);for(const T of["border","boxSizing","fontFamily","fontSize","fontWeight","letterSpacing","lineHeight","padding","textDecoration","textIndent","textTransform","whiteSpace","wordSpacing","wordWrap"])y.style[T]=w[T];y.style.visibility="hidden",g.prepend(y);const I=E.getBoundingClientRect(),b=g.getBoundingClientRect();return g.removeChild(y),{relative:{top:I.top-b.top-d.scrollTop,left:I.left-b.left-d.scrollLeft},absolute:{top:I.top-d.scrollTop,left:I.left-d.scrollLeft}}},[]),l=C.useCallback((d,g)=>{if(d.endsWith("@")||d.endsWith("/")){const m=o();m&&n(m)}g(d)},[o]),u=C.useCallback(d=>!!(i.current?.handleKeyDown(d)||t.current?.handleKeyDown(d)),[]),c=C.useCallback((d,g)=>{g(d),a.current?.focus()},[]),p=C.useCallback((d,g)=>{g(d),a.current?.focus()},[]);return{cursorPosition:e,containerRef:r,textareaRef:a,commandCompletionRef:t,fileCompletionRef:i,getCursorPosition:o,handleChange:l,handleKeyDown:u,handleCommandSelect:c,handleFileSelect:p}}const kz=({projectId:e,sessionId:n,sessionProcessId:r,sessionProcessStatus:a})=>{const{i18n:t}=Ke(),i=Ez(e,n),{config:o}=kt(),l=async p=>{await i.mutateAsync({input:p,sessionProcessId:r})},u=()=>{const p=o?.enterKeyBehavior;return p==="enter-send"?t._({id:"chat.placeholder.continue.enter",message:"Type your message... (Start with / for commands, @ for files, Enter to send)"}):p==="command-enter-send"?t._({id:"chat.placeholder.continue.command_enter",message:"Type your message... (Start with / for commands, @ for files, Command+Enter to send)"}):t._({id:"chat.placeholder.continue.shift_enter",message:"Type your message... (Start with / for commands, @ for files, Shift+Enter to send)"})},c=a==="running";return s.jsx("div",{className:"w-full px-4 sm:px-6 md:px-8 lg:px-12 xl:px-16 pb-3",children:s.jsx(sc,{projectId:e,onSubmit:l,isPending:i.isPending,error:i.error,placeholder:u(),buttonText:s.jsx(R,{id:"chat.send"}),containerClassName:"",buttonSize:"default",enableScheduledSend:!c,baseSessionId:n,disabled:c})})},wz=({projectId:e,sessionId:n})=>{const{i18n:r}=Ke(),a=yS(e),{config:t}=kt(),i=async u=>{await a.mutateAsync({input:u,baseSessionId:n})},o=()=>{const u=t?.enterKeyBehavior;return u==="enter-send"?r._({id:"chat.placeholder.resume.enter",message:"Type your message... (Start with / for commands, @ for files, Enter to send)"}):u==="command-enter-send"?r._({id:"chat.placeholder.resume.command_enter",message:"Type your message... (Start with / for commands, @ for files, Command+Enter to send)"}):r._({id:"chat.placeholder.resume.shift_enter",message:"Type your message... (Start with / for commands, @ for files, Shift+Enter to send)"})},l=s.jsx(R,{id:"chat.resume"});return s.jsx("div",{className:"w-full px-4 sm:px-6 md:px-8 lg:px-12 xl:px-16 pb-3",children:s.jsx(sc,{projectId:e,onSubmit:i,isPending:a.isPending,error:a.error,placeholder:o(),buttonText:l,containerClassName:"",buttonSize:"default",enableScheduledSend:!0,baseSessionId:n})})},_z=({projectId:e})=>{const{i18n:n}=Ke(),r=yS(e),{config:a}=kt(),t=async o=>{await r.mutateAsync({input:o})},i=()=>{const o=a?.enterKeyBehavior;return o==="enter-send"?n._({id:"chat.placeholder.continue.enter",message:"Type your message... (Start with / for commands, @ for files, Enter to send)"}):o==="command-enter-send"?n._({id:"chat.placeholder.continue.command_enter",message:"Type your message... (Start with / for commands, @ for files, Command+Enter to send)"}):n._({id:"chat.placeholder.continue.shift_enter",message:"Type your message... (Start with / for commands, @ for files, Shift+Enter to send)"})};return s.jsx("div",{className:"w-full px-4 sm:px-6 md:px-8 lg:px-12 xl:px-16 pb-3",children:s.jsx(sc,{projectId:e,onSubmit:t,isPending:r.isPending,error:r.error,placeholder:i(),buttonText:s.jsx(R,{id:"chat.button.start"}),containerClassName:"",buttonSize:"default",enableScheduledSend:!0})})},Nz=e=>e.sessionId?s.jsx(Iz,{...e,sessionId:e.sessionId}):s.jsx(vS,{...e,sessionData:null}),Iz=e=>{const n=AC(e.projectId,e.sessionId);return s.jsx(vS,{...e,sessionId:e.sessionId,sessionData:n})},vS=({projectId:e,sessionId:n,setIsMobileSidebarOpen:r,projectPath:a,currentBranch:t,revisionsData:i,projectName:o,sessionData:l})=>{const u=l?.conversations??[],c=()=>{},p=l?.getToolResult??c,d=!!n&&l!==null&&l!==void 0,{currentPermissionRequest:g,isDialogOpen:m,onPermissionResponse:f}=_C(),{data:h}=Au(e),v=i??h,S=IC(),E=RC(),y=C.useMemo(()=>{if(n)return E.getSessionProcess(n)},[E,n]);NC(y?.status==="running");const[w,I]=C.useState(0),[b,T]=C.useState(!1),D=C.useRef(null),_=et({mutationFn:async $=>{const P=await ze.api.cc["session-processes"][":sessionProcessId"].abort.$post({param:{sessionProcessId:$},json:{projectId:e}});if(!P.ok)throw new Error(P.statusText);return P.json()}});C.useEffect(()=>{if(d&&y?.status==="running"&&u.length!==w){I(u.length);const $=D.current;$&&$.scrollTo({top:$.scrollHeight,behavior:"smooth"})}},[u,d,y?.status,w]);const k=()=>{const $=D.current;$&&$.scrollTo({top:0,behavior:"smooth"})},A=()=>{const $=D.current;$&&$.scrollTo({top:$.scrollHeight,behavior:"smooth"})};let j=o??e;return d?l&&n&&(j=l.session.meta.firstUserMessage!==null?Fy(l.session.meta.firstUserMessage):n):j=s.jsx(R,{id:"chat.modal.title"}),s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex-1 flex flex-col min-h-0 min-w-0",children:[s.jsxs("header",{className:"px-2 sm:px-3 py-2 sm:py-3 sticky top-0 z-10 bg-background w-full flex-shrink-0 min-w-0 border-b space-y-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ne,{variant:"ghost",size:"sm",className:"md:hidden flex-shrink-0",onClick:()=>r(!0),"data-testid":"mobile-sidebar-toggle-button",children:s.jsx(jT,{className:"w-4 h-4"})}),s.jsx("h1",{className:"text-lg sm:text-2xl md:text-3xl font-bold break-all overflow-ellipsis line-clamp-1 min-w-0",children:j})]}),s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1.5 min-w-0 overflow-hidden flex-1",children:[a&&s.jsxs(Ye,{children:[s.jsx(Ze,{asChild:!0,children:s.jsx(pe,{variant:"secondary",className:"h-6 text-xs flex items-center max-w-full cursor-help",children:s.jsx("span",{className:"truncate",children:a.split("/").pop()})})}),s.jsx(Xe,{children:a})]}),t&&s.jsxs(Ye,{children:[s.jsx(Ze,{asChild:!0,children:s.jsxs(pe,{variant:"secondary",className:"h-6 text-xs flex items-center gap-1 max-w-full cursor-help",children:[s.jsx(Rn,{className:"w-3 h-3 flex-shrink-0"}),s.jsx("span",{className:"truncate",children:t})]})}),s.jsx(Xe,{children:s.jsx(R,{id:"control.branch"})})]}),d&&n&&s.jsxs(Ye,{children:[s.jsx(Ze,{asChild:!0,children:s.jsx(pe,{variant:"secondary",className:"h-6 text-xs flex items-center max-w-full font-mono cursor-help",children:s.jsx("span",{className:"truncate",children:n})})}),s.jsx(Xe,{children:s.jsx(R,{id:"control.session_id"})})]})]}),y?.status==="running"&&s.jsxs(pe,{variant:"secondary",className:"bg-green-500/10 text-green-900 dark:text-green-200 border-green-500/20 flex-shrink-0 h-6 text-xs",children:[s.jsx(Cn,{className:"w-3 h-3 mr-1 animate-spin"}),s.jsx(R,{id:"session.conversation.running"})]}),y?.status==="paused"&&s.jsxs(pe,{variant:"secondary",className:"bg-orange-500/10 text-orange-900 dark:text-orange-200 border-orange-500/20 flex-shrink-0 h-6 text-xs",children:[s.jsx(FT,{className:"w-3 h-3 mr-1"}),s.jsx(R,{id:"session.conversation.paused"})]}),n!==void 0&&s.jsxs(Ye,{children:[s.jsx(Ze,{asChild:!0,children:s.jsx(ne,{variant:"ghost",size:"icon",className:"flex-shrink-0 h-6 w-6",onClick:()=>S.mutate({projectId:e,sessionId:n}),disabled:S.isPending,"aria-label":"Export session to HTML",children:s.jsx(ST,{className:`w-3.5 h-3.5 ${S.isPending?"animate-pulse":""}`})})}),s.jsx(Xe,{children:"Export to HTML"})]}),s.jsxs(xC,{children:[s.jsx(kC,{asChild:!0,children:s.jsx(ne,{variant:"ghost",size:"icon",className:"flex-shrink-0 h-6 w-6","aria-label":"Session metadata",children:s.jsx(Sy,{className:"w-3.5 h-3.5"})})}),s.jsx(wC,{className:"w-80",align:"end",children:s.jsx("div",{className:"space-y-4",children:s.jsxs("div",{children:[s.jsx("h3",{className:"font-semibold text-sm mb-2",children:s.jsx(R,{id:"control.metadata"})}),s.jsxs("div",{className:"space-y-2",children:[a&&s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx("span",{className:"text-xs text-muted-foreground",children:s.jsx(R,{id:"control.project_path"})}),s.jsxs(Ye,{children:[s.jsx(Ze,{asChild:!0,children:s.jsx(pe,{variant:"secondary",className:"h-7 text-xs flex items-center w-fit cursor-help",children:a.split("/").pop()})}),s.jsx(Xe,{children:a})]})]}),n&&d&&s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx("span",{className:"text-xs text-muted-foreground",children:s.jsx(R,{id:"control.session_id"})}),s.jsx(pe,{variant:"secondary",className:"h-7 text-xs flex items-center w-fit font-mono",children:n})]}),t&&s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx("span",{className:"text-xs text-muted-foreground",children:s.jsx(R,{id:"control.branch"})}),s.jsxs(pe,{variant:"secondary",className:"h-7 text-xs flex items-center gap-1 w-fit",children:[s.jsx(Rn,{className:"w-3 h-3"}),t]})]}),d&&l&&s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx("span",{className:"text-xs text-muted-foreground",children:s.jsx(R,{id:"session.cost.label"})}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs(pe,{variant:"secondary",className:"h-7 text-xs flex items-center w-fit font-semibold",children:[s.jsx(R,{id:"session.cost.total"}),": $",l.session.meta.cost.totalUsd.toFixed(3)]}),s.jsxs("div",{className:"text-xs space-y-1 pl-2",children:[s.jsxs("div",{className:"flex justify-between gap-4",children:[s.jsxs("span",{className:"text-muted-foreground",children:[s.jsx(R,{id:"session.cost.input_tokens"}),":"]}),s.jsxs("span",{children:["$",l.session.meta.cost.breakdown.inputTokensUsd.toFixed(3)," ","(",l.session.meta.cost.tokenUsage.inputTokens.toLocaleString(),")"]})]}),s.jsxs("div",{className:"flex justify-between gap-4",children:[s.jsxs("span",{className:"text-muted-foreground",children:[s.jsx(R,{id:"session.cost.output_tokens"}),":"]}),s.jsxs("span",{children:["$",l.session.meta.cost.breakdown.outputTokensUsd.toFixed(3)," ","(",l.session.meta.cost.tokenUsage.outputTokens.toLocaleString(),")"]})]}),s.jsxs("div",{className:"flex justify-between gap-4",children:[s.jsxs("span",{className:"text-muted-foreground",children:[s.jsx(R,{id:"session.cost.cache_creation"}),":"]}),s.jsxs("span",{children:["$",l.session.meta.cost.breakdown.cacheCreationUsd.toFixed(3)," ","(",l.session.meta.cost.tokenUsage.cacheCreationTokens.toLocaleString(),")"]})]}),s.jsxs("div",{className:"flex justify-between gap-4",children:[s.jsxs("span",{className:"text-muted-foreground",children:[s.jsx(R,{id:"session.cost.cache_read"}),":"]}),s.jsxs("span",{children:["$",l.session.meta.cost.breakdown.cacheReadUsd.toFixed(3)," ","(",l.session.meta.cost.tokenUsage.cacheReadTokens.toLocaleString(),")"]})]})]})]})]})]})]})})})]})]})]}),s.jsx("div",{ref:D,className:"flex-1 overflow-y-auto min-h-0 min-w-0","data-testid":"scrollable-content",children:s.jsxs("main",{className:"w-full px-4 sm:px-6 md:px-8 lg:px-12 xl:px-16 relative min-w-0 pb-4",children:[s.jsx(mS,{conversations:d?u:[],getToolResult:p,projectId:e,sessionId:n??""}),!d&&s.jsxs("div",{className:"rounded-2xl border border-dashed border-muted-foreground/40 bg-muted/30 p-8 text-center space-y-3",children:[s.jsx("div",{className:"mx-auto flex h-12 w-12 items-center justify-center rounded-full bg-background shadow-sm",children:s.jsx(pn,{className:"w-5 h-5 text-muted-foreground"})}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{className:"text-base font-semibold",children:s.jsx(R,{id:"chat.modal.title"})}),s.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:s.jsx(R,{id:"session.empty_state.description"})})]})]}),d&&y?.status==="running"&&s.jsx("div",{className:"flex justify-start items-center py-8 animate-in fade-in duration-500",children:s.jsxs("div",{className:"flex flex-col items-center gap-4",children:[s.jsxs("div",{className:"relative",children:[s.jsx(Cn,{className:"w-8 h-8 animate-spin text-primary"}),s.jsx("div",{className:"absolute inset-0 rounded-full bg-primary/20 animate-ping"})]}),s.jsx("p",{className:"text-sm text-muted-foreground font-medium animate-pulse",children:s.jsx(R,{id:"session.processing"})})]})})]})}),s.jsx("div",{className:"w-full pt-3",children:s.jsx(sz,{projectId:e,onScrollToTop:k,onScrollToBottom:A,onOpenDiffModal:d?()=>T(!0):void 0,sessionProcess:y,abortTask:_,isNewChat:!d})}),s.jsx("div",{className:"flex-shrink-0 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60",children:d&&n&&y?s.jsx(kz,{projectId:e,sessionId:n,sessionProcessId:y.id,sessionProcessStatus:y.status}):d&&n?s.jsx(wz,{projectId:e,sessionId:n}):s.jsx(_z,{projectId:e})})]}),d&&s.jsx(oz,{projectId:e,isOpen:b,onOpenChange:T,revisionsData:v}),s.jsx(sC,{permissionRequest:g,isOpen:m,onResponse:f})]})},SS=({projectId:e})=>{const n=Un(),{i18n:r}=Ke(),{data:a,isLoading:t,error:i,isFetching:o}=Pt({queryKey:Xn(e).queryKey,queryFn:Xn(e).queryFn,refetchOnMount:!1,refetchOnWindowFocus:!1,refetchOnReconnect:!1,refetchInterval:!1}),l=()=>{n.invalidateQueries({queryKey:Xn(e).queryKey})};return s.jsxs("div",{className:"flex flex-col h-full",children:[s.jsx("div",{className:"p-3 border-b border-sidebar-border",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("h2",{className:"text-sm font-semibold text-sidebar-foreground",children:s.jsx(R,{id:"mcp.title"})}),s.jsx(ne,{onClick:l,variant:"ghost",size:"sm",className:"h-7 w-7 p-0",disabled:t||o,title:r._("Reload MCP servers"),children:s.jsx(gy,{className:`w-3 h-3 ${t||o?"animate-spin":""}`})})]})}),s.jsxs("div",{className:"flex-1 overflow-auto p-3",children:[t&&s.jsx("div",{className:"flex items-center justify-center h-32",children:s.jsx("div",{className:"text-sm text-muted-foreground",children:s.jsx(an,{})})}),i&&s.jsx("div",{className:"text-sm text-red-500",children:s.jsx(R,{id:"mcp.error.load_failed",values:{error:i.message}})}),a&&a.servers.length===0&&s.jsx("div",{className:"text-sm text-muted-foreground text-center py-8",children:s.jsx(R,{id:"mcp.no.servers"})}),a&&a.servers.length>0&&s.jsx("div",{className:"space-y-3",children:a.servers.map(u=>s.jsx("div",{className:"p-3 bg-sidebar-accent/50 rounded-md border border-sidebar-border",children:s.jsx("div",{className:"flex items-start justify-between",children:s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("h3",{className:"text-sm font-medium text-sidebar-foreground truncate",children:u.name}),s.jsx("p",{className:"text-xs text-muted-foreground mt-1 font-mono break-all",children:u.command})]})})},u.name))})]})]})},ES=({currentSessionId:e,projectId:n})=>{const{data:r,fetchNextPage:a,hasNextPage:t,isFetchingNextPage:i}=Tu(n),o=r.pages.flatMap(m=>m.sessions),l=In(dy),{config:u}=kt(),p=qI({from:"/projects/$projectId/session"}).tab??"sessions",d=e==="",g=[...o].sort((m,f)=>{const h=l.find(D=>D.sessionId===m.id),v=l.find(D=>D.sessionId===f.id),S=h?.status,E=v?.status,y=D=>D==="running"?0:D==="paused"?1:2,w=y(S),I=y(E);if(w!==I)return w-I;const b=m.lastModifiedAt?new Date(m.lastModifiedAt).getTime():0;return(f.lastModifiedAt?new Date(f.lastModifiedAt).getTime():0)-b});return s.jsxs("div",{className:"h-full flex flex-col",children:[s.jsxs("div",{className:"border-b border-sidebar-border p-4",children:[s.jsx("div",{className:"flex items-center justify-between mb-2",children:s.jsx("h2",{className:"font-semibold text-lg",children:s.jsx(R,{id:"sessions.title"})})}),s.jsxs("p",{className:"text-xs text-sidebar-foreground/70",children:[o.length," ",s.jsx(R,{id:"sessions.total"})]})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto p-2 space-y-0.5",children:[s.jsx(An,{to:"/projects/$projectId/session",params:{projectId:n},search:{tab:p},className:ce("block rounded-lg p-2.5 transition-all duration-200 border-2 border-dashed border-sidebar-border/60 hover:border-blue-400/80 hover:bg-blue-50/50 dark:hover:bg-blue-950/40 bg-sidebar/10",d&&"bg-blue-100 dark:bg-blue-900/40 border-blue-400 dark:border-blue-500 shadow-sm"),children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-primary/10 text-primary",children:s.jsx(Iu,{className:"w-4 h-4"})}),s.jsx("div",{className:"space-y-0.5",children:s.jsx("p",{className:"text-sm font-semibold text-sidebar-foreground",children:s.jsx(R,{id:"chat.modal.title"})})})]})}),g.map(m=>{const f=m.id===e,h=m.meta.firstUserMessage!==null?Fy(m.meta.firstUserMessage):m.id,v=l.find(y=>y.sessionId===m.id),S=v?.status==="running",E=v?.status==="paused";return s.jsx(An,{to:"/projects/$projectId/session",params:{projectId:n},search:{tab:p,sessionId:m.id},className:ce("block rounded-lg p-2.5 transition-all duration-200 hover:bg-blue-50/60 dark:hover:bg-blue-950/40 hover:border-blue-300/60 dark:hover:border-blue-700/60 hover:shadow-sm border border-sidebar-border/40 bg-sidebar/30",f&&"bg-blue-100 dark:bg-blue-900/50 border-blue-400 dark:border-blue-600 shadow-md ring-1 ring-blue-200/50 dark:ring-blue-700/50 hover:bg-blue-100 dark:hover:bg-blue-900/50 hover:border-blue-400 dark:hover:border-blue-600"),children:s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsx("h3",{className:"text-sm font-medium line-clamp-2 leading-tight text-sidebar-foreground flex-1",children:h}),(S||E)&&s.jsx(pe,{variant:S?"default":"secondary",className:ce("text-xs",S&&"bg-green-500 text-white",E&&"bg-yellow-500 text-white"),children:S?s.jsx(R,{id:"session.status.running"}):s.jsx(R,{id:"session.status.paused"})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3 text-xs text-sidebar-foreground/70",children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(pn,{className:"w-3 h-3"}),s.jsx("span",{children:m.meta.messageCount})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(bT,{className:"w-3 h-3"}),s.jsxs("span",{children:["$",m.meta.cost.totalUsd.toFixed(2)]})]})]}),m.lastModifiedAt&&s.jsx("span",{className:"text-xs text-sidebar-foreground/60",children:Nu(m.lastModifiedAt,{locale:u.locale,target:"time"})})]})]})},m.id)}),t&&a&&s.jsx("div",{className:"p-2",children:s.jsx(ne,{onClick:()=>a(),disabled:i,variant:"outline",size:"sm",className:"w-full",children:i?s.jsx(R,{id:"common.loading"}):s.jsx(R,{id:"sessions.load.more"})})})]})]})},Tz=({currentSessionId:e,projectId:n,isOpen:r,onClose:a})=>{const{i18n:t}=Ke(),[i,o]=C.useState("sessions"),[l,u]=C.useState(!1);C.useEffect(()=>{u(!0)},[]),C.useEffect(()=>{const g=m=>{m.key==="Escape"&&a()};return r&&(document.addEventListener("keydown",g),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",g),document.body.style.overflow=""}},[r,a]);const c=g=>{o(g)},p=g=>{g.target===g.currentTarget&&a()},d=()=>{switch(i){case"sessions":return s.jsx(ES,{currentSessionId:e,projectId:n,isMobile:!0});case"mcp":return s.jsx(SS,{projectId:n});case"settings":return s.jsx("div",{className:"h-full flex flex-col",children:s.jsx(C.Suspense,{fallback:s.jsx("div",{className:"flex-1 flex items-center justify-center p-4",children:s.jsx("div",{className:"text-sm text-sidebar-foreground/70",children:s.jsx(R,{id:"settings.loading"})})}),children:s.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-6",children:[s.jsxs("div",{className:"space-y-4",children:[s.jsx("h3",{className:"font-medium text-sm text-sidebar-foreground",children:s.jsx(R,{id:"settings.session.display"})}),s.jsx(aT,{openingProjectId:n})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsx("h3",{className:"font-medium text-sm text-sidebar-foreground",children:s.jsx(R,{id:"settings.notifications"})}),s.jsx(iT,{})]})]})})});case"system-info":return s.jsx(rT,{});default:return null}};return l?GI.createPortal(s.jsxs("div",{className:ce("fixed inset-0 z-50 transition-all duration-300 ease-out md:hidden",r?"visible opacity-100":"invisible opacity-0 pointer-events-none"),children:[s.jsx("button",{type:"button",className:"absolute inset-0 bg-black/50 backdrop-blur-sm cursor-default",onClick:p,onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&a()},"aria-label":t._("Close sidebar")}),s.jsxs("div",{className:ce("absolute left-0 top-0 h-full w-80 max-w-[85vw] bg-sidebar text-sidebar-foreground transition-transform duration-300 ease-out flex",r?"translate-x-0":"-translate-x-full"),children:[s.jsx("div",{className:"w-12 flex flex-col border-r border-sidebar-border bg-sidebar/50",children:s.jsxs(Ey,{children:[s.jsxs(Ye,{children:[s.jsx(Ze,{asChild:!0,children:s.jsx(An,{to:"/projects",className:"w-12 h-12 flex items-center justify-center border-b border-sidebar-border hover:bg-sidebar-accent transition-colors",children:s.jsx(xy,{className:"w-4 h-4 text-sidebar-foreground/70"})})}),s.jsx(Xe,{side:"right",children:s.jsx("p",{children:s.jsx(R,{id:"sidebar.back.to.projects"})})})]}),s.jsxs("div",{className:"flex flex-col p-2 space-y-1",children:[s.jsxs(Ye,{children:[s.jsx(Ze,{asChild:!0,children:s.jsx("button",{type:"button",onClick:()=>c("sessions"),className:ce("w-8 h-8 flex items-center justify-center rounded-md transition-colors","hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",i==="sessions"?"bg-sidebar-accent text-sidebar-accent-foreground shadow-sm":"text-sidebar-foreground/70"),"data-testid":"sessions-tab-button-mobile",children:s.jsx(pn,{className:"w-4 h-4"})})}),s.jsx(Xe,{side:"right",children:s.jsx("p",{children:s.jsx(R,{id:"sidebar.show.session.list"})})})]}),s.jsxs(Ye,{children:[s.jsx(Ze,{asChild:!0,children:s.jsx("button",{type:"button",onClick:()=>c("mcp"),className:ce("w-8 h-8 flex items-center justify-center rounded-md transition-colors","hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",i==="mcp"?"bg-sidebar-accent text-sidebar-accent-foreground shadow-sm":"text-sidebar-foreground/70"),"data-testid":"mcp-tab-button-mobile",children:s.jsx(wy,{className:"w-4 h-4"})})}),s.jsx(Xe,{side:"right",children:s.jsx("p",{children:s.jsx(R,{id:"sidebar.show.mcp.settings"})})})]}),s.jsxs(Ye,{children:[s.jsx(Ze,{asChild:!0,children:s.jsx("button",{type:"button",onClick:()=>c("settings"),className:ce("w-8 h-8 flex items-center justify-center rounded-md transition-colors","hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",i==="settings"?"bg-sidebar-accent text-sidebar-accent-foreground shadow-sm":"text-sidebar-foreground/70"),"data-testid":"settings-tab-button-mobile",children:s.jsx(nT,{className:"w-4 h-4"})})}),s.jsx(Xe,{side:"right",children:s.jsx(R,{id:"settings.tab.title"})})]}),s.jsxs(Ye,{children:[s.jsx(Ze,{asChild:!0,children:s.jsx("button",{type:"button",onClick:()=>c("system-info"),className:ce("w-8 h-8 flex items-center justify-center rounded-md transition-colors","hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",i==="system-info"?"bg-sidebar-accent text-sidebar-accent-foreground shadow-sm":"text-sidebar-foreground/70"),"data-testid":"system-info-tab-button-mobile",children:s.jsx(Sy,{className:"w-4 h-4"})})}),s.jsx(Xe,{side:"right",children:s.jsx(R,{id:"system.info.tab.title"})})]})]})]})}),s.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-sidebar-border bg-sidebar/80 backdrop-blur-sm",children:[s.jsx("h2",{className:"text-lg font-semibold capitalize",children:i}),s.jsx(ne,{variant:"ghost",size:"sm",onClick:a,className:"h-8 w-8 p-0 hover:bg-sidebar-accent/50",children:s.jsx(_u,{className:"w-4 h-4"})})]}),s.jsx("div",{className:"flex-1 overflow-hidden",children:d()})]})]})]}),document.body):null},xS=C.forwardRef(({className:e,checked:n,onCheckedChange:r,disabled:a,...t},i)=>{const o=l=>{r?.(l.target.checked),t.onChange?.(l)};return s.jsxs("label",{className:ce("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors","focus-within:outline-none focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2 focus-within:ring-offset-background",a&&"cursor-not-allowed opacity-50",n?"bg-primary":"bg-input",e),children:[s.jsx("input",{type:"checkbox",className:"sr-only",ref:i,checked:n,onChange:o,disabled:a,...t}),s.jsx("span",{className:ce("pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform",n?"translate-x-4":"translate-x-0")})]})});xS.displayName="Switch";const kS=[{value:0,labelKey:s.jsx(R,{id:"cron_builder.sunday"})},{value:1,labelKey:s.jsx(R,{id:"cron_builder.monday"})},{value:2,labelKey:s.jsx(R,{id:"cron_builder.tuesday"})},{value:3,labelKey:s.jsx(R,{id:"cron_builder.wednesday"})},{value:4,labelKey:s.jsx(R,{id:"cron_builder.thursday"})},{value:5,labelKey:s.jsx(R,{id:"cron_builder.friday"})},{value:6,labelKey:s.jsx(R,{id:"cron_builder.saturday"})}];function Az(e){const n=e.trim().split(/\s+/);if(n.length!==5)return null;const r=n[0],a=n[1],t=n[4];if(!r||!a||!t)return null;if(a==="*"&&r==="0")return{mode:"hourly",hour:0,minute:0,dayOfWeek:0};if(t==="*"&&a!=="*"){const i=Number.parseInt(a,10),o=Number.parseInt(r,10);if(!Number.isNaN(i)&&!Number.isNaN(o))return{mode:"daily",hour:i,minute:o,dayOfWeek:0}}if(t!=="*"&&a!=="*"){const i=Number.parseInt(a,10),o=Number.parseInt(r,10),l=Number.parseInt(t,10);if(!Number.isNaN(i)&&!Number.isNaN(o)&&!Number.isNaN(l))return{mode:"weekly",hour:i,minute:o,dayOfWeek:l}}return{mode:"custom",hour:0,minute:0,dayOfWeek:0}}function cb(e,n,r,a){switch(e){case"hourly":return"0 * * * *";case"daily":return`${r} ${n} * * *`;case"weekly":return`${r} ${n} * * ${a}`;case"custom":return"0 0 * * *"}}function Rz(e){const n=e.trim().split(/\s+/);if(n.length!==5)return!1;const r=n[0],a=n[1],t=n[2],i=n[3],o=n[4];if(!r||!a||!t||!i||!o)return!1;const l=(u,c,p)=>{if(u==="*")return!0;const d=Number.parseInt(u,10);return!Number.isNaN(d)&&d>=c&&d<=p};return l(r,0,59)&&(a==="*"||l(a,0,23))&&(t==="*"||l(t,1,31))&&(i==="*"||l(i,1,12))&&(o==="*"||l(o,0,6))}function Cz(e){const n=e.trim().split(/\s+/);if(n.length!==5)return"Invalid cron expression";const r=n[0],a=n[1],t=n[4];if(!r||!a||!t)return"Invalid cron expression";if(a==="*")return`Every hour at ${r} minute(s)`;const i=`${a.padStart(2,"0")}:${r.padStart(2,"0")}`;if(t==="*")return`Every day at ${i}`;const o=Number.parseInt(t,10),l=kS.find(u=>u.value===o);return s.jsxs(s.Fragment,{children:["Every ",l?l.labelKey:"unknown"," at ",i]})}function Oz({value:e,onChange:n}){const r=Az(e),[a,t]=C.useState(r?.mode||"daily"),[i,o]=C.useState(r?.hour||9),[l,u]=C.useState(r?.minute||0),[c,p]=C.useState(r?.dayOfWeek||1),[d,g]=C.useState(e),[m,f]=C.useState(null);C.useEffect(()=>{if(a==="custom")Rz(d)?(n(d),f(null)):f("Invalid cron expression");else{const v=cb(a,i,l,c);n(v),g(v),f(null)}},[a,i,l,c,d,n]);const h=v=>{if(t(v),v!=="custom"){const S=cb(v,i,l,c);g(S)}};return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ie,{children:s.jsx(R,{id:"cron_builder.schedule_type"})}),s.jsxs(Ot,{value:a,onValueChange:h,children:[s.jsx(Dt,{children:s.jsx(Lt,{})}),s.jsxs($t,{children:[s.jsx(Ve,{value:"hourly",children:s.jsx(R,{id:"cron_builder.hourly"})}),s.jsx(Ve,{value:"daily",children:s.jsx(R,{id:"cron_builder.daily"})}),s.jsx(Ve,{value:"weekly",children:s.jsx(R,{id:"cron_builder.weekly"})}),s.jsx(Ve,{value:"custom",children:s.jsx(R,{id:"cron_builder.custom"})})]})]})]}),a==="daily"&&s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ie,{children:s.jsx(R,{id:"cron_builder.hour"})}),s.jsx(ht,{type:"number",min:"0",max:"23",value:i,onChange:v=>o(Number.parseInt(v.target.value,10))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ie,{children:s.jsx(R,{id:"cron_builder.minute"})}),s.jsx(ht,{type:"number",min:"0",max:"59",value:l,onChange:v=>u(Number.parseInt(v.target.value,10))})]})]}),a==="weekly"&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ie,{children:s.jsx(R,{id:"cron_builder.day_of_week"})}),s.jsxs(Ot,{value:String(c),onValueChange:v=>p(Number.parseInt(v,10)),children:[s.jsx(Dt,{children:s.jsx(Lt,{})}),s.jsx($t,{children:kS.map(v=>s.jsx(Ve,{value:String(v.value),children:v.labelKey},v.value))})]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ie,{children:s.jsx(R,{id:"cron_builder.hour"})}),s.jsx(ht,{type:"number",min:"0",max:"23",value:i,onChange:v=>o(Number.parseInt(v.target.value,10))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ie,{children:s.jsx(R,{id:"cron_builder.minute"})}),s.jsx(ht,{type:"number",min:"0",max:"59",value:l,onChange:v=>u(Number.parseInt(v.target.value,10))})]})]})]}),a==="custom"&&s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ie,{children:s.jsx(R,{id:"cron_builder.cron_expression"})}),s.jsx(ht,{value:d,onChange:v=>g(v.target.value),placeholder:"0 9 * * *"})]}),s.jsxs("div",{className:"rounded-md border p-3 text-sm",children:[s.jsx("div",{className:"font-medium mb-1",children:s.jsx(R,{id:"cron_builder.preview"})}),s.jsx("div",{className:"text-muted-foreground",children:m?s.jsx("span",{className:"text-destructive",children:m}):Cz(a==="custom"?d:e)}),s.jsxs("div",{className:"text-xs text-muted-foreground mt-2",children:[s.jsx(R,{id:"cron_builder.expression"}),":"," ",s.jsx("code",{children:a==="custom"?d:e})]})]})]})}const Dz=({open:e,onOpenChange:n,job:r,projectId:a,onSubmit:t,isSubmitting:i=!1})=>{const{_:o,i18n:l}=Ke(),[u,c]=C.useState(""),[p,d]=C.useState("cron"),[g,m]=C.useState("0 9 * * *"),[f,h]=C.useState(()=>{const _=new Date;return _.setHours(_.getHours()+1),_.toISOString().slice(0,16)}),[v,S]=C.useState(""),[E,y]=C.useState(!0),[w,I]=C.useState("skip"),b=xz();C.useEffect(()=>{if(r){if(c(r.name),d(r.schedule.type),r.schedule.type==="cron")m(r.schedule.expression),I(r.schedule.concurrencyPolicy);else if(r.schedule.type==="reserved"){const _=new Date(r.schedule.reservedExecutionTime),k=_.getFullYear(),A=String(_.getMonth()+1).padStart(2,"0"),j=String(_.getDate()).padStart(2,"0"),$=String(_.getHours()).padStart(2,"0"),P=String(_.getMinutes()).padStart(2,"0");h(`${k}-${A}-${j}T${$}:${P}`)}S(r.message.content),y(r.enabled)}else{c(""),d("cron"),m("0 9 * * *");const _=new Date;_.setHours(_.getHours()+1);const k=_.getFullYear(),A=String(_.getMonth()+1).padStart(2,"0"),j=String(_.getDate()).padStart(2,"0"),$=String(_.getHours()).padStart(2,"0"),P=String(_.getMinutes()).padStart(2,"0");h(`${k}-${A}-${j}T${$}:${P}`),S(""),y(!0),I("skip")}},[r]);const T=()=>{const _={name:u,schedule:p==="cron"?{type:"cron",expression:g,concurrencyPolicy:w}:{type:"reserved",reservedExecutionTime:(()=>{const k=f.match(/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})$/);if(!k)throw new Error("Invalid datetime format");const A=Number(k[1]),j=Number(k[2]),$=Number(k[3]),P=Number(k[4]),z=Number(k[5]);return new Date(A,j-1,$,P,z).toISOString()})()},message:{content:v,projectId:a,baseSessionId:null},enabled:E};t(_)},D=u.trim()!==""&&v.trim()!=="";return s.jsx(cn,{open:e,onOpenChange:n,children:s.jsxs(dn,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[s.jsxs(jn,{children:[s.jsx(Mn,{children:r?s.jsx(R,{id:"scheduler.dialog.title.edit"}):s.jsx(R,{id:"scheduler.dialog.title.create"})}),s.jsx(Pn,{children:s.jsx(R,{id:"scheduler.dialog.description"})})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-4",children:[s.jsxs("div",{className:"space-y-0.5",children:[s.jsx(Ie,{htmlFor:"enabled",className:"text-base font-semibold",children:s.jsx(R,{id:"scheduler.form.enabled"})}),s.jsx("p",{className:"text-sm text-muted-foreground",children:s.jsx(R,{id:"scheduler.form.enabled.description"})})]}),s.jsx(xS,{id:"enabled",checked:E,onCheckedChange:y,disabled:i})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ie,{htmlFor:"job-name",children:s.jsx(R,{id:"scheduler.form.name"})}),s.jsx(ht,{id:"job-name",value:u,onChange:_=>c(_.target.value),placeholder:o({id:"scheduler.form.name.placeholder",message:"e.g., Daily Report"}),disabled:i})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ie,{children:s.jsx(R,{id:"scheduler.form.schedule_type"})}),s.jsxs(Ot,{value:p,onValueChange:_=>d(_),disabled:i,children:[s.jsx(Dt,{children:s.jsx(Lt,{})}),s.jsxs($t,{children:[s.jsx(Ve,{value:"cron",children:s.jsx(R,{id:"scheduler.form.schedule_type.cron"})}),s.jsx(Ve,{value:"reserved",children:s.jsx(R,{id:"scheduler.form.schedule_type.reserved"})})]})]})]}),p==="cron"?s.jsx(Oz,{value:g,onChange:m}):s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ie,{htmlFor:"reserved-datetime",children:s.jsx(R,{id:"scheduler.form.reserved_time"})}),s.jsx(ht,{id:"reserved-datetime",type:"datetime-local",value:f,onChange:_=>h(_.target.value),disabled:i}),s.jsx("p",{className:"text-xs text-muted-foreground",children:s.jsx(R,{id:"scheduler.form.reserved_time.hint"})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ie,{htmlFor:"message-content",children:s.jsx(R,{id:"scheduler.form.message"})}),s.jsxs("div",{className:"relative",ref:b.containerRef,children:[s.jsx(oc,{ref:b.textareaRef,id:"message-content",value:v,onChange:_=>b.handleChange(_.target.value,S),onKeyDown:_=>b.handleKeyDown(_),placeholder:l._({id:"scheduler.form.message.placeholder",message:"Type message to send to Claude Code... (/ for commands, @ for files)"}),rows:4,disabled:i,className:"resize-none","aria-label":l._({id:"scheduler.form.message.aria_label",message:"Message input with completion support (/ for commands, @ for files)"}),"aria-expanded":v.startsWith("/")||v.includes("@"),"aria-haspopup":"listbox",role:"combobox","aria-autocomplete":"list"}),s.jsx(bS,{projectId:a,message:v,commandCompletionRef:b.commandCompletionRef,fileCompletionRef:b.fileCompletionRef,handleCommandSelect:_=>b.handleCommandSelect(_,S),handleFileSelect:_=>b.handleFileSelect(_,S),cursorPosition:b.cursorPosition})]}),s.jsx("p",{className:"text-xs text-muted-foreground",children:s.jsx(R,{id:"scheduler.form.message.hint"})})]}),p==="cron"&&s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ie,{children:s.jsx(R,{id:"scheduler.form.concurrency_policy"})}),s.jsxs(Ot,{value:w,onValueChange:_=>I(_),disabled:i,children:[s.jsx(Dt,{children:s.jsx(Lt,{})}),s.jsxs($t,{children:[s.jsx(Ve,{value:"skip",children:s.jsx(R,{id:"scheduler.form.concurrency_policy.skip"})}),s.jsx(Ve,{value:"run",children:s.jsx(R,{id:"scheduler.form.concurrency_policy.run"})})]})]})]})]}),s.jsxs(fy,{children:[s.jsx(ne,{variant:"outline",onClick:()=>n(!1),disabled:i,children:s.jsx(R,{id:"common.cancel"})}),s.jsx(ne,{onClick:T,disabled:!D||i,children:i?s.jsx(R,{id:"common.saving"}):r?s.jsx(R,{id:"common.update"}):s.jsx(R,{id:"common.create"})})]})]})})},Lz=({projectId:e,sessionId:n})=>{const{i18n:r}=Ke(),{data:a,isLoading:t,isFetching:i,error:o,refetch:l}=lz(),u=gS(),c=uz(),p=cz(),[d,g]=C.useState(!1),[m,f]=C.useState(null),[h,v]=C.useState(!1),[S,E]=C.useState(null),y=k=>{u.mutate(k,{onSuccess:()=>{de.success(r._({id:"scheduler.job.created",message:"Job created successfully"})),g(!1)},onError:A=>{de.error(r._({id:"scheduler.job.create_failed",message:"Failed to create job"}),{description:A.message})}})},w=k=>{m&&c.mutate({id:m.id,updates:k},{onSuccess:()=>{de.success(r._({id:"scheduler.job.updated",message:"Job updated successfully"})),g(!1),f(null)},onError:A=>{de.error(r._({id:"scheduler.job.update_failed",message:"Failed to update job"}),{description:A.message})}})},I=()=>{S&&p.mutate(S,{onSuccess:()=>{de.success(r._({id:"scheduler.job.deleted",message:"Job deleted successfully"})),v(!1),E(null)},onError:k=>{de.error(r._({id:"scheduler.job.delete_failed",message:"Failed to delete job"}),{description:k.message})}})},b=k=>{f(k),g(!0)},T=k=>{E(k),v(!0)},D=k=>k.schedule.type==="cron"?`Cron: ${k.schedule.expression}`:k.schedule.type==="reserved"?`Reserved: ${new Date(k.schedule.reservedExecutionTime).toLocaleString()}`:"Unknown schedule type",_=k=>k?new Date(k).toLocaleString():"Never";return s.jsxs("div",{className:"flex flex-col h-full",children:[s.jsx("div",{className:"p-3 border-b border-sidebar-border",children:s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsx("h2",{className:"text-sm font-semibold text-sidebar-foreground",children:s.jsx(R,{id:"scheduler.title"})}),s.jsxs("div",{className:"flex gap-1",children:[s.jsx(ne,{onClick:()=>l(),variant:"ghost",size:"sm",className:"h-7 w-7 p-0",disabled:t||i,title:r._({id:"common.reload",message:"Reload"}),children:s.jsx(gy,{className:`w-3 h-3 ${t||i?"animate-spin":""}`})}),s.jsx(ne,{onClick:()=>{f(null),g(!0)},variant:"ghost",size:"sm",className:"h-7 w-7 p-0",title:r._({id:"scheduler.create_job",message:"Create Job"}),children:s.jsx(Iu,{className:"w-3 h-3"})})]})]})}),s.jsxs("div",{className:"flex-1 overflow-auto p-3",children:[t&&s.jsx("div",{className:"flex items-center justify-center h-32",children:s.jsx("div",{className:"text-sm text-muted-foreground",children:s.jsx(an,{})})}),o&&s.jsx("div",{className:"text-sm text-red-500",children:s.jsx(R,{id:"scheduler.error.load_failed",values:{error:o.message}})}),a&&a.length===0&&s.jsx("div",{className:"text-sm text-muted-foreground text-center py-8",children:s.jsx(R,{id:"scheduler.no_jobs"})}),a&&a.length>0&&s.jsx("div",{className:"space-y-3",children:a.map(k=>s.jsxs("div",{className:"p-3 bg-sidebar-accent/50 rounded-md border border-sidebar-border",children:[s.jsxs("div",{className:"flex items-start justify-between mb-2",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("h3",{className:"text-sm font-medium text-sidebar-foreground truncate",children:k.name}),s.jsx(pe,{variant:k.enabled?"default":"secondary",className:"text-xs",children:k.enabled?s.jsx(R,{id:"scheduler.status.enabled"}):s.jsx(R,{id:"scheduler.status.disabled"})})]}),s.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:D(k)})]}),s.jsxs("div",{className:"flex gap-1",children:[s.jsx(ne,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>b(k),children:s.jsx(YT,{className:"w-3 h-3"})}),s.jsx(ne,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 text-destructive hover:text-destructive",onClick:()=>T(k.id),children:s.jsx(JT,{className:"w-3 h-3"})})]})]}),k.lastRunAt&&s.jsx("div",{className:"text-xs text-muted-foreground mt-2 pt-2 border-t border-sidebar-border",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("span",{children:[s.jsx(R,{id:"scheduler.last_run"}),s.jsx("span",{children:_(k.lastRunAt)})]}),k.lastRunStatus&&s.jsx(pe,{variant:k.lastRunStatus==="success"?"default":"destructive",className:"text-xs",children:k.lastRunStatus})]})})]},k.id))})]}),s.jsx(Dz,{open:d,onOpenChange:k=>{g(k),k||f(null)},job:m,projectId:e,currentSessionId:n,onSubmit:m?w:y,isSubmitting:u.isPending||c.isPending}),s.jsx(cn,{open:h,onOpenChange:v,children:s.jsxs(dn,{children:[s.jsxs(jn,{children:[s.jsx(Mn,{children:s.jsx(R,{id:"scheduler.delete_dialog.title"})}),s.jsx(Pn,{children:s.jsx(R,{id:"scheduler.delete_dialog.description"})})]}),s.jsxs(fy,{children:[s.jsx(ne,{variant:"outline",onClick:()=>{v(!1),E(null)},disabled:p.isPending,children:s.jsx(R,{id:"common.cancel"})}),s.jsx(ne,{variant:"destructive",onClick:I,disabled:p.isPending,children:p.isPending?s.jsx(R,{id:"common.deleting"}):s.jsx(R,{id:"common.delete"})})]})]})})]})},$z=({currentSessionId:e,projectId:n,className:r,isMobileOpen:a=!1,onMobileOpenChange:t,initialTab:i})=>{const o=e??"",l=C.useMemo(()=>[{id:"sessions",icon:pn,title:s.jsx(R,{id:"sidebar.show.session.list"}),content:s.jsx(C.Suspense,{fallback:s.jsx(an,{}),children:s.jsx(ES,{currentSessionId:o,projectId:n})})},{id:"mcp",icon:wy,title:s.jsx(R,{id:"sidebar.show.mcp.settings"}),content:s.jsx(SS,{projectId:n})},{id:"scheduler",icon:fT,title:s.jsx(R,{id:"sidebar.show.scheduler.jobs"}),content:s.jsx(Lz,{projectId:n,sessionId:o})}],[o,n]);return s.jsxs(s.Fragment,{children:[s.jsx("div",{className:ce("hidden md:flex h-full",r),children:s.jsx(oT,{projectId:n,additionalTabs:l,defaultActiveTab:i,headerButton:s.jsx(Ey,{children:s.jsxs(Ye,{children:[s.jsx(Ze,{asChild:!0,children:s.jsx(An,{to:"/projects",className:"w-12 h-12 flex items-center justify-center hover:bg-sidebar-accent transition-colors",children:s.jsx(xy,{className:"w-4 h-4 text-sidebar-foreground/70"})})}),s.jsx(Xe,{side:"right",children:s.jsx("p",{children:s.jsx(R,{id:"sidebar.back.to.projects"})})})]})})})}),s.jsx(Tz,{currentSessionId:o,projectId:n,isOpen:a,onClose:()=>t?.(!1)})]})},jz=({projectId:e,sessionId:n,isMobileSidebarOpen:r,setIsMobileSidebarOpen:a,tab:t})=>{const{data:i}=Tu(e),{data:o}=Au(e),l=i.pages[0];if(l===void 0)return null;const u=l.project,c=u.meta.projectPath??u.claudeProjectPath,p=o?.success?o.data.currentBranch?.name:void 0;return s.jsxs(s.Fragment,{children:[s.jsx(C.Suspense,{fallback:s.jsx(an,{}),children:s.jsx($z,{currentSessionId:n,projectId:e,isMobileOpen:r,onMobileOpenChange:a,initialTab:t})}),s.jsx(C.Suspense,{fallback:s.jsx(an,{}),children:s.jsx(Nz,{projectId:e,sessionId:n,setIsMobileSidebarOpen:a,projectPath:c,currentBranch:p,revisionsData:o,projectName:u.meta.projectName??"Untitled Project"})})]})},Mz=({projectId:e,sessionId:n,tab:r})=>{const[a,t]=C.useState(!1),{previewUrl:i,previewWidth:o}=wu(),l=i?100-o:100;return s.jsx("div",{className:"flex h-screen max-h-screen overflow-hidden transition-all duration-200",style:{width:`${l}%`},children:s.jsx(jz,{projectId:e,sessionId:n,tab:r,isMobileSidebarOpen:a,setIsMobileSidebarOpen:t})})};function zz(){const e=Sc.useParams(),n=Sc.useSearch(),{data:r}=Tu(e.projectId),a=r.pages[0]?.project.meta.projectName,{sessionId:t,tab:i}=n,o=a?`${a} - Claude Code Viewer`:"Claude Code Viewer";return s.jsxs(sT,{children:[s.jsx(HI,{children:s.jsx("title",{children:o})}),s.jsx(Mz,{projectId:e.projectId,sessionId:t,tab:i})]})}export{zz as component};
|
|
187
|
+
`),K4=({conversation:e})=>{const n=e.operation==="enqueue"?"Queue Operation: Enqueue":"Queue Operation: Dequeue";return s.jsxs(Le,{children:[s.jsx(We,{asChild:!0,children:s.jsxs("div",{className:"flex items-center justify-between cursor-pointer hover:bg-muted/50 rounded p-2 -mx-2",children:[s.jsx("h4",{className:"text-xs font-medium text-muted-foreground",children:n}),s.jsx($e,{className:"h-3 w-3 text-muted-foreground transition-transform group-data-[state=open]:rotate-180"})]})}),s.jsx(je,{children:s.jsx("div",{className:"bg-background rounded border p-3 mt-2",children:s.jsxs("div",{className:"space-y-2 text-xs",children:[s.jsxs("div",{children:[s.jsx("span",{className:"font-medium text-muted-foreground",children:"Operation:"})," ",e.operation]}),s.jsxs("div",{children:[s.jsx("span",{className:"font-medium text-muted-foreground",children:"Session ID:"})," ",e.sessionId]}),s.jsxs("div",{children:[s.jsx("span",{className:"font-medium text-muted-foreground",children:"Timestamp:"})," ",e.timestamp]}),e.operation==="enqueue"&&s.jsxs("div",{children:[s.jsx("span",{className:"font-medium text-muted-foreground",children:"Content:"}),s.jsx("pre",{className:"mt-1 overflow-x-auto whitespace-pre-wrap",children:W4(e.content)})]})]})})})]})},Y4=({children:e})=>s.jsxs(Le,{children:[s.jsx(We,{asChild:!0,children:s.jsxs("div",{className:"flex items-center justify-between cursor-pointer hover:bg-muted/50 rounded p-2 -mx-2 mb-2",children:[s.jsx("h4",{className:"text-xs font-medium text-muted-foreground",children:"Summarized"}),s.jsx($e,{className:"h-3 w-3 text-muted-foreground transition-transform group-data-[state=open]:rotate-180"})]})}),s.jsx(je,{children:s.jsx("div",{className:"bg-background rounded border p-3 mt-2",children:s.jsx("pre",{className:"text-xs overflow-x-auto",children:e})})})]}),Z4=({children:e})=>s.jsxs(Le,{children:[s.jsx(We,{asChild:!0,children:s.jsxs("div",{className:"flex items-center justify-between cursor-pointer hover:bg-muted/50 rounded p-2 -mx-2",children:[s.jsx("h4",{className:"text-xs font-medium text-muted-foreground",children:"System Message"}),s.jsx($e,{className:"h-3 w-3 text-muted-foreground transition-transform group-data-[state=open]:rotate-180"})]})}),s.jsx(je,{children:s.jsx("div",{className:"bg-background rounded border p-3 mt-2",children:s.jsx("pre",{className:"text-xs overflow-x-auto",children:e})})})]}),X4=/<(?<tag>[^>]+)>(?<content>\s*[^<]*?\s*)<\/\k<tag>>/g,J4=Je({tag:He(),content:He()});xu([Je({kind:ct("command"),commandName:He(),commandArgs:He().optional(),commandMessage:He().optional()}),Je({kind:ct("local-command"),stdout:He()}),Je({kind:ct("text"),content:He()})]);const Q4=e=>{const n=Array.from(e.matchAll(X4)).map(o=>J4.safeParse(o.groups)).filter(o=>o.success).map(o=>o.data);if(n.length===0)return{kind:"text",content:e};const r=n.find(o=>o.tag==="command-name")?.content,a=n.find(o=>o.tag==="command-args")?.content,t=n.find(o=>o.tag==="command-message")?.content,i=n.find(o=>o.tag==="local-command-stdout")?.content;switch(!0){case r!==void 0:return{kind:"command",commandName:r,commandArgs:a,commandMessage:t};case i!==void 0:return{kind:"local-command",stdout:i};default:return{kind:"text",content:e}}},ib=({text:e,id:n})=>{const r=Q4(e);return r.kind==="command"?s.jsxs(ut,{className:"border-green-200 bg-green-50/50 dark:border-green-800 dark:bg-green-950/20 gap-2 py-3 mb-3",id:n,children:[s.jsx(nn,{className:"py-0 px-4",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(au,{className:"h-4 w-4 text-green-600 dark:text-green-400"}),s.jsx(rn,{className:"text-sm font-medium",children:"Claude Code Command"}),s.jsx(pe,{variant:"outline",className:"border-green-300 text-green-700 dark:border-green-700 dark:text-green-300",children:r.commandName})]})}),r.commandArgs||r.commandMessage?s.jsx(hc,{className:"py-0 px-4",children:s.jsx("div",{className:"space-y-2",children:s.jsxs("div",{children:[r.commandArgs&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Arguments:"}),s.jsx("div",{className:"bg-background rounded border p-2 mt-1",children:s.jsx("code",{className:"text-xs whitespace-pre-line break-all",children:r.commandArgs})})]}),r.commandMessage&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Message:"}),s.jsx("div",{className:"bg-background rounded border p-2 mt-1",children:s.jsx("code",{className:"text-xs whitespace-pre-line break-all",children:r.commandMessage})})]})]})})}):null]}):r.kind==="local-command"?s.jsxs(ut,{className:"border-green-200 bg-green-50/50 dark:border-green-800 dark:bg-green-950/20 gap-2 py-3 mb-3",children:[s.jsx(nn,{className:"py-0 px-4",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(au,{className:"h-4 w-4 text-green-600 dark:text-green-400"}),s.jsx(rn,{className:"text-sm font-medium",children:"Local Command"})]})}),s.jsx(hc,{className:"py-0 px-4",children:s.jsx("pre",{className:"text-xs overflow-x-auto whitespace-pre-wrap break-words",children:r.stdout})})]}):s.jsx(dS,{className:"w-full px-3 py-3 mb-5 border border-border rounded-lg bg-slate-50 dark:bg-slate-900/50",content:r.content})},ob=({content:e,id:n})=>typeof e=="string"?s.jsx(ib,{text:e,id:n}):e.type==="text"?s.jsx(ib,{text:e.text,id:n}):e.type==="image"?e.source.type==="base64"?s.jsx(ut,{className:"border-purple-200 bg-purple-50/50 dark:border-purple-800 dark:bg-purple-950/20 mb-2 p-0 overflow-hidden",id:n,children:s.jsxs(Le,{children:[s.jsx(We,{asChild:!0,children:s.jsx("div",{className:"cursor-pointer hover:bg-purple-100/50 dark:hover:bg-purple-900/20 transition-colors px-3 py-1.5 group",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(CT,{className:"h-4 w-4 text-purple-600 dark:text-purple-400"}),s.jsx("span",{className:"text-sm font-medium",children:s.jsx(R,{id:"user.content.image"})}),s.jsx(pe,{variant:"outline",className:"border-purple-300 text-purple-700 dark:border-purple-700 dark:text-purple-300",children:e.source.media_type}),s.jsx($e,{className:"h-4 w-4 text-muted-foreground transition-transform group-data-[state=open]:rotate-180 ml-auto"})]})})}),s.jsx(je,{children:s.jsx("div",{className:"py-3 px-4 border-t border-purple-200 dark:border-purple-800",children:s.jsx("div",{className:"rounded-lg border overflow-hidden bg-background",children:s.jsx("img",{src:`data:${e.source.media_type};base64,${e.source.data}`,alt:"User uploaded content",className:"max-w-full h-auto max-h-96 object-contain"})})})})]})}):s.jsx(ut,{className:"border-red-200 bg-red-50/50 dark:border-red-800 dark:bg-red-950/20",id:n,children:s.jsxs(nn,{children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(nu,{className:"h-4 w-4 text-red-600 dark:text-red-400"}),s.jsx(rn,{className:"text-sm font-medium",children:s.jsx(R,{id:"user.content.unsupported_media"})}),s.jsx(pe,{variant:"destructive",children:s.jsx(R,{id:"common.error"})})]}),s.jsx(bc,{className:"text-xs",children:s.jsx(R,{id:"user.content.unsupported_media.description"})})]})}):e.type==="document"?e.source.type==="base64"&&e.source.media_type==="application/pdf"?s.jsx(ut,{className:"border-blue-200 bg-blue-50/50 dark:border-blue-800 dark:bg-blue-950/20 mb-2 p-0 overflow-hidden",id:n,children:s.jsxs(Le,{children:[s.jsx(We,{asChild:!0,children:s.jsx("div",{className:"cursor-pointer hover:bg-blue-100/50 dark:hover:bg-blue-900/20 transition-colors px-3 py-1.5 group",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ru,{className:"h-4 w-4 text-blue-600 dark:text-blue-400"}),s.jsx("span",{className:"text-sm font-medium",children:s.jsx(R,{id:"user.content.document.pdf"})}),s.jsx(pe,{variant:"outline",className:"border-blue-300 text-blue-700 dark:border-blue-700 dark:text-blue-300",children:e.source.media_type}),s.jsx($e,{className:"h-4 w-4 text-muted-foreground transition-transform group-data-[state=open]:rotate-180 ml-auto"})]})})}),s.jsx(je,{children:s.jsx("div",{className:"py-3 px-4 border-t border-blue-200 dark:border-blue-800",children:s.jsx("div",{className:"rounded-lg border overflow-hidden bg-background",children:s.jsx("embed",{src:`data:${e.source.media_type};base64,${e.source.data}`,type:"application/pdf",className:"w-full h-[600px]"})})})})]})}):e.source.type==="text"?s.jsx(ut,{className:"border-green-200 bg-green-50/50 dark:border-green-800 dark:bg-green-950/20 mb-2 p-0 overflow-hidden",id:n,children:s.jsxs(Le,{children:[s.jsx(We,{asChild:!0,children:s.jsx("div",{className:"cursor-pointer hover:bg-green-100/50 dark:hover:bg-green-900/20 transition-colors px-3 py-1.5 group",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ru,{className:"h-4 w-4 text-green-600 dark:text-green-400"}),s.jsx("span",{className:"text-sm font-medium",children:s.jsx(R,{id:"user.content.document.text"})}),s.jsx(pe,{variant:"outline",className:"border-green-300 text-green-700 dark:border-green-700 dark:text-green-300",children:e.source.media_type}),s.jsx($e,{className:"h-4 w-4 text-muted-foreground transition-transform group-data-[state=open]:rotate-180 ml-auto"})]})})}),s.jsx(je,{children:s.jsx("div",{className:"py-3 px-4 border-t border-green-200 dark:border-green-800",children:s.jsx("div",{className:"rounded-lg border overflow-hidden bg-background",children:s.jsx("pre",{className:"p-4 text-sm overflow-auto max-h-96",children:e.source.data})})})})]})}):s.jsx(ut,{className:"border-red-200 bg-red-50/50 dark:border-red-800 dark:bg-red-950/20",id:n,children:s.jsxs(nn,{children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(nu,{className:"h-4 w-4 text-red-600 dark:text-red-400"}),s.jsx(rn,{className:"text-sm font-medium",children:s.jsx(R,{id:"user.content.unsupported_document"})}),s.jsx(pe,{variant:"destructive",children:s.jsx(R,{id:"common.error"})})]}),s.jsx(bc,{className:"text-xs",children:s.jsx(R,{id:"user.content.unsupported_document.description"})})]})}):(e.type==="tool_result",null),ez=({conversation:e,getToolResult:n,getAgentIdForToolUse:r,getSidechainConversationByPrompt:a,getSidechainConversations:t,projectId:i,sessionId:o})=>{if(e.type==="summary")return s.jsx(Y4,{children:e.summary});if(e.type==="system")return s.jsx(Z4,{children:e.content});if(e.type==="file-history-snapshot")return s.jsx(H4,{conversation:e});if(e.type==="queue-operation")return s.jsx(K4,{conversation:e});if(e.type==="user"){const l=typeof e.message.content=="string"?s.jsx(ob,{content:e.message.content,id:`message-${e.uuid}`}):s.jsx("ul",{className:"w-full",id:`message-${e.uuid}`,children:e.message.content.map(u=>s.jsx("li",{children:s.jsx(ob,{content:u})},u.toString()))});return e.isMeta===!0?s.jsx(V4,{children:l}):l}return e.type==="assistant"?s.jsx("ul",{className:"w-full",children:e.message.content.map(l=>s.jsx("li",{children:s.jsx(q4,{content:l,getToolResult:n,getAgentIdForToolUse:r,getSidechainConversationByPrompt:a,getSidechainConversations:t,projectId:i,sessionId:o})},l.toString()))}):null},tz=e=>typeof e=="object"&&e!==null&&"agentId"in e&&typeof e.agentId=="string",sb=e=>{if(e.type==="user")return`user_${e.uuid}`;if(e.type==="assistant")return`assistant_${e.uuid}`;if(e.type==="system")return`system_${e.uuid}`;if(e.type==="summary")return`summary_${e.leafUuid}`;if(e.type==="file-history-snapshot")return`file-history-snapshot_${e.messageId}`;if(e.type==="queue-operation")return`queue-operation_${e.operation}_${e.sessionId}_${e.timestamp}`;throw new Error(`Unknown conversation type: ${e}`)},nz=({errorLine:e})=>s.jsx("li",{className:"w-full flex justify-start",children:s.jsx("div",{className:"w-full max-w-3xl lg:max-w-4xl sm:w-[90%] md:w-[85%] px-2",children:s.jsxs(Le,{children:[s.jsx(We,{asChild:!0,children:s.jsxs("div",{className:"flex items-center justify-between cursor-pointer hover:bg-muted/50 rounded p-2 -mx-2 border-l-2 border-red-400",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(xc,{className:"h-3 w-3 text-red-500"}),s.jsx("span",{className:"text-xs font-medium text-red-600",children:s.jsx(R,{id:"conversation.error.schema"})})]}),s.jsx($e,{className:"h-3 w-3 text-muted-foreground transition-transform group-data-[state=open]:rotate-180"})]})}),s.jsx(je,{children:s.jsx("div",{className:"bg-background rounded border border-red-200 p-3 mt-2",children:s.jsxs("div",{className:"space-y-3",children:[s.jsxs(FI,{variant:"destructive",className:"border-red-200 bg-red-50",children:[s.jsx(xc,{className:"h-4 w-4"}),s.jsx(BI,{className:"text-red-800",children:s.jsx(R,{id:"conversation.error.schema_validation"})}),s.jsxs(zI,{className:"text-red-700",children:[s.jsx(R,{id:"conversation.error.schema_validation.description"})," ",s.jsxs("a",{href:"https://github.com/d-kimuson/claude-code-viewer/issues",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-red-600 hover:text-red-800 underline underline-offset-4",children:[s.jsx(R,{id:"conversation.error.report_issue"}),s.jsx(xT,{className:"h-3 w-3"})]})]})]}),s.jsxs("div",{className:"bg-gray-50 border rounded px-3 py-2",children:[s.jsx("h5",{className:"text-xs font-medium text-gray-700 mb-2",children:s.jsx(R,{id:"conversation.error.raw_content"})}),s.jsx("pre",{className:"text-xs overflow-x-auto whitespace-pre-wrap break-all font-mono text-gray-800",children:e})]})]})})})]})})}),mS=({conversations:e,getToolResult:n,projectId:r,sessionId:a})=>{const t=C.useMemo(()=>e.filter(d=>d.type!=="x-error"),[e]),{isRootSidechain:i,getSidechainConversations:o,getSidechainConversationByPrompt:l,existsRelatedTaskCall:u}=G4(t),c=C.useMemo(()=>{const d=new Map;for(const g of t){if(g.type!=="user")continue;const m=g.message.content;if(typeof m!="string"){for(const f of m)if(typeof f!="string"&&f.type==="tool_result"){const h=g.toolUseResult;tz(h)&&d.set(f.tool_use_id,h.agentId)}}}return d},[t]),p=C.useCallback(d=>c.get(d),[c]);return s.jsx("ul",{children:e.flatMap(d=>{if(d.type==="x-error")return s.jsx(nz,{errorLine:d.line},`error_${d.line}`);const g=s.jsx(ez,{conversation:d,getToolResult:n,getAgentIdForToolUse:p,isRootSidechain:i,getSidechainConversations:o,getSidechainConversationByPrompt:l,existsRelatedTaskCall:u,projectId:r,sessionId:a},sb(d)),m=d.type!=="summary"&&d.type!=="file-history-snapshot"&&d.type!=="queue-operation"&&d.isSidechain;return m?[]:[s.jsx("li",{className:`w-full flex ${m||d.type==="assistant"||d.type==="system"||d.type==="summary"?"justify-start":"justify-end"} animate-in fade-in slide-in-from-bottom-2 duration-300`,children:s.jsx("div",{className:"w-full max-w-3xl lg:max-w-4xl sm:w-[90%] md:w-[85%]",children:g})},sb(d))]})})};function oc({className:e,...n}){return s.jsx("textarea",{"data-slot":"textarea",className:ce("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input flex min-h-[60px] w-full min-w-0 resize-none rounded-md border bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm","focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",e),...n})}const rz=({hunk:e})=>s.jsxs("div",{className:"relative flex overflow-x-auto",children:[s.jsxs("div",{className:"flex-shrink-0 sticky left-0 z-10 bg-white dark:bg-gray-900",children:[s.jsx("div",{className:"float-left w-10 bg-gray-50 dark:bg-gray-800/50 border-r border-gray-200 dark:border-gray-700",children:e.lines.map((n,r)=>s.jsx("div",{className:"px-1 py-0.5 text-xs text-gray-400 dark:text-gray-600 font-mono text-right leading-tight",children:n.type!=="added"&&n.type!=="hunk"&&n.oldLineNumber?n.oldLineNumber:" "},`old-${n.oldLineNumber}-${r}`))}),s.jsx("div",{className:"float-left w-10 bg-gray-50 dark:bg-gray-800/50 border-r border-gray-200 dark:border-gray-700",children:e.lines.map((n,r)=>s.jsx("div",{className:"px-1 py-0.5 text-xs text-gray-400 dark:text-gray-600 font-mono text-right leading-tight",children:n.type!=="deleted"&&n.type!=="hunk"&&n.newLineNumber?n.newLineNumber:" "},`new-${n.newLineNumber}-${r}`))})]}),s.jsx("div",{className:"flex-1 min-w-0",children:e.lines.map((n,r)=>s.jsx("div",{className:ce("flex border-l-4",{"bg-green-50 dark:bg-green-950/30 border-green-200 dark:border-green-800/50 border-l-green-400":n.type==="added","bg-red-50 dark:bg-red-950/30 border-red-200 dark:border-red-800/50 border-l-red-400":n.type==="deleted","bg-blue-50 dark:bg-blue-950/30 border-blue-200 dark:border-blue-800/50 border-l-blue-400":n.type==="hunk","bg-white dark:bg-gray-900 border-gray-100 dark:border-gray-800 border-l-transparent":n.type==="unchanged"}),children:s.jsx("div",{className:"flex-1 px-2 py-0.5",children:s.jsxs("span",{className:"font-mono text-xs whitespace-pre block leading-tight",children:[s.jsx("span",{className:ce({"text-green-600 dark:text-green-400":n.type==="added","text-red-600 dark:text-red-400":n.type==="deleted","text-blue-600 dark:text-blue-400 font-medium":n.type==="hunk","text-gray-400 dark:text-gray-600":n.type==="unchanged"}),children:n.type==="added"?"+":n.type==="deleted"?"-":n.type==="hunk"?"":" "}),n.content||" "]})})},`content-${n.content}-${n.oldLineNumber}-${n.newLineNumber}-${r}`))})]}),lb=({fileDiff:e,isCollapsed:n,onToggleCollapse:r})=>{const a=()=>e.isNew?s.jsx("span",{className:"text-green-600 dark:text-green-400",children:"A"}):e.isDeleted?s.jsx("span",{className:"text-red-600 dark:text-red-400",children:"D"}):e.isRenamed?s.jsx("span",{className:"text-blue-600 dark:text-blue-400",children:"R"}):s.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"M"}),t=async i=>{i.stopPropagation();try{await navigator.clipboard.writeText(e.filename),de.success("ファイル名をコピーしました")}catch(o){console.error("Failed to copy filename:",o),de.error("ファイル名のコピーに失敗しました")}};return s.jsxs(ne,{onClick:r,className:"w-full bg-gray-50 dark:bg-gray-800 px-3 py-1.5 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors sticky top-0 z-20",children:[s.jsxs("div",{className:"w-full flex items-center gap-2",children:[n?s.jsx(hy,{className:"w-4 h-4 text-gray-500 flex-shrink-0"}):s.jsx($e,{className:"w-4 h-4 text-gray-500 flex-shrink-0"}),s.jsx("div",{className:"w-5 h-5 rounded-full bg-gray-100 dark:bg-gray-700 flex items-center justify-center text-xs font-mono flex-shrink-0",children:a()}),s.jsx("span",{className:"font-mono text-xs font-medium text-black dark:text-white text-left truncate flex-1 min-w-0",children:e.filename}),s.jsxs("div",{className:"flex items-center gap-3 text-xs text-gray-500 dark:text-gray-400 flex-shrink-0",children:[e.linesAdded>0&&s.jsxs("span",{className:"text-green-600 dark:text-green-400",children:["+",e.linesAdded]}),e.linesDeleted>0&&s.jsxs("span",{className:"text-red-600 dark:text-red-400",children:["-",e.linesDeleted]})]}),s.jsx(ne,{onClick:t,variant:"ghost",size:"sm",className:"flex-shrink-0 p-1 h-5 w-5 hover:bg-gray-200 dark:hover:bg-gray-600",children:s.jsx(ky,{className:"w-3 h-3 text-gray-500 dark:text-gray-400"})})]}),e.isBinary&&s.jsx("div",{className:"mt-2 text-xs text-gray-500 dark:text-gray-400 text-left",children:"Binary file (content not shown)"})]})},az=({fileDiff:e,className:n})=>{const[r,a]=C.useState(!1),t=()=>{a(!r)};return e.isBinary?s.jsxs("div",{className:ce("border border-gray-200 dark:border-gray-700 rounded-lg",n),children:[s.jsx(lb,{fileDiff:e,isCollapsed:r,onToggleCollapse:t}),!r&&s.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400 text-sm",children:"Binary file cannot be displayed"})]}):s.jsxs("div",{className:ce("border border-gray-200 dark:border-gray-700 rounded-lg",n),children:[s.jsx(lb,{fileDiff:e,isCollapsed:r,onToggleCollapse:t}),!r&&s.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700",children:e.hunks.map((i,o)=>s.jsx(rz,{hunk:i},`${i.oldStart}-${i.newStart}-${o}`))})]})},iz=({summary:e,className:n})=>s.jsx("div",{className:ce("bg-gray-50 dark:bg-gray-800 rounded-lg p-2 border border-gray-200 dark:border-gray-700",n),children:s.jsxs("div",{className:"flex items-center justify-between text-sm",children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(ru,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),s.jsxs("span",{className:"font-medium",children:[s.jsxs("span",{className:"hidden sm:inline",children:[e.filesChanged," ",s.jsx(R,{id:"diff.files.changed"})]}),s.jsxs("span",{className:"sm:hidden",children:[e.filesChanged," ",s.jsx(R,{id:"diff.files"})]})]})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[e.insertions>0&&s.jsxs("span",{className:"text-green-600 dark:text-green-400 font-medium",children:["+",e.insertions]}),e.deletions>0&&s.jsxs("span",{className:"text-red-600 dark:text-red-400 font-medium",children:["-",e.deletions]})]})]})}),ub=({label:e,value:n,onValueChange:r,refs:a})=>{const t=C.useId(),i=o=>{switch(o){case"branch":return s.jsx(Rn,{className:"h-4 w-4"});case"commit":return s.jsx("span",{className:"text-xs",children:"📝"});case"working":return s.jsx("span",{className:"text-xs",children:"🚧"});default:return s.jsx(Rn,{className:"h-4 w-4"})}};return s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{htmlFor:t,className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:e}),s.jsxs(Ot,{value:n,onValueChange:r,children:[s.jsx(Dt,{className:"w-full sm:w-80",children:s.jsx(Lt,{})}),s.jsx($t,{id:t,children:a.map(o=>s.jsx(Ve,{value:o.name,children:s.jsxs("div",{className:"flex items-center gap-2",children:[i(o.type),s.jsx("span",{children:o.displayName}),o.sha&&s.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400 font-mono",children:o.sha.substring(0,7)})]})},o.name))})]})]})},oz=({isOpen:e,onOpenChange:n,projectId:r,defaultCompareFrom:a="HEAD",defaultCompareTo:t="working",revisionsData:i})=>{const{i18n:o}=Ke(),l=C.useId(),[u,c]=C.useState(a),[p,d]=C.useState(t),[g,m]=C.useState(new Map),[f,h]=C.useState(""),[v,S]=C.useState(!1),{data:E,isLoading:y}=Au(r),w=i??E,{mutate:I,data:b,isPending:T,error:D}=rC(),_=aC(r),k=iC(r),A=oC(r),j=w?.success&&w.data?[{name:"working",type:"working",displayName:o._("Uncommitted changes")},{name:"HEAD",type:"commit",displayName:"HEAD"},...w.data.baseBranch?[{name:`branch:${w.data.baseBranch.name}`,type:"branch",displayName:`${w.data.baseBranch.name} (base)`,sha:w.data.baseBranch.commit}]:[],...w.data.currentBranch?[{name:`branch:${w.data.currentBranch.name}`,type:"branch",displayName:`${w.data.currentBranch.name} (current)`,sha:w.data.currentBranch.commit}]:[],...w.data.commits.map(x=>({name:`commit:${x.sha}`,type:"commit",displayName:`${x.message.substring(0,50)}${x.message.length>50?"...":""}`,sha:x.sha}))]:[],$=C.useCallback(()=>{u&&p&&u!==p&&I({projectId:r,fromRef:u,toRef:p})},[u,p,I,r]);C.useEffect(()=>{if(b?.success&&b.data.files.length>0){const x=new Map(b.data.files.map(O=>[O.filePath,!0]));m(x)}},[b]),C.useEffect(()=>{e&&u&&p&&$()},[e,u,p,$]);const P=()=>{$()},z=x=>{m(O=>{const B=new Map(O),H=!O.get(x);return B.set(x,H),B})},ee=()=>{b?.success&&b.data.files.length>0&&m(new Map(b.data.files.map(x=>[x.filePath,!0])))},X=()=>{b?.success&&b.data.files.length>0&&m(new Map(b.data.files.map(x=>[x.filePath,!1])))},G=async()=>{const x=Array.from(g.entries()).filter(([O,B])=>B).map(([O])=>O);console.log("[DiffModal.handleCommit] Selected files state:",g),console.log("[DiffModal.handleCommit] Filtered selected files:",x),console.log("[DiffModal.handleCommit] Total files:",b?.success?b.data.files.length:0);try{const O=await _.mutateAsync({files:x,message:f});console.log("[DiffModal.handleCommit] Commit result:",O),O.success?(de.success(`Committed ${O.filesCommitted} files (${O.commitSha.slice(0,7)})`),h(""),$()):de.error(O.error,{description:O.details})}catch(O){console.error("[DiffModal.handleCommit] Error:",O),de.error(o._("Failed to commit"))}},te=async()=>{try{const x=await k.mutateAsync();console.log("[DiffModal.handlePush] Push result:",x),x.success?de.success(`Pushed to ${x.remote}/${x.branch}`):de.error(x.error,{description:x.details})}catch(x){console.error("[DiffModal.handlePush] Error:",x),de.error(o._("Failed to push"))}},N=async()=>{const x=Array.from(g.entries()).filter(([O,B])=>B).map(([O])=>O);console.log("[DiffModal.handleCommitAndPush] Selected files:",x);try{const O=await A.mutateAsync({files:x,message:f});console.log("[DiffModal.handleCommitAndPush] Result:",O),O.success?(de.success(`Committed and pushed (${O.commitSha.slice(0,7)})`),h(""),$()):O.success===!1&&"commitSucceeded"in O&&O.commitSucceeded?(de.warning(`Committed (${O.commitSha?.slice(0,7)}), but push failed: ${O.error}`,{action:{label:o._("Retry Push"),onClick:te}}),h(""),$()):de.error(O.error,{description:O.details})}catch(O){console.error("[DiffModal.handleCommitAndPush] Error:",O),de.error(o._("Failed to commit and push"))}},Y=Array.from(g.values()).filter(Boolean).length,Z=Y===0||f.trim().length===0||_.isPending;return s.jsx(cn,{open:e,onOpenChange:n,children:s.jsxs(dn,{className:"max-w-7xl w-[95vw] h-[90vh] overflow-hidden flex flex-col px-2 md:px-8",children:[s.jsxs("div",{className:"flex flex-col sm:flex-row gap-2 sm:items-end",children:[s.jsxs("div",{className:"flex flex-col sm:flex-row gap-2 flex-1",children:[s.jsx(ub,{label:o._("Compare from"),value:u,onValueChange:c,refs:j.filter(x=>x.name!=="working")}),s.jsx(ub,{label:o._("Compare to"),value:p,onValueChange:d,refs:j})]}),s.jsx(ne,{onClick:P,disabled:T||y||u===p,className:"sm:self-end w-full sm:w-auto",children:T?s.jsxs(s.Fragment,{children:[s.jsx(Tt,{className:"w-4 h-4 mr-2 animate-spin"}),s.jsx(R,{id:"common.loading"})]}):s.jsx(qT,{className:"w-4 h-4"})})]}),D&&s.jsx("div",{className:"bg-red-50 dark:bg-red-900/10 border border-red-200 dark:border-red-800 rounded-lg p-4",children:s.jsx("p",{className:"text-red-600 dark:text-red-400 text-sm",children:D.message})}),b?.success&&s.jsxs("div",{className:"flex-1 overflow-auto",children:[s.jsx(iz,{summary:{filesChanged:b.data.files.length,insertions:b.data.summary.totalAdditions,deletions:b.data.summary.totalDeletions,files:b.data.diffs.map(x=>({filename:x.file.filePath,oldFilename:x.file.oldPath,isNew:x.file.status==="added",isDeleted:x.file.status==="deleted",isRenamed:x.file.status==="renamed",isBinary:!1,hunks:x.hunks,linesAdded:x.file.additions,linesDeleted:x.file.deletions}))},className:"mb-3"}),p==="working"&&s.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900 rounded-lg mb-4 border border-gray-200 dark:border-gray-700",children:[s.jsxs("button",{type:"button",onClick:()=>S(!v),className:"w-full flex items-center justify-between p-2 hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors rounded-t-lg",children:[s.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:s.jsx(R,{id:"diff.commit.changes"})}),v?s.jsx(QI,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}):s.jsx($e,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"})]}),v&&s.jsxs("div",{className:"p-4 pt-0 space-y-3",children:[s.jsx("div",{className:"flex items-center justify-between",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ne,{size:"sm",variant:"ghost",onClick:ee,disabled:_.isPending,children:s.jsx(R,{id:"diff.select.all"})}),s.jsx(ne,{size:"sm",variant:"ghost",onClick:X,disabled:_.isPending,children:s.jsx(R,{id:"diff.deselect.all"})}),s.jsxs("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:[Y," / ",b.data.files.length," files selected"]})]})}),s.jsx("div",{className:"space-y-2 max-h-40 overflow-y-auto border border-gray-200 dark:border-gray-700 rounded p-2",children:b.data.files.map(x=>s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(eT,{id:`file-${x.filePath}`,checked:g.get(x.filePath)??!1,onCheckedChange:()=>z(x.filePath),disabled:_.isPending}),s.jsx("label",{htmlFor:`file-${x.filePath}`,className:"text-sm font-mono cursor-pointer flex-1",children:x.filePath})]},x.filePath))}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{htmlFor:l,className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:s.jsx(R,{id:"diff.commit.message"})}),s.jsx(oc,{id:l,placeholder:"Enter commit message...",value:f,onChange:x=>h(x.target.value),disabled:_.isPending,className:"resize-none",rows:3})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx(ne,{onClick:G,disabled:Z,className:"w-full sm:w-auto",children:_.isPending?s.jsxs(s.Fragment,{children:[s.jsx(Tt,{className:"w-4 h-4 mr-2 animate-spin"}),s.jsx(R,{id:"diff.committing"})]}):s.jsx(R,{id:"diff.commit"})}),s.jsx(ne,{onClick:te,disabled:k.isPending,variant:"outline",className:"w-full sm:w-auto",children:k.isPending?s.jsxs(s.Fragment,{children:[s.jsx(Tt,{className:"w-4 h-4 mr-2 animate-spin"}),s.jsx(R,{id:"diff.pushing"})]}):s.jsx(R,{id:"diff.push"})}),s.jsx(ne,{onClick:N,disabled:Z||A.isPending,variant:"secondary",className:"w-full sm:w-auto",children:A.isPending?s.jsxs(s.Fragment,{children:[s.jsx(Tt,{className:"w-4 h-4 mr-2 animate-spin"}),s.jsx(R,{id:"diff.committing.pushing"})]}):s.jsx(R,{id:"diff.commit.push"})}),Z&&!_.isPending&&!A.isPending&&s.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:Y===0?s.jsx(R,{id:"diff.select.file"}):s.jsx(R,{id:"diff.enter.message"})})]})]})]}),s.jsx("div",{className:"space-y-3",children:b.data.diffs.map(x=>s.jsx(az,{fileDiff:{filename:x.file.filePath,oldFilename:x.file.oldPath,isNew:x.file.status==="added",isDeleted:x.file.status==="deleted",isRenamed:x.file.status==="renamed",isBinary:!1,hunks:x.hunks,linesAdded:x.file.additions,linesDeleted:x.file.deletions}},x.file.filePath))})]}),T&&s.jsx("div",{className:"flex-1 flex items-center justify-center",children:s.jsxs("div",{className:"text-center space-y-2",children:[s.jsx(Tt,{className:"w-8 h-8 animate-spin mx-auto"}),s.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:s.jsx(R,{id:"diff.loading"})})]})})]})})},sz=({projectId:e,isPending:n=!1,onScrollToTop:r,onScrollToBottom:a,onOpenDiffModal:t,sessionProcess:i,abortTask:o,isNewChat:l=!1})=>{const{i18n:u}=Ke(),c=my(),{openPreview:p}=wu(),d=()=>{c({to:"/projects/$projectId/session",params:{projectId:e},search:g=>{const{sessionId:m,...f}=g;return f}})};return s.jsx("div",{className:"px-4 sm:px-6 md:px-8 lg:px-12 xl:px-16 mb-1",children:s.jsxs("div",{className:"py-0 flex items-center gap-1.5 flex-wrap",children:[t&&s.jsxs(ne,{type:"button",variant:"ghost",size:"sm",onClick:t,disabled:n,className:"h-7 px-2 gap-1.5 text-xs bg-muted/20 rounded-lg border border-border/40",title:u._({id:"control.open_git_dialog",message:"Open Git Dialog"}),children:[s.jsx(IT,{className:"w-3.5 h-3.5"}),s.jsx("span",{children:s.jsx(R,{id:"control.git"})})]}),s.jsx(ne,{type:"button",variant:"ghost",size:"sm",onClick:()=>p("about:blank"),disabled:n,className:"h-7 px-2 text-xs bg-muted/20 rounded-lg border border-border/40",title:u._({id:"control.open_browser",message:"Open Browser"}),children:s.jsx(AT,{className:"w-3.5 h-3.5"})}),s.jsxs(ne,{type:"button",variant:"ghost",size:"sm",disabled:n||l,className:"h-7 px-2 gap-1.5 text-xs bg-muted/20 rounded-lg border border-border/40",onClick:d,title:u._({id:"control.new_chat",message:"New Chat"}),children:[s.jsx(Iu,{className:"w-3.5 h-3.5"}),s.jsx("span",{children:s.jsx(R,{id:"control.new"})})]}),r&&s.jsx(ne,{type:"button",variant:"ghost",size:"sm",onClick:r,disabled:n,className:"h-7 px-2 gap-1.5 text-xs bg-muted/20 rounded-lg border border-border/40",title:u._({id:"control.scroll_to_top",message:"Scroll to Top"}),children:s.jsx(mT,{className:"w-3.5 h-3.5"})}),a&&s.jsx(ne,{type:"button",variant:"ghost",size:"sm",onClick:a,disabled:n,className:"h-7 px-2 gap-1.5 text-xs bg-muted/20 rounded-lg border border-border/40",title:u._({id:"control.scroll_to_bottom",message:"Scroll to Bottom"}),children:s.jsx(cT,{className:"w-3.5 h-3.5"})}),i&&o&&s.jsxs(ne,{type:"button",variant:"destructive",size:"sm",onClick:()=>{o.mutate(i.id)},disabled:o.isPending||n,className:"h-7 px-2 gap-1.5 text-xs rounded-lg",children:[o.isPending?s.jsx(Cn,{className:"w-3.5 h-3.5 animate-spin"}):s.jsx(_u,{className:"w-3.5 h-3.5"}),s.jsx("span",{children:s.jsx(R,{id:"session.conversation.abort"})})]})]})})},yt={all:["scheduler"],jobs:()=>[...yt.all,"jobs"],job:e=>[...yt.all,"job",e]},lz=()=>Pt({queryKey:yt.jobs(),queryFn:async()=>{const e=await ze.api.scheduler.jobs.$get();if(!e.ok)throw new Error("Failed to fetch scheduler jobs");return e.json()}}),gS=()=>{const e=Un();return et({mutationFn:async n=>{const r=await ze.api.scheduler.jobs.$post({json:n});if(!r.ok)throw new Error("Failed to create scheduler job");return r.json()},onSuccess:()=>{e.invalidateQueries({queryKey:yt.jobs()})}})},uz=()=>{const e=Un();return et({mutationFn:async({id:n,updates:r})=>{const a=await ze.api.scheduler.jobs[":id"].$patch({param:{id:n},json:r});if(!a.ok)throw a.status===404?new Error("Job not found"):new Error("Failed to update scheduler job");return a.json()},onSuccess:n=>{e.invalidateQueries({queryKey:yt.job(n.id)}),e.invalidateQueries({queryKey:yt.jobs()})}})},cz=()=>{const e=Un();return et({mutationFn:async n=>{const r=await ze.api.scheduler.jobs[":id"].$delete({param:{id:n}});if(!r.ok)throw r.status===404?new Error("Job not found"):new Error("Failed to delete scheduler job");return r.json()},onSuccess:(n,r)=>{e.invalidateQueries({queryKey:yt.job(r)}),e.invalidateQueries({queryKey:yt.jobs()})}})},fS=Nn(["image/png","image/jpeg","image/gif","image/webp"]),dz=Je({type:ct("image"),source:Je({type:ct("base64"),media_type:fS,data:He()})}),pz=Je({type:ct("document"),source:xu([Je({type:ct("text"),media_type:Nn(["text/plain"]),data:He()}),Je({type:ct("base64"),media_type:Nn(["application/pdf"]),data:He()})])});Je({text:He().min(1),images:tu(dz).optional(),documents:tu(pz).optional()});const mz=e=>e.startsWith("image/")?"image":e==="application/pdf"?"pdf":"text",gz=e=>new Promise((n,r)=>{const a=new FileReader;a.onload=()=>{const t=a.result;if(typeof t=="string"){const i=t.split(",")[1];n(i??"")}else r(new Error("Failed to read file as base64"))},a.onerror=()=>{r(new Error("Failed to read file"))},a.readAsDataURL(e)}),fz=e=>new Promise((n,r)=>{const a=new FileReader;a.onload=()=>{const t=a.result;typeof t=="string"?n(t):r(new Error("Failed to read file as text"))},a.onerror=()=>{r(new Error("Failed to read file"))},a.readAsText(e)}),hz=async e=>{const n=mz(e.type);if(n==="text")return{type:"text",content:await fz(e)};const r=await gz(e);if(n==="image"){const a=fS.safeParse(e.type);return a.success?{type:"image",block:{type:"image",source:{type:"base64",media_type:a.data,data:r}}}:null}return{type:"document",block:{type:"document",source:{type:"base64",media_type:"application/pdf",data:r}}}},bz=C.forwardRef(({projectId:e,inputValue:n,onCommandSelect:r,className:a},t)=>{const{i18n:i}=Ke(),[o,l]=C.useState(!1),[u,c]=C.useState(-1),p=C.useRef(null),d=C.useRef(null),{data:g}=Pt({queryKey:yc(e).queryKey,queryFn:yc(e).queryFn,staleTime:1e3*60*5}),{shouldShowCompletion:m,filteredCommands:f}=C.useMemo(()=>{const y=[...g?.defaultCommands||[],...g?.globalCommands||[],...g?.projectCommands||[]],w=n.startsWith("/"),I=w?n.slice(1).toLowerCase():"",b=w?y.filter(T=>T.toLowerCase().includes(I)):[];return{shouldShowCompletion:w,filteredCommands:b}},[g,n]),h=m&&f.length>0;o!==h&&(l(h),c(-1));const v=C.useCallback(y=>{r(`/${y} `),l(!1),c(-1)},[r]),S=C.useCallback(y=>{if(y>=0&&d.current){const I=d.current.querySelectorAll('button[role="option"]')[y];I&&I.scrollIntoView({block:"nearest",behavior:"smooth"})}},[]),E=C.useCallback(y=>{if(!o||f.length===0)return!1;switch(y.key){case"ArrowDown":return y.preventDefault(),c(w=>{const I=w<f.length-1?w+1:0;return requestAnimationFrame(()=>S(I)),I}),!0;case"ArrowUp":return y.preventDefault(),c(w=>{const I=w>0?w-1:f.length-1;return requestAnimationFrame(()=>S(I)),I}),!0;case"Enter":case"Tab":if(u>=0&&u<f.length){y.preventDefault();const w=f[u];return w&&v(w),!0}break;case"Escape":return y.preventDefault(),l(!1),c(-1),!0}return!1},[o,f.length,u,v,S,f]);return C.useEffect(()=>{const y=w=>{p.current&&!p.current.contains(w.target)&&(l(!1),c(-1))};return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[]),C.useImperativeHandle(t,()=>({handleKeyDown:E}),[E]),!m||f.length===0?null:s.jsx("div",{ref:p,className:ce("relative",a),children:s.jsx(Le,{open:o,onOpenChange:l,children:s.jsx(je,{children:s.jsx("div",{ref:d,className:"absolute z-50 w-full bg-popover border border-border rounded-lg shadow-xl overflow-hidden",style:{height:"15rem"},role:"listbox","aria-label":i._("Available commands"),children:s.jsx("div",{className:"h-full overflow-y-auto",children:f.length>0&&s.jsxs("div",{className:"p-1.5",children:[s.jsxs("div",{className:"px-3 py-2 text-xs font-semibold text-muted-foreground/80 border-b border-border/50 mb-1 flex items-center gap-2",role:"presentation",children:[s.jsx(au,{className:"w-3.5 h-3.5"}),"Available Commands (",f.length,")"]}),f.map((y,w)=>s.jsxs(ne,{variant:"ghost",size:"sm",className:ce("w-full justify-start text-left font-mono text-sm h-9 px-3 min-w-0 transition-colors duration-150",w===u?"bg-gradient-to-r from-blue-500/10 to-purple-500/10 text-foreground border border-blue-500/20":"hover:bg-accent/50"),onClick:()=>v(y),onMouseEnter:()=>c(w),role:"option","aria-selected":w===u,"aria-label":`Command: /${y}`,title:`/${y}`,children:[s.jsx("span",{className:"text-muted-foreground mr-1.5 flex-shrink-0",children:"/"}),s.jsx("span",{className:"font-medium truncate min-w-0",children:y}),w===u&&s.jsx(vy,{className:"w-3.5 h-3.5 ml-auto text-blue-600 dark:text-blue-400 flex-shrink-0"})]},y))]})})})})})})}),yz=(e,n,r=!0)=>Pt({queryKey:vc(e,n).queryKey,queryFn:vc(e,n).queryFn,enabled:r&&!!e,staleTime:1e3*60*5}),vz=e=>{const n=e.lastIndexOf("@");if(n===-1)return{shouldShow:!1,searchPath:"",beforeAt:"",afterAt:""};const r=e.slice(0,n),a=e.slice(n+1),t=a.split(/\s/),i=t[0]||"";return{shouldShow:!(t.length>1),searchPath:i,beforeAt:r,afterAt:a}},hS=C.forwardRef(({projectId:e,inputValue:n,onFileSelect:r,className:a},t)=>{const{i18n:i}=Ke(),[o,l]=C.useState(!1),[u,c]=C.useState(-1),p=C.useRef(null),d=C.useRef(null),{shouldShow:g,searchPath:m,beforeAt:f,afterAt:h}=C.useMemo(()=>vz(n),[n]),{basePath:v,filterTerm:S}=C.useMemo(()=>{if(!m)return{basePath:"/",filterTerm:""};const _=m.lastIndexOf("/");if(_===-1)return{basePath:"/",filterTerm:m};const k=m.slice(0,_+1),A=m.slice(_+1);return{basePath:k==="/"?"/":k,filterTerm:A}},[m]),{data:E,isLoading:y}=yz(e,v,g),w=C.useMemo(()=>E?.entries?S?E.entries.filter(_=>_.name.toLowerCase().includes(S.toLowerCase())):E.entries:[],[E?.entries,S]),I=g&&!y&&w.length>0;o!==I&&(l(I),c(-1));const b=C.useCallback((_,k=!1)=>{const A=_.path,j=h.split(/\s/).slice(1).join(" "),$=`${f}@${A}${j}`.trim()+(_.type==="directory"&&!k?"/":" ");r($),(_.type==="file"||k)&&(l(!1),c(-1))},[f,h,r]),T=C.useCallback(_=>{if(_>=0&&d.current){const A=d.current.querySelectorAll('button[role="option"]')[_];A&&A.scrollIntoView({block:"nearest",behavior:"smooth"})}},[]),D=C.useCallback(_=>{if(!o||w.length===0)return!1;switch(_.key){case"ArrowDown":return _.preventDefault(),c(k=>{const A=k<w.length-1?k+1:0;return requestAnimationFrame(()=>T(A)),A}),!0;case"ArrowUp":return _.preventDefault(),c(k=>{const A=k>0?k-1:w.length-1;return requestAnimationFrame(()=>T(A)),A}),!0;case"Enter":if(u>=0&&u<w.length){_.preventDefault();const k=w[u];return k&&b(k,!0),!0}break;case"Tab":if(u>=0&&u<w.length){_.preventDefault();const k=w[u];return k&&b(k,k.type==="file"),!0}break;case"Escape":return _.preventDefault(),l(!1),c(-1),!0}return!1},[o,w.length,u,b,T,w]);return C.useEffect(()=>{const _=k=>{p.current&&!p.current.contains(k.target)&&(l(!1),c(-1))};return document.addEventListener("mousedown",_),()=>document.removeEventListener("mousedown",_)},[]),C.useImperativeHandle(t,()=>({handleKeyDown:D}),[D]),!g||y||w.length===0?null:s.jsx("div",{ref:p,className:ce("relative",a),children:s.jsx(Le,{open:o,onOpenChange:l,children:s.jsx(je,{children:s.jsx("div",{ref:d,className:"absolute z-50 w-full bg-popover border border-border rounded-lg shadow-xl overflow-hidden",style:{height:"15rem"},role:"listbox","aria-label":i._("Available files and directories"),children:s.jsx("div",{className:"h-full overflow-y-auto",children:w.length>0&&s.jsxs("div",{className:"p-1.5",children:[s.jsxs("div",{className:"px-3 py-2 text-xs font-semibold text-muted-foreground/80 border-b border-border/50 mb-1 flex items-center gap-2",role:"presentation",children:[s.jsx(Ec,{className:"w-3.5 h-3.5"}),"Files & Directories (",w.length,")",v!=="/"&&s.jsxs("span",{className:"text-xs font-mono text-muted-foreground/70",children:["in ",v]})]}),w.map((_,k)=>s.jsxs(ne,{variant:"ghost",size:"sm",className:ce("w-full justify-start text-left font-mono text-sm h-9 px-3 min-w-0 transition-colors duration-150",k===u?"bg-gradient-to-r from-blue-500/10 to-purple-500/10 text-foreground border border-blue-500/20":"hover:bg-accent/50"),onClick:()=>b(_,_.type==="file"),onMouseEnter:()=>c(k),role:"option","aria-selected":k===u,"aria-label":`${_.type}: ${_.name}`,title:_.path,children:[_.type==="directory"?s.jsx(tT,{className:"w-3.5 h-3.5 mr-2 text-blue-500 dark:text-blue-400 flex-shrink-0"}):s.jsx(Ec,{className:"w-3.5 h-3.5 mr-2 text-gray-500 dark:text-gray-400 flex-shrink-0"}),s.jsx("span",{className:"font-medium truncate min-w-0",children:_.name}),_.type==="directory"&&s.jsx("span",{className:"text-muted-foreground ml-1 flex-shrink-0",children:"/"}),k===u&&s.jsx(vy,{className:"w-3.5 h-3.5 ml-auto text-blue-600 dark:text-blue-400 flex-shrink-0"})]},_.path))]})})})})})})});hS.displayName="FileCompletion";const Sz=(e,n,r)=>{const a=typeof window<"u"?window.innerHeight:800,t=a/2,i=48,o=36,l=12,c=Math.min(r,5),p=i+o*c+l,d=n.top<t,g=a-n.top,m=n.top;let f,h;d&&g>=p+20?(f="below",h=e.top+24):!d&&m>=p+20?(f="above",h=e.top-p-16):g>m?(f="below",h=e.top+24):(f="above",h=e.top-p-16);const E=(typeof window<"u"?window.innerWidth:1200)-512-16,y=Math.max(16,Math.min(e.left-16,E));return{top:h,left:y,placement:f}},bS=({projectId:e,message:n,commandCompletionRef:r,fileCompletionRef:a,handleCommandSelect:t,handleFileSelect:i,cursorPosition:o})=>{const l=C.useMemo(()=>Sz(o.relative,o.absolute,5),[o]);return s.jsxs("div",{className:"absolute w-full max-w-sm sm:max-w-md lg:max-w-lg xl:max-w-xl z-50",style:{top:l.top,left:l.left,maxWidth:typeof window<"u"?Math.min(512,window.innerWidth*.8):512},children:[s.jsx(bz,{ref:r,projectId:e,inputValue:n,onCommandSelect:t,className:`absolute left-0 right-0 ${l.placement==="above"?"bottom-full mb-2":"top-full mt-1"}`}),s.jsx(hS,{ref:a,projectId:e,inputValue:n,onFileSelect:i,className:`absolute left-0 right-0 ${l.placement==="above"?"bottom-full mb-2":"top-full mt-1"}`})]})},sc=({projectId:e,onSubmit:n,isPending:r,error:a,placeholder:t,buttonText:i,minHeight:o="min-h-[64px]",containerClassName:l="",disabled:u=!1,buttonSize:c="lg",enableScheduledSend:p=!1,baseSessionId:d=null})=>{const m=(O=>{const B=O.match(/(\d+)px/);if(B?.[1]){const H=parseInt(B[1],10);if(!Number.isNaN(H))return H}return 48})(o),{i18n:f}=Ke(),[h,v]=C.useState(""),[S,E]=C.useState([]),[y,w]=C.useState({relative:{top:0,left:0},absolute:{top:0,left:0}}),[I,b]=C.useState("immediate"),[T,D]=C.useState(()=>{const O=new Date;O.setHours(O.getHours()+1);const B=O.getFullYear(),H=String(O.getMonth()+1).padStart(2,"0"),Q=String(O.getDate()).padStart(2,"0"),ue=String(O.getHours()).padStart(2,"0"),me=String(O.getMinutes()).padStart(2,"0");return`${B}-${H}-${Q}T${ue}:${me}`}),_=C.useRef(null),k=C.useRef(null),A=C.useRef(null),j=C.useRef(null),$=C.useRef(null),P=C.useId(),{config:z}=kt(),ee=gS();C.useEffect(()=>{const O=k.current;if(!O)return;O.style.height="auto";const B=O.scrollHeight,H=200;O.style.height=`${Math.max(m,Math.min(B,H))}px`},[h,m]),C.useEffect(()=>{const O=k.current;O&&(O.style.height=`${m}px`)},[m]);const X=async()=>{if(!h.trim()&&S.length===0)return;const O=[],B=[];for(const{file:H}of S){const Q=await hz(H);Q!==null&&(Q.type==="text"?B.push({type:"document",source:{type:"text",media_type:"text/plain",data:Q.content}}):Q.type==="image"?O.push(Q.block):Q.type==="document"&&B.push(Q.block))}if(p&&I==="scheduled"){const H=T.match(/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})$/);if(!H)throw new Error("Invalid datetime format");const Q=Number(H[1]),ue=Number(H[2]),me=Number(H[3]),he=Number(H[4]),fe=Number(H[5]),Ae=new Date(Q,ue-1,me,he,fe);try{await ee.mutateAsync({name:`Scheduled message at ${T}`,schedule:{type:"reserved",reservedExecutionTime:Ae.toISOString()},message:{content:h,projectId:e,baseSessionId:d},enabled:!0}),de.success(f._({id:"chat.scheduled_send.success",message:"Message scheduled successfully"}),{description:f._({id:"chat.scheduled_send.success_description",message:"You can view and manage it in the Scheduler tab"})}),v(""),E([])}catch(Re){de.error(f._({id:"chat.scheduled_send.failed",message:"Failed to schedule message"}),{description:Re instanceof Error?Re.message:void 0})}}else await n({text:h,images:O.length>0?O:void 0,documents:B.length>0?B:void 0}),v(""),E([])},G=O=>{const B=O.target.files;if(!B)return;const H=Array.from(B).map(Q=>({file:Q,id:`${Q.name}-${Date.now()}-${Math.random()}`}));E(Q=>[...Q,...H]),A.current&&(A.current.value="")},te=O=>{E(B=>B.filter(H=>H.id!==O))},N=O=>{if(!$.current?.handleKeyDown(O)&&!j.current?.handleKeyDown(O)&&O.key==="Enter"&&!O.nativeEvent.isComposing){const B=z?.enterKeyBehavior;(B==="enter-send"&&!O.shiftKey&&!O.metaKey||B==="shift-enter-send"&&O.shiftKey&&!O.metaKey||B==="command-enter-send"&&O.metaKey&&!O.shiftKey)&&(O.preventDefault(),X())}},Y=C.useCallback(()=>{const O=k.current,B=_.current;if(O===null||B===null)return;const H=O.selectionStart,Q=O.value.substring(0,H),ue=O.value.substring(H),me=document.createTextNode(Q),he=document.createTextNode(ue),fe=document.createElement("span");fe.innerHTML=" ";const Ae=document.createElement("div");Ae.innerHTML="",Ae.append(me,fe,he);const Re=window.getComputedStyle(O);for(const Ce of["border","boxSizing","fontFamily","fontSize","fontWeight","letterSpacing","lineHeight","padding","textDecoration","textIndent","textTransform","whiteSpace","wordSpacing","wordWrap"])Ae.style[Ce]=Re[Ce];Ae.style.visibility="hidden",B.prepend(Ae);const pt=fe.getBoundingClientRect(),it=B.getBoundingClientRect();return B.removeChild(Ae),{relative:{top:pt.top-it.top-O.scrollTop,left:pt.left-it.left-O.scrollLeft},absolute:{top:pt.top-O.scrollTop,left:pt.left-O.scrollLeft}}},[]),Z=O=>{v(O),k.current?.focus()},x=O=>{v(O),k.current?.focus()};return s.jsxs("div",{className:l,children:[a&&s.jsxs("div",{className:"flex items-center gap-2.5 px-4 py-3 text-sm text-red-600 dark:text-red-400 bg-gradient-to-r from-red-50 to-red-100/50 dark:from-red-950/30 dark:to-red-900/20 border border-red-200/50 dark:border-red-800/50 rounded-xl mb-4 animate-in fade-in slide-in-from-top-2 duration-300 shadow-sm",children:[s.jsx(nu,{className:"w-4 h-4 shrink-0 mt-0.5"}),s.jsx("span",{className:"font-medium",children:s.jsx(R,{id:"chat.error.send_failed"})})]}),s.jsxs("div",{className:"relative group",children:[s.jsx("div",{className:"absolute -inset-0.5 bg-gradient-to-r from-blue-500/20 via-purple-500/20 to-pink-500/20 rounded-2xl blur opacity-0 group-hover:opacity-100 transition-opacity duration-500","aria-hidden":"true"}),s.jsxs("div",{className:"relative bg-background border border-border/40 rounded-2xl shadow-lg hover:shadow-xl transition-all duration-300 overflow-hidden",children:[s.jsx("div",{className:"relative",ref:_,children:s.jsx(oc,{ref:k,value:h,onChange:O=>{if(O.target.value.endsWith("@")||O.target.value.endsWith("/")){const B=Y();B&&w(B)}v(O.target.value)},onKeyDown:N,placeholder:t,className:"resize-none border-0 focus-visible:ring-0 focus-visible:ring-offset-0 bg-transparent px-5 py-2 text-base transition-all duration-200 placeholder:text-muted-foreground/60 overflow-y-auto leading-6",style:{minHeight:`${m}px`},disabled:r||u,"aria-label":f._("Message input with completion support"),"aria-describedby":P,"aria-expanded":h.startsWith("/")||h.includes("@"),"aria-haspopup":"listbox",role:"combobox","aria-autocomplete":"list"})}),S.length>0&&s.jsx("div",{className:"px-5 py-3 flex flex-wrap gap-2 border-t border-border/40",children:S.map(({file:O,id:B})=>s.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-muted rounded-lg text-sm",children:[s.jsx("span",{className:"truncate max-w-[200px]",children:O.name}),s.jsx("button",{type:"button",onClick:()=>te(B),className:"text-muted-foreground hover:text-foreground transition-colors",disabled:r,children:s.jsx(_u,{className:"w-3.5 h-3.5"})})]},B))}),s.jsxs("div",{className:"flex items-center justify-between gap-3 px-5 py-1 bg-muted/30 border-t border-border/40",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{ref:A,type:"file",multiple:!0,onChange:G,className:"hidden"}),s.jsxs(ne,{type:"button",variant:"ghost",size:"sm",onClick:()=>A.current?.click(),disabled:r||u,className:"gap-1.5",children:[s.jsx(PT,{className:"w-4 h-4"}),s.jsx("span",{className:"text-xs",children:s.jsx(R,{id:"chat.attach_file"})})]}),s.jsx("span",{className:"text-xs font-medium text-muted-foreground/80",id:P,children:h.length}),(h.startsWith("/")||h.includes("@"))&&s.jsxs("span",{className:"text-xs text-blue-600 dark:text-blue-400 font-medium flex items-center gap-1",children:[s.jsx(WT,{className:"w-3 h-3"}),s.jsx(R,{id:"chat.autocomplete.active"})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[p&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ie,{htmlFor:"send-mode",className:"text-xs sr-only",children:s.jsx(R,{id:"chat.send_mode.label"})}),s.jsxs(Ot,{value:I,onValueChange:O=>b(O),disabled:r||u,children:[s.jsx(Dt,{id:"send-mode",className:"h-8 w-[140px] text-xs",children:s.jsx(Lt,{})}),s.jsxs($t,{children:[s.jsx(Ve,{value:"immediate",children:s.jsx(R,{id:"chat.send_mode.immediate"})}),s.jsx(Ve,{value:"scheduled",children:s.jsx(R,{id:"chat.send_mode.scheduled"})})]})]}),I==="scheduled"&&s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(Ie,{htmlFor:"scheduled-time",className:"text-xs sr-only",children:s.jsx(R,{id:"chat.send_mode.scheduled_time"})}),s.jsx(ht,{id:"scheduled-time",type:"datetime-local",value:T,onChange:O=>D(O.target.value),disabled:r||u,className:"h-8 w-[180px] text-xs"})]})]}),s.jsx(ne,{onClick:X,disabled:!h.trim()&&S.length===0||r||u,size:c,className:"gap-2 transition-all duration-200 hover:shadow-md hover:scale-105 active:scale-95 bg-gradient-to-r from-blue-600 to-purple-600 hover:from-blue-500 hover:to-purple-500 disabled:from-muted disabled:to-muted",children:r?s.jsxs(s.Fragment,{children:[s.jsx(Cn,{className:"w-4 h-4 animate-spin"}),s.jsx("span",{children:s.jsx(R,{id:"chat.status.processing"})})]}):s.jsxs(s.Fragment,{children:[s.jsx(HT,{className:"w-4 h-4"}),i]})})]})]})]}),s.jsx(bS,{projectId:e,message:h,commandCompletionRef:j,fileCompletionRef:$,handleCommandSelect:Z,handleFileSelect:x,cursorPosition:y})]})]})},yS=(e,n)=>{const r=my();return et({mutationFn:async a=>{const t=await ze.api.cc["session-processes"].$post({json:{projectId:e,baseSessionId:a.baseSessionId,input:a.input}},{init:{signal:AbortSignal.timeout(6e4)}});if(!t.ok)throw new Error(t.statusText);return t.json()},onSuccess:async a=>{r({to:"/projects/$projectId/session",params:{projectId:e},search:t=>({...t,sessionId:a.sessionProcess.sessionId})})}})},Ez=(e,n)=>et({mutationFn:async r=>{const a=await ze.api.cc["session-processes"][":sessionProcessId"].continue.$post({param:{sessionProcessId:r.sessionProcessId},json:{projectId:e,baseSessionId:n,input:r.input}},{init:{signal:AbortSignal.timeout(6e4)}});if(!a.ok)throw new Error(a.statusText);return a.json()}});function xz(){const[e,n]=C.useState({relative:{top:0,left:0},absolute:{top:0,left:0}}),r=C.useRef(null),a=C.useRef(null),t=C.useRef(null),i=C.useRef(null),o=C.useCallback(()=>{const d=a.current,g=r.current;if(d===null||g===null)return;const m=d.selectionStart,f=d.value.substring(0,m),h=d.value.substring(m),v=document.createTextNode(f),S=document.createTextNode(h),E=document.createElement("span");E.innerHTML=" ";const y=document.createElement("div");y.innerHTML="",y.append(v,E,S);const w=window.getComputedStyle(d);for(const T of["border","boxSizing","fontFamily","fontSize","fontWeight","letterSpacing","lineHeight","padding","textDecoration","textIndent","textTransform","whiteSpace","wordSpacing","wordWrap"])y.style[T]=w[T];y.style.visibility="hidden",g.prepend(y);const I=E.getBoundingClientRect(),b=g.getBoundingClientRect();return g.removeChild(y),{relative:{top:I.top-b.top-d.scrollTop,left:I.left-b.left-d.scrollLeft},absolute:{top:I.top-d.scrollTop,left:I.left-d.scrollLeft}}},[]),l=C.useCallback((d,g)=>{if(d.endsWith("@")||d.endsWith("/")){const m=o();m&&n(m)}g(d)},[o]),u=C.useCallback(d=>!!(i.current?.handleKeyDown(d)||t.current?.handleKeyDown(d)),[]),c=C.useCallback((d,g)=>{g(d),a.current?.focus()},[]),p=C.useCallback((d,g)=>{g(d),a.current?.focus()},[]);return{cursorPosition:e,containerRef:r,textareaRef:a,commandCompletionRef:t,fileCompletionRef:i,getCursorPosition:o,handleChange:l,handleKeyDown:u,handleCommandSelect:c,handleFileSelect:p}}const kz=({projectId:e,sessionId:n,sessionProcessId:r,sessionProcessStatus:a})=>{const{i18n:t}=Ke(),i=Ez(e,n),{config:o}=kt(),l=async p=>{await i.mutateAsync({input:p,sessionProcessId:r})},u=()=>{const p=o?.enterKeyBehavior;return p==="enter-send"?t._({id:"chat.placeholder.continue.enter",message:"Type your message... (Start with / for commands, @ for files, Enter to send)"}):p==="command-enter-send"?t._({id:"chat.placeholder.continue.command_enter",message:"Type your message... (Start with / for commands, @ for files, Command+Enter to send)"}):t._({id:"chat.placeholder.continue.shift_enter",message:"Type your message... (Start with / for commands, @ for files, Shift+Enter to send)"})},c=a==="running";return s.jsx("div",{className:"w-full px-4 sm:px-6 md:px-8 lg:px-12 xl:px-16 pb-3",children:s.jsx(sc,{projectId:e,onSubmit:l,isPending:i.isPending,error:i.error,placeholder:u(),buttonText:s.jsx(R,{id:"chat.send"}),containerClassName:"",buttonSize:"default",enableScheduledSend:!c,baseSessionId:n,disabled:c})})},wz=({projectId:e,sessionId:n})=>{const{i18n:r}=Ke(),a=yS(e),{config:t}=kt(),i=async u=>{await a.mutateAsync({input:u,baseSessionId:n})},o=()=>{const u=t?.enterKeyBehavior;return u==="enter-send"?r._({id:"chat.placeholder.resume.enter",message:"Type your message... (Start with / for commands, @ for files, Enter to send)"}):u==="command-enter-send"?r._({id:"chat.placeholder.resume.command_enter",message:"Type your message... (Start with / for commands, @ for files, Command+Enter to send)"}):r._({id:"chat.placeholder.resume.shift_enter",message:"Type your message... (Start with / for commands, @ for files, Shift+Enter to send)"})},l=s.jsx(R,{id:"chat.resume"});return s.jsx("div",{className:"w-full px-4 sm:px-6 md:px-8 lg:px-12 xl:px-16 pb-3",children:s.jsx(sc,{projectId:e,onSubmit:i,isPending:a.isPending,error:a.error,placeholder:o(),buttonText:l,containerClassName:"",buttonSize:"default",enableScheduledSend:!0,baseSessionId:n})})},_z=({projectId:e})=>{const{i18n:n}=Ke(),r=yS(e),{config:a}=kt(),t=async o=>{await r.mutateAsync({input:o})},i=()=>{const o=a?.enterKeyBehavior;return o==="enter-send"?n._({id:"chat.placeholder.continue.enter",message:"Type your message... (Start with / for commands, @ for files, Enter to send)"}):o==="command-enter-send"?n._({id:"chat.placeholder.continue.command_enter",message:"Type your message... (Start with / for commands, @ for files, Command+Enter to send)"}):n._({id:"chat.placeholder.continue.shift_enter",message:"Type your message... (Start with / for commands, @ for files, Shift+Enter to send)"})};return s.jsx("div",{className:"w-full px-4 sm:px-6 md:px-8 lg:px-12 xl:px-16 pb-3",children:s.jsx(sc,{projectId:e,onSubmit:t,isPending:r.isPending,error:r.error,placeholder:i(),buttonText:s.jsx(R,{id:"chat.button.start"}),containerClassName:"",buttonSize:"default",enableScheduledSend:!0})})},Nz=e=>e.sessionId?s.jsx(Iz,{...e,sessionId:e.sessionId}):s.jsx(vS,{...e,sessionData:null}),Iz=e=>{const n=AC(e.projectId,e.sessionId);return s.jsx(vS,{...e,sessionId:e.sessionId,sessionData:n})},vS=({projectId:e,sessionId:n,setIsMobileSidebarOpen:r,projectPath:a,currentBranch:t,revisionsData:i,projectName:o,sessionData:l})=>{const u=l?.conversations??[],c=()=>{},p=l?.getToolResult??c,d=!!n&&l!==null&&l!==void 0,{currentPermissionRequest:g,isDialogOpen:m,onPermissionResponse:f}=_C(),{data:h}=Au(e),v=i??h,S=IC(),E=RC(),y=C.useMemo(()=>{if(n)return E.getSessionProcess(n)},[E,n]);NC(y?.status==="running");const[w,I]=C.useState(0),[b,T]=C.useState(!1),D=C.useRef(null),_=et({mutationFn:async $=>{const P=await ze.api.cc["session-processes"][":sessionProcessId"].abort.$post({param:{sessionProcessId:$},json:{projectId:e}});if(!P.ok)throw new Error(P.statusText);return P.json()}});C.useEffect(()=>{if(d&&y?.status==="running"&&u.length!==w){I(u.length);const $=D.current;$&&$.scrollTo({top:$.scrollHeight,behavior:"smooth"})}},[u,d,y?.status,w]);const k=()=>{const $=D.current;$&&$.scrollTo({top:0,behavior:"smooth"})},A=()=>{const $=D.current;$&&$.scrollTo({top:$.scrollHeight,behavior:"smooth"})};let j=o??e;return d?l&&n&&(j=l.session.meta.firstUserMessage!==null?Fy(l.session.meta.firstUserMessage):n):j=s.jsx(R,{id:"chat.modal.title"}),s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex-1 flex flex-col min-h-0 min-w-0",children:[s.jsxs("header",{className:"px-2 sm:px-3 py-2 sm:py-3 sticky top-0 z-10 bg-background w-full flex-shrink-0 min-w-0 border-b space-y-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ne,{variant:"ghost",size:"sm",className:"md:hidden flex-shrink-0",onClick:()=>r(!0),"data-testid":"mobile-sidebar-toggle-button",children:s.jsx(jT,{className:"w-4 h-4"})}),s.jsx("h1",{className:"text-lg sm:text-2xl md:text-3xl font-bold break-all overflow-ellipsis line-clamp-1 min-w-0",children:j})]}),s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1.5 min-w-0 overflow-hidden flex-1",children:[a&&s.jsxs(Ye,{children:[s.jsx(Ze,{asChild:!0,children:s.jsx(pe,{variant:"secondary",className:"h-6 text-xs flex items-center max-w-full cursor-help",children:s.jsx("span",{className:"truncate",children:a.split("/").pop()})})}),s.jsx(Xe,{children:a})]}),t&&s.jsxs(Ye,{children:[s.jsx(Ze,{asChild:!0,children:s.jsxs(pe,{variant:"secondary",className:"h-6 text-xs flex items-center gap-1 max-w-full cursor-help",children:[s.jsx(Rn,{className:"w-3 h-3 flex-shrink-0"}),s.jsx("span",{className:"truncate",children:t})]})}),s.jsx(Xe,{children:s.jsx(R,{id:"control.branch"})})]}),d&&n&&s.jsxs(Ye,{children:[s.jsx(Ze,{asChild:!0,children:s.jsx(pe,{variant:"secondary",className:"h-6 text-xs flex items-center max-w-full font-mono cursor-help",children:s.jsx("span",{className:"truncate",children:n})})}),s.jsx(Xe,{children:s.jsx(R,{id:"control.session_id"})})]})]}),y?.status==="running"&&s.jsxs(pe,{variant:"secondary",className:"bg-green-500/10 text-green-900 dark:text-green-200 border-green-500/20 flex-shrink-0 h-6 text-xs",children:[s.jsx(Cn,{className:"w-3 h-3 mr-1 animate-spin"}),s.jsx(R,{id:"session.conversation.running"})]}),y?.status==="paused"&&s.jsxs(pe,{variant:"secondary",className:"bg-orange-500/10 text-orange-900 dark:text-orange-200 border-orange-500/20 flex-shrink-0 h-6 text-xs",children:[s.jsx(FT,{className:"w-3 h-3 mr-1"}),s.jsx(R,{id:"session.conversation.paused"})]}),n!==void 0&&s.jsxs(Ye,{children:[s.jsx(Ze,{asChild:!0,children:s.jsx(ne,{variant:"ghost",size:"icon",className:"flex-shrink-0 h-6 w-6",onClick:()=>S.mutate({projectId:e,sessionId:n}),disabled:S.isPending,"aria-label":"Export session to HTML",children:s.jsx(ST,{className:`w-3.5 h-3.5 ${S.isPending?"animate-pulse":""}`})})}),s.jsx(Xe,{children:"Export to HTML"})]}),s.jsxs(xC,{children:[s.jsx(kC,{asChild:!0,children:s.jsx(ne,{variant:"ghost",size:"icon",className:"flex-shrink-0 h-6 w-6","aria-label":"Session metadata",children:s.jsx(Sy,{className:"w-3.5 h-3.5"})})}),s.jsx(wC,{className:"w-80",align:"end",children:s.jsx("div",{className:"space-y-4",children:s.jsxs("div",{children:[s.jsx("h3",{className:"font-semibold text-sm mb-2",children:s.jsx(R,{id:"control.metadata"})}),s.jsxs("div",{className:"space-y-2",children:[a&&s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx("span",{className:"text-xs text-muted-foreground",children:s.jsx(R,{id:"control.project_path"})}),s.jsxs(Ye,{children:[s.jsx(Ze,{asChild:!0,children:s.jsx(pe,{variant:"secondary",className:"h-7 text-xs flex items-center w-fit cursor-help",children:a.split("/").pop()})}),s.jsx(Xe,{children:a})]})]}),n&&d&&s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx("span",{className:"text-xs text-muted-foreground",children:s.jsx(R,{id:"control.session_id"})}),s.jsx(pe,{variant:"secondary",className:"h-7 text-xs flex items-center w-fit font-mono",children:n})]}),t&&s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx("span",{className:"text-xs text-muted-foreground",children:s.jsx(R,{id:"control.branch"})}),s.jsxs(pe,{variant:"secondary",className:"h-7 text-xs flex items-center gap-1 w-fit",children:[s.jsx(Rn,{className:"w-3 h-3"}),t]})]}),d&&l&&s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx("span",{className:"text-xs text-muted-foreground",children:s.jsx(R,{id:"session.cost.label"})}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs(pe,{variant:"secondary",className:"h-7 text-xs flex items-center w-fit font-semibold",children:[s.jsx(R,{id:"session.cost.total"}),": $",l.session.meta.cost.totalUsd.toFixed(3)]}),s.jsxs("div",{className:"text-xs space-y-1 pl-2",children:[s.jsxs("div",{className:"flex justify-between gap-4",children:[s.jsxs("span",{className:"text-muted-foreground",children:[s.jsx(R,{id:"session.cost.input_tokens"}),":"]}),s.jsxs("span",{children:["$",l.session.meta.cost.breakdown.inputTokensUsd.toFixed(3)," ","(",l.session.meta.cost.tokenUsage.inputTokens.toLocaleString(),")"]})]}),s.jsxs("div",{className:"flex justify-between gap-4",children:[s.jsxs("span",{className:"text-muted-foreground",children:[s.jsx(R,{id:"session.cost.output_tokens"}),":"]}),s.jsxs("span",{children:["$",l.session.meta.cost.breakdown.outputTokensUsd.toFixed(3)," ","(",l.session.meta.cost.tokenUsage.outputTokens.toLocaleString(),")"]})]}),s.jsxs("div",{className:"flex justify-between gap-4",children:[s.jsxs("span",{className:"text-muted-foreground",children:[s.jsx(R,{id:"session.cost.cache_creation"}),":"]}),s.jsxs("span",{children:["$",l.session.meta.cost.breakdown.cacheCreationUsd.toFixed(3)," ","(",l.session.meta.cost.tokenUsage.cacheCreationTokens.toLocaleString(),")"]})]}),s.jsxs("div",{className:"flex justify-between gap-4",children:[s.jsxs("span",{className:"text-muted-foreground",children:[s.jsx(R,{id:"session.cost.cache_read"}),":"]}),s.jsxs("span",{children:["$",l.session.meta.cost.breakdown.cacheReadUsd.toFixed(3)," ","(",l.session.meta.cost.tokenUsage.cacheReadTokens.toLocaleString(),")"]})]})]})]})]})]})]})})})]})]})]}),s.jsx("div",{ref:D,className:"flex-1 overflow-y-auto min-h-0 min-w-0","data-testid":"scrollable-content",children:s.jsxs("main",{className:"w-full px-4 sm:px-6 md:px-8 lg:px-12 xl:px-16 relative min-w-0 pb-4",children:[s.jsx(mS,{conversations:d?u:[],getToolResult:p,projectId:e,sessionId:n??""}),!d&&s.jsxs("div",{className:"rounded-2xl border border-dashed border-muted-foreground/40 bg-muted/30 p-8 text-center space-y-3",children:[s.jsx("div",{className:"mx-auto flex h-12 w-12 items-center justify-center rounded-full bg-background shadow-sm",children:s.jsx(pn,{className:"w-5 h-5 text-muted-foreground"})}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{className:"text-base font-semibold",children:s.jsx(R,{id:"chat.modal.title"})}),s.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:s.jsx(R,{id:"session.empty_state.description"})})]})]}),d&&y?.status==="running"&&s.jsx("div",{className:"flex justify-start items-center py-8 animate-in fade-in duration-500",children:s.jsxs("div",{className:"flex flex-col items-center gap-4",children:[s.jsxs("div",{className:"relative",children:[s.jsx(Cn,{className:"w-8 h-8 animate-spin text-primary"}),s.jsx("div",{className:"absolute inset-0 rounded-full bg-primary/20 animate-ping"})]}),s.jsx("p",{className:"text-sm text-muted-foreground font-medium animate-pulse",children:s.jsx(R,{id:"session.processing"})})]})})]})}),s.jsx("div",{className:"w-full pt-3",children:s.jsx(sz,{projectId:e,onScrollToTop:k,onScrollToBottom:A,onOpenDiffModal:d?()=>T(!0):void 0,sessionProcess:y,abortTask:_,isNewChat:!d})}),s.jsx("div",{className:"flex-shrink-0 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60",children:d&&n&&y?s.jsx(kz,{projectId:e,sessionId:n,sessionProcessId:y.id,sessionProcessStatus:y.status}):d&&n?s.jsx(wz,{projectId:e,sessionId:n}):s.jsx(_z,{projectId:e})})]}),d&&s.jsx(oz,{projectId:e,isOpen:b,onOpenChange:T,revisionsData:v}),s.jsx(sC,{permissionRequest:g,isOpen:m,onResponse:f})]})},SS=({projectId:e})=>{const n=Un(),{i18n:r}=Ke(),{data:a,isLoading:t,error:i,isFetching:o}=Pt({queryKey:Xn(e).queryKey,queryFn:Xn(e).queryFn,refetchOnMount:!1,refetchOnWindowFocus:!1,refetchOnReconnect:!1,refetchInterval:!1}),l=()=>{n.invalidateQueries({queryKey:Xn(e).queryKey})};return s.jsxs("div",{className:"flex flex-col h-full",children:[s.jsx("div",{className:"p-3 border-b border-sidebar-border",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("h2",{className:"text-sm font-semibold text-sidebar-foreground",children:s.jsx(R,{id:"mcp.title"})}),s.jsx(ne,{onClick:l,variant:"ghost",size:"sm",className:"h-7 w-7 p-0",disabled:t||o,title:r._("Reload MCP servers"),children:s.jsx(gy,{className:`w-3 h-3 ${t||o?"animate-spin":""}`})})]})}),s.jsxs("div",{className:"flex-1 overflow-auto p-3",children:[t&&s.jsx("div",{className:"flex items-center justify-center h-32",children:s.jsx("div",{className:"text-sm text-muted-foreground",children:s.jsx(an,{})})}),i&&s.jsx("div",{className:"text-sm text-red-500",children:s.jsx(R,{id:"mcp.error.load_failed",values:{error:i.message}})}),a&&a.servers.length===0&&s.jsx("div",{className:"text-sm text-muted-foreground text-center py-8",children:s.jsx(R,{id:"mcp.no.servers"})}),a&&a.servers.length>0&&s.jsx("div",{className:"space-y-3",children:a.servers.map(u=>s.jsx("div",{className:"p-3 bg-sidebar-accent/50 rounded-md border border-sidebar-border",children:s.jsx("div",{className:"flex items-start justify-between",children:s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("h3",{className:"text-sm font-medium text-sidebar-foreground truncate",children:u.name}),s.jsx("p",{className:"text-xs text-muted-foreground mt-1 font-mono break-all",children:u.command})]})})},u.name))})]})]})},ES=({currentSessionId:e,projectId:n})=>{const{data:r,fetchNextPage:a,hasNextPage:t,isFetchingNextPage:i}=Tu(n),o=r.pages.flatMap(m=>m.sessions),l=In(dy),{config:u}=kt(),p=qI({from:"/projects/$projectId/session"}).tab??"sessions",d=e==="",g=[...o].sort((m,f)=>{const h=l.find(D=>D.sessionId===m.id),v=l.find(D=>D.sessionId===f.id),S=h?.status,E=v?.status,y=D=>D==="running"?0:D==="paused"?1:2,w=y(S),I=y(E);if(w!==I)return w-I;const b=m.lastModifiedAt?new Date(m.lastModifiedAt).getTime():0;return(f.lastModifiedAt?new Date(f.lastModifiedAt).getTime():0)-b});return s.jsxs("div",{className:"h-full flex flex-col",children:[s.jsxs("div",{className:"border-b border-sidebar-border p-4",children:[s.jsx("div",{className:"flex items-center justify-between mb-2",children:s.jsx("h2",{className:"font-semibold text-lg",children:s.jsx(R,{id:"sessions.title"})})}),s.jsxs("p",{className:"text-xs text-sidebar-foreground/70",children:[o.length," ",s.jsx(R,{id:"sessions.total"})]})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto p-2 space-y-0.5",children:[s.jsx(An,{to:"/projects/$projectId/session",params:{projectId:n},search:{tab:p},className:ce("block rounded-lg p-2.5 transition-all duration-200 border-2 border-dashed border-sidebar-border/60 hover:border-blue-400/80 hover:bg-blue-50/50 dark:hover:bg-blue-950/40 bg-sidebar/10",d&&"bg-blue-100 dark:bg-blue-900/40 border-blue-400 dark:border-blue-500 shadow-sm"),children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-primary/10 text-primary",children:s.jsx(Iu,{className:"w-4 h-4"})}),s.jsx("div",{className:"space-y-0.5",children:s.jsx("p",{className:"text-sm font-semibold text-sidebar-foreground",children:s.jsx(R,{id:"chat.modal.title"})})})]})}),g.map(m=>{const f=m.id===e,h=m.meta.firstUserMessage!==null?Fy(m.meta.firstUserMessage):m.id,v=l.find(y=>y.sessionId===m.id),S=v?.status==="running",E=v?.status==="paused";return s.jsx(An,{to:"/projects/$projectId/session",params:{projectId:n},search:{tab:p,sessionId:m.id},className:ce("block rounded-lg p-2.5 transition-all duration-200 hover:bg-blue-50/60 dark:hover:bg-blue-950/40 hover:border-blue-300/60 dark:hover:border-blue-700/60 hover:shadow-sm border border-sidebar-border/40 bg-sidebar/30",f&&"bg-blue-100 dark:bg-blue-900/50 border-blue-400 dark:border-blue-600 shadow-md ring-1 ring-blue-200/50 dark:ring-blue-700/50 hover:bg-blue-100 dark:hover:bg-blue-900/50 hover:border-blue-400 dark:hover:border-blue-600"),children:s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsx("h3",{className:"text-sm font-medium line-clamp-2 leading-tight text-sidebar-foreground flex-1",children:h}),(S||E)&&s.jsx(pe,{variant:S?"default":"secondary",className:ce("text-xs",S&&"bg-green-500 text-white",E&&"bg-yellow-500 text-white"),children:S?s.jsx(R,{id:"session.status.running"}):s.jsx(R,{id:"session.status.paused"})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3 text-xs text-sidebar-foreground/70",children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(pn,{className:"w-3 h-3"}),s.jsx("span",{children:m.meta.messageCount})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(bT,{className:"w-3 h-3"}),s.jsxs("span",{children:["$",m.meta.cost.totalUsd.toFixed(2)]})]})]}),m.lastModifiedAt&&s.jsx("span",{className:"text-xs text-sidebar-foreground/60",children:Nu(m.lastModifiedAt,{locale:u.locale,target:"time"})})]})]})},m.id)}),t&&a&&s.jsx("div",{className:"p-2",children:s.jsx(ne,{onClick:()=>a(),disabled:i,variant:"outline",size:"sm",className:"w-full",children:i?s.jsx(R,{id:"common.loading"}):s.jsx(R,{id:"sessions.load.more"})})})]})]})},Tz=({currentSessionId:e,projectId:n,isOpen:r,onClose:a})=>{const{i18n:t}=Ke(),[i,o]=C.useState("sessions"),[l,u]=C.useState(!1);C.useEffect(()=>{u(!0)},[]),C.useEffect(()=>{const g=m=>{m.key==="Escape"&&a()};return r&&(document.addEventListener("keydown",g),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",g),document.body.style.overflow=""}},[r,a]);const c=g=>{o(g)},p=g=>{g.target===g.currentTarget&&a()},d=()=>{switch(i){case"sessions":return s.jsx(ES,{currentSessionId:e,projectId:n,isMobile:!0});case"mcp":return s.jsx(SS,{projectId:n});case"settings":return s.jsx("div",{className:"h-full flex flex-col",children:s.jsx(C.Suspense,{fallback:s.jsx("div",{className:"flex-1 flex items-center justify-center p-4",children:s.jsx("div",{className:"text-sm text-sidebar-foreground/70",children:s.jsx(R,{id:"settings.loading"})})}),children:s.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-6",children:[s.jsxs("div",{className:"space-y-4",children:[s.jsx("h3",{className:"font-medium text-sm text-sidebar-foreground",children:s.jsx(R,{id:"settings.session.display"})}),s.jsx(aT,{openingProjectId:n})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsx("h3",{className:"font-medium text-sm text-sidebar-foreground",children:s.jsx(R,{id:"settings.notifications"})}),s.jsx(iT,{})]})]})})});case"system-info":return s.jsx(rT,{});default:return null}};return l?GI.createPortal(s.jsxs("div",{className:ce("fixed inset-0 z-50 transition-all duration-300 ease-out md:hidden",r?"visible opacity-100":"invisible opacity-0 pointer-events-none"),children:[s.jsx("button",{type:"button",className:"absolute inset-0 bg-black/50 backdrop-blur-sm cursor-default",onClick:p,onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&a()},"aria-label":t._("Close sidebar")}),s.jsxs("div",{className:ce("absolute left-0 top-0 h-full w-80 max-w-[85vw] bg-sidebar text-sidebar-foreground transition-transform duration-300 ease-out flex",r?"translate-x-0":"-translate-x-full"),children:[s.jsx("div",{className:"w-12 flex flex-col border-r border-sidebar-border bg-sidebar/50",children:s.jsxs(Ey,{children:[s.jsxs(Ye,{children:[s.jsx(Ze,{asChild:!0,children:s.jsx(An,{to:"/projects",className:"w-12 h-12 flex items-center justify-center border-b border-sidebar-border hover:bg-sidebar-accent transition-colors",children:s.jsx(xy,{className:"w-4 h-4 text-sidebar-foreground/70"})})}),s.jsx(Xe,{side:"right",children:s.jsx("p",{children:s.jsx(R,{id:"sidebar.back.to.projects"})})})]}),s.jsxs("div",{className:"flex flex-col p-2 space-y-1",children:[s.jsxs(Ye,{children:[s.jsx(Ze,{asChild:!0,children:s.jsx("button",{type:"button",onClick:()=>c("sessions"),className:ce("w-8 h-8 flex items-center justify-center rounded-md transition-colors","hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",i==="sessions"?"bg-sidebar-accent text-sidebar-accent-foreground shadow-sm":"text-sidebar-foreground/70"),"data-testid":"sessions-tab-button-mobile",children:s.jsx(pn,{className:"w-4 h-4"})})}),s.jsx(Xe,{side:"right",children:s.jsx("p",{children:s.jsx(R,{id:"sidebar.show.session.list"})})})]}),s.jsxs(Ye,{children:[s.jsx(Ze,{asChild:!0,children:s.jsx("button",{type:"button",onClick:()=>c("mcp"),className:ce("w-8 h-8 flex items-center justify-center rounded-md transition-colors","hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",i==="mcp"?"bg-sidebar-accent text-sidebar-accent-foreground shadow-sm":"text-sidebar-foreground/70"),"data-testid":"mcp-tab-button-mobile",children:s.jsx(wy,{className:"w-4 h-4"})})}),s.jsx(Xe,{side:"right",children:s.jsx("p",{children:s.jsx(R,{id:"sidebar.show.mcp.settings"})})})]}),s.jsxs(Ye,{children:[s.jsx(Ze,{asChild:!0,children:s.jsx("button",{type:"button",onClick:()=>c("settings"),className:ce("w-8 h-8 flex items-center justify-center rounded-md transition-colors","hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",i==="settings"?"bg-sidebar-accent text-sidebar-accent-foreground shadow-sm":"text-sidebar-foreground/70"),"data-testid":"settings-tab-button-mobile",children:s.jsx(nT,{className:"w-4 h-4"})})}),s.jsx(Xe,{side:"right",children:s.jsx(R,{id:"settings.tab.title"})})]}),s.jsxs(Ye,{children:[s.jsx(Ze,{asChild:!0,children:s.jsx("button",{type:"button",onClick:()=>c("system-info"),className:ce("w-8 h-8 flex items-center justify-center rounded-md transition-colors","hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",i==="system-info"?"bg-sidebar-accent text-sidebar-accent-foreground shadow-sm":"text-sidebar-foreground/70"),"data-testid":"system-info-tab-button-mobile",children:s.jsx(Sy,{className:"w-4 h-4"})})}),s.jsx(Xe,{side:"right",children:s.jsx(R,{id:"system.info.tab.title"})})]})]})]})}),s.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-sidebar-border bg-sidebar/80 backdrop-blur-sm",children:[s.jsx("h2",{className:"text-lg font-semibold capitalize",children:i}),s.jsx(ne,{variant:"ghost",size:"sm",onClick:a,className:"h-8 w-8 p-0 hover:bg-sidebar-accent/50",children:s.jsx(_u,{className:"w-4 h-4"})})]}),s.jsx("div",{className:"flex-1 overflow-hidden",children:d()})]})]})]}),document.body):null},xS=C.forwardRef(({className:e,checked:n,onCheckedChange:r,disabled:a,...t},i)=>{const o=l=>{r?.(l.target.checked),t.onChange?.(l)};return s.jsxs("label",{className:ce("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors","focus-within:outline-none focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2 focus-within:ring-offset-background",a&&"cursor-not-allowed opacity-50",n?"bg-primary":"bg-input",e),children:[s.jsx("input",{type:"checkbox",className:"sr-only",ref:i,checked:n,onChange:o,disabled:a,...t}),s.jsx("span",{className:ce("pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform",n?"translate-x-4":"translate-x-0")})]})});xS.displayName="Switch";const kS=[{value:0,labelKey:s.jsx(R,{id:"cron_builder.sunday"})},{value:1,labelKey:s.jsx(R,{id:"cron_builder.monday"})},{value:2,labelKey:s.jsx(R,{id:"cron_builder.tuesday"})},{value:3,labelKey:s.jsx(R,{id:"cron_builder.wednesday"})},{value:4,labelKey:s.jsx(R,{id:"cron_builder.thursday"})},{value:5,labelKey:s.jsx(R,{id:"cron_builder.friday"})},{value:6,labelKey:s.jsx(R,{id:"cron_builder.saturday"})}];function Az(e){const n=e.trim().split(/\s+/);if(n.length!==5)return null;const r=n[0],a=n[1],t=n[4];if(!r||!a||!t)return null;if(a==="*"&&r==="0")return{mode:"hourly",hour:0,minute:0,dayOfWeek:0};if(t==="*"&&a!=="*"){const i=Number.parseInt(a,10),o=Number.parseInt(r,10);if(!Number.isNaN(i)&&!Number.isNaN(o))return{mode:"daily",hour:i,minute:o,dayOfWeek:0}}if(t!=="*"&&a!=="*"){const i=Number.parseInt(a,10),o=Number.parseInt(r,10),l=Number.parseInt(t,10);if(!Number.isNaN(i)&&!Number.isNaN(o)&&!Number.isNaN(l))return{mode:"weekly",hour:i,minute:o,dayOfWeek:l}}return{mode:"custom",hour:0,minute:0,dayOfWeek:0}}function cb(e,n,r,a){switch(e){case"hourly":return"0 * * * *";case"daily":return`${r} ${n} * * *`;case"weekly":return`${r} ${n} * * ${a}`;case"custom":return"0 0 * * *"}}function Rz(e){const n=e.trim().split(/\s+/);if(n.length!==5)return!1;const r=n[0],a=n[1],t=n[2],i=n[3],o=n[4];if(!r||!a||!t||!i||!o)return!1;const l=(u,c,p)=>{if(u==="*")return!0;const d=Number.parseInt(u,10);return!Number.isNaN(d)&&d>=c&&d<=p};return l(r,0,59)&&(a==="*"||l(a,0,23))&&(t==="*"||l(t,1,31))&&(i==="*"||l(i,1,12))&&(o==="*"||l(o,0,6))}function Cz(e){const n=e.trim().split(/\s+/);if(n.length!==5)return"Invalid cron expression";const r=n[0],a=n[1],t=n[4];if(!r||!a||!t)return"Invalid cron expression";if(a==="*")return`Every hour at ${r} minute(s)`;const i=`${a.padStart(2,"0")}:${r.padStart(2,"0")}`;if(t==="*")return`Every day at ${i}`;const o=Number.parseInt(t,10),l=kS.find(u=>u.value===o);return s.jsxs(s.Fragment,{children:["Every ",l?l.labelKey:"unknown"," at ",i]})}function Oz({value:e,onChange:n}){const r=Az(e),[a,t]=C.useState(r?.mode||"daily"),[i,o]=C.useState(r?.hour||9),[l,u]=C.useState(r?.minute||0),[c,p]=C.useState(r?.dayOfWeek||1),[d,g]=C.useState(e),[m,f]=C.useState(null);C.useEffect(()=>{if(a==="custom")Rz(d)?(n(d),f(null)):f("Invalid cron expression");else{const v=cb(a,i,l,c);n(v),g(v),f(null)}},[a,i,l,c,d,n]);const h=v=>{if(t(v),v!=="custom"){const S=cb(v,i,l,c);g(S)}};return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ie,{children:s.jsx(R,{id:"cron_builder.schedule_type"})}),s.jsxs(Ot,{value:a,onValueChange:h,children:[s.jsx(Dt,{children:s.jsx(Lt,{})}),s.jsxs($t,{children:[s.jsx(Ve,{value:"hourly",children:s.jsx(R,{id:"cron_builder.hourly"})}),s.jsx(Ve,{value:"daily",children:s.jsx(R,{id:"cron_builder.daily"})}),s.jsx(Ve,{value:"weekly",children:s.jsx(R,{id:"cron_builder.weekly"})}),s.jsx(Ve,{value:"custom",children:s.jsx(R,{id:"cron_builder.custom"})})]})]})]}),a==="daily"&&s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ie,{children:s.jsx(R,{id:"cron_builder.hour"})}),s.jsx(ht,{type:"number",min:"0",max:"23",value:i,onChange:v=>o(Number.parseInt(v.target.value,10))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ie,{children:s.jsx(R,{id:"cron_builder.minute"})}),s.jsx(ht,{type:"number",min:"0",max:"59",value:l,onChange:v=>u(Number.parseInt(v.target.value,10))})]})]}),a==="weekly"&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ie,{children:s.jsx(R,{id:"cron_builder.day_of_week"})}),s.jsxs(Ot,{value:String(c),onValueChange:v=>p(Number.parseInt(v,10)),children:[s.jsx(Dt,{children:s.jsx(Lt,{})}),s.jsx($t,{children:kS.map(v=>s.jsx(Ve,{value:String(v.value),children:v.labelKey},v.value))})]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ie,{children:s.jsx(R,{id:"cron_builder.hour"})}),s.jsx(ht,{type:"number",min:"0",max:"23",value:i,onChange:v=>o(Number.parseInt(v.target.value,10))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ie,{children:s.jsx(R,{id:"cron_builder.minute"})}),s.jsx(ht,{type:"number",min:"0",max:"59",value:l,onChange:v=>u(Number.parseInt(v.target.value,10))})]})]})]}),a==="custom"&&s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ie,{children:s.jsx(R,{id:"cron_builder.cron_expression"})}),s.jsx(ht,{value:d,onChange:v=>g(v.target.value),placeholder:"0 9 * * *"})]}),s.jsxs("div",{className:"rounded-md border p-3 text-sm",children:[s.jsx("div",{className:"font-medium mb-1",children:s.jsx(R,{id:"cron_builder.preview"})}),s.jsx("div",{className:"text-muted-foreground",children:m?s.jsx("span",{className:"text-destructive",children:m}):Cz(a==="custom"?d:e)}),s.jsxs("div",{className:"text-xs text-muted-foreground mt-2",children:[s.jsx(R,{id:"cron_builder.expression"}),":"," ",s.jsx("code",{children:a==="custom"?d:e})]})]})]})}const Dz=({open:e,onOpenChange:n,job:r,projectId:a,onSubmit:t,isSubmitting:i=!1})=>{const{_:o,i18n:l}=Ke(),[u,c]=C.useState(""),[p,d]=C.useState("cron"),[g,m]=C.useState("0 9 * * *"),[f,h]=C.useState(()=>{const _=new Date;return _.setHours(_.getHours()+1),_.toISOString().slice(0,16)}),[v,S]=C.useState(""),[E,y]=C.useState(!0),[w,I]=C.useState("skip"),b=xz();C.useEffect(()=>{if(r){if(c(r.name),d(r.schedule.type),r.schedule.type==="cron")m(r.schedule.expression),I(r.schedule.concurrencyPolicy);else if(r.schedule.type==="reserved"){const _=new Date(r.schedule.reservedExecutionTime),k=_.getFullYear(),A=String(_.getMonth()+1).padStart(2,"0"),j=String(_.getDate()).padStart(2,"0"),$=String(_.getHours()).padStart(2,"0"),P=String(_.getMinutes()).padStart(2,"0");h(`${k}-${A}-${j}T${$}:${P}`)}S(r.message.content),y(r.enabled)}else{c(""),d("cron"),m("0 9 * * *");const _=new Date;_.setHours(_.getHours()+1);const k=_.getFullYear(),A=String(_.getMonth()+1).padStart(2,"0"),j=String(_.getDate()).padStart(2,"0"),$=String(_.getHours()).padStart(2,"0"),P=String(_.getMinutes()).padStart(2,"0");h(`${k}-${A}-${j}T${$}:${P}`),S(""),y(!0),I("skip")}},[r]);const T=()=>{const _={name:u,schedule:p==="cron"?{type:"cron",expression:g,concurrencyPolicy:w}:{type:"reserved",reservedExecutionTime:(()=>{const k=f.match(/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})$/);if(!k)throw new Error("Invalid datetime format");const A=Number(k[1]),j=Number(k[2]),$=Number(k[3]),P=Number(k[4]),z=Number(k[5]);return new Date(A,j-1,$,P,z).toISOString()})()},message:{content:v,projectId:a,baseSessionId:null},enabled:E};t(_)},D=u.trim()!==""&&v.trim()!=="";return s.jsx(cn,{open:e,onOpenChange:n,children:s.jsxs(dn,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[s.jsxs(jn,{children:[s.jsx(Mn,{children:r?s.jsx(R,{id:"scheduler.dialog.title.edit"}):s.jsx(R,{id:"scheduler.dialog.title.create"})}),s.jsx(Pn,{children:s.jsx(R,{id:"scheduler.dialog.description"})})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-4",children:[s.jsxs("div",{className:"space-y-0.5",children:[s.jsx(Ie,{htmlFor:"enabled",className:"text-base font-semibold",children:s.jsx(R,{id:"scheduler.form.enabled"})}),s.jsx("p",{className:"text-sm text-muted-foreground",children:s.jsx(R,{id:"scheduler.form.enabled.description"})})]}),s.jsx(xS,{id:"enabled",checked:E,onCheckedChange:y,disabled:i})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ie,{htmlFor:"job-name",children:s.jsx(R,{id:"scheduler.form.name"})}),s.jsx(ht,{id:"job-name",value:u,onChange:_=>c(_.target.value),placeholder:o({id:"scheduler.form.name.placeholder",message:"e.g., Daily Report"}),disabled:i})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ie,{children:s.jsx(R,{id:"scheduler.form.schedule_type"})}),s.jsxs(Ot,{value:p,onValueChange:_=>d(_),disabled:i,children:[s.jsx(Dt,{children:s.jsx(Lt,{})}),s.jsxs($t,{children:[s.jsx(Ve,{value:"cron",children:s.jsx(R,{id:"scheduler.form.schedule_type.cron"})}),s.jsx(Ve,{value:"reserved",children:s.jsx(R,{id:"scheduler.form.schedule_type.reserved"})})]})]})]}),p==="cron"?s.jsx(Oz,{value:g,onChange:m}):s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ie,{htmlFor:"reserved-datetime",children:s.jsx(R,{id:"scheduler.form.reserved_time"})}),s.jsx(ht,{id:"reserved-datetime",type:"datetime-local",value:f,onChange:_=>h(_.target.value),disabled:i}),s.jsx("p",{className:"text-xs text-muted-foreground",children:s.jsx(R,{id:"scheduler.form.reserved_time.hint"})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ie,{htmlFor:"message-content",children:s.jsx(R,{id:"scheduler.form.message"})}),s.jsxs("div",{className:"relative",ref:b.containerRef,children:[s.jsx(oc,{ref:b.textareaRef,id:"message-content",value:v,onChange:_=>b.handleChange(_.target.value,S),onKeyDown:_=>b.handleKeyDown(_),placeholder:l._({id:"scheduler.form.message.placeholder",message:"Type message to send to Claude Code... (/ for commands, @ for files)"}),rows:4,disabled:i,className:"resize-none","aria-label":l._({id:"scheduler.form.message.aria_label",message:"Message input with completion support (/ for commands, @ for files)"}),"aria-expanded":v.startsWith("/")||v.includes("@"),"aria-haspopup":"listbox",role:"combobox","aria-autocomplete":"list"}),s.jsx(bS,{projectId:a,message:v,commandCompletionRef:b.commandCompletionRef,fileCompletionRef:b.fileCompletionRef,handleCommandSelect:_=>b.handleCommandSelect(_,S),handleFileSelect:_=>b.handleFileSelect(_,S),cursorPosition:b.cursorPosition})]}),s.jsx("p",{className:"text-xs text-muted-foreground",children:s.jsx(R,{id:"scheduler.form.message.hint"})})]}),p==="cron"&&s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ie,{children:s.jsx(R,{id:"scheduler.form.concurrency_policy"})}),s.jsxs(Ot,{value:w,onValueChange:_=>I(_),disabled:i,children:[s.jsx(Dt,{children:s.jsx(Lt,{})}),s.jsxs($t,{children:[s.jsx(Ve,{value:"skip",children:s.jsx(R,{id:"scheduler.form.concurrency_policy.skip"})}),s.jsx(Ve,{value:"run",children:s.jsx(R,{id:"scheduler.form.concurrency_policy.run"})})]})]})]})]}),s.jsxs(fy,{children:[s.jsx(ne,{variant:"outline",onClick:()=>n(!1),disabled:i,children:s.jsx(R,{id:"common.cancel"})}),s.jsx(ne,{onClick:T,disabled:!D||i,children:i?s.jsx(R,{id:"common.saving"}):r?s.jsx(R,{id:"common.update"}):s.jsx(R,{id:"common.create"})})]})]})})},Lz=({projectId:e,sessionId:n})=>{const{i18n:r}=Ke(),{data:a,isLoading:t,isFetching:i,error:o,refetch:l}=lz(),u=gS(),c=uz(),p=cz(),[d,g]=C.useState(!1),[m,f]=C.useState(null),[h,v]=C.useState(!1),[S,E]=C.useState(null),y=k=>{u.mutate(k,{onSuccess:()=>{de.success(r._({id:"scheduler.job.created",message:"Job created successfully"})),g(!1)},onError:A=>{de.error(r._({id:"scheduler.job.create_failed",message:"Failed to create job"}),{description:A.message})}})},w=k=>{m&&c.mutate({id:m.id,updates:k},{onSuccess:()=>{de.success(r._({id:"scheduler.job.updated",message:"Job updated successfully"})),g(!1),f(null)},onError:A=>{de.error(r._({id:"scheduler.job.update_failed",message:"Failed to update job"}),{description:A.message})}})},I=()=>{S&&p.mutate(S,{onSuccess:()=>{de.success(r._({id:"scheduler.job.deleted",message:"Job deleted successfully"})),v(!1),E(null)},onError:k=>{de.error(r._({id:"scheduler.job.delete_failed",message:"Failed to delete job"}),{description:k.message})}})},b=k=>{f(k),g(!0)},T=k=>{E(k),v(!0)},D=k=>k.schedule.type==="cron"?`Cron: ${k.schedule.expression}`:k.schedule.type==="reserved"?`Reserved: ${new Date(k.schedule.reservedExecutionTime).toLocaleString()}`:"Unknown schedule type",_=k=>k?new Date(k).toLocaleString():"Never";return s.jsxs("div",{className:"flex flex-col h-full",children:[s.jsx("div",{className:"p-3 border-b border-sidebar-border",children:s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsx("h2",{className:"text-sm font-semibold text-sidebar-foreground",children:s.jsx(R,{id:"scheduler.title"})}),s.jsxs("div",{className:"flex gap-1",children:[s.jsx(ne,{onClick:()=>l(),variant:"ghost",size:"sm",className:"h-7 w-7 p-0",disabled:t||i,title:r._({id:"common.reload",message:"Reload"}),children:s.jsx(gy,{className:`w-3 h-3 ${t||i?"animate-spin":""}`})}),s.jsx(ne,{onClick:()=>{f(null),g(!0)},variant:"ghost",size:"sm",className:"h-7 w-7 p-0",title:r._({id:"scheduler.create_job",message:"Create Job"}),children:s.jsx(Iu,{className:"w-3 h-3"})})]})]})}),s.jsxs("div",{className:"flex-1 overflow-auto p-3",children:[t&&s.jsx("div",{className:"flex items-center justify-center h-32",children:s.jsx("div",{className:"text-sm text-muted-foreground",children:s.jsx(an,{})})}),o&&s.jsx("div",{className:"text-sm text-red-500",children:s.jsx(R,{id:"scheduler.error.load_failed",values:{error:o.message}})}),a&&a.length===0&&s.jsx("div",{className:"text-sm text-muted-foreground text-center py-8",children:s.jsx(R,{id:"scheduler.no_jobs"})}),a&&a.length>0&&s.jsx("div",{className:"space-y-3",children:a.map(k=>s.jsxs("div",{className:"p-3 bg-sidebar-accent/50 rounded-md border border-sidebar-border",children:[s.jsxs("div",{className:"flex items-start justify-between mb-2",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("h3",{className:"text-sm font-medium text-sidebar-foreground truncate",children:k.name}),s.jsx(pe,{variant:k.enabled?"default":"secondary",className:"text-xs",children:k.enabled?s.jsx(R,{id:"scheduler.status.enabled"}):s.jsx(R,{id:"scheduler.status.disabled"})})]}),s.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:D(k)})]}),s.jsxs("div",{className:"flex gap-1",children:[s.jsx(ne,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>b(k),children:s.jsx(YT,{className:"w-3 h-3"})}),s.jsx(ne,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 text-destructive hover:text-destructive",onClick:()=>T(k.id),children:s.jsx(JT,{className:"w-3 h-3"})})]})]}),k.lastRunAt&&s.jsx("div",{className:"text-xs text-muted-foreground mt-2 pt-2 border-t border-sidebar-border",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("span",{children:[s.jsx(R,{id:"scheduler.last_run"}),s.jsx("span",{children:_(k.lastRunAt)})]}),k.lastRunStatus&&s.jsx(pe,{variant:k.lastRunStatus==="success"?"default":"destructive",className:"text-xs",children:k.lastRunStatus})]})})]},k.id))})]}),s.jsx(Dz,{open:d,onOpenChange:k=>{g(k),k||f(null)},job:m,projectId:e,currentSessionId:n,onSubmit:m?w:y,isSubmitting:u.isPending||c.isPending}),s.jsx(cn,{open:h,onOpenChange:v,children:s.jsxs(dn,{children:[s.jsxs(jn,{children:[s.jsx(Mn,{children:s.jsx(R,{id:"scheduler.delete_dialog.title"})}),s.jsx(Pn,{children:s.jsx(R,{id:"scheduler.delete_dialog.description"})})]}),s.jsxs(fy,{children:[s.jsx(ne,{variant:"outline",onClick:()=>{v(!1),E(null)},disabled:p.isPending,children:s.jsx(R,{id:"common.cancel"})}),s.jsx(ne,{variant:"destructive",onClick:I,disabled:p.isPending,children:p.isPending?s.jsx(R,{id:"common.deleting"}):s.jsx(R,{id:"common.delete"})})]})]})})]})},$z=({currentSessionId:e,projectId:n,className:r,isMobileOpen:a=!1,onMobileOpenChange:t,initialTab:i})=>{const o=e??"",l=C.useMemo(()=>[{id:"sessions",icon:pn,title:s.jsx(R,{id:"sidebar.show.session.list"}),content:s.jsx(C.Suspense,{fallback:s.jsx(an,{}),children:s.jsx(ES,{currentSessionId:o,projectId:n})})},{id:"mcp",icon:wy,title:s.jsx(R,{id:"sidebar.show.mcp.settings"}),content:s.jsx(SS,{projectId:n})},{id:"scheduler",icon:fT,title:s.jsx(R,{id:"sidebar.show.scheduler.jobs"}),content:s.jsx(Lz,{projectId:n,sessionId:o})}],[o,n]);return s.jsxs(s.Fragment,{children:[s.jsx("div",{className:ce("hidden md:flex h-full",r),children:s.jsx(oT,{projectId:n,additionalTabs:l,defaultActiveTab:i,headerButton:s.jsx(Ey,{children:s.jsxs(Ye,{children:[s.jsx(Ze,{asChild:!0,children:s.jsx(An,{to:"/projects",className:"w-12 h-12 flex items-center justify-center hover:bg-sidebar-accent transition-colors",children:s.jsx(xy,{className:"w-4 h-4 text-sidebar-foreground/70"})})}),s.jsx(Xe,{side:"right",children:s.jsx("p",{children:s.jsx(R,{id:"sidebar.back.to.projects"})})})]})})})}),s.jsx(Tz,{currentSessionId:o,projectId:n,isOpen:a,onClose:()=>t?.(!1)})]})},jz=({projectId:e,sessionId:n,isMobileSidebarOpen:r,setIsMobileSidebarOpen:a,tab:t})=>{const{data:i}=Tu(e),{data:o}=Au(e),l=i.pages[0];if(l===void 0)return null;const u=l.project,c=u.meta.projectPath??u.claudeProjectPath,p=o?.success?o.data.currentBranch?.name:void 0;return s.jsxs(s.Fragment,{children:[s.jsx(C.Suspense,{fallback:s.jsx(an,{}),children:s.jsx($z,{currentSessionId:n,projectId:e,isMobileOpen:r,onMobileOpenChange:a,initialTab:t})}),s.jsx(C.Suspense,{fallback:s.jsx(an,{}),children:s.jsx(Nz,{projectId:e,sessionId:n,setIsMobileSidebarOpen:a,projectPath:c,currentBranch:p,revisionsData:o,projectName:u.meta.projectName??"Untitled Project"})})]})},Mz=({projectId:e,sessionId:n,tab:r})=>{const[a,t]=C.useState(!1),{previewUrl:i,previewWidth:o}=wu(),l=i?100-o:100;return s.jsx("div",{className:"flex h-screen max-h-screen overflow-hidden transition-all duration-200",style:{width:`${l}%`},children:s.jsx(jz,{projectId:e,sessionId:n,tab:r,isMobileSidebarOpen:a,setIsMobileSidebarOpen:t})})};function zz(){const e=Sc.useParams(),n=Sc.useSearch(),{data:r}=Tu(e.projectId),a=r.pages[0]?.project.meta.projectName,{sessionId:t,tab:i}=n,o=a?`${a} - Claude Code Viewer`:"Claude Code Viewer";return s.jsxs(sT,{children:[s.jsx(HI,{children:s.jsx("title",{children:o})}),s.jsx(Mz,{projectId:e.projectId,sessionId:t,tab:i})]})}export{zz as component};
|