@kimuson/claude-code-viewer 0.6.1-beta.3 → 0.7.0

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.
@@ -1,8 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{d as t,f as n,n as r,t as i}from"./markdown-parser-vendor-D9j1a-bm.js";import{A as a,E as o,F as s,I as c,L as l,M as u,N as d,O as f,P as p,S as m,V as h,W as g,_,a as v,b as y,d as b,f as x,h as S,i as C,j as w,k as T,l as E,m as D,n as O,o as k,ot as A,p as j,r as M,st as N,u as P,v as ee,w as te,y as ne,z as re}from"./AuthProvider-BKc7q7ka.js";import{$ as ie,A as F,B as ae,C as oe,D as se,E as ce,F as le,G as ue,H as I,I as de,J as fe,K as pe,L as me,N as he,O as L,P as ge,Q as _e,R as ve,S as ye,T as be,U as xe,V as Se,W as R,X as Ce,Y as we,Z as Te,_ as Ee,a as De,b as Oe,c as ke,d as Ae,et as je,f as Me,g as Ne,h as Pe,i as Fe,j as Ie,k as Le,l as Re,m as ze,n as z,o as Be,p as Ve,q as He,s as Ue,u as We,v as Ge,w as Ke,x as qe,y as Je,z as Ye}from"./dist-DiGJ7VFi.js";import{n as B,r as Xe}from"./dist-CG2L4mx5.js";import{t as V}from"./createLucideIcon-BL_meogc.js";import{S as Ze,_ as Qe,a as $e,b as et,c as tt,d as nt,f as rt,g as it,h as at,i as ot,l as st,m as ct,n as lt,o as ut,p as dt,r as ft,s as pt,t as mt,u as ht,v as gt,x as _t,y as vt}from"./ProtectedRoute-DtqWc34B.js";import{t as yt}from"./eye-SsvAY8oF.js";import{a as bt,c as xt,d as St,f as Ct,i as wt,l as Tt,n as Et,o as H,r as Dt,s as U,t as Ot,u as kt}from"./card-DGrqtTaC.js";import{t as At}from"./input-B_6IT1CP.js";import{a as jt,c as Mt,d as Nt,f as Pt,h as Ft,i as It,l as Lt,m as Rt,n as zt,o as Bt,r as Vt,s as Ht,t as Ut,u as Wt}from"./index-CdgCTIqU.js";import{t as W}from"./label-Cw6sZ5kQ.js";import{n as Gt,t as Kt}from"./xterm-vendor-DRG2K165.js";import{_ as qt,a as Jt,c as Yt,d as Xt,f as Zt,g as Qt,h as $t,i as en,l as tn,m as nn,n as rn,o as an,p as on,r as sn,s as cn,t as ln,u as un,v as dn,y as G}from"./syntax-highlighter-vendor-CwGXx8v4.js";var fn=V(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),pn=V(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),mn=V(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),hn=V(`bell-off`,[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M17 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 .258-1.742`,key:`178tsu`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M8.668 3.01A6 6 0 0 1 18 8c0 2.687.77 4.653 1.707 6.05`,key:`1hqiys`}]]),gn=V(`bell-ring`,[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M22 8c0-2.3-.8-4.3-2-6`,key:`5bb3ad`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}],[`path`,{d:`M4 2C2.8 3.7 2 5.7 2 8`,key:`tap9e0`}]]),_n=V(`bot`,[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]),vn=V(`calendar-clock`,[[`path`,{d:`M16 14v2.2l1.6 1`,key:`fo4ql5`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`path`,{d:`M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5`,key:`1osxxc`}],[`path`,{d:`M3 10h5`,key:`r794hk`}],[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`circle`,{cx:`16`,cy:`16`,r:`6`,key:`qoo3c4`}]]),K=V(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),yn=V(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),bn=V(`chevron-up`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]),xn=V(`chevrons-down`,[[`path`,{d:`m7 6 5 5 5-5`,key:`1lc07p`}],[`path`,{d:`m7 13 5 5 5-5`,key:`1d48rs`}]]),Sn=V(`chevrons-up-down`,[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]),Cn=V(`chevrons-up`,[[`path`,{d:`m17 11-5-5-5 5`,key:`e8nh98`}],[`path`,{d:`m17 18-5-5-5 5`,key:`2avn1x`}]]),wn=V(`circle-check`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),Tn=V(`circle-dot`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}]]),En=V(`circle-question-mark`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),Dn=V(`circle-x`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]]),On=V(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),kn=V(`clipboard-check`,[[`rect`,{width:`8`,height:`4`,x:`8`,y:`2`,rx:`1`,ry:`1`,key:`tgr4d6`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`,key:`116196`}],[`path`,{d:`m9 14 2 2 4-4`,key:`df797q`}]]),An=V(`clipboard-paste`,[[`path`,{d:`M11 14h10`,key:`1w8e9d`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v1.344`,key:`1e62lh`}],[`path`,{d:`m17 18 4-4-4-4`,key:`z2g111`}],[`path`,{d:`M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 1.793-1.113`,key:`bjbb7m`}],[`rect`,{x:`8`,y:`2`,width:`8`,height:`4`,rx:`1`,key:`ublpy`}]]),jn=V(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]),Mn=V(`code`,[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]),Nn=V(`copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),Pn=V(`download`,[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]),Fn=V(`ellipsis-vertical`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]]),In=V(`external-link`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),Ln=V(`file-code`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 12.5 8 15l2 2.5`,key:`1tg20x`}],[`path`,{d:`m14 12.5 2 2.5-2 2.5`,key:`yinavb`}]]),Rn=V(`file-text`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),zn=V(`file`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}]]),Bn=V(`funnel`,[[`path`,{d:`M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z`,key:`sc7q7i`}]]),Vn=V(`git-branch`,[[`path`,{d:`M15 6a9 9 0 0 0-9 9V3`,key:`1cii5b`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}]]),Hn=V(`git-compare`,[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M13 6h3a2 2 0 0 1 2 2v7`,key:`1yeb86`}],[`path`,{d:`M11 18H8a2 2 0 0 1-2-2V9`,key:`19pyzm`}]]),Un=V(`git-pull-request`,[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M13 6h3a2 2 0 0 1 2 2v7`,key:`1yeb86`}],[`line`,{x1:`6`,x2:`6`,y1:`9`,y2:`21`,key:`rroup`}]]),Wn=V(`globe`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]),Gn=V(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),Kn=V(`info`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]),qn=V(`lightbulb`,[[`path`,{d:`M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5`,key:`1gvzjb`}],[`path`,{d:`M9 18h6`,key:`x1upvd`}],[`path`,{d:`M10 22h4`,key:`ceow96`}]]),Jn=V(`list-todo`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`rect`,{x:`3`,y:`4`,width:`6`,height:`6`,rx:`1`,key:`cif1o7`}]]),Yn=V(`loader`,[[`path`,{d:`M12 2v4`,key:`3427ic`}],[`path`,{d:`m16.2 7.8 2.9-2.9`,key:`r700ao`}],[`path`,{d:`M18 12h4`,key:`wj9ykh`}],[`path`,{d:`m16.2 16.2 2.9 2.9`,key:`1bxg5t`}],[`path`,{d:`M12 18v4`,key:`jadmvz`}],[`path`,{d:`m4.9 19.1 2.9-2.9`,key:`bwix9q`}],[`path`,{d:`M2 12h4`,key:`j09sii`}],[`path`,{d:`m4.9 4.9 2.9 2.9`,key:`giyufr`}]]),Xn=V(`log-out`,[[`path`,{d:`m16 17 5-5-5-5`,key:`1bji2h`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}]]),Zn=V(`menu`,[[`path`,{d:`M4 5h16`,key:`1tepv9`}],[`path`,{d:`M4 12h16`,key:`1lakjw`}],[`path`,{d:`M4 19h16`,key:`1djgab`}]]),Qn=V(`message-square-plus`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M12 8v6`,key:`1ib9pf`}],[`path`,{d:`M9 11h6`,key:`1fldmi`}]]),$n=V(`message-square-text`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M7 11h10`,key:`1twpyw`}],[`path`,{d:`M7 15h6`,key:`d9of3u`}],[`path`,{d:`M7 7h8`,key:`af5zfr`}]]),er=V(`mic-off`,[[`path`,{d:`M12 19v3`,key:`npa21l`}],[`path`,{d:`M15 9.34V5a3 3 0 0 0-5.68-1.33`,key:`1gzdoj`}],[`path`,{d:`M16.95 16.95A7 7 0 0 1 5 12v-2`,key:`cqa7eg`}],[`path`,{d:`M18.89 13.23A7 7 0 0 0 19 12v-2`,key:`16hl24`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M9 9v3a3 3 0 0 0 5.12 2.12`,key:`r2i35w`}]]),tr=V(`mic`,[[`path`,{d:`M12 19v3`,key:`npa21l`}],[`path`,{d:`M19 10v2a7 7 0 0 1-14 0v-2`,key:`1vc78b`}],[`rect`,{x:`9`,y:`2`,width:`6`,height:`13`,rx:`3`,key:`s6n7sd`}]]),nr=V(`panel-bottom-close`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 15h18`,key:`5xshup`}],[`path`,{d:`m15 8-3 3-3-3`,key:`1oxy1z`}]]),rr=V(`panel-bottom`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 15h18`,key:`5xshup`}]]),ir=V(`panel-left`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}]]),ar=V(`panel-right`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]]),or=V(`paperclip`,[[`path`,{d:`m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551`,key:`1miecu`}]]),sr=V(`pause`,[[`rect`,{x:`14`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`kaeet6`}],[`rect`,{x:`5`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`1wsw3u`}]]),cr=V(`plug`,[[`path`,{d:`M12 22v-5`,key:`1ega77`}],[`path`,{d:`M15 8V2`,key:`18g5xt`}],[`path`,{d:`M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z`,key:`1xoxul`}],[`path`,{d:`M9 8V2`,key:`14iosj`}]]),lr=V(`refresh-ccw`,[[`path`,{d:`M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`14sxne`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16`,key:`1hlbsb`}],[`path`,{d:`M16 16h5v5`,key:`ccwih5`}]]),ur=V(`rocket`,[[`path`,{d:`M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5`,key:`qeys4`}],[`path`,{d:`M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09`,key:`u4xsad`}],[`path`,{d:`M9 12a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.4 22.4 0 0 1-4 2z`,key:`676m9`}],[`path`,{d:`M9 12H4s.55-3.03 2-4c1.62-1.08 5 .05 5 .05`,key:`92ym6u`}]]),dr=V(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),fr=V(`send-horizontal`,[[`path`,{d:`M3.714 3.048a.498.498 0 0 0-.683.627l2.843 7.627a2 2 0 0 1 0 1.396l-2.842 7.627a.498.498 0 0 0 .682.627l18-8.5a.5.5 0 0 0 0-.904z`,key:`117uat`}],[`path`,{d:`M6 12h16`,key:`s4cdu5`}]]),pr=V(`send`,[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]),mr=V(`settings`,[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`,key:`1i5ecw`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),hr=V(`shield-alert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),gr=V(`square-pen`,[[`path`,{d:`M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7`,key:`1m0v6g`}],[`path`,{d:`M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z`,key:`ohrbg2`}]]),_r=V(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]),vr=V(`trash-2`,[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]),yr=V(`trash`,[[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]),br=V(`triangle-alert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),xr=V(`wrench`,[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]),Sr=class extends h{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){super.setOptions({...e,behavior:Pt()})}getOptimisticResult(e){return e.behavior=Pt(),super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`forward`}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`backward`}}})}createResult(e,t){let{state:n}=e,r=super.createResult(e,t),{isFetching:i,isRefetching:a,isError:o,isRefetchError:s}=r,c=n.fetchMeta?.fetchMore?.direction,l=o&&c===`forward`,u=i&&c===`forward`,d=o&&c===`backward`,f=i&&c===`backward`;return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:Wt(t,n.data),hasPreviousPage:Nt(t,n.data),isFetchNextPageError:l,isFetchingNextPage:u,isFetchPreviousPageError:d,isFetchingPreviousPage:f,isRefetchError:s&&!l&&!d,isRefetching:a&&!u&&!f}}};function Cr(e,t){return c({...e,enabled:!0,suspense:!0,throwOnError:l},Sr,t)}var q=e(n(),1);function wr(e,t){let n=re(t),r=n.getQueryCache();return q.useSyncExternalStore(q.useCallback(e=>r.subscribe(g.batchCalls(e)),[r]),()=>n.isFetching(e),()=>n.isFetching(e))}var Tr=e(je(),1),J=t();function Er(e){let t=e+`CollectionProvider`,[n,r]=Le(t),[i,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=e=>{let{scope:t,children:n}=e,r=q.useRef(null),a=q.useRef(new Map).current;return(0,J.jsx)(i,{scope:t,itemMap:a,collectionRef:r,children:n})};o.displayName=t;let s=e+`CollectionSlot`,c=Ie(s),l=q.forwardRef((e,t)=>{let{scope:n,children:r}=e;return(0,J.jsx)(c,{ref:Ct(t,a(s,n).collectionRef),children:r})});l.displayName=s;let u=e+`CollectionItemSlot`,d=`data-radix-collection-item`,f=Ie(u),p=q.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=q.useRef(null),s=Ct(t,o),c=a(u,n);return q.useEffect(()=>(c.itemMap.set(o,{ref:o,...i}),()=>void c.itemMap.delete(o))),(0,J.jsx)(f,{[d]:``,ref:s,children:r})});p.displayName=u;function m(t){let n=a(e+`CollectionConsumer`,t);return q.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${d}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return[{Provider:o,Slot:l,ItemSlot:p},m,r]}var Dr=`Collapsible`,[Or,kr]=Le(Dr),[Ar,jr]=Or(Dr),Mr=q.forwardRef((e,t)=>{let{__scopeCollapsible:n,open:r,defaultOpen:i,disabled:a,onOpenChange:o,...s}=e,[c,l]=ce({prop:r,defaultProp:i??!1,onChange:o,caller:Dr});return(0,J.jsx)(Ar,{scope:n,disabled:a,contentId:Ke(),open:c,onOpenToggle:q.useCallback(()=>l(e=>!e),[l]),children:(0,J.jsx)(F.div,{"data-state":Rr(c),"data-disabled":a?``:void 0,...s,ref:t})})});Mr.displayName=Dr;var Nr=`CollapsibleTrigger`,Pr=q.forwardRef((e,t)=>{let{__scopeCollapsible:n,...r}=e,i=jr(Nr,n);return(0,J.jsx)(F.button,{type:`button`,"aria-controls":i.contentId,"aria-expanded":i.open||!1,"data-state":Rr(i.open),"data-disabled":i.disabled?``:void 0,disabled:i.disabled,...r,ref:t,onClick:L(e.onClick,i.onOpenToggle)})});Pr.displayName=Nr;var Fr=`CollapsibleContent`,Ir=q.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=jr(Fr,e.__scopeCollapsible);return(0,J.jsx)(be,{present:n||i.open,children:({present:e})=>(0,J.jsx)(Lr,{...r,ref:t,present:e})})});Ir.displayName=Fr;var Lr=q.forwardRef((e,t)=>{let{__scopeCollapsible:n,present:r,children:i,...a}=e,o=jr(Fr,n),[s,c]=q.useState(r),l=q.useRef(null),u=Ct(t,l),d=q.useRef(0),f=d.current,p=q.useRef(0),m=p.current,h=o.open||s,g=q.useRef(h),_=q.useRef(void 0);return q.useEffect(()=>{let e=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(e)},[]),se(()=>{let e=l.current;if(e){_.current=_.current||{transitionDuration:e.style.transitionDuration,animationName:e.style.animationName},e.style.transitionDuration=`0s`,e.style.animationName=`none`;let t=e.getBoundingClientRect();d.current=t.height,p.current=t.width,g.current||(e.style.transitionDuration=_.current.transitionDuration,e.style.animationName=_.current.animationName),c(r)}},[o.open,r]),(0,J.jsx)(F.div,{"data-state":Rr(o.open),"data-disabled":o.disabled?``:void 0,id:o.contentId,hidden:!h,...a,ref:u,style:{"--radix-collapsible-content-height":f?`${f}px`:void 0,"--radix-collapsible-content-width":m?`${m}px`:void 0,...e.style},children:h&&i})});function Rr(e){return e?`open`:`closed`}var zr=Mr,Br=q.createContext(void 0);function Vr(e){let t=q.useContext(Br);return e||t||`ltr`}var Hr=`rovingFocusGroup.onEntryFocus`,Ur={bubbles:!1,cancelable:!0},Wr=`RovingFocusGroup`,[Gr,Kr,qr]=Er(Wr),[Jr,Yr]=Le(Wr,[qr]),[Xr,Zr]=Jr(Wr),Qr=q.forwardRef((e,t)=>(0,J.jsx)(Gr.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,J.jsx)(Gr.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,J.jsx)($r,{...e,ref:t})})}));Qr.displayName=Wr;var $r=q.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:a,currentTabStopId:o,defaultCurrentTabStopId:s,onCurrentTabStopIdChange:c,onEntryFocus:l,preventScrollOnEntryFocus:u=!1,...d}=e,f=q.useRef(null),p=Ct(t,f),m=Vr(a),[h,g]=ce({prop:o,defaultProp:s??null,onChange:c,caller:Wr}),[_,v]=q.useState(!1),y=oe(l),b=Kr(n),x=q.useRef(!1),[S,C]=q.useState(0);return q.useEffect(()=>{let e=f.current;if(e)return e.addEventListener(Hr,y),()=>e.removeEventListener(Hr,y)},[y]),(0,J.jsx)(Xr,{scope:n,orientation:r,dir:m,loop:i,currentTabStopId:h,onItemFocus:q.useCallback(e=>g(e),[g]),onItemShiftTab:q.useCallback(()=>v(!0),[]),onFocusableItemAdd:q.useCallback(()=>C(e=>e+1),[]),onFocusableItemRemove:q.useCallback(()=>C(e=>e-1),[]),children:(0,J.jsx)(F.div,{tabIndex:_||S===0?-1:0,"data-orientation":r,...d,ref:p,style:{outline:`none`,...e.style},onMouseDown:L(e.onMouseDown,()=>{x.current=!0}),onFocus:L(e.onFocus,e=>{let t=!x.current;if(e.target===e.currentTarget&&t&&!_){let t=new CustomEvent(Hr,Ur);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=b().filter(e=>e.focusable);ai([e.find(e=>e.active),e.find(e=>e.id===h),...e].filter(Boolean).map(e=>e.ref.current),u)}}x.current=!1}),onBlur:L(e.onBlur,()=>v(!1))})})}),ei=`RovingFocusGroupItem`,ti=q.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,c=Ke(),l=a||c,u=Zr(ei,n),d=u.currentTabStopId===l,f=Kr(n),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:h}=u;return q.useEffect(()=>{if(r)return p(),()=>m()},[r,p,m]),(0,J.jsx)(Gr.ItemSlot,{scope:n,id:l,focusable:r,active:i,children:(0,J.jsx)(F.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...s,ref:t,onMouseDown:L(e.onMouseDown,e=>{r?u.onItemFocus(l):e.preventDefault()}),onFocus:L(e.onFocus,()=>u.onItemFocus(l)),onKeyDown:L(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){u.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=ii(e,u.orientation,u.dir);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=f().filter(e=>e.focusable).map(e=>e.ref.current);if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=u.loop?oi(n,r+1):n.slice(r+1)}setTimeout(()=>ai(n))}}),children:typeof o==`function`?o({isCurrentTabStop:d,hasTabStop:h!=null}):o})})});ti.displayName=ei;var ni={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function ri(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}function ii(e,t,n){let r=ri(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return ni[r]}function ai(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function oi(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var si=Qr,ci=ti;function li(e,[t,n]){return Math.min(n,Math.max(t,e))}var ui=[` `,`Enter`,`ArrowUp`,`ArrowDown`],di=[` `,`Enter`],fi=`Select`,[pi,mi,hi]=Er(fi),[gi,_i]=Le(fi,[hi,at]),vi=at(),[yi,bi]=gi(fi),[xi,Si]=gi(fi),Ci=e=>{let{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:a,value:o,defaultValue:s,onValueChange:c,dir:l,name:u,autoComplete:d,disabled:f,required:p,form:m}=e,h=vi(t),[g,_]=q.useState(null),[v,y]=q.useState(null),[b,x]=q.useState(!1),S=Vr(l),[C,w]=ce({prop:r,defaultProp:i??!1,onChange:a,caller:fi}),[T,E]=ce({prop:o,defaultProp:s,onChange:c,caller:fi}),D=q.useRef(null),O=g?m||!!g.closest(`form`):!0,[k,A]=q.useState(new Set),j=Array.from(k).map(e=>e.props.value).join(`;`);return(0,J.jsx)(ct,{...h,children:(0,J.jsxs)(yi,{required:p,scope:t,trigger:g,onTriggerChange:_,valueNode:v,onValueNodeChange:y,valueNodeHasChildren:b,onValueNodeHasChildrenChange:x,contentId:Ke(),value:T,onValueChange:E,open:C,onOpenChange:w,dir:S,triggerPointerDownPosRef:D,disabled:f,children:[(0,J.jsx)(pi.Provider,{scope:t,children:(0,J.jsx)(xi,{scope:e.__scopeSelect,onNativeOptionAdd:q.useCallback(e=>{A(t=>new Set(t).add(e))},[]),onNativeOptionRemove:q.useCallback(e=>{A(t=>{let n=new Set(t);return n.delete(e),n})},[]),children:n})}),O?(0,J.jsxs)(va,{"aria-hidden":!0,required:p,tabIndex:-1,name:u,autoComplete:d,value:T,onChange:e=>E(e.target.value),disabled:f,form:m,children:[T===void 0?(0,J.jsx)(`option`,{value:``}):null,Array.from(k)]},j):null]})})};Ci.displayName=fi;var wi=`SelectTrigger`,Ti=q.forwardRef((e,t)=>{let{__scopeSelect:n,disabled:r=!1,...i}=e,a=vi(n),o=bi(wi,n),s=o.disabled||r,c=Ct(t,o.onTriggerChange),l=mi(n),u=q.useRef(`touch`),[d,f,p]=ba(e=>{let t=l().filter(e=>!e.disabled),n=xa(t,e,t.find(e=>e.value===o.value));n!==void 0&&o.onValueChange(n.value)}),m=e=>{s||(o.onOpenChange(!0),p()),e&&(o.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})};return(0,J.jsx)(nt,{asChild:!0,...a,children:(0,J.jsx)(F.button,{type:`button`,role:`combobox`,"aria-controls":o.contentId,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":`none`,dir:o.dir,"data-state":o.open?`open`:`closed`,disabled:s,"data-disabled":s?``:void 0,"data-placeholder":ya(o.value)?``:void 0,...i,ref:c,onClick:L(i.onClick,e=>{e.currentTarget.focus(),u.current!==`mouse`&&m(e)}),onPointerDown:L(i.onPointerDown,e=>{u.current=e.pointerType;let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),e.button===0&&e.ctrlKey===!1&&e.pointerType===`mouse`&&(m(e),e.preventDefault())}),onKeyDown:L(i.onKeyDown,e=>{let t=d.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&f(e.key),!(t&&e.key===` `)&&ui.includes(e.key)&&(m(),e.preventDefault())})})})});Ti.displayName=wi;var Ei=`SelectValue`,Di=q.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,children:a,placeholder:o=``,...s}=e,c=bi(Ei,n),{onValueNodeHasChildrenChange:l}=c,u=a!==void 0,d=Ct(t,c.onValueNodeChange);return se(()=>{l(u)},[l,u]),(0,J.jsx)(F.span,{...s,ref:d,style:{pointerEvents:`none`},children:ya(c.value)?(0,J.jsx)(J.Fragment,{children:o}):a})});Di.displayName=Ei;var Oi=`SelectIcon`,ki=q.forwardRef((e,t)=>{let{__scopeSelect:n,children:r,...i}=e;return(0,J.jsx)(F.span,{"aria-hidden":!0,...i,ref:t,children:r||`▼`})});ki.displayName=Oi;var Ai=`SelectPortal`,ji=e=>(0,J.jsx)(Oe,{asChild:!0,...e});ji.displayName=Ai;var Mi=`SelectContent`,Ni=q.forwardRef((e,t)=>{let n=bi(Mi,e.__scopeSelect),[r,i]=q.useState();if(se(()=>{i(new DocumentFragment)},[]),!n.open){let t=r;return t?Tr.createPortal((0,J.jsx)(Fi,{scope:e.__scopeSelect,children:(0,J.jsx)(pi.Slot,{scope:e.__scopeSelect,children:(0,J.jsx)(`div`,{children:e.children})})}),t):null}return(0,J.jsx)(zi,{...e,ref:t})});Ni.displayName=Mi;var Pi=10,[Fi,Ii]=gi(Mi),Li=`SelectContentImpl`,Ri=Ie(`SelectContent.RemoveScroll`),zi=q.forwardRef((e,t)=>{let{__scopeSelect:n,position:r=`item-aligned`,onCloseAutoFocus:i,onEscapeKeyDown:a,onPointerDownOutside:o,side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g,..._}=e,v=bi(Mi,n),[y,b]=q.useState(null),[x,S]=q.useState(null),C=Ct(t,e=>b(e)),[w,T]=q.useState(null),[E,D]=q.useState(null),O=mi(n),[k,A]=q.useState(!1),j=q.useRef(!1);q.useEffect(()=>{if(y)return Ee(y)},[y]),Je();let M=q.useCallback(e=>{let[t,...n]=O().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(let n of e)if(n===i||(n?.scrollIntoView({block:`nearest`}),n===t&&x&&(x.scrollTop=0),n===r&&x&&(x.scrollTop=x.scrollHeight),n?.focus(),document.activeElement!==i))return},[O,x]),N=q.useCallback(()=>M([w,y]),[M,w,y]);q.useEffect(()=>{k&&N()},[k,N]);let{onOpenChange:P,triggerPointerDownPosRef:ee}=v;q.useEffect(()=>{if(y){let e={x:0,y:0},t=t=>{e={x:Math.abs(Math.round(t.pageX)-(ee.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(ee.current?.y??0))}},n=n=>{e.x<=10&&e.y<=10?n.preventDefault():y.contains(n.target)||P(!1),document.removeEventListener(`pointermove`,t),ee.current=null};return ee.current!==null&&(document.addEventListener(`pointermove`,t),document.addEventListener(`pointerup`,n,{capture:!0,once:!0})),()=>{document.removeEventListener(`pointermove`,t),document.removeEventListener(`pointerup`,n,{capture:!0})}}},[y,P,ee]),q.useEffect(()=>{let e=()=>P(!1);return window.addEventListener(`blur`,e),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`resize`,e)}},[P]);let[te,ne]=ba(e=>{let t=O().filter(e=>!e.disabled),n=xa(t,e,t.find(e=>e.ref.current===document.activeElement));n&&setTimeout(()=>n.ref.current.focus())}),re=q.useCallback((e,t,n)=>{let r=!j.current&&!n;(v.value!==void 0&&v.value===t||r)&&(T(e),r&&(j.current=!0))},[v.value]),ie=q.useCallback(()=>y?.focus(),[y]),F=q.useCallback((e,t,n)=>{let r=!j.current&&!n;(v.value!==void 0&&v.value===t||r)&&D(e)},[v.value]),ae=r===`popper`?Ui:Vi,oe=ae===Ui?{side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g}:{};return(0,J.jsx)(Fi,{scope:n,content:y,viewport:x,onViewportChange:S,itemRefCallback:re,selectedItem:w,onItemLeave:ie,itemTextRefCallback:F,focusSelectedItem:N,selectedItemText:E,position:r,isPositioned:k,searchRef:te,children:(0,J.jsx)(Ge,{as:Ri,allowPinchZoom:!0,children:(0,J.jsx)(qe,{asChild:!0,trapped:v.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:L(i,e=>{v.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,J.jsx)(ye,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>v.onOpenChange(!1),children:(0,J.jsx)(ae,{role:`listbox`,id:v.contentId,"data-state":v.open?`open`:`closed`,dir:v.dir,onContextMenu:e=>e.preventDefault(),..._,...oe,onPlaced:()=>A(!0),ref:C,style:{display:`flex`,flexDirection:`column`,outline:`none`,..._.style},onKeyDown:L(_.onKeyDown,e=>{let t=e.ctrlKey||e.altKey||e.metaKey;if(e.key===`Tab`&&e.preventDefault(),!t&&e.key.length===1&&ne(e.key),[`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(e.key)){let t=O().filter(e=>!e.disabled).map(e=>e.ref.current);if([`ArrowUp`,`End`].includes(e.key)&&(t=t.slice().reverse()),[`ArrowUp`,`ArrowDown`].includes(e.key)){let n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>M(t)),e.preventDefault()}})})})})})})});zi.displayName=Li;var Bi=`SelectItemAlignedPosition`,Vi=q.forwardRef((e,t)=>{let{__scopeSelect:n,onPlaced:r,...i}=e,a=bi(Mi,n),o=Ii(Mi,n),[s,c]=q.useState(null),[l,u]=q.useState(null),d=Ct(t,e=>u(e)),f=mi(n),p=q.useRef(!1),m=q.useRef(!0),{viewport:h,selectedItem:g,selectedItemText:_,focusSelectedItem:v}=o,y=q.useCallback(()=>{if(a.trigger&&a.valueNode&&s&&l&&h&&g&&_){let e=a.trigger.getBoundingClientRect(),t=l.getBoundingClientRect(),n=a.valueNode.getBoundingClientRect(),i=_.getBoundingClientRect();if(a.dir!==`rtl`){let r=i.left-t.left,a=n.left-r,o=e.left-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-Pi,d=li(a,[Pi,Math.max(Pi,u-l)]);s.style.minWidth=c+`px`,s.style.left=d+`px`}else{let r=t.right-i.right,a=window.innerWidth-n.right-r,o=window.innerWidth-e.right-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-Pi,d=li(a,[Pi,Math.max(Pi,u-l)]);s.style.minWidth=c+`px`,s.style.right=d+`px`}let o=f(),c=window.innerHeight-Pi*2,u=h.scrollHeight,d=window.getComputedStyle(l),m=parseInt(d.borderTopWidth,10),v=parseInt(d.paddingTop,10),y=parseInt(d.borderBottomWidth,10),b=parseInt(d.paddingBottom,10),x=m+v+u+b+y,S=Math.min(g.offsetHeight*5,x),C=window.getComputedStyle(h),w=parseInt(C.paddingTop,10),T=parseInt(C.paddingBottom,10),E=e.top+e.height/2-Pi,D=c-E,O=g.offsetHeight/2,k=g.offsetTop+O,A=m+v+k,j=x-A;if(A<=E){let e=o.length>0&&g===o[o.length-1].ref.current;s.style.bottom=`0px`;let t=l.clientHeight-h.offsetTop-h.offsetHeight,n=A+Math.max(D,O+(e?T:0)+t+y);s.style.height=n+`px`}else{let e=o.length>0&&g===o[0].ref.current;s.style.top=`0px`;let t=Math.max(E,m+h.offsetTop+(e?w:0)+O)+j;s.style.height=t+`px`,h.scrollTop=A-E+h.offsetTop}s.style.margin=`${Pi}px 0`,s.style.minHeight=S+`px`,s.style.maxHeight=c+`px`,r?.(),requestAnimationFrame(()=>p.current=!0)}},[f,a.trigger,a.valueNode,s,l,h,g,_,a.dir,r]);se(()=>y(),[y]);let[b,x]=q.useState();return se(()=>{l&&x(window.getComputedStyle(l).zIndex)},[l]),(0,J.jsx)(Wi,{scope:n,contentWrapper:s,shouldExpandOnScrollRef:p,onScrollButtonChange:q.useCallback(e=>{e&&m.current===!0&&(y(),v?.(),m.current=!1)},[y,v]),children:(0,J.jsx)(`div`,{ref:c,style:{display:`flex`,flexDirection:`column`,position:`fixed`,zIndex:b},children:(0,J.jsx)(F.div,{...i,ref:d,style:{boxSizing:`border-box`,maxHeight:`100%`,...i.style}})})})});Vi.displayName=Bi;var Hi=`SelectPopperPosition`,Ui=q.forwardRef((e,t)=>{let{__scopeSelect:n,align:r=`start`,collisionPadding:i=Pi,...a}=e,o=vi(n);return(0,J.jsx)(dt,{...o,...a,ref:t,align:r,collisionPadding:i,style:{boxSizing:`border-box`,...a.style,"--radix-select-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-select-content-available-width":`var(--radix-popper-available-width)`,"--radix-select-content-available-height":`var(--radix-popper-available-height)`,"--radix-select-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-select-trigger-height":`var(--radix-popper-anchor-height)`}})});Ui.displayName=Hi;var[Wi,Gi]=gi(Mi,{}),Ki=`SelectViewport`,qi=q.forwardRef((e,t)=>{let{__scopeSelect:n,nonce:r,...i}=e,a=Ii(Ki,n),o=Gi(Ki,n),s=Ct(t,a.onViewportChange),c=q.useRef(0);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`},nonce:r}),(0,J.jsx)(pi.Slot,{scope:n,children:(0,J.jsx)(F.div,{"data-radix-select-viewport":``,role:`presentation`,...i,ref:s,style:{position:`relative`,flex:1,overflow:`hidden auto`,...i.style},onScroll:L(i.onScroll,e=>{let t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=o;if(r?.current&&n){let e=Math.abs(c.current-t.scrollTop);if(e>0){let r=window.innerHeight-Pi*2,i=parseFloat(n.style.minHeight),a=parseFloat(n.style.height),o=Math.max(i,a);if(o<r){let i=o+e,a=Math.min(r,i),s=i-a;n.style.height=a+`px`,n.style.bottom===`0px`&&(t.scrollTop=s>0?s:0,n.style.justifyContent=`flex-end`)}}}c.current=t.scrollTop})})})]})});qi.displayName=Ki;var Ji=`SelectGroup`,[Yi,Xi]=gi(Ji),Zi=q.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=Ke();return(0,J.jsx)(Yi,{scope:n,id:i,children:(0,J.jsx)(F.div,{role:`group`,"aria-labelledby":i,...r,ref:t})})});Zi.displayName=Ji;var Qi=`SelectLabel`,$i=q.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=Xi(Qi,n);return(0,J.jsx)(F.div,{id:i.id,...r,ref:t})});$i.displayName=Qi;var ea=`SelectItem`,[ta,na]=gi(ea),ra=q.forwardRef((e,t)=>{let{__scopeSelect:n,value:r,disabled:i=!1,textValue:a,...o}=e,s=bi(ea,n),c=Ii(ea,n),l=s.value===r,[u,d]=q.useState(a??``),[f,p]=q.useState(!1),m=Ct(t,e=>c.itemRefCallback?.(e,r,i)),h=Ke(),g=q.useRef(`touch`),_=()=>{i||(s.onValueChange(r),s.onOpenChange(!1))};if(r===``)throw Error(`A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.`);return(0,J.jsx)(ta,{scope:n,value:r,disabled:i,textId:h,isSelected:l,onItemTextChange:q.useCallback(e=>{d(t=>t||(e?.textContent??``).trim())},[]),children:(0,J.jsx)(pi.ItemSlot,{scope:n,value:r,disabled:i,textValue:u,children:(0,J.jsx)(F.div,{role:`option`,"aria-labelledby":h,"data-highlighted":f?``:void 0,"aria-selected":l&&f,"data-state":l?`checked`:`unchecked`,"aria-disabled":i||void 0,"data-disabled":i?``:void 0,tabIndex:i?void 0:-1,...o,ref:m,onFocus:L(o.onFocus,()=>p(!0)),onBlur:L(o.onBlur,()=>p(!1)),onClick:L(o.onClick,()=>{g.current!==`mouse`&&_()}),onPointerUp:L(o.onPointerUp,()=>{g.current===`mouse`&&_()}),onPointerDown:L(o.onPointerDown,e=>{g.current=e.pointerType}),onPointerMove:L(o.onPointerMove,e=>{g.current=e.pointerType,i?c.onItemLeave?.():g.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:L(o.onPointerLeave,e=>{e.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:L(o.onKeyDown,e=>{c.searchRef?.current!==``&&e.key===` `||(di.includes(e.key)&&_(),e.key===` `&&e.preventDefault())})})})})});ra.displayName=ea;var ia=`SelectItemText`,aa=q.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,...a}=e,o=bi(ia,n),s=Ii(ia,n),c=na(ia,n),l=Si(ia,n),[u,d]=q.useState(null),f=Ct(t,e=>d(e),c.onItemTextChange,e=>s.itemTextRefCallback?.(e,c.value,c.disabled)),p=u?.textContent,m=q.useMemo(()=>(0,J.jsx)(`option`,{value:c.value,disabled:c.disabled,children:p},c.value),[c.disabled,c.value,p]),{onNativeOptionAdd:h,onNativeOptionRemove:g}=l;return se(()=>(h(m),()=>g(m)),[h,g,m]),(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(F.span,{id:c.textId,...a,ref:f}),c.isSelected&&o.valueNode&&!o.valueNodeHasChildren?Tr.createPortal(a.children,o.valueNode):null]})});aa.displayName=ia;var oa=`SelectItemIndicator`,sa=q.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return na(oa,n).isSelected?(0,J.jsx)(F.span,{"aria-hidden":!0,...r,ref:t}):null});sa.displayName=oa;var ca=`SelectScrollUpButton`,la=q.forwardRef((e,t)=>{let n=Ii(ca,e.__scopeSelect),r=Gi(ca,e.__scopeSelect),[i,a]=q.useState(!1),o=Ct(t,r.onScrollButtonChange);return se(()=>{if(n.viewport&&n.isPositioned){let e=function(){a(t.scrollTop>0)},t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,J.jsx)(fa,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop-=t.offsetHeight)}}):null});la.displayName=ca;var ua=`SelectScrollDownButton`,da=q.forwardRef((e,t)=>{let n=Ii(ua,e.__scopeSelect),r=Gi(ua,e.__scopeSelect),[i,a]=q.useState(!1),o=Ct(t,r.onScrollButtonChange);return se(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollHeight-t.clientHeight;a(Math.ceil(t.scrollTop)<e)},t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,J.jsx)(fa,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop+=t.offsetHeight)}}):null});da.displayName=ua;var fa=q.forwardRef((e,t)=>{let{__scopeSelect:n,onAutoScroll:r,...i}=e,a=Ii(`SelectScrollButton`,n),o=q.useRef(null),s=mi(n),c=q.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return q.useEffect(()=>()=>c(),[c]),se(()=>{s().find(e=>e.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:`nearest`})},[s]),(0,J.jsx)(F.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:L(i.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:L(i.onPointerMove,()=>{a.onItemLeave?.(),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:L(i.onPointerLeave,()=>{c()})})}),pa=`SelectSeparator`,ma=q.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return(0,J.jsx)(F.div,{"aria-hidden":!0,...r,ref:t})});ma.displayName=pa;var ha=`SelectArrow`,ga=q.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=vi(n),a=bi(ha,n),o=Ii(ha,n);return a.open&&o.position===`popper`?(0,J.jsx)(rt,{...i,...r,ref:t}):null});ga.displayName=ha;var _a=`SelectBubbleInput`,va=q.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{let i=q.useRef(null),a=Ct(r,i),o=it(t);return q.useEffect(()=>{let e=i.current;if(!e)return;let n=window.HTMLSelectElement.prototype,r=Object.getOwnPropertyDescriptor(n,`value`).set;if(o!==t&&r){let n=new Event(`change`,{bubbles:!0});r.call(e,t),e.dispatchEvent(n)}},[o,t]),(0,J.jsx)(F.select,{...n,style:{...Qe,...n.style},ref:a,defaultValue:t})});va.displayName=_a;function ya(e){return e===``||e===void 0}function ba(e){let t=oe(e),n=q.useRef(``),r=q.useRef(0),i=q.useCallback(e=>{let i=n.current+e;t(i),(function e(t){n.current=t,window.clearTimeout(r.current),t!==``&&(r.current=window.setTimeout(()=>e(``),1e3))})(i)},[t]),a=q.useCallback(()=>{n.current=``,window.clearTimeout(r.current)},[]);return q.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,a]}function xa(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=Sa(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.textValue.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}function Sa(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Ca=Ci,wa=Ti,Ta=Di,Ea=ki,Da=ji,Oa=Ni,ka=qi,Aa=ra,ja=aa,Ma=sa,Na=la,Pa=da,Fa=`Tabs`,[Ia,La]=Le(Fa,[Yr]),Ra=Yr(),[za,Ba]=Ia(Fa),Va=q.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,onValueChange:i,defaultValue:a,orientation:o=`horizontal`,dir:s,activationMode:c=`automatic`,...l}=e,u=Vr(s),[d,f]=ce({prop:r,onChange:i,defaultProp:a??``,caller:Fa});return(0,J.jsx)(za,{scope:n,baseId:Ke(),value:d,onValueChange:f,orientation:o,dir:u,activationMode:c,children:(0,J.jsx)(F.div,{dir:u,"data-orientation":o,...l,ref:t})})});Va.displayName=Fa;var Ha=`TabsList`,Ua=q.forwardRef((e,t)=>{let{__scopeTabs:n,loop:r=!0,...i}=e,a=Ba(Ha,n),o=Ra(n);return(0,J.jsx)(si,{asChild:!0,...o,orientation:a.orientation,dir:a.dir,loop:r,children:(0,J.jsx)(F.div,{role:`tablist`,"aria-orientation":a.orientation,...i,ref:t})})});Ua.displayName=Ha;var Wa=`TabsTrigger`,Ga=q.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,disabled:i=!1,...a}=e,o=Ba(Wa,n),s=Ra(n),c=Ja(o.baseId,r),l=Ya(o.baseId,r),u=r===o.value;return(0,J.jsx)(ci,{asChild:!0,...s,focusable:!i,active:u,children:(0,J.jsx)(F.button,{type:`button`,role:`tab`,"aria-selected":u,"aria-controls":l,"data-state":u?`active`:`inactive`,"data-disabled":i?``:void 0,disabled:i,id:c,...a,ref:t,onMouseDown:L(e.onMouseDown,e=>{!i&&e.button===0&&e.ctrlKey===!1?o.onValueChange(r):e.preventDefault()}),onKeyDown:L(e.onKeyDown,e=>{[` `,`Enter`].includes(e.key)&&o.onValueChange(r)}),onFocus:L(e.onFocus,()=>{let e=o.activationMode!==`manual`;!u&&!i&&e&&o.onValueChange(r)})})})});Ga.displayName=Wa;var Ka=`TabsContent`,qa=q.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,forceMount:i,children:a,...o}=e,s=Ba(Ka,n),c=Ja(s.baseId,r),l=Ya(s.baseId,r),u=r===s.value,d=q.useRef(u);return q.useEffect(()=>{let e=requestAnimationFrame(()=>d.current=!1);return()=>cancelAnimationFrame(e)},[]),(0,J.jsx)(be,{present:i||u,children:({present:n})=>(0,J.jsx)(F.div,{"data-state":u?`active`:`inactive`,"data-orientation":s.orientation,role:`tabpanel`,"aria-labelledby":c,hidden:!n,id:l,tabIndex:0,...o,ref:t,style:{...e.style,animationDuration:d.current?`0s`:void 0},children:n&&a})})});qa.displayName=Ka;function Ja(e,t){return`${e}-trigger-${t}`}function Ya(e,t){return`${e}-content-${t}`}var Xa=Va,Za=Ua,Qa=Ga,$a=qa,eo=u(!1),to=u(!1),no=u(`explorer`),ro=u(28),io=u(!0),ao=u(null),oo=u(null),so=u(``),co=u({current:null}),lo=xt(`inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none 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 transition-[color,box-shadow] overflow-hidden`,{variants:{variant:{default:`border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90`,secondary:`border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90`,destructive:`border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60`,outline:`text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground`}},defaultVariants:{variant:`default`}}),Y=({className:e,variant:t,asChild:n=!1,...r})=>(0,J.jsx)(n?Tt:`span`,{"data-slot":`badge`,className:U(lo({variant:t}),e),...r}),uo=u(!1),fo=u(20),po=u(!1),mo=u(25),ho=(e,t,n)=>Math.min(n,Math.max(t,e)),go=()=>({isLeftPanelOpen:T(uo),leftPanelWidth:T(fo)}),_o=()=>{let e=w(),t=a(uo),n=a(fo);return{setIsLeftPanelOpen:t,toggleLeftPanel:(0,q.useCallback)(()=>{t(!e.get(uo))},[t,e]),setLeftPanelWidth:(0,q.useCallback)(e=>{n(ho(e,15,40))},[n])}},vo=()=>({isBottomPanelOpen:T(po),bottomPanelHeight:T(mo)}),yo=()=>{let e=a(po),t=a(mo);return{setIsBottomPanelOpen:e,setBottomPanelHeight:(0,q.useCallback)(e=>{t(ho(e,15,50))},[t])}},bo=(e,t,n)=>Math.min(n,Math.max(t,e)),xo=e=>{try{let t=new URL(e).hostname;return[`github.com`,`www.github.com`,`gitlab.com`,`www.gitlab.com`,`twitter.com`,`x.com`,`facebook.com`,`linkedin.com`,`google.com`,`www.google.com`].some(e=>t.endsWith(e))}catch{return!1}},So=()=>T(to),Co=()=>T(ro),wo=()=>({isOpen:So(),activeTab:T(no),width:Co(),browserUrl:T(ao),inputUrl:T(so)}),To=()=>T(io),Eo=()=>({setIsTodoSectionOpen:a(io)}),Do=()=>{let e=w(),t=a(to),n=a(no),r=a(ro),i=a(ao),o=a(oo),s=a(so);return{openPanel:(0,q.useCallback)(e=>{t(!0),e&&n(e)},[t,n]),closePanel:(0,q.useCallback)(()=>{t(!1)},[t]),togglePanel:(0,q.useCallback)(()=>{t(!e.get(to))},[t,e]),setActiveTab:n,setWidth:(0,q.useCallback)(e=>{r(bo(e,20,80))},[r]),setInputUrl:s,setCurrentUrl:o,openBrowser:(0,q.useCallback)(e=>{if(xo(e)){z.warning(`This website cannot be previewed instantly.`,{description:`It blocks embedded views. Click to open in a new tab.`,action:{label:`Open Link`,onClick:()=>window.open(e,`_blank`)},duration:5e3});return}i(e),o(e),s(e),n(`browser`),t(!0)},[i,o,s,n,t]),closeBrowser:(0,q.useCallback)(()=>{i(null),o(null),s(``)},[i,o,s]),reloadBrowser:(0,q.useCallback)(()=>{let t=e.get(co),n=e.get(oo),r=e.get(ao),i=n??r;t.current!==null&&i!==null&&i!==``&&(t.current.src=i)},[e]),handleUrlSubmit:(0,q.useCallback)(()=>{let t=e.get(so);if(t){if(xo(t)){z.warning(`This website cannot be previewed instantly.`,{description:`It blocks embedded views. Click to open in a new tab.`,action:{label:`Open Link`,onClick:()=>window.open(t,`_blank`)},duration:5e3});return}i(t),o(t)}},[e,i,o])}},Oo=1,ko=.9,Ao=.8,jo=.17,Mo=.1,No=.999,Po=.9999,Fo=.99,Io=/[\\\/_+.#"@\[\(\{&]/,Lo=/[\\\/_+.#"@\[\(\{&]/g,Ro=/[\s-]/,zo=/[\s-]/g;function Bo(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?Oo:Fo;var s=`${i},${a}`;if(o[s]!==void 0)return o[s];for(var c=r.charAt(a),l=n.indexOf(c,i),u=0,d,f,p,m;l>=0;)d=Bo(e,t,n,r,l+1,a+1,o),d>u&&(l===i?d*=Oo:Io.test(e.charAt(l-1))?(d*=Ao,p=e.slice(i,l-1).match(Lo),p&&i>0&&(d*=No**+p.length)):Ro.test(e.charAt(l-1))?(d*=ko,m=e.slice(i,l-1).match(zo),m&&i>0&&(d*=No**+m.length)):(d*=jo,i>0&&(d*=No**+(l-i))),e.charAt(l)!==t.charAt(a)&&(d*=Po)),(d<Mo&&n.charAt(l-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(l-1)!==r.charAt(a))&&(f=Bo(e,t,n,r,l+1,a+2,o),f*Mo>d&&(d=f*Mo)),d>u&&(u=d),l=n.indexOf(c,l+1);return o[s]=u,u}function Vo(e){return e.toLowerCase().replace(zo,` `)}function Ho(e,t,n){return e=n&&n.length>0?`${e+` `+n.join(` `)}`:e,Bo(e,t,Vo(e),Vo(t),0,0,{})}var Uo=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=kt(`Primitive.${t}`),r=q.forwardRef((e,r)=>{let{asChild:i,...a}=e,o=i?n:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,J.jsx)(o,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{}),Wo=`[cmdk-group=""]`,Go=`[cmdk-group-items=""]`,Ko=`[cmdk-group-heading=""]`,qo=`[cmdk-item=""]`,Jo=`${qo}:not([aria-disabled="true"])`,Yo=`cmdk-item-select`,Xo=`data-value`,Zo=(e,t,n)=>Ho(e,t,n),Qo=q.createContext(void 0),$o=()=>q.useContext(Qo),es=q.createContext(void 0),ts=()=>q.useContext(es),ns=q.createContext(void 0),rs=q.forwardRef((e,t)=>{let n=_s(()=>({search:``,value:e.value??e.defaultValue??``,selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),r=_s(()=>new Set),i=_s(()=>new Map),a=_s(()=>new Map),o=_s(()=>new Set),s=hs(e),{label:c,children:l,value:u,onValueChange:d,filter:f,shouldFilter:p,loop:m,disablePointerSelection:h=!1,vimBindings:g=!0,..._}=e,v=Ke(),y=Ke(),b=Ke(),x=q.useRef(null),S=bs();gs(()=>{if(u!==void 0){let e=u.trim();n.current.value=e,C.emit()}},[u]),gs(()=>{S(6,k)},[]);let C=q.useMemo(()=>({subscribe:e=>(o.current.add(e),()=>o.current.delete(e)),snapshot:()=>n.current,setState:(e,t,r)=>{var i,a,o;if(!Object.is(n.current[e],t)){if(n.current[e]=t,e===`search`)O(),E(),S(1,D);else if(e===`value`){if(document.activeElement.hasAttribute(`cmdk-input`)||document.activeElement.hasAttribute(`cmdk-root`)){let e=document.getElementById(b);e?e.focus():(i=document.getElementById(v))==null||i.focus()}if(S(7,()=>{n.current.selectedItemId=A()?.id,C.emit()}),r||S(5,k),s.current?.value!==void 0){let e=t??``;(o=(a=s.current).onValueChange)==null||o.call(a,e);return}}C.emit()}},emit:()=>{o.current.forEach(e=>e())}}),[]),w=q.useMemo(()=>({value:(e,t,r)=>{t!==a.current.get(e)?.value&&(a.current.set(e,{value:t,keywords:r}),n.current.filtered.items.set(e,T(t,r)),S(2,()=>{E(),C.emit()}))},item:(e,t)=>(r.current.add(e),t&&(i.current.has(t)?i.current.get(t).add(e):i.current.set(t,new Set([e]))),S(3,()=>{O(),E(),n.current.value||D(),C.emit()}),()=>{a.current.delete(e),r.current.delete(e),n.current.filtered.items.delete(e);let t=A();S(4,()=>{O(),t?.getAttribute(`id`)===e&&D(),C.emit()})}),group:e=>(i.current.has(e)||i.current.set(e,new Set),()=>{a.current.delete(e),i.current.delete(e)}),filter:()=>s.current.shouldFilter,label:c||e[`aria-label`],getDisablePointerSelection:()=>s.current.disablePointerSelection,listId:v,inputId:b,labelId:y,listInnerRef:x}),[]);function T(e,t){let r=s.current?.filter??Zo;return e?r(e,n.current.search,t):0}function E(){if(!n.current.search||s.current.shouldFilter===!1)return;let e=n.current.filtered.items,t=[];n.current.filtered.groups.forEach(n=>{let r=i.current.get(n),a=0;r.forEach(t=>{let n=e.get(t);a=Math.max(n,a)}),t.push([n,a])});let r=x.current;j().sort((t,n)=>{let r=t.getAttribute(`id`),i=n.getAttribute(`id`);return(e.get(i)??0)-(e.get(r)??0)}).forEach(e=>{let t=e.closest(Go);t?t.appendChild(e.parentElement===t?e:e.closest(`${Go} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${Go} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{let t=x.current?.querySelector(`${Wo}[${Xo}="${encodeURIComponent(e[0])}"]`);t?.parentElement.appendChild(t)})}function D(){let e=j().find(e=>e.getAttribute(`aria-disabled`)!==`true`)?.getAttribute(Xo);C.setState(`value`,e||void 0)}function O(){if(!n.current.search||s.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let e=0;for(let t of r.current){let r=T(a.current.get(t)?.value??``,a.current.get(t)?.keywords??[]);n.current.filtered.items.set(t,r),r>0&&e++}for(let[e,t]of i.current)for(let r of t)if(n.current.filtered.items.get(r)>0){n.current.filtered.groups.add(e);break}n.current.filtered.count=e}function k(){var e;let t=A();t&&(t.parentElement?.firstChild===t&&((e=t.closest(Wo)?.querySelector(Ko))==null||e.scrollIntoView({block:`nearest`})),t.scrollIntoView({block:`nearest`}))}function A(){return x.current?.querySelector(`${qo}[aria-selected="true"]`)}function j(){return Array.from(x.current?.querySelectorAll(Jo)||[])}function M(e){let t=j()[e];t&&C.setState(`value`,t.getAttribute(Xo))}function N(e){var t;let n=A(),r=j(),i=r.findIndex(e=>e===n),a=r[i+e];(t=s.current)!=null&&t.loop&&(a=i+e<0?r[r.length-1]:i+e===r.length?r[0]:r[i+e]),a&&C.setState(`value`,a.getAttribute(Xo))}function P(e){let t=A()?.closest(Wo),n;for(;t&&!n;)t=e>0?ps(t,Wo):ms(t,Wo),n=t?.querySelector(Jo);n?C.setState(`value`,n.getAttribute(Xo)):N(e)}let ee=()=>M(j().length-1),te=e=>{e.preventDefault(),e.metaKey?ee():e.altKey?P(1):N(1)},ne=e=>{e.preventDefault(),e.metaKey?M(0):e.altKey?P(-1):N(-1)};return q.createElement(Uo.div,{ref:t,tabIndex:-1,..._,"cmdk-root":``,onKeyDown:e=>{var t;(t=_.onKeyDown)==null||t.call(_,e);let n=e.nativeEvent.isComposing||e.keyCode===229;if(!(e.defaultPrevented||n))switch(e.key){case`n`:case`j`:g&&e.ctrlKey&&te(e);break;case`ArrowDown`:te(e);break;case`p`:case`k`:g&&e.ctrlKey&&ne(e);break;case`ArrowUp`:ne(e);break;case`Home`:e.preventDefault(),M(0);break;case`End`:e.preventDefault(),ee();break;case`Enter`:{e.preventDefault();let t=A();if(t){let e=new Event(Yo);t.dispatchEvent(e)}}}}},q.createElement(`label`,{"cmdk-label":``,htmlFor:w.inputId,id:w.labelId,style:Cs},c),Ss(e,e=>q.createElement(es.Provider,{value:C},q.createElement(Qo.Provider,{value:w},e))))}),is=q.forwardRef((e,t)=>{let n=Ke(),r=q.useRef(null),i=q.useContext(ns),a=$o(),o=hs(e),s=o.current?.forceMount??i?.forceMount;gs(()=>{if(!s)return a.item(n,i?.id)},[s]);let c=ys(n,r,[e.value,e.children,r],e.keywords),l=ts(),u=vs(e=>e.value&&e.value===c.current),d=vs(e=>s||a.filter()===!1?!0:e.search?e.filtered.items.get(n)>0:!0);q.useEffect(()=>{let t=r.current;if(!(!t||e.disabled))return t.addEventListener(Yo,f),()=>t.removeEventListener(Yo,f)},[d,e.onSelect,e.disabled]);function f(){var e,t;p(),(t=(e=o.current).onSelect)==null||t.call(e,c.current)}function p(){l.setState(`value`,c.current,!0)}if(!d)return null;let{disabled:m,value:h,onSelect:g,forceMount:_,keywords:v,...y}=e;return q.createElement(Uo.div,{ref:St(r,t),...y,id:n,"cmdk-item":``,role:`option`,"aria-disabled":!!m,"aria-selected":!!u,"data-disabled":!!m,"data-selected":!!u,onPointerMove:m||a.getDisablePointerSelection()?void 0:p,onClick:m?void 0:f},e.children)}),as=q.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...a}=e,o=Ke(),s=q.useRef(null),c=q.useRef(null),l=Ke(),u=$o(),d=vs(e=>i||u.filter()===!1?!0:e.search?e.filtered.groups.has(o):!0);gs(()=>u.group(o),[]),ys(o,s,[e.value,e.heading,c]);let f=q.useMemo(()=>({id:o,forceMount:i}),[i]);return q.createElement(Uo.div,{ref:St(s,t),...a,"cmdk-group":``,role:`presentation`,hidden:d?void 0:!0},n&&q.createElement(`div`,{ref:c,"cmdk-group-heading":``,"aria-hidden":!0,id:l},n),Ss(e,e=>q.createElement(`div`,{"cmdk-group-items":``,role:`group`,"aria-labelledby":n?l:void 0},q.createElement(ns.Provider,{value:f},e))))}),os=q.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=q.useRef(null),a=vs(e=>!e.search);return!n&&!a?null:q.createElement(Uo.div,{ref:St(i,t),...r,"cmdk-separator":``,role:`separator`})}),ss=q.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,a=ts(),o=vs(e=>e.search),s=vs(e=>e.selectedItemId),c=$o();return q.useEffect(()=>{e.value!=null&&a.setState(`search`,e.value)},[e.value]),q.createElement(Uo.input,{ref:t,...r,"cmdk-input":``,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,"aria-autocomplete":`list`,role:`combobox`,"aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":s,id:c.inputId,type:`text`,value:i?e.value:o,onChange:e=>{i||a.setState(`search`,e.target.value),n?.(e.target.value)}})}),cs=q.forwardRef((e,t)=>{let{children:n,label:r=`Suggestions`,...i}=e,a=q.useRef(null),o=q.useRef(null),s=vs(e=>e.selectedItemId),c=$o();return q.useEffect(()=>{if(o.current&&a.current){let e=o.current,t=a.current,n,r=new ResizeObserver(()=>{n=requestAnimationFrame(()=>{let n=e.offsetHeight;t.style.setProperty(`--cmdk-list-height`,n.toFixed(1)+`px`)})});return r.observe(e),()=>{cancelAnimationFrame(n),r.unobserve(e)}}},[]),q.createElement(Uo.div,{ref:St(a,t),...i,"cmdk-list":``,role:`listbox`,tabIndex:-1,"aria-activedescendant":s,"aria-label":r,id:c.listId},Ss(e,e=>q.createElement(`div`,{ref:St(o,c.listInnerRef),"cmdk-list-sizer":``},e)))}),ls=q.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:a,container:o,...s}=e;return q.createElement(Ne,{open:n,onOpenChange:r},q.createElement(Pe,{container:o},q.createElement(ze,{"cmdk-overlay":``,className:i}),q.createElement(Ve,{"aria-label":e.label,"cmdk-dialog":``,className:a},q.createElement(rs,{ref:t,...s}))))}),us=q.forwardRef((e,t)=>vs(e=>e.filtered.count===0)?q.createElement(Uo.div,{ref:t,...e,"cmdk-empty":``,role:`presentation`}):null),ds=q.forwardRef((e,t)=>{let{progress:n,children:r,label:i=`Loading...`,...a}=e;return q.createElement(Uo.div,{ref:t,...a,"cmdk-loading":``,role:`progressbar`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},Ss(e,e=>q.createElement(`div`,{"aria-hidden":!0},e)))}),fs=Object.assign(rs,{List:cs,Item:is,Input:ss,Group:as,Separator:os,Dialog:ls,Empty:us,Loading:ds});function ps(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function ms(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function hs(e){let t=q.useRef(e);return gs(()=>{t.current=e}),t}var gs=typeof window>`u`?q.useEffect:q.useLayoutEffect;function _s(e){let t=q.useRef();return t.current===void 0&&(t.current=e()),t}function vs(e){let t=ts(),n=()=>e(t.snapshot());return q.useSyncExternalStore(t.subscribe,n,n)}function ys(e,t,n,r=[]){let i=q.useRef(),a=$o();return gs(()=>{var o;let s=(()=>{for(let e of n){if(typeof e==`string`)return e.trim();if(typeof e==`object`&&`current`in e)return e.current?e.current.textContent?.trim():i.current}})(),c=r.map(e=>e.trim());a.value(e,s,c),(o=t.current)==null||o.setAttribute(Xo,s),i.current=s}),i}var bs=()=>{let[e,t]=q.useState(),n=_s(()=>new Map);return gs(()=>{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function xs(e){let t=e.type;return typeof t==`function`?t(e.props):`render`in t?t.render(e.props):e}function Ss({asChild:e,children:t},n){return e&&q.isValidElement(t)?q.cloneElement(xs(t),{ref:t.ref},n(t.props.children)):n(t)}var Cs={position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`},ws=({className:e,...t})=>(0,J.jsx)(fs,{"data-slot":`command`,className:U(`bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md`,e),...t}),Ts=({className:e,...t})=>(0,J.jsxs)(`div`,{"data-slot":`command-input-wrapper`,className:`flex h-9 items-center gap-2 border-b px-3`,children:[(0,J.jsx)(Te,{className:`size-4 shrink-0 opacity-50`}),(0,J.jsx)(fs.Input,{"data-slot":`command-input`,className:U(`placeholder:text-muted-foreground flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50`,e),...t})]}),Es=({className:e,...t})=>(0,J.jsx)(fs.List,{"data-slot":`command-list`,className:U(`max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto`,e),...t}),Ds=({...e})=>(0,J.jsx)(fs.Empty,{"data-slot":`command-empty`,className:`py-6 text-center text-sm`,...e}),Os=({className:e,...t})=>(0,J.jsx)(fs.Group,{"data-slot":`command-group`,className:U(`text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium`,e),...t}),ks=({className:e,...t})=>(0,J.jsx)(fs.Item,{"data-slot":`command-item`,className:U(`data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...t}),As=e=>e.replace(/^\/(?:home|Users)\/[^/]+/,`~`),js=({currentProjectId:e,currentProjectPath:t})=>{let[n,r]=(0,q.useState)(!1),i=N(),{data:a}=we({queryKey:y.queryKey,queryFn:y.queryFn}),o=a?.projects??[],s=t??(()=>{let t=o.find(t=>t.id===e);return t?t.meta.projectPath??t.claudeProjectPath:void 0})(),c=s!==void 0&&s!==``?As(s):void 0,l=t=>{r(!1),t!==e&&i({to:`/projects/$projectId/session`,params:{projectId:t}})};return(0,J.jsxs)(ot,{open:n,onOpenChange:r,children:[(0,J.jsx)(ut,{asChild:!0,children:(0,J.jsxs)(`button`,{type:`button`,role:`combobox`,"aria-expanded":n,className:`flex items-center gap-1.5 h-7 text-foreground/70 font-medium truncate hover:text-foreground transition-colors rounded px-2 hover:bg-muted/50`,children:[(0,J.jsx)(vt,{className:`w-3.5 h-3.5 shrink-0 opacity-60`}),(0,J.jsx)(`span`,{className:`truncate max-w-[300px] font-mono text-xs`,children:c??(0,J.jsx)(B,{id:`project_switcher.no_project`})}),(0,J.jsx)(Sn,{className:`w-3.5 h-3.5 shrink-0 opacity-40`})]})}),(0,J.jsx)($e,{className:`w-80 p-0 z-[53]`,align:`start`,sideOffset:8,children:(0,J.jsxs)(ws,{children:[(0,J.jsx)(Ts,{placeholder:`Search projects...`}),(0,J.jsxs)(Es,{children:[(0,J.jsx)(Ds,{children:(0,J.jsx)(B,{id:`project_switcher.no_results`})}),(0,J.jsx)(Os,{children:o.map(t=>{let n=t.meta.projectPath??t.claudeProjectPath,r=As(n);return(0,J.jsxs)(ks,{value:n,onSelect:()=>l(t.id),className:`gap-2`,children:[(0,J.jsx)(_t,{className:U(`w-3.5 h-3.5 shrink-0`,t.id===e?`opacity-100`:`opacity-0`)}),(0,J.jsx)(`span`,{className:`truncate font-mono text-xs`,children:r})]},t.id)})})]})]})})]})},Ms=({children:e,projectId:t,projectPath:n,currentBranch:r,sessionId:i})=>{let{isLeftPanelOpen:a}=go(),{setIsLeftPanelOpen:o}=_o(),{isBottomPanelOpen:s}=vo(),{setIsBottomPanelOpen:c}=yo(),l=So(),{togglePanel:u}=Do(),[d,f]=(0,q.useState)(!1);return(0,J.jsxs)(`div`,{className:`flex flex-col h-screen w-screen overflow-hidden bg-background`,children:[(0,J.jsxs)(`header`,{className:`h-(--spacing-header-height) flex items-center justify-between px-3 bg-muted/30 border-b border-border/40 text-xs flex-shrink-0 select-none`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2.5 min-w-0 flex-1 overflow-x-auto overflow-y-hidden`,children:[(0,J.jsx)(`div`,{className:`shrink-0`,children:(0,J.jsx)(js,{currentProjectId:t,currentProjectPath:n})}),r!==void 0&&r!==``&&(0,J.jsxs)(Y,{variant:`outline`,className:`h-5 text-[11px] px-2 bg-background/50 border-border/60 gap-1 shrink-0`,children:[(0,J.jsx)(Vn,{className:`w-3 h-3`}),(0,J.jsx)(`span`,{className:`max-w-[100px] truncate`,children:r})]}),i!==void 0&&i!==``&&(0,J.jsx)(Y,{variant:`outline`,className:`h-5 text-[11px] px-2 bg-background/50 border-border/60 font-mono shrink-0 whitespace-nowrap hidden md:flex`,children:i})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,J.jsx)(`button`,{type:`button`,onClick:()=>f(!0),className:`md:hidden w-11 h-11 flex items-center justify-center rounded transition-colors hover:bg-muted text-muted-foreground hover:text-foreground`,"aria-label":`Search`,children:(0,J.jsx)(Te,{className:`w-3.5 h-3.5`})}),(0,J.jsx)(ft,{sessionId:i}),(0,J.jsxs)(st,{children:[(0,J.jsxs)(pt,{children:[(0,J.jsx)(ht,{asChild:!0,children:(0,J.jsx)(`button`,{type:`button`,onClick:()=>{o(!a)},className:U(`hidden md:flex w-7 h-7 items-center justify-center rounded transition-colors`,a?`bg-primary/10 text-primary`:`hover:bg-muted text-muted-foreground hover:text-foreground`),"aria-label":`Toggle left panel`,children:(0,J.jsx)(ir,{className:`w-3.5 h-3.5`})})}),(0,J.jsx)(tt,{side:`bottom`,className:`text-xs`,children:(0,J.jsx)(B,{id:`layout.toggle_left_panel`})})]}),(0,J.jsxs)(pt,{children:[(0,J.jsx)(ht,{asChild:!0,children:(0,J.jsx)(`button`,{type:`button`,onClick:()=>c(!s),className:U(`w-11 h-11 md:w-7 md:h-7 flex items-center justify-center rounded transition-colors`,s?`bg-primary/10 text-primary`:`hover:bg-muted text-muted-foreground hover:text-foreground`),"aria-label":`Toggle bottom panel`,children:(0,J.jsx)(rr,{className:`w-3.5 h-3.5`})})}),(0,J.jsx)(tt,{side:`bottom`,className:`text-xs`,children:(0,J.jsx)(B,{id:`layout.toggle_bottom_panel`})})]}),(0,J.jsxs)(pt,{children:[(0,J.jsx)(ht,{asChild:!0,children:(0,J.jsx)(`button`,{type:`button`,onClick:u,className:U(`w-11 h-11 md:w-7 md:h-7 flex items-center justify-center rounded transition-colors`,l?`bg-primary/10 text-primary`:`hover:bg-muted text-muted-foreground hover:text-foreground`),"aria-label":`Toggle right panel`,children:(0,J.jsx)(ar,{className:`w-3.5 h-3.5`})})}),(0,J.jsx)(tt,{side:`bottom`,className:`text-xs`,children:(0,J.jsx)(B,{id:`layout.toggle_right_panel`})})]})]})]})]}),(0,J.jsx)(`div`,{className:`flex-1 min-h-0 overflow-hidden`,children:e}),(0,J.jsx)(De,{open:d,onOpenChange:f,projectId:t})]})},Ns=({onResize:e,onResizeStart:t,onResizeEnd:n,enabled:r=!0})=>{let[i,a]=(0,q.useState)(!1),o=(0,q.useRef)(!1),s=(0,q.useRef)(null),c=(0,q.useRef)(null),l=(0,q.useCallback)(()=>{o.current=!1,a(!1),n?.()},[n]),u=(0,q.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),o.current=!0,a(!0),t?.()},[t]);return(0,q.useEffect)(()=>{if(!r){l();return}let t=()=>{s.current===null&&(s.current=window.requestAnimationFrame(()=>{s.current=null;let t=c.current;t&&e(t)}))},n=e=>{o.current&&(e.preventDefault(),c.current=e,t())},i=e=>{e.preventDefault(),l()},a=()=>{l()},u=()=>{document.hidden&&l()},d=()=>{l()};return document.addEventListener(`mousemove`,n,{passive:!1}),document.addEventListener(`mouseup`,i,{passive:!1}),document.addEventListener(`mouseleave`,a),document.addEventListener(`visibilitychange`,u),window.addEventListener(`blur`,d),()=>{s.current!==null&&window.cancelAnimationFrame(s.current),document.removeEventListener(`mousemove`,n),document.removeEventListener(`mouseup`,i),document.removeEventListener(`mouseleave`,a),document.removeEventListener(`visibilitychange`,u),window.removeEventListener(`blur`,d)}},[r,e,l]),{isResizing:i,handleMouseDown:u}},Ps=()=>typeof window>`u`?!1:window.innerWidth<=767,Fs=`(max-width: 767px)`,Is=()=>{let[e,t]=(0,q.useState)(Ps);return(0,q.useEffect)(()=>{if(typeof window>`u`)return;let e=window.matchMedia(Fs),n=()=>t(e.matches);return n(),e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e},Ls=`terminalSessionId`,Rs=e=>{try{let t=JSON.parse(e);if(typeof t!=`object`||!t)return;let n=t;if(n.type===`hello`&&typeof n.sessionId==`string`&&typeof n.seq==`number`)return{type:`hello`,sessionId:n.sessionId,seq:n.seq};if((n.type===`output`||n.type===`snapshot`)&&typeof n.seq==`number`&&typeof n.data==`string`)return{type:n.type,seq:n.seq,data:n.data};if(n.type===`exit`&&typeof n.code==`number`)return{type:`exit`,code:n.code};if(n.type===`pong`)return{type:`pong`}}catch{return}},zs=e=>e===void 0||e===``?Ls:`${Ls}:${e}`,Bs=e=>{let t=localStorage.getItem(zs(e));return t!==null&&t.length>0?t:void 0},Vs=(e,t)=>{let n=window.location.protocol===`https:`?`wss`:`ws`,r=window.location.host,i=new URLSearchParams;e!==void 0&&e!==``&&i.set(`sessionId`,e),t!==void 0&&t!==``&&i.set(`cwd`,t);let a=i.toString();return`${n}://${r}/ws/terminal${a?`?${a}`:``}`},Hs=e=>{localStorage.removeItem(zs(e))},Us=(0,q.forwardRef)(({resetToken:e=0,cwd:t,onProcessExit:n},r)=>{let i=(0,q.useRef)(null),a=(0,q.useRef)(null),o=(0,q.useRef)(null),s=(0,q.useRef)(null),c=(0,q.useRef)(void 0),l=(0,q.useRef)(0),u=(0,q.useRef)(!1),d=(0,q.useRef)(n);d.current=n;let f=(0,q.useRef)(void 0);return(0,q.useImperativeHandle)(r,()=>({sendData:e=>{f.current?.({type:`input`,data:e})},sendSignal:e=>{f.current?.({type:`signal`,name:e})},scrollLines:e=>{a.current?.scrollLines(e)}})),(0,q.useEffect)(()=>{let n=i.current;if(!n)return;e>0&&Hs(t);let r=new Kt({convertEol:!0,cursorBlink:!0,fontFamily:`ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas`}),p=new Gt;r.loadAddon(p),r.open(n);let m=()=>{p.fit(),r.rows>0&&r.refresh(0,r.rows-1)},h=()=>{u.current||(u.current=!0,requestAnimationFrame(()=>{u.current=!1,r.rows>0&&r.refresh(0,r.rows-1)}))};m(),requestAnimationFrame(()=>{m()}),a.current=r,o.current=p;let g=Bs(t);c.current=g,l.current=0;let _=new WebSocket(Vs(g,t));s.current=_;let v=e=>{_.readyState===WebSocket.OPEN&&_.send(JSON.stringify(e))};f.current=v;let y=()=>{v({type:`resize`,cols:r.cols,rows:r.rows})};_.addEventListener(`open`,()=>{v({type:`sync`,lastSeq:l.current}),m(),y()}),_.addEventListener(`message`,e=>{if(typeof e.data!=`string`)return;let n=Rs(e.data);if(n){if(n.type===`hello`){c.current=n.sessionId,localStorage.setItem(zs(t),n.sessionId);return}if(n.type===`output`||n.type===`snapshot`){r.write(n.data),h(),l.current=n.seq;return}if(n.type===`exit`){r.write(`\r\n[process exited with code ${n.code}]\r\n`),d.current?.();return}}});let b=r.onData(e=>{v({type:`input`,data:e})}),x=r.onKey(({domEvent:e})=>{e.ctrlKey&&e.key.toLowerCase()===`c`&&(e.preventDefault(),e.stopPropagation(),v({type:`signal`,name:`SIGINT`}))}),S=new ResizeObserver(()=>{m(),y()});S.observe(n);let C=window.setInterval(()=>{_.readyState===WebSocket.OPEN&&_.send(JSON.stringify({type:`ping`}))},2e4),w=0,T=e=>{let t=e.touches[0];t&&(w=t.clientY)},E=e=>{e.preventDefault();let t=e.touches[0];if(!t)return;let n=w-t.clientY;w=t.clientY;let i=Math.round(n/20);i!==0&&r.scrollLines(i)};return n.addEventListener(`touchstart`,T,{passive:!0}),n.addEventListener(`touchmove`,E,{passive:!1}),()=>{f.current=void 0,n.removeEventListener(`touchstart`,T),n.removeEventListener(`touchmove`,E),window.clearInterval(C),S.disconnect(),b.dispose(),x.dispose(),_.close(),r.dispose()}},[e,t]),(0,J.jsx)(`div`,{ref:i,className:`h-full w-full`})});Us.displayName=`TerminalPanel`;var Ws=[{label:`Esc`,type:`data`,data:`\x1B`},{label:`Tab`,type:`data`,data:` `},{label:`↑`,type:`data`,data:`\x1B[A`},{label:`↓`,type:`data`,data:`\x1B[B`},{label:`←`,type:`data`,data:`\x1B[D`},{label:`→`,type:`data`,data:`\x1B[C`},{label:`Ctrl+C`,type:`signal`,signal:`SIGINT`},{label:`Ctrl+U`,type:`data`,data:``}],Gs=({cwd:e})=>{let{isBottomPanelOpen:t,bottomPanelHeight:n}=vo(),{setIsBottomPanelOpen:r,setBottomPanelHeight:i}=yo(),a=Is(),[o,s]=(0,q.useState)(0),c=(0,q.useRef)(void 0),l=(0,q.useRef)(null);(0,q.useEffect)(()=>()=>{c.current&&clearTimeout(c.current)},[]);let u=(0,q.useCallback)(()=>{c.current=setTimeout(()=>{r(!1)},1500)},[r]),{isResizing:d,handleMouseDown:f}=Ns({onResize:(0,q.useCallback)(e=>{i((window.innerHeight-e.clientY)/window.innerHeight*100)},[i])});(0,q.useEffect)(()=>(d?(document.body.style.userSelect=`none`,document.body.style.cursor=`ns-resize`,document.body.style.pointerEvents=`none`):(document.body.style.userSelect=``,document.body.style.cursor=``,document.body.style.pointerEvents=``),()=>{document.body.style.userSelect=``,document.body.style.cursor=``,document.body.style.pointerEvents=``}),[d]);let p=(0,q.useCallback)(e=>{e.type===`data`?l.current?.sendData(e.data):l.current?.sendSignal(e.signal)},[]);return t?(0,J.jsxs)(`div`,{className:`border-t border-border/60 bg-background flex flex-col flex-shrink-0`,style:{height:`${n}%`,userSelect:d?`none`:`auto`},children:[(0,J.jsx)(`div`,{className:`h-1 cursor-ns-resize hover:bg-primary/40 active:bg-primary transition-colors flex-shrink-0`,style:{pointerEvents:`auto`},onMouseDown:f}),(0,J.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-1.5 border-b border-border/40 bg-muted/20 flex-shrink-0`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-muted-foreground`,children:[(0,J.jsx)(ur,{className:`w-3.5 h-3.5`}),(0,J.jsx)(`span`,{children:(0,J.jsx)(B,{id:`layout.bottom_panel.title`})})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,J.jsxs)(`button`,{type:`button`,onClick:()=>s(e=>e+1),className:`h-6 px-2 text-[11px] rounded border border-border/60 text-muted-foreground hover:text-foreground hover:bg-muted transition-colors flex items-center gap-1`,"aria-label":`Start a new terminal session`,children:[(0,J.jsx)(dr,{className:`w-3 h-3`}),`New session`]}),(0,J.jsx)(`button`,{type:`button`,onClick:()=>r(!1),className:`w-5 h-5 flex items-center justify-center rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors`,"aria-label":`Collapse terminal panel`,children:(0,J.jsx)(nr,{className:`w-3 h-3`})})]})]}),(0,J.jsx)(`div`,{className:`flex-1 min-h-0 bg-muted/5`,children:(0,J.jsx)(Us,{ref:l,resetToken:o,cwd:e,onProcessExit:u})}),a&&(0,J.jsxs)(`div`,{className:`flex items-center gap-1 px-2 py-1.5 border-t border-border/40 bg-muted/10 overflow-x-auto flex-shrink-0`,children:[(0,J.jsx)(`button`,{type:`button`,className:`flex items-center justify-center min-w-[40px] h-9 rounded border border-border/60 text-muted-foreground active:bg-muted transition-colors flex-shrink-0`,onPointerDown:e=>{e.preventDefault(),l.current?.scrollLines(-5)},"aria-label":`Scroll up`,children:(0,J.jsx)(Cn,{className:`w-3.5 h-3.5`})}),(0,J.jsx)(`button`,{type:`button`,className:`flex items-center justify-center min-w-[40px] h-9 rounded border border-border/60 text-muted-foreground active:bg-muted transition-colors flex-shrink-0`,onPointerDown:e=>{e.preventDefault(),l.current?.scrollLines(5)},"aria-label":`Scroll down`,children:(0,J.jsx)(xn,{className:`w-3.5 h-3.5`})}),(0,J.jsx)(`div`,{className:`w-px h-5 bg-border/60 mx-0.5 flex-shrink-0`}),Ws.map(e=>(0,J.jsx)(`button`,{type:`button`,className:`flex items-center justify-center min-w-[44px] h-9 px-2 rounded border border-border/60 text-xs font-mono text-muted-foreground active:bg-muted transition-colors flex-shrink-0`,onPointerDown:t=>{t.preventDefault(),p(e)},children:e.label},e.label))]})]}):null},Ks=[{id:`explorer`,icon:Rn,label:(0,J.jsx)(B,{id:`panel.tab.explorer`})},{id:`git`,icon:Hn,label:(0,J.jsx)(B,{id:`panel.tab.git`})},{id:`review`,icon:kn,label:(0,J.jsx)(B,{id:`panel.tab.review`})},{id:`browser`,icon:Wn,label:(0,J.jsx)(B,{id:`panel.tab.browser`})}],qs=({gitTabContent:e,filesToolsTabContent:t,reviewTabContent:n})=>{let{isOpen:r,activeTab:i,width:o,browserUrl:s,inputUrl:c}=wo(),{closePanel:l,setActiveTab:u,setWidth:d,setInputUrl:f,setCurrentUrl:p,reloadBrowser:m,handleUrlSubmit:h}=Do(),g=Is(),_=(0,q.useRef)(null),v=a(co),y=(0,q.useRef)(null);(0,q.useEffect)(()=>{v(_)},[v]),(0,q.useEffect)(()=>{if(s===null||s===``||!r){y.current=null;return}let e=window.setInterval(()=>{try{let e=_.current?.contentWindow?.location.href;if(e===void 0||e===``||e===`about:blank`)return;e!==y.current&&(y.current=e,p(e),f(e))}catch{}},500);return()=>window.clearInterval(e)},[s,r,p,f]);let b=(0,q.useCallback)(e=>{d((window.innerWidth-e.clientX)/window.innerWidth*100)},[d]),x=a(eo),{isResizing:S,handleMouseDown:C}=Ns({onResize:b,enabled:r&&!g});(0,q.useEffect)(()=>(x(S),S?(document.body.style.userSelect=`none`,document.body.style.cursor=`ew-resize`,document.body.style.pointerEvents=`none`):(document.body.style.userSelect=``,document.body.style.cursor=``,document.body.style.pointerEvents=``),()=>{document.body.style.userSelect=``,document.body.style.cursor=``,document.body.style.pointerEvents=``}),[S,x]);let w=(0,q.useCallback)(e=>{e.key===`Enter`&&h()},[h]);if(!r)return null;let T=Ks.find(e=>e.id===i)?.label;return(0,J.jsxs)(`div`,{className:U(`fixed bg-background border-border/60 shadow-2xl z-[40] flex flex-col`,g?`left-0 right-0`:`right-0 border-l`),style:{top:`var(--header-height)`,bottom:`0px`,width:g?`100%`:`${o}%`,userSelect:S?`none`:`auto`},children:[g&&(0,J.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 border-b border-border/60 bg-muted/10`,children:[(0,J.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground`,children:T}),(0,J.jsx)(`button`,{type:`button`,onClick:l,className:`w-7 h-7 flex items-center justify-center rounded-md hover:bg-muted text-muted-foreground hover:text-foreground transition-colors`,"aria-label":`Close right panel`,children:(0,J.jsx)(Ce,{className:`w-3.5 h-3.5`})})]}),!g&&(0,J.jsx)(`div`,{className:`absolute left-0 top-0 bottom-0 w-1.5 cursor-ew-resize hover:bg-primary/40 active:bg-primary transition-colors z-10`,style:{pointerEvents:`auto`},onMouseDown:C}),(0,J.jsx)(`div`,{className:U(`flex items-center border-b border-border/60 bg-muted/20`,g?`px-2 py-2`:`px-1.5 py-1`),children:(0,J.jsx)(st,{children:(0,J.jsx)(`div`,{className:U(`flex items-center`,g?`gap-1 w-full justify-between`:`gap-0.5`),children:Ks.map(e=>{let t=e.icon,n=i===e.id,r=(0,J.jsxs)(`button`,{type:`button`,onClick:()=>u(e.id),className:U(`flex items-center justify-center rounded-md transition-all`,g?`w-16 h-10 flex-col gap-0.5`:`w-7 h-7`,n?`bg-background text-foreground shadow-sm border border-border/40`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),"data-testid":`right-panel-tab-${e.id}`,children:[(0,J.jsx)(t,{className:U(g?`w-4 h-4`:`w-3.5 h-3.5`)}),g&&(0,J.jsx)(`span`,{className:`text-[10px] leading-none`,children:e.label})]});return g?(0,J.jsx)(`div`,{children:r},e.id):(0,J.jsxs)(pt,{children:[(0,J.jsx)(ht,{asChild:!0,children:r}),(0,J.jsx)(tt,{side:`bottom`,children:e.label})]},e.id)})})})}),(0,J.jsxs)(`div`,{className:`flex-1 flex flex-col min-h-0 overflow-hidden`,children:[i===`git`&&(0,J.jsx)(`div`,{className:`flex-1 overflow-auto`,children:e}),i===`explorer`&&(0,J.jsx)(`div`,{className:`flex-1 overflow-auto`,children:t}),i===`review`&&(0,J.jsx)(`div`,{className:`flex-1 overflow-auto`,children:n}),i===`browser`&&(0,J.jsx)(Js,{browserUrl:s,inputUrl:c,setInputUrl:f,onReload:m,onUrlKeyDown:w,iframeRef:_})]})]})},Js=({browserUrl:e,inputUrl:t,setInputUrl:n,onReload:r,onUrlKeyDown:i,iframeRef:a})=>(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2 py-1.5 border-b border-border/40 bg-muted/10`,children:[(0,J.jsx)(`button`,{type:`button`,onClick:r,className:`p-1.5 hover:bg-muted rounded-md transition-colors text-muted-foreground hover:text-foreground`,"aria-label":`Reload`,children:(0,J.jsx)(Rt,{className:`w-3.5 h-3.5`})}),(0,J.jsx)(`input`,{type:`text`,value:t,onChange:e=>n(e.target.value),onKeyDown:i,placeholder:`Enter URL and press Enter`,className:`flex-1 px-2.5 py-1.5 bg-background border border-border/60 rounded-md text-xs text-foreground font-mono focus:outline-none focus:ring-2 focus:ring-primary/30 focus:border-primary/50 transition-all`})]}),e!==null&&e!==``?(0,J.jsx)(`iframe`,{ref:a,src:e,className:`flex-1 w-full h-full border-0 bg-white`,title:`Browser Preview`,sandbox:`allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox`}):(0,J.jsx)(`div`,{className:`flex-1 flex items-center justify-center bg-muted/5`,children:(0,J.jsxs)(`div`,{className:`text-center space-y-3 px-8`,children:[(0,J.jsx)(`div`,{className:`w-16 h-16 mx-auto rounded-2xl bg-muted/30 flex items-center justify-center`,children:(0,J.jsx)(Wn,{className:`w-8 h-8 text-muted-foreground/50`})}),(0,J.jsxs)(`div`,{className:`space-y-1`,children:[(0,J.jsx)(`p`,{className:`text-sm font-medium text-muted-foreground`,children:(0,J.jsx)(B,{id:`panel.browser.empty.title`})}),(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground/70`,children:(0,J.jsx)(B,{id:`panel.browser.empty.description`})})]})]})})]}),Ys={ts:`typescript`,tsx:`tsx`,js:`javascript`,jsx:`jsx`,mjs:`javascript`,cjs:`javascript`,json:`json`,jsonc:`json`,md:`markdown`,mdx:`markdown`,py:`python`,rs:`rust`,go:`go`,html:`html`,htm:`html`,css:`css`,scss:`scss`,sass:`sass`,less:`less`,yml:`yaml`,yaml:`yaml`,toml:`toml`,xml:`xml`,sh:`bash`,bash:`bash`,zsh:`bash`,fish:`bash`,ps1:`powershell`,sql:`sql`,graphql:`graphql`,gql:`graphql`,java:`java`,kt:`kotlin`,kts:`kotlin`,scala:`scala`,rb:`ruby`,php:`php`,c:`c`,h:`c`,cpp:`cpp`,cc:`cpp`,cxx:`cpp`,hpp:`cpp`,cs:`csharp`,swift:`swift`,m:`objectivec`,mm:`objectivec`,r:`r`,lua:`lua`,vim:`vim`,dockerfile:`dockerfile`,makefile:`makefile`,cmake:`cmake`,tf:`hcl`,hcl:`hcl`,proto:`protobuf`,prisma:`prisma`,vue:`javascript`,svelte:`javascript`,astro:`javascript`,zig:`zig`,elm:`elm`,ex:`elixir`,exs:`elixir`,erl:`erlang`,hrl:`erlang`,clj:`clojure`,cljs:`clojure`,cljc:`clojure`,hs:`haskell`,lhs:`haskell`,ml:`ocaml`,mli:`ocaml`,fs:`fsharp`,fsx:`fsharp`,fsi:`fsharp`,pl:`perl`,pm:`perl`,nim:`nim`,d:`d`,dart:`dart`,v:`v`,sol:`solidity`,ini:`ini`,cfg:`ini`,conf:`ini`,env:`bash`,gitignore:`text`,editorconfig:`ini`,txt:`text`},Xs=e=>{let t=e.split(`/`).pop()??``,n=t.toLowerCase();if(n===`dockerfile`)return`dockerfile`;if(n===`makefile`)return`makefile`;if(n.startsWith(`.env`))return`bash`;let r=t.lastIndexOf(`.`);return r===-1||r===t.length-1?`text`:Ys[t.slice(r+1).toLowerCase()]??`text`},Zs=new Set([`Write`,`Edit`,`MultiEdit`]),Qs=e=>{if(!Zs.has(e.name))return[];let t=e.input;if(typeof t==`object`&&t&&`file_path`in t){let e=t.file_path;if(typeof e==`string`&&e.length>0)return[e]}return[]},$s=e=>{let t=new Map;for(let n of e){if(n.type===`x-error`||n.type!==`assistant`)continue;let e=n.message.content;if(Array.isArray(e))for(let r of e){if(typeof r==`string`||r.type!==`tool_use`)continue;let e=Qs(r);for(let i of e)t.set(i,{filePath:i,toolName:r.name,toolUseId:r.id,timestamp:n.timestamp})}}return Array.from(t.values())},ec=e=>{if(e==null)return``;if(typeof e==`string`)return e.slice(0,80);if(typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`)return String(e).slice(0,80);if(typeof e!=`object`)return``;let t=e;if(`file_path`in t&&typeof t.file_path==`string`)return t.file_path;if(`command`in t&&typeof t.command==`string`)return t.command.slice(0,80);if(`query`in t&&typeof t.query==`string`)return t.query.slice(0,80);if(`pattern`in t&&typeof t.pattern==`string`)return t.pattern.slice(0,80);if(`url`in t&&typeof t.url==`string`)return t.url;if(`content`in t&&typeof t.content==`string`)return t.content.slice(0,80);let n=Object.keys(t).slice(0,3);return n.length===0?`{}`:n.join(`, `)},tc=e=>{let t=[];for(let n of e){if(n.type===`x-error`||n.type!==`assistant`)continue;let e=n.message.content;if(Array.isArray(e))for(let r of e)typeof r==`string`||r.type!==`tool_use`||t.push({id:r.id,name:r.name,timestamp:n.timestamp,inputSummary:ec(r.input)})}return t},nc=e=>!(`todos`in e)||!Array.isArray(e.todos)?!1:e.todos.every(e=>typeof e==`object`&&!!e&&`content`in e&&typeof e.content==`string`&&`status`in e&&(e.status===`pending`||e.status===`in_progress`||e.status===`completed`)),rc=e=>{let t=null;for(let n of e){if(n.type===`x-error`||n.type!==`assistant`)continue;let e=n.message.content;if(Array.isArray(e))for(let n of e)typeof n==`string`||n.type!==`tool_use`||n.name===`TodoWrite`&&nc(n.input)&&(t=n.input.todos)}return t},ic=/<(?<tag>[^>]+)>(?<content>[\s\S]*?)<\/\k<tag>>/g,ac=I({tag:R(),content:R()});ue([I({kind:ae(`command`),commandName:R(),commandArgs:R().optional(),commandMessage:R().optional()}),I({kind:ae(`local-command`),stdout:R()}),I({kind:ae(`text`),content:R()})]);var oc=e=>{let t=Array.from(e.matchAll(ic)).map(e=>ac.safeParse(e.groups)).filter(e=>e.success).map(e=>e.data);if(t.length===0)return{kind:`text`,content:e};let n=t.find(e=>e.tag===`command-name`)?.content,r=t.find(e=>e.tag===`command-args`)?.content,i=t.find(e=>e.tag===`command-message`)?.content,a=t.find(e=>e.tag===`local-command-stdout`)?.content;switch(!0){case n!==void 0:return{kind:`command`,commandName:n,commandArgs:r,commandMessage:i};case a!==void 0:return{kind:`local-command`,stdout:a};default:return{kind:`text`,content:e}}},sc=e=>{if(e<0)return`0s`;let t=Math.floor(e/1e3),n=Math.floor(t/3600),r=Math.floor(t%3600/60),i=t%60;return n===0&&r===0?`${(e/1e3).toFixed(1)}s`:n===0?i>0?`${r}m ${i}s`:`${r}m`:r>0?`${n}h ${r}m`:`${n}h`},cc=(e,t)=>{let n=new Date(e),r=new Date(t);return Number.isNaN(n.getTime())||Number.isNaN(r.getTime())?null:r.getTime()-n.getTime()},lc=({...e})=>(0,J.jsx)(zr,{"data-slot":`collapsible`,...e}),uc=({...e})=>(0,J.jsx)(Pr,{"data-slot":`collapsible-trigger`,...e}),dc=({...e})=>(0,J.jsx)(Ir,{"data-slot":`collapsible-content`,...e}),fc=e=>{if(e===void 0||e===``)return!1;try{return new URL(e),!0}catch{return!1}},pc=({href:e,children:t})=>{let[n,r]=(0,q.useState)(!1),{openBrowser:i}=Do();return fc(e)?(0,J.jsxs)(`span`,{className:`relative inline-block pr-8 max-w-full break-all`,onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),children:[(0,J.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 break-all`,children:t}),n&&(0,J.jsx)(`button`,{type:`button`,onClick:t=>{t.preventDefault(),t.stopPropagation(),e!==void 0&&e!==``&&i(e)},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:(0,J.jsxs)(`svg`,{className:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,role:`img`,"aria-labelledby":`preview-icon-title`,children:[(0,J.jsx)(`title`,{id:`preview-icon-title`,children:`Preview`}),(0,J.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M15 12a3 3 0 11-6 0 3 3 0 016 0z`}),(0,J.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`})]})})]}):(0,J.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 break-all`,children:t})};G.registerLanguage(`bash`,$t),G.registerLanguage(`sh`,$t),G.registerLanguage(`shell`,$t),G.registerLanguage(`c`,nn),G.registerLanguage(`cpp`,on),G.registerLanguage(`css`,Zt),G.registerLanguage(`diff`,Xt),G.registerLanguage(`go`,un),G.registerLanguage(`java`,tn),G.registerLanguage(`javascript`,Yt),G.registerLanguage(`js`,Yt),G.registerLanguage(`json`,cn),G.registerLanguage(`markdown`,an),G.registerLanguage(`md`,an),G.registerLanguage(`python`,Jt),G.registerLanguage(`py`,Jt),G.registerLanguage(`sql`,en),G.registerLanguage(`tsx`,sn),G.registerLanguage(`typescript`,rn),G.registerLanguage(`ts`,rn),G.registerLanguage(`yaml`,ln),G.registerLanguage(`yml`,ln);var mc=({content:e,className:t=``})=>{let{resolvedTheme:n}=Vt(),a=n===`dark`?qt:Qt,o=(0,q.useMemo)(()=>({h1({children:e,...t}){return(0,J.jsx)(`h1`,{className:`text-3xl font-bold mb-6 mt-8 pb-3 border-b border-border text-foreground`,...t,children:e})},h2({children:e,...t}){return(0,J.jsx)(`h2`,{className:`text-2xl font-semibold mb-4 mt-8 pb-2 border-b border-border/50 text-foreground`,...t,children:e})},h3({children:e,...t}){return(0,J.jsx)(`h3`,{className:`text-xl font-semibold mb-3 mt-6 text-foreground`,...t,children:e})},h4({children:e,...t}){return(0,J.jsx)(`h4`,{className:`text-lg font-medium mb-2 mt-4 text-foreground`,...t,children:e})},h5({children:e,...t}){return(0,J.jsx)(`h5`,{className:`text-base font-medium mb-2 mt-4 text-foreground`,...t,children:e})},h6({children:e,...t}){return(0,J.jsx)(`h6`,{className:`text-sm font-medium mb-2 mt-4 text-muted-foreground`,...t,children:e})},p({children:e,...t}){return(0,J.jsx)(`p`,{className:`mb-4 leading-7 text-foreground break-all`,...t,children:e})},ul({children:e,...t}){return(0,J.jsx)(`ul`,{className:`mb-4 ml-6 list-disc space-y-2`,...t,children:e})},ol({children:e,...t}){return(0,J.jsx)(`ol`,{className:`mb-4 ml-6 list-decimal space-y-2`,...t,children:e})},li({children:e,...t}){return(0,J.jsx)(`li`,{className:`leading-7 text-foreground`,...t,children:e})},code({className:e,children:t,...n}){let r=/language-(\w+)/.exec(e??``);return r?(()=>{let e=typeof t==`string`?t:Array.isArray(t)?t.filter(e=>typeof e==`string`).join(``):``;return(0,J.jsxs)(`div`,{className:`relative my-6`,children:[(0,J.jsx)(`div`,{className:`flex items-center justify-between bg-muted/30 px-4 py-2 border-b border-border rounded-t-lg`,children:(0,J.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:r[1]})}),(0,J.jsx)(G,{style:a,language:r[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:e.replace(/\n$/,``)})]})})():(0,J.jsx)(`code`,{className:`inline-block max-w-full align-middle overflow-hidden rounded-md border bg-muted/70 px-2 py-1 font-mono text-sm text-foreground whitespace-break-spaces break-words [overflow-wrap:anywhere]`,...n,children:t})},pre({children:e,...t}){return(0,J.jsx)(`pre`,{...t,children:e})},blockquote({children:e,...t}){return(0,J.jsx)(`blockquote`,{className:`border-l-4 border-primary/30 bg-muted/30 pl-6 pr-4 py-4 my-6 italic rounded-r-lg`,...t,children:(0,J.jsx)(`div`,{className:`text-muted-foreground`,children:e})})},a({children:e,href:t,...n}){return(0,J.jsx)(pc,{href:t,...n,children:e})},table({children:e,...t}){return(0,J.jsx)(`div`,{className:`overflow-x-auto my-6 rounded-lg border border-border max-w-full`,children:(0,J.jsx)(`table`,{className:`w-full border-collapse`,...t,children:e})})},thead({children:e,...t}){return(0,J.jsx)(`thead`,{className:`bg-muted/50`,...t,children:e})},th({children:e,...t}){return(0,J.jsx)(`th`,{className:`border-b border-border px-4 py-3 text-left font-semibold text-foreground`,...t,children:e})},td({children:e,...t}){return(0,J.jsx)(`td`,{className:`border-b border-border px-4 py-3 text-foreground`,...t,children:e})},hr({...e}){return(0,J.jsx)(`hr`,{className:`my-8 border-t border-border`,...e})},strong({children:e,...t}){return(0,J.jsx)(`strong`,{className:`font-semibold text-foreground`,...t,children:e})},em({children:e,...t}){return(0,J.jsx)(`em`,{className:`italic text-foreground`,...t,children:e})}}),[a]);return(0,J.jsx)(`div`,{className:`prose prose-neutral dark:prose-invert max-w-none ${t}`,children:(0,J.jsx)(r,{remarkPlugins:[i],components:o,children:e})})},hc=({content:e,className:t,placement:n=`user`})=>{let{i18n:r}=Xe(),i=async()=>{try{await navigator.clipboard.writeText(e),z.success(r._({id:`conversation.copy.success`,message:`Message copied`}))}catch(e){console.error(`Failed to copy message:`,e),z.error(r._({id:`conversation.copy.failed`,message:`Failed to copy message`}))}},a=r._({id:`conversation.copy`,message:`Copy message`});return(0,J.jsxs)(`div`,{className:`group relative`,children:[(0,J.jsx)(mc,{content:e,className:t}),(0,J.jsx)(`div`,{className:U(`pointer-events-none absolute`,{"right-2 bottom-6":n===`user`,"right-0 bottom-0 translate-x-1":n===`assistant`}),children:(0,J.jsx)(H,{type:`button`,variant:`ghost`,size:`icon`,className:`pointer-events-auto h-7 w-7 bg-background/85 opacity-0 shadow-sm transition-opacity group-hover:opacity-100 group-focus-within:opacity-100 backdrop-blur supports-[backdrop-filter]:bg-background/70`,onClick:()=>{i()},"aria-label":a,title:a,children:(0,J.jsx)(Nn,{className:`h-3.5 w-3.5`})})})]})},gc=({...e})=>(0,J.jsx)(Ca,{...e}),_c=({...e})=>(0,J.jsx)(Ta,{...e}),vc=({className:e,children:t,...n})=>(0,J.jsxs)(wa,{className:U(`flex h-10 w-full items-center justify-between rounded-md border bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1`,e),...n,children:[t,(0,J.jsx)(Ea,{asChild:!0,children:(0,J.jsx)(K,{className:`h-4 w-4 opacity-50`})})]}),yc=({className:e,...t})=>(0,J.jsx)(Na,{className:U(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,J.jsx)(bn,{className:`h-4 w-4`})}),bc=({className:e,...t})=>(0,J.jsx)(Pa,{className:U(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,J.jsx)(K,{className:`h-4 w-4`})}),xc=({className:e,children:t,position:n=`popper`,...r})=>(0,J.jsx)(Da,{children:(0,J.jsxs)(Oa,{className:U(`relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,n===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),position:n,...r,children:[(0,J.jsx)(yc,{}),(0,J.jsx)(ka,{className:U(`p-1`,n===`popper`&&`h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]`),children:t}),(0,J.jsx)(bc,{})]})}),X=({className:e,children:t,...n})=>(0,J.jsxs)(Aa,{className:U(`relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,e),...n,children:[(0,J.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,J.jsx)(Ma,{children:(0,J.jsx)(_t,{className:`h-4 w-4`})})}),(0,J.jsx)(ja,{children:t})]}),Sc=({projectId:e,filePaths:t,children:n})=>{let[r,i]=(0,q.useState)(!1),[a,o]=(0,q.useState)(0),{resolvedTheme:s}=Vt(),c=s===`dark`?qt:Qt,l=t[a]??t[0],u=e=>{i(e),e||o(0)},{data:d,isLoading:f,error:p,refetch:m}=we({...b(e,l??``),enabled:r&&l!==void 0}),h=l?.split(`/`).pop()??l??``,g=d?.success===!0?d.language:Xs(l??``),_=t.length>1;return(0,J.jsxs)(Be,{open:r,onOpenChange:u,children:[(0,J.jsx)(Me,{asChild:!0,children:n??(0,J.jsxs)(H,{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":`file-content-button`,children:[(0,J.jsx)(yt,{className:`h-3 w-3`}),(0,J.jsx)(B,{id:`assistant.tool.view_file`})]})}),(0,J.jsxs)(Ue,{className:`w-[95vw] md:w-[90vw] lg:w-[85vw] max-w-[1200px] h-[85vh] max-h-[85vh] flex flex-col p-0`,"data-testid":`file-content-dialog`,children:[(0,J.jsx)(We,{className:`px-6 py-4 border-b bg-muted/30`,children:(0,J.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,J.jsx)(`div`,{className:`flex-shrink-0 mt-1`,children:(0,J.jsx)(`div`,{className:`h-10 w-10 rounded-lg bg-primary/10 flex items-center justify-center`,children:(0,J.jsx)(Ln,{className:`h-5 w-5 text-primary`})})}),(0,J.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,J.jsx)(Ae,{className:`text-lg font-semibold leading-tight mb-1 pr-8 break-all`,children:h}),(0,J.jsx)(ke,{className:`text-xs flex items-center gap-2 flex-wrap`,asChild:!0,children:(0,J.jsxs)(`div`,{children:[_?(0,J.jsxs)(gc,{value:String(a),onValueChange:e=>o(Number(e)),children:[(0,J.jsx)(vc,{className:`h-7 text-[10px] font-mono max-w-[400px]`,"data-testid":`file-selector`,children:(0,J.jsx)(_c,{})}),(0,J.jsx)(xc,{children:t.map((e,t)=>(0,J.jsx)(X,{value:String(t),className:`text-[10px] font-mono`,children:e},e))})]}):(0,J.jsx)(`code`,{className:`px-1.5 py-0.5 bg-muted rounded text-[10px] font-mono break-all`,children:l}),d?.success===!0&&d.truncated&&(0,J.jsx)(Y,{variant:`secondary`,className:`text-[10px]`,children:(0,J.jsx)(B,{id:`assistant.tool.file_truncated`})})]})})]})]})}),(0,J.jsxs)(`div`,{className:`flex-1 overflow-auto`,children:[f&&(0,J.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-4`,children:[(0,J.jsx)(A,{className:`h-8 w-8 animate-spin text-primary`}),(0,J.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:(0,J.jsx)(B,{id:`assistant.tool.loading_file`})})]}),p&&(0,J.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-4 px-6`,children:[(0,J.jsx)(Ft,{className:`h-8 w-8 text-destructive`}),(0,J.jsx)(`p`,{className:`text-sm text-destructive text-center`,children:(0,J.jsx)(B,{id:`assistant.tool.error_loading_file`})}),(0,J.jsx)(H,{variant:`outline`,size:`sm`,onClick:()=>{m()},children:(0,J.jsx)(B,{id:`assistant.tool.retry`})})]}),d&&!d.success&&(0,J.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-4 px-6`,children:[(0,J.jsx)(Ft,{className:`h-8 w-8 text-destructive`}),(0,J.jsxs)(`p`,{className:`text-sm text-destructive text-center`,children:[d.error===`NOT_FOUND`&&(0,J.jsx)(B,{id:`assistant.tool.file_not_found`}),d.error===`BINARY_FILE`&&(0,J.jsx)(B,{id:`assistant.tool.binary_file`}),d.error===`INVALID_PATH`&&(0,J.jsx)(B,{id:`assistant.tool.invalid_path`}),d.error===`READ_ERROR`&&(0,J.jsx)(B,{id:`assistant.tool.read_error`})]}),d.message&&(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground text-center max-w-md`,children:d.message})]}),d?.success===!0&&(0,J.jsx)(dn,{style:c,language:g,showLineNumbers:!0,wrapLines:!0,customStyle:{margin:0,borderRadius:0,fontSize:`0.75rem`,minHeight:`100%`},lineNumberStyle:{minWidth:`3em`,paddingRight:`1em`,textAlign:`right`,userSelect:`none`},children:d.content})]})]})]})},Cc=e=>{let t=I({type:ae(`user`),message:I({content:ue([R(),ve(ue([R(),I({type:ae(`text`),text:R()})]))])})}).safeParse(e);if(!t.success)return null;let n=t.data.message.content;return typeof n==`string`?n:(()=>{if(!Array.isArray(n))return null;let e=n.at(0);return e===void 0?null:typeof e==`string`?e:e.type===`text`?e.text:null})()},wc=({prompt:e,projectId:t,sessionId:n,agentId:r,getSidechainConversationByAgentId:i,getSidechainConversationByPrompt:a,getSidechainConversations:o,getToolResult:s})=>{let[c,l]=(0,q.useState)(!1),u=(0,q.useRef)(null),d=(r===void 0?void 0:i(r))??a(e),f=d===void 0?[]:o(d.uuid),p=f.length>0,m=c&&!p&&r!==void 0,{data:h,isLoading:g,error:_,refetch:v}=we({...C(t,r??``,n),enabled:m,staleTime:0}),y=p?f.map(e=>({...e,isSidechain:!1})):h?.conversations??[],b=p?void 0:h?.agentSessionId,x=p?d?.uuid:b,S=(()=>{let t=y.at(0);return t?Cc(t)??e:e.length>60?`${e.slice(0,60)}...`:e})(),w=m&&g,T=m&&_!==null,E=!w&&!T&&y.length===0&&c,D=!w&&!T&&y.length>0,O=y.find(e=>e.type===`user`||e.type===`assistant`||e.type===`system`);return(0,J.jsxs)(Be,{open:c,onOpenChange:l,children:[(0,J.jsx)(Me,{asChild:!0,children:(0,J.jsxs)(H,{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:[(0,J.jsx)(yt,{className:`h-3 w-3`}),(0,J.jsx)(B,{id:`assistant.tool.view_task_details`})]})}),(0,J.jsxs)(Ue,{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:[(0,J.jsx)(We,{className:`px-6 py-4 border-b bg-muted/30`,children:(0,J.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,J.jsx)(`div`,{className:`flex-shrink-0 mt-1`,children:(0,J.jsx)(`div`,{className:`h-10 w-10 rounded-lg bg-primary/10 flex items-center justify-center`,children:(0,J.jsx)(_e,{className:`h-5 w-5 text-primary`})})}),(0,J.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,J.jsx)(Ae,{className:`text-lg font-semibold leading-tight mb-1 pr-2`,children:S.length>120?`${S.slice(0,120)}...`:S}),(0,J.jsxs)(ke,{className:`text-xs flex items-center gap-2 flex-wrap`,children:[x!=null&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,J.jsx)(B,{id:`assistant.tool.task_id`}),`:`,` `,(0,J.jsx)(`code`,{className:`px-1.5 py-0.5 bg-muted rounded text-[10px] font-mono`,children:x.slice(0,8)})]}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`|`})]}),(0,J.jsx)(`span`,{children:(0,J.jsx)(B,{id:`assistant.tool.message_count`,values:{count:y.length}})})]})]})]})}),(0,J.jsxs)(`div`,{ref:u,className:`flex-1 overflow-auto px-6 py-4`,children:[w&&(0,J.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-4`,children:[(0,J.jsx)(A,{className:`h-8 w-8 animate-spin text-primary`}),(0,J.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:(0,J.jsx)(B,{id:`assistant.tool.loading_task`})})]}),T&&(0,J.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-4`,children:[(0,J.jsx)(Dn,{className:`h-8 w-8 text-destructive`}),(0,J.jsx)(`p`,{className:`text-sm text-destructive`,children:(0,J.jsx)(B,{id:`assistant.tool.error_loading_task`})}),(0,J.jsx)(H,{variant:`outline`,size:`sm`,onClick:()=>{v()},children:(0,J.jsx)(B,{id:`assistant.tool.retry`})})]}),E&&(0,J.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-4`,children:[(0,J.jsx)(Y,{variant:`secondary`,className:`text-sm`,children:(0,J.jsx)(B,{id:`assistant.tool.no_task_data`})}),(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground max-w-md text-center`,children:(0,J.jsx)(B,{id:`assistant.tool.no_task_data_description`})})]}),D&&(0,J.jsx)(su,{conversations:[...p?[]:[{type:`user`,message:{role:`user`,content:e},isSidechain:!1,userType:`external`,cwd:O?.cwd??`dummy`,sessionId:n,version:O?.version??`dummy`,uuid:`dummy`,timestamp:O?.timestamp??`dummy`,parentUuid:null,isMeta:!1,toolUseResult:void 0,gitBranch:O?.gitBranch??`dummy`,isCompactSummary:!1}],...y.map(e=>({...e,isSidechain:!1}))],getToolResult:s,projectId:t,sessionId:n,scheduledJobs:[],scrollContainerRef:u})]})]})]})},Tc=({input:e})=>{let t=Object.entries(e);return t.length===0?null:(0,J.jsx)(`span`,{children:t.map(([e,t],n)=>{let r=typeof t==`string`?t:JSON.stringify(t).replace(/^"|"$/g,``);return(0,J.jsxs)(`span`,{children:[n>0&&(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`, `}),(0,J.jsxs)(`span`,{className:`text-muted-foreground`,children:[e,`=`]}),(0,J.jsx)(`span`,{children:r})]},e)})})},Ec=I({command:R(),description:R().optional()}),Dc=I({stdout:R(),stderr:R(),interrupted:Ye()}),Oc=({input:e,toolUseResult:t})=>{let n=Ec.safeParse(e);if(!n.success)return null;let r=Dc.safeParse(t);return(0,J.jsxs)(`div`,{className:`font-mono text-xs rounded bg-gray-900 dark:bg-gray-950 text-gray-100 overflow-hidden`,children:[(0,J.jsxs)(`div`,{className:`px-3 py-2 bg-gray-800 dark:bg-gray-900 border-b border-gray-700 flex items-start gap-2`,children:[(0,J.jsx)(`span`,{className:`text-green-400 select-none flex-shrink-0`,children:`$`}),(0,J.jsx)(`span`,{className:`whitespace-pre-wrap break-all`,children:n.data.command})]}),r.success&&r.data.stdout&&(0,J.jsx)(`div`,{className:`px-3 py-2 whitespace-pre-wrap break-words max-h-96 overflow-y-auto`,children:r.data.stdout}),r.success&&r.data.stderr&&(0,J.jsx)(`div`,{className:`px-3 py-2 text-red-400 border-t border-gray-700 whitespace-pre-wrap break-words max-h-48 overflow-y-auto`,children:r.data.stderr}),r.success&&r.data.interrupted&&(0,J.jsx)(`div`,{className:`px-3 py-1 text-yellow-400 border-t border-gray-700 text-xs`,children:`Process interrupted`}),!r.success&&t===void 0&&(0,J.jsx)(`div`,{className:`px-3 py-2 text-gray-500 animate-pulse`,children:`Running...`})]})},kc=I({label:R(),description:R(),preview:R().optional()}),Ac=I({questions:ve(I({question:R(),header:R(),options:ve(kc),multiSelect:Ye().optional()}))}),jc=I({content:ue([R(),ve(I({type:ae(`text`),text:R()}))])}),Mc=xe(R(),R()),Nc=e=>{if(e==null)return{};if(typeof e==`string`){try{let t=JSON.parse(e),n=Mc.safeParse(t);if(n.success)return n.data}catch{}return{}}let t=jc.safeParse(e);if(!t.success)return{};let{content:n}=t.data;if(typeof n==`string`)return Nc(n);for(let e of n){let t=Nc(e.text);if(Object.keys(t).length>0)return t}return{}},Pc=({input:e,output:t})=>{let n=(0,q.useMemo)(()=>Nc(t),[t]),r=Ac.safeParse(e);return r.success?(0,J.jsx)(`div`,{className:`space-y-3`,children:r.data.questions.map(e=>{let r=n[e.question];return(0,J.jsxs)(`div`,{className:`rounded border border-gray-200 dark:border-gray-700 overflow-hidden`,children:[(0,J.jsxs)(`div`,{className:`px-3 py-2 bg-gray-50 dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`span`,{className:`text-xs font-medium px-1.5 py-0.5 rounded bg-purple-100 dark:bg-purple-900/50 text-purple-700 dark:text-purple-300`,children:e.header}),e.multiSelect===!0&&(0,J.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`(multiple)`})]}),(0,J.jsx)(`p`,{className:`text-sm mt-1`,children:e.question})]}),(0,J.jsx)(`div`,{className:`divide-y divide-gray-100 dark:divide-gray-800`,children:e.options.map(e=>{let t=r===e.label;return(0,J.jsxs)(`div`,{className:`px-3 py-2 ${t?`bg-green-50 dark:bg-green-950/30 border-l-2 border-l-green-500`:``}`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`span`,{className:`text-sm font-medium ${t?`text-green-700 dark:text-green-300`:``}`,children:e.label}),t&&(0,J.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded bg-green-100 dark:bg-green-900/50 text-green-700 dark:text-green-300`,children:`Selected`})]}),(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:e.description}),e.preview!==void 0&&e.preview!==``&&(0,J.jsxs)(lc,{children:[(0,J.jsxs)(uc,{className:`flex items-center gap-1 text-xs text-blue-600 dark:text-blue-400 mt-1 hover:underline group`,children:[`Preview`,(0,J.jsx)(K,{className:`h-3 w-3 transition-transform group-data-[state=open]:rotate-180`})]}),(0,J.jsx)(dc,{children:(0,J.jsx)(`pre`,{className:`mt-1 text-xs bg-gray-100 dark:bg-gray-800 rounded p-2 overflow-x-auto whitespace-pre-wrap break-words`,children:e.preview})})]})]},e.label)})}),(r===void 0||r===``)&&t===void 0&&(0,J.jsx)(`div`,{className:`px-3 py-2 text-xs text-muted-foreground animate-pulse border-t border-gray-200 dark:border-gray-700`,children:`Waiting for answer...`})]},e.question)})}):null},Fc=Symbol(``),Ic=e=>typeof e?.then==`function`;function Lc(e=()=>{try{return window.localStorage}catch{return}},t){let n,r,i={getItem:(i,a)=>{let o=e=>{if(e||=``,n!==e){try{r=JSON.parse(e,t?.reviver)}catch{return a}n=e}return r},s=e()?.getItem(i)??null;return Ic(s)?s.then(o):o(s)},setItem:(n,r)=>e()?.setItem(n,JSON.stringify(r,t?.replacer)),removeItem:t=>e()?.removeItem(t)},a=e=>(t,n,r)=>e(t,e=>{let t;try{t=JSON.parse(e||``)}catch{t=r}n(t)}),o;try{o=e()?.subscribe}catch{}return!o&&typeof window<`u`&&typeof window.addEventListener==`function`&&window.Storage&&(o=(t,n)=>{if(!(e()instanceof window.Storage))return()=>{};let r=r=>{r.storageArea===e()&&r.key===t&&n(r.newValue)};return window.addEventListener(`storage`,r),()=>{window.removeEventListener(`storage`,r)}}),o&&(i.subscribe=a(o)),i}var Rc=Lc();function zc(e,t,n=Rc,r){let i=u(r?.getOnInit?n.getItem(e,t):t);return i.onMount=r=>(r(n.getItem(e,t)),n.subscribe?.call(n,e,r,t)),u(e=>e(i),(r,a,o)=>{let s=typeof o==`function`?o(r(i)):o;return s===Fc?(a(i,t),n.removeItem(e)):Ic(s)?s.then(t=>(a(i,t),n.setItem(e,t))):(a(i,s),n.setItem(e,s))})}var Bc=me([`added`,`deleted`,`unchanged`,`hunk`,`context`]),Vc=I({id:R(),filename:R(),lineNumber:Se(),lineType:Bc,content:R(),createdAt:Se()}),Hc=xe(R(),ve(Vc)),Uc=(e,t)=>{let n=Hc.safeParse(e);return n.success?n.data:t},Wc=(e,t,n)=>({...e,[t]:[...e[t]??[],n]}),Gc=(e,t,n)=>{let r=(e[t]??[]).filter(e=>e.id!==n);if(r.length===0){let{[t]:n,...r}=e;return r}return{...e,[t]:r}},Kc=(e,t)=>{let{[t]:n,...r}=e;return r},qc=Lc(()=>localStorage),Jc=zc(`claude-code-viewer-review-comments`,{},{getItem:(e,t)=>Uc(qc.getItem(e,t),t),setItem:(e,t)=>qc.setItem(e,t),removeItem:e=>qc.removeItem(e)}),Yc=e=>{let[t,n]=f(Jc);return{comments:(0,q.useMemo)(()=>t[e]??[],[t,e]),addComment:(0,q.useCallback)(t=>{let r={...t,id:crypto.randomUUID(),createdAt:Date.now()};n(t=>Wc(t,e,r))},[e,n]),removeComment:(0,q.useCallback)(t=>{n(n=>Gc(n,e,t))},[e,n]),clearComments:(0,q.useCallback)(()=>{n(t=>Kc(t,e))},[e,n])}},Xc=(e,t,n)=>{if(e.length===0)return`## Review: ${t} vs ${n}`;let r=new Map;for(let t of e){let e=r.get(t.filename)??[];e.push(t),r.set(t.filename,e)}return`## Review: ${t} vs ${n}\n\n${[...r.keys()].sort().flatMap(e=>[...r.get(e)??[]].sort((e,t)=>e.lineNumber-t.lineNumber).map(e=>`### ${e.filename} (L${e.lineNumber})\n${e.content}`)).join(`
2
-
3
- `)}`},Zc=({className:e,...t})=>(0,J.jsx)(`textarea`,{"data-slot":`textarea`,className:U(`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),...t}),Qc=`[font-family:"Fira_Code","Fira_Mono",Menlo,Consolas,"DejaVu_Sans_Mono",monospace]`,$c=e=>U({"bg-green-50 dark:bg-green-950/30":e===`added`,"bg-red-50 dark:bg-red-950/30":e===`deleted`,"bg-blue-50 dark:bg-blue-950/30":e===`hunk`,"bg-white dark:bg-gray-900":e===`unchanged`||e===`context`}),el=e=>U({"bg-green-50 dark:bg-green-950":e===`added`,"bg-red-50 dark:bg-red-950":e===`deleted`,"bg-blue-50 dark:bg-blue-950":e===`hunk`,"bg-white dark:bg-gray-900":e===`unchanged`||e===`context`}),tl=e=>e.newLineNumber??e.oldLineNumber??0,nl=({reviewProps:e,line:t,onClose:n})=>{let[r,i]=(0,q.useState)(``),{addComment:a}=Yc(e.reviewSessionId),{i18n:o}=Xe(),s=()=>{r.trim()!==``&&(a({filename:e.filename,lineNumber:tl(t),lineType:t.type,content:r.trim()}),i(``),n())};return(0,J.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,J.jsx)(Zc,{value:r,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),s())},placeholder:o._(`review.comment.placeholder`),className:`min-h-[72px] border-0 bg-transparent px-2.5 text-[13px] leading-relaxed shadow-none ring-0 placeholder:text-muted-foreground/50 focus-visible:ring-0`}),(0,J.jsxs)(`div`,{className:`flex items-center justify-between border-t border-border/40 pt-2`,children:[(0,J.jsx)(`span`,{className:`text-[10px] text-muted-foreground/50`,children:`⌘ + Enter`}),(0,J.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,J.jsx)(H,{variant:`ghost`,size:`sm`,onClick:n,className:`h-7 w-7 p-0 text-muted-foreground hover:text-foreground`,children:(0,J.jsx)(Ce,{className:`h-3.5 w-3.5`})}),(0,J.jsxs)(H,{size:`sm`,onClick:s,disabled:r.trim()===``,className:`h-7 gap-1 rounded-full px-3 text-[11px] font-medium`,children:[(0,J.jsx)(fr,{className:`h-3 w-3`}),(0,J.jsx)(B,{id:`review.comment.save`})]})]})]})]})},rl=({comment:e,onRemove:t})=>(0,J.jsxs)(`div`,{className:`group/comment relative rounded-md border border-border/50 bg-muted/30 px-2.5 py-2 transition-colors hover:border-border`,children:[(0,J.jsx)(`p`,{className:`pr-5 text-[13px] leading-relaxed text-foreground/90`,children:e.content}),(0,J.jsx)(`button`,{type:`button`,onClick:()=>t(e.id),className:`absolute right-1.5 top-1.5 rounded p-0.5 text-muted-foreground/40 opacity-0 transition-all hover:bg-destructive/10 hover:text-destructive group-hover/comment:opacity-100`,children:(0,J.jsx)(vr,{className:`h-3 w-3`})})]}),il=({reviewProps:e,line:t,lineComments:n,onRemoveComment:r})=>{let[i,a]=(0,q.useState)(!1),o=n.length>0;return(0,J.jsxs)(ot,{open:i,onOpenChange:a,children:[(0,J.jsx)(ut,{asChild:!0,children:(0,J.jsx)(`button`,{type:`button`,className:U(`absolute left-0.5 top-px z-10 flex items-center rounded-sm transition-all`,o?`opacity-100`:`opacity-0 group-hover:opacity-100`),children:o?(0,J.jsx)(`span`,{className:`flex h-[18px] min-w-[18px] items-center justify-center rounded-full bg-sky-500 px-1 text-[10px] font-semibold tabular-nums text-white shadow-sm shadow-sky-500/25`,children:n.length}):(0,J.jsx)(`span`,{className:`flex h-[18px] w-[18px] items-center justify-center rounded-sm text-muted-foreground/60 transition-colors hover:bg-primary/10 hover:text-primary`,children:(0,J.jsx)(Qn,{className:`h-3.5 w-3.5`})})})}),(0,J.jsxs)($e,{side:`right`,align:`start`,className:`w-80 overflow-hidden rounded-xl border-border/50 p-0 shadow-xl shadow-black/5 dark:shadow-black/20`,children:[o&&(0,J.jsx)(`div`,{className:`space-y-1.5 border-b border-border/40 bg-muted/20 p-3`,children:n.map(e=>(0,J.jsx)(rl,{comment:e,onRemove:r},e.id))}),(0,J.jsx)(`div`,{className:`p-3`,children:(0,J.jsx)(nl,{reviewProps:e,line:t,onClose:()=>a(!1)})})]})]})},al=({hunk:e})=>(0,J.jsx)(`div`,{className:`w-20 shrink-0`,children:(0,J.jsx)(`div`,{children:e.lines.map(e=>(0,J.jsxs)(`div`,{className:U(`grid grid-cols-[2.5rem_2.5rem] border-r border-l-4`,Qc,el(e.type),{"border-green-200 border-l-green-400 dark:border-green-800/50":e.type===`added`,"border-red-200 border-l-red-400 dark:border-red-800/50":e.type===`deleted`,"border-blue-200 border-l-blue-400 dark:border-blue-800/50":e.type===`hunk`,"border-gray-200 border-l-transparent dark:border-gray-700":e.type===`unchanged`||e.type===`context`}),children:[(0,J.jsx)(`div`,{className:`border-r px-1 py-0.5 text-right text-xs leading-tight tabular-nums border-gray-200 dark:border-gray-700`,children:e.type!==`added`&&e.type!==`hunk`&&e.oldLineNumber!==void 0?e.oldLineNumber:`\xA0`}),(0,J.jsx)(`div`,{className:`px-1 py-0.5 text-right text-xs leading-tight tabular-nums`,children:e.type!==`deleted`&&e.type!==`hunk`&&e.newLineNumber!==void 0?e.newLineNumber:`\xA0`})]},`gutter-${e.oldLineNumber??``}-${e.newLineNumber??``}`))})}),ol=({hunks:e,reviewProps:t,commentsByLine:n,onRemoveComment:r})=>(0,J.jsx)(J.Fragment,{children:e.map(e=>(0,J.jsx)(`div`,{children:e.lines.map(i=>{let a=tl(i),o=n?.get(a)??[];return(0,J.jsx)(`div`,{"data-slot":`diff-row`,className:U(`relative min-w-full border-l-4`,$c(i.type),{"border-green-200 border-l-green-400 dark:border-green-800/50":i.type===`added`,"border-red-200 border-l-red-400 dark:border-red-800/50":i.type===`deleted`,"border-blue-200 border-l-blue-400 dark:border-blue-800/50":i.type===`hunk`,"border-gray-100 border-l-transparent dark:border-gray-800":i.type===`unchanged`||i.type===`context`},t!==void 0&&i.type!==`hunk`&&`group`),children:(0,J.jsxs)(`div`,{"data-slot":`diff-row-content`,className:U(`relative min-w-0 px-2 py-0.5 pl-7 text-xs leading-tight whitespace-pre`,Qc),children:[t!==void 0&&i.type!==`hunk`&&r!==void 0&&(0,J.jsx)(il,{reviewProps:t,line:i,lineComments:o,onRemoveComment:r}),(0,J.jsx)(`span`,{"data-slot":`diff-sign`,className:U(`absolute left-2 top-0.5 w-4 text-center`,{"text-green-600 dark:text-green-400":i.type===`added`,"text-red-600 dark:text-red-400":i.type===`deleted`,"font-medium text-blue-600 dark:text-blue-400":i.type===`hunk`,"text-gray-400 dark:text-gray-600":i.type===`unchanged`||i.type===`context`}),children:i.type===`added`?`+`:i.type===`deleted`?`-`:i.type===`hunk`?`@`:`\xA0`}),(0,J.jsx)(`span`,{className:`inline-block w-max min-w-full pr-4`,children:i.content||` `})]})},`content-${e.oldStart}-${e.newStart}-${i.oldLineNumber??``}-${i.newLineNumber??``}`)})},`${e.oldStart}-${e.newStart}`))}),sl=({hunks:e,reviewProps:t,commentsByLine:n,onRemoveComment:r})=>(0,J.jsxs)(`div`,{className:`relative flex`,children:[(0,J.jsx)(`div`,{className:`w-20 shrink-0`,children:e.map(e=>(0,J.jsx)(al,{hunk:e},`${e.oldStart}-${e.newStart}`))}),(0,J.jsx)(`div`,{className:`min-w-0 flex-1 overflow-x-auto`,children:(0,J.jsx)(`div`,{className:`inline-block w-max min-w-full align-top`,children:(0,J.jsx)(ol,{hunks:e,reviewProps:t,commentsByLine:n,onRemoveComment:r})})})]}),cl=({fileDiff:e,isCollapsed:t,onToggleCollapse:n})=>{let r=()=>e.isNew?(0,J.jsx)(`span`,{className:`text-green-600 dark:text-green-400`,children:`A`}):e.isDeleted?(0,J.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:`D`}):e.isRenamed?(0,J.jsx)(`span`,{className:`text-blue-600 dark:text-blue-400`,children:`R`}):(0,J.jsx)(`span`,{className:`text-gray-600 dark:text-gray-400`,children:`M`}),i=async t=>{t.stopPropagation();try{await navigator.clipboard.writeText(e.filename),z.success(`ファイル名をコピーしました`)}catch(e){console.error(`Failed to copy filename:`,e),z.error(`ファイル名のコピーに失敗しました`)}};return(0,J.jsxs)(`div`,{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:[(0,J.jsx)(`button`,{type:`button`,onClick:n,className:`w-full text-left`,"aria-expanded":!t,children:(0,J.jsxs)(`div`,{className:`w-full flex items-center gap-2 pr-8`,children:[t?(0,J.jsx)(et,{className:`w-4 h-4 text-gray-500 flex-shrink-0`}):(0,J.jsx)(K,{className:`w-4 h-4 text-gray-500 flex-shrink-0`}),(0,J.jsx)(`div`,{className:U(`w-5 h-5 rounded-full bg-gray-100 dark:bg-gray-700 flex items-center justify-center text-xs flex-shrink-0`,Qc),children:r()}),(0,J.jsx)(`span`,{className:U(`text-xs font-medium text-black dark:text-white text-left truncate flex-1 min-w-0`,Qc),children:e.filename}),(0,J.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-gray-500 dark:text-gray-400 flex-shrink-0`,children:[e.linesAdded>0&&(0,J.jsxs)(`span`,{className:`text-green-600 dark:text-green-400`,children:[`+`,e.linesAdded]}),e.linesDeleted>0&&(0,J.jsxs)(`span`,{className:`text-red-600 dark:text-red-400`,children:[`-`,e.linesDeleted]})]})]})}),(0,J.jsx)(H,{type:`button`,onClick:e=>{i(e)},variant:`ghost`,size:`sm`,className:`absolute right-3 top-1/2 h-5 w-5 -translate-y-1/2 p-1 hover:bg-gray-200 dark:hover:bg-gray-600`,children:(0,J.jsx)(Nn,{className:`w-3 h-3 text-gray-500 dark:text-gray-400`})}),e.isBinary&&(0,J.jsx)(`div`,{className:`mt-2 text-xs text-gray-500 dark:text-gray-400 text-left`,children:`Binary file (content not shown)`})]})},ll=(e,t)=>{let{comments:n,addComment:r,removeComment:i,clearComments:a}=Yc(e??``);return{commentsByLine:(0,q.useMemo)(()=>{if(t===void 0)return new Map;let e=new Map;for(let r of n){if(r.filename!==t)continue;let n=e.get(r.lineNumber);n===void 0?e.set(r.lineNumber,[r]):n.push(r)}return e},[n,t]),addComment:r,removeComment:i,clearComments:a}},ul=(0,q.memo)(({fileDiff:e,className:t,filename:n,reviewSessionId:r})=>{let[i,a]=(0,q.useState)(!1),o=n!==void 0&&r!==void 0,{commentsByLine:s,removeComment:c}=ll(r,n),l=o?{filename:n,reviewSessionId:r}:void 0,u=()=>{a(!i)};return e.isBinary?(0,J.jsxs)(`div`,{className:U(`overflow-hidden border border-gray-200 dark:border-gray-700 rounded-lg`,t),children:[(0,J.jsx)(cl,{fileDiff:e,isCollapsed:i,onToggleCollapse:u}),!i&&(0,J.jsx)(`div`,{className:`text-center py-8 text-gray-500 dark:text-gray-400 text-sm`,children:`Binary file cannot be displayed`})]}):(0,J.jsxs)(`div`,{className:U(`overflow-hidden border border-gray-200 dark:border-gray-700 rounded-lg`,t),children:[(0,J.jsx)(cl,{fileDiff:e,isCollapsed:i,onToggleCollapse:u}),!i&&(0,J.jsx)(`div`,{className:`border-t border-gray-200 dark:border-gray-700`,children:(0,J.jsx)(sl,{hunks:e.hunks,reviewProps:l,commentsByLine:s,onRemoveComment:c})})]})});ul.displayName=`DiffViewer`;var dl=I({file_path:R()}),fl=ve(I({oldStart:Se(),oldLines:Se(),newStart:Se(),newLines:Se(),lines:ve(R())})),pl=I({filePath:R(),structuredPatch:fl}),ml=e=>e.map(e=>{let t=e.oldStart,n=e.newStart,r=e.lines.map(e=>{let r=e[0],i=e.slice(1);if(r===`-`){let e={type:`deleted`,oldLineNumber:t,content:i};return t++,e}if(r===`+`){let e={type:`added`,newLineNumber:n,content:i};return n++,e}let a={type:`unchanged`,oldLineNumber:t,newLineNumber:n,content:i};return t++,n++,a});return{oldStart:e.oldStart,newStart:e.newStart,lines:r}}),hl=({input:e,toolUseResult:t})=>{let n=dl.safeParse(e);if(!n.success)return null;let r=pl.safeParse(t);if(!r.success)return(0,J.jsxs)(`div`,{className:`rounded border border-gray-200 dark:border-gray-700`,children:[(0,J.jsx)(`div`,{className:`px-3 py-2 bg-gray-50 dark:bg-gray-800 font-mono text-xs font-medium`,children:n.data.file_path}),t===void 0&&(0,J.jsx)(`div`,{className:`px-3 py-4 text-xs text-muted-foreground animate-pulse text-center`,children:`Applying edit...`})]});let i=ml(r.data.structuredPatch),a=0,o=0;for(let e of i)for(let t of e.lines)t.type===`added`&&a++,t.type===`deleted`&&o++;return(0,J.jsx)(ul,{fileDiff:{filename:r.data.filePath,isNew:!1,isDeleted:!1,isRenamed:!1,isBinary:!1,hunks:i,linesAdded:a,linesDeleted:o}})},gl=I({file_path:R()}),_l=e=>{let t=e.split(`
4
- `),n=[];for(let e of t){let t=/^\s*(\d+)\t(.*)$/.exec(e);t&&t[1]!==void 0&&t[2]!==void 0&&n.push({lineNumber:Number.parseInt(t[1],10),content:t[2]})}let r=n[0];return r?{startLine:r.lineNumber,code:n.map(e=>e.content).join(`
5
- `)}:null},vl=I({content:R()}),yl=I({content:ve(I({type:ae(`text`),text:R()}))}),bl=e=>{if(e==null)return null;let t=vl.safeParse(e);if(t.success)return t.data.content;let n=yl.safeParse(e);if(n.success){let e=n.data.content[0];if(e)return e.text}return null},xl=({input:e,output:t})=>{let{resolvedTheme:n}=Vt(),r=n===`dark`?qt:Qt,i=gl.safeParse(e);if(!i.success)return null;let a=bl(t);if(a===null)return(0,J.jsxs)(`div`,{className:`rounded border border-gray-200 dark:border-gray-700`,children:[(0,J.jsx)(`div`,{className:`px-3 py-2 bg-gray-50 dark:bg-gray-800 font-mono text-xs font-medium`,children:i.data.file_path}),t===void 0&&(0,J.jsx)(`div`,{className:`px-3 py-4 text-xs text-muted-foreground animate-pulse text-center`,children:`Reading file...`})]});let o=_l(a);if(!o)return null;let s=Xs(i.data.file_path);return(0,J.jsxs)(`div`,{className:`rounded border border-gray-200 dark:border-gray-700 overflow-hidden`,children:[(0,J.jsx)(`div`,{className:`px-3 py-1.5 bg-gray-50 dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700 font-mono text-xs font-medium`,children:i.data.file_path}),(0,J.jsx)(dn,{style:r,language:s,showLineNumbers:!0,startingLineNumber:o.startLine,wrapLines:!0,customStyle:{margin:0,borderRadius:0,fontSize:`0.75rem`},children:o.code})]})},Sl=I({prompt:R(),description:R().optional(),subagent_type:R().optional()}),Cl=I({totalDurationMs:Se().optional(),totalTokens:Se().optional(),totalToolUseCount:Se().optional()}),wl=e=>{if(e<1e3)return`${e}ms`;let t=e/1e3;return t<60?`${t.toFixed(1)}s`:`${Math.floor(t/60)}m ${Math.round(t%60)}s`},Tl=({input:e,toolUseResult:t})=>{let n=Sl.safeParse(e);if(!n.success)return null;let r=Cl.safeParse(t),i=n.data.subagent_type!==void 0&&n.data.subagent_type!==``,a=n.data.description!==void 0&&n.data.description!==``;return(0,J.jsxs)(`div`,{className:`rounded border border-gray-200 dark:border-gray-700 overflow-hidden`,children:[(0,J.jsxs)(`div`,{className:`px-3 py-1.5 bg-gray-50 dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700 flex items-center gap-2 flex-wrap`,children:[i?(0,J.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded bg-blue-100 dark:bg-blue-900/50 text-blue-700 dark:text-blue-300 font-medium`,children:n.data.subagent_type}):null,a?(0,J.jsx)(`span`,{className:`text-xs text-muted-foreground truncate`,children:n.data.description}):null]}),(0,J.jsx)(`div`,{className:`px-3 py-2`,children:(0,J.jsx)(`pre`,{className:`text-xs whitespace-pre-wrap break-words font-sans leading-relaxed`,children:n.data.prompt})}),r.success&&r.data.totalDurationMs!==void 0&&(0,J.jsxs)(`div`,{className:`px-3 py-1.5 bg-gray-50 dark:bg-gray-800 border-t border-gray-200 dark:border-gray-700 flex items-center gap-3 text-xs text-muted-foreground`,children:[r.data.totalDurationMs!==void 0&&(0,J.jsx)(`span`,{children:wl(r.data.totalDurationMs)}),r.data.totalTokens!==void 0&&(0,J.jsxs)(`span`,{children:[r.data.totalTokens.toLocaleString(),` tokens`]}),r.data.totalToolUseCount!==void 0&&(0,J.jsxs)(`span`,{children:[r.data.totalToolUseCount,` tool uses`]})]}),t===void 0&&(0,J.jsx)(`div`,{className:`px-3 py-1.5 bg-gray-50 dark:bg-gray-800 border-t border-gray-200 dark:border-gray-700 text-xs text-muted-foreground animate-pulse`,children:`Running...`})]})},El=I({todos:ve(I({content:R(),status:me([`pending`,`in_progress`,`completed`])}))}),Dl=({status:e})=>{switch(e){case`completed`:return(0,J.jsx)(wn,{className:`w-3.5 h-3.5 flex-shrink-0 text-green-600 dark:text-green-500`});case`in_progress`:return(0,J.jsx)(Tn,{className:`w-3.5 h-3.5 flex-shrink-0 text-amber-600 dark:text-amber-500`});case`pending`:return(0,J.jsx)(On,{className:`w-3.5 h-3.5 flex-shrink-0 text-muted-foreground`});default:return null}},Ol={Bash:Oc,Edit:hl,Read:xl,Task:Tl,Agent:Tl,TodoWrite:({input:e})=>{let t=El.safeParse(e);if(!t.success)return null;let{todos:n}=t.data,r=n.filter(e=>e.status===`completed`).length,i=n.length,a=n.some(e=>e.status===`in_progress`);return(0,J.jsxs)(`div`,{className:`rounded border border-gray-200 dark:border-gray-700 overflow-hidden`,children:[(0,J.jsxs)(`div`,{className:`px-3 py-1.5 bg-gray-50 dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700 flex items-center gap-2`,children:[(0,J.jsx)(Jn,{className:U(`w-3.5 h-3.5`,a?`text-amber-600 dark:text-amber-500`:`text-muted-foreground`)}),(0,J.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:`Tasks`}),(0,J.jsxs)(`span`,{className:U(`text-[10px] px-1.5 py-0.5 rounded-full ml-auto`,r===i?`bg-green-500/20 text-green-700 dark:text-green-400`:a?`bg-amber-500/20 text-amber-700 dark:text-amber-400`:`bg-muted text-muted-foreground`),children:[r,`/`,i]})]}),(0,J.jsx)(`div`,{className:`p-2 space-y-1 max-h-48 overflow-y-auto`,children:n.map(e=>(0,J.jsxs)(`div`,{className:U(`flex items-start gap-2 px-2 py-1.5 text-xs rounded-md transition-colors`,e.status===`completed`&&`text-muted-foreground`,e.status===`in_progress`&&`bg-amber-500/10`),children:[(0,J.jsx)(Dl,{status:e.status}),(0,J.jsx)(`span`,{className:U(`flex-1 break-words`,e.status===`completed`&&`line-through`),children:e.content})]},`${e.content}-${e.status}`))})]})},CCVAskUserQuestion:Pc},kl=e=>Ol[e],Al=de.object({prompt:de.string()}),jl=new Set([`Task`,`Agent`]),Ml=({content:e,getToolResult:t,getAgentIdForToolUse:n,getToolUseResult:r,getSidechainConversationByAgentId:i,getSidechainConversationByPrompt:a,getSidechainConversations:o,projectId:s,sessionId:c,syntaxTheme:l})=>{let u=kl(e.name),[d,f]=(0,q.useState)(u?`visual`:`raw`),p=t(e.id),m=r(e.id),h=(0,q.useMemo)(()=>!u||d!==`visual`?null:(0,J.jsx)(u,{input:e.input,output:p,toolUseResult:m}),[u,d,e.input,p,m]),g=d===`visual`&&u&&h===null?`raw`:d,_=(()=>{let r=jl.has(e.name)?Al.safeParse(e.input):void 0;if(r===void 0||r.success===!1)return;let l=n(e.id);return(0,J.jsx)(wc,{prompt:r.data.prompt,projectId:s,sessionId:c,agentId:l,getSidechainConversationByAgentId:i,getSidechainConversationByPrompt:a,getSidechainConversations:o,getToolResult:t})})(),v=Qs(e),y=v.length>0?(0,J.jsx)(Sc,{projectId:s,filePaths:v}):void 0;return(0,J.jsx)(Ot,{className:`border-blue-200 bg-blue-50/50 dark:border-blue-800 dark:bg-blue-950/20 mb-2 p-0 overflow-hidden`,children:(0,J.jsxs)(lc,{children:[(0,J.jsxs)(`div`,{className:`flex items-center min-w-0`,children:[(0,J.jsx)(uc,{asChild:!0,children:(0,J.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:(0,J.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,J.jsx)(xr,{className:`h-4 w-4 text-blue-600 dark:text-blue-400 flex-shrink-0`}),(0,J.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&&(0,J.jsxs)(`span`,{className:`font-normal`,children:[` `,`(`,(0,J.jsx)(Tc,{input:e.input}),`)`]})]}),(0,J.jsx)(K,{className:`h-4 w-4 text-muted-foreground transition-transform duration-200 group-data-[state=open]:rotate-180 flex-shrink-0`})]})})}),(_??y)&&(0,J.jsxs)(`div`,{className:`flex-shrink-0 border-l border-blue-200 dark:border-blue-800 flex items-center`,children:[_,y]})]}),(0,J.jsx)(dc,{children:(0,J.jsxs)(`div`,{className:`space-y-3 py-3 px-4 border-t border-blue-200 dark:border-blue-800`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`h4`,{className:`text-xs font-medium text-muted-foreground`,children:`ID`}),(0,J.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}),u&&(0,J.jsxs)(`button`,{type:`button`,onClick:()=>f(g===`raw`?`visual`:`raw`),className:`ml-auto flex items-center gap-1 px-2 py-0.5 text-xs rounded-md border transition-colors ${g===`raw`?`border-blue-300 dark:border-blue-700 bg-blue-100 dark:bg-blue-900/50 text-blue-700 dark:text-blue-300`:`border-gray-200 dark:border-gray-700 text-muted-foreground hover:bg-gray-100 dark:hover:bg-gray-800`}`,children:[(0,J.jsx)(Mn,{className:`h-3 w-3`}),`Raw`]})]}),g===`visual`&&h,g===`raw`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h4`,{className:`text-xs font-medium text-muted-foreground mb-2`,children:(0,J.jsx)(B,{id:`assistant.tool.input_parameters`})}),(0,J.jsx)(dn,{style:l,language:`json`,PreTag:`div`,className:`text-xs rounded`,children:JSON.stringify(e.input,null,2)})]}),p&&(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h4`,{className:`text-xs font-medium text-muted-foreground mb-2`,children:(0,J.jsx)(B,{id:`assistant.tool.result`})}),(0,J.jsx)(`div`,{className:`bg-background rounded border p-3`,children:typeof p.content==`string`?(0,J.jsx)(`pre`,{className:`text-xs overflow-x-auto whitespace-pre-wrap break-words`,children:p.content}):p.content.map(e=>{if(e.type===`image`)return(0,J.jsx)(`img`,{src:`data:${e.source.media_type};base64,${e.source.data}`,alt:`Tool Result`},e.source.data);if(e.type===`text`)return(0,J.jsx)(`pre`,{className:`text-xs overflow-x-auto whitespace-pre-wrap break-words`,children:e.text},e.text);if(e.type===`tool_reference`)return null;throw Error(`Unexpected tool result content type`)})})]})]})]})})]})})},Nl=({content:e,getToolResult:t,getAgentIdForToolUse:n,getToolUseResult:r,getSidechainConversationByAgentId:i,getSidechainConversationByPrompt:a,getSidechainConversations:o,projectId:s,sessionId:c})=>{let{resolvedTheme:l}=Vt(),u=l===`dark`?qt:Qt;return e.type===`text`?(0,J.jsx)(`div`,{className:`w-full mx-1 sm:mx-2 my-4 sm:my-6`,children:(0,J.jsx)(hc,{content:e.text,placement:`assistant`})}):e.type===`thinking`?e.thinking===``?null:(0,J.jsx)(Ot,{className:`bg-muted/50 border-dashed gap-2 py-1 mb-2 hover:shadow-sm transition-all duration-200`,children:(0,J.jsxs)(lc,{children:[(0,J.jsx)(uc,{asChild:!0,children:(0,J.jsx)(wt,{className:`cursor-pointer hover:bg-muted/80 rounded-t-lg transition-all duration-200 py-0 px-4 group`,children:(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(qn,{className:`h-4 w-4 text-muted-foreground group-hover:text-yellow-600 transition-colors`}),(0,J.jsx)(bt,{className:`text-sm font-medium group-hover:text-foreground transition-colors`,children:(0,J.jsx)(B,{id:`assistant.thinking`})}),(0,J.jsx)(K,{className:`h-4 w-4 text-muted-foreground transition-transform duration-200 group-data-[state=open]:rotate-180`})]})})}),(0,J.jsx)(dc,{children:(0,J.jsx)(`div`,{className:`py-2 px-4`,children:(0,J.jsx)(`div`,{className:`text-sm text-muted-foreground whitespace-pre-wrap font-mono`,children:e.thinking})})})]})}):e.type===`tool_use`?(0,J.jsx)(Ml,{content:e,getToolResult:t,getAgentIdForToolUse:n,getToolUseResult:r,getSidechainConversationByAgentId:i,getSidechainConversationByPrompt:a,getSidechainConversations:o,projectId:s,sessionId:c,syntaxTheme:u}):(e.type,null)},Pl=e=>{let t=(0,q.useMemo)(()=>e.filter(e=>e.type!==`summary`&&e.type!==`file-history-snapshot`&&e.type!==`queue-operation`&&e.type!==`progress`&&e.type!==`custom-title`&&e.type!==`agent-name`&&e.type!==`agent-setting`&&e.type!==`pr-link`&&e.type!==`last-prompt`).filter(e=>e.isSidechain===!0),[e]),n=(0,q.useMemo)(()=>new Map(t.map(e=>[e.uuid,e])),[t]),r=(0,q.useMemo)(()=>{let e=[];for(let n of t)n.type!==`user`||n.parentUuid!==null||typeof n.message.content==`string`&&e.push([n.message.content,n]);return new Map(e)},[t]),i=(0,q.useMemo)(()=>new Set(e.filter(e=>e.type===`assistant`).flatMap(e=>e.message.content.filter(e=>e.type===`tool_use`)).flatMap(e=>{if(!jl.has(e.name))return[];let t=Al.safeParse(e.input);return t.success===!1?[]:[t.data.prompt]})),[e]),a=(0,q.useCallback)(e=>{if(e.parentUuid===null)return e;let t=n.get(e.parentUuid);return t===void 0?e:a(t)},[n]),o=(0,q.useMemo)(()=>{let e=new Map;for(let n of t){let t=a(n);e.has(t.uuid)?e.get(t.uuid)?.push(n):e.set(t.uuid,[n])}return e},[t,a]),s=(0,q.useCallback)(e=>e.type===`summary`||e.type===`file-history-snapshot`||e.type===`queue-operation`||e.type===`custom-title`||e.type===`agent-name`||e.type===`agent-setting`||e.type===`pr-link`||e.type===`last-prompt`?!1:o.has(e.uuid),[o]),c=(0,q.useCallback)(e=>o.get(e)??[],[o]),l=(0,q.useCallback)(e=>r.get(e),[r]),u=(0,q.useMemo)(()=>{let e=[];for(let n of t)n.type!==`user`&&n.type!==`system`&&n.type!==`assistant`||n.parentUuid!==null||n.agentId===void 0||e.push([n.agentId,n]);return new Map(e)},[t]);return{isRootSidechain:s,getSidechainConversations:c,getSidechainConversationByPrompt:l,getSidechainConversationByAgentId:(0,q.useCallback)(e=>u.get(e),[u]),existsRelatedTaskCall:e=>i.has(e)}},Fl=e=>{if(e===void 0||e===``)return;let t=e.trim().toLowerCase().replaceAll(`_`,`-`);if(!(t.length===0||t===`*`)){if(t.startsWith(`zh`))return`zh_CN`;if(t.startsWith(`ja`)||t.startsWith(`jp`))return`ja`;if(t.startsWith(`en`))return`en`}},Il=e=>{if(!e)return;let t;t=e.languages.length>0?e.languages:e.language?[e.language]:[];for(let e of t){let t=Fl(e);if(t)return t}},Ll=({conversation:e})=>{let t=Object.keys(e.snapshot.trackedFileBackups).length,{config:n}=ge();return(0,J.jsxs)(lc,{children:[(0,J.jsx)(uc,{asChild:!0,children:(0,J.jsxs)(`div`,{className:`flex items-center justify-between cursor-pointer hover:bg-muted/50 rounded p-2 -mx-2`,children:[(0,J.jsxs)(`h4`,{className:`text-xs font-medium text-muted-foreground`,children:[`File History Snapshot `,t>0&&`(${t} files)`]}),(0,J.jsx)(K,{className:`h-3 w-3 text-muted-foreground transition-transform group-data-[state=open]:rotate-180`})]})}),(0,J.jsx)(dc,{children:(0,J.jsx)(`div`,{className:`bg-background rounded border p-3 mt-2`,children:(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsxs)(`div`,{className:`text-xs`,children:[(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`Timestamp: `}),(0,J.jsx)(`span`,{children:he(e.snapshot.timestamp,{locale:n.locale})})]}),(0,J.jsxs)(`div`,{className:`text-xs`,children:[(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`Message ID: `}),(0,J.jsx)(`span`,{className:`font-mono`,children:e.messageId})]}),(0,J.jsxs)(`div`,{className:`text-xs`,children:[(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`Is Snapshot Update: `}),(0,J.jsx)(`span`,{children:e.isSnapshotUpdate?`Yes`:`No`})]}),t>0&&(0,J.jsxs)(`div`,{className:`text-xs`,children:[(0,J.jsx)(`div`,{className:`text-muted-foreground mb-1`,children:`Tracked Files:`}),(0,J.jsx)(`ul`,{className:`list-disc list-inside space-y-1`,children:Object.keys(e.snapshot.trackedFileBackups).map(e=>(0,J.jsx)(`li`,{className:`font-mono text-xs break-all`,children:e},e))})]})]})})})]})},Rl=({children:e})=>(0,J.jsxs)(lc,{children:[(0,J.jsx)(uc,{asChild:!0,children:(0,J.jsxs)(`div`,{className:`flex items-center justify-between cursor-pointer hover:bg-muted/50 rounded p-2 -mx-2 mb-2`,children:[(0,J.jsx)(`h4`,{className:`text-xs font-medium text-muted-foreground`,children:`Meta Information`}),(0,J.jsx)(K,{className:`h-3 w-3 text-muted-foreground transition-transform group-data-[state=open]:rotate-180`})]})}),(0,J.jsx)(dc,{children:(0,J.jsx)(`div`,{className:`bg-background rounded border p-3 mt-2`,children:e})})]}),zl=e=>e===void 0?``:typeof e==`string`?e:e.map(e=>typeof e==`string`?e:e.type===`text`?e.text:e.type===`image`?`[Image]`:e.type===`document`?`[Document]`:e.type===`tool_result`?`[Tool Result]`:e).join(`
6
- `),Bl=({conversation:e})=>(0,J.jsxs)(lc,{children:[(0,J.jsx)(uc,{asChild:!0,children:(0,J.jsxs)(`div`,{className:`flex items-center justify-between cursor-pointer hover:bg-muted/50 rounded p-2 -mx-2`,children:[(0,J.jsx)(`h4`,{className:`text-xs font-medium text-muted-foreground`,children:e.operation===`enqueue`?`Queue Operation: Enqueue`:`Queue Operation: Dequeue`}),(0,J.jsx)(K,{className:`h-3 w-3 text-muted-foreground transition-transform group-data-[state=open]:rotate-180`})]})}),(0,J.jsx)(dc,{children:(0,J.jsx)(`div`,{className:`bg-background rounded border p-3 mt-2`,children:(0,J.jsxs)(`div`,{className:`space-y-2 text-xs`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`span`,{className:`font-medium text-muted-foreground`,children:`Operation:`}),` `,e.operation]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`span`,{className:`font-medium text-muted-foreground`,children:`Session ID:`}),` `,e.sessionId]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`span`,{className:`font-medium text-muted-foreground`,children:`Timestamp:`}),` `,e.timestamp]}),e.operation===`enqueue`&&e.content!==void 0&&(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`span`,{className:`font-medium text-muted-foreground`,children:`Content:`}),(0,J.jsx)(`pre`,{className:`mt-1 overflow-x-auto whitespace-pre-wrap`,children:zl(e.content)})]})]})})})]}),Vl=({children:e})=>(0,J.jsxs)(lc,{children:[(0,J.jsx)(uc,{asChild:!0,children:(0,J.jsxs)(`div`,{className:`flex items-center justify-between cursor-pointer hover:bg-muted/50 rounded p-2 -mx-2 mb-2`,children:[(0,J.jsx)(`h4`,{className:`text-xs font-medium text-muted-foreground`,children:`Summarized`}),(0,J.jsx)(K,{className:`h-3 w-3 text-muted-foreground transition-transform group-data-[state=open]:rotate-180`})]})}),(0,J.jsx)(dc,{children:(0,J.jsx)(`div`,{className:`bg-background rounded border p-3 mt-2`,children:(0,J.jsx)(`pre`,{className:`text-xs overflow-x-auto`,children:e})})})]}),Hl=({children:e})=>(0,J.jsxs)(lc,{children:[(0,J.jsx)(uc,{asChild:!0,children:(0,J.jsxs)(`div`,{className:`flex items-center justify-between cursor-pointer hover:bg-muted/50 rounded p-2 -mx-2`,children:[(0,J.jsx)(`h4`,{className:`text-xs font-medium text-muted-foreground`,children:`System Message`}),(0,J.jsx)(K,{className:`h-3 w-3 text-muted-foreground transition-transform group-data-[state=open]:rotate-180`})]})}),(0,J.jsx)(dc,{children:(0,J.jsx)(`div`,{className:`bg-background rounded border p-3 mt-2`,children:(0,J.jsx)(`pre`,{className:`text-xs overflow-x-auto`,children:e})})})]}),Ul=({durationMs:e})=>(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground mt-2 px-2`,children:[(0,J.jsx)(jn,{className:`h-3 w-3`}),(0,J.jsxs)(`span`,{children:[(0,J.jsx)(B,{id:`assistant.turn_duration`}),`: `,sc(e)]})]}),Wl=({text:e,id:t})=>{let n=oc(e);if(n.kind===`command`){let e=n.commandArgs!==void 0&&n.commandArgs!==``,r=n.commandMessage!==void 0&&n.commandMessage!==``,i=e||r;return(0,J.jsxs)(Ot,{className:`border-green-200 bg-green-50/50 dark:border-green-800 dark:bg-green-950/20 gap-2 py-3 mb-3`,id:t,children:[(0,J.jsx)(wt,{className:`py-0 px-4`,children:(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(_r,{className:`h-4 w-4 text-green-600 dark:text-green-400`}),(0,J.jsx)(bt,{className:`text-sm font-medium`,children:`Claude Code Command`}),(0,J.jsx)(Y,{variant:`outline`,className:`border-green-300 text-green-700 dark:border-green-700 dark:text-green-300`,children:n.commandName})]})}),i?(0,J.jsx)(Et,{className:`py-0 px-4`,children:(0,J.jsx)(`div`,{className:`space-y-2`,children:(0,J.jsxs)(`div`,{children:[e?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:`Arguments:`}),(0,J.jsx)(`div`,{className:`bg-background rounded border p-2 mt-1`,children:(0,J.jsx)(`code`,{className:`text-xs whitespace-pre-line break-all`,children:n.commandArgs})})]}):null,r?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:`Message:`}),(0,J.jsx)(`div`,{className:`bg-background rounded border p-2 mt-1`,children:(0,J.jsx)(`code`,{className:`text-xs whitespace-pre-line break-all`,children:n.commandMessage})})]}):null]})})}):null]})}return n.kind===`local-command`?(0,J.jsxs)(Ot,{className:`border-green-200 bg-green-50/50 dark:border-green-800 dark:bg-green-950/20 gap-2 py-3 mb-3`,children:[(0,J.jsx)(wt,{className:`py-0 px-4`,children:(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(_r,{className:`h-4 w-4 text-green-600 dark:text-green-400`}),(0,J.jsx)(bt,{className:`text-sm font-medium`,children:`Local Command`})]})}),(0,J.jsx)(Et,{className:`py-0 px-4`,children:(0,J.jsx)(`pre`,{className:`text-xs overflow-x-auto whitespace-pre-wrap break-words`,children:n.stdout})})]}):(0,J.jsx)(hc,{className:`w-full px-3 py-3 mb-5 border border-border rounded-lg bg-slate-50 dark:bg-slate-900/50`,content:n.content})},Gl=({content:e,id:t})=>typeof e==`string`?(0,J.jsx)(Wl,{text:e,id:t}):e.type===`text`?(0,J.jsx)(Wl,{text:e.text,id:t}):e.type===`image`?e.source.type===`base64`?(0,J.jsx)(Ot,{className:`border-purple-200 bg-purple-50/50 dark:border-purple-800 dark:bg-purple-950/20 mb-2 p-0 overflow-hidden`,id:t,children:(0,J.jsxs)(lc,{children:[(0,J.jsx)(uc,{asChild:!0,children:(0,J.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:(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(Gn,{className:`h-4 w-4 text-purple-600 dark:text-purple-400`}),(0,J.jsx)(`span`,{className:`text-sm font-medium`,children:(0,J.jsx)(B,{id:`user.content.image`})}),(0,J.jsx)(Y,{variant:`outline`,className:`border-purple-300 text-purple-700 dark:border-purple-700 dark:text-purple-300`,children:e.source.media_type}),(0,J.jsx)(K,{className:`h-4 w-4 text-muted-foreground transition-transform group-data-[state=open]:rotate-180 ml-auto`})]})})}),(0,J.jsx)(dc,{children:(0,J.jsx)(`div`,{className:`py-3 px-4 border-t border-purple-200 dark:border-purple-800`,children:(0,J.jsx)(`div`,{className:`rounded-lg border overflow-hidden bg-background`,children:(0,J.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`})})})})]})}):(0,J.jsx)(Ot,{className:`border-red-200 bg-red-50/50 dark:border-red-800 dark:bg-red-950/20`,id:t,children:(0,J.jsxs)(wt,{children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(Ft,{className:`h-4 w-4 text-red-600 dark:text-red-400`}),(0,J.jsx)(bt,{className:`text-sm font-medium`,children:(0,J.jsx)(B,{id:`user.content.unsupported_media`})}),(0,J.jsx)(Y,{variant:`destructive`,children:(0,J.jsx)(B,{id:`common.error`})})]}),(0,J.jsx)(Dt,{className:`text-xs`,children:(0,J.jsx)(B,{id:`user.content.unsupported_media.description`})})]})}):e.type===`document`?e.source.type===`base64`&&e.source.media_type===`application/pdf`?(0,J.jsx)(Ot,{className:`border-blue-200 bg-blue-50/50 dark:border-blue-800 dark:bg-blue-950/20 mb-2 p-0 overflow-hidden`,id:t,children:(0,J.jsxs)(lc,{children:[(0,J.jsx)(uc,{asChild:!0,children:(0,J.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:(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(Rn,{className:`h-4 w-4 text-blue-600 dark:text-blue-400`}),(0,J.jsx)(`span`,{className:`text-sm font-medium`,children:(0,J.jsx)(B,{id:`user.content.document.pdf`})}),(0,J.jsx)(Y,{variant:`outline`,className:`border-blue-300 text-blue-700 dark:border-blue-700 dark:text-blue-300`,children:e.source.media_type}),(0,J.jsx)(K,{className:`h-4 w-4 text-muted-foreground transition-transform group-data-[state=open]:rotate-180 ml-auto`})]})})}),(0,J.jsx)(dc,{children:(0,J.jsx)(`div`,{className:`py-3 px-4 border-t border-blue-200 dark:border-blue-800`,children:(0,J.jsx)(`div`,{className:`rounded-lg border overflow-hidden bg-background`,children:(0,J.jsx)(`embed`,{src:`data:${e.source.media_type};base64,${e.source.data}`,type:`application/pdf`,className:`w-full h-[600px]`})})})})]})}):e.source.type===`text`?(0,J.jsx)(Ot,{className:`border-green-200 bg-green-50/50 dark:border-green-800 dark:bg-green-950/20 mb-2 p-0 overflow-hidden`,id:t,children:(0,J.jsxs)(lc,{children:[(0,J.jsx)(uc,{asChild:!0,children:(0,J.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:(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(Rn,{className:`h-4 w-4 text-green-600 dark:text-green-400`}),(0,J.jsx)(`span`,{className:`text-sm font-medium`,children:(0,J.jsx)(B,{id:`user.content.document.text`})}),(0,J.jsx)(Y,{variant:`outline`,className:`border-green-300 text-green-700 dark:border-green-700 dark:text-green-300`,children:e.source.media_type}),(0,J.jsx)(K,{className:`h-4 w-4 text-muted-foreground transition-transform group-data-[state=open]:rotate-180 ml-auto`})]})})}),(0,J.jsx)(dc,{children:(0,J.jsx)(`div`,{className:`py-3 px-4 border-t border-green-200 dark:border-green-800`,children:(0,J.jsx)(`div`,{className:`rounded-lg border overflow-hidden bg-background`,children:(0,J.jsx)(`pre`,{className:`p-4 text-sm overflow-auto max-h-96`,children:e.source.data})})})})]})}):(0,J.jsx)(Ot,{className:`border-red-200 bg-red-50/50 dark:border-red-800 dark:bg-red-950/20`,id:t,children:(0,J.jsxs)(wt,{children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(Ft,{className:`h-4 w-4 text-red-600 dark:text-red-400`}),(0,J.jsx)(bt,{className:`text-sm font-medium`,children:(0,J.jsx)(B,{id:`user.content.unsupported_document`})}),(0,J.jsx)(Y,{variant:`destructive`,children:(0,J.jsx)(B,{id:`common.error`})})]}),(0,J.jsx)(Dt,{className:`text-xs`,children:(0,J.jsx)(B,{id:`user.content.unsupported_document.description`})})]})}):(e.type,null),Kl=e=>{let t=[];if(`subtype`in e&&e.subtype&&t.push(`[${e.subtype}]`),`level`in e&&e.level&&t.push(`Level: ${e.level}`),`content`in e&&typeof e.content==`string`&&t.push(`\n${e.content}`),e.subtype===`stop_hook_summary`&&(t.push(`Hook Count: ${e.hookCount}`),t.push(`Stop Reason: ${e.stopReason}`),t.push(`Prevented Continuation: ${e.preventedContinuation}`),t.push(`Has Output: ${e.hasOutput}`),e.hookInfos.length>0&&t.push(`Commands: ${e.hookInfos.map(e=>e.command).join(`, `)}`),e.hookErrors.length>0&&t.push(`Errors: ${JSON.stringify(e.hookErrors,null,2)}`)),e.subtype===`turn_duration`&&t.push(`Duration: ${(e.durationMs/1e3).toFixed(2)}s`),e.subtype===`compact_boundary`&&e.compactMetadata&&(t.push(`Trigger: ${e.compactMetadata.trigger}`),t.push(`Pre-Tokens: ${e.compactMetadata.preTokens}`)),e.subtype===`api_error`&&`error`in e){let n=e.error;n.status!==void 0&&t.push(`Status: ${n.status}`),n.requestID!==void 0&&n.requestID!==``&&t.push(`Request ID: ${n.requestID}`);let r=n?.error?.error?.message??n?.error?.message??(n?.error?JSON.stringify(n.error,null,2):null);r!==null&&r!==``&&t.push(`Error: ${r}`),e.retryAttempt!==void 0&&t.push(`Retry: ${e.retryAttempt}/${e.maxRetries}`),e.retryInMs!==void 0&&t.push(`Retry In: ${(e.retryInMs/1e3).toFixed(2)}s`)}return`toolUseID`in e&&e.toolUseID&&t.push(`Tool Use ID: ${e.toolUseID}`),`slug`in e&&e.slug!==void 0&&e.slug!==``&&t.push(`Slug: ${e.slug}`),t.join(`
7
- `)},ql=(0,q.memo)(({conversation:e,getToolResult:t,getAgentIdForToolUse:n,getToolUseResult:r,getTurnDuration:i,getSidechainConversationByPrompt:a,getSidechainConversations:o,getSidechainConversationByAgentId:s,projectId:c,sessionId:l,showTimestamp:u=!0})=>{let{i18n:d}=Xe(),f=le.safeParse(d.locale),p=f.success?f.data:`en`;if(e.type===`summary`)return(0,J.jsx)(Vl,{children:e.summary});if(e.type===`system`)return(0,J.jsx)(Hl,{children:Kl(e)});if(e.type===`file-history-snapshot`)return(0,J.jsx)(Ll,{conversation:e});if(e.type===`queue-operation`)return(0,J.jsx)(Bl,{conversation:e});if(e.type===`user`){if(typeof e.message.content==`string`){let i=oc(e.message.content);if(i.kind===`local-command`){let d={type:`text`,text:i.stdout};return(0,J.jsxs)(`div`,{className:`w-full`,children:[u&&e.timestamp&&(0,J.jsx)(`div`,{className:`text-xs text-muted-foreground mb-1 px-1 select-none text-left`,children:he(e.timestamp,{locale:p,target:`datetime`})}),(0,J.jsx)(`ul`,{className:`w-full`,children:(0,J.jsx)(`li`,{children:(0,J.jsx)(Nl,{content:d,getToolResult:t,getAgentIdForToolUse:n,getToolUseResult:r,getSidechainConversationByAgentId:s,getSidechainConversationByPrompt:a,getSidechainConversations:o,projectId:c,sessionId:l})})})]})}}let i=typeof e.message.content==`string`?(0,J.jsx)(Gl,{content:e.message.content,id:`message-${e.uuid}`}):(0,J.jsx)(`ul`,{className:`w-full`,id:`message-${e.uuid}`,children:e.message.content.map((e,t)=>(0,J.jsx)(`li`,{children:(0,J.jsx)(Gl,{content:e})},t))}),d=u&&e.timestamp?(0,J.jsx)(`div`,{className:`text-xs text-muted-foreground mb-1 px-1 select-none text-right`,children:he(e.timestamp,{locale:p,target:`datetime`})}):null;return e.isMeta===!0?(0,J.jsx)(Rl,{children:(0,J.jsxs)(`div`,{className:`flex flex-col w-full`,children:[d,i]})}):(0,J.jsxs)(`div`,{className:`flex flex-col w-full`,children:[d,i]})}if(e.type===`assistant`){let d=e.message.content.filter(e=>!(e.type===`thinking`&&e.thinking===``||e.type===`tool_result`));if(d.length===0&&i(e.uuid)===void 0)return null;let f=i(e.uuid);return(0,J.jsxs)(`div`,{className:`w-full`,children:[u&&e.timestamp&&(0,J.jsx)(`div`,{className:`text-xs text-muted-foreground mb-1 px-1 select-none text-left`,children:he(e.timestamp,{locale:p,target:`datetime`})}),(0,J.jsx)(`ul`,{className:`w-full`,children:d.map((e,i)=>(0,J.jsx)(`li`,{children:(0,J.jsx)(Nl,{content:e,getToolResult:t,getAgentIdForToolUse:n,getToolUseResult:r,getSidechainConversationByAgentId:s,getSidechainConversationByPrompt:a,getSidechainConversations:o,projectId:c,sessionId:l})},i))}),f!==void 0&&(0,J.jsx)(Ul,{durationMs:f})]})}return null}),Jl=new Set([`summary`,`progress`,`queue-operation`,`file-history-snapshot`,`custom-title`,`agent-name`,`agent-setting`]),Yl=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}`;if(e.type===`progress`)return`progress_${e.uuid}`;if(e.type===`custom-title`)return`custom-title_${e.sessionId}_${e.customTitle}`;if(e.type===`agent-name`)return`agent-name_${e.sessionId}_${e.agentName}`;if(e.type===`agent-setting`)return`agent-setting_${e.sessionId}_${e.agentSetting}`;if(e.type===`pr-link`)return`pr-link_${e.sessionId}_${e.prNumber}`;if(e.type===`last-prompt`)return`last-prompt_${e.sessionId}`;throw Error(`Unknown conversation type`)},Xl=(e,t)=>{let n=[],r=new Map,i=e=>{let t=r.get(e)??0;return r.set(e,t+1),t===0?e:`${e}_${t}`};for(let r of e){if(r.type===`x-error`){n.push({conversation:r,showTimestamp:!1,rowKey:i(`error_${r.lineNumber}`)});continue}t(r)&&n.push({conversation:r,showTimestamp:!Jl.has(r.type),rowKey:i(Yl(r))})}return n},Zl=({scheduledJobs:e})=>{let{i18n:t}=Xe();return e.length===0?null:(0,J.jsx)(`div`,{className:`w-full flex justify-start mt-4`,children:(0,J.jsx)(`div`,{className:`w-full max-w-3xl lg:max-w-4xl sm:w-[90%] md:w-[85%] px-2`,children:(0,J.jsxs)(`div`,{className:`bg-blue-50 dark:bg-blue-950/30 border border-blue-200 dark:border-blue-800/50 rounded-lg p-4 space-y-3`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(vn,{className:`w-4 h-4 text-blue-600 dark:text-blue-400`}),(0,J.jsx)(`h3`,{className:`text-sm font-semibold text-blue-900 dark:text-blue-100`,children:(0,J.jsx)(B,{id:`session.scheduled_messages.title`})})]}),(0,J.jsx)(`div`,{className:`space-y-2`,children:e.map(e=>{if(e.schedule.type!==`reserved`)return null;let n=new Date(e.schedule.reservedExecutionTime);return(0,J.jsxs)(`div`,{className:`flex flex-col gap-2 p-3 bg-white dark:bg-gray-900 rounded border border-blue-100 dark:border-blue-900`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(Y,{variant:`secondary`,className:`bg-blue-100 text-blue-900 dark:bg-blue-900 dark:text-blue-100`,children:t.date(n,{year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`})}),!e.enabled&&(0,J.jsx)(Y,{variant:`outline`,className:`text-xs`,children:(0,J.jsx)(B,{id:`session.scheduled_messages.disabled`})})]}),(0,J.jsxs)(`p`,{className:`text-sm text-gray-700 dark:text-gray-300 line-clamp-2`,children:[(0,J.jsx)(B,{id:`session.scheduled_messages.message_label`}),`: `,e.message.content]})]},e.id)})})]})})})},Ql=`conversation-in-page-search`,$l=e=>typeof e==`object`&&!!e&&`agentId`in e&&typeof e.agentId==`string`,eu=e=>{if(typeof e==`string`)return e;let t=[];for(let n of e){if(typeof n==`string`){t.push(n);continue}n.type===`text`&&t.push(n.text)}return t.join(` `)},tu=e=>e.type===`text`?e.text:e.type===`thinking`?e.thinking:e.type===`tool_use`?e.name:``,nu=e=>e.type===`x-error`?e.line:e.type===`user`?eu(e.message.content):e.type===`assistant`?e.message.content.map(tu).join(` `):e.type===`summary`?e.summary:e.type===`system`&&`content`in e?e.content:e.type===`custom-title`?e.customTitle:e.type===`last-prompt`?e.lastPrompt:``,ru=()=>{let e=document.getElementById(Ql);return e instanceof HTMLInputElement?e:null},iu=e=>{if(e===null)return;let t=e.querySelectorAll(`mark[data-active-search-highlight='true']`);for(let e of t){let t=e.parentNode;if(t===null)continue;let n=document.createTextNode(e.textContent??``);t.replaceChild(n,e),t.normalize()}},au=(e,t)=>{let n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);for(;;){let e=n.nextNode();if(e===null)return null;if(!(e instanceof Text))continue;let r=e.nodeValue;if(r===null||r===``)continue;let i=r.toLowerCase().indexOf(t);if(i>=0)return{node:e,startOffset:i}}},ou=({errorLine:e})=>(0,J.jsx)(`div`,{className:`w-full max-w-3xl lg:max-w-4xl sm:w-[90%] md:w-[85%] px-2`,children:(0,J.jsxs)(lc,{children:[(0,J.jsx)(uc,{asChild:!0,children:(0,J.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:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(br,{className:`h-3 w-3 text-red-500`}),(0,J.jsx)(`span`,{className:`text-xs font-medium text-red-600`,children:(0,J.jsx)(B,{id:`conversation.error.schema`})})]}),(0,J.jsx)(K,{className:`h-3 w-3 text-muted-foreground transition-transform group-data-[state=open]:rotate-180`})]})}),(0,J.jsx)(dc,{children:(0,J.jsx)(`div`,{className:`bg-background rounded border border-red-200 p-3 mt-2`,children:(0,J.jsxs)(`div`,{className:`space-y-3`,children:[(0,J.jsxs)(Ht,{variant:`destructive`,className:`border-red-200 bg-red-50`,children:[(0,J.jsx)(br,{className:`h-4 w-4`}),(0,J.jsx)(Lt,{className:`text-red-800`,children:(0,J.jsx)(B,{id:`conversation.error.schema_validation`})}),(0,J.jsxs)(Mt,{className:`text-red-700`,children:[(0,J.jsx)(B,{id:`conversation.error.schema_validation.description`}),` `,(0,J.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:[(0,J.jsx)(B,{id:`conversation.error.report_issue`}),(0,J.jsx)(In,{className:`h-3 w-3`})]})]})]}),(0,J.jsxs)(`div`,{className:`bg-gray-50 border rounded px-3 py-2`,children:[(0,J.jsx)(`h5`,{className:`text-xs font-medium text-gray-700 mb-2`,children:(0,J.jsx)(B,{id:`conversation.error.raw_content`})}),(0,J.jsx)(`pre`,{className:`text-xs overflow-x-auto whitespace-pre-wrap break-all font-mono text-gray-800`,children:e})]})]})})})]})}),su=({conversations:e,getToolResult:t,projectId:n,sessionId:r,scheduledJobs:i,scrollContainerRef:a,enableInPageSearch:o=!1})=>{let{config:s}=ge(),[c,l]=(0,q.useState)(!1),[u,d]=(0,q.useState)(``),[f,p]=(0,q.useState)(0),m=(0,q.useRef)(null),h=(0,q.useRef)(new Map),g=(0,q.useMemo)(()=>e.filter(e=>e.type!==`x-error`),[e]),{isRootSidechain:_,getSidechainConversations:v,getSidechainConversationByPrompt:y,getSidechainConversationByAgentId:b,existsRelatedTaskCall:x}=Pl(g),S=(0,q.useMemo)(()=>{let e=new Map,t=e=>{if(e.type!==`user`||e.isSidechain)return!1;let t=e.message.content;if(Array.isArray(t)){let e=t[0];if(typeof e==`object`&&e&&`type`in e&&e.type===`tool_result`)return!1}return!0},n=[];for(let e=0;e<g.length;e++){let r=g[e];r!==void 0&&t(r)&&n.push(e)}for(let t=0;t<n.length;t++){let r=n[t];if(r===void 0)continue;let i=n[t+1]??g.length,a=g[r];if(a===void 0||a.type!==`user`)continue;let o=null;for(let e=r+1;e<i;e++){let t=g[e];t!==void 0&&t.type===`assistant`&&!t.isSidechain&&(o=t)}if(o!==null){let t=cc(a.timestamp,o.timestamp);t!==null&&t>=0&&e.set(o.uuid,t)}}return e},[g]),C=(0,q.useCallback)(e=>S.get(e),[S]),w=(0,q.useMemo)(()=>{let e=new Map;for(let t of g){if(t.type!==`user`)continue;let n=t.message.content;if(typeof n!=`string`){for(let r of n)if(typeof r!=`string`&&r.type===`tool_result`){let n=t.toolUseResult;$l(n)&&e.set(r.tool_use_id,n.agentId)}}}return e},[g]),T=(0,q.useCallback)(e=>w.get(e),[w]),E=(0,q.useMemo)(()=>{let e=new Map;for(let t of g){if(t.type!==`user`)continue;let n=t.message.content;if(typeof n!=`string`)for(let r of n)typeof r!=`string`&&r.type===`tool_result`&&t.toolUseResult!==void 0&&e.set(r.tool_use_id,t.toolUseResult)}return e},[g]),D=(0,q.useCallback)(e=>E.get(e),[E]),O=(0,q.useCallback)(e=>{if(e.type!==`user`)return!1;let t=e.message.content;return typeof t==`string`?!1:t.every(e=>typeof e!=`string`&&e.type===`tool_result`)},[]),k=(0,q.useCallback)(e=>e.type===`x-error`?!0:!(e.type===`progress`||e.type===`custom-title`||e.type===`agent-name`||e.type===`agent-setting`||e.type===`pr-link`||e.type===`last-prompt`||e.type!==`summary`&&e.type!==`file-history-snapshot`&&e.type!==`queue-operation`&&e.isSidechain||e.type===`user`&&O(e)),[O]),A=(0,q.useMemo)(()=>Xl(e,k),[e,k]),j=(0,q.useMemo)(()=>A.map(e=>nu(e.conversation).toLowerCase()),[A]),M=(0,q.useMemo)(()=>{if(u===``)return[];let e=[];for(let t=0;t<j.length;t++){let n=j[t];n!==void 0&&n.includes(u)&&e.push(t)}return e},[u,j]);(0,q.useEffect)(()=>{if(!o)return;let e=s?.findHotkey??`command-f`,t=t=>{(e===`command-f`?t.metaKey&&!t.ctrlKey&&t.key.toLowerCase()===`f`:!t.metaKey&&t.ctrlKey&&t.key.toLowerCase()===`f`)&&(t.preventDefault(),l(!0)),t.key===`Escape`&&c&&l(!1)};return window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`keydown`,t)}},[o,c,s?.findHotkey]),(0,q.useEffect)(()=>{p(0)},[u]),(0,q.useEffect)(()=>{c&&requestAnimationFrame(()=>{let e=ru();e!==null&&(e.focus(),e.select())})},[c]);let N=(0,q.useCallback)(e=>{d(e.trim().toLowerCase()),p(0)},[]);(0,q.useEffect)(()=>{if(M.length===0)return;if(f>=M.length){p(0);return}let e=M[f];if(e===void 0)return;let t=h.current.get(e);t!==void 0&&t.scrollIntoView({behavior:`smooth`,block:`center`})},[f,M]),(0,q.useEffect)(()=>{let e=a.current;if(e===null||(m.current!==null&&(window.cancelAnimationFrame(m.current),m.current=null),iu(e),u===``||M.length===0))return;let t=M[f];if(t===void 0)return;let n=e=>{let r=h.current.get(t);if(!(r instanceof HTMLElement)){e>0&&(m.current=window.requestAnimationFrame(()=>{n(e-1)}));return}let i=au(r,u);if(i===null){e>0&&(m.current=window.requestAnimationFrame(()=>{n(e-1)}));return}let a=document.createElement(`mark`);a.dataset.activeSearchHighlight=`true`,a.className=`rounded bg-yellow-200 px-0.5 text-foreground dark:bg-yellow-700/70`;let o=document.createRange();o.setStart(i.node,i.startOffset),o.setEnd(i.node,i.startOffset+u.length),o.surroundContents(a),m.current=null};n(6)},[f,u,M,a]),(0,q.useEffect)(()=>{let e=a.current;return()=>{m.current!==null&&window.cancelAnimationFrame(m.current),iu(e)}},[a]);let P=()=>{M.length!==0&&p(e=>e===0?M.length-1:e-1)},ee=()=>{M.length!==0&&p(e=>(e+1)%M.length)},te=(0,q.useCallback)((e,t)=>{t===null?h.current.delete(e):h.current.set(e,t)},[]),ne=e=>{let i=A[e];if(i===void 0)return null;if(i.conversation.type===`x-error`)return(0,J.jsx)(`div`,{className:`w-full flex justify-start`,children:(0,J.jsx)(ou,{errorLine:i.conversation.line})});let a=i.conversation,o=a.type===`user`&&typeof a.message.content==`string`&&oc(a.message.content).kind===`local-command`;return(0,J.jsx)(`div`,{className:`w-full flex ${a.type!==`summary`&&a.type!==`file-history-snapshot`&&a.type!==`queue-operation`&&a.type!==`progress`&&a.type!==`custom-title`&&a.type!==`agent-name`&&a.type!==`agent-setting`&&a.type!==`pr-link`&&a.type!==`last-prompt`&&a.isSidechain||o||a.type===`assistant`||a.type===`system`||a.type===`summary`?`justify-start`:`justify-end`}`,children:(0,J.jsx)(`div`,{className:`w-full max-w-3xl lg:max-w-4xl sm:w-[90%] md:w-[85%]`,children:(0,J.jsx)(ql,{conversation:a,getToolResult:t,getAgentIdForToolUse:T,getToolUseResult:D,getTurnDuration:C,isRootSidechain:_,getSidechainConversations:v,getSidechainConversationByAgentId:b,getSidechainConversationByPrompt:y,existsRelatedTaskCall:x,projectId:n,sessionId:r,showTimestamp:i.showTimestamp})})})};return(0,J.jsxs)(J.Fragment,{children:[o&&c&&(0,J.jsx)(`div`,{className:`sticky top-2 z-20 mb-3 flex justify-end`,children:(0,J.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border bg-background/95 px-2 py-1.5 shadow-sm backdrop-blur supports-[backdrop-filter]:bg-background/85`,children:[(0,J.jsx)(Te,{className:`h-4 w-4 text-muted-foreground`}),(0,J.jsx)(At,{id:Ql,placeholder:`Find in conversation`,defaultValue:u,className:`h-8 w-56`,onKeyDown:e=>{if(e.key!==`Enter`)return;let t=e.currentTarget.value;if(t.trim().toLowerCase()===u&&M.length>0){e.shiftKey?P():ee();return}N(t)}}),(0,J.jsx)(`span`,{className:`min-w-14 text-right text-xs text-muted-foreground`,children:M.length===0?`0/0`:`${f+1}/${M.length}`}),(0,J.jsx)(H,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,onClick:()=>{let e=ru()?.value??``;if(e.trim().toLowerCase()!==u){N(e);return}P()},disabled:M.length===0,children:(0,J.jsx)(bn,{className:`h-4 w-4`})}),(0,J.jsx)(H,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,onClick:()=>{let e=ru()?.value??``;if(e.trim().toLowerCase()!==u){N(e);return}ee()},disabled:M.length===0,children:(0,J.jsx)(K,{className:`h-4 w-4`})}),(0,J.jsx)(H,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,onClick:()=>l(!1),children:(0,J.jsx)(Ce,{className:`h-4 w-4`})})]})}),(0,J.jsx)(`ul`,{className:`w-full`,children:A.map((e,t)=>{let n=ne(t);return n===null?null:(0,J.jsx)(`li`,{ref:e=>te(t,e),children:n},e.rowKey)})}),(0,J.jsx)(Zl,{scheduledJobs:i})]})},cu=e=>({type:`user`,message:{role:`user`,content:e.userMessage},isSidechain:!1,userType:`external`,cwd:``,sessionId:e.sessionId,version:`virtual`,uuid:`vc__${e.sessionId}__${e.sentAt}`,timestamp:e.sentAt,parentUuid:null}),lu=(e,t)=>e.some(e=>e.type===`user`&&e.timestamp>=t),uu=u(new Map),du=d(),fu=e=>{let t=du.get(uu),n=new Map(t);n.set(e.sessionId,e),du.set(uu,n)},pu=e=>du.get(uu).get(e),mu=e=>{let t=du.get(uu);if(!t.has(e))return;let n=new Map(t);n.delete(e),du.set(uu,n)},hu=e=>e.filter(e=>e.type!==`x-error`),gu=(e,t)=>{let{isConnected:n}=T(jt);return s({queryKey:m(e,t).queryKey,queryFn:async()=>{let n=await m(e,t).queryFn(),r=pu(t);if(n.session===null)return r?{session:{id:t,jsonlFilePath:``,meta:{messageCount:0,firstUserMessage:null,customTitle:null,cost:{totalUsd:0,breakdown:{inputTokensUsd:0,outputTokensUsd:0,cacheCreationUsd:0,cacheReadUsd:0},tokenUsage:{inputTokens:0,outputTokens:0,cacheCreationTokens:0,cacheReadTokens:0}},modelName:null,prLinks:[]},conversations:[cu(r)],lastModifiedAt:r.sentAt}}:n;if(r&&!lu(hu(n.session.conversations),r.sentAt)){let e=cu(r);return{...n,session:{...n.session,conversations:[...n.session.conversations,e]}}}return n},refetchInterval:n?!1:3e4,refetchIntervalInBackground:!1})},_u=(e,t)=>{let n=gu(e,t).data?.session;if(n==null)throw Error(`Session not found`);let r=(0,q.useMemo)(()=>{let e=n.conversations.flatMap(e=>e.type!==`user`||typeof e.message.content==`string`?[]:e.message.content.flatMap(e=>typeof e==`string`||e.type!==`tool_result`?[]:[[e.tool_use_id,e]]));return new Map(e)},[n.conversations]),i=(0,q.useCallback)(e=>r.get(e),[r]);return{session:n,conversations:n.conversations,getToolResult:i}},vu=({status:e})=>{switch(e){case`completed`:return(0,J.jsx)(wn,{className:`w-3.5 h-3.5 flex-shrink-0 text-green-600 dark:text-green-500`});case`in_progress`:return(0,J.jsx)(Tn,{className:`w-3.5 h-3.5 flex-shrink-0 text-amber-600 dark:text-amber-500`});case`pending`:return(0,J.jsx)(On,{className:`w-3.5 h-3.5 flex-shrink-0 text-muted-foreground`});default:return null}},yu=({todos:e})=>{let t=To(),{setIsTodoSectionOpen:n}=Eo();if(!e||e.length===0)return null;let r=e.filter(e=>e.status===`completed`).length,i=e.length,a=e.some(e=>e.status===`in_progress`);return(0,J.jsxs)(`div`,{className:`border-t border-border/40 bg-muted/5`,children:[(0,J.jsxs)(`button`,{type:`button`,onClick:()=>n(!t),className:U(`w-full flex items-center gap-2 px-3 py-2 text-xs font-medium transition-colors`,`hover:bg-muted/30`,a&&!t&&`bg-amber-500/5`),children:[t?(0,J.jsx)(K,{className:`w-3.5 h-3.5 text-muted-foreground`}):(0,J.jsx)(et,{className:`w-3.5 h-3.5 text-muted-foreground`}),(0,J.jsx)(Jn,{className:U(`w-3.5 h-3.5`,a?`text-amber-600 dark:text-amber-500`:`text-muted-foreground`)}),(0,J.jsx)(`span`,{className:U(`flex-1 text-left`,a?`text-amber-700 dark:text-amber-400`:`text-muted-foreground`),children:(0,J.jsx)(B,{id:`panel.todo.collapsed_title`})}),(0,J.jsxs)(`span`,{className:U(`text-[10px] px-1.5 py-0.5 rounded-full`,r===i?`bg-green-500/20 text-green-700 dark:text-green-400`:a?`bg-amber-500/20 text-amber-700 dark:text-amber-400`:`bg-muted text-muted-foreground`),children:[r,`/`,i]})]}),t&&(0,J.jsx)(`div`,{className:`p-2 space-y-1 max-h-48 overflow-y-auto border-t border-border/40`,children:e.map(e=>(0,J.jsxs)(`div`,{className:U(`flex items-start gap-2 px-2 py-1.5 text-xs rounded-md transition-colors`,e.status===`completed`&&`text-muted-foreground`,e.status===`in_progress`&&`bg-amber-500/10`),children:[(0,J.jsx)(vu,{status:e.status}),(0,J.jsx)(`span`,{className:U(`flex-1 break-words`,e.status===`completed`&&`line-through`),children:e.content})]},`${e.content}-${e.status}`))})]})},bu=e=>e.toSorted((e,t)=>e.displayPath.localeCompare(t.displayPath)),xu=(e,t)=>{if(t===void 0||t===``)return{internal:[],external:bu(e.map(e=>({...e,displayPath:e.filePath})))};let n=t.endsWith(`/`)?t:`${t}/`,r=[],i=[];for(let a of e)a.filePath.startsWith(n)?r.push({...a,displayPath:a.filePath.slice(n.length)}):a.filePath===t?r.push({...a,displayPath:`.`}):i.push({...a,displayPath:a.filePath});return{internal:bu(r),external:bu(i)}},Su=({title:e,count:t,defaultOpen:n=!1,children:r,icon:i,stickyTop:a=0})=>{let[o,s]=(0,q.useState)(n);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`button`,{type:`button`,onClick:()=>s(!o),style:{top:a},className:`w-full flex items-center gap-2 px-3 py-2 text-xs font-medium text-muted-foreground hover:text-foreground hover:bg-muted/30 transition-colors sticky bg-background z-10 border-b border-border/40`,children:[o?(0,J.jsx)(K,{className:`w-3.5 h-3.5`}):(0,J.jsx)(et,{className:`w-3.5 h-3.5`}),i,(0,J.jsx)(`span`,{className:`flex-1 text-left`,children:e}),(0,J.jsx)(`span`,{className:`text-[10px] bg-muted px-1.5 py-0.5 rounded-full`,children:t})]}),o&&(0,J.jsx)(`div`,{className:`px-1 pb-2 border-b border-border/40`,children:r})]})},Cu=({filePath:e,displayPath:t,toolName:n,projectId:r,isExternal:i})=>{let a=async()=>{try{await navigator.clipboard.writeText(e),z.success(`File path copied`)}catch(e){console.error(`Failed to copy file path:`,e),z.error(`Failed to copy file path`)}};return(0,J.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1.5 text-xs font-normal hover:bg-accent rounded-md transition-colors`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2 flex-1 min-w-0`,children:[i===!0?(0,J.jsx)(In,{className:`h-3.5 w-3.5 flex-shrink-0 text-muted-foreground`}):(0,J.jsx)(zn,{className:`h-3.5 w-3.5 flex-shrink-0 text-muted-foreground`}),(0,J.jsx)(`span`,{className:`truncate text-left flex-1 font-mono text-xs`,children:t}),(0,J.jsx)(`span`,{className:`text-[10px] text-muted-foreground/70 flex-shrink-0 bg-muted/50 px-1.5 py-0.5 rounded`,children:n})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-1 flex-shrink-0`,children:[(0,J.jsx)(Sc,{projectId:r,filePaths:[e],children:(0,J.jsx)(H,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0`,"aria-label":`Open file`,children:(0,J.jsx)(yt,{className:`h-3.5 w-3.5 text-muted-foreground`})})}),(0,J.jsx)(H,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0`,onClick:()=>void a(),"aria-label":`Copy file path`,children:(0,J.jsx)(Nn,{className:`h-3.5 w-3.5 text-muted-foreground`})})]})]})},wu=({name:e,timestamp:t,inputSummary:n})=>{let r=(0,q.useMemo)(()=>{try{return new Date(t).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}catch{return``}},[t]);return(0,J.jsxs)(`div`,{className:`flex items-start gap-2 px-2 py-1.5 text-xs hover:bg-muted/30 rounded-md transition-colors`,children:[(0,J.jsx)(_r,{className:`h-3.5 w-3.5 flex-shrink-0 text-muted-foreground mt-0.5`}),(0,J.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`span`,{className:`font-medium text-foreground`,children:e}),(0,J.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:r})]}),n&&(0,J.jsx)(`p`,{className:`text-[10px] text-muted-foreground truncate mt-0.5 font-mono`,children:n})]})]})},Tu=({message:e,icon:t})=>(0,J.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-3 text-xs text-muted-foreground`,children:[t,(0,J.jsx)(`span`,{children:e})]}),Eu=({title:e,count:t,defaultOpen:n=!1,children:r,icon:i,stickyTop:a=0})=>(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{style:{top:a},className:`w-full flex items-center gap-2 px-3 py-2 text-xs font-medium text-muted-foreground sticky bg-background z-10 border-b border-border/40`,children:[(0,J.jsx)(K,{className:`w-3.5 h-3.5`}),i,(0,J.jsx)(`span`,{className:`flex-1 text-left`,children:e}),(0,J.jsx)(`span`,{className:`text-[10px] bg-muted px-1.5 py-0.5 rounded-full`,children:t})]}),n&&(0,J.jsx)(`div`,{className:`px-1 pb-2 border-b border-border/40`,children:r})]}),Du=()=>void 0,Ou=({projectId:e,sessionId:t,agentId:n,title:r,isOpen:i,onOpenChange:a})=>{let o=(0,q.useRef)(null),{data:s,isLoading:c,error:l,refetch:u}=we({...C(e,n,t),enabled:i,staleTime:0}),d=s?.conversations??[];return(0,J.jsx)(Be,{open:i,onOpenChange:a,children:(0,J.jsxs)(Ue,{className:`w-[95vw] md:w-[90vw] lg:w-[85vw] max-w-[1400px] h-[85vh] max-h-[85vh] flex flex-col p-0`,"data-testid":`agent-session-modal`,children:[(0,J.jsx)(We,{className:`px-6 py-4 border-b bg-muted/30`,children:(0,J.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,J.jsx)(`div`,{className:`flex-shrink-0 mt-1`,children:(0,J.jsx)(`div`,{className:`h-10 w-10 rounded-lg bg-primary/10 flex items-center justify-center`,children:(0,J.jsx)(_e,{className:`h-5 w-5 text-primary`})})}),(0,J.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,J.jsx)(Ae,{className:`text-lg font-semibold leading-tight mb-1 pr-2`,children:r.length>120?`${r.slice(0,120)}...`:r}),(0,J.jsxs)(ke,{className:`text-xs flex items-center gap-2 flex-wrap`,children:[(0,J.jsxs)(`span`,{className:`flex items-center gap-1`,children:[`Agent:`,` `,(0,J.jsx)(`code`,{className:`px-1.5 py-0.5 bg-muted rounded text-[10px] font-mono`,children:n.slice(0,8)})]}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`|`}),(0,J.jsx)(`span`,{children:(0,J.jsx)(B,{id:`assistant.tool.message_count`,values:{count:d.length}})})]})]})]})}),(0,J.jsxs)(`div`,{ref:o,className:`flex-1 overflow-auto px-6 py-4`,children:[c&&(0,J.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-4`,children:[(0,J.jsx)(A,{className:`h-8 w-8 animate-spin text-primary`}),(0,J.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:(0,J.jsx)(B,{id:`assistant.tool.loading_task`})})]}),l!==null&&!c&&(0,J.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-4`,children:[(0,J.jsx)(Dn,{className:`h-8 w-8 text-destructive`}),(0,J.jsx)(`p`,{className:`text-sm text-destructive`,children:(0,J.jsx)(B,{id:`assistant.tool.error_loading_task`})}),(0,J.jsx)(H,{variant:`outline`,size:`sm`,onClick:()=>void u(),children:(0,J.jsx)(B,{id:`assistant.tool.retry`})})]}),!c&&l===null&&d.length===0&&(0,J.jsx)(`div`,{className:`flex flex-col items-center justify-center h-full gap-4`,children:(0,J.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:(0,J.jsx)(B,{id:`assistant.tool.no_task_data`})})}),!c&&l===null&&d.length>0&&(0,J.jsx)(su,{conversations:d.map(e=>({...e,isSidechain:!1})),getToolResult:Du,projectId:e,sessionId:t,scheduledJobs:[],scrollContainerRef:o})]})]})})},ku=({agentId:e,firstMessage:t,onClick:n})=>{let r=t??`Agent ${e.slice(0,8)}`,i=r.length>80?`${r.slice(0,80)}...`:r;return(0,J.jsxs)(H,{variant:`ghost`,size:`sm`,className:`w-full justify-start h-auto py-1.5 px-2 text-xs font-normal hover:bg-accent gap-2 rounded-md`,onClick:n,children:[(0,J.jsx)(_n,{className:`h-3.5 w-3.5 flex-shrink-0 text-muted-foreground`}),(0,J.jsx)(`span`,{className:`truncate text-left flex-1 text-xs`,children:i}),(0,J.jsx)(`span`,{className:`text-[10px] text-muted-foreground/70 flex-shrink-0 bg-muted/50 px-1.5 py-0.5 rounded font-mono`,children:e.slice(0,8)})]})},Au=()=>(0,J.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,J.jsxs)(`div`,{className:`flex-1 min-h-0 overflow-y-auto`,children:[(0,J.jsx)(`div`,{className:`px-3 py-3 border-b border-border/40 bg-muted/10`,children:(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:(0,J.jsx)(B,{id:`session.empty_state.description`})})}),(0,J.jsx)(Eu,{title:(0,J.jsx)(B,{id:`panel.files.edited_section`}),count:0,icon:(0,J.jsx)(zn,{className:`w-3.5 h-3.5`}),stickyTop:0,children:(0,J.jsx)(Tu,{icon:(0,J.jsx)(zn,{className:`h-3.5 w-3.5`}),message:(0,J.jsx)(B,{id:`panel.files.no_edited_files`})})}),(0,J.jsx)(Eu,{title:(0,J.jsx)(B,{id:`panel.files.tool_calls_section`}),count:0,icon:(0,J.jsx)(xr,{className:`w-3.5 h-3.5`}),stickyTop:33,children:(0,J.jsx)(Tu,{icon:(0,J.jsx)(xr,{className:`h-3.5 w-3.5`}),message:(0,J.jsx)(B,{id:`panel.files.no_tool_calls`})})}),(0,J.jsx)(Eu,{title:`Agents`,count:0,icon:(0,J.jsx)(_n,{className:`w-3.5 h-3.5`}),stickyTop:66,children:(0,J.jsx)(Tu,{icon:(0,J.jsx)(_n,{className:`h-3.5 w-3.5`}),message:(0,J.jsx)(B,{id:`panel.files.no_agents`})})})]}),(0,J.jsx)(yu,{todos:null})]}),ju=({projectId:e,sessionId:t})=>{let{conversations:n}=_u(e,t),[r,i]=(0,q.useState)(new Set),[a,o]=(0,q.useState)(null),{data:s,isPending:c}=we({...M(e,t)}),l=(0,q.useMemo)(()=>s?.agentSessions??[],[s?.agentSessions]),u=l.length>0,d=(0,q.useMemo)(()=>a===null?``:l.find(e=>e.agentId===a)?.firstMessage??`Agent ${a.slice(0,8)}`,[a,l]),f=(0,q.useCallback)(e=>{o(e)},[]),p=(0,q.useCallback)(e=>{e||o(null)},[]),m=(0,q.useMemo)(()=>$s(n),[n]),h=(0,q.useMemo)(()=>tc(n),[n]),g=(0,q.useMemo)(()=>{let e=new Set(h.map(e=>e.name));return Array.from(e).sort()},[h]),_=(0,q.useMemo)(()=>r.size===0?h:h.filter(e=>r.has(e.name)),[h,r]),v=(0,q.useMemo)(()=>{for(let e of n)if(`cwd`in e&&typeof e.cwd==`string`)return e.cwd},[n]),y=(0,q.useMemo)(()=>xu(m,v),[m,v]),b=(0,q.useMemo)(()=>rc(n),[n]),x=y.internal.length>0||y.external.length>0,S=_.length>0,C=e=>{i(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};return(0,J.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,J.jsxs)(`div`,{className:`flex-1 min-h-0 overflow-y-auto`,children:[(0,J.jsx)(Su,{title:(0,J.jsx)(B,{id:`panel.files.edited_section`}),count:m.length,icon:(0,J.jsx)(zn,{className:`w-3.5 h-3.5`}),stickyTop:0,children:x?(0,J.jsxs)(J.Fragment,{children:[y.internal.length>0&&(0,J.jsx)(`div`,{className:`space-y-0.5`,children:y.internal.map(t=>(0,J.jsx)(Cu,{filePath:t.filePath,displayPath:t.displayPath,toolName:t.toolName,projectId:e},t.filePath))}),y.external.length>0&&(0,J.jsxs)(`div`,{className:`space-y-0.5 mt-2`,children:[(0,J.jsx)(`div`,{className:`px-2 py-1 text-[10px] font-medium text-muted-foreground/70 uppercase tracking-wider`,children:(0,J.jsx)(B,{id:`sidebar.edited_files.external`})}),y.external.map(t=>(0,J.jsx)(Cu,{filePath:t.filePath,displayPath:t.displayPath,toolName:t.toolName,projectId:e,isExternal:!0},t.filePath))]})]}):(0,J.jsx)(Tu,{icon:(0,J.jsx)(zn,{className:`h-3.5 w-3.5`}),message:(0,J.jsx)(B,{id:`panel.files.no_edited_files`})})}),(0,J.jsxs)(Su,{title:(0,J.jsx)(B,{id:`panel.files.tool_calls_section`}),count:_.length,icon:(0,J.jsx)(xr,{className:`w-3.5 h-3.5`}),stickyTop:33,children:[h.length>0&&(0,J.jsx)(`div`,{className:`px-2 pb-2`,children:(0,J.jsxs)(ot,{children:[(0,J.jsx)(ut,{asChild:!0,children:(0,J.jsxs)(H,{variant:`outline`,size:`sm`,className:U(`h-7 text-xs gap-1.5`,r.size>0&&`border-primary text-primary`),children:[(0,J.jsx)(Bn,{className:`w-3 h-3`}),(0,J.jsx)(B,{id:`panel.files.filter_tools`}),r.size>0&&(0,J.jsx)(`span`,{className:`ml-1 px-1 py-0.5 bg-primary/10 rounded text-[10px]`,children:r.size})]})}),(0,J.jsxs)($e,{align:`start`,className:`w-48 p-2`,children:[(0,J.jsx)(`div`,{className:`space-y-1`,children:g.map(e=>(0,J.jsxs)(`button`,{type:`button`,className:`flex items-center gap-2 px-2 py-1 hover:bg-muted/50 rounded cursor-pointer w-full text-left`,onClick:()=>C(e),children:[(0,J.jsx)(lt,{checked:r.has(e),onCheckedChange:()=>C(e)}),(0,J.jsx)(`span`,{className:`text-xs`,children:e})]},e))}),r.size>0&&(0,J.jsx)(H,{variant:`ghost`,size:`sm`,className:`w-full mt-2 h-7 text-xs`,onClick:()=>{i(new Set)},children:`Clear filter`})]})]})}),S?(0,J.jsx)(`div`,{className:`space-y-0.5`,children:_.map(e=>(0,J.jsx)(wu,{name:e.name,timestamp:e.timestamp,inputSummary:e.inputSummary},e.id))}):(0,J.jsx)(Tu,{icon:(0,J.jsx)(xr,{className:`h-3.5 w-3.5`}),message:r.size>0?(0,J.jsx)(B,{id:`panel.files.no_filtered_tool_calls`}):(0,J.jsx)(B,{id:`panel.files.no_tool_calls`})})]}),(0,J.jsx)(Su,{title:`Agents`,count:l.length,icon:(0,J.jsx)(_n,{className:`w-3.5 h-3.5`}),stickyTop:66,children:c?(0,J.jsx)(Tu,{icon:(0,J.jsx)(A,{className:`h-3.5 w-3.5 animate-spin`}),message:(0,J.jsx)(B,{id:`panel.files.loading_agents`})}):u?(0,J.jsx)(`div`,{className:`space-y-0.5`,children:l.map(e=>(0,J.jsx)(ku,{agentId:e.agentId,firstMessage:e.firstMessage,onClick:()=>f(e.agentId)},e.agentId))}):(0,J.jsx)(Tu,{icon:(0,J.jsx)(_n,{className:`h-3.5 w-3.5`}),message:(0,J.jsx)(B,{id:`panel.files.no_agents`})})})]}),(0,J.jsx)(yu,{todos:b}),a!==null&&(0,J.jsx)(Ou,{projectId:e,sessionId:t,agentId:a,title:d,isOpen:!0,onOpenChange:p})]})},Mu=Xa,Nu=q.forwardRef(({className:e,...t},n)=>(0,J.jsx)(Za,{ref:n,"data-slot":`tabs-list`,className:U(`inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground gap-1`,e),...t}));Nu.displayName=Za.displayName;var Pu=q.forwardRef(({className:e,...t},n)=>(0,J.jsx)(Qa,{ref:n,"data-slot":`tabs-trigger`,className:U(`inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1.5 text-sm font-medium ring-offset-background transition-all disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 gap-2 [&_svg]:size-4 [&_svg]:shrink-0`,e),...t}));Pu.displayName=Qa.displayName;var Fu=q.forwardRef(({className:e,...t},n)=>(0,J.jsx)($a,{ref:n,"data-slot":`tabs-content`,className:U(`mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,e),...t}));Fu.displayName=$a.displayName;var Iu=e=>we({queryKey:j(e).queryKey,queryFn:j(e).queryFn,staleTime:3e4}),Lu=e=>s({queryKey:j(e).queryKey,queryFn:j(e).queryFn,staleTime:3e4}),Ru=e=>s({queryKey:x(e).queryKey,queryFn:x(e).queryFn,staleTime:3e4}),zu=(e,t,n)=>s({queryKey:D(e,t,n).queryKey,queryFn:D(e,t,n).queryFn,staleTime:3e4}),Bu=e=>{let t=re();return p({mutationFn:async t=>{let n=await o.api.projects[`:projectId`].git.checkout.$post({param:{projectId:e},json:{branchName:t}});if(!n.ok)throw Error(`Failed to checkout: ${n.statusText}`);return n.json()},onSuccess:()=>{t.invalidateQueries({queryKey:x(e).queryKey}),t.invalidateQueries({queryKey:j(e).queryKey}),t.invalidateQueries({queryKey:[`git`,`diff`,e]})}})},Vu=()=>p({mutationFn:async({projectId:e,fromRef:t,toRef:n})=>{let r=await o.api.projects[`:projectId`].git.diff.$post({param:{projectId:e},json:{fromRef:t,toRef:n}});if(!r.ok)throw Error(`Failed to get diff: ${r.statusText}`);return r.json()}}),Hu=e=>p({mutationFn:async({files:t,message:n})=>{let r=await o.api.projects[`:projectId`].git.commit.$post({param:{projectId:e},json:{files:t,message:n}});if(!r.ok)throw Error(`Failed to commit files: ${r.statusText}`);return r.json()}}),Uu=e=>p({mutationFn:async()=>{let t=await o.api.projects[`:projectId`].git.push.$post({param:{projectId:e}});if(!t.ok)throw Error(`Failed to push commits: ${t.statusText}`);return t.json()}}),Wu=e=>p({mutationFn:async({files:t,message:n})=>{let r=await o.api.projects[`:projectId`].git[`commit-and-push`].$post({param:{projectId:e},json:{files:t,message:n}});if(!r.ok)throw Error(`Failed to commit and push: ${r.statusText}`);return r.json()}}),Gu=()=>(0,J.jsxs)(H,{variant:`ghost`,size:`sm`,className:`flex-1 min-w-0 justify-start gap-2 h-7 px-2 text-xs font-normal`,disabled:!0,children:[(0,J.jsx)(Vn,{className:`w-3.5 h-3.5 text-muted-foreground flex-shrink-0`}),(0,J.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,J.jsx)(A,{className:`w-3 h-3 animate-spin`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`Loading...`})]})]}),Ku=({projectId:e})=>{let[t,n]=(0,q.useState)(!1),{data:r}=Lu(e),{data:i}=Ru(e),{mutate:a,isPending:o}=Bu(e),s=r?.success?r.data.currentBranch?.name??null:null,c=(0,q.useMemo)(()=>i?.success?i.data.branches:[],[i]),l=e=>{if(e===s){n(!1);return}a(e,{onSuccess:t=>{t.success?z.success(`Switched to ${e}`):z.error(`Failed to switch branch`),n(!1)},onError:()=>{z.error(`Failed to switch branch`),n(!1)}})};return(0,J.jsxs)(ot,{open:t,onOpenChange:n,children:[(0,J.jsx)(ut,{asChild:!0,children:(0,J.jsxs)(H,{variant:`ghost`,size:`sm`,className:`flex-1 min-w-0 justify-start gap-2 h-7 px-2 text-xs font-normal`,disabled:o,children:[(0,J.jsx)(Vn,{className:`w-3.5 h-3.5 text-muted-foreground flex-shrink-0`}),(0,J.jsx)(`span`,{className:`font-mono truncate flex-1 text-left`,children:o?(0,J.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,J.jsx)(A,{className:`w-3 h-3 animate-spin`}),`Switching...`]}):s??`No branch`})]})}),(0,J.jsx)($e,{className:`w-64 p-0`,align:`start`,children:(0,J.jsxs)(ws,{children:[(0,J.jsx)(Ts,{placeholder:`Search branch...`,className:`h-8`}),(0,J.jsxs)(Es,{children:[(0,J.jsx)(Ds,{children:`No branch found.`}),(0,J.jsx)(Os,{children:c.map(e=>(0,J.jsxs)(ks,{value:e.name,onSelect:()=>l(e.name),className:`text-xs`,children:[(0,J.jsx)(Vn,{className:`w-3.5 h-3.5 mr-2 text-muted-foreground`}),(0,J.jsx)(`span`,{className:`font-mono truncate flex-1`,children:e.name}),e.name===s&&(0,J.jsx)(_t,{className:`w-3.5 h-3.5 text-primary`})]},e.name))})]})]})})]})},qu=({projectId:e,filePath:t,status:n,additions:r,deletions:i,diffHunks:a,children:o})=>{let[s,c]=(0,q.useState)(!1),[l,u]=(0,q.useState)(`diff`),{resolvedTheme:d}=Vt(),f=d===`dark`?qt:Qt,p=e=>{(e===`content`||e===`diff`)&&u(e)},{data:m,isLoading:h,error:g,refetch:_}=we({...b(e,t),enabled:s&&l===`content`}),v=t.split(`/`).pop()??t,y=m?.success===!0?m.language:Xs(t);return(0,J.jsxs)(Be,{open:s,onOpenChange:c,children:[(0,J.jsx)(Me,{asChild:!0,children:o}),(0,J.jsxs)(Ue,{className:`w-[95vw] md:w-[90vw] lg:w-[90vw] max-w-[1600px] h-[85vh] max-h-[85vh] flex flex-col p-0`,"data-testid":`git-file-dialog`,children:[(0,J.jsx)(We,{className:`px-6 py-4 border-b bg-muted/30`,children:(0,J.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,J.jsx)(`div`,{className:`flex-shrink-0 mt-1`,children:(0,J.jsx)(`div`,{className:`h-10 w-10 rounded-lg bg-primary/10 flex items-center justify-center`,children:(0,J.jsx)(Ln,{className:`h-5 w-5 text-primary`})})}),(0,J.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,J.jsx)(Ae,{className:`text-lg font-semibold leading-tight mb-1 pr-8 break-all`,children:v}),(0,J.jsx)(ke,{className:`text-xs flex items-center gap-2 flex-wrap`,asChild:!0,children:(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`code`,{className:`px-1.5 py-0.5 bg-muted rounded text-[10px] font-mono break-all`,children:t}),(0,J.jsx)(Y,{variant:`secondary`,className:U(`text-[10px]`,n===`added`&&`bg-green-500/20 text-green-700`,n===`deleted`&&`bg-red-500/20 text-red-700`,n===`modified`&&`bg-amber-500/20 text-amber-700`,n===`renamed`&&`bg-blue-500/20 text-blue-700`),children:n}),r>0&&(0,J.jsxs)(`span`,{className:`text-green-600 dark:text-green-400 text-[10px]`,children:[`+`,r]}),i>0&&(0,J.jsxs)(`span`,{className:`text-red-600 dark:text-red-400 text-[10px]`,children:[`-`,i]})]})})]})]})}),(0,J.jsxs)(Mu,{value:l,onValueChange:p,className:`flex-1 flex flex-col overflow-hidden`,children:[(0,J.jsxs)(Nu,{className:`mx-4 mt-2 w-fit`,children:[(0,J.jsxs)(Pu,{value:`diff`,className:`text-xs`,children:[(0,J.jsx)(Hn,{className:`w-3.5 h-3.5 mr-1`}),(0,J.jsx)(B,{id:`panel.git.view_diff`})]}),(0,J.jsxs)(Pu,{value:`content`,className:`text-xs`,children:[(0,J.jsx)(yt,{className:`w-3.5 h-3.5 mr-1`}),(0,J.jsx)(B,{id:`panel.git.view_content`})]})]}),(0,J.jsx)(Fu,{value:`diff`,className:`flex-1 overflow-auto m-0 p-4`,children:a&&a.length>0?(0,J.jsx)(ul,{fileDiff:{filename:t,isNew:n===`added`,isDeleted:n===`deleted`,isRenamed:n===`renamed`,isBinary:!1,hunks:a,linesAdded:r,linesDeleted:i}}):(0,J.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground text-sm`,children:`No diff available`})}),(0,J.jsxs)(Fu,{value:`content`,className:`flex-1 overflow-auto m-0`,children:[h&&(0,J.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-4`,children:[(0,J.jsx)(A,{className:`h-8 w-8 animate-spin text-primary`}),(0,J.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:(0,J.jsx)(B,{id:`assistant.tool.loading_file`})})]}),g!==null&&(0,J.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-4 px-6`,children:[(0,J.jsx)(Ft,{className:`h-8 w-8 text-destructive`}),(0,J.jsx)(`p`,{className:`text-sm text-destructive text-center`,children:(0,J.jsx)(B,{id:`assistant.tool.error_loading_file`})}),(0,J.jsx)(H,{variant:`outline`,size:`sm`,onClick:()=>{_()},children:(0,J.jsx)(B,{id:`assistant.tool.retry`})})]}),m&&!m.success&&(0,J.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-4 px-6`,children:[(0,J.jsx)(Ft,{className:`h-8 w-8 text-destructive`}),(0,J.jsxs)(`p`,{className:`text-sm text-destructive text-center`,children:[m.error===`NOT_FOUND`&&(0,J.jsx)(B,{id:`assistant.tool.file_not_found`}),m.error===`BINARY_FILE`&&(0,J.jsx)(B,{id:`assistant.tool.binary_file`}),m.error===`INVALID_PATH`&&(0,J.jsx)(B,{id:`assistant.tool.invalid_path`}),m.error===`READ_ERROR`&&(0,J.jsx)(B,{id:`assistant.tool.read_error`})]})]}),m?.success===!0&&(0,J.jsx)(dn,{style:f,language:y,showLineNumbers:!0,wrapLines:!0,customStyle:{margin:0,borderRadius:0,fontSize:`0.75rem`,minHeight:`100%`},lineNumberStyle:{minWidth:`3em`,paddingRight:`1em`,textAlign:`right`,userSelect:`none`},children:m.content})]})]})]})]})},Ju=()=>(0,J.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,J.jsx)(A,{className:`w-5 h-5 animate-spin text-muted-foreground`})}),Yu=({projectId:e})=>{let{i18n:t}=Xe(),n=(0,q.useId)(),{data:r}=zu(e,`HEAD`,`working`),i=re(),a=r?.success?r.data.files:[],o=a.length>0,[s,c]=(0,q.useState)(()=>new Map),[l,u]=(0,q.useState)(``),[d,f]=(0,q.useState)(!1),p=Hu(e),m=Uu(e),h=Wu(e),g=r?.success===!0?r.data:void 0,_=(0,q.useMemo)(()=>{let e=new Map;if(g===void 0)return e;for(let t of g.diffs)e.set(t.file.filePath,{hunks:t.hunks});return e},[g]);(0,q.useEffect)(()=>{g!==void 0&&g.files.length>0&&c(new Map(g.files.map(e=>[e.filePath,!0])))},[g]);let v=e=>{c(t=>{let n=new Map(t);return n.set(e,t.get(e)!==!0),n})},y=()=>{g!==void 0&&g.files.length>0&&c(new Map(g.files.map(e=>[e.filePath,!0])))},b=()=>{g!==void 0&&g.files.length>0&&c(new Map(g.files.map(e=>[e.filePath,!1])))},x=(0,q.useCallback)(()=>{i.invalidateQueries({queryKey:[`git`,`diff`,e]})},[i,e]),S=async()=>{let e=Array.from(s.entries()).filter(([,e])=>e).map(([e])=>e);try{let t=await p.mutateAsync({files:e,message:l});t.success?(z.success(`Committed ${t.filesCommitted} files (${t.commitSha.slice(0,7)})`),u(``),x()):z.error(t.error,{description:t.details})}catch{z.error(t._(`Failed to commit`))}},C=async()=>{try{let e=await m.mutateAsync();e.success?z.success(`Pushed to ${e.remote}/${e.branch}`):z.error(e.error,{description:e.details})}catch{z.error(t._(`Failed to push`))}},w=async()=>{let e=Array.from(s.entries()).filter(([,e])=>e).map(([e])=>e);try{let n=await h.mutateAsync({files:e,message:l});n.success?(z.success(`Committed and pushed (${n.commitSha.slice(0,7)})`),u(``),x()):n.success===!1&&`commitSucceeded`in n&&n.commitSucceeded?(z.warning(`Committed (${n.commitSha?.slice(0,7)}), but push failed: ${n.error}`,{action:{label:t._(`Retry Push`),onClick:()=>{C()}}}),u(``),x()):z.error(n.error,{description:n.details})}catch{z.error(t._(`Failed to commit and push`))}},T=Array.from(s.values()).filter(Boolean).length,E=T===0||l.trim().length===0||p.isPending;return o?(0,J.jsxs)(`div`,{className:`flex flex-col`,children:[(0,J.jsxs)(`div`,{className:`mx-2 mt-2 mb-1 bg-gray-50 dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-700`,children:[(0,J.jsxs)(`button`,{type:`button`,onClick:()=>f(!d),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:[(0,J.jsx)(`span`,{className:`text-xs font-medium text-gray-700 dark:text-gray-300`,children:(0,J.jsx)(B,{id:`diff.commit.changes`})}),d?(0,J.jsx)(bn,{className:`h-4 w-4 text-gray-600 dark:text-gray-400`}):(0,J.jsx)(K,{className:`h-4 w-4 text-gray-600 dark:text-gray-400`})]}),d&&(0,J.jsxs)(`div`,{className:`p-3 pt-0 space-y-3`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,J.jsx)(H,{size:`sm`,variant:`ghost`,onClick:y,disabled:p.isPending,className:`h-6 text-[10px]`,children:(0,J.jsx)(B,{id:`diff.select.all`})}),(0,J.jsx)(H,{size:`sm`,variant:`ghost`,onClick:b,disabled:p.isPending,className:`h-6 text-[10px]`,children:(0,J.jsx)(B,{id:`diff.deselect.all`})}),(0,J.jsxs)(`span`,{className:`text-[10px] text-gray-600 dark:text-gray-400`,children:[T,` / `,a.length,` files`]})]}),(0,J.jsxs)(`div`,{className:`space-y-1`,children:[(0,J.jsx)(`label`,{htmlFor:n,className:`text-[10px] font-medium text-gray-700 dark:text-gray-300`,children:(0,J.jsx)(B,{id:`diff.commit.message`})}),(0,J.jsx)(Zc,{id:n,placeholder:`Enter commit message...`,value:l,onChange:e=>u(e.target.value),disabled:p.isPending,className:`resize-none text-xs min-h-[60px]`,rows:2})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5 flex-wrap`,children:[(0,J.jsx)(H,{onClick:()=>{S()},disabled:E,size:`sm`,className:`h-7 text-xs`,children:p.isPending?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(A,{className:`w-3 h-3 mr-1 animate-spin`}),(0,J.jsx)(B,{id:`diff.committing`})]}):(0,J.jsx)(B,{id:`diff.commit`})}),(0,J.jsx)(H,{onClick:()=>{C()},disabled:m.isPending,variant:`outline`,size:`sm`,className:`h-7 text-xs`,children:m.isPending?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(A,{className:`w-3 h-3 mr-1 animate-spin`}),(0,J.jsx)(B,{id:`diff.pushing`})]}):(0,J.jsx)(B,{id:`diff.push`})}),(0,J.jsx)(H,{onClick:()=>{w()},disabled:E||h.isPending,variant:`secondary`,size:`sm`,className:`h-7 text-xs`,children:h.isPending?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(A,{className:`w-3 h-3 mr-1 animate-spin`}),(0,J.jsx)(B,{id:`diff.committing.pushing`})]}):(0,J.jsx)(B,{id:`diff.commit.push`})})]})]})]}),(0,J.jsx)(`div`,{className:`p-2 space-y-1`,children:a.map(t=>{let n=_.get(t.filePath);return(0,J.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,J.jsx)(lt,{checked:s.get(t.filePath)??!1,onCheckedChange:()=>v(t.filePath),disabled:p.isPending,className:`h-3 w-3 flex-shrink-0`}),(0,J.jsx)(qu,{projectId:e,filePath:t.filePath,status:t.status,additions:t.additions,deletions:t.deletions,diffHunks:n?.hunks,children:(0,J.jsxs)(`button`,{type:`button`,className:`w-full flex items-center gap-2 px-1.5 py-1.5 text-xs hover:bg-muted/30 rounded-md transition-colors text-left`,"data-testid":`git-file-button`,children:[(0,J.jsx)(`span`,{className:U(`w-1.5 h-1.5 rounded-full flex-shrink-0`,t.status===`added`&&`bg-green-500`,t.status===`deleted`&&`bg-red-500`,t.status===`modified`&&`bg-amber-500`,t.status===`renamed`&&`bg-blue-500`)}),(0,J.jsx)(`span`,{className:`truncate flex-1 font-mono`,children:t.filePath}),(0,J.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[10px] text-muted-foreground`,children:[t.additions>0&&(0,J.jsxs)(`span`,{className:`text-green-600 dark:text-green-400`,children:[`+`,t.additions]}),t.deletions>0&&(0,J.jsxs)(`span`,{className:`text-red-600 dark:text-red-400`,children:[`-`,t.deletions]})]})]})})]},t.filePath)})})]}):(0,J.jsx)(`div`,{className:`flex-1 flex items-center justify-center p-8`,children:(0,J.jsxs)(`div`,{className:`text-center space-y-3`,children:[(0,J.jsx)(`div`,{className:`w-12 h-12 mx-auto rounded-xl bg-muted/30 flex items-center justify-center`,children:(0,J.jsx)(Hn,{className:`w-6 h-6 text-muted-foreground/50`})}),(0,J.jsx)(`div`,{className:`space-y-1`,children:(0,J.jsx)(`p`,{className:`text-sm font-medium text-muted-foreground`,children:(0,J.jsx)(B,{id:`panel.git.empty`})})})]})})},Xu=({projectId:e,sessionId:t})=>{let{conversations:n}=_u(e,t);return(0,J.jsx)(yu,{todos:(0,q.useMemo)(()=>rc(n),[n])})},Zu=({projectId:e,sessionId:t})=>{let{session:n}=_u(e,t),r=n.meta.prLinks;return r.length===0?null:(0,J.jsx)(`div`,{className:`border-t border-border/40`,children:(0,J.jsxs)(`div`,{className:`px-3 py-2 bg-muted/10`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-2`,children:[(0,J.jsx)(Un,{className:`w-3.5 h-3.5 text-muted-foreground`}),(0,J.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:(0,J.jsx)(B,{id:`panel.git.pr_links`})})]}),(0,J.jsx)(`div`,{className:`space-y-1.5`,children:r.map(e=>(0,J.jsxs)(`a`,{href:e.prUrl,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-2 px-2 py-1.5 rounded-md hover:bg-muted/50 transition-colors group text-xs`,children:[(0,J.jsx)(Un,{className:`w-3.5 h-3.5 text-emerald-500 flex-shrink-0`}),(0,J.jsxs)(`span`,{className:`flex-1 min-w-0 truncate text-foreground`,children:[e.prRepository,`#`,e.prNumber]}),(0,J.jsx)(In,{className:`w-3 h-3 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity flex-shrink-0`})]},`${e.prRepository}#${e.prNumber}`))})]})})},Qu=({projectId:e,sessionId:t})=>{let n=re(),r=wr({predicate:t=>t.queryKey[0]===`git`&&t.queryKey.includes(e)})>0,i=(0,q.useCallback)(()=>{n.invalidateQueries({queryKey:j(e).queryKey}),n.invalidateQueries({queryKey:x(e).queryKey}),n.invalidateQueries({queryKey:[`git`,`diff`,e]})},[n,e]);return(0,J.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,J.jsxs)(`div`,{className:`border-b border-border/40 px-3 py-2 bg-muted/10 flex items-center gap-1`,children:[(0,J.jsx)(q.Suspense,{fallback:(0,J.jsx)(Gu,{}),children:(0,J.jsx)(Ku,{projectId:e})}),(0,J.jsx)(H,{variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0 flex-shrink-0`,onClick:i,disabled:r,children:(0,J.jsx)(Rt,{className:U(`w-3.5 h-3.5 text-muted-foreground`,r&&`animate-spin`)})})]}),(0,J.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto`,children:(0,J.jsx)(q.Suspense,{fallback:(0,J.jsx)(Ju,{}),children:(0,J.jsx)(Yu,{projectId:e})})}),t!==void 0&&t!==``&&(0,J.jsx)(q.Suspense,{fallback:null,children:(0,J.jsx)(Zu,{projectId:e,sessionId:t})}),t!==void 0&&t!==``&&(0,J.jsx)(q.Suspense,{fallback:null,children:(0,J.jsx)(Xu,{projectId:e,sessionId:t})})]})},$u=xe(R(),R()),ed=({projectId:e,sessionId:t})=>`${e}:${t}`,td=(e,t)=>{let n=$u.safeParse(e);return n.success?n.data:t},nd=(e,t,n)=>{if(n===``){let{[t]:n,...r}=e;return r}return{...e,[t]:n}},rd=Lc(()=>localStorage),id=zc(`claude-code-viewer-chat-input-drafts`,{},{getItem:(e,t)=>td(rd.getItem(e,t),t),setItem:(e,t)=>rd.setItem(e,t),removeItem:e=>rd.removeItem(e)}),ad=e=>{let[t,n]=f(id),r=ed(e);return[t[r]??``,(0,q.useCallback)(e=>{n(t=>{let n=t[r]??``;return nd(t,r,typeof e==`function`?e(n):e)})},[r,n]),(0,q.useCallback)(()=>{n(e=>nd(e,r,``))},[r,n])]},od=({projectId:e,sessionId:t})=>{let{conversations:n}=_u(e,t);return(0,J.jsx)(yu,{todos:(0,q.useMemo)(()=>rc(n),[n])})},sd=({summary:e,className:t})=>(0,J.jsx)(`div`,{className:U(`bg-gray-50 dark:bg-gray-800 rounded-lg p-2 border border-gray-200 dark:border-gray-700`,t),children:(0,J.jsxs)(`div`,{className:`flex items-center justify-between text-sm`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,J.jsx)(Rn,{className:`h-4 w-4 text-gray-600 dark:text-gray-400`}),(0,J.jsxs)(`span`,{className:`font-medium`,children:[e.filesChanged,` `,(0,J.jsx)(B,{id:`diff.files.changed`})]})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-3`,children:[e.insertions>0&&(0,J.jsxs)(`span`,{className:`text-green-600 dark:text-green-400 font-medium`,children:[`+`,e.insertions]}),e.deletions>0&&(0,J.jsxs)(`span`,{className:`text-red-600 dark:text-red-400 font-medium`,children:[`-`,e.deletions]})]})]})}),cd=({label:e,value:t,onValueChange:n,refs:r})=>{let i=(0,q.useId)(),a=e=>{switch(e){case`branch`:return(0,J.jsx)(Vn,{className:`h-4 w-4`});case`commit`:return(0,J.jsx)(`span`,{className:`text-xs`,children:`📝`});case`head`:return(0,J.jsx)(Vn,{className:`h-4 w-4`});case`working`:return(0,J.jsx)(`span`,{className:`text-xs`,children:`🚧`});default:return(0,J.jsx)(Vn,{className:`h-4 w-4`})}};return(0,J.jsxs)(`div`,{className:`space-y-1`,children:[(0,J.jsx)(`label`,{htmlFor:i,className:`text-xs font-medium text-gray-700 dark:text-gray-300`,children:e}),(0,J.jsxs)(gc,{value:t,onValueChange:n,children:[(0,J.jsx)(vc,{className:`w-full h-8 text-xs`,children:(0,J.jsx)(_c,{})}),(0,J.jsx)(xc,{id:i,children:r.map(e=>(0,J.jsx)(X,{value:e.name,className:`text-xs`,children:(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[a(e.type),(0,J.jsx)(`span`,{children:e.displayName}),e.sha!==void 0&&e.sha!==``&&(0,J.jsx)(`span`,{className:`text-[10px] text-gray-500 dark:text-gray-400 font-mono`,children:e.sha.substring(0,7)})]})},e.name))})]})]})},ld=({projectId:e,sessionId:t})=>{let{i18n:n}=Xe(),[r,i]=(0,q.useState)(`HEAD`),[a,o]=(0,q.useState)(`working`),{comments:s,clearComments:c}=Yc(t??``),[,l]=ad({projectId:e,sessionId:t??``}),{data:u,isLoading:d}=Iu(e),{mutate:f,data:p,isPending:m,error:h}=Vu(),g=u?.success===!0?u.data:void 0,_=p?.success===!0?p.data:void 0,v=(e,t,n)=>({name:`branch:${e}`,type:`branch`,displayName:t,sha:n}),y=(e,t)=>({name:`commit:${e}`,type:`commit`,displayName:t,sha:e}),b=g===void 0?[]:[{name:`working`,type:`working`,displayName:n._(`Uncommitted changes`)},{name:`HEAD`,type:`head`,displayName:`HEAD`,...g.head===null?{}:{sha:g.head}},...g.baseBranch===null?[]:[v(g.baseBranch.name,`${g.baseBranch.name} (base)`,g.baseBranch.commit)],...g.currentBranch===null?[]:[v(g.currentBranch.name,`${g.currentBranch.name} (current)`,g.currentBranch.commit)],...g.commits.map(e=>y(e.sha,`${e.message.substring(0,50)}${e.message.length>50?`...`:``}`))],x=(0,q.useCallback)(()=>{r.length>0&&a.length>0&&r!==a&&f({projectId:e,fromRef:r,toRef:a})},[r,a,f,e]);return(0,q.useEffect)(()=>{r.length>0&&a.length>0&&x()},[r,a,x]),d?(0,J.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,J.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,J.jsx)(A,{className:`w-5 h-5 animate-spin text-muted-foreground`})}),t!==void 0&&t!==``?(0,J.jsx)(od,{projectId:e,sessionId:t}):(0,J.jsx)(yu,{todos:null})]}):(0,J.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,J.jsxs)(`div`,{className:`p-3 border-b border-border/40 space-y-2`,children:[(0,J.jsxs)(`div`,{className:`flex gap-2`,children:[(0,J.jsx)(`div`,{className:`flex-1`,children:(0,J.jsx)(cd,{label:n._(`Compare from`),value:r,onValueChange:i,refs:b.filter(e=>e.name!==`working`)})}),(0,J.jsx)(`div`,{className:`flex-1`,children:(0,J.jsx)(cd,{label:n._(`Compare to`),value:a,onValueChange:o,refs:b})})]}),(0,J.jsx)(H,{onClick:x,disabled:m||r===a,size:`sm`,className:`w-full h-7 text-xs`,children:m?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(A,{className:`w-3 h-3 mr-1.5 animate-spin`}),(0,J.jsx)(B,{id:`common.loading`})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(lr,{className:`w-3 h-3 mr-1.5`}),`Refresh`]})})]}),(0,J.jsxs)(`div`,{className:`flex-1 min-h-0 overflow-y-auto`,children:[h&&(0,J.jsx)(`div`,{className:`m-3 bg-red-50 dark:bg-red-900/10 border border-red-200 dark:border-red-800 rounded-lg p-3`,children:(0,J.jsx)(`p`,{className:`text-red-600 dark:text-red-400 text-xs`,children:h.message})}),_===void 0&&!m&&h===null&&(0,J.jsx)(`div`,{className:`flex-1 flex items-center justify-center p-8`,children:(0,J.jsxs)(`div`,{className:`text-center space-y-3`,children:[(0,J.jsx)(`div`,{className:`w-12 h-12 mx-auto rounded-xl bg-muted/30 flex items-center justify-center`,children:(0,J.jsx)(Hn,{className:`w-6 h-6 text-muted-foreground/50`})}),(0,J.jsx)(`div`,{className:`space-y-1`,children:(0,J.jsx)(`p`,{className:`text-sm font-medium text-muted-foreground`,children:(0,J.jsx)(B,{id:`panel.review.empty`})})})]})}),_!==void 0&&(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`div`,{className:`sticky top-0 z-10 flex items-center justify-between border-b border-border/40 bg-background/95 px-3 py-2 backdrop-blur-sm`,children:[(0,J.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:s.length===0?n._(`review.comments.empty`):n._(`review.comments.count`,{count:s.length})}),(0,J.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,J.jsxs)(H,{variant:`ghost`,size:`sm`,disabled:s.length===0,onClick:()=>{c(),z.success(n._(`review.action.reset.success`))},className:`h-7 text-xs`,children:[(0,J.jsx)(vr,{className:`w-3 h-3 mr-1`}),(0,J.jsx)(B,{id:`review.action.reset`})]}),(0,J.jsxs)(H,{variant:`default`,size:`sm`,disabled:s.length===0,onClick:()=>{let e=Xc(s,r,a);l(t=>t?`${t}\n\n${e}`:e),z.success(n._(`review.action.insert.success`))},className:`h-7 text-xs`,children:[(0,J.jsx)(An,{className:`w-3 h-3 mr-1`}),(0,J.jsx)(B,{id:`review.action.insert`})]})]})]}),(0,J.jsxs)(`div`,{className:`p-3 space-y-3`,children:[(0,J.jsx)(sd,{summary:{filesChanged:_.files.length,insertions:_.summary.totalAdditions,deletions:_.summary.totalDeletions}}),(0,J.jsx)(`div`,{className:`space-y-2`,children:_.diffs.map(e=>(0,J.jsx)(ul,{fileDiff:{filename:e.file.filePath,oldFilename:e.file.oldPath,isNew:e.file.status===`added`,isDeleted:e.file.status===`deleted`,isRenamed:e.file.status===`renamed`,isBinary:!1,hunks:e.hunks,linesAdded:e.file.additions,linesDeleted:e.file.deletions},filename:e.file.filePath,reviewSessionId:t},e.file.filePath))})]})]}),m&&(0,J.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,J.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,J.jsx)(A,{className:`w-6 h-6 animate-spin mx-auto text-muted-foreground`}),(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:(0,J.jsx)(B,{id:`diff.loading`})})]})})]}),t!==void 0&&t!==``?(0,J.jsx)(od,{projectId:e,sessionId:t}):(0,J.jsx)(yu,{todos:null})]})},ud={sm:`w-4 h-4`,default:`w-8 h-8`,lg:`w-12 h-12`},dd={sm:`text-sm`,default:`text-base`,lg:`text-lg`},fd=({message:e,size:t=`default`,fullScreen:n=!0,className:r})=>{let i=(0,J.jsxs)(`div`,{className:U(`flex flex-col items-center justify-center gap-3`,r),"data-testid":`loading-indicator`,children:[(0,J.jsx)(A,{className:U(ud[t],`animate-spin text-primary`)}),e!==void 0&&e!==``&&(0,J.jsx)(`p`,{className:U(dd[t],`text-muted-foreground font-medium`),children:e})]});return n?(0,J.jsx)(`div`,{className:`flex items-center justify-center w-full h-full min-h-[400px]`,children:i}):i},pd=48,md=200,hd=({children:e,className:t})=>{let{isLeftPanelOpen:n,leftPanelWidth:r}=go(),{setLeftPanelWidth:i}=_o(),a=Is(),{isResizing:o,handleMouseDown:s}=Ns({onResize:(0,q.useCallback)(e=>{i(e.clientX/window.innerWidth*100)},[i])});if((0,q.useEffect)(()=>(o?(document.body.style.userSelect=`none`,document.body.style.cursor=`ew-resize`,document.body.style.pointerEvents=`none`):(document.body.style.userSelect=``,document.body.style.cursor=``,document.body.style.pointerEvents=``),()=>{document.body.style.userSelect=``,document.body.style.cursor=``,document.body.style.pointerEvents=``}),[o]),a)return null;let c=n?`${r}%`:`${pd}px`,l=n?`${pd+md}px`:`${pd}px`;return(0,J.jsxs)(`div`,{className:U(`relative flex-shrink-0 h-full flex overflow-hidden transition-all duration-200`,t),style:{width:c,minWidth:l,maxWidth:n?`50%`:`${pd}px`,userSelect:o?`none`:`auto`},children:[(0,J.jsx)(`div`,{className:`w-full h-full overflow-hidden`,children:e}),n&&(0,J.jsx)(`div`,{role:`separator`,className:`absolute right-0 top-0 bottom-0 w-1.5 cursor-ew-resize hover:bg-primary/40 active:bg-primary transition-colors z-10`,style:{pointerEvents:`auto`},onMouseDown:s})]})},gd=({startX:e,startY:t,endX:n,endY:r,threshold:i,maxVerticalRatio:a,edgeWidth:o})=>{let s=n-e,c=r-t,l=Math.abs(s);if(l<i||l>0&&Math.abs(c)/l>a)return null;let u=s>0?`right`:`left`;return u===`right`&&o!==void 0&&e>=o?null:u},_d=e=>{let t=e.changedTouches[0];if(t)return{clientX:t.clientX,clientY:t.clientY}},vd=({onSwipe:e,threshold:t=50,maxVerticalRatio:n=.75,edgeWidth:r,enabled:i=!0})=>{let a=(0,q.useRef)(null),o=(0,q.useRef)(null),s=(0,q.useRef)(e);s.current=e;let c=(0,q.useCallback)(e=>{if(o.current?.(),o.current=null,!e||!i)return;let c=e=>{let t=_d(e);t&&(a.current={x:t.clientX,y:t.clientY})},l=e=>{let i=a.current;if(a.current=null,!i)return;let o=_d(e);if(!o)return;let c=gd({startX:i.x,startY:i.y,endX:o.clientX,endY:o.clientY,threshold:t,maxVerticalRatio:n,edgeWidth:r});c&&s.current(c)},u=()=>{a.current=null};e.addEventListener(`touchstart`,c,{passive:!0}),e.addEventListener(`touchend`,l,{passive:!0}),e.addEventListener(`touchcancel`,u,{passive:!0}),o.current=()=>{e.removeEventListener(`touchstart`,c),e.removeEventListener(`touchend`,l),e.removeEventListener(`touchcancel`,u)}},[i,t,n,r]);return(0,q.useEffect)(()=>()=>{o.current?.(),o.current=null},[]),c},yd=(e,t)=>e===void 0?!t:e,bd=()=>{let e=w(),t=Ut.useNavigate(),n=Ut.useSearch(),r=(0,q.useRef)(!1),i=(0,q.useRef)(!1),a=Is(),o=(0,q.useRef)(!1);(0,q.useEffect)(()=>{r.current=!0;let t=o.current?a:Ps(),i=yd(n.rightPanel,t);e.set(to,i),e.set(no,n.rightPanelTab),o.current=!0,r.current=!1},[n.rightPanel,n.rightPanelTab,e,a]),(0,q.useEffect)(()=>{let n=e.sub(to,()=>{if(r.current)return;i.current=!0;let n=e.get(to);t({search:e=>({...e,rightPanel:n}),replace:!0}),queueMicrotask(()=>{i.current=!1})}),a=e.sub(no,()=>{if(r.current)return;i.current=!0;let n=e.get(no);t({search:e=>({...e,rightPanelTab:n}),replace:!0}),queueMicrotask(()=>{i.current=!1})});return()=>{n(),a()}},[e,t])},xd=e=>Cr({queryKey:ne(e).queryKey,queryFn:async({pageParam:t})=>await ne(e,t).queryFn(),initialPageParam:void 0,getNextPageParam:e=>e.nextCursor,refetchOnReconnect:!0});I({model:R().optional(),effort:me([`low`,`medium`,`high`,`max`]).optional(),permissionMode:me([`acceptEdits`,`bypassPermissions`,`default`,`plan`]).optional(),useSystemPromptPreset:Ye().optional()});var Sd=zc(`claude-code-viewer-session-options`,{}),Cd=e=>{let[t,n]=f(Sd);return[(0,q.useMemo)(()=>t[e]??{},[t,e]),(0,q.useCallback)(t=>{n(n=>({...n,[e]:t}))},[n,e])]},wd=(e,t,n)=>[...e.values()].filter(e=>e.projectId===t&&!n.has(e.sessionId)).map(e=>({id:e.sessionId,jsonlFilePath:``,lastModifiedAt:e.sentAt,meta:{messageCount:0,firstUserMessage:{kind:`text`,content:e.userMessage},customTitle:null,cost:{totalUsd:0,breakdown:{inputTokensUsd:0,outputTokensUsd:0,cacheCreationUsd:0,cacheReadUsd:0},tokenUsage:{inputTokens:0,outputTokens:0,cacheCreationTokens:0,cacheReadTokens:0}},modelName:null,prLinks:[]}})),Td=I({mode:ae(`preset`),append:R().optional()}),Ed=I({allowedDomains:R().optional(),allowLocalBinding:Ye().optional()}),Dd=I({enabled:Ye().optional(),autoAllowBashIfSandboxed:Ye().optional(),allowUnsandboxedCommands:Ye().optional(),network:Ed.optional()}),Od=I({model:R().optional(),disallowedTools:ve(R()).optional(),systemPrompt:Td.optional(),env:xe(R(),R().optional()).optional(),sandbox:Dd.optional(),settingSources:ve(me([`user`,`project`,`local`])).optional(),maxTurns:Se().int().positive().optional(),maxThinkingTokens:Se().int().positive().optional(),maxBudgetUsd:Se().nonnegative().optional(),effort:me([`low`,`medium`,`high`,`max`]).optional(),permissionMode:me([`acceptEdits`,`bypassPermissions`,`default`,`plan`]).optional()}),kd=[`user`,`project`,`local`],Ad=()=>({settingSources:[...kd],permissionMode:`default`,systemPrompt:{type:`preset`,preset:`claude_code`}}),jd=e=>{let t=e=>e===void 0?!1:Array.isArray(e)?e.length>0:typeof e==`object`&&e?Object.keys(e).length>0:!0,n=e=>{if(e===void 0||e===``)return;let t=e.split(`,`).map(e=>e.trim()).filter(Boolean);return t.length>0?t:void 0},r=e=>{if(e===void 0)return;let r=n(e.allowedDomains),i=e.allowLocalBinding,a={...r===void 0?{}:{allowedDomains:r},...i===void 0?{}:{allowLocalBinding:i}};return t(a)?a:void 0},i=e=>{if(e===void 0)return;let n=r(e.network),i={...e.enabled===void 0?{}:{enabled:e.enabled},...e.autoAllowBashIfSandboxed===void 0?{}:{autoAllowBashIfSandboxed:e.autoAllowBashIfSandboxed},...e.allowUnsandboxedCommands===void 0?{}:{allowUnsandboxedCommands:e.allowUnsandboxedCommands},...n===void 0?{}:{network:n}};return t(i)?i:void 0},a=e=>{if(!(e?.mode!==`preset`||e.append===void 0||e.append===``))return{type:`preset`,preset:`claude_code`,append:e.append}};if(!Object.values(e).some(e=>t(e)))return;let o=a(e.systemPrompt),s=i(e.sandbox),c=e.env!==void 0&&t(e.env)?e.env:void 0,l={...e.model!==void 0&&e.model!==``?{model:e.model}:{},...e.disallowedTools!==void 0&&e.disallowedTools.length>0?{disallowedTools:e.disallowedTools}:{},...o===void 0?{}:{systemPrompt:o},...c===void 0?{}:{env:c},...s===void 0?{}:{sandbox:s},...e.settingSources===void 0?{}:{settingSources:e.settingSources},...e.maxTurns===void 0?{}:{maxTurns:e.maxTurns},...e.maxThinkingTokens===void 0?{}:{maxThinkingTokens:e.maxThinkingTokens},...e.maxBudgetUsd===void 0?{}:{maxBudgetUsd:e.maxBudgetUsd},...e.effort===void 0?{}:{effort:e.effort},...e.permissionMode===void 0?{}:{permissionMode:e.permissionMode}};return t(l)?l:void 0},Md=e=>{if(!e)return{systemPrompt:{mode:`preset`},settingSources:[...kd]};let t={settingSources:[...kd]};if(e.model!==void 0&&e.model!==``&&(t.model=e.model),e.disallowedTools!==void 0&&(t.disallowedTools=e.disallowedTools),e.systemPrompt===void 0?t.systemPrompt={mode:`preset`}:typeof e.systemPrompt!=`string`&&(t.systemPrompt={mode:`preset`,append:e.systemPrompt.append}),e.env!==void 0&&(t.env=e.env),e.sandbox!==void 0){let n={};if(e.sandbox.enabled!==void 0&&(n.enabled=e.sandbox.enabled),e.sandbox.autoAllowBashIfSandboxed!==void 0&&(n.autoAllowBashIfSandboxed=e.sandbox.autoAllowBashIfSandboxed),e.sandbox.allowUnsandboxedCommands!==void 0&&(n.allowUnsandboxedCommands=e.sandbox.allowUnsandboxedCommands),e.sandbox.network!==void 0){let t={};e.sandbox.network.allowedDomains!==void 0&&e.sandbox.network.allowedDomains.length>0&&(t.allowedDomains=e.sandbox.network.allowedDomains.join(`, `)),e.sandbox.network.allowLocalBinding!==void 0&&(t.allowLocalBinding=e.sandbox.network.allowLocalBinding),n.network=t}t.sandbox=n}return e.settingSources!==void 0&&(t.settingSources=e.settingSources),e.maxTurns!==void 0&&(t.maxTurns=e.maxTurns),e.maxThinkingTokens!==void 0&&(t.maxThinkingTokens=e.maxThinkingTokens),e.maxBudgetUsd!==void 0&&(t.maxBudgetUsd=e.maxBudgetUsd),e.effort!==void 0&&(t.effort=e.effort),e.permissionMode!==void 0&&(t.permissionMode=e.permissionMode),t},Nd=e=>e===null?`null`:e===void 0?`undefined`:typeof e==`boolean`||typeof e==`number`?e.toString():typeof e==`string`?e:JSON.stringify(e,null,2),Pd=({paramKey:e,value:t})=>{let[n,r]=(0,q.useState)(!1),i=Nd(t),a=i.length>100,o=async e=>{try{await navigator.clipboard.writeText(e),r(!0),setTimeout(()=>r(!1),1500)}catch(e){console.error(`Failed to copy to clipboard:`,e)}};return(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsx)(`span`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:e}),(0,J.jsx)(H,{variant:`ghost`,size:`sm`,onClick:()=>void o(i),className:`h-6 w-6 p-0 text-muted-foreground hover:text-foreground`,children:n?(0,J.jsx)(_t,{className:`size-3 text-green-500`}):(0,J.jsx)(Nn,{className:`size-3`})})]}),(0,J.jsx)(`div`,{className:`rounded-md bg-muted/60 border border-border/40 px-3 py-2 ${a?`max-h-32 overflow-y-auto`:``}`,children:(0,J.jsx)(`pre`,{className:`text-xs font-mono whitespace-pre-wrap break-words leading-relaxed text-foreground/80`,children:i})})]})},Fd=({permissionRequest:e,onResponse:t})=>{let[n,r]=(0,q.useState)(!1),[i,a]=(0,q.useState)(!1),{config:o}=ge();if(!e)return null;let s=async n=>{r(!0);let i={permissionRequestId:e.id,decision:n};try{await t(i)}finally{r(!1)}},c=Object.entries(e.toolInput),l=c.length>0;return(0,J.jsx)(`div`,{className:`mx-4 sm:mx-6 md:mx-8 lg:mx-12 xl:mx-16 mb-3 animate-in fade-in slide-in-from-bottom-2 duration-300`,children:(0,J.jsxs)(`div`,{className:`rounded-xl border border-orange-500/25 bg-card shadow-sm overflow-hidden`,children:[(0,J.jsxs)(`div`,{className:`px-4 py-2.5 border-b border-border/60 bg-orange-500/[0.04]`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,J.jsx)(`div`,{className:`flex items-center justify-center size-6 rounded-md bg-orange-500/10 text-orange-600 dark:text-orange-400`,children:(0,J.jsx)(hr,{className:`size-3.5`})}),(0,J.jsx)(`span`,{className:`text-sm font-semibold`,children:`Permission Request`})]}),(0,J.jsx)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:he(e.timestamp,{locale:o.locale,target:`time`})})]}),(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1.5 ml-[2.125rem]`,children:`Claude Code wants to execute a tool and needs your permission.`})]}),(0,J.jsxs)(`div`,{className:`p-4 space-y-3`,children:[(0,J.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,J.jsx)(Y,{variant:`secondary`,className:`font-mono text-xs tracking-tight`,children:e.toolName})}),l&&(0,J.jsx)(`div`,{className:`rounded-lg border border-border/60 overflow-hidden`,children:(0,J.jsxs)(lc,{open:i,onOpenChange:a,children:[(0,J.jsxs)(uc,{className:`flex w-full items-center justify-between px-3.5 py-2.5 hover:bg-muted/40 transition-colors`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`span`,{className:`text-sm font-medium`,children:`Parameters`}),(0,J.jsx)(Y,{variant:`outline`,className:`text-[11px] font-mono`,children:c.length})]}),i?(0,J.jsx)(K,{className:`size-4 text-muted-foreground`}):(0,J.jsx)(et,{className:`size-4 text-muted-foreground`})]}),(0,J.jsx)(dc,{children:(0,J.jsx)(`div`,{className:`px-3.5 pb-3.5 pt-0.5 space-y-3 max-h-48 overflow-y-auto border-t border-border/40`,children:c.map(([e,t])=>(0,J.jsx)(Pd,{paramKey:e,value:t},e))})})]})}),!l&&(0,J.jsx)(`div`,{className:`rounded-lg border border-border/60 px-3.5 py-2.5 text-center text-sm text-muted-foreground`,children:`No parameters`}),(0,J.jsxs)(`div`,{className:`flex gap-2.5 justify-end pt-1`,children:[(0,J.jsxs)(H,{variant:`ghost`,size:`sm`,onClick:()=>void s(`deny`),disabled:n,className:`min-w-[4.5rem] gap-1.5 text-muted-foreground hover:text-destructive hover:bg-destructive/10`,children:[(0,J.jsx)(Ce,{className:`size-3.5`}),`Deny`]}),(0,J.jsxs)(H,{size:`sm`,onClick:()=>void s(`allow`),disabled:n,className:`min-w-[4.5rem] gap-1.5`,children:[(0,J.jsx)(_t,{className:`size-3.5`}),`Allow`]})]})]})]})})},Id=`__other__`,Ld=({current:e,total:t})=>(0,J.jsx)(`div`,{className:`flex items-center gap-1.5`,children:Array.from({length:t},(t,n)=>(0,J.jsx)(`button`,{type:`button`,tabIndex:-1,"aria-label":`Step ${String(n+1)}`,className:U(`size-2 rounded-full transition-all duration-300`,n===e?`bg-primary scale-125`:n<e?`bg-primary/40`:`bg-muted-foreground/25`)},`step-${String(n)}`))}),Rd=({questionRequest:e,onResponse:t})=>{let[n,r]=(0,q.useState)(0),[i,a]=(0,q.useState)({}),[o,s]=(0,q.useState)({}),[c,l]=(0,q.useState)({}),[u,d]=(0,q.useState)({}),[f,p]=(0,q.useState)(!1),m=(0,q.useRef)(null);if(!e)return null;let h=e.questions,g=h.length,_=h[n];if(!_)return null;let v=_.question,y=c[v]??new Set,b=u[v]??``,x=(e,t)=>{let n=e.question,r=new Set;t===Id?(r.add(Id),requestAnimationFrame(()=>m.current?.focus())):r.add(t),l(e=>({...e,[n]:r}));let i=e.options.find(e=>e.label===t);i?.preview!==void 0&&i.preview!==``?s(e=>({...e,[n]:{...e[n],preview:i.preview}})):s(e=>{let t=e[n];if(!t)return e;let{preview:r,...i}=t;return{...e,[n]:i}})},S=(e,t)=>{let n=e.question,r=new Set(c[n]??new Set);t===Id?r.has(Id)?r.delete(Id):(r.add(Id),requestAnimationFrame(()=>m.current?.focus())):r.has(t)?r.delete(t):r.add(t),l(e=>({...e,[n]:r}))},C=(e,t)=>{let n=e.question;d(e=>({...e,[n]:t}))},w=e=>{let t=e.question,n=c[t]??new Set,r=u[t]??``,i=[];for(let e of n)e===Id?r.trim()&&i.push(r.trim()):i.push(e);return i.join(`, `)},T=()=>{let e=c[v]??new Set;return!(e.size===0||e.has(Id)&&!(u[v]??``).trim())},E=()=>{if(n>0){let e=w(_);a(t=>({...t,[v]:e})),r(e=>e-1)}},D=()=>{let e=w(_);a(t=>({...t,[v]:e})),n<g-1&&r(e=>e+1)},O=async()=>{p(!0);let n={...i};n[v]=w(_);let c={questionRequestId:e.id,answers:n,annotations:o};try{await t(c)}finally{p(!1),r(0),a({}),s({}),l({}),d({})}},k=n===g-1,A=T(),j=n===0,M=e=>y.has(e),N=_.options.find(e=>y.has(e.label)&&e.preview!==void 0&&e.preview!==``)?.preview,P=M(Id);return(0,J.jsx)(`div`,{className:`mx-4 sm:mx-6 md:mx-8 lg:mx-12 xl:mx-16 mb-3 animate-in fade-in slide-in-from-bottom-2 duration-300`,children:(0,J.jsxs)(`div`,{className:`rounded-xl border border-border bg-card shadow-sm overflow-hidden`,children:[(0,J.jsx)(`div`,{className:`px-4 py-2.5 border-b border-border/60 bg-muted/30`,children:(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,J.jsx)(`div`,{className:`flex items-center justify-center size-6 rounded-md bg-primary/10 text-primary`,children:(0,J.jsx)($n,{className:`size-3.5`})}),(0,J.jsx)(Y,{variant:`outline`,className:`text-[11px] font-medium tracking-wide uppercase`,children:_.header})]}),g>1&&(0,J.jsx)(Ld,{current:n,total:g})]})}),(0,J.jsxs)(`div`,{className:`p-4 space-y-3.5`,children:[(0,J.jsx)(`p`,{className:`text-sm font-medium leading-relaxed`,children:_.question}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[_.options.map(e=>{let t=M(e.label);return(0,J.jsx)(`button`,{type:`button`,onClick:()=>_.multiSelect?S(_,e.label):x(_,e.label),className:U(`w-full text-left rounded-lg border px-3.5 py-2.5 transition-all duration-200`,`hover:shadow-sm`,t?`border-primary/60 bg-primary/[0.04] shadow-sm ring-1 ring-primary/20`:`border-border/60 hover:border-border hover:bg-muted/40`),children:(0,J.jsxs)(`div`,{className:`flex items-start gap-3`,children:[_.multiSelect?(0,J.jsx)(lt,{checked:t,className:`mt-0.5`,tabIndex:-1}):(0,J.jsx)(`div`,{className:U(`mt-0.5 size-4 shrink-0 rounded-full border-2 transition-all duration-200 flex items-center justify-center`,t?`border-primary bg-primary`:`border-muted-foreground/30`),children:t&&(0,J.jsx)(`div`,{className:`size-1.5 rounded-full bg-primary-foreground`})}),(0,J.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,J.jsx)(W,{className:`text-sm font-medium cursor-pointer leading-tight`,children:e.label}),e.description&&(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5 leading-relaxed`,children:e.description})]})]})},e.label)}),(0,J.jsxs)(`div`,{className:U(`rounded-lg border transition-all duration-200`,P?`border-primary/60 bg-primary/[0.04] shadow-sm ring-1 ring-primary/20`:`border-border/60 hover:border-border hover:bg-muted/40`),children:[(0,J.jsx)(`button`,{type:`button`,onClick:()=>_.multiSelect?S(_,Id):x(_,Id),className:`w-full text-left px-3.5 py-2.5`,children:(0,J.jsxs)(`div`,{className:`flex items-start gap-3`,children:[_.multiSelect?(0,J.jsx)(lt,{checked:P,className:`mt-0.5`,tabIndex:-1}):(0,J.jsx)(`div`,{className:U(`mt-0.5 size-4 shrink-0 rounded-full border-2 transition-all duration-200 flex items-center justify-center`,P?`border-primary bg-primary`:`border-muted-foreground/30`),children:P&&(0,J.jsx)(`div`,{className:`size-1.5 rounded-full bg-primary-foreground`})}),(0,J.jsx)(W,{className:`text-sm font-medium cursor-pointer leading-tight`,children:`Other`})]})}),(0,J.jsx)(`div`,{className:U(`grid transition-all duration-250 ease-out`,P?`grid-rows-[1fr] opacity-100`:`grid-rows-[0fr] opacity-0`),children:(0,J.jsx)(`div`,{className:`overflow-hidden`,children:(0,J.jsx)(`div`,{className:`px-3.5 pb-3 pt-1`,children:(0,J.jsx)(Zc,{ref:m,placeholder:`Type your response here...`,value:b,onChange:e=>C(_,e.target.value),className:`min-h-[68px] text-sm resize-none`,rows:2})})})})]})]}),N!==void 0&&N!==``&&(0,J.jsxs)(`div`,{className:`rounded-lg border border-border/60 bg-muted/30 overflow-hidden animate-in fade-in duration-200`,children:[(0,J.jsx)(`div`,{className:`px-3 py-1.5 border-b border-border/40 bg-muted/40`,children:(0,J.jsx)(`span`,{className:`text-[11px] font-medium text-muted-foreground uppercase tracking-wider`,children:`Preview`})}),(0,J.jsx)(`div`,{className:`p-3`,children:(0,J.jsx)(`pre`,{className:`text-xs font-mono whitespace-pre-wrap break-words max-h-32 overflow-y-auto leading-relaxed text-foreground/80`,children:N})})]}),(0,J.jsxs)(`div`,{className:`flex items-center justify-between pt-1`,children:[(0,J.jsx)(`div`,{children:g>1&&!j&&(0,J.jsxs)(H,{variant:`ghost`,size:`sm`,onClick:E,className:`gap-1 text-muted-foreground hover:text-foreground`,children:[(0,J.jsx)(yn,{className:`size-3.5`}),`Back`]})}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[!A&&P&&!b.trim()&&(0,J.jsxs)(`span`,{className:`text-xs text-muted-foreground flex items-center gap-1`,children:[(0,J.jsx)(Ft,{className:`size-3`}),`Enter a response`]}),k?(0,J.jsxs)(H,{size:`sm`,onClick:()=>void O(),disabled:!A||f,className:`gap-1.5 min-w-[5.5rem]`,children:[(0,J.jsx)(pr,{className:`size-3.5`}),`Submit`]}):(0,J.jsxs)(H,{size:`sm`,onClick:D,disabled:!A,className:`gap-1 min-w-[5rem]`,children:[`Next`,(0,J.jsx)(et,{className:`size-3.5`})]})]})]})]})]})})},zd=({permissionRequest:e,questionRequest:t,onPermissionResponse:n,onQuestionResponse:r})=>t?(0,J.jsx)(Rd,{questionRequest:t,onResponse:r}):e?(0,J.jsx)(Fd,{permissionRequest:e,onResponse:n}):null,Bd=e=>{let t=re(),{data:n}=we({..._,enabled:e!==void 0});return{currentPermissionRequest:(n?.permissionRequests??[]).find(t=>t.sessionId===e)??null,onPermissionResponse:(0,q.useCallback)(async n=>{try{if(!(await o.api[`claude-code`][`permission-response`].$post({json:n})).ok)throw Error(`Failed to send permission response`);e!==void 0&&e!==``&&await o.api.notifications[`:sessionId`].consume.$post({param:{sessionId:e},json:{types:[`permission_requested`]}}),await t.invalidateQueries({queryKey:_.queryKey})}catch(e){console.error(`Error sending permission response:`,e),z.error(`Failed to send permission response`)}},[e,t])}},Vd=e=>{let t=re(),{data:n}=we({...ee,enabled:e!==void 0});return{currentQuestionRequest:(n?.questionRequests??[]).find(t=>t.sessionId===e)??null,onQuestionResponse:(0,q.useCallback)(async n=>{try{if(!(await o.api[`claude-code`][`question-response`].$post({json:n})).ok)throw Error(`Failed to send question response`);e!==void 0&&e!==``&&await o.api.notifications[`:sessionId`].consume.$post({param:{sessionId:e},json:{types:[`question_asked`]}}),await t.invalidateQueries({queryKey:ee.queryKey})}catch(e){console.error(`Error sending question response:`,e),z.error(`Failed to send question response`)}},[e,t])}},Hd={all:[`scheduler`],jobs:()=>[...Hd.all,`jobs`],job:e=>[...Hd.all,`job`,e]},Ud=()=>we({queryKey:Hd.jobs(),queryFn:async()=>{let e=await o.api.scheduler.jobs.$get();if(!e.ok)throw Error(`Failed to fetch scheduler jobs`);return e.json()}}),Wd=()=>{let e=re();return p({mutationFn:async e=>{let t=await o.api.scheduler.jobs.$post({json:e});if(!t.ok)throw Error(`Failed to create scheduler job`);return t.json()},onSuccess:()=>{e.invalidateQueries({queryKey:Hd.jobs()})}})},Gd=()=>{let e=re();return p({mutationFn:async({id:e,updates:t})=>{let n=await o.api.scheduler.jobs[`:id`].$patch({param:{id:e},json:t});if(!n.ok)throw n.status===404?Error(`Job not found`):Error(`Failed to update scheduler job`);return n.json()},onSuccess:t=>{e.invalidateQueries({queryKey:Hd.job(t.id)}),e.invalidateQueries({queryKey:Hd.jobs()})}})},Kd=()=>{let e=re();return p({mutationFn:async e=>{let t=await o.api.scheduler.jobs[`:id`].$delete({param:{id:e}});if(!t.ok)throw t.status===404?Error(`Job not found`):Error(`Failed to delete scheduler job`);return t.json()},onSuccess:(t,n)=>{e.invalidateQueries({queryKey:Hd.job(n)}),e.invalidateQueries({queryKey:Hd.jobs()})}})},qd=zc(`claude-code-viewer-notification-settings`,{soundType:`none`}),Jd=u(e=>e(qd).soundType!==`none`),Yd={beep:{frequency:[800],duration:.15,type:`sine`,volume:.3},chime:{frequency:[523,659,784],duration:.4,type:`sine`,volume:.2},ping:{frequency:[1e3],duration:.1,type:`triangle`,volume:.4},pop:{frequency:[400,600],duration:.08,type:`square`,volume:.2}},Xd=e=>{if(e!==`none`)try{let t=Yd[e],n=window.AudioContext??window.webkitAudioContext;if(n===void 0)return;let r=new n;t.frequency.forEach((e,n)=>{let i=r.createOscillator(),a=r.createGain();i.connect(a),a.connect(r.destination),i.frequency.setValueAtTime(e,r.currentTime),i.type=t.type;let o=r.currentTime+n*.05;a.gain.setValueAtTime(t.volume,o),a.gain.exponentialRampToValueAtTime(.01,o+t.duration),i.start(o),i.stop(o+t.duration)})}catch(e){console.warn(`Failed to play notification sound:`,e)}},Zd=e=>({none:(0,J.jsx)(B,{id:`notification.none`}),beep:(0,J.jsx)(B,{id:`notification.beep`}),chime:(0,J.jsx)(B,{id:`notification.chime`}),ping:(0,J.jsx)(B,{id:`notification.ping`}),pop:(0,J.jsx)(B,{id:`notification.pop`})})[e],Qd=()=>[`none`,`beep`,`chime`,`ping`,`pop`],$d=(e,t)=>{let n=T(qd),r=T(Jd),i=(0,q.useRef)(e),a=(0,q.useRef)(t);a.current!==t&&(a.current=t,i.current=e),(0,q.useEffect)(()=>{let t=i.current;i.current=e,t&&!e&&(z.success(`Task completed`),r&&Xd(n.soundType))},[e,r,n.soundType])},ef=e=>e.replace(/<local-command-caveat>[\s\S]*?<\/local-command-caveat>/g,``).trim(),tf=(e,t,n)=>e??(t?nf(t):n),nf=e=>{switch(e.kind){case`command`:return e.commandArgs===void 0?e.commandName:`${e.commandName} ${e.commandArgs}`;case`local-command`:return ef(e.stdout);case`text`:return ef(e.content);default:throw Error(`Invalid first command`)}},rf=()=>p({mutationFn:async e=>{let t=await o.api.projects[`:projectId`].sessions[`:sessionId`].export.$get({param:{projectId:e.projectId,sessionId:e.sessionId}});if(!t.ok)throw Error(t.statusText);return await t.json()},onSuccess:(e,t)=>{let n=t.sessionId.replace(/[^a-zA-Z0-9._-]/g,`_`)||`unknown`,r=new File([e.html],`ccv-html-export-${n}.html`,{type:`text/html`}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=r.name,a.rel=`noopener`,a.target=`_self`,a.style.display=`none`,document.body.appendChild(a),a.click(),setTimeout(()=>{URL.revokeObjectURL(i),a.remove()},1e3)}}),af=()=>{let e=T(It);return{sessionProcesses:e,getSessionProcess:(0,q.useCallback)(t=>e.find(e=>e.sessionId===t),[e])}},of=()=>{let{data:e}=s({queryKey:E.queryKey,queryFn:E.queryFn}),t=(0,q.useMemo)(()=>new Set(e.flags.filter(e=>e.enabled).map(e=>e.name)),[e.flags]),n=(0,q.useCallback)(e=>t.has(e),[t]);return{flags:e.flags,isFlagEnabled:n}},sf=({projectId:e,isPending:t=!1,onScrollToTop:n,onScrollToBottom:r,sessionProcess:i,abortTask:a,isNewChat:o=!1,enableCCOptions:s=!1,ccOptions:c,onCCOptionsChange:l})=>{let{i18n:u}=Xe(),d=(0,q.useId)(),f=N({from:`/projects/$projectId/session`}),{isFlagEnabled:p}=of(),m=p(`tool-approval`),h=()=>{f({to:`/projects/$projectId/session`,params:{projectId:e},search:{sessionId:void 0}})};return(0,J.jsx)(`div`,{className:`px-4 sm:px-6 md:px-8 lg:px-12 xl:px-16 mb-1`,children:(0,J.jsxs)(`div`,{className:`py-0 flex items-center gap-1.5 flex-wrap`,children:[(0,J.jsxs)(H,{type:`button`,variant:`ghost`,size:`sm`,disabled:t||o,className:`h-7 px-2 gap-1.5 text-xs bg-muted/20 rounded-lg border border-border/40`,"data-testid":`start-new-chat-button`,onClick:h,title:u._({id:`control.new_chat`,message:`New Chat`}),children:[(0,J.jsx)(gt,{className:`w-3.5 h-3.5`}),(0,J.jsx)(`span`,{className:`hidden sm:inline`,children:(0,J.jsx)(B,{id:`control.new`})})]}),n&&(0,J.jsx)(H,{type:`button`,variant:`ghost`,size:`sm`,onClick:n,disabled:t,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:(0,J.jsx)(mn,{className:`w-3.5 h-3.5`})}),r&&(0,J.jsx)(H,{type:`button`,variant:`ghost`,size:`sm`,onClick:r,disabled:t,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:(0,J.jsx)(fn,{className:`w-3.5 h-3.5`})}),i&&a&&(0,J.jsxs)(H,{type:`button`,variant:`destructive`,size:`sm`,onClick:()=>{a.mutate(i.id)},disabled:a.isPending||t,className:`h-7 px-2 gap-1.5 text-xs rounded-lg`,children:[a.isPending?(0,J.jsx)(Yn,{className:`w-3.5 h-3.5 animate-spin`}):(0,J.jsx)(Ce,{className:`w-3.5 h-3.5`}),(0,J.jsx)(`span`,{children:(0,J.jsx)(B,{id:`session.conversation.abort`})})]}),s&&l&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(pt,{children:[(0,J.jsx)(ht,{asChild:!0,children:(0,J.jsx)(`span`,{children:(0,J.jsxs)(gc,{value:c?.permissionMode??`default`,onValueChange:e=>l({...c,permissionMode:e}),disabled:t||!m,children:[(0,J.jsx)(vc,{className:`h-7 w-auto min-w-[80px] text-[11px] font-medium bg-background/50 border-border/30 shadow-none hover:bg-background hover:border-border/50 transition-all duration-200 gap-1 px-2`,children:(0,J.jsx)(_c,{})}),(0,J.jsxs)(xc,{children:[(0,J.jsx)(X,{value:`default`,children:(0,J.jsx)(B,{id:`chat.toolbar.permission_mode.default`,message:`Default`})}),(0,J.jsx)(X,{value:`acceptEdits`,children:(0,J.jsx)(B,{id:`chat.toolbar.permission_mode.accept_edits`,message:`Accept Edits`})}),(0,J.jsx)(X,{value:`bypassPermissions`,children:(0,J.jsx)(B,{id:`chat.toolbar.permission_mode.bypass`,message:`Bypass`})}),(0,J.jsx)(X,{value:`plan`,children:(0,J.jsx)(B,{id:`chat.toolbar.permission_mode.plan`,message:`Plan`})})]})]})})}),(0,J.jsx)(tt,{children:(0,J.jsx)(B,{id:`chat.toolbar.permission_mode.tooltip`,message:`Select permission mode`})})]}),(0,J.jsxs)(pt,{children:[(0,J.jsx)(ht,{asChild:!0,children:(0,J.jsxs)(`label`,{htmlFor:d,className:`flex items-center gap-1.5 cursor-pointer h-7 px-2 rounded-lg text-[11px] font-medium text-muted-foreground hover:bg-background/80 hover:text-foreground transition-all duration-200`,children:[(0,J.jsx)(lt,{id:d,checked:c?.systemPrompt!==void 0,onCheckedChange:e=>{l({...c,systemPrompt:e===!0?{type:`preset`,preset:`claude_code`}:void 0})},disabled:t,className:`h-3.5 w-3.5`}),(0,J.jsx)(`span`,{className:`whitespace-nowrap`,children:`Claude Code`})]})}),(0,J.jsx)(tt,{children:(0,J.jsx)(B,{id:`chat.toolbar.system_prompt.tooltip`,message:`Include default Claude Code prompt`})})]})]})]})})},cf=()=>{if(!(typeof window>`u`))return window.SpeechRecognition??window.webkitSpeechRecognition},lf=4,uf=[0,0,0,0],df=({onTranscript:e,onInterimTranscript:t})=>{let[n,r]=(0,q.useState)(!1),[i,a]=(0,q.useState)(uf),o=(0,q.useRef)(null),s=(0,q.useRef)(null),c=(0,q.useRef)(null),l=(0,q.useRef)(null),u=(0,q.useRef)(null),d=(0,q.useRef)(e);d.current=e;let f=(0,q.useRef)(t);f.current=t;let p=cf()!==void 0,m=(0,q.useCallback)(()=>{if(u.current!==null&&(cancelAnimationFrame(u.current),u.current=null),s.current&&=(s.current.close().catch(()=>{}),null),c.current=null,l.current){for(let e of l.current.getTracks())e.stop();l.current=null}a(uf)},[]),h=(0,q.useCallback)(async()=>{try{let e=await navigator.mediaDevices.getUserMedia({audio:!0});l.current=e;let t=new AudioContext;s.current=t;let n=t.createMediaStreamSource(e),r=t.createAnalyser();r.fftSize=64,n.connect(r),c.current=r;let i=new Uint8Array(r.frequencyBinCount),o=()=>{let e=c.current;if(!e)return;e.getByteFrequencyData(i);let t=i.length,n=Math.floor(t/lf),r=[];for(let e=0;e<lf;e++){let a=e*n,o=Math.min(a+n,t),s=0;for(let e=a;e<o;e++)s+=i[e]??0;let c=o>a?s/(o-a):0;r.push(c/255)}a(r),u.current=requestAnimationFrame(o)};return u.current=requestAnimationFrame(o),!0}catch{return!1}},[]),g=(0,q.useCallback)(()=>{let e=o.current;e&&(o.current=null,e.stop()),m(),r(!1)},[m]),_=(0,q.useCallback)(()=>{let e=cf();if(!e)return;let t=new e;t.continuous=!0,t.interimResults=!0,t.lang=navigator.language,t.onresult=e=>{let t=``,n=``;for(let r=e.resultIndex;r<e.results.length;r++){let i=e.results[r];if(!i)continue;let a=i[0];a&&(i.isFinal?t+=a.transcript:n+=a.transcript)}t&&d.current(t),n&&f.current?.(n)},t.onerror=()=>{g()},t.onend=()=>{o.current===t&&(o.current=null,m(),r(!1))},o.current=t,r(!0);try{t.start()}catch{g();return}h().then(()=>{o.current!==t&&m()})},[h,g,m]),v=(0,q.useCallback)(()=>{n?g():_()},[n,_,g]);return(0,q.useEffect)(()=>()=>{if(o.current&&=(o.current.stop(),null),u.current!==null&&cancelAnimationFrame(u.current),s.current&&s.current.close().catch(()=>{}),l.current)for(let e of l.current.getTracks())e.stop()},[]),{isSupported:p,isListening:n,audioLevels:i,toggle:v}},ff=e=>e.type===`checkbox`,pf=e=>e instanceof Date,mf=e=>e==null,hf=e=>typeof e==`object`,gf=e=>!mf(e)&&!Array.isArray(e)&&hf(e)&&!pf(e),_f=e=>gf(e)&&e.target?ff(e.target)?e.target.checked:e.target.value:e,vf=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,yf=(e,t)=>e.has(vf(t)),bf=e=>{let t=e.constructor&&e.constructor.prototype;return gf(t)&&t.hasOwnProperty(`isPrototypeOf`)},xf=typeof window<`u`&&window.HTMLElement!==void 0&&typeof document<`u`;function Sf(e){if(e instanceof Date)return new Date(e);let t=typeof FileList<`u`&&e instanceof FileList;if(xf&&(e instanceof Blob||t))return e;let n=Array.isArray(e);if(!n&&!(gf(e)&&bf(e)))return e;let r=n?[]:Object.create(Object.getPrototypeOf(e));for(let t in e)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=Sf(e[t]));return r}var Cf=e=>/^\w*$/.test(e),Z=e=>e===void 0,wf=e=>Array.isArray(e)?e.filter(Boolean):[],Tf=e=>wf(e.replace(/["|']|\]/g,``).split(/\.|\[/)),Q=(e,t,n)=>{if(!t||!gf(e))return n;let r=(Cf(t)?[t]:Tf(t)).reduce((e,t)=>mf(e)?e:e[t],e);return Z(r)||r===e?Z(e[t])?n:e[t]:r},Ef=e=>typeof e==`boolean`,Df=e=>typeof e==`function`,$=(e,t,n)=>{let r=-1,i=Cf(t)?[t]:Tf(t),a=i.length,o=a-1;for(;++r<a;){let t=i[r],a=n;if(r!==o){let n=e[t];a=gf(n)||Array.isArray(n)?n:isNaN(+i[r+1])?{}:[]}if(t===`__proto__`||t===`constructor`||t===`prototype`)return;e[t]=a,e=e[t]}},Of={BLUR:`blur`,FOCUS_OUT:`focusout`,CHANGE:`change`,SUBMIT:`submit`,TRIGGER:`trigger`,VALID:`valid`},kf={onBlur:`onBlur`,onChange:`onChange`,onSubmit:`onSubmit`,onTouched:`onTouched`,all:`all`},Af={max:`max`,min:`min`,maxLength:`maxLength`,minLength:`minLength`,pattern:`pattern`,required:`required`,validate:`validate`},jf=`form`,Mf=`root`,Nf=q.createContext(null);Nf.displayName=`HookFormControlContext`;var Pf=(e,t,n,r=!0)=>{let i={defaultValues:t._defaultValues};for(let a in e)Object.defineProperty(i,a,{get:()=>{let i=a;return t._proxyFormState[i]!==kf.all&&(t._proxyFormState[i]=!r||kf.all),n&&(n[i]=!0),e[i]}});return i},Ff=typeof window<`u`?q.useLayoutEffect:q.useEffect,If=e=>typeof e==`string`,Lf=(e,t,n,r,i)=>If(e)?(r&&t.watch.add(e),Q(n,e,i)):Array.isArray(e)?e.map(e=>(r&&t.watch.add(e),Q(n,e))):(r&&(t.watchAll=!0),n),Rf=e=>mf(e)||!hf(e);function zf(e,t,n=new WeakSet){if(Rf(e)||Rf(t))return Object.is(e,t);if(pf(e)&&pf(t))return Object.is(e.getTime(),t.getTime());let r=Object.keys(e),i=Object.keys(t);if(r.length!==i.length)return!1;if(n.has(e)||n.has(t))return!0;n.add(e),n.add(t);for(let a of r){let r=e[a];if(!i.includes(a))return!1;if(a!==`ref`){let e=t[a];if(pf(r)&&pf(e)||gf(r)&&gf(e)||Array.isArray(r)&&Array.isArray(e)?!zf(r,e,n):!Object.is(r,e))return!1}}return!0}var Bf=q.createContext(null);Bf.displayName=`HookFormContext`;var Vf=(e,t,n,r,i)=>t?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[r]:i||!0}}:{},Hf=e=>Array.isArray(e)?e:[e],Uf=()=>{let e=[];return{get observers(){return e},next:t=>{for(let n of e)n.next&&n.next(t)},subscribe:t=>(e.push(t),{unsubscribe:()=>{e=e.filter(e=>e!==t)}}),unsubscribe:()=>{e=[]}}};function Wf(e,t){let n={};for(let r in e)if(e.hasOwnProperty(r)){let i=e[r],a=t[r];if(i&&gf(i)&&a){let e=Wf(i,a);gf(e)&&(n[r]=e)}else e[r]&&(n[r]=a)}return n}var Gf=e=>gf(e)&&!Object.keys(e).length,Kf=e=>e.type===`file`,qf=e=>{if(!xf)return!1;let t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},Jf=e=>e.type===`select-multiple`,Yf=e=>e.type===`radio`,Xf=e=>Yf(e)||ff(e),Zf=e=>qf(e)&&e.isConnected;function Qf(e,t){let n=t.slice(0,-1).length,r=0;for(;r<n;)e=Z(e)?r++:e[t[r++]];return e}function $f(e){for(let t in e)if(e.hasOwnProperty(t)&&!Z(e[t]))return!1;return!0}function ep(e,t){let n=Array.isArray(t)?t:Cf(t)?[t]:Tf(t),r=n.length===1?e:Qf(e,n),i=n.length-1,a=n[i];return r&&delete r[a],i!==0&&(gf(r)&&Gf(r)||Array.isArray(r)&&$f(r))&&ep(e,n.slice(0,-1)),e}var tp=e=>{for(let t in e)if(Df(e[t]))return!0;return!1};function np(e){return Array.isArray(e)||gf(e)&&!tp(e)}function rp(e,t={}){for(let n in e){let r=e[n];np(r)?(t[n]=Array.isArray(r)?[]:{},rp(r,t[n])):Z(r)||(t[n]=!0)}return t}function ip(e,t,n){n||=rp(t);for(let r in e){let i=e[r];if(np(i))Z(t)||Rf(n[r])?n[r]=rp(i,Array.isArray(i)?[]:{}):ip(i,mf(t)?{}:t[r],n[r]);else{let e=t[r];n[r]=!zf(i,e)}}return n}var ap={value:!1,isValid:!1},op={value:!0,isValid:!0},sp=e=>{if(Array.isArray(e)){if(e.length>1){let t=e.filter(e=>e&&e.checked&&!e.disabled).map(e=>e.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!Z(e[0].attributes.value)?Z(e[0].value)||e[0].value===``?op:{value:e[0].value,isValid:!0}:op:ap}return ap},cp=(e,{valueAsNumber:t,valueAsDate:n,setValueAs:r})=>Z(e)?e:t?e===``?NaN:e&&+e:n&&If(e)?new Date(e):r?r(e):e,lp={isValid:!1,value:null},up=e=>Array.isArray(e)?e.reduce((e,t)=>t&&t.checked&&!t.disabled?{isValid:!0,value:t.value}:e,lp):lp;function dp(e){let t=e.ref;return Kf(t)?t.files:Yf(t)?up(e.refs).value:Jf(t)?[...t.selectedOptions].map(({value:e})=>e):ff(t)?sp(e.refs).value:cp(Z(t.value)?e.ref.value:t.value,e)}var fp=(e,t,n,r)=>{let i={};for(let n of e){let e=Q(t,n);e&&$(i,n,e._f)}return{criteriaMode:n,names:[...e],fields:i,shouldUseNativeValidation:r}},pp=e=>e instanceof RegExp,mp=e=>Z(e)?e:pp(e)?e.source:gf(e)?pp(e.value)?e.value.source:e.value:e,hp=e=>({isOnSubmit:!e||e===kf.onSubmit,isOnBlur:e===kf.onBlur,isOnChange:e===kf.onChange,isOnAll:e===kf.all,isOnTouch:e===kf.onTouched}),gp=`AsyncFunction`,_p=e=>!!e&&!!e.validate&&!!(Df(e.validate)&&e.validate.constructor.name===gp||gf(e.validate)&&Object.values(e.validate).find(e=>e.constructor.name===gp)),vp=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate),yp=(e,t,n)=>!n&&(t.watchAll||t.watch.has(e)||[...t.watch].some(t=>e.startsWith(t)&&/^\.\w+/.test(e.slice(t.length)))),bp=(e,t,n,r)=>{for(let i of n||Object.keys(e)){let n=Q(e,i);if(n){let{_f:e,...a}=n;if(e){if(e.refs&&e.refs[0]&&t(e.refs[0],i)&&!r||e.ref&&t(e.ref,e.name)&&!r)return!0;if(bp(a,t))break}else if(gf(a)&&bp(a,t))break}}};function xp(e,t,n){let r=Q(e,n);if(r||Cf(n))return{error:r,name:n};let i=n.split(`.`);for(;i.length;){let r=i.join(`.`),a=Q(t,r),o=Q(e,r);if(a&&!Array.isArray(a)&&n!==r)return{name:n};if(o&&o.type)return{name:r,error:o};if(o&&o.root&&o.root.type)return{name:`${r}.root`,error:o.root};i.pop()}return{name:n}}var Sp=(e,t,n,r)=>{n(e);let{name:i,...a}=e;return Gf(a)||Object.keys(a).length>=Object.keys(t).length||Object.keys(a).find(e=>t[e]===(!r||kf.all))},Cp=(e,t,n)=>!e||!t||e===t||Hf(e).some(e=>e&&(n?e===t:e.startsWith(t)||t.startsWith(e))),wp=(e,t,n,r,i)=>i.isOnAll?!1:!n&&i.isOnTouch?!(t||e):(n?r.isOnBlur:i.isOnBlur)?!e:(n?r.isOnChange:i.isOnChange)?e:!0,Tp=(e,t)=>!wf(Q(e,t)).length&&ep(e,t),Ep=(e,t,n)=>{let r=Hf(Q(e,n));return $(r,Mf,t[n]),$(e,n,r),e};function Dp(e,t,n=`validate`){if(If(e)||Array.isArray(e)&&e.every(If)||Ef(e)&&!e)return{type:n,message:If(e)?e:``,ref:t}}var Op=e=>gf(e)&&!pp(e)?e:{value:e,message:``},kp=async(e,t,n,r,i,a)=>{let{ref:o,refs:s,required:c,maxLength:l,minLength:u,min:d,max:f,pattern:p,validate:m,name:h,valueAsNumber:g,mount:_}=e._f,v=Q(n,h);if(!_||t.has(h))return{};let y=s?s[0]:o,b=e=>{i&&y.reportValidity&&(y.setCustomValidity(Ef(e)?``:e||``),y.reportValidity())},x={},S=Yf(o),C=ff(o),w=S||C,T=(g||Kf(o))&&Z(o.value)&&Z(v)||qf(o)&&o.value===``||v===``||Array.isArray(v)&&!v.length,E=Vf.bind(null,h,r,x),D=(e,t,n,r=Af.maxLength,i=Af.minLength)=>{let a=e?t:n;x[h]={type:e?r:i,message:a,ref:o,...E(e?r:i,a)}};if(a?!Array.isArray(v)||!v.length:c&&(!w&&(T||mf(v))||Ef(v)&&!v||C&&!sp(s).isValid||S&&!up(s).isValid)){let{value:e,message:t}=If(c)?{value:!!c,message:c}:Op(c);if(e&&(x[h]={type:Af.required,message:t,ref:y,...E(Af.required,t)},!r))return b(t),x}if(!T&&(!mf(d)||!mf(f))){let e,t,n=Op(f),i=Op(d);if(!mf(v)&&!isNaN(v)){let r=o.valueAsNumber||v&&+v;mf(n.value)||(e=r>n.value),mf(i.value)||(t=r<i.value)}else{let r=o.valueAsDate||new Date(v),a=e=>new Date(new Date().toDateString()+` `+e),s=o.type==`time`,c=o.type==`week`;If(n.value)&&v&&(e=s?a(v)>a(n.value):c?v>n.value:r>new Date(n.value)),If(i.value)&&v&&(t=s?a(v)<a(i.value):c?v<i.value:r<new Date(i.value))}if((e||t)&&(D(!!e,n.message,i.message,Af.max,Af.min),!r))return b(x[h].message),x}if((l||u)&&!T&&(If(v)||a&&Array.isArray(v))){let e=Op(l),t=Op(u),n=!mf(e.value)&&v.length>+e.value,i=!mf(t.value)&&v.length<+t.value;if((n||i)&&(D(n,e.message,t.message),!r))return b(x[h].message),x}if(p&&!T&&If(v)){let{value:e,message:t}=Op(p);if(pp(e)&&!v.match(e)&&(x[h]={type:Af.pattern,message:t,ref:o,...E(Af.pattern,t)},!r))return b(t),x}if(m){if(Df(m)){let e=Dp(await m(v,n),y);if(e&&(x[h]={...e,...E(Af.validate,e.message)},!r))return b(e.message),x}else if(gf(m)){let e={};for(let t in m){if(!Gf(e)&&!r)break;let i=Dp(await m[t](v,n),y,t);i&&(e={...i,...E(t,i.message)},b(i.message),r&&(x[h]=e))}if(!Gf(e)&&(x[h]={ref:y,...e},!r))return x}}return b(!0),x},Ap={mode:kf.onSubmit,reValidateMode:kf.onChange,shouldFocusError:!0};function jp(e={}){let t={...Ap,...e},n={submitCount:0,isDirty:!1,isReady:!1,isLoading:Df(t.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1},r={},i=(gf(t.defaultValues)||gf(t.values))&&Sf(t.defaultValues||t.values)||{},a=t.shouldUnregister?{}:Sf(i),o={action:!1,mount:!1,watch:!1,keepIsValid:!1},s={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},c,l=0,u={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},d={...u},f={...d},p={array:Uf(),state:Uf()},m=t.criteriaMode===kf.all,h=e=>t=>{clearTimeout(l),l=setTimeout(e,t)},g=async e=>{if(!o.keepIsValid&&!t.disabled&&(d.isValid||f.isValid||e)){let e;t.resolver?(e=Gf((await w()).errors),_()):e=await D({fields:r,onlyCheckValid:!0,eventType:Of.VALID}),e!==n.isValid&&p.state.next({isValid:e})}},_=(e,r)=>{!t.disabled&&(d.isValidating||d.validatingFields||f.isValidating||f.validatingFields)&&((e||Array.from(s.mount)).forEach(e=>{e&&(r?$(n.validatingFields,e,r):ep(n.validatingFields,e))}),p.state.next({validatingFields:n.validatingFields,isValidating:!Gf(n.validatingFields)}))},v=(e,s=[],c,l,u=!0,m=!0)=>{if(l&&c&&!t.disabled){if(o.action=!0,m&&Array.isArray(Q(r,e))){let t=c(Q(r,e),l.argA,l.argB);u&&$(r,e,t)}if(m&&Array.isArray(Q(n.errors,e))){let t=c(Q(n.errors,e),l.argA,l.argB);u&&$(n.errors,e,t),Tp(n.errors,e)}if((d.touchedFields||f.touchedFields)&&m&&Array.isArray(Q(n.touchedFields,e))){let t=c(Q(n.touchedFields,e),l.argA,l.argB);u&&$(n.touchedFields,e,t)}if(d.dirtyFields||f.dirtyFields){let t=ip(i,a),r=vf(e);$(n.dirtyFields,r,Q(t,r))}p.state.next({name:e,isDirty:k(e,s),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else $(a,e,s)},y=(e,t)=>{$(n.errors,e,t),p.state.next({errors:n.errors})},b=e=>{n.errors=e,p.state.next({errors:n.errors,isValid:!1})},x=(e,t,n,s)=>{let c=Q(r,e);if(c){let r=Q(a,e,Z(n)?Q(i,e):n);Z(r)||s&&s.defaultChecked||t?$(a,e,t?r:dp(c._f)):M(e,r),o.mount&&!o.action&&g()}},S=(e,r,a,o,s)=>{let c=!1,l=!1,u={name:e};if(!t.disabled){if(!a||o){(d.isDirty||f.isDirty)&&(l=n.isDirty,n.isDirty=u.isDirty=k(),c=l!==u.isDirty);let t=zf(Q(i,e),r);l=!!Q(n.dirtyFields,e),t?ep(n.dirtyFields,e):$(n.dirtyFields,e,!0),u.dirtyFields=n.dirtyFields,c||=(d.dirtyFields||f.dirtyFields)&&l!==!t}if(a){let t=Q(n.touchedFields,e);t||($(n.touchedFields,e,a),u.touchedFields=n.touchedFields,c||=(d.touchedFields||f.touchedFields)&&t!==a)}c&&s&&p.state.next(u)}return c?u:{}},C=(e,r,i,a)=>{let o=Q(n.errors,e),s=(d.isValid||f.isValid)&&Ef(r)&&n.isValid!==r;if(t.delayError&&i?(c=h(()=>y(e,i)),c(t.delayError)):(clearTimeout(l),c=null,i?$(n.errors,e,i):ep(n.errors,e)),(i?!zf(o,i):o)||!Gf(a)||s){let t={...a,...s&&Ef(r)?{isValid:r}:{},errors:n.errors,name:e};n={...n,...t},p.state.next(t)}},w=async e=>(_(e,!0),await t.resolver(a,t.context,fp(e||s.mount,r,t.criteriaMode,t.shouldUseNativeValidation))),T=async e=>{let{errors:t}=await w(e);if(_(e),e)for(let r of e){let e=Q(t,r);e?$(n.errors,r,e):ep(n.errors,r)}else n.errors=t;return t},E=async({name:t,eventType:r})=>{if(e.validate){let i=await e.validate({formValues:a,formState:n,name:t,eventType:r});if(gf(i))for(let e in i)i[e]&&ae(`${jf}.${e}`,{message:If(i.message)?i.message:``,type:Af.validate});else If(i)||!i?ae(jf,{message:i||``,type:Af.validate}):F(jf);return i}return!0},D=async({fields:r,onlyCheckValid:i,name:o,eventType:c,context:l={valid:!0,runRootValidation:!1}})=>{if(e.validate&&(l.runRootValidation=!0,!await E({name:o,eventType:c})&&(l.valid=!1,i)))return l.valid;for(let o in r){let u=r[o];if(u){let{_f:r,...f}=u;if(r){let o=s.array.has(r.name),c=u._f&&_p(u._f);c&&d.validatingFields&&_([r.name],!0);let f=await kp(u,s.disabled,a,m,t.shouldUseNativeValidation&&!i,o);if(c&&d.validatingFields&&_([r.name]),f[r.name]&&(l.valid=!1,i)||(!i&&(Q(f,r.name)?o?Ep(n.errors,f,r.name):$(n.errors,r.name,f[r.name]):ep(n.errors,r.name)),e.shouldUseNativeValidation&&f[r.name]))break}!Gf(f)&&await D({context:l,onlyCheckValid:i,fields:f,name:o,eventType:c})}}return l.valid},O=()=>{for(let e of s.unMount){let t=Q(r,e);t&&(t._f.refs?t._f.refs.every(e=>!Zf(e)):!Zf(t._f.ref))&&le(e)}s.unMount=new Set},k=(e,n)=>!t.disabled&&(e&&n&&$(a,e,n),!zf(re(),i)),A=(e,t,n)=>Lf(e,s,{...o.mount?a:Z(t)?i:If(e)?{[e]:t}:t},n,t),j=e=>wf(Q(o.mount?a:i,e,t.shouldUnregister?Q(i,e,[]):[])),M=(e,t,n={})=>{let i=Q(r,e),o=t;if(i){let n=i._f;n&&(!n.disabled&&$(a,e,cp(t,n)),o=qf(n.ref)&&mf(t)?``:t,Jf(n.ref)?[...n.ref.options].forEach(e=>e.selected=o.includes(e.value)):n.refs?ff(n.ref)?n.refs.forEach(e=>{(!e.defaultChecked||!e.disabled)&&(Array.isArray(o)?e.checked=!!o.find(t=>t===e.value):e.checked=o===e.value||!!o)}):n.refs.forEach(e=>e.checked=e.value===o):Kf(n.ref)?n.ref.value=``:(n.ref.value=o,n.ref.type||p.state.next({name:e,values:Sf(a)})))}(n.shouldDirty||n.shouldTouch)&&S(e,o,n.shouldTouch,n.shouldDirty,!0),n.shouldValidate&&ne(e)},N=(e,t,n)=>{for(let i in t){if(!t.hasOwnProperty(i))return;let a=t[i],o=e+`.`+i,c=Q(r,o);(s.array.has(e)||gf(a)||c&&!c._f)&&!pf(a)?N(o,a,n):M(o,a,n)}},P=(e,t,c={})=>{let l=Q(r,e),u=s.array.has(e),m=Sf(t);$(a,e,m),u?(p.array.next({name:e,values:Sf(a)}),(d.isDirty||d.dirtyFields||f.isDirty||f.dirtyFields)&&c.shouldDirty&&p.state.next({name:e,dirtyFields:ip(i,a),isDirty:k(e,m)})):l&&!l._f&&!mf(m)?N(e,m,c):M(e,m,c),yp(e,s)?p.state.next({...n,name:e,values:Sf(a)}):p.state.next({name:o.mount?e:void 0,values:Sf(a)})},ee=async i=>{o.mount=!0;let l=i.target,u=l.name,h=!0,v=Q(r,u),y=e=>{h=Number.isNaN(e)||pf(e)&&isNaN(e.getTime())||zf(e,Q(a,u,e))},b=hp(t.mode),x=hp(t.reValidateMode);if(v){let o,T,O=l.type?dp(v._f):_f(i),k=i.type===Of.BLUR||i.type===Of.FOCUS_OUT,A=!vp(v._f)&&!e.validate&&!t.resolver&&!Q(n.errors,u)&&!v._f.deps||wp(k,Q(n.touchedFields,u),n.isSubmitted,x,b),j=yp(u,s,k);$(a,u,O),k?(!l||!l.readOnly)&&(v._f.onBlur&&v._f.onBlur(i),c&&c(0)):v._f.onChange&&v._f.onChange(i);let M=S(u,O,k),N=!Gf(M)||j;if(!k&&p.state.next({name:u,type:i.type,values:Sf(a)}),A)return(d.isValid||f.isValid)&&(t.mode===`onBlur`?k&&g():k||g()),N&&p.state.next({name:u,...j?{}:M});if(!t.resolver&&e.validate&&await E({name:u,eventType:i.type}),!k&&j&&p.state.next({...n}),t.resolver){let{errors:e}=await w([u]);if(_([u]),y(O),h){let t=xp(n.errors,r,u),i=xp(e,r,t.name||u);o=i.error,u=i.name,T=Gf(e)}}else _([u],!0),o=(await kp(v,s.disabled,a,m,t.shouldUseNativeValidation))[u],_([u]),y(O),h&&(o?T=!1:(d.isValid||f.isValid)&&(T=await D({fields:r,onlyCheckValid:!0,name:u,eventType:i.type})));h&&(v._f.deps&&(!Array.isArray(v._f.deps)||v._f.deps.length>0)&&ne(v._f.deps),C(u,T,o,M))}},te=(e,t)=>{if(Q(n.errors,t)&&e.focus)return e.focus(),1},ne=async(e,i={})=>{let a,o,c=Hf(e);if(t.resolver){let t=await T(Z(e)?e:c);a=Gf(t),o=e?!c.some(e=>Q(t,e)):a}else e?(o=(await Promise.all(c.map(async e=>{let t=Q(r,e);return await D({fields:t&&t._f?{[e]:t}:t,eventType:Of.TRIGGER})}))).every(Boolean),!(!o&&!n.isValid)&&g()):o=a=await D({fields:r,name:e,eventType:Of.TRIGGER});return p.state.next({...!If(e)||(d.isValid||f.isValid)&&a!==n.isValid?{}:{name:e},...t.resolver||!e?{isValid:a}:{},errors:n.errors}),i.shouldFocus&&!o&&bp(r,te,e?c:s.mount),o},re=(e,t)=>{let r={...o.mount?a:i};return t&&(r=Wf(t.dirtyFields?n.dirtyFields:n.touchedFields,r)),Z(e)?r:If(e)?Q(r,e):e.map(e=>Q(r,e))},ie=(e,t)=>({invalid:!!Q((t||n).errors,e),isDirty:!!Q((t||n).dirtyFields,e),error:Q((t||n).errors,e),isValidating:!!Q(n.validatingFields,e),isTouched:!!Q((t||n).touchedFields,e)}),F=e=>{let t=e?Hf(e):void 0;t?.forEach(e=>ep(n.errors,e)),t?t.forEach(e=>{p.state.next({name:e,errors:n.errors})}):p.state.next({errors:{}})},ae=(e,t,i)=>{let a=(Q(r,e,{_f:{}})._f||{}).ref,{ref:o,message:s,type:c,...l}=Q(n.errors,e)||{};$(n.errors,e,{...l,...t,ref:a}),p.state.next({name:e,errors:n.errors,isValid:!1}),i&&i.shouldFocus&&a&&a.focus&&a.focus()},oe=(e,t)=>Df(e)?p.state.subscribe({next:n=>`values`in n&&e(A(void 0,t),n)}):A(e,t,!0),se=e=>p.state.subscribe({next:t=>{Cp(e.name,t.name,e.exact)&&Sp(t,e.formState||d,_e,e.reRenderRoot)&&e.callback({values:{...a},...n,...t,defaultValues:i})}}).unsubscribe,ce=e=>(o.mount=!0,f={...f,...e.formState},se({...e,formState:{...u,...e.formState}})),le=(e,o={})=>{for(let c of e?Hf(e):s.mount)s.mount.delete(c),s.array.delete(c),o.keepValue||(ep(r,c),ep(a,c)),!o.keepError&&ep(n.errors,c),!o.keepDirty&&ep(n.dirtyFields,c),!o.keepTouched&&ep(n.touchedFields,c),!o.keepIsValidating&&ep(n.validatingFields,c),!t.shouldUnregister&&!o.keepDefaultValue&&ep(i,c);p.state.next({values:Sf(a)}),p.state.next({...n,...o.keepDirty?{isDirty:k()}:{}}),!o.keepIsValid&&g()},ue=({disabled:e,name:t})=>{if(Ef(e)&&o.mount||e||s.disabled.has(t)){let n=s.disabled.has(t)!==!!e;e?s.disabled.add(t):s.disabled.delete(t),n&&o.mount&&!o.action&&g()}},I=(e,n={})=>{let a=Q(r,e),c=Ef(n.disabled)||Ef(t.disabled);return $(r,e,{...a||{},_f:{...a&&a._f?a._f:{ref:{name:e}},name:e,mount:!0,...n}}),s.mount.add(e),a?ue({disabled:Ef(n.disabled)?n.disabled:t.disabled,name:e}):x(e,!0,n.value),{...c?{disabled:n.disabled||t.disabled}:{},...t.progressive?{required:!!n.required,min:mp(n.min),max:mp(n.max),minLength:mp(n.minLength),maxLength:mp(n.maxLength),pattern:mp(n.pattern)}:{},name:e,onChange:ee,onBlur:ee,ref:c=>{if(c){I(e,n),a=Q(r,e);let t=Z(c.value)&&c.querySelectorAll&&c.querySelectorAll(`input,select,textarea`)[0]||c,o=Xf(t),s=a._f.refs||[];if(o?s.find(e=>e===t):t===a._f.ref)return;$(r,e,{_f:{...a._f,...o?{refs:[...s.filter(Zf),t,...Array.isArray(Q(i,e))?[{}]:[]],ref:{type:t.type,name:e}}:{ref:t}}}),x(e,!1,void 0,t)}else a=Q(r,e,{}),a._f&&(a._f.mount=!1),(t.shouldUnregister||n.shouldUnregister)&&!(yf(s.array,e)&&o.action)&&s.unMount.add(e)}}},de=()=>t.shouldFocusError&&bp(r,te,s.mount),fe=e=>{Ef(e)&&(p.state.next({disabled:e}),bp(r,(t,n)=>{let i=Q(r,n);i&&(t.disabled=i._f.disabled||e,Array.isArray(i._f.refs)&&i._f.refs.forEach(t=>{t.disabled=i._f.disabled||e}))},0,!1))},pe=(e,i)=>async o=>{let c;o&&(o.preventDefault&&o.preventDefault(),o.persist&&o.persist());let l=Sf(a);if(p.state.next({isSubmitting:!0}),t.resolver){let{errors:e,values:t}=await w();_(),n.errors=e,l=Sf(t)}else await D({fields:r,eventType:Of.SUBMIT});if(s.disabled.size)for(let e of s.disabled)ep(l,e);if(ep(n.errors,Mf),Gf(n.errors)){p.state.next({errors:{}});try{await e(l,o)}catch(e){c=e}}else i&&await i({...n.errors},o),de(),setTimeout(de);if(p.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:Gf(n.errors)&&!c,submitCount:n.submitCount+1,errors:n.errors}),c)throw c},me=(e,t={})=>{Q(r,e)&&(Z(t.defaultValue)?P(e,Sf(Q(i,e))):(P(e,t.defaultValue),$(i,e,Sf(t.defaultValue))),t.keepTouched||ep(n.touchedFields,e),t.keepDirty||(ep(n.dirtyFields,e),n.isDirty=t.defaultValue?k(e,Sf(Q(i,e))):k()),t.keepError||(ep(n.errors,e),d.isValid&&g()),p.state.next({...n}))},he=(e,c={})=>{let l=e?Sf(e):i,u=Sf(l),f=Gf(e),m=f?i:u;if(c.keepDefaultValues||(i=l),!c.keepValues){if(c.keepDirtyValues){let e=new Set([...s.mount,...Object.keys(ip(i,a))]);for(let t of Array.from(e)){let e=Q(n.dirtyFields,t),r=Q(a,t),i=Q(m,t);e&&!Z(r)?$(m,t,r):!e&&!Z(i)&&P(t,i)}}else{if(xf&&Z(e))for(let e of s.mount){let t=Q(r,e);if(t&&t._f){let e=Array.isArray(t._f.refs)?t._f.refs[0]:t._f.ref;if(qf(e)){let t=e.closest(`form`);if(t){t.reset();break}}}}if(c.keepFieldsRef)for(let e of s.mount)P(e,Q(m,e));else r={}}a=t.shouldUnregister?c.keepDefaultValues?Sf(i):{}:Sf(m),p.array.next({values:{...m}}),p.state.next({values:{...m}})}s={mount:c.keepDirtyValues?s.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:``},o.mount=!d.isValid||!!c.keepIsValid||!!c.keepDirtyValues||!t.shouldUnregister&&!Gf(m),o.watch=!!t.shouldUnregister,o.keepIsValid=!!c.keepIsValid,o.action=!1,c.keepErrors||(n.errors={}),p.state.next({submitCount:c.keepSubmitCount?n.submitCount:0,isDirty:f?!1:c.keepDirty?n.isDirty:!!(c.keepDefaultValues&&!zf(e,i)),isSubmitted:c.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:f?{}:c.keepDirtyValues?c.keepDefaultValues&&a?ip(i,a):n.dirtyFields:c.keepDefaultValues&&e?ip(i,e):c.keepDirty?n.dirtyFields:{},touchedFields:c.keepTouched?n.touchedFields:{},errors:c.keepErrors?n.errors:{},isSubmitSuccessful:c.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:i})},L=(e,n)=>he(Df(e)?e(a):e,{...t.resetOptions,...n}),ge=(e,t={})=>{let n=Q(r,e),i=n&&n._f;if(i){let e=i.refs?i.refs[0]:i.ref;e.focus&&setTimeout(()=>{e.focus(),t.shouldSelect&&Df(e.select)&&e.select()})}},_e=e=>{n={...n,...e}},ve={control:{register:I,unregister:le,getFieldState:ie,handleSubmit:pe,setError:ae,_subscribe:se,_runSchema:w,_updateIsValidating:_,_focusError:de,_getWatch:A,_getDirty:k,_setValid:g,_setFieldArray:v,_setDisabledField:ue,_setErrors:b,_getFieldArray:j,_reset:he,_resetDefaultValues:()=>Df(t.defaultValues)&&t.defaultValues().then(e=>{L(e,t.resetOptions),p.state.next({isLoading:!1})}),_removeUnmounted:O,_disableForm:fe,_subjects:p,_proxyFormState:d,get _fields(){return r},get _formValues(){return a},get _state(){return o},set _state(e){o=e},get _defaultValues(){return i},get _names(){return s},set _names(e){s=e},get _formState(){return n},get _options(){return t},set _options(e){t={...t,...e}}},subscribe:ce,trigger:ne,register:I,handleSubmit:pe,watch:oe,setValue:P,getValues:re,reset:L,resetField:me,clearErrors:F,unregister:le,setError:ae,setFocus:ge,getFieldState:ie};return{...ve,formControl:ve}}function Mp(e={}){let t=q.useRef(void 0),n=q.useRef(void 0),[r,i]=q.useState({isDirty:!1,isValidating:!1,isLoading:Df(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1,isReady:!1,defaultValues:Df(e.defaultValues)?void 0:e.defaultValues});if(!t.current)if(e.formControl)t.current={...e.formControl,formState:r},e.defaultValues&&!Df(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{let{formControl:n,...i}=jp(e);t.current={...i,formState:r}}let a=t.current.control;return a._options=e,Ff(()=>{let e=a._subscribe({formState:a._proxyFormState,callback:()=>i({...a._formState}),reRenderRoot:!0});return i(e=>({...e,isReady:!0})),a._formState.isReady=!0,e},[a]),q.useEffect(()=>a._disableForm(e.disabled),[a,e.disabled]),q.useEffect(()=>{e.mode&&(a._options.mode=e.mode),e.reValidateMode&&(a._options.reValidateMode=e.reValidateMode)},[a,e.mode,e.reValidateMode]),q.useEffect(()=>{e.errors&&(a._setErrors(e.errors),a._focusError())},[a,e.errors]),q.useEffect(()=>{e.shouldUnregister&&a._subjects.state.next({values:a._getWatch()})},[a,e.shouldUnregister]),q.useEffect(()=>{if(a._proxyFormState.isDirty){let e=a._getDirty();e!==r.isDirty&&a._subjects.state.next({isDirty:e})}},[a,r.isDirty]),q.useEffect(()=>{e.values&&!zf(e.values,n.current)?(a._reset(e.values,{keepFieldsRef:!0,...a._options.resetOptions}),a._options.resetOptions?.keepIsValid||a._setValid(),n.current=e.values,i(e=>({...e}))):a._resetDefaultValues()},[a,e.values]),q.useEffect(()=>{a._state.mount||(a._setValid(),a._state.mount=!0),a._state.watch&&(a._state.watch=!1,a._subjects.state.next({...a._formState})),a._removeUnmounted()}),t.current.formState=q.useMemo(()=>Pf(r,a),[a,r]),t.current}var Np=(e,t,n)=>{if(e&&`reportValidity`in e){let r=Q(n,t);e.setCustomValidity(r&&r.message||``),e.reportValidity()}},Pp=(e,t)=>{for(let n in t.fields){let r=t.fields[n];r&&r.ref&&`reportValidity`in r.ref?Np(r.ref,n,e):r&&r.refs&&r.refs.forEach(t=>Np(t,n,e))}},Fp=(e,t)=>{t.shouldUseNativeValidation&&Pp(e,t);let n={};for(let r in e){let i=Q(t.fields,r),a=Object.assign(e[r]||{},{ref:i&&i.ref});if(Ip(t.names||Object.keys(e),r)){let e=Object.assign({},Q(n,r));$(e,`root`,a),$(n,r,e)}else $(n,r,a)}return n},Ip=(e,t)=>{let n=Lp(t);return e.some(e=>Lp(e).match(`^${n}\\.\\d+`))};function Lp(e){return e.replace(/\]|\[/g,``)}function Rp(e,t){try{var n=e()}catch(e){return t(e)}return n&&n.then?n.then(void 0,t):n}function zp(e,t){for(var n={};e.length;){var r=e[0],i=r.code,a=r.message,o=r.path.join(`.`);if(!n[o])if(`unionErrors`in r){var s=r.unionErrors[0].errors[0];n[o]={message:s.message,type:s.code}}else n[o]={message:a,type:i};if(`unionErrors`in r&&r.unionErrors.forEach(function(t){return t.errors.forEach(function(t){return e.push(t)})}),t){var c=n[o].types,l=c&&c[r.code];n[o]=Vf(o,t,n,i,l?[].concat(l,r.message):r.message)}e.shift()}return n}function Bp(e,t){for(var n={};e.length;){var r=e[0],i=r.code,a=r.message,o=r.path.join(`.`);if(!n[o])if(r.code===`invalid_union`&&r.errors.length>0){var s=r.errors[0][0];n[o]={message:s.message,type:s.code}}else n[o]={message:a,type:i};if(r.code===`invalid_union`&&r.errors.forEach(function(t){return t.forEach(function(t){return e.push(t)})}),t){var c=n[o].types,l=c&&c[r.code];n[o]=Vf(o,t,n,i,l?[].concat(l,r.message):r.message)}e.shift()}return n}function Vp(e,t,n){if(n===void 0&&(n={}),function(e){return`_def`in e&&typeof e._def==`object`&&`typeName`in e._def}(e))return function(r,i,a){try{return Promise.resolve(Rp(function(){return Promise.resolve(e[n.mode===`sync`?`parse`:`parseAsync`](r,t)).then(function(e){return a.shouldUseNativeValidation&&Pp({},a),{errors:{},values:n.raw?Object.assign({},r):e}})},function(e){if(function(e){return Array.isArray(e?.issues)}(e))return{values:{},errors:Fp(zp(e.errors,!a.shouldUseNativeValidation&&a.criteriaMode===`all`),a)};throw e}))}catch(e){return Promise.reject(e)}};if(function(e){return`_zod`in e&&typeof e._zod==`object`}(e))return function(r,i,a){try{return Promise.resolve(Rp(function(){return Promise.resolve((n.mode===`sync`?pe:He)(e,r,t)).then(function(e){return a.shouldUseNativeValidation&&Pp({},a),{errors:{},values:n.raw?Object.assign({},r):e}})},function(e){if(function(e){return e instanceof fe}(e))return{values:{},errors:Fp(Bp(e.issues,!a.shouldUseNativeValidation&&a.criteriaMode===`all`),a)};throw e}))}catch(e){return Promise.reject(e)}};throw Error(`Invalid input: not a Zod schema`)}var Hp=q.forwardRef(({className:e,checked:t,onCheckedChange:n,disabled:r,...i},a)=>(0,J.jsxs)(`label`,{className:U(`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`,r===!0&&`cursor-not-allowed opacity-50`,t===!0?`bg-primary`:`bg-input`,e),children:[(0,J.jsx)(`input`,{type:`checkbox`,className:`sr-only`,ref:a,checked:t,onChange:e=>{n?.(e.target.checked),i.onChange?.(e)},disabled:r,...i}),(0,J.jsx)(`span`,{className:U(`pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform`,t===!0?`translate-x-4`:`translate-x-0`)})]}));Hp.displayName=`Switch`;var Up=[`Bash`,`Read`,`Write`,`Edit`,`Glob`,`Grep`,`WebFetch`,`WebSearch`,`Task`,`TodoRead`,`TodoWrite`,`NotebookEdit`,`AskUserQuestion`],Wp=e=>e===void 0?`undefined`:e===null?`null`:typeof e==`object`?Array.isArray(e)?`[${e.map(Wp).join(`,`)}]`:`{${Object.entries(e).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>`${JSON.stringify(e)}:${Wp(t)}`).join(`,`)}}`:JSON.stringify(e),Gp=({value:e,onChange:t,disabled:n})=>{let{i18n:r}=Xe(),i=Object.entries(e),a=()=>{t({...e,"":``})},o=n=>{let r={...e};delete r[n],t(r)},s=(n,r)=>{let i={};for(let[t,a]of Object.entries(e))t===n?i[r]=a:i[t]=a;t(i)},c=(n,r)=>{t({...e,[n]:r})};return(0,J.jsxs)(`div`,{className:`space-y-2`,children:[i.map(([e,t])=>(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(At,{value:e,onChange:t=>s(e,t.target.value),placeholder:r._(`Key`),disabled:n,className:`h-8 text-xs flex-1`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`=`}),(0,J.jsx)(At,{value:t??``,onChange:t=>c(e,t.target.value),placeholder:r._(`Value`),disabled:n,className:`h-8 text-xs flex-1`}),(0,J.jsx)(H,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>o(e),disabled:n,className:`h-8 w-8 p-0`,children:(0,J.jsx)(yr,{className:`w-3 h-3`})})]},`env-${e}`)),(0,J.jsxs)(H,{type:`button`,variant:`outline`,size:`sm`,onClick:a,disabled:n,className:`h-7 text-xs`,children:[(0,J.jsx)(gt,{className:`w-3 h-3 mr-1`}),(0,J.jsx)(B,{id:`settings.env.add`})]})]})},Kp=({value:e,onChange:t,disabled:n})=>{let{i18n:r}=Xe(),[i,a]=(0,q.useState)(``),o=n=>{e.includes(n)?t(e.filter(e=>e!==n)):t([...e,n])},s=()=>{let n=i.trim();n&&!e.includes(n)&&(t([...e,n]),a(``))};return(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.map(e=>(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-2 py-0.5 bg-primary/10 text-primary rounded text-xs`,children:[e,(0,J.jsx)(`button`,{type:`button`,onClick:()=>o(e),disabled:n,className:`hover:bg-primary/20 rounded-full p-0.5`,children:(0,J.jsx)(Ce,{className:`w-3 h-3`})})]},e))}),(0,J.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:Up.filter(t=>!e.includes(t)).map(e=>(0,J.jsx)(`button`,{type:`button`,onClick:()=>o(e),disabled:n,className:`px-2 py-0.5 text-xs rounded border border-border hover:bg-muted transition-colors`,children:e},e))}),(0,J.jsxs)(`div`,{className:`flex gap-2`,children:[(0,J.jsx)(At,{value:i,onChange:e=>a(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),s())},placeholder:r._(`Custom tool name...`),disabled:n,className:`h-8 text-xs flex-1`}),(0,J.jsx)(H,{type:`button`,variant:`outline`,size:`sm`,onClick:s,disabled:n??!i.trim(),className:`h-8 text-xs`,children:(0,J.jsx)(gt,{className:`w-3 h-3`})})]})]})},qp=({value:e,onChange:t,disabled:n=!1})=>{let{i18n:r}=Xe(),i=(0,q.useId)(),a=(0,q.useId)(),o=(0,q.useId)(),{register:s,watch:c,setValue:l,formState:{errors:u}}=Mp({resolver:Vp(Od),defaultValues:Md(e)}),d=c(),f=(0,q.useMemo)(()=>jd(d),[d]),p=(0,q.useRef)(null);return(0,q.useEffect)(()=>{let e=Wp(f);e!==p.current&&(p.current=e,t(f))},[f,t]),(0,J.jsxs)(`div`,{className:`space-y-4 text-sm`,children:[(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(W,{className:`text-xs font-medium`,children:(0,J.jsx)(B,{id:`settings.disallowedTools.label`})}),(0,J.jsx)(Kp,{value:d.disallowedTools??[],onChange:e=>l(`disallowedTools`,e),disabled:n}),u.disallowedTools?.message!==void 0&&u.disallowedTools.message!==``&&(0,J.jsx)(`p`,{className:`text-xs text-red-500`,children:u.disallowedTools.message})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(W,{className:`text-xs font-medium`,children:(0,J.jsx)(B,{id:`settings.env.label`,message:`Environment Variables`})}),(0,J.jsx)(Gp,{value:d.env??{},onChange:e=>l(`env`,e),disabled:n}),u.env?.root?.message!==void 0&&u.env.root.message!==``&&(0,J.jsx)(`p`,{className:`text-xs text-red-500`,children:u.env.root.message})]}),(0,J.jsxs)(`div`,{className:`space-y-2 p-3 bg-muted/30 rounded-md`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsx)(W,{className:`text-xs font-medium`,children:(0,J.jsx)(B,{id:`settings.sandbox.label`,message:`Sandbox`})}),(0,J.jsx)(Hp,{checked:d.sandbox?.enabled??!1,onCheckedChange:e=>l(`sandbox`,{...d.sandbox,enabled:e}),disabled:n})]}),d.sandbox?.enabled===!0&&(0,J.jsxs)(`div`,{className:`space-y-3 pt-2 border-t border-border/50`,children:[(0,J.jsxs)(`label`,{htmlFor:i,className:`flex items-center gap-2 cursor-pointer`,children:[(0,J.jsx)(lt,{id:i,checked:d.sandbox?.autoAllowBashIfSandboxed??!1,onCheckedChange:e=>l(`sandbox`,{...d.sandbox,autoAllowBashIfSandboxed:e===!0}),disabled:n}),(0,J.jsx)(`span`,{className:`text-xs`,children:(0,J.jsx)(B,{id:`settings.sandbox.autoAllowBash`,message:`Auto-allow Bash if sandboxed`})})]}),(0,J.jsxs)(`label`,{htmlFor:a,className:`flex items-center gap-2 cursor-pointer`,children:[(0,J.jsx)(lt,{id:a,checked:d.sandbox?.allowUnsandboxedCommands??!1,onCheckedChange:e=>l(`sandbox`,{...d.sandbox,allowUnsandboxedCommands:e===!0}),disabled:n}),(0,J.jsx)(`span`,{className:`text-xs`,children:(0,J.jsx)(B,{id:`settings.sandbox.allowUnsandboxedCommands`,message:`Allow unsandboxed commands`})})]}),(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(W,{className:`text-xs font-medium`,children:(0,J.jsx)(B,{id:`settings.sandbox.network.label`,message:`Network Settings`})}),(0,J.jsxs)(`label`,{htmlFor:o,className:`flex items-center gap-2 cursor-pointer`,children:[(0,J.jsx)(lt,{id:o,checked:d.sandbox?.network?.allowLocalBinding??!1,onCheckedChange:e=>l(`sandbox`,{...d.sandbox,network:{...d.sandbox?.network,allowLocalBinding:e===!0}}),disabled:n}),(0,J.jsx)(`span`,{className:`text-xs`,children:(0,J.jsx)(B,{id:`settings.sandbox.network.allowLocalBinding`,message:`Allow local binding`})})]}),(0,J.jsxs)(`div`,{className:`space-y-1`,children:[(0,J.jsx)(W,{className:`text-xs text-muted-foreground`,children:(0,J.jsx)(B,{id:`settings.sandbox.network.allowedDomains`,message:`Allowed Domains (comma-separated)`})}),(0,J.jsx)(At,{value:d.sandbox?.network?.allowedDomains??``,onChange:e=>{l(`sandbox`,{...d.sandbox,network:{...d.sandbox?.network,allowedDomains:e.target.value||void 0}})},placeholder:r._(`e.g., api.example.com, cdn.example.com`),disabled:n,className:`h-8 text-xs`})]})]})]}),u.sandbox?.message!==void 0&&u.sandbox.message!==``&&(0,J.jsx)(`p`,{className:`text-xs text-red-500`,children:u.sandbox.message})]}),(0,J.jsxs)(`details`,{className:`group`,children:[(0,J.jsx)(`summary`,{className:`text-xs font-medium text-muted-foreground cursor-pointer hover:text-foreground transition-colors`,children:(0,J.jsx)(B,{id:`settings.advanced`,message:`Advanced Settings`})}),(0,J.jsxs)(`div`,{className:`mt-3 space-y-4 pl-2 border-l-2 border-border/50`,children:[(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(W,{className:`text-xs font-medium`,children:(0,J.jsx)(B,{id:`settings.settingSources.label`,message:`Setting Sources`})}),(0,J.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:[`user`,`project`,`local`].map(e=>{let t=d.settingSources??[`user`,`project`,`local`];return(0,J.jsxs)(`label`,{className:`inline-flex items-center gap-1.5 cursor-pointer`,children:[(0,J.jsx)(lt,{checked:t.includes(e),onCheckedChange:n=>{n===!0?l(`settingSources`,[...t,e]):l(`settingSources`,t.filter(t=>t!==e))},disabled:n}),(0,J.jsx)(`span`,{className:`text-xs`,children:e})]},e)})}),u.settingSources?.message!==void 0&&u.settingSources.message!==``&&(0,J.jsx)(`p`,{className:`text-xs text-red-500`,children:u.settingSources.message})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(W,{htmlFor:`maxTurns`,className:`text-xs font-medium`,children:(0,J.jsx)(B,{id:`settings.maxTurns.label`,message:`Max Turns`})}),(0,J.jsx)(At,{id:`maxTurns`,type:`number`,min:1,...s(`maxTurns`,{setValueAs:e=>e===``?void 0:Number(e)}),placeholder:r._(`e.g., 10`),disabled:n,className:`h-8 text-xs`}),u.maxTurns?.message!==void 0&&u.maxTurns.message!==``&&(0,J.jsx)(`p`,{className:`text-xs text-red-500`,children:u.maxTurns.message})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(W,{htmlFor:`maxThinkingTokens`,className:`text-xs font-medium`,children:(0,J.jsx)(B,{id:`settings.maxThinkingTokens.label`,message:`Max Thinking Tokens`})}),(0,J.jsx)(At,{id:`maxThinkingTokens`,type:`number`,min:1,...s(`maxThinkingTokens`,{setValueAs:e=>e===``?void 0:Number(e)}),placeholder:r._(`e.g., 10000`),disabled:n,className:`h-8 text-xs`}),u.maxThinkingTokens?.message!==void 0&&u.maxThinkingTokens.message!==``?(0,J.jsx)(`p`,{className:`text-xs text-red-500`,children:u.maxThinkingTokens.message}):null]}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(W,{htmlFor:`maxBudgetUsd`,className:`text-xs font-medium`,children:(0,J.jsx)(B,{id:`settings.maxBudgetUsd.label`,message:`Max Budget (USD)`})}),(0,J.jsx)(At,{id:`maxBudgetUsd`,type:`number`,min:0,step:.01,...s(`maxBudgetUsd`,{setValueAs:e=>e===``?void 0:Number(e)}),placeholder:r._(`e.g., 1.00`),disabled:n,className:`h-8 text-xs`}),u.maxBudgetUsd?.message!==void 0&&u.maxBudgetUsd.message!==``&&(0,J.jsx)(`p`,{className:`text-xs text-red-500`,children:u.maxBudgetUsd.message})]})]})]})]})},Jp=({value:e,onChange:t,disabled:n})=>{let[r,i]=(0,q.useState)(!1);return(0,J.jsxs)(ot,{open:r,onOpenChange:i,children:[(0,J.jsx)(ut,{asChild:!0,children:(0,J.jsx)(H,{type:`button`,variant:`ghost`,size:`sm`,disabled:n,className:`px-2 hover:bg-background/80 hover:text-foreground text-muted-foreground transition-all duration-200 h-8 rounded-lg`,children:(0,J.jsx)(mr,{className:`w-4 h-4`})})}),(0,J.jsx)($e,{className:`w-[calc(100vw-2rem)] sm:w-80 max-h-[70vh] overflow-y-auto z-[60]`,align:`end`,side:`top`,collisionPadding:16,children:(0,J.jsxs)(`div`,{className:`space-y-3`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsx)(`h4`,{className:`font-medium text-sm`,children:(0,J.jsx)(B,{id:`settings.title`,message:`Claude Code Settings`})}),(0,J.jsx)(H,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>i(!1),className:`h-6 w-6 p-0`,children:(0,J.jsx)(Ce,{className:`w-4 h-4`})})]}),(0,J.jsx)(qp,{value:e,onChange:t,disabled:n})]})})]})},Yp=e=>{if(e.startsWith(`/`)&&!e.includes(` `))return!0;let t=e.lastIndexOf(`@`);return t===-1?!1:!e.slice(t+1).includes(` `)},Xp=me([`image/png`,`image/jpeg`,`image/gif`,`image/webp`]),Zp=e=>e.startsWith(`image/`)?`image`:e===`application/pdf`?`pdf`:`text`,Qp=e=>{if(e===null)return[];let t=Array.from(e.items).flatMap(e=>{if(e.kind!==`file`||!e.type.startsWith(`image/`))return[];let t=e.getAsFile();return t===null?[]:[t]});return t.length>0?t:Array.from(e.files).filter(e=>e.type.startsWith(`image/`))},$p=e=>new Promise((t,n)=>{let r=new FileReader;r.onload=()=>{let e=r.result;if(typeof e==`string`){let n=e.split(`,`)[1];t(n??``)}else n(Error(`Failed to read file as base64`))},r.onerror=()=>{n(Error(`Failed to read file`))},r.readAsDataURL(e)}),em=e=>new Promise((t,n)=>{let r=new FileReader;r.onload=()=>{let e=r.result;typeof e==`string`?t(e):n(Error(`Failed to read file as text`))},r.onerror=()=>{n(Error(`Failed to read file`))},r.readAsText(e)}),tm=async e=>{let t=Zp(e.type);if(t===`text`)return{type:`text`,content:await em(e)};let n=await $p(e);if(t===`image`){let t=Xp.safeParse(e.type);return t.success?{type:`image`,block:{type:`image`,source:{type:`base64`,media_type:t.data,data:n}}}:null}return{type:`document`,block:{type:`document`,source:{type:`base64`,media_type:`application/pdf`,data:n}}}},nm=(0,q.forwardRef)(({projectId:e,inputValue:t,onCommandSelect:n,className:r},i)=>{let{i18n:a}=Xe(),[o,s]=(0,q.useState)(!1),[c,l]=(0,q.useState)(-1),u=(0,q.useRef)(null),d=(0,q.useRef)(null),{data:f}=we({queryKey:k(e).queryKey,queryFn:k(e).queryFn,staleTime:1e3*60*5}),{shouldShowCompletion:p,filteredCommands:m}=(0,q.useMemo)(()=>{let e=[...f?.defaultCommands??[],...f?.globalCommands??[],...f?.projectCommands??[],...f?.globalSkills??[],...f?.projectSkills??[]],n=t.startsWith(`/`),r=n?t.slice(1).toLowerCase():``;return{shouldShowCompletion:n,filteredCommands:n?e.filter(e=>e.name.toLowerCase().includes(r)||(e.description!==null&&e.description!==``?e.description.toLowerCase():``).includes(r)):[]}},[f,t]),h=p&&m.length>0;o!==h&&(s(h),l(-1));let g=(0,q.useCallback)(e=>{let t=e.argumentHint!==null&&e.argumentHint!==``?` ${e.argumentHint}`:``;n(`/${e.name}${t} `),s(!1),l(-1)},[n]),_=(0,q.useCallback)(e=>{if(e>=0&&d.current){let t=d.current.querySelectorAll(`button[role="option"]`)[e];t instanceof HTMLElement&&t.scrollIntoView({block:`nearest`,behavior:`smooth`})}},[]),v=(0,q.useCallback)(e=>{if(!o||m.length===0)return!1;switch(e.key){case`ArrowDown`:return e.preventDefault(),l(e=>{let t=e<m.length-1?e+1:0;return requestAnimationFrame(()=>_(t)),t}),!0;case`ArrowUp`:return e.preventDefault(),l(e=>{let t=e>0?e-1:m.length-1;return requestAnimationFrame(()=>_(t)),t}),!0;case`Enter`:case`Tab`:if(c>=0&&c<m.length){e.preventDefault();let t=m[c];return t&&g(t),!0}return!1;case`Escape`:return e.preventDefault(),s(!1),l(-1),!0;default:return!1}},[o,c,g,_,m]);return(0,q.useEffect)(()=>{let e=e=>{u.current&&e.target instanceof Node&&!u.current.contains(e.target)&&(s(!1),l(-1))};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]),(0,q.useImperativeHandle)(i,()=>({handleKeyDown:v}),[v]),!p||m.length===0?null:(0,J.jsx)(`div`,{ref:u,className:U(`relative`,r),children:(0,J.jsx)(lc,{open:o,onOpenChange:s,children:(0,J.jsx)(dc,{children:(0,J.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":a._(`Available commands`),children:(0,J.jsx)(`div`,{className:`h-full overflow-y-auto`,children:m.length>0&&(0,J.jsxs)(`div`,{className:`p-1.5`,children:[(0,J.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:[(0,J.jsx)(_r,{className:`w-3.5 h-3.5`}),`Available Commands / Skills (`,m.length,`)`]}),m.map((e,t)=>(0,J.jsxs)(H,{variant:`ghost`,size:`sm`,className:U(`w-full justify-start text-left font-mono text-sm h-auto min-h-9 px-3 py-2 min-w-0 transition-colors duration-150`,t===c?`bg-gradient-to-r from-blue-500/10 to-purple-500/10 text-foreground border border-blue-500/20`:`hover:bg-accent/50`),onClick:()=>g(e),onMouseEnter:()=>l(t),role:`option`,"aria-selected":t===c,"aria-label":`Command: /${e.name}`,title:e.description??`/${e.name}`,children:[(0,J.jsxs)(`div`,{className:`flex flex-col items-start gap-0.5 min-w-0 flex-1`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5 w-full`,children:[(0,J.jsx)(`span`,{className:`text-muted-foreground flex-shrink-0`,children:`/`}),(0,J.jsx)(`span`,{className:`font-medium truncate`,children:e.name}),e.argumentHint!==null&&e.argumentHint!==``?(0,J.jsx)(`span`,{className:`text-muted-foreground/60 text-xs truncate`,children:e.argumentHint}):null]}),e.description!==null&&e.description!==``?(0,J.jsx)(`span`,{className:`text-muted-foreground/70 text-xs pl-0 truncate w-full`,children:e.description}):null]}),t===c&&(0,J.jsx)(_t,{className:`w-3.5 h-3.5 ml-auto text-blue-600 dark:text-blue-400 flex-shrink-0`})]},e.name))]})})})})})})}),rm=(e,t,n=!0)=>we({queryKey:P(e,t).queryKey,queryFn:P(e,t).queryFn,enabled:n&&!!e,staleTime:1e3*60*5}),im=e=>{let t=e.lastIndexOf(`@`);if(t===-1)return{shouldShow:!1,searchPath:``,beforeAt:``,afterAt:``};let n=e.slice(0,t),r=e.slice(t+1),i=r.split(/\s/),a=i[0]??``;return{shouldShow:!(i.length>1),searchPath:a,beforeAt:n,afterAt:r}},am=(0,q.forwardRef)(({projectId:e,inputValue:t,onFileSelect:n,className:r},i)=>{let{i18n:a}=Xe(),[o,s]=(0,q.useState)(!1),[c,l]=(0,q.useState)(-1),u=(0,q.useRef)(null),d=(0,q.useRef)(null),{shouldShow:f,searchPath:p,beforeAt:m,afterAt:h}=(0,q.useMemo)(()=>im(t),[t]),{basePath:g,filterTerm:_}=(0,q.useMemo)(()=>{if(!p)return{basePath:`/`,filterTerm:``};let e=p.lastIndexOf(`/`);if(e===-1)return{basePath:`/`,filterTerm:p};let t=p.slice(0,e+1),n=p.slice(e+1);return{basePath:t===`/`?`/`:t,filterTerm:n}},[p]),{data:v,isLoading:y}=rm(e,g,f),b=(0,q.useMemo)(()=>v?.entries?_?v.entries.filter(e=>e.name.toLowerCase().includes(_.toLowerCase())):v.entries:[],[v?.entries,_]),x=f&&!y&&b.length>0;o!==x&&(s(x),l(-1));let S=(0,q.useCallback)((e,t=!1)=>{n(`${m}@${e.path}${h.split(/\s/).slice(1).join(` `)}`.trim()+(e.type===`directory`&&!t?`/`:` `)),(e.type===`file`||t)&&(s(!1),l(-1))},[m,h,n]),C=(0,q.useCallback)(e=>{if(e>=0&&d.current){let t=d.current.querySelectorAll(`button[role="option"]`)[e];t instanceof HTMLElement&&t.scrollIntoView({block:`nearest`,behavior:`smooth`})}},[]),w=(0,q.useCallback)(e=>{if(!o||b.length===0)return!1;switch(e.key){case`ArrowDown`:return e.preventDefault(),l(e=>{let t=e<b.length-1?e+1:0;return requestAnimationFrame(()=>C(t)),t}),!0;case`ArrowUp`:return e.preventDefault(),l(e=>{let t=e>0?e-1:b.length-1;return requestAnimationFrame(()=>C(t)),t}),!0;case`Enter`:if(c>=0&&c<b.length){e.preventDefault();let t=b[c];return t&&S(t,!0),!0}return!1;case`Tab`:if(c>=0&&c<b.length){e.preventDefault();let t=b[c];return t&&S(t,t.type===`file`),!0}return!1;case`Escape`:return e.preventDefault(),s(!1),l(-1),!0;default:return!1}},[o,c,S,C,b]);return(0,q.useEffect)(()=>{let e=e=>{u.current&&e.target instanceof Node&&!u.current.contains(e.target)&&(s(!1),l(-1))};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]),(0,q.useImperativeHandle)(i,()=>({handleKeyDown:w}),[w]),!f||y||b.length===0?null:(0,J.jsx)(`div`,{ref:u,className:U(`relative`,r),children:(0,J.jsx)(lc,{open:o,onOpenChange:s,children:(0,J.jsx)(dc,{children:(0,J.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":a._(`Available files and directories`),children:(0,J.jsx)(`div`,{className:`h-full overflow-y-auto`,children:b.length>0&&(0,J.jsxs)(`div`,{className:`p-1.5`,children:[(0,J.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:[(0,J.jsx)(zn,{className:`w-3.5 h-3.5`}),`Files & Directories (`,b.length,`)`,g!==`/`&&(0,J.jsxs)(`span`,{className:`text-xs font-mono text-muted-foreground/70`,children:[`in `,g]})]}),b.map((e,t)=>(0,J.jsxs)(H,{variant:`ghost`,size:`sm`,className:U(`w-full justify-start text-left font-mono text-sm h-9 px-3 min-w-0 transition-colors duration-150`,t===c?`bg-gradient-to-r from-blue-500/10 to-purple-500/10 text-foreground border border-blue-500/20`:`hover:bg-accent/50`),onClick:()=>S(e,e.type===`file`),onMouseEnter:()=>l(t),role:`option`,"aria-selected":t===c,"aria-label":`${e.type}: ${e.name}`,title:e.path,children:[e.type===`directory`?(0,J.jsx)(vt,{className:`w-3.5 h-3.5 mr-2 text-blue-500 dark:text-blue-400 flex-shrink-0`}):(0,J.jsx)(zn,{className:`w-3.5 h-3.5 mr-2 text-gray-500 dark:text-gray-400 flex-shrink-0`}),(0,J.jsx)(`span`,{className:`font-medium truncate min-w-0`,children:e.name}),e.type===`directory`&&(0,J.jsx)(`span`,{className:`text-muted-foreground ml-1 flex-shrink-0`,children:`/`}),t===c&&(0,J.jsx)(_t,{className:`w-3.5 h-3.5 ml-auto text-blue-600 dark:text-blue-400 flex-shrink-0`})]},e.path))]})})})})})})});am.displayName=`FileCompletion`;var om=(e,t,n)=>{let r=typeof window<`u`?window.innerHeight:800,i=r/2,a=48+36*Math.min(n,5)+12,o=t.top<i,s=r-t.top,c=t.top,l,u;o&&s>=a+20?(l=`below`,u=e.top+24):!o&&c>=a+20?(l=`above`,u=e.top-a-16):s>c?(l=`below`,u=e.top+24):(l=`above`,u=e.top-a-16);let d=(typeof window<`u`?window.innerWidth:1200)-512-16,f=Math.max(16,Math.min(e.left-16,d));return{top:u,left:f,placement:l}},sm=({projectId:e,message:t,commandCompletionRef:n,fileCompletionRef:r,handleCommandSelect:i,handleFileSelect:a,cursorPosition:o})=>{let s=(0,q.useMemo)(()=>om(o.relative,o.absolute,5),[o]);return(0,J.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:s.top,left:s.left,maxWidth:typeof window<`u`?Math.min(512,window.innerWidth*.8):512},children:[(0,J.jsx)(nm,{ref:n,projectId:e,inputValue:t,onCommandSelect:i,className:`absolute left-0 right-0 ${s.placement===`above`?`bottom-full mb-2`:`top-full mt-1`}`}),(0,J.jsx)(am,{ref:r,projectId:e,inputValue:t,onFileSelect:a,className:`absolute left-0 right-0 ${s.placement===`above`?`bottom-full mb-2`:`top-full mt-1`}`})]})},cm=({projectId:e,onSubmit:t,isPending:n,error:r,placeholder:i,buttonText:a,minHeight:o=`min-h-[64px]`,containerClassName:s=``,disabled:c=!1,sendDisabled:l=!1,buttonSize:u=`lg`,enableScheduledSend:d=!1,baseSessionId:f=null,enableCCOptions:p=!1,ccOptions:m,onCCOptionsChange:h})=>{let g=(e=>{let t=e.match(/(\d+)px/);if(t?.[1]!==void 0){let e=parseInt(t[1],10);if(!Number.isNaN(e))return e}return 48})(o),{i18n:_}=Xe(),[v,y,b]=ad({projectId:e,sessionId:f??`new-session`}),[x,S]=(0,q.useState)([]),[C,w]=(0,q.useState)({relative:{top:0,left:0},absolute:{top:0,left:0}}),[T,E]=(0,q.useState)(`immediate`),[D,O]=(0,q.useState)(()=>{let e=new Date;return e.setHours(e.getHours()+1),`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}T${String(e.getHours()).padStart(2,`0`)}:${String(e.getMinutes()).padStart(2,`0`)}`}),k=(0,q.useRef)(null),A=(0,q.useRef)(null),j=(0,q.useRef)(null),M=(0,q.useRef)(null),N=(0,q.useRef)(null),{config:P}=ge(),ee=Wd(),{isSupported:te,isListening:ne,audioLevels:re,toggle:ie}=df({onTranscript:(0,q.useCallback)(e=>{y(t=>t+e)},[y])});(0,q.useEffect)(()=>{let e=A.current;if(!e)return;e.style.height=`auto`;let t=e.scrollHeight;e.style.height=`${Math.max(g,Math.min(t,200))}px`},[v,g]),(0,q.useEffect)(()=>{let e=A.current;e&&(e.style.height=`${g}px`)},[g]);let F=e=>{if(e.length===0)return;let t=e.map(e=>({file:e,id:`${e.name}-${Date.now()}-${Math.random()}`}));S(e=>[...e,...t])},ae=async()=>{if(!v.trim()&&x.length===0||n||c||l)return;let r=[],i=[];for(let{file:e}of x){let t=await tm(e);t!==null&&(t.type===`text`?i.push({type:`document`,source:{type:`text`,media_type:`text/plain`,data:t.content}}):t.type===`image`?r.push(t.block):t.type===`document`&&i.push(t.block))}if(d&&T===`scheduled`){let t=D.match(/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})$/);if(!t)throw Error(`Invalid datetime format`);let n=Number(t[1]),r=Number(t[2]),i=Number(t[3]),a=Number(t[4]),o=Number(t[5]),s=new Date(n,r-1,i,a,o);try{await ee.mutateAsync({name:`Scheduled message at ${D}`,schedule:{type:`reserved`,reservedExecutionTime:s.toISOString()},message:{content:v,projectId:e,sessionId:f!==null&&f!==``?f:crypto.randomUUID(),resume:f!==null&&f!==``},enabled:!0}),z.success(_._({id:`chat.scheduled_send.success`,message:`Message scheduled successfully`}),{description:_._({id:`chat.scheduled_send.success_description`,message:`You can view and manage it in the Scheduler tab`})}),b(),S([])}catch(e){z.error(_._({id:`chat.scheduled_send.failed`,message:`Failed to schedule message`}),{description:e instanceof Error?e.message:void 0})}}else await t({text:v,images:r.length>0?r:void 0,documents:i.length>0?i:void 0,ccOptions:m}),b(),S([])},oe=e=>{let t=e.target.files;t&&(F(Array.from(t)),j.current&&(j.current.value=``))},se=e=>{let t=Qp(e.clipboardData);t.length!==0&&(e.preventDefault(),F(t))},ce=e=>{S(t=>t.filter(t=>t.id!==e))},le=e=>{if(N.current?.handleKeyDown(e)!==!0&&M.current?.handleKeyDown(e)!==!0&&e.key===`Enter`&&!e.nativeEvent.isComposing){let t=P?.enterKeyBehavior;(t===`enter-send`&&!e.shiftKey&&!e.metaKey||t===`shift-enter-send`&&e.shiftKey&&!e.metaKey||t===`command-enter-send`&&e.metaKey&&!e.shiftKey)&&(e.preventDefault(),ae())}},ue=(0,q.useCallback)(()=>{let e=A.current,t=k.current;if(e===null||t===null)return;let n=e.selectionStart,r=e.value.substring(0,n),i=e.value.substring(n),a=document.createTextNode(r),o=document.createTextNode(i),s=document.createElement(`span`);s.innerHTML=`&nbsp;`;let c=document.createElement(`div`);c.innerHTML=``,c.append(a,s,o);let l=window.getComputedStyle(e);for(let e of[`border`,`boxSizing`,`fontFamily`,`fontSize`,`fontWeight`,`letterSpacing`,`lineHeight`,`padding`,`textDecoration`,`textIndent`,`textTransform`,`whiteSpace`,`wordSpacing`,`wordWrap`])c.style[e]=l[e];c.style.visibility=`hidden`,t.prepend(c);let u=s.getBoundingClientRect(),d=t.getBoundingClientRect();return t.removeChild(c),{relative:{top:u.top-d.top-e.scrollTop,left:u.left-d.left-e.scrollLeft},absolute:{top:u.top-e.scrollTop,left:u.left-e.scrollLeft}}},[]),I=e=>{y(e),A.current?.focus()},de=e=>{y(e),A.current?.focus()};return(0,J.jsxs)(`div`,{className:s,children:[r&&(0,J.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:[(0,J.jsx)(Ft,{className:`w-4 h-4 shrink-0 mt-0.5`}),(0,J.jsx)(`span`,{className:`font-medium`,children:(0,J.jsx)(B,{id:`chat.error.send_failed`})})]}),(0,J.jsxs)(`div`,{className:`relative group`,children:[(0,J.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 group-focus-within:opacity-100 transition-opacity duration-500 will-change-opacity`,"aria-hidden":`true`}),(0,J.jsxs)(`div`,{className:`relative bg-background border border-border/40 rounded-2xl shadow-lg hover:shadow-xl transition-all duration-300 overflow-hidden ring-0 group-focus-within:ring-1 group-focus-within:ring-primary/20 group-focus-within:border-primary/20`,children:[(0,J.jsx)(`div`,{className:`relative`,ref:k,children:(0,J.jsx)(Zc,{ref:A,value:v,onChange:e=>{if(e.target.value.endsWith(`@`)||e.target.value.endsWith(`/`)){let e=ue();e&&w(e)}y(e.target.value)},onKeyDown:le,onPaste:se,placeholder:i,className:`resize-none border-0 focus-visible:ring-0 focus-visible:ring-offset-0 bg-transparent px-5 py-4 text-base transition-all duration-200 placeholder:text-muted-foreground/50 overflow-y-auto leading-relaxed antialiased font-normal`,style:{minHeight:`${g}px`},disabled:n||c,"aria-label":_._(`Message input with completion support`),"aria-expanded":Yp(v)})}),x.length>0&&(0,J.jsx)(`div`,{className:`px-5 py-3 flex flex-wrap gap-2 border-t border-border/40 bg-muted/10 animate-in fade-in slide-in-from-top-1 duration-200`,children:x.map(({file:e,id:t})=>(0,J.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 bg-background border border-border/50 shadow-sm rounded-lg text-sm text-foreground/80 hover:text-foreground hover:border-foreground/20 transition-all duration-200`,children:[(0,J.jsx)(`span`,{className:`truncate max-w-[200px] font-medium`,children:e.name}),(0,J.jsx)(`button`,{type:`button`,onClick:()=>ce(t),className:`text-muted-foreground hover:text-red-500 transition-colors bg-transparent rounded-full p-0.5 hover:bg-muted`,disabled:n,children:(0,J.jsx)(Ce,{className:`w-3.5 h-3.5`})})]},t))}),(0,J.jsxs)(`div`,{className:`flex flex-col gap-2 px-2 py-1 bg-muted/10 border-t border-border/30 backdrop-blur-sm`,children:[d&&T===`scheduled`&&(0,J.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-stretch sm:items-center gap-2 pt-1 animate-in fade-in duration-200`,children:[(0,J.jsx)(W,{htmlFor:`send-mode-mobile`,className:`text-xs sr-only`,children:(0,J.jsx)(B,{id:`chat.send_mode.label`})}),(0,J.jsxs)(gc,{value:T,onValueChange:e=>E(e),disabled:n||c,children:[(0,J.jsx)(vc,{id:`send-mode-mobile`,className:`h-8 w-full sm:w-[140px] text-xs bg-background/50 border-border/50 shadow-sm focus:ring-primary/20`,children:(0,J.jsx)(_c,{})}),(0,J.jsxs)(xc,{children:[(0,J.jsx)(X,{value:`immediate`,children:(0,J.jsx)(B,{id:`chat.send_mode.immediate`})}),(0,J.jsx)(X,{value:`scheduled`,children:(0,J.jsx)(B,{id:`chat.send_mode.scheduled`})})]})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5 flex-1`,children:[(0,J.jsx)(W,{htmlFor:`scheduled-time`,className:`text-xs sr-only`,children:(0,J.jsx)(B,{id:`chat.send_mode.scheduled_time`})}),(0,J.jsx)(At,{id:`scheduled-time`,type:`datetime-local`,value:D,onChange:e=>O(e.target.value),disabled:n||c,className:`h-8 w-full sm:w-[180px] text-xs bg-background/50 border-border/50 shadow-sm focus:ring-primary/20`})]})]}),(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-0.5 text-muted-foreground/70 flex-1 min-w-0 flex-wrap`,children:[(0,J.jsx)(`input`,{ref:j,type:`file`,multiple:!0,onChange:oe,className:`hidden`}),(0,J.jsxs)(pt,{children:[(0,J.jsx)(ht,{asChild:!0,children:(0,J.jsx)(H,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>j.current?.click(),disabled:n||c,className:`px-1.5 hover:bg-background/80 hover:text-foreground text-muted-foreground transition-all duration-200 h-7 rounded-lg`,children:(0,J.jsx)(or,{className:`w-3.5 h-3.5`})})}),(0,J.jsx)(tt,{children:(0,J.jsx)(B,{id:`chat.attach_file`})})]}),p&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(pt,{children:[(0,J.jsx)(ht,{asChild:!0,children:(0,J.jsx)(`span`,{children:(0,J.jsxs)(gc,{value:m?.model??`default`,onValueChange:e=>h?.({...m,model:e===`default`?void 0:e}),disabled:n||c,children:[(0,J.jsx)(vc,{className:`h-7 w-auto min-w-[80px] text-[11px] font-medium bg-background/50 border-border/30 shadow-none hover:bg-background hover:border-border/50 transition-all duration-200 gap-1 px-2`,children:(0,J.jsx)(_c,{})}),(0,J.jsx)(xc,{children:(P?.modelChoices??[`default`]).map(e=>(0,J.jsx)(X,{value:e,children:e},e))})]})})}),(0,J.jsx)(tt,{children:(0,J.jsx)(B,{id:`chat.toolbar.model.tooltip`,message:`Select model`})})]}),(0,J.jsxs)(pt,{children:[(0,J.jsx)(ht,{asChild:!0,children:(0,J.jsx)(`span`,{children:(0,J.jsxs)(gc,{value:m?.effort??`auto`,onValueChange:e=>h?.({...m,effort:e===`auto`?void 0:e}),disabled:n||c,children:[(0,J.jsx)(vc,{className:`h-7 w-auto min-w-[70px] text-[11px] font-medium bg-background/50 border-border/30 shadow-none hover:bg-background hover:border-border/50 transition-all duration-200 gap-1 px-2`,children:(0,J.jsx)(_c,{})}),(0,J.jsxs)(xc,{children:[(0,J.jsx)(X,{value:`auto`,children:`Auto`}),(0,J.jsx)(X,{value:`low`,children:`Low`}),(0,J.jsx)(X,{value:`medium`,children:`Medium`}),(0,J.jsx)(X,{value:`high`,children:`High`}),(0,J.jsx)(X,{value:`max`,children:`Max`})]})]})})}),(0,J.jsx)(tt,{children:(0,J.jsx)(B,{id:`chat.toolbar.effort.tooltip`,message:`Select reasoning effort`})})]})]}),p&&h&&(0,J.jsx)(Jp,{value:m,onChange:h,disabled:n||c})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-1`,children:[d&&T===`immediate`&&(0,J.jsxs)(pt,{children:[(0,J.jsx)(ht,{asChild:!0,children:(0,J.jsx)(H,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>E(`scheduled`),disabled:n||c,className:`h-9 px-2`,children:(0,J.jsx)(vn,{className:`w-4 h-4`})})}),(0,J.jsx)(tt,{children:(0,J.jsx)(B,{id:`chat.send_mode.scheduled`})})]}),te&&(0,J.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[ne&&(0,J.jsx)(`div`,{className:`flex items-center gap-px h-4 px-0.5`,children:[`a`,`b`,`c`,`d`].map((e,t)=>(0,J.jsx)(`div`,{className:`w-0.5 rounded-full bg-red-500 transition-all duration-75 ease-out`,style:{height:`${Math.max(3,(re[t]??0)*16)}px`}},e))}),(0,J.jsxs)(pt,{children:[(0,J.jsx)(ht,{asChild:!0,children:(0,J.jsx)(H,{type:`button`,variant:`ghost`,size:`sm`,onClick:ie,disabled:n||c,className:`px-1.5 hover:bg-background/80 hover:text-foreground transition-all duration-200 h-7 rounded-lg ${ne?`text-red-500`:`text-muted-foreground`}`,children:ne?(0,J.jsx)(er,{className:`w-3.5 h-3.5`}):(0,J.jsx)(tr,{className:`w-3.5 h-3.5`})})}),(0,J.jsx)(tt,{children:(0,J.jsx)(B,{id:`chat.voice_input`,message:`Voice input`})})]})]}),(0,J.jsx)(H,{onClick:()=>{ae()},disabled:!v.trim()&&x.length===0||n||c||l,size:u,className:`gap-2 px-3 h-9 transition-all duration-300 shadow-md hover:shadow-lg hover:scale-[1.02] active:scale-[0.98] bg-gradient-to-r from-blue-600 via-indigo-600 to-purple-600 hover:from-blue-500 hover:via-indigo-500 hover:to-purple-500 disabled:from-muted disabled:to-muted disabled:shadow-none bg-[length:200%_auto] hover:bg-[position:right_center]`,children:n?(0,J.jsx)(Yn,{className:`w-4 h-4 animate-spin`}):(0,J.jsx)(pr,{className:`w-4 h-4`})})]})]})]})]}),(0,J.jsx)(sm,{projectId:e,message:v,commandCompletionRef:M,fileCompletionRef:N,handleCommandSelect:I,handleFileSelect:de,cursorPosition:C})]})]})},lm=(e,t)=>{let n=N({from:`/projects/$projectId/session`});return p({mutationFn:async r=>{let{ccOptions:i,...a}=r.input,s=r.baseSessionId,c=s!==void 0&&s!==``,l=c?s:crypto.randomUUID();fu({sessionId:l,projectId:e,userMessage:a.text,sentAt:new Date().toISOString()}),n({to:`/projects/$projectId/session`,params:{projectId:e},search:{sessionId:l}}),t?.();try{let t=await o.api[`claude-code`][`session-processes`].$post({json:{projectId:e,sessionId:l,resume:c,input:a,ccOptions:i}},{init:{signal:AbortSignal.timeout(10*1e3)}});if(!t.ok)throw Error(t.statusText);return await t.json()}catch(e){throw mu(l),e}}})},um=(e,t)=>p({mutationFn:async n=>{fu({sessionId:t,projectId:e,userMessage:n.input.text,sentAt:new Date().toISOString()});try{let r=await o.api[`claude-code`][`session-processes`][`:sessionProcessId`].continue.$post({param:{sessionProcessId:n.sessionProcessId},json:{projectId:e,baseSessionId:t,input:n.input}},{init:{signal:AbortSignal.timeout(10*1e3)}});if(!r.ok)throw Error(r.statusText);return await r.json()}catch(e){throw mu(t),e}}}),dm=()=>{let[e,t]=(0,q.useState)({relative:{top:0,left:0},absolute:{top:0,left:0}}),n=(0,q.useRef)(null),r=(0,q.useRef)(null),i=(0,q.useRef)(null),a=(0,q.useRef)(null),o=(0,q.useCallback)(()=>{let e=r.current,t=n.current;if(e===null||t===null)return;let i=e.selectionStart,a=e.value.substring(0,i),o=e.value.substring(i),s=document.createTextNode(a),c=document.createTextNode(o),l=document.createElement(`span`);l.innerHTML=`&nbsp;`;let u=document.createElement(`div`);u.innerHTML=``,u.append(s,l,c);let d=window.getComputedStyle(e);for(let e of[`border`,`boxSizing`,`fontFamily`,`fontSize`,`fontWeight`,`letterSpacing`,`lineHeight`,`padding`,`textDecoration`,`textIndent`,`textTransform`,`whiteSpace`,`wordSpacing`,`wordWrap`])u.style[e]=d[e];u.style.visibility=`hidden`,t.prepend(u);let f=l.getBoundingClientRect(),p=t.getBoundingClientRect();return t.removeChild(u),{relative:{top:f.top-p.top-e.scrollTop,left:f.left-p.left-e.scrollLeft},absolute:{top:f.top-e.scrollTop,left:f.left-e.scrollLeft}}},[]);return{cursorPosition:e,containerRef:n,textareaRef:r,commandCompletionRef:i,fileCompletionRef:a,getCursorPosition:o,handleChange:(0,q.useCallback)((e,n)=>{if(e.endsWith(`@`)||e.endsWith(`/`)){let e=o();e&&t(e)}n(e)},[o]),handleKeyDown:(0,q.useCallback)(e=>a.current?.handleKeyDown(e)===!0||i.current?.handleKeyDown(e)===!0,[]),handleCommandSelect:(0,q.useCallback)((e,t)=>{t(e),r.current?.focus()},[]),handleFileSelect:(0,q.useCallback)((e,t)=>{t(e),r.current?.focus()},[])}},fm=({projectId:e,sessionId:t,sessionProcessId:n,sessionProcessStatus:r})=>{let{i18n:i}=Xe(),a=um(e,t),{config:o}=ge(),s=async e=>{await a.mutateAsync({input:e,sessionProcessId:n})},c=()=>{let e=o?.enterKeyBehavior;return e===`enter-send`?i._({id:`chat.placeholder.continue.enter`,message:`Type your message... (Start with / for commands, @ for files, Enter to send)`}):e===`command-enter-send`?i._({id:`chat.placeholder.continue.command_enter`,message:`Type your message... (Start with / for commands, @ for files, Command+Enter to send)`}):i._({id:`chat.placeholder.continue.shift_enter`,message:`Type your message... (Start with / for commands, @ for files, Shift+Enter to send)`})},l=r===`running`;return(0,J.jsx)(`div`,{className:`w-full px-4 pb-3`,children:(0,J.jsx)(cm,{projectId:e,onSubmit:s,isPending:a.isPending,error:a.error,placeholder:l?(()=>{let e=o?.enterKeyBehavior;return e===`enter-send`?i._({id:`chat.placeholder.running.enter`,message:`Claude is running… type your next message and send when ready (Enter to send)`}):e===`command-enter-send`?i._({id:`chat.placeholder.running.command_enter`,message:`Claude is running… type your next message and send when ready (Command+Enter to send)`}):i._({id:`chat.placeholder.running.shift_enter`,message:`Claude is running… type your next message and send when ready (Shift+Enter to send)`})})():c(),buttonText:(0,J.jsx)(B,{id:`chat.send`}),containerClassName:``,buttonSize:`default`,enableScheduledSend:!l,baseSessionId:t,sendDisabled:l})})},pm=({projectId:e,sessionId:t,ccOptions:n,onCCOptionsChange:r})=>{let{i18n:i}=Xe(),a=lm(e),{config:o}=ge(),s=async e=>{await a.mutateAsync({input:e,baseSessionId:t})},c=()=>{let e=o?.enterKeyBehavior;return e===`enter-send`?i._({id:`chat.placeholder.resume.enter`,message:`Type your message... (Start with / for commands, @ for files, Enter to send)`}):e===`command-enter-send`?i._({id:`chat.placeholder.resume.command_enter`,message:`Type your message... (Start with / for commands, @ for files, Command+Enter to send)`}):i._({id:`chat.placeholder.resume.shift_enter`,message:`Type your message... (Start with / for commands, @ for files, Shift+Enter to send)`})},l=(0,J.jsx)(B,{id:`chat.resume`});return(0,J.jsx)(`div`,{className:`w-full px-4 pb-3`,children:(0,J.jsx)(cm,{projectId:e,onSubmit:s,isPending:a.isPending,error:a.error,placeholder:c(),buttonText:l,containerClassName:``,buttonSize:`default`,enableScheduledSend:!0,baseSessionId:t,enableCCOptions:!0,ccOptions:n,onCCOptionsChange:r})})},mm=({projectId:e,ccOptions:t,onCCOptionsChange:n})=>{let{i18n:r}=Xe(),i=lm(e),{config:a}=ge();return(0,J.jsx)(`div`,{className:`w-full px-4 pb-3`,children:(0,J.jsx)(cm,{projectId:e,onSubmit:async e=>{await i.mutateAsync({input:e})},isPending:i.isPending,error:i.error,placeholder:(()=>{let e=a?.enterKeyBehavior;return e===`enter-send`?r._({id:`chat.placeholder.continue.enter`,message:`Type your message... (Start with / for commands, @ for files, Enter to send)`}):e===`command-enter-send`?r._({id:`chat.placeholder.continue.command_enter`,message:`Type your message... (Start with / for commands, @ for files, Command+Enter to send)`}):r._({id:`chat.placeholder.continue.shift_enter`,message:`Type your message... (Start with / for commands, @ for files, Shift+Enter to send)`})})(),buttonText:(0,J.jsx)(B,{id:`chat.button.start`}),containerClassName:``,buttonSize:`default`,enableScheduledSend:!0,enableCCOptions:!0,ccOptions:t,onCCOptionsChange:n})})},hm=()=>{let e=re();return p({mutationFn:async({projectId:e,sessionId:t})=>{let n=await o.api.projects[`:projectId`].sessions[`:sessionId`].$delete({param:{projectId:e,sessionId:t}});if(!n.ok)throw n.status===404?Error(`Session not found`):Error(`Failed to delete session`);return n.json()},onSuccess:(t,{projectId:n})=>{e.invalidateQueries({queryKey:ne(n).queryKey})}})},gm=({open:e,onOpenChange:t,projectId:n,sessionId:r,sessionTitle:i,onSuccess:a})=>{let{i18n:o}=Xe(),s=hm();return(0,J.jsx)(Be,{open:e,onOpenChange:t,children:(0,J.jsxs)(Ue,{className:`max-w-2xl max-h-[80vh] overflow-auto`,children:[(0,J.jsxs)(We,{children:[(0,J.jsx)(Ae,{children:(0,J.jsx)(B,{id:`session.delete_dialog.title`})}),(0,J.jsx)(ke,{className:`break-words line-clamp-10`,children:(0,J.jsx)(B,{id:`session.delete_dialog.description`,values:{title:i}})})]}),(0,J.jsxs)(Re,{children:[(0,J.jsx)(H,{variant:`outline`,onClick:()=>{t(!1)},disabled:s.isPending,children:(0,J.jsx)(B,{id:`common.cancel`})}),(0,J.jsx)(H,{variant:`destructive`,onClick:()=>{s.mutate({projectId:n,sessionId:r},{onSuccess:()=>{z.success(o._({id:`session.delete.success`,message:`Session deleted successfully`})),t(!1),a?.()},onError:e=>{z.error(o._({id:`session.delete.failed`,message:`Failed to delete session`}),{description:e.message})}})},disabled:s.isPending,children:s.isPending?(0,J.jsx)(B,{id:`common.deleting`}):(0,J.jsx)(B,{id:`common.delete`})})]})]})})},_m=e=>{if(e===`running`)return{labelId:`session.status.running`,className:`bg-green-500/10 text-green-700 dark:text-green-300 border-green-500/20`,icon:`running`};if(e===`paused`)return{labelId:`session.status.paused`,className:`bg-orange-500/10 text-orange-700 dark:text-orange-300 border-orange-500/20`,icon:`paused`}},vm=e=>e.sessionId===void 0||e.sessionId===``?(0,J.jsx)(bm,{...e,sessionData:null,onMobileMenuOpen:e.onMobileMenuOpen}):(0,J.jsx)(ym,{...e,sessionId:e.sessionId}),ym=e=>{let t=_u(e.projectId,e.sessionId);return(0,J.jsx)(bm,{...e,sessionId:e.sessionId,sessionData:t,onMobileMenuOpen:e.onMobileMenuOpen})},bm=({projectId:e,sessionId:t,projectPath:n,projectName:r,sessionData:i,onMobileMenuOpen:a})=>{let s=N(),c=i?.conversations,l=c?.length??0,u=t!==void 0&&t!==``,d=n!==void 0&&n!==``,f=i?.getToolResult??(()=>void 0),m=u&&i!=null,{currentPermissionRequest:h,onPermissionResponse:g}=Bd(t),{currentQuestionRequest:_,onQuestionResponse:v}=Vd(t),{data:y}=Iu(e),b=y?.success===!0?y.data.currentBranch?.name:void 0,x=b!==void 0&&b!==``,S=rf(),{data:C}=Ud(),{data:w}=xd(e),E=T(It),D=T(uu),{config:O}=ge(),[k,A]=Cd(e),[j,M]=(0,q.useState)(()=>({...Ad(),...k.model!==void 0&&k.model!==``?{model:k.model}:{},...k.effort===void 0?{}:{effort:k.effort},...k.permissionMode===void 0?{}:{permissionMode:k.permissionMode},...k.useSystemPromptPreset===!1?{systemPrompt:void 0}:{}})),P=(0,q.useCallback)(e=>{M(e),A({model:e?.model,effort:e?.effort,permissionMode:e?.permissionMode,useSystemPromptPreset:e?.systemPrompt!==void 0})},[A]),ee=(0,q.useMemo)(()=>{let t=w.pages.flatMap(e=>e.sessions),n=wd(D,e,new Set(t.map(e=>e.id)));return[...t,...n]},[w.pages,e,D]),te=(0,q.useMemo)(()=>(c??[]).some(e=>e.type!==`user`||typeof e.message.content!=`string`?!1:oc(e.message.content).kind===`local-command`),[c]),ne=(0,q.useMemo)(()=>[...ee].sort((e,t)=>{let n=E.find(t=>t.sessionId===e.id),r=E.find(e=>e.sessionId===t.id),i=n?.status,a=r?.status,o=e=>e===`running`?0:e===`paused`?1:2,s=o(i),c=o(a);if(s!==c)return s-c;let l=e.lastModifiedAt?new Date(e.lastModifiedAt).getTime():0;return(t.lastModifiedAt?new Date(t.lastModifiedAt).getTime():0)-l}),[ee,E]),re=af(),F=(0,q.useMemo)(()=>{if(u)return re.getSessionProcess(t)},[u,t,re]),ae=!F,oe=F?.status===`running`&&te?`paused`:F?.status,se=_m(oe);$d(oe===`running`,t??``);let ce=(0,q.useMemo)(()=>!u||C===void 0?[]:C.filter(n=>n.message.resume&&n.message.sessionId===t&&n.message.projectId===e&&n.schedule.type===`reserved`&&n.lastRunStatus===null),[C,u,e,t]),[le,ue]=(0,q.useState)(0),[I,de]=(0,q.useState)(!1),fe=(0,q.useRef)(null),pe=(0,q.useRef)(null),me=(0,q.useCallback)(e=>{let t=fe.current;if(t!==null){if(t.scrollTo({top:t.scrollHeight,behavior:`auto`}),e<=0){pe.current=null;return}pe.current=window.requestAnimationFrame(()=>{me(e-1)})}},[]),L=p({mutationFn:async t=>{let n=await o.api[`claude-code`][`session-processes`][`:sessionProcessId`].abort.$post({param:{sessionProcessId:t},json:{projectId:e}});if(!n.ok)throw Error(n.statusText);return n.json()}});(0,q.useEffect)(()=>{if(m&&oe===`running`&&l!==le){let e=fe.current;if(e!==null&&e.scrollHeight-e.scrollTop-e.clientHeight>120){ue(l);return}ue(l),me(6)}},[l,m,oe,le,me]);let ve=()=>{let e=fe.current;e!==null&&e.scrollTo({top:0,behavior:`auto`})},ye=()=>{pe.current!==null&&(window.cancelAnimationFrame(pe.current),pe.current=null),me(8)};(0,q.useEffect)(()=>()=>{pe.current!==null&&window.cancelAnimationFrame(pe.current)},[]);let be=tf(i?.session.meta.customTitle??null,i?.session.meta.firstUserMessage??null,t??``),xe=()=>{if(i==null||!u)return;let e=t.replace(/[^a-zA-Z0-9._-]/g,`_`)||`unknown`,n=i.conversations.map(e=>e.type===`x-error`?e.line:JSON.stringify(e)).join(`
8
- `),r=new File([n],`ccv-jsonl-export-${e}.jsonl`,{type:`application/x-ndjson`}),a=URL.createObjectURL(r),o=document.createElement(`a`);o.href=a,o.download=r.name,o.rel=`noopener`,o.target=`_self`,o.style.display=`none`,document.body.appendChild(o),o.click(),setTimeout(()=>{URL.revokeObjectURL(a),o.remove()},1e3)},Se=async()=>{let e=i?.session.jsonlFilePath;if(!(e===void 0||e===``))try{await navigator.clipboard.writeText(e),z.success(`Session file path copied`)}catch(e){console.error(`Failed to copy session file path:`,e),z.error(`Failed to copy session file path`)}},R=r??e;return m?u&&(R=be):R=(0,J.jsx)(B,{id:`chat.modal.title`}),(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`flex-1 flex flex-col min-h-0 min-w-0`,children:[(0,J.jsx)(`header`,{className:`px-2 sm:px-3 py-1.5 sm:py-2 sticky top-0 z-10 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/80 w-full flex-shrink-0 min-w-0 border-b border-border/40`,children:(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0 flex-1`,children:[a&&(0,J.jsx)(H,{variant:`ghost`,size:`sm`,className:`flex-shrink-0 h-7 w-7 p-0 md:hidden`,onClick:a,"aria-label":`Open menu`,children:(0,J.jsx)(Zn,{className:`w-4 h-4`})}),se&&(0,J.jsxs)(Y,{variant:`secondary`,className:U(`h-5 text-[10px] px-1.5 flex-shrink-0`,se.className),children:[se.icon===`running`?(0,J.jsx)(Yn,{className:`w-2.5 h-2.5 mr-0.5 animate-spin`}):(0,J.jsx)(sr,{className:`w-2.5 h-2.5 mr-0.5`}),(0,J.jsx)(B,{id:se.labelId})]}),(0,J.jsx)(`h1`,{className:`text-sm sm:text-base font-semibold break-all overflow-ellipsis line-clamp-1 min-w-0 text-foreground/90`,children:R})]}),m&&(0,J.jsxs)(ot,{children:[(0,J.jsx)(ut,{asChild:!0,children:(0,J.jsx)(H,{variant:`ghost`,size:`sm`,className:`flex-shrink-0 h-7 w-7 p-0`,"aria-label":`Open session menu`,children:(0,J.jsx)(Fn,{className:`w-4 h-4`})})}),(0,J.jsx)($e,{className:`w-80`,align:`end`,children:(0,J.jsxs)(`div`,{className:`space-y-4`,children:[(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(`p`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wide`,children:`Actions`}),(0,J.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,J.jsxs)(H,{variant:`ghost`,size:`sm`,className:`justify-start`,onClick:()=>S.mutate({projectId:e,sessionId:t}),disabled:S.isPending,children:[(0,J.jsx)(Pn,{className:`w-4 h-4 mr-2 ${S.isPending?`animate-pulse`:``}`}),(0,J.jsx)(B,{id:`session.menu.export_html`})]}),(0,J.jsxs)(H,{variant:`ghost`,size:`sm`,className:`justify-start`,onClick:xe,children:[(0,J.jsx)(Pn,{className:`w-4 h-4 mr-2`}),(0,J.jsx)(B,{id:`session.menu.export_jsonl`})]}),i?.session.jsonlFilePath!==void 0&&i.session.jsonlFilePath!==``&&(0,J.jsxs)(H,{variant:`ghost`,size:`sm`,className:`justify-start`,onClick:()=>{Se()},children:[(0,J.jsx)(Nn,{className:`w-4 h-4 mr-2`}),(0,J.jsx)(B,{id:`session.menu.copy_session_path`})]}),(0,J.jsxs)(H,{variant:`ghost`,size:`sm`,className:`justify-start text-destructive hover:text-destructive`,onClick:()=>de(!0),children:[(0,J.jsx)(yr,{className:`w-4 h-4 mr-2`}),(0,J.jsx)(B,{id:`session.delete_dialog.title`})]})]})]}),(0,J.jsx)(`div`,{className:`h-px bg-border/60`}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h3`,{className:`font-semibold text-sm mb-2`,children:(0,J.jsx)(B,{id:`control.metadata`})}),(0,J.jsxs)(`div`,{className:`space-y-2`,children:[d&&(0,J.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,J.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:(0,J.jsx)(B,{id:`control.project_path`})}),(0,J.jsx)(Y,{variant:`secondary`,className:`h-7 text-xs flex items-center w-fit break-all`,children:n})]}),x&&(0,J.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,J.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:(0,J.jsx)(B,{id:`control.branch`})}),(0,J.jsxs)(Y,{variant:`secondary`,className:`h-7 text-xs flex items-center gap-1 w-fit`,children:[(0,J.jsx)(Vn,{className:`w-3 h-3`}),b]})]}),m&&(0,J.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,J.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:(0,J.jsx)(B,{id:`control.session_id`})}),(0,J.jsx)(Y,{variant:`secondary`,className:`h-7 text-xs flex items-center w-fit font-mono break-all`,children:t})]}),m&&(0,J.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,J.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:(0,J.jsx)(B,{id:`control.model`})}),(0,J.jsx)(Y,{variant:`secondary`,className:`h-7 text-xs flex items-center w-fit font-mono`,children:i.session.meta.modelName??`Unknown`})]}),m&&(0,J.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,J.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:(0,J.jsx)(B,{id:`session.cost.label`})}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsxs)(Y,{variant:`secondary`,className:`h-7 text-xs flex items-center w-fit font-semibold`,children:[(0,J.jsx)(B,{id:`session.cost.total`}),`: $`,i.session.meta.cost.totalUsd.toFixed(3)]}),(0,J.jsxs)(`div`,{className:`text-xs space-y-1 pl-2`,children:[(0,J.jsxs)(`div`,{className:`flex justify-between gap-4`,children:[(0,J.jsxs)(`span`,{className:`text-muted-foreground`,children:[(0,J.jsx)(B,{id:`session.cost.input_tokens`}),`:`]}),(0,J.jsxs)(`span`,{children:[`$`,i.session.meta.cost.breakdown.inputTokensUsd.toFixed(3),` `,`(`,i.session.meta.cost.tokenUsage.inputTokens.toLocaleString(),`)`]})]}),(0,J.jsxs)(`div`,{className:`flex justify-between gap-4`,children:[(0,J.jsxs)(`span`,{className:`text-muted-foreground`,children:[(0,J.jsx)(B,{id:`session.cost.output_tokens`}),`:`]}),(0,J.jsxs)(`span`,{children:[`$`,i.session.meta.cost.breakdown.outputTokensUsd.toFixed(3),` `,`(`,i.session.meta.cost.tokenUsage.outputTokens.toLocaleString(),`)`]})]}),(0,J.jsxs)(`div`,{className:`flex justify-between gap-4`,children:[(0,J.jsxs)(`span`,{className:`text-muted-foreground`,children:[(0,J.jsx)(B,{id:`session.cost.cache_creation`}),`:`]}),(0,J.jsxs)(`span`,{children:[`$`,i.session.meta.cost.breakdown.cacheCreationUsd.toFixed(3),` `,`(`,i.session.meta.cost.tokenUsage.cacheCreationTokens.toLocaleString(),`)`]})]}),(0,J.jsxs)(`div`,{className:`flex justify-between gap-4`,children:[(0,J.jsxs)(`span`,{className:`text-muted-foreground`,children:[(0,J.jsx)(B,{id:`session.cost.cache_read`}),`:`]}),(0,J.jsxs)(`span`,{children:[`$`,i.session.meta.cost.breakdown.cacheReadUsd.toFixed(3),` `,`(`,i.session.meta.cost.tokenUsage.cacheReadTokens.toLocaleString(),`)`]})]})]})]})]})]})]})]})})]})]})}),(0,J.jsx)(`div`,{ref:fe,className:`flex-1 overflow-y-auto min-h-0 min-w-0`,"data-testid":`scrollable-content`,children:(0,J.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:[(0,J.jsx)(su,{conversations:m?c??[]:[],getToolResult:f,projectId:e,sessionId:t??``,scheduledJobs:ce,scrollContainerRef:fe,enableInPageSearch:!0}),!m&&(0,J.jsxs)(`div`,{className:`space-y-6`,children:[(0,J.jsxs)(`div`,{className:`rounded-2xl border border-dashed border-muted-foreground/40 bg-muted/30 p-8 text-center space-y-3`,children:[(0,J.jsx)(`div`,{className:`mx-auto flex h-12 w-12 items-center justify-center rounded-full bg-background shadow-sm`,children:(0,J.jsx)(_e,{className:`w-5 h-5 text-muted-foreground`})}),(0,J.jsxs)(`div`,{className:`space-y-1`,children:[(0,J.jsx)(`p`,{className:`text-base font-semibold`,children:(0,J.jsx)(B,{id:`chat.modal.title`})}),(0,J.jsx)(`p`,{className:`text-sm text-muted-foreground leading-relaxed`,children:(0,J.jsx)(B,{id:`session.empty_state.description`})})]})]}),ne.length>0&&(0,J.jsxs)(`div`,{className:`space-y-3`,children:[(0,J.jsx)(`h3`,{className:`text-sm font-semibold text-muted-foreground`,children:(0,J.jsx)(B,{id:`chat.history.title`})}),(0,J.jsx)(`div`,{className:`grid gap-2`,children:ne.slice(0,3).map(t=>{let n=tf(t.meta.customTitle,t.meta.firstUserMessage,t.id),r=E.find(e=>e.sessionId===t.id),i=r?.status===`running`,a=r?.status===`paused`;return(0,J.jsxs)(ie,{to:`/projects/$projectId/session`,params:{projectId:e},search:{sessionId:t.id},className:U(`block p-3 rounded-lg transition-colors border`,`border-border/40 hover:bg-muted/50 hover:border-primary/30`),children:[(0,J.jsxs)(`div`,{className:`flex items-start justify-between gap-2 mb-1`,children:[(0,J.jsx)(`h4`,{className:`text-sm font-medium line-clamp-1 flex-1`,children:n}),(i||a)&&(0,J.jsx)(Y,{variant:`secondary`,className:U(`text-[10px] px-1.5 h-4 shrink-0`,i&&`bg-green-500/10 text-green-600 dark:text-green-400`,a&&`bg-yellow-500/10 text-yellow-600 dark:text-yellow-400`),children:i?(0,J.jsx)(B,{id:`session.status.running`}):(0,J.jsx)(B,{id:`session.status.paused`})})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] text-muted-foreground`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,J.jsx)(_e,{className:`w-2.5 h-2.5`}),(0,J.jsx)(`span`,{children:t.meta.messageCount})]}),t.lastModifiedAt&&(0,J.jsx)(`span`,{children:he(t.lastModifiedAt,{locale:O.locale,target:`time`})})]})]},t.id)})})]})]}),m&&oe===`running`&&(0,J.jsx)(`div`,{className:`flex justify-start items-center py-8 animate-in fade-in duration-500`,children:(0,J.jsxs)(`div`,{className:`flex flex-col items-center gap-4`,children:[(0,J.jsxs)(`div`,{className:`relative`,children:[(0,J.jsx)(Yn,{className:`w-8 h-8 animate-spin text-primary`}),(0,J.jsx)(`div`,{className:`absolute inset-0 rounded-full bg-primary/20 animate-ping`})]}),(0,J.jsx)(`p`,{className:`text-sm text-muted-foreground font-medium animate-pulse`,children:(0,J.jsx)(B,{id:`session.processing`})})]})})]})}),(0,J.jsx)(zd,{permissionRequest:h,questionRequest:_,onPermissionResponse:g,onQuestionResponse:v}),(0,J.jsx)(`div`,{className:`w-full pt-3`,children:(0,J.jsx)(sf,{projectId:e,onScrollToTop:ve,onScrollToBottom:ye,sessionProcess:F,abortTask:L,isNewChat:!m,enableCCOptions:ae,ccOptions:j,onCCOptionsChange:P})}),(0,J.jsx)(`div`,{className:`flex-shrink-0 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60`,children:m&&F?(0,J.jsx)(fm,{projectId:e,sessionId:t,sessionProcessId:F.id,sessionProcessStatus:oe}):m?(0,J.jsx)(pm,{projectId:e,sessionId:t,ccOptions:j,onCCOptionsChange:P}):(0,J.jsx)(mm,{projectId:e,ccOptions:j,onCCOptionsChange:P})})]}),m&&(0,J.jsx)(gm,{open:I,onOpenChange:de,projectId:e,sessionId:t,sessionTitle:be,onSuccess:()=>{s({to:`/projects/$projectId/session`,params:{projectId:e},search:{tab:`sessions`}})}})]})},xm=()=>`serviceWorker`in navigator&&`PushManager`in window&&`Notification`in window,Sm=()=>xm()?Notification.permission:`unsupported`,Cm=({showLabels:e=!0,showDescriptions:t=!0,className:n=``})=>{let r=(0,q.useId)(),[i,a]=f(qd),[o,s]=(0,q.useState)(Sm),[c,l]=(0,q.useState)(!1),u=(0,q.useCallback)(e=>{a(t=>({...t,soundType:e}))},[a]),d=(0,q.useCallback)(()=>{i.soundType!==`none`&&Xd(i.soundType)},[i.soundType]),p=(0,q.useCallback)(()=>{l(!0),Bt().then(e=>{s(e)}).finally(()=>{l(!1)})},[]),m=Qd();return(0,J.jsxs)(`div`,{className:`space-y-4 ${n}`,children:[o!==`unsupported`&&(0,J.jsxs)(`div`,{className:`space-y-2`,children:[e&&(0,J.jsx)(`p`,{className:`text-sm font-medium leading-none`,children:(0,J.jsx)(B,{id:`notification.push.label`})}),(0,J.jsx)(`div`,{className:`flex items-center gap-2`,children:o===`granted`?(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm text-muted-foreground`,children:[(0,J.jsx)(gn,{className:`w-3.5 h-3.5 text-primary`}),(0,J.jsx)(`span`,{children:(0,J.jsx)(B,{id:`notification.push.enabled`})})]}):o===`denied`?(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm text-muted-foreground`,children:[(0,J.jsx)(hn,{className:`w-3.5 h-3.5`}),(0,J.jsx)(`span`,{children:(0,J.jsx)(B,{id:`notification.push.denied`})})]}):(0,J.jsxs)(H,{variant:`outline`,size:`sm`,onClick:p,disabled:c,className:`gap-1.5`,children:[(0,J.jsx)(Ze,{className:`w-3.5 h-3.5`}),(0,J.jsx)(B,{id:`notification.push.enable`})]})})]}),(0,J.jsxs)(`div`,{className:`space-y-2`,children:[e&&(0,J.jsx)(`label`,{htmlFor:r,className:`text-sm font-medium leading-none`,children:`Task completion sound`}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsxs)(gc,{value:i.soundType,onValueChange:u,children:[(0,J.jsx)(vc,{id:r,className:`w-[180px]`,children:(0,J.jsx)(_c,{placeholder:`音を選択`})}),(0,J.jsx)(xc,{children:m.map(e=>(0,J.jsx)(X,{value:e,children:Zd(e)},e))})]}),i.soundType!==`none`&&(0,J.jsx)(H,{variant:`outline`,size:`sm`,onClick:d,className:`px-3`,children:(0,J.jsx)(B,{id:`notification.test`})})]}),t&&(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:(0,J.jsx)(B,{id:`notification.description`})})]})]})},wm=e=>e===`ctrl-k`||e===`command-k`,Tm=e=>e===`ctrl-f`||e===`command-f`,Em=({openingProjectId:e,showLabels:t=!0,showDescriptions:n=!0,className:r=``})=>{let[i,a]=(0,q.useState)(``),o=(0,q.useId)(),s=(0,q.useId)(),c=(0,q.useId)(),l=(0,q.useId)(),u=(0,q.useId)(),d=(0,q.useId)(),{config:f,updateConfig:p}=ge(),m=re(),{theme:h}=Vt(),{i18n:g}=Xe(),_=(0,q.useMemo)(()=>Il()??`en`,[]),v=()=>{p({...f,hideNoUserMessageSession:!f?.hideNoUserMessageSession},{onSuccess:async()=>{await m.refetchQueries({queryKey:y.queryKey})}})},b=()=>{p({...f,unifySameTitleSession:!f?.unifySameTitleSession},{onSuccess:async()=>{await m.refetchQueries({queryKey:ne(e).queryKey})}})},x=()=>{p({...f,autoScheduleContinueOnRateLimit:!f?.autoScheduleContinueOnRateLimit})},S=[`shift-enter-send`,`enter-send`,`command-enter-send`],C=e=>{let t=S.find(t=>t===e);t!==void 0&&p({...f,enterKeyBehavior:t})},w=e=>{wm(e)&&p({...f,searchHotkey:e})},T=e=>{Tm(e)&&p({...f,findHotkey:e})},E=()=>{let e=i.trim();e&&!f?.modelChoices?.includes(e)&&(p({...f,modelChoices:[...f?.modelChoices??[],e]}),a(``))},D=e=>{p({...f,modelChoices:(f?.modelChoices??[]).filter(t=>t!==e)})};return(0,J.jsxs)(`div`,{className:`space-y-4 ${r}`,children:[(0,J.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,J.jsx)(lt,{id:o,checked:f?.hideNoUserMessageSession,onCheckedChange:v}),t&&(0,J.jsx)(`label`,{htmlFor:o,className:`text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70`,children:(0,J.jsx)(B,{id:`settings.session.hide_no_user_message`})})]}),n&&(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1 ml-6`,children:(0,J.jsx)(B,{id:`settings.session.hide_no_user_message.description`})}),(0,J.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,J.jsx)(lt,{id:`${o}-unify`,checked:f?.unifySameTitleSession,onCheckedChange:b}),t&&(0,J.jsx)(`label`,{htmlFor:`${o}-unify`,className:`text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70`,children:(0,J.jsx)(B,{id:`settings.session.unify_same_title`})})]}),n&&(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1 ml-6`,children:(0,J.jsx)(B,{id:`settings.session.unify_same_title.description`})}),(0,J.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,J.jsx)(lt,{id:`${o}-auto-schedule-continue`,checked:f?.autoScheduleContinueOnRateLimit,onCheckedChange:x}),t&&(0,J.jsx)(`label`,{htmlFor:`${o}-auto-schedule-continue`,className:`text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70`,children:(0,J.jsx)(B,{id:`settings.session.auto_schedule_continue_on_rate_limit`})})]}),n&&(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1 ml-6`,children:(0,J.jsx)(B,{id:`settings.session.auto_schedule_continue_on_rate_limit.description`})}),(0,J.jsxs)(`div`,{className:`space-y-2`,children:[t&&(0,J.jsx)(`label`,{htmlFor:s,className:`text-sm font-medium leading-none`,children:(0,J.jsx)(B,{id:`settings.input.enter_key_behavior`})}),(0,J.jsxs)(gc,{value:f?.enterKeyBehavior||`shift-enter-send`,onValueChange:C,children:[(0,J.jsx)(vc,{id:s,className:`w-full`,children:(0,J.jsx)(_c,{placeholder:g._(`Select enter key behavior`)})}),(0,J.jsxs)(xc,{children:[(0,J.jsx)(X,{value:`shift-enter-send`,children:(0,J.jsx)(B,{id:`settings.input.enter_key_behavior.shift_enter`})}),(0,J.jsx)(X,{value:`enter-send`,children:(0,J.jsx)(B,{id:`settings.input.enter_key_behavior.enter`})}),(0,J.jsx)(X,{value:`command-enter-send`,children:(0,J.jsx)(B,{id:`settings.input.enter_key_behavior.command_enter`})})]})]}),n&&(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:(0,J.jsx)(B,{id:`settings.input.enter_key_behavior.description`})})]}),(0,J.jsxs)(`div`,{className:`space-y-2`,children:[t&&(0,J.jsx)(`label`,{htmlFor:c,className:`text-sm font-medium leading-none`,children:(0,J.jsx)(B,{id:`settings.input.search_hotkey`})}),(0,J.jsxs)(gc,{value:f?.searchHotkey||`command-k`,onValueChange:w,children:[(0,J.jsx)(vc,{id:c,className:`w-full`,children:(0,J.jsx)(_c,{placeholder:g._(`Select search hotkey`)})}),(0,J.jsxs)(xc,{children:[(0,J.jsx)(X,{value:`ctrl-k`,children:(0,J.jsx)(B,{id:`settings.input.search_hotkey.ctrl_k`})}),(0,J.jsx)(X,{value:`command-k`,children:(0,J.jsx)(B,{id:`settings.input.search_hotkey.command_k`})})]})]}),n&&(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:(0,J.jsx)(B,{id:`settings.input.search_hotkey.description`})})]}),(0,J.jsxs)(`div`,{className:`space-y-2`,children:[t&&(0,J.jsx)(`label`,{htmlFor:l,className:`text-sm font-medium leading-none`,children:(0,J.jsx)(B,{id:`settings.input.find_hotkey`})}),(0,J.jsxs)(gc,{value:f?.findHotkey||`command-f`,onValueChange:T,children:[(0,J.jsx)(vc,{id:l,className:`w-full`,children:(0,J.jsx)(_c,{placeholder:g._(`Select find hotkey`)})}),(0,J.jsxs)(xc,{children:[(0,J.jsx)(X,{value:`ctrl-f`,children:(0,J.jsx)(B,{id:`settings.input.find_hotkey.ctrl_f`})}),(0,J.jsx)(X,{value:`command-f`,children:(0,J.jsx)(B,{id:`settings.input.find_hotkey.command_f`})})]})]}),n&&(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:(0,J.jsx)(B,{id:`settings.input.find_hotkey.description`})})]}),(0,J.jsxs)(`div`,{className:`space-y-2`,children:[t&&(0,J.jsx)(`span`,{className:`text-sm font-medium leading-none block`,children:(0,J.jsx)(B,{id:`settings.model_choices.label`,message:`Model Choices`})}),(0,J.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:(f?.modelChoices??[]).map(e=>(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-2 py-0.5 bg-primary/10 text-primary rounded text-xs`,children:[e,(0,J.jsx)(`button`,{type:`button`,onClick:()=>D(e),className:`hover:bg-primary/20 rounded-full p-0.5`,children:(0,J.jsx)(Ce,{className:`w-3 h-3`})})]},e))}),(0,J.jsxs)(`div`,{className:`flex gap-2`,children:[(0,J.jsx)(At,{value:i,onChange:e=>a(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),E())},placeholder:g._({id:`settings.model_choices.placeholder`,message:`Add model choice...`}),className:`h-8 text-xs flex-1`}),(0,J.jsx)(H,{type:`button`,variant:`outline`,size:`sm`,onClick:E,disabled:!i.trim(),className:`h-8 text-xs`,children:(0,J.jsx)(gt,{className:`w-3 h-3`})})]}),n&&(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:(0,J.jsx)(B,{id:`settings.model_choices.description`,message:`Configure the model options available in the session toolbar`})})]}),(0,J.jsxs)(`div`,{className:`space-y-2`,children:[t&&(0,J.jsx)(`label`,{htmlFor:u,className:`text-sm font-medium leading-none`,children:(0,J.jsx)(B,{id:`settings.locale`})}),(0,J.jsxs)(gc,{value:f?.locale||_,onValueChange:e=>{p({...f,locale:e})},children:[(0,J.jsx)(vc,{id:u,className:`w-full`,children:(0,J.jsx)(_c,{placeholder:g._(`Select language`)})}),(0,J.jsxs)(xc,{children:[(0,J.jsx)(X,{value:`ja`,children:(0,J.jsx)(B,{id:`settings.locale.ja`})}),(0,J.jsx)(X,{value:`en`,children:(0,J.jsx)(B,{id:`settings.locale.en`})}),(0,J.jsx)(X,{value:`zh_CN`,children:(0,J.jsx)(B,{id:`settings.locale.zh_CN`})})]})]}),n&&(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:(0,J.jsx)(B,{id:`settings.locale.description`})})]}),(0,J.jsxs)(`div`,{className:`space-y-2`,children:[t&&(0,J.jsx)(`label`,{htmlFor:d,className:`text-sm font-medium leading-none`,children:(0,J.jsx)(B,{id:`settings.theme`})}),(0,J.jsxs)(gc,{value:h??`system`,onValueChange:e=>{p({...f,theme:e})},children:[(0,J.jsx)(vc,{id:d,className:`w-full`,children:(0,J.jsx)(_c,{placeholder:g._(`Select theme`)})}),(0,J.jsxs)(xc,{children:[(0,J.jsx)(X,{value:`light`,children:(0,J.jsx)(B,{id:`settings.theme.light`})}),(0,J.jsx)(X,{value:`dark`,children:(0,J.jsx)(B,{id:`settings.theme.dark`})}),(0,J.jsx)(X,{value:`system`,children:(0,J.jsx)(B,{id:`settings.theme.system`})})]})]}),n&&(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:(0,J.jsx)(B,{id:`settings.theme.description`})})]})]})},Dm=e=>{switch(e){case`tool-approval`:return{title:(0,J.jsx)(B,{id:`system_info.feature.tool_approval.title`}),description:(0,J.jsx)(B,{id:`system_info.feature.tool_approval.description`})};case`agent-sdk`:return{title:(0,J.jsx)(B,{id:`system_info.feature.agent_sdk.title`}),description:(0,J.jsx)(B,{id:`system_info.feature.agent_sdk.description`})};case`sidechain-separation`:return{title:(0,J.jsx)(B,{id:`system_info.feature.sidechain_separation.title`}),description:(0,J.jsx)(B,{id:`system_info.feature.sidechain_separation.description`})};case`uuid-on-sdk-message`:return{title:(0,J.jsx)(B,{id:`system_info.feature.uuid_on_sdk_message.title`}),description:(0,J.jsx)(B,{id:`system_info.feature.uuid_on_sdk_message.description`})};case`run-skills-directly`:return{title:(0,J.jsx)(B,{id:`system_info.feature.run_skills_directly.title`}),description:(0,J.jsx)(B,{id:`system_info.feature.run_skills_directly.description`})};default:return{title:e,description:(0,J.jsx)(B,{id:`system_info.feature.unknown.description`})}}},Om=()=>{let[e,t]=(0,q.useState)(!1),{data:n}=s({...te}),{data:r}=s({...v}),{flags:i}=of();return(0,J.jsxs)(`div`,{className:`h-full flex flex-col`,children:[(0,J.jsxs)(`div`,{className:`border-b border-sidebar-border p-4`,children:[(0,J.jsx)(`h2`,{className:`font-semibold text-lg`,children:(0,J.jsx)(B,{id:`system_info.title`})}),(0,J.jsx)(`p`,{className:`text-xs text-sidebar-foreground/70`,children:(0,J.jsx)(B,{id:`system_info.description`})})]}),(0,J.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4 space-y-6`,children:[(0,J.jsxs)(`div`,{className:`space-y-3`,children:[(0,J.jsx)(`h3`,{className:`font-medium text-sm text-sidebar-foreground`,children:(0,J.jsx)(B,{id:`system_info.viewer_version`})}),(0,J.jsxs)(`div`,{className:`flex justify-between items-center pl-2`,children:[(0,J.jsx)(`span`,{className:`text-xs text-sidebar-foreground/70`,children:(0,J.jsx)(B,{id:`system_info.version_label`})}),(0,J.jsxs)(Y,{variant:`secondary`,className:`text-xs font-mono`,children:[`v`,n?.version||`Unknown`]})]})]}),(0,J.jsxs)(`div`,{className:`space-y-3`,children:[(0,J.jsx)(`h3`,{className:`font-medium text-sm text-sidebar-foreground`,children:(0,J.jsx)(B,{id:`system_info.claude_code`})}),(0,J.jsxs)(`div`,{className:`space-y-2 pl-2`,children:[(0,J.jsxs)(`div`,{className:`space-y-1`,children:[(0,J.jsx)(`div`,{className:`text-xs text-sidebar-foreground/70`,children:(0,J.jsx)(B,{id:`system_info.executable_path`})}),(0,J.jsx)(`div`,{className:`text-xs text-sidebar-foreground font-mono break-all`,children:r?.executablePath||(0,J.jsx)(`span`,{className:`text-sidebar-foreground/50`,children:(0,J.jsx)(B,{id:`system_info.unknown`})})})]}),(0,J.jsxs)(`div`,{className:`flex justify-between items-center pt-1`,children:[(0,J.jsx)(`span`,{className:`text-xs text-sidebar-foreground/70`,children:(0,J.jsx)(B,{id:`system_info.version_label`})}),(0,J.jsx)(Y,{variant:`secondary`,className:`text-xs font-mono`,children:r?.version??(0,J.jsx)(B,{id:`system_info.unknown`})})]})]})]}),(0,J.jsx)(`div`,{className:`space-y-3`,children:(0,J.jsxs)(lc,{open:e,onOpenChange:t,children:[(0,J.jsxs)(uc,{className:`flex w-full items-center justify-between group`,children:[(0,J.jsx)(`h3`,{className:`font-medium text-sm text-sidebar-foreground`,children:(0,J.jsx)(B,{id:`system_info.available_features`})}),e?(0,J.jsx)(K,{className:`h-4 w-4 text-sidebar-foreground/70 group-hover:text-sidebar-foreground transition-colors`}):(0,J.jsx)(et,{className:`h-4 w-4 text-sidebar-foreground/70 group-hover:text-sidebar-foreground transition-colors`})]}),(0,J.jsx)(dc,{className:`pt-3`,children:(0,J.jsx)(st,{children:(0,J.jsx)(`ul`,{className:`space-y-2 pl-2`,children:i.map(({name:e,enabled:t})=>{let n=Dm(e);return(0,J.jsxs)(`li`,{className:`flex items-start gap-2`,children:[t?(0,J.jsx)(wn,{className:`h-3.5 w-3.5 text-green-500 dark:text-green-400 mt-0.5 flex-shrink-0`}):(0,J.jsx)(Dn,{className:`h-3.5 w-3.5 text-sidebar-foreground/30 mt-0.5 flex-shrink-0`}),(0,J.jsxs)(pt,{children:[(0,J.jsx)(ht,{asChild:!0,children:(0,J.jsx)(`span`,{className:t?`text-xs text-sidebar-foreground cursor-help`:`text-xs text-sidebar-foreground/50 line-through cursor-help`,children:n.title})}),(0,J.jsx)(tt,{side:`right`,className:`max-w-xs text-xs`,children:n.description})]})]},e)})})})})]})})]})]})},km=({projectId:e})=>{let t=re(),{i18n:n}=Xe(),{data:r,isLoading:i,error:a,isFetching:o}=we({queryKey:S(e).queryKey,queryFn:S(e).queryFn,refetchOnMount:!1,refetchOnWindowFocus:!1,refetchOnReconnect:!1,refetchInterval:!1});return(0,J.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,J.jsx)(`div`,{className:`p-3 border-b border-sidebar-border`,children:(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold text-sidebar-foreground`,children:(0,J.jsx)(B,{id:`mcp.title`})}),(0,J.jsx)(H,{onClick:()=>{t.invalidateQueries({queryKey:S(e).queryKey})},variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,disabled:i||o,title:n._(`Reload MCP servers`),children:(0,J.jsx)(Rt,{className:`w-3 h-3 ${i||o?`animate-spin`:``}`})})]})}),(0,J.jsxs)(`div`,{className:`flex-1 overflow-auto p-3`,children:[i&&(0,J.jsx)(`div`,{className:`flex items-center justify-center h-32`,children:(0,J.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:(0,J.jsx)(fd,{})})}),a&&(0,J.jsx)(`div`,{className:`text-sm text-red-500`,children:(0,J.jsx)(B,{id:`mcp.error.load_failed`,values:{error:a.message}})}),r&&r.servers.length===0&&(0,J.jsx)(`div`,{className:`text-sm text-muted-foreground text-center py-8`,children:(0,J.jsx)(B,{id:`mcp.no.servers`})}),r&&r.servers.length>0&&(0,J.jsx)(`div`,{className:`space-y-3`,children:r.servers.map(e=>(0,J.jsx)(`div`,{className:`p-3 bg-sidebar-accent/50 rounded-md border ${e.status===`failed`?`border-red-500/50 bg-red-500/10`:`border-sidebar-border`}`,children:(0,J.jsx)(`div`,{className:`flex items-start justify-between`,children:(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.status===`connected`&&(0,J.jsx)(wn,{className:`w-4 h-4 text-green-500 flex-shrink-0`}),e.status===`failed`&&(0,J.jsx)(Dn,{className:`w-4 h-4 text-red-500 flex-shrink-0`}),e.status===`unknown`&&(0,J.jsx)(En,{className:`w-4 h-4 text-muted-foreground flex-shrink-0`}),(0,J.jsx)(`h3`,{className:`text-sm font-medium text-sidebar-foreground truncate`,children:e.name})]}),(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1 font-mono break-all pl-6`,children:e.command})]})})},e.name))})]})]})},Am=[{value:0,labelKey:(0,J.jsx)(B,{id:`cron_builder.sunday`})},{value:1,labelKey:(0,J.jsx)(B,{id:`cron_builder.monday`})},{value:2,labelKey:(0,J.jsx)(B,{id:`cron_builder.tuesday`})},{value:3,labelKey:(0,J.jsx)(B,{id:`cron_builder.wednesday`})},{value:4,labelKey:(0,J.jsx)(B,{id:`cron_builder.thursday`})},{value:5,labelKey:(0,J.jsx)(B,{id:`cron_builder.friday`})},{value:6,labelKey:(0,J.jsx)(B,{id:`cron_builder.saturday`})}],jm=e=>{let t=e.trim().split(/\s+/);if(t.length!==5)return null;let n=t[0],r=t[1],i=t[4];if(n===void 0||n===``||r===void 0||r===``||i===void 0||i===``)return null;if(r===`*`&&n===`0`)return{mode:`hourly`,hour:0,minute:0,dayOfWeek:0};if(i===`*`&&r!==`*`){let e=Number.parseInt(r,10),t=Number.parseInt(n,10);if(!Number.isNaN(e)&&!Number.isNaN(t))return{mode:`daily`,hour:e,minute:t,dayOfWeek:0}}if(i!==`*`&&r!==`*`){let e=Number.parseInt(r,10),t=Number.parseInt(n,10),a=Number.parseInt(i,10);if(!Number.isNaN(e)&&!Number.isNaN(t)&&!Number.isNaN(a))return{mode:`weekly`,hour:e,minute:t,dayOfWeek:a}}return{mode:`custom`,hour:0,minute:0,dayOfWeek:0}},Mm=(e,t,n,r)=>{switch(e){case`hourly`:return`0 * * * *`;case`daily`:return`${n} ${t} * * *`;case`weekly`:return`${n} ${t} * * ${r}`;case`custom`:return`0 0 * * *`;default:return`0 0 * * *`}},Nm=e=>{let t=e.trim().split(/\s+/);if(t.length!==5)return!1;let n=t[0],r=t[1],i=t[2],a=t[3],o=t[4];if(n===void 0||n===``||r===void 0||r===``||i===void 0||i===``||a===void 0||a===``||o===void 0||o===``)return!1;let s=(e,t,n)=>{if(e===`*`)return!0;let r=Number.parseInt(e,10);return!Number.isNaN(r)&&r>=t&&r<=n};return s(n,0,59)&&(r===`*`||s(r,0,23))&&(i===`*`||s(i,1,31))&&(a===`*`||s(a,1,12))&&(o===`*`||s(o,0,6))},Pm=e=>{let t=e.trim().split(/\s+/);if(t.length!==5)return`Invalid cron expression`;let n=t[0],r=t[1],i=t[4];if(n===void 0||n===``||r===void 0||r===``||i===void 0||i===``)return`Invalid cron expression`;if(r===`*`)return`Every hour at ${n} minute(s)`;let a=`${r.padStart(2,`0`)}:${n.padStart(2,`0`)}`;if(i===`*`)return`Every day at ${a}`;let o=Number.parseInt(i,10),s=Am.find(e=>e.value===o);return(0,J.jsxs)(J.Fragment,{children:[`Every `,s?s.labelKey:`unknown`,` at `,a]})},Fm=({value:e,onChange:t})=>{let n=jm(e),[r,i]=(0,q.useState)(n?.mode??`daily`),[a,o]=(0,q.useState)(n?.hour??9),[s,c]=(0,q.useState)(n?.minute??0),[l,u]=(0,q.useState)(n?.dayOfWeek??1),[d,f]=(0,q.useState)(e),[p,m]=(0,q.useState)(null);return(0,q.useEffect)(()=>{if(r===`custom`)Nm(d)?(t(d),m(null)):m(`Invalid cron expression`);else{let e=Mm(r,a,s,l);t(e),f(e),m(null)}},[r,a,s,l,d,t]),(0,J.jsxs)(`div`,{className:`space-y-4`,children:[(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(W,{children:(0,J.jsx)(B,{id:`cron_builder.schedule_type`})}),(0,J.jsxs)(gc,{value:r,onValueChange:e=>{i(e),e!==`custom`&&f(Mm(e,a,s,l))},children:[(0,J.jsx)(vc,{children:(0,J.jsx)(_c,{})}),(0,J.jsxs)(xc,{children:[(0,J.jsx)(X,{value:`hourly`,children:(0,J.jsx)(B,{id:`cron_builder.hourly`})}),(0,J.jsx)(X,{value:`daily`,children:(0,J.jsx)(B,{id:`cron_builder.daily`})}),(0,J.jsx)(X,{value:`weekly`,children:(0,J.jsx)(B,{id:`cron_builder.weekly`})}),(0,J.jsx)(X,{value:`custom`,children:(0,J.jsx)(B,{id:`cron_builder.custom`})})]})]})]}),r===`daily`&&(0,J.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(W,{children:(0,J.jsx)(B,{id:`cron_builder.hour`})}),(0,J.jsx)(At,{type:`number`,min:`0`,max:`23`,value:a,onChange:e=>o(Number.parseInt(e.target.value,10))})]}),(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(W,{children:(0,J.jsx)(B,{id:`cron_builder.minute`})}),(0,J.jsx)(At,{type:`number`,min:`0`,max:`59`,value:s,onChange:e=>c(Number.parseInt(e.target.value,10))})]})]}),r===`weekly`&&(0,J.jsxs)(`div`,{className:`space-y-4`,children:[(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(W,{children:(0,J.jsx)(B,{id:`cron_builder.day_of_week`})}),(0,J.jsxs)(gc,{value:String(l),onValueChange:e=>u(Number.parseInt(e,10)),children:[(0,J.jsx)(vc,{children:(0,J.jsx)(_c,{})}),(0,J.jsx)(xc,{children:Am.map(e=>(0,J.jsx)(X,{value:String(e.value),children:e.labelKey},e.value))})]})]}),(0,J.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(W,{children:(0,J.jsx)(B,{id:`cron_builder.hour`})}),(0,J.jsx)(At,{type:`number`,min:`0`,max:`23`,value:a,onChange:e=>o(Number.parseInt(e.target.value,10))})]}),(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(W,{children:(0,J.jsx)(B,{id:`cron_builder.minute`})}),(0,J.jsx)(At,{type:`number`,min:`0`,max:`59`,value:s,onChange:e=>c(Number.parseInt(e.target.value,10))})]})]})]}),r===`custom`&&(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(W,{children:(0,J.jsx)(B,{id:`cron_builder.cron_expression`})}),(0,J.jsx)(At,{value:d,onChange:e=>f(e.target.value),placeholder:`0 9 * * *`})]}),(0,J.jsxs)(`div`,{className:`rounded-md border p-3 text-sm`,children:[(0,J.jsx)(`div`,{className:`font-medium mb-1`,children:(0,J.jsx)(B,{id:`cron_builder.preview`})}),(0,J.jsx)(`div`,{className:`text-muted-foreground`,children:p===null?Pm(r===`custom`?d:e):(0,J.jsx)(`span`,{className:`text-destructive`,children:p})}),(0,J.jsxs)(`div`,{className:`text-xs text-muted-foreground mt-2`,children:[(0,J.jsx)(B,{id:`cron_builder.expression`}),`:`,` `,(0,J.jsx)(`code`,{children:r===`custom`?d:e})]})]})]})},Im=({open:e,onOpenChange:t,job:n,projectId:r,onSubmit:i,isSubmitting:a=!1})=>{let{_:o,i18n:s}=Xe(),[c,l]=(0,q.useState)(``),[u,d]=(0,q.useState)(`cron`),[f,p]=(0,q.useState)(`0 9 * * *`),[m,h]=(0,q.useState)(()=>{let e=new Date;return e.setHours(e.getHours()+1),e.toISOString().slice(0,16)}),[g,_]=(0,q.useState)(``),[v,y]=(0,q.useState)(!0),[b,x]=(0,q.useState)(`skip`),S=dm();(0,q.useEffect)(()=>{if(n){if(l(n.name),d(n.schedule.type),n.schedule.type===`cron`)p(n.schedule.expression),x(n.schedule.concurrencyPolicy);else if(n.schedule.type===`reserved`){let e=new Date(n.schedule.reservedExecutionTime);h(`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}T${String(e.getHours()).padStart(2,`0`)}:${String(e.getMinutes()).padStart(2,`0`)}`)}_(n.message.content),y(n.enabled)}else{l(``),d(`cron`),p(`0 9 * * *`);let e=new Date;e.setHours(e.getHours()+1),h(`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}T${String(e.getHours()).padStart(2,`0`)}:${String(e.getMinutes()).padStart(2,`0`)}`),_(``),y(!0),x(`skip`)}},[n]);let C=()=>{i({name:c,schedule:u===`cron`?{type:`cron`,expression:f,concurrencyPolicy:b}:{type:`reserved`,reservedExecutionTime:(()=>{let e=m.match(/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})$/);if(!e)throw Error(`Invalid datetime format`);let t=Number(e[1]),n=Number(e[2]),r=Number(e[3]),i=Number(e[4]),a=Number(e[5]);return new Date(t,n-1,r,i,a).toISOString()})()},message:{content:g,projectId:r,sessionId:crypto.randomUUID(),resume:!1},enabled:v})},w=c.trim()!==``&&g.trim()!==``;return(0,J.jsx)(Be,{open:e,onOpenChange:t,children:(0,J.jsxs)(Ue,{className:`max-w-2xl max-h-[90vh] overflow-y-auto`,children:[(0,J.jsxs)(We,{children:[(0,J.jsx)(Ae,{children:n?(0,J.jsx)(B,{id:`scheduler.dialog.title.edit`}):(0,J.jsx)(B,{id:`scheduler.dialog.title.create`})}),(0,J.jsx)(ke,{children:(0,J.jsx)(B,{id:`scheduler.dialog.description`})})]}),(0,J.jsxs)(`div`,{className:`space-y-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between rounded-lg border p-4`,children:[(0,J.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,J.jsx)(W,{htmlFor:`enabled`,className:`text-base font-semibold`,children:(0,J.jsx)(B,{id:`scheduler.form.enabled`})}),(0,J.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:(0,J.jsx)(B,{id:`scheduler.form.enabled.description`})})]}),(0,J.jsx)(Hp,{id:`enabled`,checked:v,onCheckedChange:y,disabled:a})]}),(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(W,{htmlFor:`job-name`,children:(0,J.jsx)(B,{id:`scheduler.form.name`})}),(0,J.jsx)(At,{id:`job-name`,value:c,onChange:e=>l(e.target.value),placeholder:o({id:`scheduler.form.name.placeholder`,message:`e.g., Daily Report`}),disabled:a})]}),(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(W,{children:(0,J.jsx)(B,{id:`scheduler.form.schedule_type`})}),(0,J.jsxs)(gc,{value:u,onValueChange:e=>d(e),disabled:a,children:[(0,J.jsx)(vc,{children:(0,J.jsx)(_c,{})}),(0,J.jsxs)(xc,{children:[(0,J.jsx)(X,{value:`cron`,children:(0,J.jsx)(B,{id:`scheduler.form.schedule_type.cron`})}),(0,J.jsx)(X,{value:`reserved`,children:(0,J.jsx)(B,{id:`scheduler.form.schedule_type.reserved`})})]})]})]}),u===`cron`?(0,J.jsx)(Fm,{value:f,onChange:p}):(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(W,{htmlFor:`reserved-datetime`,children:(0,J.jsx)(B,{id:`scheduler.form.reserved_time`})}),(0,J.jsx)(At,{id:`reserved-datetime`,type:`datetime-local`,value:m,onChange:e=>h(e.target.value),disabled:a}),(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:(0,J.jsx)(B,{id:`scheduler.form.reserved_time.hint`})})]}),(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(W,{htmlFor:`message-content`,children:(0,J.jsx)(B,{id:`scheduler.form.message`})}),(0,J.jsxs)(`div`,{className:`relative`,ref:S.containerRef,children:[(0,J.jsx)(Zc,{ref:S.textareaRef,id:`message-content`,value:g,onChange:e=>S.handleChange(e.target.value,_),onKeyDown:e=>S.handleKeyDown(e),placeholder:s._({id:`scheduler.form.message.placeholder`,message:`Type message to send to Claude Code... (/ for commands, @ for files)`}),rows:4,disabled:a,className:`resize-none`,"aria-label":s._({id:`scheduler.form.message.aria_label`,message:`Message input with completion support (/ for commands, @ for files)`}),"aria-expanded":g.startsWith(`/`)||g.includes(`@`)}),(0,J.jsx)(sm,{projectId:r,message:g,commandCompletionRef:S.commandCompletionRef,fileCompletionRef:S.fileCompletionRef,handleCommandSelect:e=>S.handleCommandSelect(e,_),handleFileSelect:e=>S.handleFileSelect(e,_),cursorPosition:S.cursorPosition})]}),(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:(0,J.jsx)(B,{id:`scheduler.form.message.hint`})})]}),u===`cron`&&(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(W,{children:(0,J.jsx)(B,{id:`scheduler.form.concurrency_policy`})}),(0,J.jsxs)(gc,{value:b,onValueChange:e=>x(e),disabled:a,children:[(0,J.jsx)(vc,{children:(0,J.jsx)(_c,{})}),(0,J.jsxs)(xc,{children:[(0,J.jsx)(X,{value:`skip`,children:(0,J.jsx)(B,{id:`scheduler.form.concurrency_policy.skip`})}),(0,J.jsx)(X,{value:`run`,children:(0,J.jsx)(B,{id:`scheduler.form.concurrency_policy.run`})})]})]})]})]}),(0,J.jsxs)(Re,{children:[(0,J.jsx)(H,{variant:`outline`,onClick:()=>t(!1),disabled:a,children:(0,J.jsx)(B,{id:`common.cancel`})}),(0,J.jsx)(H,{onClick:C,disabled:!w||a,children:a?(0,J.jsx)(B,{id:`common.saving`}):n?(0,J.jsx)(B,{id:`common.update`}):(0,J.jsx)(B,{id:`common.create`})})]})]})})},Lm=({projectId:e,sessionId:t})=>{let{i18n:n}=Xe(),{data:r,isLoading:i,isFetching:a,error:o,refetch:s}=Ud(),c=Wd(),l=Gd(),u=Kd(),[d,f]=(0,q.useState)(!1),[p,m]=(0,q.useState)(null),[h,g]=(0,q.useState)(!1),[_,v]=(0,q.useState)(null),y=e=>{c.mutate(e,{onSuccess:()=>{z.success(n._({id:`scheduler.job.created`,message:`Job created successfully`})),f(!1)},onError:e=>{z.error(n._({id:`scheduler.job.create_failed`,message:`Failed to create job`}),{description:e.message})}})},b=e=>{p&&l.mutate({id:p.id,updates:e},{onSuccess:()=>{z.success(n._({id:`scheduler.job.updated`,message:`Job updated successfully`})),f(!1),m(null)},onError:e=>{z.error(n._({id:`scheduler.job.update_failed`,message:`Failed to update job`}),{description:e.message})}})},x=()=>{_===null||_===``||u.mutate(_,{onSuccess:()=>{z.success(n._({id:`scheduler.job.deleted`,message:`Job deleted successfully`})),g(!1),v(null)},onError:e=>{z.error(n._({id:`scheduler.job.delete_failed`,message:`Failed to delete job`}),{description:e.message})}})},S=e=>{m(e),f(!0)},C=e=>{v(e),g(!0)},w=e=>e.schedule.type===`cron`?`Cron: ${e.schedule.expression}`:e.schedule.type===`reserved`?`Reserved: ${new Date(e.schedule.reservedExecutionTime).toLocaleString()}`:`Unknown schedule type`,T=e=>e===null||e===``?`Never`:new Date(e).toLocaleString();return(0,J.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,J.jsx)(`div`,{className:`p-3 border-b border-sidebar-border`,children:(0,J.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold text-sidebar-foreground`,children:(0,J.jsx)(B,{id:`scheduler.title`})}),(0,J.jsxs)(`div`,{className:`flex gap-1`,children:[(0,J.jsx)(H,{onClick:()=>{s()},variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,disabled:i||a,title:n._({id:`common.reload`,message:`Reload`}),children:(0,J.jsx)(Rt,{className:`w-3 h-3 ${i||a?`animate-spin`:``}`})}),(0,J.jsx)(H,{onClick:()=>{m(null),f(!0)},variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,title:n._({id:`scheduler.create_job`,message:`Create Job`}),children:(0,J.jsx)(gt,{className:`w-3 h-3`})})]})]})}),(0,J.jsxs)(`div`,{className:`flex-1 overflow-auto p-3`,children:[i&&(0,J.jsx)(`div`,{className:`flex items-center justify-center h-32`,children:(0,J.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:(0,J.jsx)(fd,{})})}),o&&(0,J.jsx)(`div`,{className:`text-sm text-red-500`,children:(0,J.jsx)(B,{id:`scheduler.error.load_failed`,values:{error:o.message}})}),r&&r.length===0&&(0,J.jsx)(`div`,{className:`text-sm text-muted-foreground text-center py-8`,children:(0,J.jsx)(B,{id:`scheduler.no_jobs`})}),r&&r.length>0&&(0,J.jsx)(`div`,{className:`space-y-3`,children:r.map(e=>(0,J.jsxs)(`div`,{className:`p-3 bg-sidebar-accent/50 rounded-md border border-sidebar-border`,children:[(0,J.jsxs)(`div`,{className:`flex items-start justify-between mb-2`,children:[(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`h3`,{className:`text-sm font-medium text-sidebar-foreground truncate`,children:e.name}),(0,J.jsx)(Y,{variant:e.enabled?`default`:`secondary`,className:`text-xs`,children:e.enabled?(0,J.jsx)(B,{id:`scheduler.status.enabled`}):(0,J.jsx)(B,{id:`scheduler.status.disabled`})})]}),(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:w(e)})]}),(0,J.jsxs)(`div`,{className:`flex gap-1`,children:[(0,J.jsx)(H,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0`,onClick:()=>S(e),children:(0,J.jsx)(gr,{className:`w-3 h-3`})}),(0,J.jsx)(H,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 text-destructive hover:text-destructive`,onClick:()=>C(e.id),children:(0,J.jsx)(yr,{className:`w-3 h-3`})})]})]}),e.lastRunAt!==null&&e.lastRunAt!==``&&(0,J.jsx)(`div`,{className:`text-xs text-muted-foreground mt-2 pt-2 border-t border-sidebar-border`,children:(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsxs)(`span`,{children:[(0,J.jsx)(B,{id:`scheduler.last_run`}),(0,J.jsx)(`span`,{children:T(e.lastRunAt)})]}),e.lastRunStatus&&(0,J.jsx)(Y,{variant:e.lastRunStatus===`success`?`default`:`destructive`,className:`text-xs`,children:e.lastRunStatus})]})})]},e.id))})]}),(0,J.jsx)(Im,{open:d,onOpenChange:e=>{f(e),e||m(null)},job:p,projectId:e,currentSessionId:t,onSubmit:p?b:y,isSubmitting:c.isPending||l.isPending}),(0,J.jsx)(Be,{open:h,onOpenChange:g,children:(0,J.jsxs)(Ue,{children:[(0,J.jsxs)(We,{children:[(0,J.jsx)(Ae,{children:(0,J.jsx)(B,{id:`scheduler.delete_dialog.title`})}),(0,J.jsx)(ke,{children:(0,J.jsx)(B,{id:`scheduler.delete_dialog.description`})})]}),(0,J.jsxs)(Re,{children:[(0,J.jsx)(H,{variant:`outline`,onClick:()=>{g(!1),v(null)},disabled:u.isPending,children:(0,J.jsx)(B,{id:`common.cancel`})}),(0,J.jsx)(H,{variant:`destructive`,onClick:x,disabled:u.isPending,children:u.isPending?(0,J.jsx)(B,{id:`common.deleting`}):(0,J.jsx)(B,{id:`common.delete`})})]})]})})]})},Rm=({currentSessionId:e,projectId:t,onSessionSelect:n})=>{let{data:r,fetchNextPage:i,hasNextPage:a,isFetchingNextPage:o}=xd(t),s=T(It),c=T(uu),l=(0,q.useMemo)(()=>{let e=r.pages.flatMap(e=>e.sessions),n=wd(c,t,new Set(e.map(e=>e.id)));return[...e,...n]},[r.pages,t,c]);(0,q.useEffect)(()=>{let e=new Set(r.pages.flatMap(e=>e.sessions).map(e=>e.id));for(let n of c.values())n.projectId===t&&e.has(n.sessionId)&&mu(n.sessionId)},[r.pages,t,c]);let{config:u}=ge(),d=(0,q.useRef)(null);(0,q.useEffect)(()=>{d.current?.scrollIntoView({block:`nearest`,behavior:`smooth`})},[e]);let f=`sessions`,p=e===``,m=(0,q.useMemo)(()=>{let e=e=>e===`running`?0:e===`paused`?1:2;return[...l].sort((t,n)=>{let r=s.find(e=>e.sessionId===t.id)?.status,i=s.find(e=>e.sessionId===n.id)?.status,a=e(r),o=e(i);if(a!==o)return a-o;let c=t.lastModifiedAt?new Date(t.lastModifiedAt).getTime():0;return(n.lastModifiedAt?new Date(n.lastModifiedAt).getTime():0)-c})},[l,s]);return(0,J.jsxs)(`div`,{className:`h-full flex flex-col`,children:[(0,J.jsxs)(`div`,{className:`border-b border-sidebar-border p-4`,children:[(0,J.jsx)(`div`,{className:`flex items-center justify-between mb-2`,children:(0,J.jsx)(`h2`,{className:`font-semibold text-lg`,children:(0,J.jsx)(B,{id:`sessions.title`})})}),(0,J.jsxs)(`p`,{className:`text-xs text-sidebar-foreground/70`,children:[l.length,` `,(0,J.jsx)(B,{id:`sessions.total`})]})]}),(0,J.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-2 space-y-0.5`,children:[(0,J.jsx)(ie,{to:`/projects/$projectId/session`,params:{projectId:t},search:{tab:f},onClick:n,className:U(`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`,p&&`bg-blue-100 dark:bg-blue-900/40 border-blue-400 dark:border-blue-500 shadow-sm`),children:(0,J.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,J.jsx)(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-full bg-primary/10 text-primary`,children:(0,J.jsx)(gt,{className:`w-4 h-4`})}),(0,J.jsx)(`div`,{className:`space-y-0.5`,children:(0,J.jsx)(`p`,{className:`text-sm font-semibold text-sidebar-foreground`,children:(0,J.jsx)(B,{id:`chat.modal.title`})})})]})}),m.map(r=>{let i=r.id===e,a=tf(r.meta.customTitle,r.meta.firstUserMessage,r.id),o=s.find(e=>e.sessionId===r.id),c=o?.status===`running`,l=o?.status===`paused`;return(0,J.jsx)(ie,{ref:i?d:void 0,to:`/projects/$projectId/session`,params:{projectId:t},search:{tab:f,sessionId:r.id},onClick:n,className:U(`group relative 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`,i&&`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:(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsxs)(`div`,{className:`flex items-start justify-between gap-2 pr-6`,children:[(0,J.jsx)(`h3`,{className:`text-sm font-medium line-clamp-2 leading-tight text-sidebar-foreground flex-1`,children:a}),(c||l)&&(0,J.jsx)(Y,{variant:c?`default`:`secondary`,className:U(`text-xs shrink-0`,c&&`bg-green-500 text-white`,l&&`bg-yellow-500 text-white`),children:c?(0,J.jsx)(B,{id:`session.status.running`}):(0,J.jsx)(B,{id:`session.status.paused`})})]}),(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,J.jsx)(`div`,{className:`flex items-center gap-2 text-xs text-sidebar-foreground/70 min-w-0`,children:(0,J.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,J.jsx)(_e,{className:`w-3 h-3`}),(0,J.jsx)(`span`,{children:r.meta.messageCount})]})}),r.lastModifiedAt&&(0,J.jsx)(`span`,{className:`text-xs text-sidebar-foreground/60 shrink-0`,children:he(r.lastModifiedAt,{locale:u.locale,target:`time`})})]})]})},r.id)}),a===!0&&(0,J.jsx)(`div`,{className:`p-2`,children:(0,J.jsx)(H,{onClick:()=>{i()},disabled:o,variant:`outline`,size:`sm`,className:`w-full`,children:o?(0,J.jsx)(B,{id:`common.loading`}):(0,J.jsx)(B,{id:`sessions.load.more`})})})]})]})},zm=async(e,t)=>(await o.api.tasks.$get({query:{projectId:e,sessionId:t}})).json(),Bm=async(e,t,n)=>(await o.api.tasks.$post({query:{projectId:e,sessionId:n},json:t})).json(),Vm=async(e,t,n,r)=>(await o.api.tasks[`:taskId`].$patch({param:{taskId:t},query:{projectId:e,sessionId:r},json:n})).json(),Hm=({status:e,onClick:t})=>(0,J.jsxs)(`button`,{type:`button`,onClick:t,className:U(`flex items-center justify-center w-6 h-6 rounded-md shrink-0 transition-all duration-200`,`hover:scale-110 active:scale-95`,e===`completed`&&`bg-green-500/20 text-green-600 dark:text-green-400 hover:bg-green-500/30`,e===`in_progress`&&`bg-blue-500/20 text-blue-600 dark:text-blue-400 hover:bg-blue-500/30`,e===`pending`&&`bg-gray-500/10 text-gray-500 dark:text-gray-400 hover:bg-gray-500/20`,e===`failed`&&`bg-red-500/20 text-red-600 dark:text-red-400 hover:bg-red-500/30`),children:[e===`completed`&&(0,J.jsx)(wn,{className:`w-4 h-4`}),e===`in_progress`&&(0,J.jsx)(jn,{className:`w-4 h-4 animate-pulse`}),e===`pending`&&(0,J.jsx)(On,{className:`w-4 h-4`}),e===`failed`&&(0,J.jsx)(Ft,{className:`w-4 h-4`})]}),Um=({task:e,onToggleStatus:t})=>{let n=e.status===`completed`,r=e.status===`in_progress`,i=e.status===`failed`;return(0,J.jsx)(`div`,{className:U(`group relative block rounded-lg p-3 transition-all duration-200`,`border border-sidebar-border/40 bg-sidebar/30`,`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`,r&&`bg-blue-50/80 dark:bg-blue-950/50 border-blue-400/60 dark:border-blue-600/60`,n&&`opacity-60 bg-sidebar/20`,i&&`border-red-400/60 bg-red-50/30 dark:bg-red-950/30 dark:border-red-700/60`),children:(0,J.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,J.jsx)(Hm,{status:e.status,onClick:()=>t(e)}),(0,J.jsxs)(`div`,{className:`flex-1 min-w-0 space-y-1`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`span`,{className:U(`text-sm font-medium leading-tight line-clamp-1`,n&&`line-through text-sidebar-foreground/60`),children:e.subject}),(0,J.jsxs)(`span`,{className:`text-[10px] font-mono text-sidebar-foreground/50 shrink-0`,children:[`#`,e.id]})]}),e.description!==void 0&&e.description!==``&&(0,J.jsx)(`p`,{className:`text-xs text-sidebar-foreground/60 line-clamp-2 leading-relaxed`,children:e.description}),e.blockedBy&&e.blockedBy.length>0&&e.status!==`completed`&&(0,J.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-1.5`,children:e.blockedBy.map(e=>(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded text-[10px] bg-amber-100 dark:bg-amber-900/30 text-amber-700 dark:text-amber-400 border border-amber-200 dark:border-amber-800/50`,children:[(0,J.jsx)(br,{className:`w-2.5 h-2.5`}),`#`,e]},e))})]})]})})},Wm=()=>(0,J.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-12 px-4 text-center`,children:[(0,J.jsx)(`div`,{className:`w-12 h-12 rounded-full bg-sidebar-accent/50 flex items-center justify-center mb-4`,children:(0,J.jsx)(Jn,{className:`w-6 h-6 text-sidebar-foreground/40`})}),(0,J.jsx)(`p`,{className:`text-sm font-medium text-sidebar-foreground/70`,children:`No tasks yet`}),(0,J.jsx)(`p`,{className:`text-xs text-sidebar-foreground/50 mt-1`,children:`Tasks will appear here when created`})]}),Gm=()=>(0,J.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-sidebar-foreground/60`,children:[(0,J.jsx)(A,{className:`w-4 h-4 animate-spin`}),(0,J.jsx)(`span`,{className:`text-sm`,children:`Loading tasks...`})]})}),Km=()=>(0,J.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-12 px-4 text-center`,children:[(0,J.jsx)(`div`,{className:`w-12 h-12 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center mb-4`,children:(0,J.jsx)(Ft,{className:`w-6 h-6 text-red-500`})}),(0,J.jsx)(`p`,{className:`text-sm font-medium text-red-600 dark:text-red-400`,children:`Failed to load tasks`}),(0,J.jsx)(`p`,{className:`text-xs text-sidebar-foreground/50 mt-1`,children:`Please try again later`})]}),qm=({projectId:e,sessionId:t})=>{let[n,r]=(0,q.useState)(!1),[i,a]=(0,q.useState)(``),[o,s]=(0,q.useState)(``),c=re(),{data:l,isLoading:u,error:d}=we({queryKey:[`tasks`,e,t],queryFn:()=>zm(e,t),refetchInterval:5e3}),f=p({mutationFn:n=>Bm(e,n,t),onSuccess:()=>{c.invalidateQueries({queryKey:[`tasks`,e,t]}),r(!1),a(``),s(``),z.success(`Task created`)},onError:()=>z.error(`Failed to create task`)}),m=p({mutationFn:n=>Vm(e,n.taskId,n.update,t),onSuccess:()=>{c.invalidateQueries({queryKey:[`tasks`,e,t]})},onError:()=>z.error(`Failed to update task`)}),h=e=>{let t=`pending`;e.status===`pending`?t=`in_progress`:e.status===`in_progress`?t=`completed`:(e.status===`completed`||e.status===`failed`)&&(t=`pending`),m.mutate({taskId:e.id,update:{status:t}})},g=e=>{e.preventDefault(),i.trim().length!==0&&f.mutate({subject:i,description:o})},_=l?.length??0;return(0,J.jsxs)(`div`,{className:`h-full flex flex-col`,children:[(0,J.jsxs)(`div`,{className:`border-b border-sidebar-border p-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,J.jsx)(`h2`,{className:`font-semibold text-lg`,children:`Tasks`}),(0,J.jsxs)(Be,{open:n,onOpenChange:r,children:[(0,J.jsx)(Me,{asChild:!0,children:(0,J.jsx)(H,{size:`sm`,variant:`ghost`,className:`h-8 w-8 p-0 rounded-full hover:bg-primary/10 hover:text-primary transition-colors`,children:(0,J.jsx)(gt,{className:`w-4 h-4`})})}),(0,J.jsxs)(Ue,{className:`sm:max-w-md`,children:[(0,J.jsxs)(We,{children:[(0,J.jsx)(Ae,{children:`Create New Task`}),(0,J.jsx)(ke,{children:`Add a new task to track your progress.`})]}),(0,J.jsxs)(`form`,{onSubmit:g,className:`space-y-4 mt-2`,children:[(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(W,{htmlFor:`subject`,children:`Title`}),(0,J.jsx)(At,{id:`subject`,value:i,onChange:e=>a(e.target.value),placeholder:`e.g. Implement login flow`,className:`focus-visible:ring-primary/30`})]}),(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(W,{htmlFor:`description`,children:`Description`}),(0,J.jsx)(Zc,{id:`description`,value:o,onChange:e=>s(e.target.value),placeholder:`Optional details about the task...`,className:`focus-visible:ring-primary/30 min-h-[80px]`})]}),(0,J.jsx)(Re,{children:(0,J.jsx)(H,{type:`submit`,disabled:f.isPending||i.trim().length===0,className:`w-full sm:w-auto`,children:f.isPending?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(A,{className:`w-4 h-4 mr-2 animate-spin`}),`Creating...`]}):`Create Task`})})]})]})]})]}),(0,J.jsxs)(`p`,{className:`text-xs text-sidebar-foreground/70`,children:[_,` `,_===1?`task`:`tasks`]})]}),(0,J.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-2 space-y-2`,children:[u&&(0,J.jsx)(Gm,{}),d&&(0,J.jsx)(Km,{}),!u&&!d&&_===0&&(0,J.jsx)(Wm,{}),!u&&!d&&l?.map(e=>(0,J.jsx)(Um,{task:e,onToggleStatus:h},e.id))]})]})},Jm=({currentSessionId:e,projectId:t,isOpen:n,onClose:r,initialTab:i=`sessions`})=>{let{i18n:a}=Xe(),o=N(),[s,c]=(0,q.useState)(i),l=s,u={sessions:a._({id:`sidebar.tab.sessions`}),mcp:a._({id:`sidebar.tab.mcp`}),tasks:a._({id:`sidebar.tab.tasks`}),scheduler:a._({id:`sidebar.tab.scheduler`}),settings:a._({id:`sidebar.tab.settings`}),"system-info":a._({id:`sidebar.tab.system_info`})};(0,q.useEffect)(()=>{c(i)},[i]),(0,q.useEffect)(()=>{if(!n)return;document.body.style.overflow=`hidden`;let e=e=>{e.key===`Escape`&&r()};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e),document.body.style.overflow=``}},[n,r]);let d=vd({onSwipe:e=>{e===`left`&&r()},enabled:n}),f=e=>{if(e===`projects`){o({to:`/projects`}),r();return}let t=zt.safeParse(e);t.success&&c(t.data)},p=()=>{switch(s){case`sessions`:return(0,J.jsx)(Rm,{currentSessionId:e,projectId:t,onSessionSelect:r});case`mcp`:return(0,J.jsx)(km,{projectId:t});case`tasks`:return(0,J.jsx)(qm,{projectId:t,sessionId:e});case`scheduler`:return(0,J.jsx)(Lm,{projectId:t,sessionId:e});case`settings`:return(0,J.jsx)(`div`,{className:`h-full flex flex-col`,children:(0,J.jsx)(q.Suspense,{fallback:(0,J.jsx)(`div`,{className:`flex-1 flex items-center justify-center p-4`,children:(0,J.jsx)(`div`,{className:`text-sm text-sidebar-foreground/70`,children:(0,J.jsx)(B,{id:`settings.loading`})})}),children:(0,J.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4 space-y-6`,children:[(0,J.jsxs)(`div`,{className:`space-y-4`,children:[(0,J.jsx)(`h3`,{className:`font-medium text-sm text-sidebar-foreground`,children:(0,J.jsx)(B,{id:`settings.session.display`})}),(0,J.jsx)(Em,{openingProjectId:t})]}),(0,J.jsxs)(`div`,{className:`space-y-4`,children:[(0,J.jsx)(`h3`,{className:`font-medium text-sm text-sidebar-foreground`,children:(0,J.jsx)(B,{id:`settings.notifications`})}),(0,J.jsx)(Cm,{})]})]})})});case`system-info`:return(0,J.jsx)(q.Suspense,{fallback:(0,J.jsx)(`div`,{className:`flex-1 flex items-center justify-center p-4`,children:(0,J.jsx)(`div`,{className:`text-sm text-sidebar-foreground/70`,children:`Loading...`})}),children:(0,J.jsx)(Om,{})});default:return null}};return(0,J.jsxs)(`div`,{ref:d,className:U(`fixed inset-y-0 left-0 w-[75vw] z-50 bg-sidebar text-sidebar-foreground flex flex-col shadow-xl md:hidden`,`transition-transform duration-300 ease-out`,n?`translate-x-0`:`-translate-x-full`),children:[(0,J.jsxs)(`div`,{className:`h-(--spacing-header-height) flex items-center gap-2 px-3 border-b border-sidebar-border bg-sidebar/80 backdrop-blur-sm flex-shrink-0`,children:[(0,J.jsxs)(gc,{value:s,onValueChange:f,children:[(0,J.jsx)(vc,{className:`flex-1 h-7 text-xs`,children:(0,J.jsx)(_c,{})}),(0,J.jsxs)(xc,{children:[(0,J.jsx)(X,{value:`projects`,className:`text-xs`,children:a._({id:`sidebar.tab.projects`,message:`Projects`})}),zt.options.map(e=>(0,J.jsx)(X,{value:e,className:`text-xs`,children:u[e]},e))]})]}),(0,J.jsx)(ie,{to:`/projects/$projectId/session`,params:{projectId:t},search:{tab:l},onClick:r,className:`flex-shrink-0`,children:(0,J.jsx)(H,{variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0 hover:bg-sidebar-accent/50`,"aria-label":a._(`New chat`),children:(0,J.jsx)(gt,{className:`w-3.5 h-3.5`})})}),(0,J.jsx)(H,{variant:`ghost`,size:`sm`,onClick:r,className:`h-7 w-7 p-0 hover:bg-sidebar-accent/50 flex-shrink-0`,"aria-label":a._(`Close sidebar`),children:(0,J.jsx)(Ce,{className:`w-3.5 h-3.5`})})]}),(0,J.jsx)(`div`,{className:`flex-1 overflow-hidden`,children:p()})]})},Ym=({projectId:e,className:t,additionalTabs:n=[],defaultActiveTab:r,headerButton:i,fillWidth:a=!1,isContentHidden:o=!1,onToggle:s,onMobileTabClick:c})=>{let{openSearch:l}=Fe(),{authEnabled:u,logout:d}=O(),f=N(),p=async()=>{await d(),f({to:`/login`})},m={id:`settings`,icon:mr,title:(0,J.jsx)(B,{id:`settings.tab.title`}),content:(0,J.jsxs)(`div`,{className:`h-full flex flex-col`,children:[(0,J.jsxs)(`div`,{className:`border-b border-sidebar-border p-4`,children:[(0,J.jsx)(`h2`,{className:`font-semibold text-lg`,children:(0,J.jsx)(B,{id:`settings.title`})}),(0,J.jsx)(`p`,{className:`text-xs text-sidebar-foreground/70`,children:(0,J.jsx)(B,{id:`settings.description`})})]}),(0,J.jsx)(q.Suspense,{fallback:(0,J.jsx)(`div`,{className:`flex-1 flex items-center justify-center p-4`,children:(0,J.jsx)(`div`,{className:`text-sm text-sidebar-foreground/70`,children:(0,J.jsx)(B,{id:`settings.loading`})})}),children:(0,J.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4 space-y-6`,children:[(0,J.jsxs)(`div`,{className:`space-y-4`,children:[(0,J.jsx)(`h3`,{className:`font-medium text-sm text-sidebar-foreground`,children:(0,J.jsx)(B,{id:`settings.section.session_display`})}),(0,J.jsx)(Em,{openingProjectId:e??``})]}),(0,J.jsxs)(`div`,{className:`space-y-4`,children:[(0,J.jsx)(`h3`,{className:`font-medium text-sm text-sidebar-foreground`,children:(0,J.jsx)(B,{id:`settings.section.notifications`})}),(0,J.jsx)(Cm,{})]})]})})]})},h={id:`system-info`,icon:Kn,title:(0,J.jsx)(B,{id:`settings.section.system_info`}),content:(0,J.jsx)(q.Suspense,{fallback:(0,J.jsx)(fd,{}),children:(0,J.jsx)(Om,{})})},g=[...n,m,h],[_,v]=(0,q.useState)(r??g[0]?.id??`settings`),y=e=>{if(c){v(e),c(e);return}o?(v(e),s?.()):_===e?s?.():v(e)},b=g.find(e=>e.id===_)?.content,x=!o;return(0,J.jsxs)(`div`,{className:U(`h-full border-r border-sidebar-border transition-all duration-300 ease-in-out flex bg-sidebar text-sidebar-foreground`,x?a?`w-full`:`w-80 lg:w-80`:`w-(--spacing-sidebar-icon-menu-mobile) md:w-(--spacing-sidebar-icon-menu)`,t),children:[(0,J.jsx)(`div`,{className:`w-(--spacing-sidebar-icon-menu-mobile) md:w-(--spacing-sidebar-icon-menu) flex flex-col border-r border-sidebar-border bg-sidebar/50`,children:(0,J.jsxs)(st,{children:[i!==void 0&&(0,J.jsx)(`div`,{className:`border-b border-sidebar-border`,children:i}),(0,J.jsx)(`div`,{className:`p-1.5 md:p-2 border-b border-sidebar-border`,children:(0,J.jsxs)(pt,{children:[(0,J.jsx)(ht,{asChild:!0,children:(0,J.jsx)(`button`,{type:`button`,onClick:l,className:U(`w-7 h-7 md:w-8 md:h-8 flex items-center justify-center rounded-md transition-colors`,`hover:bg-sidebar-accent hover:text-sidebar-accent-foreground`,`text-sidebar-foreground/70`),"data-testid":`search-button`,children:(0,J.jsx)(Te,{className:`w-4 h-4`})})}),(0,J.jsx)(tt,{side:`right`,children:(0,J.jsxs)(`p`,{children:[`Search `,(0,J.jsx)(`kbd`,{className:`ml-1 text-xs opacity-60`,children:`⌘K`})]})})]})}),(0,J.jsx)(`div`,{className:`flex-1 flex flex-col p-1.5 md:p-2 space-y-0.5 md:space-y-1`,children:g.map(e=>{let t=e.icon;return(0,J.jsxs)(pt,{children:[(0,J.jsx)(ht,{asChild:!0,children:(0,J.jsx)(`button`,{type:`button`,onClick:()=>y(e.id),className:U(`w-7 h-7 md:w-8 md:h-8 flex items-center justify-center rounded-md transition-colors`,`hover:bg-sidebar-accent hover:text-sidebar-accent-foreground`,_===e.id&&x?`bg-sidebar-accent text-sidebar-accent-foreground shadow-sm`:`text-sidebar-foreground/70`),"data-testid":`${e.id}-tab-button`,children:(0,J.jsx)(t,{className:`w-4 h-4`})})}),(0,J.jsx)(tt,{side:`right`,children:(0,J.jsx)(`p`,{children:e.title})})]},e.id)})}),u&&(0,J.jsx)(`div`,{className:`p-1.5 md:p-2 border-t border-sidebar-border`,children:(0,J.jsxs)(pt,{children:[(0,J.jsx)(ht,{asChild:!0,children:(0,J.jsx)(`button`,{type:`button`,onClick:()=>void p(),className:U(`w-7 h-7 md:w-8 md:h-8 flex items-center justify-center rounded-md transition-colors`,`hover:bg-destructive/10 hover:text-destructive`,`text-sidebar-foreground/70`),"data-testid":`logout-button`,children:(0,J.jsx)(Xn,{className:`w-4 h-4`})})}),(0,J.jsx)(tt,{side:`right`,children:(0,J.jsx)(`p`,{children:`Logout`})})]})})]})}),x&&(0,J.jsx)(`div`,{className:`flex-1 flex flex-col overflow-hidden`,children:b})]})},Xm=({currentSessionId:e,projectId:t,className:n,initialTab:r})=>{let{isLeftPanelOpen:i}=go(),{toggleLeftPanel:a}=_o(),o=e??``,s=(0,q.useMemo)(()=>[{id:`sessions`,icon:_e,title:(0,J.jsx)(B,{id:`sidebar.show.session.list`}),content:(0,J.jsx)(q.Suspense,{fallback:(0,J.jsx)(fd,{}),children:(0,J.jsx)(Rm,{currentSessionId:o,projectId:t})})},{id:`mcp`,icon:cr,title:(0,J.jsx)(B,{id:`sidebar.show.mcp.settings`}),content:(0,J.jsx)(km,{projectId:t})},{id:`tasks`,icon:Jn,title:(0,J.jsx)(B,{id:`sidebar.show.task.list`}),content:(0,J.jsx)(qm,{projectId:t,sessionId:o})},{id:`scheduler`,icon:vn,title:(0,J.jsx)(B,{id:`sidebar.show.scheduler.jobs`}),content:(0,J.jsx)(Lm,{projectId:t,sessionId:o})}],[o,t]);return(0,J.jsx)(`div`,{className:U(`hidden md:flex h-full w-full`,n),children:(0,J.jsx)(Ym,{projectId:t,additionalTabs:s,defaultActiveTab:r,headerButton:(0,J.jsx)(st,{children:(0,J.jsxs)(pt,{children:[(0,J.jsx)(ht,{asChild:!0,children:(0,J.jsx)(ie,{to:`/projects`,className:`w-(--spacing-sidebar-icon-menu) h-(--spacing-sidebar-icon-menu) flex items-center justify-center hover:bg-sidebar-accent transition-colors`,children:(0,J.jsx)(pn,{className:`w-4 h-4 text-sidebar-foreground/70`})})}),(0,J.jsx)(tt,{side:`right`,children:(0,J.jsx)(`p`,{children:(0,J.jsx)(B,{id:`sidebar.back.to.projects`})})})]})}),fillWidth:!0,isContentHidden:!i,onToggle:a})})},Zm=({projectId:e,sessionId:t,tab:n})=>(bd(),(0,J.jsx)(Ms,{projectId:e,sessionId:t,children:(0,J.jsx)(q.Suspense,{fallback:(0,J.jsx)(fd,{}),children:(0,J.jsx)(Qm,{projectId:e,sessionId:t,tab:n})})})),Qm=({projectId:e,sessionId:t,tab:n})=>{let[r,i]=(0,q.useState)(!1),a=Is(),o=vd({onSwipe:e=>{e===`right`&&!r&&i(!0)},edgeWidth:30,enabled:a}),s=So(),c=Co(),l=T(eo),{data:u}=xd(e),d=u.pages[0]?.project,f=d?.meta.projectPath??d?.claudeProjectPath,p=d?.meta.projectName??`Untitled Project`,m=p?`${p} - Claude Code Viewer`:`Claude Code Viewer`,h=s&&!a?`${c}%`:`0`,g=(0,q.useCallback)(()=>{i(!0)},[]),_=(0,q.useCallback)(()=>{i(!1)},[]);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`title`,{children:m}),a&&(0,J.jsx)(Jm,{currentSessionId:t??``,projectId:e,isOpen:r,onClose:_,initialTab:n}),a&&r&&(0,J.jsx)(`button`,{type:`button`,className:`fixed inset-0 z-40 bg-black/30 md:hidden`,onClick:_,"aria-label":`Close sidebar`}),(0,J.jsxs)(`div`,{ref:o,className:U(`flex h-full overflow-hidden`,a&&`transition-transform duration-300 ease-out`),style:a&&r?{transform:`translateX(75vw)`}:void 0,children:[(0,J.jsx)(hd,{children:(0,J.jsx)(q.Suspense,{fallback:(0,J.jsx)(fd,{}),children:(0,J.jsx)(Xm,{currentSessionId:t,projectId:e,initialTab:n})})}),(0,J.jsxs)(`div`,{className:U(`flex flex-col flex-1 min-w-0`,!l&&`transition-all duration-200`),style:{marginRight:h},children:[(0,J.jsx)(`div`,{className:`flex flex-col flex-1 min-h-0 overflow-hidden`,children:(0,J.jsx)(q.Suspense,{fallback:(0,J.jsx)(fd,{}),children:(0,J.jsx)(vm,{projectId:e,sessionId:t,projectPath:f,projectName:p,onMobileMenuOpen:a?g:void 0})})}),(0,J.jsx)(Gs,{cwd:f})]}),(0,J.jsx)(qs,{projectId:e,sessionId:t,gitTabContent:(0,J.jsx)(Qu,{projectId:e,sessionId:t}),filesToolsTabContent:t!==void 0&&t!==``?(0,J.jsx)(q.Suspense,{fallback:(0,J.jsx)(fd,{}),children:(0,J.jsx)(ju,{projectId:e,sessionId:t})}):(0,J.jsx)(Au,{}),reviewTabContent:(0,J.jsx)(q.Suspense,{fallback:(0,J.jsx)(fd,{}),children:(0,J.jsx)(ld,{projectId:e,sessionId:t})})})]})]})},$m=()=>{let e=Ut.useParams(),{sessionId:t,tab:n}=Ut.useSearch();return(0,J.jsx)(mt,{children:(0,J.jsx)(Zm,{projectId:e.projectId,sessionId:t,tab:n})})};export{$m as component};