@jean2/client 0.8.3 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/README.md +1 -1
  2. package/dist/assets/ServerContext-CBFiY6IH.js +1 -0
  3. package/dist/assets/SessionContent-BUi72_iy.js +9 -0
  4. package/dist/assets/{SessionMenuButton-BRiMfAN5.js → SessionMenuButton-CMaV4kEA.js} +3 -3
  5. package/dist/assets/ThemeProvider-Da23NPAS.js +1 -0
  6. package/dist/assets/_serverId-BvST5YDe.js +12 -0
  7. package/dist/assets/_serverId-DfPzo4bd.js +1 -0
  8. package/dist/assets/_serverId-MO9g8fX9.js +2 -0
  9. package/dist/assets/_sessionId-CPP8h5aK.js +1 -0
  10. package/dist/assets/_sessionId-DBdXwlmj.js +1 -0
  11. package/dist/assets/alert-3Kbxsvve.js +31 -0
  12. package/dist/assets/badge-CzDK507L.js +45 -0
  13. package/dist/assets/compiler-runtime-DZXZ41-q.js +1 -0
  14. package/dist/assets/confirmation-dialog-x-_jBxq9.js +1 -0
  15. package/dist/assets/core-B5tm5Pq5.js +1 -0
  16. package/dist/assets/createLucideIcon-BYAVpx9Z.js +1 -0
  17. package/dist/assets/dist-js-CnIJv7bh.js +1 -0
  18. package/dist/assets/{event-qUXFERHS.js → event-Bg5mre8h.js} +1 -1
  19. package/dist/assets/index-gpIdz2Xy.css +2 -0
  20. package/dist/assets/index-wGbWnMXW.js +10 -0
  21. package/dist/assets/overview-B_ZDrH1J.js +1 -0
  22. package/dist/assets/overview-mSGJdfsz.js +1 -0
  23. package/dist/assets/platform-5d-ZQG2e.js +1 -0
  24. package/dist/assets/popover-EEh8MoGn.js +1 -0
  25. package/dist/assets/{preload-helper-CYlqXMwt.js → preload-helper-D-tEmku_.js} +1 -1
  26. package/dist/assets/routes-WPmRqSvV.js +1 -0
  27. package/dist/assets/scroll-area-zE8JtjlC.js +1 -0
  28. package/dist/assets/{server-BNi58bIU.js → server-g7It7jLf.js} +1 -1
  29. package/dist/assets/servers-GmYSnzvH.js +1 -0
  30. package/dist/assets/sidebar-BULcvh4r.js +1 -0
  31. package/dist/assets/src-9dJwbSJY.js +1 -0
  32. package/dist/assets/{triangle-alert-DxjucLze.js → triangle-alert-BOCjiWM3.js} +1 -1
  33. package/dist/assets/useNavigate-Dxc8FNpV.js +1 -0
  34. package/dist/assets/useParams-RuFKFrOo.js +1 -0
  35. package/dist/assets/useRouterState-C1XfNwIo.js +1 -0
  36. package/dist/assets/workspace-BDB9L3JR.js +1 -0
  37. package/dist/assets/workspace-_n12Hx4o.js +1 -0
  38. package/dist/index.html +12 -13
  39. package/package.json +1 -1
  40. package/dist/assets/ServerContext-D9RfmQC6.js +0 -1
  41. package/dist/assets/SessionContent-DAoBLNGO.js +0 -9
  42. package/dist/assets/ThemeProvider-JPllbGvS.js +0 -1
  43. package/dist/assets/_serverId-Bd-hxE5e.js +0 -2
  44. package/dist/assets/_serverId-CsnPjy9K.js +0 -12
  45. package/dist/assets/_serverId-XYC72_6_.js +0 -1
  46. package/dist/assets/_sessionId-C96NK5UN.js +0 -1
  47. package/dist/assets/_sessionId-DdW2fnoe.js +0 -1
  48. package/dist/assets/alert-DeW1kArF.js +0 -31
  49. package/dist/assets/badge-DUoauaaV.js +0 -45
  50. package/dist/assets/confirmation-dialog-DeIbHoOu.js +0 -1
  51. package/dist/assets/core-CblztWA2.js +0 -1
  52. package/dist/assets/createLucideIcon-BaO6wACO.js +0 -1
  53. package/dist/assets/dropdown-menu-kSrbs3Xk.js +0 -1
  54. package/dist/assets/index-0foRHKn1.js +0 -10
  55. package/dist/assets/index-Bv9FJWM6.css +0 -2
  56. package/dist/assets/jsx-runtime-D-oznMWL.js +0 -1
  57. package/dist/assets/overview-ZVTPIcDN.js +0 -1
  58. package/dist/assets/overview-b6wqapV-.js +0 -1
  59. package/dist/assets/platform-Bn4qAxt4.js +0 -1
  60. package/dist/assets/popover-DqniPNsl.js +0 -1
  61. package/dist/assets/react-DcCgrBX5.js +0 -1
  62. package/dist/assets/routes-BbfnvJnQ.js +0 -1
  63. package/dist/assets/scroll-area-DVew28V6.js +0 -1
  64. package/dist/assets/servers-CGl9kUR2.js +0 -1
  65. package/dist/assets/src-w2G0llvL.js +0 -1
  66. package/dist/assets/useNavigate-5b_LZg00.js +0 -1
  67. package/dist/assets/useParams-BODsv_8k.js +0 -1
  68. package/dist/assets/useRouterState-FezJSBQO.js +0 -1
  69. package/dist/assets/workspace-B2-0-561.js +0 -1
  70. package/dist/assets/workspace-BfFnK9TP.js +0 -1
package/README.md CHANGED
@@ -14,7 +14,7 @@ Three deployment targets:
14
14
  - Multi-model and multi-provider selection (budget/standard/premium tiers)
15
15
  - Session management — create, close, reopen, rename, fork, compact, and revert
16
16
  - Multi-server and multi-workspace support with quick switching
17
- - Tool permission approval flow with allow-once and always-allow options
17
+ - Tool permission approval flow with grant scope options (once, session, workspace, always)
18
18
  - File tree browser and file path autocomplete
19
19
  - MCP (Model Context Protocol) server management
20
20
  - Queued messages when a session is busy streaming
@@ -0,0 +1 @@
1
+ import{n as e,o as t,r as n,t as r}from"./compiler-runtime-DZXZ41-q.js";import{a as i,c as a,i as o,l as s,n as c,o as l,r as u,s as d,t as f}from"./servers-GmYSnzvH.js";var p=t(n(),1),m=r();function h(e){return/^[a-f0-9]{64}$/.test(e)}function g(e){return e.length<12?e:`${e.slice(0,4)}...${e.slice(-4)}`}function _(e){let t=e.trim(),n=/^https:\/\//i.test(t),r=t.replace(/^(https?:\/\/|wss?:\/\/)/i,``);return r=r.replace(/\/+$/,``),n&&(r=`https://${r}`),r}var v=e(),y=(0,p.createContext)(null),b=e=>{let t=(0,m.c)(18),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=[],t[0]=r):r=t[0];let[h,g]=(0,p.useState)(r),b;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(b=[],t[1]=b):b=t[1];let[x,S]=(0,p.useState)(b),[C,w]=(0,p.useState)(!1),T,E;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(T=()=>{let e=o(),t=u();g(e),S(t),w(!0)},E=[],t[2]=T,t[3]=E):(T=t[2],E=t[3]),(0,p.useEffect)(T,E);let D;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(D=(e,t,n)=>{let r=_(t),i={id:crypto.randomUUID(),name:e,url:r,token:n,createdAt:new Date().toISOString()};return a(i),g(o()),i},t[4]=D):D=t[4];let O=D,k;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(k=(e,t)=>{s(e,{...t,...t.url&&{url:_(t.url)}}),g(o())},t[5]=k):k=t[5];let A=k,j;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(j=e=>{c(e),g(o()),S(u())},t[6]=j):j=t[6];let M=j,N;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(N=(e,t,n,r)=>{f({serverId:e,serverName:t,workspaceId:n,workspaceName:r}),S(u())},t[7]=N):N=t[7];let P=N,F;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(F=e=>{i(e),S(u())},t[8]=F):F=t[8];let I=F,L;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(L=e=>{l(e),S(u())},t[9]=L):L=t[9];let R=L,z;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(z=e=>{d(e),S(u())},t[10]=z):z=t[10];let B=z,V;t[11]!==C||t[12]!==x||t[13]!==h?(V={servers:h,quickConnections:x,isHydrated:C,addServer:O,editServer:A,removeServer:M,addToQuickConnections:P,removeFromQuickConnections:I,removeFromQuickConnectionsByWorkspace:R,reorderQuick:B},t[11]=C,t[12]=x,t[13]=h,t[14]=V):V=t[14];let H=V,U;return t[15]!==n||t[16]!==H?(U=(0,v.jsx)(y.Provider,{value:H,children:n}),t[15]=n,t[16]=H,t[17]=U):U=t[17],U},x=()=>{let e=(0,p.useContext)(y);if(e===null)throw Error(`useServerContext must be used within a ServerProvider`);return e};export{_ as a,g as i,x as n,h as r,b as t};
@@ -0,0 +1,9 @@
1
+ import{n as e,o as t,r as n,t as r}from"./compiler-runtime-DZXZ41-q.js";import{i}from"./src-9dJwbSJY.js";import{n as a}from"./ThemeProvider-Da23NPAS.js";import{$ as o,Ct as s,Dt as c,Et as l,J as u,Q as d,S as f,Tt as p,Y as m,Z as h,_ as g,_t as _,a as v,b as y,bt as b,c as x,ct as S,d as C,f as w,ft as T,h as E,ht as D,i as O,j as k,jt as A,l as j,m as M,n as N,ot as P,p as F,pt as I,r as L,rt as R,s as z,st as B,t as V,u as H,ut as U,v as W,vt as G,wt as K,x as ee,xt as te,y as q,yt as J}from"./badge-CzDK507L.js";import{t as Y}from"./createLucideIcon-BYAVpx9Z.js";import{n as ne,t as re}from"./confirmation-dialog-x-_jBxq9.js";import{C as ie,S as ae,T as oe,_ as se,a as ce,b as le,c as ue,d as de,f as fe,g as pe,h as me,i as he,l as ge,m as X,n as _e,o as ve,p as ye,r as be,s as xe,t as Se,u as Ce,v as we,w as Te,x as Ee,y as De}from"./alert-3Kbxsvve.js";import{a as Oe,b as ke,c as Ae,f as je,i as Me,l as Ne,n as Pe,o as Fe,r as Ie,s as Le,t as Re,u as ze,x as Be}from"./popover-EEh8MoGn.js";import{i as Ve,n as He,r as Ue,t as We}from"./triangle-alert-BOCjiWM3.js";function Ge(e){return e.role===`assistant`}var Ke=Y(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),qe=Y(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),Je=Y(`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`}]]),Ye=Y(`brain`,[[`path`,{d:`M12 18V5`,key:`adv99a`}],[`path`,{d:`M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4`,key:`1e3is1`}],[`path`,{d:`M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5`,key:`1gqd8o`}],[`path`,{d:`M17.997 5.125a4 4 0 0 1 2.526 5.77`,key:`iwvgf7`}],[`path`,{d:`M18 18a4 4 0 0 0 2-7.464`,key:`efp6ie`}],[`path`,{d:`M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517`,key:`1gq6am`}],[`path`,{d:`M6 18a4 4 0 0 1-2-7.464`,key:`k1g0md`}],[`path`,{d:`M6.003 5.125a4 4 0 0 0-2.526 5.77`,key:`q97ue3`}]]),Xe=Y(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),Ze=Y(`circle-check`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),Qe=Y(`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`}]]),$e=Y(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),et=Y(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]),tt=Y(`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`}]]),nt=Y(`file-pen`,[[`path`,{d:`M12.659 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v9.34`,key:`o6klzx`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10.378 12.622a1 1 0 0 1 3 3.003L8.36 20.637a2 2 0 0 1-.854.506l-2.867.837a.5.5 0 0 1-.62-.62l.836-2.869a2 2 0 0 1 .506-.853z`,key:`zhnas1`}]]),rt=Y(`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`}]]),it=Y(`hand`,[[`path`,{d:`M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2`,key:`1fvzgz`}],[`path`,{d:`M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2`,key:`1kc0my`}],[`path`,{d:`M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8`,key:`10h0bg`}],[`path`,{d:`M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15`,key:`1s1gnw`}]]),at=Y(`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`}]]),ot=Y(`message-square`,[[`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`}]]),st=Y(`minimize-2`,[[`path`,{d:`m14 10 7-7`,key:`oa77jy`}],[`path`,{d:`M20 10h-6V4`,key:`mjg0md`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M4 14h6v6`,key:`rmj7iw`}]]),ct=Y(`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`}]]),lt=Y(`shield-off`,[[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71`,key:`1jlk70`}],[`path`,{d:`M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264`,key:`18rp1v`}]]),ut=Y(`undo-2`,[[`path`,{d:`M9 14 4 9l5-5`,key:`102s5s`}],[`path`,{d:`M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11`,key:`f3b9sd`}]]),dt=Y(`wifi-off`,[[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M8.5 16.429a5 5 0 0 1 7 0`,key:`1bycff`}],[`path`,{d:`M5 12.859a10 10 0 0 1 5.17-2.69`,key:`1dl1wf`}],[`path`,{d:`M19 12.859a10 10 0 0 0-2.007-1.523`,key:`4k23kn`}],[`path`,{d:`M2 8.82a15 15 0 0 1 4.177-2.643`,key:`1grhjp`}],[`path`,{d:`M22 8.82a15 15 0 0 0-11.288-3.764`,key:`z3jwby`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),ft=Y(`wifi`,[[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M2 8.82a15 15 0 0 1 20 0`,key:`dnpr2z`}],[`path`,{d:`M5 12.859a10 10 0 0 1 14 0`,key:`1x1e6c`}],[`path`,{d:`M8.5 16.429a5 5 0 0 1 7 0`,key:`1bycff`}]]),Z=t(n(),1),Q=e(),pt=`Checkbox`,[mt,ht]=d(pt),[gt,_t]=mt(pt);function vt(e){let{__scopeCheckbox:t,checked:n,children:r,defaultChecked:i,disabled:a,form:o,name:s,onCheckedChange:c,required:l,value:u=`on`,internal_do_not_use_render:d}=e,[f,p]=m({prop:n,defaultProp:i==null?!1:i,onChange:c,caller:pt}),[h,g]=Z.useState(null),[_,v]=Z.useState(null),y=Z.useRef(!1),b=h?!!o||!!h.closest(`form`):!0,x={checked:f,disabled:a,setChecked:p,control:h,setControl:g,name:s,form:o,value:u,hasConsumerStoppedPropagationRef:y,required:l,defaultChecked:Dt(i)?!1:i,isFormControl:b,bubbleInput:_,setBubbleInput:v};return(0,Q.jsx)(gt,{scope:t,...x,children:Et(d)?d(x):r})}var yt=`CheckboxTrigger`,bt=Z.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:n,...r},i)=>{let{control:a,value:s,disabled:c,checked:l,required:u,setControl:d,setChecked:f,hasConsumerStoppedPropagationRef:p,isFormControl:m,bubbleInput:g}=_t(yt,e),_=R(i,d),v=Z.useRef(l);return Z.useEffect(()=>{let e=a==null?void 0:a.form;if(e){let t=()=>f(v.current);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[a,f]),(0,Q.jsx)(o.button,{type:`button`,role:`checkbox`,"aria-checked":Dt(l)?`mixed`:l,"aria-required":u,"data-state":Ot(l),"data-disabled":c?``:void 0,disabled:c,value:s,...r,ref:_,onKeyDown:h(t,e=>{e.key===`Enter`&&e.preventDefault()}),onClick:h(n,e=>{f(e=>Dt(e)?!0:!e),g&&m&&(p.current=e.isPropagationStopped(),p.current||e.stopPropagation())})})});bt.displayName=yt;var xt=Z.forwardRef((e,t)=>{let{__scopeCheckbox:n,name:r,checked:i,defaultChecked:a,required:o,disabled:s,value:c,onCheckedChange:l,form:u,...d}=e;return(0,Q.jsx)(vt,{__scopeCheckbox:n,checked:i,defaultChecked:a,disabled:s,required:o,onCheckedChange:l,name:r,form:u,value:c,internal_do_not_use_render:({isFormControl:e})=>(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(bt,{...d,ref:t,__scopeCheckbox:n}),e&&(0,Q.jsx)(Tt,{__scopeCheckbox:n})]})})});xt.displayName=pt;var St=`CheckboxIndicator`,Ct=Z.forwardRef((e,t)=>{let{__scopeCheckbox:n,forceMount:r,...i}=e,a=_t(St,n);return(0,Q.jsx)(u,{present:r||Dt(a.checked)||a.checked===!0,children:(0,Q.jsx)(o.span,{"data-state":Ot(a.checked),"data-disabled":a.disabled?``:void 0,...i,ref:t,style:{pointerEvents:`none`,...e.style}})})});Ct.displayName=St;var wt=`CheckboxBubbleInput`,Tt=Z.forwardRef(({__scopeCheckbox:e,...t},n)=>{let{control:r,hasConsumerStoppedPropagationRef:i,checked:a,defaultChecked:s,required:c,disabled:l,name:u,value:d,form:f,bubbleInput:p,setBubbleInput:m}=_t(wt,e),h=R(n,m),g=xe(a),_=k(r);Z.useEffect(()=>{let e=p;if(!e)return;let t=window.HTMLInputElement.prototype,n=Object.getOwnPropertyDescriptor(t,`checked`).set,r=!i.current;if(g!==a&&n){let t=new Event(`click`,{bubbles:r});e.indeterminate=Dt(a),n.call(e,Dt(a)?!1:a),e.dispatchEvent(t)}},[p,g,a,i]);let v=Z.useRef(Dt(a)?!1:a);return(0,Q.jsx)(o.input,{type:`checkbox`,"aria-hidden":!0,defaultChecked:s==null?v.current:s,required:c,disabled:l,name:u,value:d,form:f,...t,tabIndex:-1,ref:h,style:{...t.style,..._,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0,transform:`translateX(-100%)`}})});Tt.displayName=wt;function Et(e){return typeof e==`function`}function Dt(e){return e===`indeterminate`}function Ot(e){return Dt(e)?`indeterminate`:e?`checked`:`unchecked`}var $=r();function kt(){let e=(0,$.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Q.jsxs)(`div`,{className:`flex flex-col h-full items-center justify-center gap-4 text-muted-foreground`,children:[(0,Q.jsx)(te,{className:`size-8 animate-spin`}),(0,Q.jsx)(`p`,{className:`text-sm`,children:`Loading conversation...`})]}),e[0]=t):t=e[0],t}function At(e){let t=(0,$.c)(3),{message:n}=e,r=n===void 0?`Connecting to server...`:n,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Q.jsx)(te,{className:`size-8 animate-spin`}),t[0]=i):i=t[0];let a;return t[1]===r?a=t[2]:(a=(0,Q.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-4 text-muted-foreground`,children:[i,(0,Q.jsx)(`p`,{className:`text-sm`,children:r})]}),t[1]=r,t[2]=a),a}var jt=e=>{let t=(0,$.c)(26),{serverUrl:n,authError:r,retryCount:i,nextRetryIn:a,onRetry:o,onLogout:s}=e,c,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Q.jsx)(dt,{className:`size-12 text-destructive mb-4`}),l=(0,Q.jsx)(`h2`,{className:`text-xl font-semibold text-foreground mb-2`,children:`Unable to connect to server`}),t[0]=c,t[1]=l):(c=t[0],l=t[1]);let u=r||`Please check that the server is running.`,d;t[2]===u?d=t[3]:(d=(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground mb-4 max-w-[400px]`,children:u}),t[2]=u,t[3]=d);let f;t[4]===n?f=t[5]:(f=n&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground mb-6 font-mono bg-muted px-3 py-1.5 rounded`,children:n}),t[4]=n,t[5]=f);let p;t[6]===a?p=t[7]:(p=(0,Q.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Retrying in `,a,`s...`]}),t[6]=a,t[7]=p);let m;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,Q.jsx)(me,{className:`size-4 mr-2`,"data-icon":`inline-start`}),t[8]=m):m=t[8];let h;t[9]===o?h=t[10]:(h=(0,Q.jsxs)(q,{onClick:o,variant:`default`,children:[m,`Retry Now`]}),t[9]=o,t[10]=h);let g;t[11]===s?g=t[12]:(g=(0,Q.jsx)(q,{onClick:s,variant:`ghost`,children:`Change Server`}),t[11]=s,t[12]=g);let _;t[13]!==h||t[14]!==g?(_=(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[h,g]}),t[13]=h,t[14]=g,t[15]=_):_=t[15];let v;t[16]===i?v=t[17]:(v=i>0&&(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Retry attempt: `,i]}),t[16]=i,t[17]=v);let y;t[18]!==_||t[19]!==v||t[20]!==p?(y=(0,Q.jsxs)(`div`,{className:`flex flex-col items-center gap-4`,children:[p,_,v]}),t[18]=_,t[19]=v,t[20]=p,t[21]=y):y=t[21];let b;return t[22]!==y||t[23]!==d||t[24]!==f?(b=(0,Q.jsxs)(`div`,{className:`flex flex-col items-center justify-center min-h-[400px] px-4 text-center`,children:[c,l,d,f,y]}),t[22]=y,t[23]=d,t[24]=f,t[25]=b):b=t[25],b};function Mt(e){return e>=1e6?(e/1e6).toFixed(1)+`M`:e>=1e3?(e/1e3).toFixed(1)+`k`:e.toString()}function Nt(e){return e>=60?`critical`:e>=40?`warning`:`normal`}function Pt(e){let t=(0,$.c)(21),{totalTokens:n,contextWindow:r}=e,i=n===void 0?0:n,a=r===void 0?0:r,[o,s]=(0,Z.useState)(!1),c=i===0?0:a,l;t[0]!==c||t[1]!==i?(l=c===0?0:Math.min(100,Math.round(i/c*100)),t[0]=c,t[1]=i,t[2]=l):l=t[2];let u=l,d=Nt(u),f=2*Math.PI*8,p=f*(1-u/100),m=u===0?`text-muted-foreground/30`:d===`critical`?`text-destructive`:d===`warning`?`text-warning`:`text-primary`,h;t[3]===o?h=t[4]:(h=()=>s(!o),t[3]=o,t[4]=h);let g;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,Q.jsx)(`circle`,{cx:`10`,cy:`10`,r:8,stroke:`currentColor`,className:`text-muted-foreground/20`,strokeWidth:`3`}),t[5]=g):g=t[5];let _;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(_={transition:`stroke-dashoffset 0.3s ease`},t[6]=_):_=t[6];let v;t[7]!==m||t[8]!==p?(v=(0,Q.jsxs)(`svg`,{viewBox:`0 0 20 20`,className:`size-5`,fill:`none`,children:[g,(0,Q.jsx)(`circle`,{cx:`10`,cy:`10`,r:8,stroke:`currentColor`,className:m,strokeWidth:`3`,strokeDasharray:f,strokeDashoffset:p,strokeLinecap:`round`,transform:`rotate(-90 10 10)`,style:_})]}),t[7]=m,t[8]=p,t[9]=v):v=t[9];let y;t[10]!==c||t[11]!==u||t[12]!==o||t[13]!==i?(y=o?`${Mt(i)}/${Mt(c)}`:`${u}%`,t[10]=c,t[11]=u,t[12]=o,t[13]=i,t[14]=y):y=t[14];let b;t[15]===y?b=t[16]:(b=(0,Q.jsx)(`span`,{className:`text-xs font-mono text-muted-foreground`,children:y}),t[15]=y,t[16]=b);let x;return t[17]!==h||t[18]!==v||t[19]!==b?(x=(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 cursor-pointer select-none`,onClick:h,children:[v,b]}),t[17]=h,t[18]=v,t[19]=b,t[20]=x):x=t[20],x}function Ft(e){switch(e){case`budget`:return`$`;case`standard`:return`$$`;case`premium`:return`$$$`;default:return``}}function It(e){let t=(0,$.c)(79),{models:n,selectedModelId:r,onChangeModel:i,disabled:a,compact:o,iconOnly:s}=e,c=o===void 0?!1:o,u=s===void 0?!1:s,[d,f]=(0,Z.useState)(!1),p,m,h,g,_,v,b,x,S,C,w,T,E;if(t[0]!==c||t[1]!==a||t[2]!==u||t[3]!==n||t[4]!==i||t[5]!==d||t[6]!==r){v=Symbol.for(`react.early_return_sentinel`);bb0:{let e=n.reduce(Lt,{}),o=e=>{let t=n.find(t=>t.id===e);t&&(i(e,t.providerId),f(!1))},s;if(t[20]!==n||t[21]!==r){let e;t[23]===r?e=t[24]:(e=e=>e.id===r,t[23]=r,t[24]=e),s=n.find(e),t[20]=n,t[21]=r,t[22]=s}else s=t[22];let D=s;if(u){let n;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Q.jsx)(ae,{className:`size-4 text-muted-foreground`}),t[25]=n):n=t[25];let i;t[26]!==a||t[27]!==d?(i=(0,Q.jsx)(Me,{asChild:!0,children:(0,Q.jsx)(q,{variant:`ghost`,size:`icon-sm`,role:`combobox`,"aria-expanded":d,"aria-label":`Select model`,disabled:a,children:n})}),t[26]=a,t[27]=d,t[28]=i):i=t[28];let s;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Q.jsx)(Ae,{placeholder:`Search model...`}),t[29]=s):s=t[29];let c;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Q.jsx)(Fe,{children:`No model found.`}),t[30]=c):c=t[30];let u=(0,Q.jsxs)(ze,{className:`max-h-[50vh] overflow-y-auto`,children:[c,Object.entries(e).map(e=>{let[t,n]=e;return(0,Q.jsx)(Le,{heading:t,children:n.map(e=>(0,Q.jsxs)(Ne,{value:e.id,onSelect:()=>o(e.id),className:`justify-between`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{children:e.name}),(0,Q.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:Ft(e.tier)})]}),(0,Q.jsx)(l,{className:y(`size-4`,r===e.id?`opacity-100`:`opacity-0`)})]},e.id))},t)})]}),p;t[31]===u?p=t[32]:(p=(0,Q.jsx)(Ie,{className:`w-[240px] p-0`,children:(0,Q.jsxs)(Oe,{children:[s,u]})}),t[31]=u,t[32]=p);let m;t[33]!==d||t[34]!==i||t[35]!==p?(m=(0,Q.jsxs)(Re,{open:d,onOpenChange:f,children:[i,p]}),t[33]=d,t[34]=i,t[35]=p,t[36]=m):m=t[36],v=m;break bb0}if(c){let n,i;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Q.jsx)(ae,{className:`size-4 flex-shrink-0 text-muted-foreground`}),i=(0,Q.jsx)(Be,{className:`size-3 shrink-0 opacity-50`}),t[37]=n,t[38]=i):(n=t[37],i=t[38]);let s;t[39]!==a||t[40]!==d?(s=(0,Q.jsx)(Me,{asChild:!0,children:(0,Q.jsxs)(q,{variant:`ghost`,size:`sm`,role:`combobox`,"aria-expanded":d,"aria-label":`Select model`,className:`h-8 gap-1.5 px-2 text-muted-foreground hover:bg-accent`,disabled:a,children:[n,i]})}),t[39]=a,t[40]=d,t[41]=s):s=t[41];let c;t[42]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Q.jsx)(Ae,{placeholder:`Search model...`}),t[42]=c):c=t[42];let u;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Q.jsx)(Fe,{children:`No model found.`}),t[43]=u):u=t[43];let p=(0,Q.jsxs)(ze,{className:`max-h-[50vh] overflow-y-auto`,children:[u,Object.entries(e).map(e=>{let[t,n]=e;return(0,Q.jsx)(Le,{heading:t,children:n.map(e=>(0,Q.jsxs)(Ne,{value:e.id,onSelect:()=>o(e.id),className:`justify-between`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{children:e.name}),(0,Q.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:Ft(e.tier)})]}),(0,Q.jsx)(l,{className:y(`size-4`,r===e.id?`opacity-100`:`opacity-0`)})]},e.id))},t)})]}),m;t[44]===p?m=t[45]:(m=(0,Q.jsx)(Ie,{className:`w-[240px] p-0`,children:(0,Q.jsxs)(Oe,{children:[c,p]})}),t[44]=p,t[45]=m);let h;t[46]!==d||t[47]!==s||t[48]!==m?(h=(0,Q.jsxs)(Re,{open:d,onOpenChange:f,children:[s,m]}),t[46]=d,t[47]=s,t[48]=m,t[49]=h):h=t[49],v=h;break bb0}g=Re,T=d,E=f;let O;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,Q.jsx)(ae,{className:`size-4 flex-shrink-0 text-muted-foreground`}),t[50]=O):O=t[50];let k=(D==null?void 0:D.name)||`Select model`,A;t[51]===k?A=t[52]:(A=(0,Q.jsx)(`span`,{className:`truncate`,children:k}),t[51]=k,t[52]=A);let j;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,Q.jsx)(Be,{className:`size-3 shrink-0 opacity-50`}),t[53]=j):j=t[53],t[54]!==a||t[55]!==d||t[56]!==A?(_=(0,Q.jsx)(Me,{asChild:!0,children:(0,Q.jsxs)(q,{variant:`ghost`,size:`sm`,role:`combobox`,"aria-expanded":d,"aria-label":`Select model`,className:`h-8 gap-1.5 px-2 text-muted-foreground hover:bg-accent`,disabled:a,children:[O,A,j]})}),t[54]=a,t[55]=d,t[56]=A,t[57]=_):_=t[57],h=Ie,w=`w-[240px] p-0`,m=Oe,t[58]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,Q.jsx)(Ae,{placeholder:`Search model...`}),t[58]=C):C=t[58],p=ze,b=`max-h-[50vh] overflow-y-auto`,t[59]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,Q.jsx)(Fe,{children:`No model found.`}),t[59]=x):x=t[59],S=Object.entries(e).map(e=>{let[t,n]=e;return(0,Q.jsx)(Le,{heading:t,children:n.map(e=>(0,Q.jsxs)(Ne,{value:e.id,onSelect:()=>o(e.id),className:`justify-between`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{children:e.name}),(0,Q.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:Ft(e.tier)})]}),(0,Q.jsx)(l,{className:y(`size-4`,r===e.id?`opacity-100`:`opacity-0`)})]},e.id))},t)})}t[0]=c,t[1]=a,t[2]=u,t[3]=n,t[4]=i,t[5]=d,t[6]=r,t[7]=p,t[8]=m,t[9]=h,t[10]=g,t[11]=_,t[12]=v,t[13]=b,t[14]=x,t[15]=S,t[16]=C,t[17]=w,t[18]=T,t[19]=E}else p=t[7],m=t[8],h=t[9],g=t[10],_=t[11],v=t[12],b=t[13],x=t[14],S=t[15],C=t[16],w=t[17],T=t[18],E=t[19];if(v!==Symbol.for(`react.early_return_sentinel`))return v;let D;t[60]!==p||t[61]!==b||t[62]!==x||t[63]!==S?(D=(0,Q.jsxs)(p,{className:b,children:[x,S]}),t[60]=p,t[61]=b,t[62]=x,t[63]=S,t[64]=D):D=t[64];let O;t[65]!==m||t[66]!==D||t[67]!==C?(O=(0,Q.jsxs)(m,{children:[C,D]}),t[65]=m,t[66]=D,t[67]=C,t[68]=O):O=t[68];let k;t[69]!==h||t[70]!==O||t[71]!==w?(k=(0,Q.jsx)(h,{className:w,children:O}),t[69]=h,t[70]=O,t[71]=w,t[72]=k):k=t[72];let A;return t[73]!==g||t[74]!==_||t[75]!==k||t[76]!==T||t[77]!==E?(A=(0,Q.jsxs)(g,{open:T,onOpenChange:E,children:[_,k]}),t[73]=g,t[74]=_,t[75]=k,t[76]=T,t[77]=E,t[78]=A):A=t[78],A}function Lt(e,t){return e[t.providerName]||(e[t.providerName]=[]),e[t.providerName].push(t),e}var Rt={low:`Low`,medium:`Medium`,high:`High`,xhigh:`X-High`,minimal:`Minimal`,max:`Max`};function zt(e){return Rt[e]||e.charAt(0).toUpperCase()+e.slice(1)}function Bt(e){let t=(0,$.c)(69),{variants:n,selectedVariant:r,onChangeVariant:i,disabled:a,compact:o,iconOnly:s}=e,c=o===void 0?!1:o,u=s===void 0?!1:s,[d,f]=(0,Z.useState)(!1);if(!n||Object.keys(n).length===0)return null;let p,m,h,g,_,v,b;if(t[0]!==i||t[1]!==r||t[2]!==n){let e=Object.keys(n),a;t[10]===i?a=t[11]:(a=e=>{i(e===`__none__`?null:e),f(!1)},t[10]=i,t[11]=a);let o=a,s;t[12]===r?s=t[13]:(s=r?zt(r):`Default`,t[12]=r,t[13]=s),h=s,m=Oe,t[14]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,Q.jsx)(Ae,{placeholder:`Search...`}),t[14]=b):b=t[14],p=ze,g=`max-h-[50vh] overflow-y-auto`;let c;t[15]===o?c=t[16]:(c=()=>o(`__none__`),t[15]=o,t[16]=c);let u;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Q.jsx)(`span`,{children:`Default`}),t[17]=u):u=t[17];let d=r===null?`opacity-100`:`opacity-0`,x;t[18]===d?x=t[19]:(x=y(`size-4`,d),t[18]=d,t[19]=x);let S;t[20]===x?S=t[21]:(S=(0,Q.jsx)(l,{className:x}),t[20]=x,t[21]=S),t[22]!==S||t[23]!==c?(_=(0,Q.jsxs)(Ne,{value:`__none__`,onSelect:c,className:`justify-between`,children:[u,S]},`__none__`),t[22]=S,t[23]=c,t[24]=_):_=t[24],v=e.map(e=>(0,Q.jsxs)(Ne,{value:e,onSelect:()=>o(e),className:`justify-between`,children:[(0,Q.jsx)(`span`,{children:zt(e)}),(0,Q.jsx)(l,{className:y(`size-4`,r===e?`opacity-100`:`opacity-0`)})]},e)),t[0]=i,t[1]=r,t[2]=n,t[3]=p,t[4]=m,t[5]=h,t[6]=g,t[7]=_,t[8]=v,t[9]=b}else p=t[3],m=t[4],h=t[5],g=t[6],_=t[7],v=t[8],b=t[9];let x;t[25]!==p||t[26]!==g||t[27]!==_||t[28]!==v?(x=(0,Q.jsxs)(p,{className:g,children:[_,v]}),t[25]=p,t[26]=g,t[27]=_,t[28]=v,t[29]=x):x=t[29];let S;t[30]!==m||t[31]!==b||t[32]!==x?(S=(0,Q.jsxs)(m,{children:[b,x]}),t[30]=m,t[31]=b,t[32]=x,t[33]=S):S=t[33];let C=S;if(u){let e;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(Ye,{className:`size-4 text-muted-foreground`}),t[34]=e):e=t[34];let n;t[35]!==a||t[36]!==d?(n=(0,Q.jsx)(Me,{asChild:!0,children:(0,Q.jsx)(q,{variant:`ghost`,size:`icon-sm`,role:`combobox`,"aria-expanded":d,"aria-label":`Select variant`,disabled:a,children:e})}),t[35]=a,t[36]=d,t[37]=n):n=t[37];let r;t[38]===C?r=t[39]:(r=(0,Q.jsx)(Ie,{className:`w-[240px] p-0`,children:C}),t[38]=C,t[39]=r);let i;return t[40]!==d||t[41]!==n||t[42]!==r?(i=(0,Q.jsxs)(Re,{open:d,onOpenChange:f,children:[n,r]}),t[40]=d,t[41]=n,t[42]=r,t[43]=i):i=t[43],i}if(c){let e,n;t[44]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Q.jsx)(Ye,{className:`size-4 flex-shrink-0 text-muted-foreground`}),e=(0,Q.jsx)(Be,{className:`size-3 shrink-0 opacity-50`}),t[44]=e,t[45]=n):(e=t[44],n=t[45]);let r;t[46]!==a||t[47]!==d?(r=(0,Q.jsx)(Me,{asChild:!0,children:(0,Q.jsxs)(q,{variant:`ghost`,size:`sm`,className:`h-8 gap-1.5 px-2 text-muted-foreground hover:bg-accent`,role:`combobox`,"aria-expanded":d,"aria-label":`Select variant`,disabled:a,children:[n,e]})}),t[46]=a,t[47]=d,t[48]=r):r=t[48];let i;t[49]===C?i=t[50]:(i=(0,Q.jsx)(Ie,{className:`w-[240px] p-0`,children:C}),t[49]=C,t[50]=i);let o;return t[51]!==d||t[52]!==r||t[53]!==i?(o=(0,Q.jsxs)(Re,{open:d,onOpenChange:f,children:[r,i]}),t[51]=d,t[52]=r,t[53]=i,t[54]=o):o=t[54],o}let w;t[55]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,Q.jsx)(Ye,{className:`size-4 flex-shrink-0 text-muted-foreground`}),t[55]=w):w=t[55];let T;t[56]===h?T=t[57]:(T=(0,Q.jsx)(`span`,{className:`truncate`,children:h}),t[56]=h,t[57]=T);let E;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,Q.jsx)(Be,{className:`size-3 shrink-0 opacity-50`}),t[58]=E):E=t[58];let D;t[59]!==a||t[60]!==d||t[61]!==T?(D=(0,Q.jsx)(Me,{asChild:!0,children:(0,Q.jsxs)(q,{variant:`ghost`,size:`sm`,className:`h-8 gap-1.5 px-2 text-muted-foreground hover:bg-accent`,role:`combobox`,"aria-expanded":d,"aria-label":`Select variant`,disabled:a,children:[w,T,E]})}),t[59]=a,t[60]=d,t[61]=T,t[62]=D):D=t[62];let O;t[63]===C?O=t[64]:(O=(0,Q.jsx)(Ie,{className:`w-[240px] p-0`,children:C}),t[63]=C,t[64]=O);let k;return t[65]!==d||t[66]!==D||t[67]!==O?(k=(0,Q.jsxs)(Re,{open:d,onOpenChange:f,children:[D,O]}),t[65]=d,t[66]=D,t[67]=O,t[68]=k):k=t[68],k}function Vt(e){let t=(0,$.c)(66),{preconfigs:n,selectedPreconfigId:r,onChangePreconfig:i,disabled:a,compact:o,iconOnly:s}=e,c=o===void 0?!1:o,u=s===void 0?!1:s,[d,f]=(0,Z.useState)(!1),p;if(t[0]!==n||t[1]!==r){let e;t[3]===r?e=t[4]:(e=e=>e.id===r,t[3]=r,t[4]=e),p=n.find(e),t[0]=n,t[1]=r,t[2]=p}else p=t[2];let m=p,h;t[5]===i?h=t[6]:(h=e=>{i(e),f(!1)},t[5]=i,t[6]=h);let g=h;if(u){let e;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(X,{className:`size-4 text-muted-foreground`}),t[7]=e):e=t[7];let i;t[8]!==a||t[9]!==d?(i=(0,Q.jsx)(Me,{asChild:!0,children:(0,Q.jsx)(q,{variant:`ghost`,size:`icon-sm`,role:`combobox`,"aria-expanded":d,"aria-label":`Select config`,disabled:a,children:e})}),t[8]=a,t[9]=d,t[10]=i):i=t[10];let o;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Q.jsx)(Ae,{placeholder:`Search config...`}),t[11]=o):o=t[11];let s;if(t[12]!==g||t[13]!==n||t[14]!==r){let e;t[16]!==g||t[17]!==r?(e=e=>(0,Q.jsxs)(Ne,{onSelect:()=>g(e.id),className:`justify-between`,children:[(0,Q.jsxs)(`span`,{children:[e.name,e.isDefault&&(0,Q.jsx)(`span`,{className:`ml-1 text-muted-foreground text-xs`,children:`(default)`})]}),(0,Q.jsx)(l,{className:y(`size-4`,r===e.id?`opacity-100`:`opacity-0`)})]},e.id),t[16]=g,t[17]=r,t[18]=e):e=t[18],s=n.map(e),t[12]=g,t[13]=n,t[14]=r,t[15]=s}else s=t[15];let c;t[19]===s?c=t[20]:(c=(0,Q.jsx)(Ie,{className:`w-[240px] p-0`,children:(0,Q.jsxs)(Oe,{children:[o,(0,Q.jsx)(ze,{className:`max-h-[50vh] overflow-y-auto`,children:s})]})}),t[19]=s,t[20]=c);let u;return t[21]!==d||t[22]!==i||t[23]!==c?(u=(0,Q.jsxs)(Re,{open:d,onOpenChange:f,children:[i,c]}),t[21]=d,t[22]=i,t[23]=c,t[24]=u):u=t[24],u}if(c){let e,i;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(X,{className:`size-4 flex-shrink-0 text-muted-foreground`}),i=(0,Q.jsx)(Be,{className:`size-3 shrink-0 opacity-50`}),t[25]=e,t[26]=i):(e=t[25],i=t[26]);let o;t[27]!==a||t[28]!==d?(o=(0,Q.jsx)(Me,{asChild:!0,children:(0,Q.jsxs)(q,{variant:`ghost`,size:`sm`,className:`h-8 gap-1.5 px-2 text-muted-foreground hover:bg-accent`,role:`combobox`,"aria-expanded":d,"aria-label":`Select config`,disabled:a,children:[e,i]})}),t[27]=a,t[28]=d,t[29]=o):o=t[29];let s;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Q.jsx)(Ae,{placeholder:`Search config...`}),t[30]=s):s=t[30];let c;if(t[31]!==g||t[32]!==n||t[33]!==r){let e;t[35]!==g||t[36]!==r?(e=e=>(0,Q.jsxs)(Ne,{onSelect:()=>g(e.id),className:`justify-between`,children:[(0,Q.jsxs)(`span`,{children:[e.name,e.isDefault&&(0,Q.jsx)(`span`,{className:`ml-1 text-muted-foreground text-xs`,children:`(default)`})]}),(0,Q.jsx)(l,{className:y(`size-4`,r===e.id?`opacity-100`:`opacity-0`)})]},e.id),t[35]=g,t[36]=r,t[37]=e):e=t[37],c=n.map(e),t[31]=g,t[32]=n,t[33]=r,t[34]=c}else c=t[34];let u;t[38]===c?u=t[39]:(u=(0,Q.jsx)(Ie,{className:`w-[240px] p-0`,children:(0,Q.jsxs)(Oe,{children:[s,(0,Q.jsx)(ze,{className:`max-h-[50vh] overflow-y-auto`,children:c})]})}),t[38]=c,t[39]=u);let p;return t[40]!==d||t[41]!==u||t[42]!==o?(p=(0,Q.jsxs)(Re,{open:d,onOpenChange:f,children:[o,u]}),t[40]=d,t[41]=u,t[42]=o,t[43]=p):p=t[43],p}let _;t[44]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,Q.jsx)(X,{className:`size-4 flex-shrink-0 text-muted-foreground`}),t[44]=_):_=t[44];let v=(m==null?void 0:m.name)||`Select config`,b;t[45]===v?b=t[46]:(b=(0,Q.jsx)(`span`,{className:`truncate`,children:v}),t[45]=v,t[46]=b);let x;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,Q.jsx)(Be,{className:`size-3 shrink-0 opacity-50`}),t[47]=x):x=t[47];let S;t[48]!==a||t[49]!==d||t[50]!==b?(S=(0,Q.jsx)(Me,{asChild:!0,children:(0,Q.jsxs)(q,{variant:`ghost`,size:`sm`,className:`h-8 gap-1.5 px-2 text-muted-foreground hover:bg-accent`,role:`combobox`,"aria-expanded":d,"aria-label":`Select config`,disabled:a,children:[_,b,x]})}),t[48]=a,t[49]=d,t[50]=b,t[51]=S):S=t[51];let C;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,Q.jsx)(Ae,{placeholder:`Search config...`}),t[52]=C):C=t[52];let w;if(t[53]!==g||t[54]!==n||t[55]!==r){let e;t[57]!==g||t[58]!==r?(e=e=>(0,Q.jsxs)(Ne,{onSelect:()=>g(e.id),className:`justify-between`,children:[(0,Q.jsxs)(`span`,{children:[e.name,e.isDefault&&(0,Q.jsx)(`span`,{className:`ml-1 text-muted-foreground text-xs`,children:`(default)`})]}),(0,Q.jsx)(l,{className:y(`size-4`,r===e.id?`opacity-100`:`opacity-0`)})]},e.id),t[57]=g,t[58]=r,t[59]=e):e=t[59],w=n.map(e),t[53]=g,t[54]=n,t[55]=r,t[56]=w}else w=t[56];let T;t[60]===w?T=t[61]:(T=(0,Q.jsx)(Ie,{className:`w-[240px] p-0`,children:(0,Q.jsxs)(Oe,{children:[C,(0,Q.jsx)(ze,{className:`max-h-[50vh] overflow-y-auto`,children:w})]})}),t[60]=w,t[61]=T);let E;return t[62]!==d||t[63]!==T||t[64]!==S?(E=(0,Q.jsxs)(Re,{open:d,onOpenChange:f,children:[S,T]}),t[62]=d,t[63]=T,t[64]=S,t[65]=E):E=t[65],E}function Ht(e){switch(e){case`uncontrolled`:return{icon:J,tooltip:`No active controller`,label:`No client currently controls this session.`,ariaLabel:`Session control: no active controller`,variant:`ghost`,iconClass:`text-muted-foreground/60`};case`controller`:return{icon:J,tooltip:`You control this session`,label:`You are controlling this session.`,ariaLabel:`Session control: you control this session`,variant:`ghost`,iconClass:`text-muted-foreground`};case`observer`:return{icon:le,tooltip:`Controlled on another device`,label:`Another client is controlling this session.`,ariaLabel:`Session control: controlled on another device`,variant:`ghost`,iconClass:`text-muted-foreground`};case`takeover_controller`:return{icon:it,tooltip:`Another client requested control`,label:`Another client wants to take control of this session.`,ariaLabel:`Session control: takeover requested`,variant:`ghost`,iconClass:`text-orange-500`};case`takeover_requester`:return{icon:it,tooltip:`Takeover request pending`,label:`Your control request is waiting for approval.`,ariaLabel:`Session control: takeover request pending`,variant:`ghost`,iconClass:`text-orange-500`};case`grace`:return{icon:ft,tooltip:`Waiting for previous controller to reconnect`,label:`The previous controller may still reconnect.`,ariaLabel:`Session control: waiting for reconnect`,variant:`ghost`,iconClass:`text-yellow-500`}}}function Ut(e){let t=(0,$.c)(54),{uiState:n,sessionId:r,pendingRequesterClientId:i,onClaimControl:a,onReleaseControl:o,onRequestTakeover:s,onRespondTakeover:c}=e,l;t[0]===n?l=t[1]:(l=Ht(n),t[0]=n,t[1]=l);let u=l,d=u.icon;if(!(n===`uncontrolled`&&a||n===`controller`&&o||n===`observer`&&s||n===`takeover_controller`&&c)){let e=`size-4 ${u.iconClass}`,n;t[2]!==d||t[3]!==e?(n=(0,Q.jsx)(d,{className:e}),t[2]=d,t[3]=e,t[4]=n):n=t[4];let r;t[5]!==u.ariaLabel||t[6]!==n?(r=(0,Q.jsx)(E,{asChild:!0,children:(0,Q.jsx)(q,{variant:`ghost`,size:`sm`,className:`h-8 w-8 p-0 hover:bg-accent`,"aria-label":u.ariaLabel,children:n})}),t[5]=u.ariaLabel,t[6]=n,t[7]=r):r=t[7];let i;t[8]===u.tooltip?i=t[9]:(i=(0,Q.jsx)(F,{children:u.tooltip}),t[8]=u.tooltip,t[9]=i);let a;return t[10]!==r||t[11]!==i?(a=(0,Q.jsxs)(w,{children:[r,i]}),t[10]=r,t[11]=i,t[12]=a):a=t[12],a}let f=`size-4 ${u.iconClass}`,p;t[13]!==d||t[14]!==f?(p=(0,Q.jsx)(d,{className:f}),t[13]=d,t[14]=f,t[15]=p):p=t[15];let m;t[16]!==u.ariaLabel||t[17]!==u.variant||t[18]!==p?(m=(0,Q.jsx)(E,{asChild:!0,children:(0,Q.jsx)(C,{asChild:!0,children:(0,Q.jsx)(q,{variant:u.variant,size:`sm`,className:`h-8 w-8 p-0 hover:bg-accent`,"aria-label":u.ariaLabel,children:p})})}),t[16]=u.ariaLabel,t[17]=u.variant,t[18]=p,t[19]=m):m=t[19];let h;t[20]===u.tooltip?h=t[21]:(h=(0,Q.jsx)(F,{children:u.tooltip}),t[20]=u.tooltip,t[21]=h);let g;t[22]!==m||t[23]!==h?(g=(0,Q.jsxs)(w,{children:[m,h]}),t[22]=m,t[23]=h,t[24]=g):g=t[24];let _;t[25]===u.label?_=t[26]:(_=(0,Q.jsx)(j,{children:u.label}),t[25]=u.label,t[26]=_);let y;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,Q.jsx)(H,{}),t[27]=y):y=t[27];let b;t[28]!==a||t[29]!==r||t[30]!==n?(b=n===`uncontrolled`&&a&&(0,Q.jsxs)(x,{onClick:()=>a(r),children:[(0,Q.jsx)(J,{className:`size-4`}),`Claim control`]}),t[28]=a,t[29]=r,t[30]=n,t[31]=b):b=t[31];let S;t[32]!==o||t[33]!==r||t[34]!==n?(S=n===`controller`&&o&&(0,Q.jsxs)(x,{onClick:()=>o(r),children:[(0,Q.jsx)(J,{className:`size-4`}),`Release control`]}),t[32]=o,t[33]=r,t[34]=n,t[35]=S):S=t[35];let T;t[36]!==s||t[37]!==r||t[38]!==n?(T=n===`observer`&&s&&(0,Q.jsxs)(x,{onClick:()=>s(r),children:[(0,Q.jsx)(it,{className:`size-4`}),`Request control`]}),t[36]=s,t[37]=r,t[38]=n,t[39]=T):T=t[39];let D;t[40]!==c||t[41]!==i||t[42]!==r||t[43]!==n?(D=n===`takeover_controller`&&c&&i&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(x,{onClick:()=>c(r,i,`approve`),children:[(0,Q.jsx)(J,{className:`size-4 text-green-600`}),`Approve`]}),(0,Q.jsxs)(x,{variant:`destructive`,onClick:()=>c(r,i,`deny`),children:[(0,Q.jsx)(J,{className:`size-4`}),`Deny`]})]}),t[40]=c,t[41]=i,t[42]=r,t[43]=n,t[44]=D):D=t[44];let O;t[45]!==S||t[46]!==T||t[47]!==D||t[48]!==_||t[49]!==b?(O=(0,Q.jsxs)(z,{align:`end`,sideOffset:4,className:`w-56`,children:[_,y,b,S,T,D]}),t[45]=S,t[46]=T,t[47]=D,t[48]=_,t[49]=b,t[50]=O):O=t[50];let k;return t[51]!==O||t[52]!==g?(k=(0,Q.jsxs)(v,{children:[g,O]}),t[51]=O,t[52]=g,t[53]=k):k=t[53],k}function Wt(e,t){return!e||e===`uncontrolled`?`uncontrolled`:e===`grace`?`grace`:e===`takeover_requested`?t?`takeover_controller`:`takeover_requester`:e===`controlled`?t?`controller`:`observer`:`uncontrolled`}function Gt(e){var t;let n=(0,$.c)(110),{session:r,preconfigs:i,models:a,usage:o,modelName:s,onChangePreconfig:c,onChangeModel:l,onChangeVariant:u,onRename:d,onNavigateBack:p,isStreaming:m,onInterrupt:h,onCompact:_,isCompacting:v,canCompact:y,selectedVariant:b,variants:x,onClaimControl:S,onReleaseControl:C,onRequestTakeover:T,onRespondTakeover:D}=e,[O,k]=(0,Z.useState)(!1),[A,j]=(0,Z.useState)(r.title||``),N=(0,Z.useRef)(null),P=f(),I=ee(),L;n[0]===r.id?L=n[1]:(L=e=>e.controlBySessionId[r.id],n[0]=r.id,n[1]=L);let R=ue(L),z=ge(Kt),B=(R==null?void 0:R.status)===`controlled`||(R==null?void 0:R.status)===`takeover_requested`,H=B&&R.controllerClientId===z,U=B&&R.controllerClientId!==z,W=R==null?void 0:R.status,G;n[2]!==H||n[3]!==W?(G=Wt(W,H),n[2]=H,n[3]=W,n[4]=G):G=n[4];let K=G,te,J;n[5]===O?(te=n[6],J=n[7]):(te=()=>{O&&N.current&&(N.current.focus(),N.current.select())},J=[O],n[5]=O,n[6]=te,n[7]=J),(0,Z.useEffect)(te,J);let Y;n[8]===r.title?Y=n[9]:(Y=()=>{j(r.title||``),k(!0)},n[8]=r.title,n[9]=Y);let re=Y,ie;n[10]!==A||n[11]!==d||n[12]!==r.id||n[13]!==r.title?(ie=()=>{let e=A.trim();e&&e!==r.title&&d(r.id,e),k(!1)},n[10]=A,n[11]=d,n[12]=r.id,n[13]=r.title,n[14]=ie):ie=n[14];let ae=ie,se;n[15]!==ae||n[16]!==r.title?(se=e=>{e.key===`Enter`?ae():e.key===`Escape`&&(j(r.title||``),k(!1))},n[15]=ae,n[16]=r.title,n[17]=se):se=n[17];let ce=se,le;if(n[18]!==s||n[19]!==i||n[20]!==r.preconfigId||n[21]!==r.selectedModel){var de;le=r.selectedModel||((de=i.find(e=>e.id===r.preconfigId))==null?void 0:de.model)||s,n[18]=s,n[19]=i,n[20]=r.preconfigId,n[21]=r.selectedModel,n[22]=le}else le=n[22];let fe=le,pe;if(n[23]!==a||n[24]!==fe){let e;n[26]===fe?e=n[27]:(e=e=>e.id===fe,n[26]=fe,n[27]=e),pe=a.find(e),n[23]=a,n[24]=fe,n[25]=pe}else pe=n[25];let me=pe,he=me==null?void 0:me.contextWindow,X;n[28]!==p||n[29]!==r.parentId?(X=r.parentId&&p&&(0,Q.jsxs)(q,{variant:`ghost`,size:`sm`,onClick:p,className:`h-7`,children:[(0,Q.jsx)(oe,{className:`size-4`,"data-icon":`inline-start`}),`Back`]}),n[28]=p,n[29]=r.parentId,n[30]=X):X=n[30];let _e;n[31]!==A||n[32]!==ce||n[33]!==re||n[34]!==ae||n[35]!==O||n[36]!==r.title?(_e=O?(0,Q.jsx)(`input`,{ref:N,type:`text`,value:A,onChange:e=>j(e.target.value),onBlur:ae,onKeyDown:ce,className:`text-base font-semibold bg-background border border-primary rounded px-2 py-0.5 outline-none min-w-0 flex-1`,autoFocus:!0}):(0,Q.jsx)(`h2`,{className:`text-base font-semibold cursor-pointer px-2 py-0.5 -mx-2 rounded hover:bg-accent transition-colors truncate min-w-0`,onDoubleClick:re,children:r.title||`Untitled Session`}),n[31]=A,n[32]=ce,n[33]=re,n[34]=ae,n[35]=O,n[36]=r.title,n[37]=_e):_e=n[37];let ve;n[38]!==he||n[39]!==P||n[40]!==s||n[41]!==o.completionTokens||n[42]!==o.promptTokens||n[43]!==o.totalTokens?(ve=(0,Q.jsx)(Pt,{promptTokens:o.promptTokens,completionTokens:o.completionTokens,totalTokens:o.totalTokens,contextWindow:he,modelName:s,compact:P}),n[38]=he,n[39]=P,n[40]=s,n[41]=o.completionTokens,n[42]=o.promptTokens,n[43]=o.totalTokens,n[44]=ve):ve=n[44];let ye;n[45]===r.status?ye=n[46]:(ye=r.status===`closed`&&(0,Q.jsxs)(V,{variant:`secondary`,children:[(0,Q.jsx)(ne,{className:`size-3`,"data-icon":`inline-start`}),`Archived`]}),n[45]=r.status,n[46]=ye);let be;n[47]!==X||n[48]!==_e||n[49]!==ve||n[50]!==ye?(be=(0,Q.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0 flex-1`,children:[X,_e,ve,ye]}),n[47]=X,n[48]=_e,n[49]=ve,n[50]=ye,n[51]=be):be=n[51];let xe;n[52]===Symbol.for(`react.memo_cache_sentinel`)?(xe=(0,Q.jsx)(g,{className:`md:hidden`}),n[52]=xe):xe=n[52];let Se=r.status===`closed`||!!r.parentId||U,Ce;n[53]!==I||n[54]!==P||n[55]!==a||n[56]!==l||n[57]!==fe||n[58]!==Se?(Ce=(0,Q.jsx)(It,{models:a,selectedModelId:fe,onChangeModel:l,disabled:Se,iconOnly:P,compact:I}),n[53]=I,n[54]=P,n[55]=a,n[56]=l,n[57]=fe,n[58]=Se,n[59]=Ce):Ce=n[59];let we=r.status===`closed`||!!r.parentId||U,Te;n[60]!==I||n[61]!==P||n[62]!==u||n[63]!==b||n[64]!==we||n[65]!==x?(Te=(0,Q.jsx)(Bt,{variants:x,selectedVariant:b,onChangeVariant:u,disabled:we,iconOnly:P,compact:I}),n[60]=I,n[61]=P,n[62]=u,n[63]=b,n[64]=we,n[65]=x,n[66]=Te):Te=n[66];let Ee=r.status===`closed`||!!r.parentId||U,De;n[67]!==I||n[68]!==P||n[69]!==c||n[70]!==i||n[71]!==r.preconfigId||n[72]!==Ee?(De=(0,Q.jsx)(Vt,{preconfigs:i,selectedPreconfigId:r.preconfigId,onChangePreconfig:c,disabled:Ee,iconOnly:P,compact:I}),n[67]=I,n[68]=P,n[69]=c,n[70]=i,n[71]=r.preconfigId,n[72]=Ee,n[73]=De):De=n[73];let Oe;n[74]===Symbol.for(`react.memo_cache_sentinel`)?(Oe=(0,Q.jsx)(g,{orientation:`vertical`,className:`hidden md:block`}),n[74]=Oe):Oe=n[74];let ke;if(n[75]!==(R==null||(t=R.pendingTakeover)==null?void 0:t.requestedByClientId)||n[76]!==K||n[77]!==z||n[78]!==S||n[79]!==C||n[80]!==T||n[81]!==D||n[82]!==r.id){var Ae,je;ke=z&&(0,Q.jsx)(Ut,{uiState:K,sessionId:r.id,pendingRequesterClientId:R==null||(Ae=R.pendingTakeover)==null?void 0:Ae.requestedByClientId,onClaimControl:S,onReleaseControl:C,onRequestTakeover:T,onRespondTakeover:D}),n[75]=R==null||(je=R.pendingTakeover)==null?void 0:je.requestedByClientId,n[76]=K,n[77]=z,n[78]=S,n[79]=C,n[80]=T,n[81]=D,n[82]=r.id,n[83]=ke}else ke=n[83];let Me;n[84]!==y||n[85]!==v||n[86]!==m||n[87]!==_?(Me=_&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(w,{children:[(0,Q.jsx)(E,{asChild:!0,children:(0,Q.jsx)(q,{variant:`ghost`,size:`sm`,className:`h-8 w-8 p-0 text-muted-foreground hover:bg-accent`,onClick:_,disabled:m||v||!y,children:(0,Q.jsx)(st,{className:`size-4`})})}),(0,Q.jsx)(F,{children:v?`Compacting...`:`Compact older messages`})]}),(0,Q.jsx)(g,{orientation:`vertical`,className:`hidden md:block`})]}),n[84]=y,n[85]=v,n[86]=m,n[87]=_,n[88]=Me):Me=n[88];let Ne=m?`destructive`:`ghost`,Pe=`h-8 w-8 p-0 hover:bg-accent${m?``:` text-muted-foreground opacity-60 hover:opacity-100`}`,Fe=!h||U,Ie;n[89]===Symbol.for(`react.memo_cache_sentinel`)?(Ie=(0,Q.jsx)(He,{className:`size-4`}),n[89]=Ie):Ie=n[89];let Le;n[90]!==h||n[91]!==Ne||n[92]!==Pe||n[93]!==Fe?(Le=(0,Q.jsx)(E,{asChild:!0,children:(0,Q.jsx)(q,{variant:Ne,size:`sm`,className:Pe,onClick:h,disabled:Fe,children:Ie})}),n[90]=h,n[91]=Ne,n[92]=Pe,n[93]=Fe,n[94]=Le):Le=n[94];let Re=m?`Interrupt operation`:`Interrupt`,ze;n[95]===Re?ze=n[96]:(ze=(0,Q.jsx)(F,{children:Re}),n[95]=Re,n[96]=ze);let Be;n[97]!==Le||n[98]!==ze?(Be=(0,Q.jsxs)(w,{children:[Le,ze]}),n[97]=Le,n[98]=ze,n[99]=Be):Be=n[99];let Ve;n[100]!==Ce||n[101]!==Te||n[102]!==De||n[103]!==ke||n[104]!==Me||n[105]!==Be?(Ve=(0,Q.jsxs)(`div`,{className:`flex items-center gap-3 sm:gap-4 flex-wrap md:flex-nowrap shrink-0`,children:[Ce,Te,De,Oe,ke,Me,Be]}),n[100]=Ce,n[101]=Te,n[102]=De,n[103]=ke,n[104]=Me,n[105]=Be,n[106]=Ve):Ve=n[106];let Ue;return n[107]!==be||n[108]!==Ve?(Ue=(0,Q.jsx)(`header`,{className:`flex flex-col border-b border-border bg-card`,children:(0,Q.jsx)(M,{delayDuration:300,children:(0,Q.jsxs)(`div`,{className:`flex flex-col md:flex-row md:items-center md:justify-between px-4 py-1 gap-1`,children:[be,xe,Ve]})})}),n[107]=be,n[108]=Ve,n[109]=Ue):Ue=n[109],Ue}function Kt(e){return e.clientId}function qt(e){let t=(0,$.c)(25),{prompts:n,query:r,selectedIndex:i,onSelect:a}=e,o,s,c,l;if(t[0]!==a||t[1]!==n||t[2]!==r||t[3]!==i){l=Symbol.for(`react.early_return_sentinel`);bb0:{let e;if(t[8]===r?e=t[9]:(e=e=>e.name.toLowerCase().includes(r.toLowerCase()),t[8]=r,t[9]=e),o=n.filter(e),o.length===0){let e;t[10]===r?e=t[11]:(e=(0,Q.jsxs)(`div`,{className:`p-2 text-xs text-muted-foreground`,children:[`No prompts matching "/`,r,`"`]}),t[10]=r,t[11]=e),l=e;break bb0}s=`p-1`;let u;t[12]!==a||t[13]!==i?(u=(e,t)=>(0,Q.jsxs)(`button`,{onClick:()=>a(e),className:y(`flex items-center gap-2 w-full px-2 py-1.5 rounded text-sm text-left`,`hover:bg-muted`,t===i&&`bg-primary/20 text-primary font-medium ring-1 ring-primary/50`),children:[(0,Q.jsx)(ot,{className:`w-4 h-4 text-muted-foreground flex-shrink-0`}),(0,Q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`font-mono text-xs`,children:[`/`,e.name]}),(0,Q.jsx)(`div`,{className:`text-xs text-muted-foreground truncate`,children:e.description})]})]},e.name),t[12]=a,t[13]=i,t[14]=u):u=t[14],c=o.map(u)}t[0]=a,t[1]=n,t[2]=r,t[3]=i,t[4]=o,t[5]=s,t[6]=c,t[7]=l}else o=t[4],s=t[5],c=t[6],l=t[7];if(l!==Symbol.for(`react.early_return_sentinel`))return l;let u=o.length===1?``:`s`,d;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Q.jsx)(`kbd`,{className:`ml-1 px-1 py-0.5 bg-muted rounded text-[10px]`,children:`↑↓`}),t[15]=d):d=t[15];let f;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Q.jsx)(`kbd`,{className:`ml-1 px-1 py-0.5 bg-muted rounded text-[10px]`,children:`↵`}),t[16]=f):f=t[16];let p;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,Q.jsx)(`kbd`,{className:`ml-1 px-1 py-0.5 bg-muted rounded text-[10px]`,children:`esc`}),t[17]=p):p=t[17];let m;t[18]!==o.length||t[19]!==u?(m=(0,Q.jsxs)(`div`,{className:`mt-1 pt-1 border-t text-xs text-muted-foreground px-2`,children:[o.length,` prompt`,u,` •`,d,` navigate`,f,` select`,p,` close`]}),t[18]=o.length,t[19]=u,t[20]=m):m=t[20];let h;return t[21]!==s||t[22]!==c||t[23]!==m?(h=(0,Q.jsxs)(`div`,{className:s,children:[c,m]}),t[21]=s,t[22]=c,t[23]=m,t[24]=h):h=t[24],h}function Jt(e){let t=(0,$.c)(26),{id:n,kind:r,filename:i,size:a,previewUrl:o,isUploading:s,onRemove:c}=e,l=s&&`opacity-50`,u;t[0]===l?u=t[1]:(u=y(`flex items-center gap-2 px-2 py-1.5 bg-muted rounded-lg border border-border max-w-[180px]`,l),t[0]=l,t[1]=u);let d;t[2]!==i||t[3]!==r||t[4]!==o?(d=r===`image`&&o?(0,Q.jsx)(`img`,{src:o,alt:i,className:`size-8 rounded object-cover shrink-0`}):r===`image`?(0,Q.jsx)(at,{className:`size-4 text-muted-foreground shrink-0`}):(0,Q.jsx)(we,{className:`size-4 text-muted-foreground shrink-0`}),t[2]=i,t[3]=r,t[4]=o,t[5]=d):d=t[5];let f;t[6]===i?f=t[7]:(f=(0,Q.jsx)(`div`,{className:`text-xs truncate`,children:i}),t[6]=i,t[7]=f);let p;t[8]===a?p=t[9]:(p=Yt(a),t[8]=a,t[9]=p);let m;t[10]===p?m=t[11]:(m=(0,Q.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:p}),t[10]=p,t[11]=m);let h;t[12]!==f||t[13]!==m?(h=(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[f,m]}),t[12]=f,t[13]=m,t[14]=h):h=t[14];let g;t[15]!==n||t[16]!==c?(g=()=>c(n),t[15]=n,t[16]=c,t[17]=g):g=t[17];let v;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Q.jsx)(_,{className:`size-3 text-muted-foreground`}),t[18]=v):v=t[18];let b;t[19]===g?b=t[20]:(b=(0,Q.jsx)(`button`,{type:`button`,onClick:g,className:`shrink-0 p-0.5 hover:bg-accent rounded`,children:v}),t[19]=g,t[20]=b);let x;return t[21]!==b||t[22]!==u||t[23]!==d||t[24]!==h?(x=(0,Q.jsxs)(`div`,{className:u,children:[d,h,b]}),t[21]=b,t[22]=u,t[23]=d,t[24]=h,t[25]=x):x=t[25],x}function Yt(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Xt(e){let t=(0,$.c)(28),{path:n,onRemove:r,onPreview:i}=e,a;t[0]===n?a=t[1]:(a=n.split(`/`).pop()||n,t[0]=n,t[1]=a);let o=a,s;t[2]===n?s=t[3]:(s=n.slice(0,n.lastIndexOf(`/`)+1),t[2]=n,t[3]=s);let c=s,l;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Q.jsx)(we,{className:`size-4 text-primary shrink-0`}),t[4]=l):l=t[4];let u;t[5]!==i||t[6]!==n?(u=()=>i==null?void 0:i(n),t[5]=i,t[6]=n,t[7]=u):u=t[7];let d;t[8]===c?d=t[9]:(d=(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:c}),t[8]=c,t[9]=d);let f;t[10]===o?f=t[11]:(f=(0,Q.jsx)(`span`,{children:o}),t[10]=o,t[11]=f);let p;t[12]!==d||t[13]!==f?(p=(0,Q.jsxs)(`div`,{className:`text-xs truncate`,children:[d,f]}),t[12]=d,t[13]=f,t[14]=p):p=t[14];let m;t[15]!==u||t[16]!==p?(m=(0,Q.jsx)(`button`,{type:`button`,onClick:u,className:`min-w-0 flex-1 text-left cursor-pointer`,children:p}),t[15]=u,t[16]=p,t[17]=m):m=t[17];let h;t[18]!==r||t[19]!==n?(h=()=>r(n),t[18]=r,t[19]=n,t[20]=h):h=t[20];let g=`Remove ${o}`,v;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Q.jsx)(_,{className:`size-3 text-muted-foreground`}),t[21]=v):v=t[21];let y;t[22]!==g||t[23]!==h?(y=(0,Q.jsx)(`button`,{type:`button`,onClick:h,"aria-label":g,className:`shrink-0 p-0.5 hover:bg-accent rounded`,children:v}),t[22]=g,t[23]=h,t[24]=y):y=t[24];let b;return t[25]!==y||t[26]!==m?(b=(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1.5 bg-primary/15 rounded-lg border border-primary/30 max-w-[220px]`,children:[l,m,y]}),t[25]=y,t[26]=m,t[27]=b):b=t[27],b}var Zt={off:{icon:lt,iconClass:`text-muted-foreground/60`,tooltip:`Auto-approve: Off`,label:`Always ask for approval.`,ariaLabel:`Auto-approve: off`},none:{icon:J,iconClass:`text-muted-foreground`,tooltip:`Auto-approve: None`,label:`Auto-approve permissions with none risk.`,ariaLabel:`Auto-approve: none risk`},low:{icon:fe,iconClass:`text-success`,tooltip:`Auto-approve: Low`,label:`Auto-approve permissions with low risk and below.`,ariaLabel:`Auto-approve: low risk and below`},medium:{icon:fe,iconClass:`text-warning`,tooltip:`Auto-approve: Medium`,label:`Auto-approve permissions with medium risk and below.`,ariaLabel:`Auto-approve: medium risk and below`},high:{icon:ye,iconClass:`text-destructive`,tooltip:`Auto-approve: High`,label:`Auto-approve permissions with high risk and below.`,ariaLabel:`Auto-approve: high risk and below`}},Qt=[`off`,`none`,`low`,`medium`,`high`];function $t(e){switch(e){case`off`:return``;case`none`:return`text-muted-foreground`;case`low`:return`text-success`;case`medium`:return`text-warning`;case`high`:return`text-destructive`}}function en(e){var t;let n=(0,$.c)(35),{sessionId:r,disabled:i}=e,a=B(nn),o=B(tn),s=(t=a[r])==null?`low`:t,c=Zt[s],l=c.icon;if(i){let e=`size-4 ${c.iconClass}`,t;n[0]!==l||n[1]!==e?(t=(0,Q.jsx)(l,{className:e}),n[0]=l,n[1]=e,n[2]=t):t=n[2];let r;n[3]!==c.ariaLabel||n[4]!==t?(r=(0,Q.jsx)(E,{asChild:!0,children:(0,Q.jsx)(q,{variant:`ghost`,size:`sm`,className:`h-8 w-8 p-0 hover:bg-accent`,disabled:!0,"aria-label":c.ariaLabel,children:t})}),n[3]=c.ariaLabel,n[4]=t,n[5]=r):r=n[5];let i;n[6]===c.tooltip?i=n[7]:(i=(0,Q.jsx)(F,{children:c.tooltip}),n[6]=c.tooltip,n[7]=i);let a;return n[8]!==r||n[9]!==i?(a=(0,Q.jsx)(M,{delayDuration:300,children:(0,Q.jsxs)(w,{children:[r,i]})}),n[8]=r,n[9]=i,n[10]=a):a=n[10],a}let u=`size-4 ${c.iconClass}`,d;n[11]!==l||n[12]!==u?(d=(0,Q.jsx)(l,{className:u}),n[11]=l,n[12]=u,n[13]=d):d=n[13];let f;n[14]!==c.ariaLabel||n[15]!==d?(f=(0,Q.jsx)(E,{asChild:!0,children:(0,Q.jsx)(C,{asChild:!0,children:(0,Q.jsx)(q,{variant:`ghost`,size:`sm`,className:`h-8 w-8 p-0 hover:bg-accent`,"aria-label":c.ariaLabel,children:d})})}),n[14]=c.ariaLabel,n[15]=d,n[16]=f):f=n[16];let p;n[17]===c.tooltip?p=n[18]:(p=(0,Q.jsx)(F,{children:c.tooltip}),n[17]=c.tooltip,n[18]=p);let m;n[19]!==f||n[20]!==p?(m=(0,Q.jsx)(M,{delayDuration:300,children:(0,Q.jsxs)(w,{children:[f,p]})}),n[19]=f,n[20]=p,n[21]=m):m=n[21];let h;n[22]===c.label?h=n[23]:(h=(0,Q.jsx)(j,{children:c.label}),n[22]=c.label,n[23]=h);let g;n[24]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,Q.jsx)(H,{}),n[24]=g):g=n[24];let _;n[25]!==s||n[26]!==r||n[27]!==o?(_=Qt.map(e=>{let t=Zt[e],n=t.icon;return(0,Q.jsxs)(x,{onClick:()=>o(r,e),className:e===s?`bg-accent`:``,children:[(0,Q.jsx)(n,{className:`size-4 ${$t(e)}`}),(0,Q.jsx)(`span`,{className:`ml-2`,children:t.label})]},e)}),n[25]=s,n[26]=r,n[27]=o,n[28]=_):_=n[28];let y;n[29]!==h||n[30]!==_?(y=(0,Q.jsxs)(z,{align:`end`,sideOffset:4,className:`w-56`,children:[h,g,_]}),n[29]=h,n[30]=_,n[31]=y):y=n[31];let b;return n[32]!==m||n[33]!==y?(b=(0,Q.jsxs)(v,{children:[m,y]}),n[32]=m,n[33]=y,n[34]=b):b=n[34],b}function tn(e){return e.setAutoApproveMaxSeverity}function nn(e){return e.autoApproveBySession}function rn(e){let t=(0,$.c)(11),{debounceMs:n}=e,[r,i]=(0,Z.useState)(``),[a,o]=(0,Z.useState)(!1),s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=[],t[0]=s):s=t[0];let[c,l]=(0,Z.useState)(s),u;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(u=e=>{let t={type:`file`,path:e.path,display:e.name};return l(e=>[...e,t]),o(!1),i(``),t},t[1]=u):u=t[1];let d=u,f=an,p;t[2]===c?p=t[3]:(p=e=>{let t=/@([^\s@]+)/g,n=[],r;for(;(r=t.exec(e))!==null;){let e=r[1];c.some(t=>t.path===e)&&!n.some(t=>t.path===e)&&n.push({type:`file`,path:e,display:e.split(`/`).pop()||e})}return n},t[2]=c,t[3]=p);let m=p,h;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(h=()=>l([]),t[4]=h):h=t[4];let g;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(g=e=>{l(t=>t.filter(t=>t.path!==e))},t[5]=g):g=t[5];let _;return t[6]!==m||t[7]!==c||t[8]!==r||t[9]!==a?(_={query:r,setQuery:i,showAutocomplete:a,setShowAutocomplete:o,mentions:c,handleFileSelect:d,insertMention:f,extractMentions:m,clearMentions:h,removeMention:g},t[6]=m,t[7]=c,t[8]=r,t[9]=a,t[10]=_):_=t[10],_}function an(e,t,n){let r=e.lastIndexOf(`@`,t);return r===-1?{text:e,cursorPos:t}:{text:e.slice(0,r)+`@${n.path}`+e.slice(t),cursorPos:r+n.path.length+1}}function on(e){return`${c}${e}`}function sn(e,t){if(!(typeof window>`u`))try{localStorage.setItem(on(e),JSON.stringify({text:t,updatedAt:Date.now()}))}catch(e){console.warn(`Error saving draft:`,e)}}function cn(e){if(typeof window>`u`)return``;try{let t=localStorage.getItem(on(e));if(t===null)return``;let n=JSON.parse(t);return typeof n.text!=`string`||typeof n.updatedAt!=`number`||Date.now()-n.updatedAt>2592e6?(localStorage.removeItem(on(e)),``):n.text}catch{return``}}function ln(e){if(!(typeof window>`u`))try{localStorage.removeItem(on(e))}catch(e){console.warn(`Error clearing draft:`,e)}}function un(){A()}function dn(e){let t=(0,$.c)(12),[n,r]=(0,Z.useState)(``),i=(0,Z.useRef)(void 0),a=(0,Z.useRef)(``),o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=[],t[0]=o):o=t[0],(0,Z.useEffect)(fn,o);let s;t[1]===e?s=t[2]:(s=t=>{r(t),a.current=t,e!==void 0&&(t===``?ln(e):sn(e,t))},t[1]=e,t[2]=s);let c=s,l;t[3]===e?l=t[4]:(l=()=>{r(``),a.current=``,e!==void 0&&ln(e)},t[3]=e,t[4]=l);let u=l,d,f;t[5]===e?(d=t[6],f=t[7]):(d=()=>{let t=i.current;if(t!==void 0&&t!==e){let e=a.current;e!==``&&sn(t,e)}if(e!==void 0){let t=cn(e);a.current=t,r(t)}else a.current=``,r(``);i.current=e},f=[e],t[5]=e,t[6]=d,t[7]=f),(0,Z.useEffect)(d,f);let p;return t[8]!==u||t[9]!==n||t[10]!==c?(p={input:n,setInput:c,clearInput:u},t[8]=u,t[9]=n,t[10]=c,t[11]=p):p=t[11],p}function fn(){un()}function pn(e,t){return t?e.content.includes(`ARG`)?e.content.replace(`ARG`,t):`${e.content}\n${t}`:e.content}function mn(e){let t=e.trimStart();if(!t.startsWith(`/`))return null;let n=t.indexOf(` `);return n===-1?{command:t.slice(1),rest:``}:{command:t.slice(1,n),rest:t.slice(n+1).trim()}}var hn=(0,Z.forwardRef)(function({onSendMessage:e,disabled:t,isStreaming:n,onStopStreaming:r,placeholder:i=`Type a message...`,workspaceId:a,sdkClient:o,prompts:s=[],sessionId:c,modelSupportsImage:l},u){let{input:d,setInput:f,clearInput:p}=dn(c),[m,h]=(0,Z.useState)(0),[g,_]=(0,Z.useState)([]),[v,b]=(0,Z.useState)(0),[x,S]=(0,Z.useState)(`none`),[C,w]=(0,Z.useState)(null),[T,E]=(0,Z.useState)(``),[D,O]=(0,Z.useState)([]),[k,A]=(0,Z.useState)(!1),j=(0,Z.useRef)(null),N=(0,Z.useRef)(null);(0,Z.useImperativeHandle)(u,()=>({focus:()=>{var e;return(e=j.current)==null?void 0:e.focus()}}),[]);let{query:P,setQuery:F,showAutocomplete:L,setShowAutocomplete:R,mentions:z,handleFileSelect:V,insertMention:H,clearMentions:U,removeMention:W}=rn({workspaceId:a||``}),G=B(e=>e.openFilePreview),K=I(e=>e.activeWorkspace);(0,Z.useEffect)(()=>{if(z.length===0)return;let e=new Set(z.map(e=>e.path)),t=/@([^\s@]+)/g,n,r=new Set;for(;(n=t.exec(d))!==null;)e.has(n[1])&&r.add(n[1]);for(let e of z)r.has(e.path)||W(e.path)},[d,z,W]),(0,Z.useEffect)(()=>{b(0),w(null)},[g,T,s]),(0,Z.useEffect)(()=>{let e=j.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,150)}px`)},[d]);let ee=s.filter(e=>e.name.toLowerCase().includes(T.toLowerCase())),te=x===`prompts`&&s.length>0,J=x===`files`&&L&&!!a,Y=(0,Z.useCallback)(e=>{let t=e.target.value,n=e.target.selectionStart||0;f(t),h(n);let r=t.lastIndexOf(`/`,n);if(r!==-1){let e=r>0?t[r-1]:`
2
+ `,i=t.slice(r+1,n);if((e===`
3
+ `||e===` `||e===``)&&!i.includes(` `)){E(i),S(`prompts`);return}}let i=t.lastIndexOf(`@`,n);if(i!==-1){let e=t.slice(i+1,n);if(!e.includes(` `)){F(e),R(!0),S(`files`);return}}S(`none`),R(!1)},[F,R,f]),ne=(0,Z.useCallback)(e=>{let t=H(d,m,V(e));f(t.text),S(`none`),R(!1),_([]),setTimeout(()=>{j.current&&(j.current.focus(),j.current.setSelectionRange(t.cursorPos,t.cursorPos))},0)},[d,m,V,H,R,f]),re=(0,Z.useCallback)(e=>{let t=d.lastIndexOf(`/`,m),n=d.slice(0,t),r=d.slice(t+1),i=r.indexOf(` `),a=i===-1?``:r.slice(i),o=`${n}/${e.name}${a}`,s=t+1+e.name.length+0;f(o),S(`none`),setTimeout(()=>{j.current&&(j.current.focus(),j.current.setSelectionRange(s,s))},0)},[d,m,f]),ie=(0,Z.useCallback)(()=>{for(let e of D)e.previewUrl&&URL.revokeObjectURL(e.previewUrl);O([]),p(),U()},[D,p,U]),ae=(0,Z.useCallback)(async e=>{if(!o||!c)return null;try{let t=await(o==null?void 0:o.http.attachments.upload(c,e));return{id:crypto.randomUUID(),kind:t.kind,filename:t.filename,size:t.size,previewUrl:e.type.startsWith(`image/`)?URL.createObjectURL(e):void 0,uploadedId:t.id,uploadedKind:t.kind}}catch(e){return console.error(`Upload error:`,e),null}},[o,c]),oe=(0,Z.useCallback)(e=>{O(t=>{let n=t.find(t=>t.id===e);return n!=null&&n.previewUrl&&URL.revokeObjectURL(n.previewUrl),t.filter(t=>t.id!==e)})},[]),se=(0,Z.useCallback)(e=>{let t=e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),n=RegExp(`@${t}`,`g`);f(d.replace(n,``).replace(/\s+/g,` `).trim()),W(e)},[d,f,W]),ce=(0,Z.useCallback)(e=>{K!=null&&K.id&&G({workspaceId:K.id,path:e,name:e.split(`/`).pop()||e})},[K==null?void 0:K.id,G]),le=(0,Z.useCallback)(async e=>{let t=Array.from(e);for(let e of t){if(e.size>20*1024*1024)continue;let t=e.type.startsWith(`image/`)?`image`:e.type.startsWith(`video/`)?`video`:`file`,n={id:crypto.randomUUID(),kind:t,filename:e.name,size:e.size,previewUrl:e.type.startsWith(`image/`)?URL.createObjectURL(e):void 0,isUploading:!0};O(e=>[...e,n]);let r=await ae(e);O(r?e=>e.map(e=>e.id===n.id?(e.previewUrl&&e.previewUrl!==r.previewUrl&&URL.revokeObjectURL(e.previewUrl),{...r,isUploading:!1}):e):e=>e.filter(e=>e.id!==n.id))}},[ae]),ue=(0,Z.useCallback)(e=>{var t;let n=(t=e.clipboardData)==null?void 0:t.files;n&&n.length>0&&(e.preventDefault(),le(n))},[le]),de=(0,Z.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),A(!0)},[]),fe=(0,Z.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),A(!1)},[]),pe=(0,Z.useCallback)(e=>{var t;e.preventDefault(),e.stopPropagation(),A(!1);let n=(t=e.dataTransfer)==null?void 0:t.files;n&&n.length>0&&le(n)},[le]),me=async n=>{n==null||n.preventDefault();let r=d.trim();if(!r&&D.length===0||t)return;let i=mn(d);if(i){let t=s.find(e=>e.name===i.command);if(t){let n=pn(t,i.rest),r=D.filter(e=>e.uploadedId).map(e=>({id:e.uploadedId,kind:e.uploadedKind}));e(n,r.length>0?r:void 0),ie();return}}let a=D.filter(e=>e.uploadedId).map(e=>({id:e.uploadedId,kind:e.uploadedKind}));e(r||``,a.length>0?a:void 0),ie()},he=e=>{if(!e.nativeEvent.isComposing){if(te&&ee.length>0)switch(e.key){case`ArrowDown`:e.preventDefault(),b(e=>Math.min(e+1,ee.length-1));return;case`ArrowUp`:e.preventDefault(),b(e=>Math.max(e-1,0));return;case`Enter`:if(e.shiftKey)return;e.preventDefault(),ee[v]&&re(ee[v]);return;case`Tab`:e.preventDefault(),ee[v]&&re(ee[v]);return;case`Escape`:e.preventDefault(),S(`none`);return}if(J&&g.length>0)switch(e.key){case`ArrowDown`:e.preventDefault(),b(e=>Math.min(e+1,g.length-1));return;case`ArrowUp`:e.preventDefault(),b(e=>Math.max(e-1,0));return;case`Enter`:e.preventDefault(),g[v]&&ne(g[v]);return;case`ArrowRight`:e.preventDefault(),w(v);return;case`ArrowLeft`:e.preventDefault(),w(null);return;case`Escape`:e.preventDefault(),R(!1),S(`none`),w(null);return;case`Tab`:e.preventDefault(),g[v]&&ne(g[v]),w(null);return}e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),me())}},ge=(0,Z.useCallback)(e=>{_(e)},[]);if(n&&r)return(0,Q.jsx)(`div`,{className:`p-4 border-t border-border bg-background`,children:(0,Q.jsxs)(`div`,{className:`flex items-center justify-center gap-3`,children:[(0,Q.jsxs)(`div`,{className:`animate-pulse flex items-center gap-2 text-muted-foreground`,children:[(0,Q.jsx)(`div`,{className:`size-2 rounded-full bg-primary animate-bounce`}),(0,Q.jsx)(`div`,{className:`size-2 rounded-full bg-primary animate-bounce [animation-delay:0.1s]`}),(0,Q.jsx)(`div`,{className:`size-2 rounded-full bg-primary animate-bounce [animation-delay:0.2s]`}),(0,Q.jsx)(`span`,{className:`text-sm ml-2`,children:`Generating...`})]}),(0,Q.jsxs)(q,{variant:`outline`,size:`sm`,onClick:r,children:[(0,Q.jsx)(He,{className:`size-4`,"data-icon":`inline-start`}),`Stop`]})]})});let X=d.trim(),_e=D.some(e=>e.isUploading),ye=X||D.length>0,be=!ye||t||_e;return(0,Q.jsx)(`form`,{onSubmit:me,onDragOver:de,onDragLeave:fe,onDrop:pe,className:y(`px-4 pt-2 pb-3 bg-background`,k&&`ring-2 ring-primary`),children:(0,Q.jsxs)(`div`,{className:y(`rounded-xl bg-input/30 overflow-hidden`,`focus-within:ring-1 focus-within:ring-ring/40`,`transition-shadow`,`border border-border`,k&&`ring-2 ring-primary border-primary`),children:[(D.length>0||!n)&&(0,Q.jsx)(`div`,{className:`flex gap-2 flex-wrap px-3 pt-3`,children:D.map(e=>(0,Q.jsx)(Jt,{id:e.id,kind:e.kind,filename:e.filename,size:e.size,previewUrl:e.previewUrl,isUploading:e.isUploading,onRemove:oe},e.id))}),D.length>0&&l===!1&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 px-3 pt-2 text-xs text-amber-600 dark:text-amber-400`,children:[(0,Q.jsx)(We,{className:`size-3 shrink-0`}),(0,Q.jsx)(`span`,{children:`This model will not inspect images directly. They will be sent as file paths instead.`})]}),z.length>0&&(0,Q.jsx)(`div`,{className:`flex gap-2 flex-wrap px-3 pt-2`,children:z.map(e=>(0,Q.jsx)(Xt,{path:e.path,onRemove:se,onPreview:ce},e.path))}),(0,Q.jsx)(`div`,{className:`relative`,children:(0,Q.jsxs)(Re,{open:te||J,onOpenChange:e=>{e||(S(`none`),R(!1),w(null))},children:[(0,Q.jsx)(Pe,{asChild:!0,children:(0,Q.jsx)(je,{ref:j,value:d,onChange:Y,onKeyDown:he,onPaste:ue,placeholder:i,disabled:t,className:y(`min-h-[52px] max-h-[200px] resize-none border-0 bg-transparent dark:bg-transparent shadow-none`,`px-3 pt-3 pb-0 chat-input-scrollbar`,`focus-visible:ring-0 focus-visible:shadow-none`,`placeholder:text-muted-foreground/60`,`disabled:bg-transparent disabled:opacity-100 dark:disabled:bg-transparent`),rows:1,"data-chat-input":`true`})}),(0,Q.jsx)(Ie,{className:y(`p-0`,J?`w-96`:`w-72`),align:`start`,side:`top`,sideOffset:8,onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>e.preventDefault(),children:J?(0,Q.jsx)(M,{children:(0,Q.jsx)(ve,{workspaceId:a||``,searchQuery:P,selectedIndex:v,tooltipIndex:C,onTooltipIndexChange:w,onSelect:ne,onFilesChange:ge,sdkClient:o})}):(0,Q.jsx)(qt,{prompts:s,query:T,selectedIndex:v,onSelect:re})})]})}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-2 pb-2 pt-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(`button`,{type:`button`,className:`flex items-center justify-center size-8 rounded-md text-muted-foreground hover:text-foreground hover:bg-accent transition-colors disabled:opacity-50 disabled:pointer-events-none`,onClick:()=>{var e;return(e=N.current)==null?void 0:e.click()},disabled:t,"aria-label":`Attach file`,children:(0,Q.jsx)(ct,{className:`size-4`})}),(0,Q.jsx)(`input`,{ref:N,type:`file`,accept:`image/*,video/*,.pdf,.doc,.docx,.txt,.csv,.json,.xml,.md`,multiple:!0,className:`hidden`,onChange:e=>{e.target.files&&le(e.target.files),e.target.value=``}}),c&&(0,Q.jsx)(en,{sessionId:c,disabled:t})]}),(0,Q.jsxs)(`div`,{className:`hidden sm:flex items-center gap-1 text-xs text-muted-foreground`,children:[(0,Q.jsx)(`kbd`,{className:`px-1.5 py-0.5 bg-muted rounded text-[10px]`,children:`/`}),(0,Q.jsx)(`span`,{children:`prompts`}),(0,Q.jsx)(`span`,{className:`mx-1`,children:`•`}),(0,Q.jsx)(`kbd`,{className:`px-1.5 py-0.5 bg-muted rounded text-[10px]`,children:`@`}),(0,Q.jsx)(`span`,{children:`files`}),(0,Q.jsx)(`span`,{className:`mx-1`,children:`•`}),(0,Q.jsx)(`kbd`,{className:`px-1.5 py-0.5 bg-muted rounded text-[10px]`,children:`Enter`}),(0,Q.jsx)(`span`,{children:`to send`}),(0,Q.jsx)(`span`,{className:`mx-1`,children:`•`}),(0,Q.jsx)(`kbd`,{className:`px-1.5 py-0.5 bg-muted rounded text-[10px]`,children:`⇧ Enter`}),(0,Q.jsx)(`span`,{children:`new line`})]}),(0,Q.jsx)(q,{type:`submit`,disabled:be,size:`icon`,className:y(`size-8 rounded-full`,ye&&!t?`bg-primary text-primary-foreground hover:bg-primary/90`:`bg-muted text-muted-foreground`),"aria-label":`Send message`,children:(0,Q.jsx)(qe,{className:`size-4`})})]})]})})});function gn(e){return e.startsWith(`https://`)?`https`:`http`}function _n(e,t){return`${gn(e)}://${e.replace(/^https?:\/\//,``)}${t}`}function vn(e){let t=(0,$.c)(3),n=(0,Z.useRef)(e),r;t[0]===e?r=t[1]:(r=()=>{n.current=e},t[0]=e,t[1]=r),(0,Z.useLayoutEffect)(r);let i;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=(...e)=>{let t=e;return n.current(...t)},t[2]=i):i=t[2],i}var yn=t(i(),1);function bn(e,t,n){var r;let i=(r=n.initialDeps)==null?[]:r,a,o=!0;function s(){var r,s,c;let l;n.key&&(r=n.debug)!=null&&r.call(n)&&(l=Date.now());let u=e();if(!(u.length!==i.length||u.some((e,t)=>i[t]!==e)))return a;i=u;let d;if(n.key&&(s=n.debug)!=null&&s.call(n)&&(d=Date.now()),a=t(...u),n.key&&(c=n.debug)!=null&&c.call(n)){let e=Math.round((Date.now()-l)*100)/100,t=Math.round((Date.now()-d)*100)/100,r=t/16,i=(e,t)=>{for(e=String(e);e.length<t;)e=` `+e;return e};console.info(`%c⏱ ${i(t,5)} /${i(e,5)} ms`,`
4
+ font-size: .6rem;
5
+ font-weight: bold;
6
+ color: hsl(${Math.max(0,Math.min(120-120*r,120))}deg 100% 31%);`,n==null?void 0:n.key)}return n!=null&&n.onChange&&!(o&&n.skipInitialOnChange)&&n.onChange(a),o=!1,a}return s.updateDeps=e=>{i=e},s}function xn(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var Sn=(e,t)=>Math.abs(e-t)<1.01,Cn=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},wn=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},Tn=e=>e,En=e=>{let t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1),r=[];for(let e=t;e<=n;e++)r.push(e);return r},Dn=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(wn(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e!=null&&e.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i(wn(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},On={passive:!0},kn=typeof window>`u`?!0:`onscrollend`in window,An=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=0,a=e.options.useScrollendEvent&&kn?()=>void 0:Cn(r,()=>{t(i,!1)},e.options.isScrollingResetDelay),o=r=>()=>{let{horizontal:o,isRtl:s}=e.options;i=o?n.scrollLeft*(s&&-1||1):n.scrollTop,a(),t(i,r)},s=o(!0),c=o(!1);n.addEventListener(`scroll`,s,On);let l=e.options.useScrollendEvent&&kn;return l&&n.addEventListener(`scrollend`,c,On),()=>{n.removeEventListener(`scroll`,s),l&&n.removeEventListener(`scrollend`,c)}},jn=(e,t,n)=>{if(t!=null&&t.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},Mn=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;let o=e+t;(a=(i=r.scrollElement)==null?void 0:i.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:o,behavior:n})},Nn=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.now=()=>{var e,t,n,r;return(e=(r=(n=(t=this.targetWindow)==null?void 0:t.performance)==null?void 0:n.now)==null?void 0:r.call(n))==null?Date.now():e},this.observer=(()=>{let e=null,t=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(e=>{e.forEach(e=>{let t=()=>{let t=e.target,n=this.indexFromElement(t);if(!t.isConnected){this.observer.unobserve(t);return}this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})}));return{disconnect:()=>{var n;(n=t())==null||n.disconnect(),e=null},observe:e=>{var n;return(n=t())==null?void 0:n.observe(e,{box:`border-box`})},unobserve:e=>{var n;return(n=t())==null?void 0:n.unobserve(e)}}})(),this.range=null,this.setOptions=e=>{Object.entries(e).forEach(([t,n])=>{n===void 0&&delete e[t]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:Tn,rangeExtractor:En,onChange:()=>{},measureElement:jn,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:`data-index`,initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,...e}},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=bn(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var e;let t=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==t){if(this.cleanup(),!t){this.maybeNotify();return}if(this.scrollElement=t,this.scrollElement&&`ownerDocument`in this.scrollElement)this.targetWindow=this.scrollElement.ownerDocument.defaultView;else{var n;this.targetWindow=(n=(e=this.scrollElement)==null?void 0:e.window)==null?null:n}this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{this.scrollAdjustments=0,this.scrollDirection=t?this.getScrollOffset()<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t,this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this.rafId=null,this.getSize=()=>{var e;return this.options.enabled?(this.scrollRect=(e=this.scrollRect)==null?this.options.initialRect:e,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0)},this.getScrollOffset=()=>{var e;return this.options.enabled?(this.scrollOffset=(e=this.scrollOffset)==null?typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset:e,this.scrollOffset):(this.scrollOffset=null,0)},this.getFurthestMeasurement=(e,t)=>{let n=new Map,r=new Map;for(let i=t-1;i>=0;i--){let t=e[i];if(n.has(t.lane))continue;let a=r.get(t.lane);if(a==null||t.end>a.end?r.set(t.lane,t):t.end<a.end&&n.set(t.lane,!0),n.size===this.options.lanes)break}return r.size===this.options.lanes?Array.from(r.values()).sort((e,t)=>e.end===t.end?e.index-t.index:e.end-t.end)[0]:void 0},this.getMeasurementOptions=bn(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes],(e,t,n,r,i,a)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMeasuredCacheIndexes=[],{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a}),{key:!1}),this.getMeasurements=bn(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a},o)=>{if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let s=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1);let c=this.measurementsCache.slice(0,s),l=Array(a).fill(void 0);for(let e=0;e<s;e++){let t=c[e];t&&(l[t.lane]=e)}for(let i=s;i<e;i++){let e=r(i),a=this.laneAssignments.get(i),s,u;if(a!==void 0&&this.options.lanes>1){s=a;let e=l[s],r=e===void 0?void 0:c[e];u=r?r.end+this.options.gap:t+n}else{let e=this.options.lanes===1?c[i-1]:this.getFurthestMeasurement(c,i);u=e?e.end+this.options.gap:t+n,s=e?e.lane:i%this.options.lanes,this.options.lanes>1&&this.laneAssignments.set(i,s)}let d=o.get(e),f=typeof d==`number`?d:this.options.estimateSize(i),p=u+f;c[i]={index:i,start:u,size:f,end:p,key:e,lane:s},l[s]=i}return this.measurementsCache=c,c},{key:!1,debug:()=>this.options.debug}),this.calculateRange=bn(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>this.range=e.length>0&&t>0?Fn({measurements:e,outerSize:t,scrollOffset:n,lanes:r}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=bn(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,n,r,i)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{var t,n;if(!this.scrollState||this.scrollState.behavior!==`smooth`)return!0;let r=(t=this.scrollState.index)==null?(n=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:n.index:t;if(r!==void 0&&this.range){let t=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),n=Math.max(0,r-t),i=Math.min(this.options.count-1,r+t);return e>=n&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e),n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{var n,r;let i=this.measurementsCache[e];if(!i)return;let a=t-((n=this.itemSizeCache.get(i.key))==null?i.size:n);a!==0&&(((r=this.scrollState)==null?void 0:r.behavior)!==`smooth`&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?i.start<this.getScrollOffset()+this.scrollAdjustments:this.shouldAdjustScrollPositionOnItemSizeChange(i,a,this))&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=a,behavior:void 0}),this.pendingMeasuredCacheIndexes.push(i.index),this.itemSizeCache=new Map(this.itemSizeCache.set(i.key,t)),this.notify(!1))},this.getVirtualItems=bn(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,i=e.length;r<i;r++){let i=t[e[r]];n.push(i)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length!==0)return xn(t[Pn(0,t.length-1,e=>xn(t[e]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if(`scrollHeight`in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`)if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t];if(t===`end`&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{let r=this.getOffsetForAlignment(e,t);this.scrollState={index:null,align:t,behavior:n,startedAt:this.now(),lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r,o=this.now();this.scrollState={index:e,align:a,behavior:n,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getScrollOffset()+e;this.scrollState={index:null,align:`start`,behavior:t,startedAt:this.now(),lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.getTotalSize=()=>{var e;let t=this.getMeasurements(),n;if(t.length===0)n=this.options.paddingStart;else if(this.options.lanes===1){var r;n=(r=(e=t[t.length-1])==null?void 0:e.end)==null?0:r}else{let e=Array(this.options.lanes).fill(null),r=t.length-1;for(;r>=0&&e.some(e=>e===null);){let n=t[r];e[n.lane]===null&&(e[n.lane]=n.end),r--}n=Math.max(...e.filter(e=>e!==null))}return Math.max(n-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(e)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId==null&&(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let e=this.scrollState.index==null?void 0:this.getOffsetForIndex(this.scrollState.index,this.scrollState.align),t=e?e[0]:this.scrollState.lastTargetOffset,n=t!==this.scrollState.lastTargetOffset;if(!n&&Sn(t,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1){this.scrollState=null;return}}else this.scrollState.stableFrames=0,n&&(this.scrollState.lastTargetOffset=t,this.scrollState.behavior=`auto`,this._scrollToOffset(t,{adjustments:void 0,behavior:`auto`}));this.scheduleScrollReconcile()}},Pn=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function Fn({measurements:e,outerSize:t,scrollOffset:n,lanes:r}){let i=e.length-1,a=t=>e[t].start;if(e.length<=r)return{startIndex:0,endIndex:i};let o=Pn(0,i,a,n),s=o;if(r===1)for(;s<i&&e[s].end<n+t;)s++;else if(r>1){let a=Array(r).fill(0);for(;s<i&&a.some(e=>e<n+t);){let t=e[s];a[t.lane]=t.end,s++}let c=Array(r).fill(n+t);for(;o>=0&&c.some(e=>e>=n);){let t=e[o];c[t.lane]=t.start,o--}o=Math.max(0,o-o%r),s=Math.min(i,s+(r-1-s%r))}return{startIndex:o,endIndex:s}}var In=typeof document<`u`?Z.useLayoutEffect:Z.useEffect;function Ln({useFlushSync:e=!0,...t}){let n=Z.useReducer(()=>({}),{})[1],r={...t,onChange:(r,i)=>{var a;e&&i?(0,yn.flushSync)(n):n(),(a=t.onChange)==null||a.call(t,r,i)}},[i]=Z.useState(()=>new Nn(r));return i.setOptions(r),In(()=>i._didMount(),[]),In(()=>i._willUpdate()),i}function Rn(e){return Ln({observeElementRect:Dn,observeElementOffset:An,scrollToFn:Mn,...e})}function zn(e){let t=(0,$.c)(50),{message:n,textContent:r,children:i,isQueued:a,onRemove:o,onRevert:s,canRevert:c,onFork:u,canFork:d,isClearAll:f}=e,p=a===void 0?!1:a,m=c===void 0?!1:c,h=d===void 0?!1:d,g=f===void 0?!1:f,[v,b]=(0,Z.useState)(!1),[x,S]=(0,Z.useState)(!1),[C,w]=(0,Z.useState)(!1),T=n.role===`user`,E;t[0]===r?E=t[1]:(E=async()=>{let e=r||``;await navigator.clipboard.writeText(e),b(!0),setTimeout(()=>b(!1),2e3)},t[0]=r,t[1]=E);let D=E,O=T?`items-end`:`items-stretch`,k;t[2]===O?k=t[3]:(k=y(`flex flex-col gap-1 animate-slide-up min-w-0`,O),t[2]=O,t[3]=k);let A=T?`mr-3`:`ml-3`,j;t[4]===A?j=t[5]:(j=y(`flex items-center gap-1.5 text-xs uppercase tracking-wide text-muted-foreground`,A),t[4]=A,t[5]=j);let M;t[6]!==h||t[7]!==m||t[8]!==v||t[9]!==D||t[10]!==p||t[11]!==T||t[12]!==n.role||t[13]!==u||t[14]!==s?(M=T?(0,Q.jsxs)(Q.Fragment,{children:[!p&&(0,Q.jsxs)(Q.Fragment,{children:[m&&s&&(0,Q.jsx)(q,{variant:`ghost`,size:`icon`,onClick:()=>S(!0),className:`size-5 text-muted-foreground hover:text-foreground`,title:`Revert to this point`,children:(0,Q.jsx)(ut,{className:`size-3`})}),h&&u&&(0,Q.jsx)(q,{variant:`ghost`,size:`icon`,onClick:()=>w(!0),className:`size-5 text-muted-foreground hover:text-foreground`,title:`Fork from this point`,children:(0,Q.jsx)(rt,{className:`size-3`})}),(0,Q.jsx)(q,{variant:`ghost`,size:`icon`,onClick:D,className:`size-5 text-muted-foreground hover:text-foreground`,children:v?(0,Q.jsx)(l,{className:`size-3`}):(0,Q.jsx)(ie,{className:`size-3`})})]}),(0,Q.jsx)(de,{className:`size-3`}),n.role]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Je,{className:`size-3`}),n.role,(0,Q.jsx)(q,{variant:`ghost`,size:`icon`,onClick:D,className:`size-5 text-muted-foreground hover:text-foreground`,children:v?(0,Q.jsx)(l,{className:`size-3`}):(0,Q.jsx)(ie,{className:`size-3`})})]}),t[6]=h,t[7]=m,t[8]=v,t[9]=D,t[10]=p,t[11]=T,t[12]=n.role,t[13]=u,t[14]=s,t[15]=M):M=t[15];let N;t[16]!==M||t[17]!==j?(N=(0,Q.jsx)(`div`,{className:j,children:M}),t[16]=M,t[17]=j,t[18]=N):N=t[18];let P=T?`rounded-2xl px-4 py-3 max-w-[90%] bg-primary text-primary-foreground rounded-br-md`:`w-full overflow-visible`,F=p&&`rounded-2xl px-4 py-3 bg-muted border-2 border-dashed border-muted-foreground/30 opacity-80`,I;t[19]!==P||t[20]!==F?(I=y(`relative group min-w-0 overflow-hidden`,P,F),t[19]=P,t[20]=F,t[21]=I):I=t[21];let L;t[22]!==p||t[23]!==o?(L=p&&(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2 mb-2 pb-2 border-b border-muted-foreground/20`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,Q.jsx)(et,{className:`size-3 animate-pulse`}),(0,Q.jsx)(`span`,{children:`Pending`})]}),o&&(0,Q.jsx)(q,{variant:`ghost`,size:`icon`,onClick:o,className:`size-6 text-muted-foreground hover:text-destructive hover:bg-destructive/10`,title:`Remove from queue`,children:(0,Q.jsx)(_,{className:`size-3`})})]}),t[22]=p,t[23]=o,t[24]=L):L=t[24];let R;t[25]===i?R=t[26]:(R=(0,Q.jsx)(`div`,{className:`min-w-0`,children:i}),t[25]=i,t[26]=R);let z;t[27]!==I||t[28]!==L||t[29]!==R?(z=(0,Q.jsxs)(`div`,{className:I,children:[L,R]}),t[27]=I,t[28]=L,t[29]=R,t[30]=z):z=t[30];let B=g?`Clear Conversation`:`Revert Conversation`,V=g?`This will delete all messages in this session, leaving it completely empty. Are you sure you want to continue?`:`This will delete this message and all messages after it. Are you sure you want to continue?`,H=g?`Clear All`:`Revert`,U;t[31]===s?U=t[32]:(U=()=>{s==null||s()},t[31]=s,t[32]=U);let W;t[33]!==x||t[34]!==B||t[35]!==V||t[36]!==H||t[37]!==U?(W=(0,Q.jsx)(re,{open:x,onOpenChange:S,title:B,description:V,confirmLabel:H,cancelLabel:`Cancel`,onConfirm:U,variant:`destructive`}),t[33]=x,t[34]=B,t[35]=V,t[36]=H,t[37]=U,t[38]=W):W=t[38];let G;t[39]===u?G=t[40]:(G=()=>{u==null||u()},t[39]=u,t[40]=G);let K;t[41]!==C||t[42]!==G?(K=(0,Q.jsx)(re,{open:C,onOpenChange:w,title:`Fork Conversation`,description:`This will create a new session with messages up to and including this point. The original session will be unchanged.`,confirmLabel:`Fork`,cancelLabel:`Cancel`,onConfirm:G}),t[41]=C,t[42]=G,t[43]=K):K=t[43];let ee;return t[44]!==N||t[45]!==z||t[46]!==W||t[47]!==K||t[48]!==k?(ee=(0,Q.jsxs)(`div`,{className:k,children:[N,z,W,K]}),t[44]=N,t[45]=z,t[46]=W,t[47]=K,t[48]=k,t[49]=ee):ee=t[49],ee}var Bn=ce.oneDark,Vn=ce.oneLight;function Hn(e){var t;let n=(t=e.split(`.`).pop())==null?void 0:t.toLowerCase();return{ts:`typescript`,tsx:`typescript`,js:`javascript`,jsx:`javascript`,json:`json`,md:`markdown`,css:`css`,html:`html`,py:`python`,go:`go`,rs:`rust`,sh:`bash`,yaml:`yaml`,yml:`yaml`}[n||``]||n||`text`}var Un=(0,Z.memo)(function(e){let t=(0,$.c)(35),{type:n,content:r,lineNumber:i,newLineNumber:o,language:s,codeTheme:c}=e,{resolvedMode:l}=a(),u=l===`dark`,d=n===`added`&&(u?`bg-green-500/20`:`bg-green-500/15`),f=n===`removed`&&(u?`bg-red-500/20`:`bg-red-500/15`),p=n===`context`&&`bg-muted/30`,m;t[0]!==d||t[1]!==f||t[2]!==p?(m=y(`flex font-mono text-xs`,d,f,p),t[0]=d,t[1]=f,t[2]=p,t[3]=m):m=t[3];let h=m,g=n===`added`&&(u?`text-green-400`:`text-green-600`),_=n===`removed`&&(u?`text-red-400`:`text-red-600`),v=n===`context`&&`text-muted-foreground/50`,b;t[4]!==g||t[5]!==_||t[6]!==v?(b=y(`font-bold w-4 select-none`,g,_,v),t[4]=g,t[5]=_,t[6]=v,t[7]=b):b=t[7];let x=b,S=u?`border-white/10`:`border-border`,C;t[8]===S?C=t[9]:(C=y(`w-10 text-right pr-2 text-muted-foreground select-none border-r`,S),t[8]=S,t[9]=C);let w=i==null?``:i,T;t[10]!==C||t[11]!==w?(T=(0,Q.jsx)(`span`,{className:C,children:w}),t[10]=C,t[11]=w,t[12]=T):T=t[12];let E=u?`border-white/10`:`border-border`,D;t[13]===E?D=t[14]:(D=y(`w-10 text-right pr-2 text-muted-foreground select-none border-r`,E),t[13]=E,t[14]=D);let O=o==null?``:o,k;t[15]!==D||t[16]!==O?(k=(0,Q.jsx)(`span`,{className:D,children:O}),t[15]=D,t[16]=O,t[17]=k):k=t[17];let A=n===`added`&&`+`,j=n===`removed`&&`-`,M=n===`context`&&` `,N;t[18]!==x||t[19]!==A||t[20]!==j||t[21]!==M?(N=(0,Q.jsxs)(`span`,{className:x,children:[A,j,M]}),t[18]=x,t[19]=A,t[20]=j,t[21]=M,t[22]=N):N=t[22];let P;t[23]!==c||t[24]!==r||t[25]!==s?(P=(0,Q.jsx)(he,{theme:c,code:r,language:s,children:Gn}),t[23]=c,t[24]=r,t[25]=s,t[26]=P):P=t[26];let F;t[27]!==N||t[28]!==P?(F=(0,Q.jsxs)(`span`,{className:`pl-2 flex-1 whitespace-pre overflow-hidden flex`,children:[N,P]}),t[27]=N,t[28]=P,t[29]=F):F=t[29];let I;return t[30]!==T||t[31]!==k||t[32]!==F||t[33]!==h?(I=(0,Q.jsxs)(`div`,{className:h,children:[T,k,F]}),t[30]=T,t[31]=k,t[32]=F,t[33]=h,t[34]=I):I=t[34],I}),Wn=(0,Z.memo)(function(e){let t=(0,$.c)(35),{hunks:n,path:r,language:i,additions:o,deletions:s}=e,[c,l]=(0,Z.useState)(!0),u;t[0]!==r||t[1]!==i?(u=i||Hn(r),t[0]=r,t[1]=i,t[2]=u):u=t[2];let d=u,f=B(Kn),m=I(qn),{resolvedMode:h}=a(),g=h===`dark`,_=g?Bn:Vn,v;t[3]!==m||t[4]!==f||t[5]!==r?(v=()=>{m&&f({workspaceId:m.id,path:r,name:r.split(`/`).pop()||r})},t[3]=m,t[4]=f,t[5]=r,t[6]=v):v=t[6];let b=v,x;t[7]===c?x=t[8]:(x=()=>l(!c),t[7]=c,t[8]=x);let S;t[9]===c?S=t[10]:(S=c?(0,Q.jsx)(Xe,{className:`size-3`}):(0,Q.jsx)(p,{className:`size-3`}),t[9]=c,t[10]=S);let C;t[11]!==x||t[12]!==S?(C=(0,Q.jsx)(`button`,{onClick:x,className:`px-1 py-1 hover:bg-muted rounded`,children:S}),t[11]=x,t[12]=S,t[13]=C):C=t[13];let w;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,Q.jsx)(De,{className:`size-3`}),t[14]=w):w=t[14];let T;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,Q.jsx)(Ee,{className:`size-2.5 opacity-0 group-hover/path:opacity-100 transition-opacity`}),t[15]=T):T=t[15];let E;t[16]!==b||t[17]!==r?(E=(0,Q.jsxs)(`button`,{type:`button`,onClick:b,className:`flex items-center gap-1 font-mono pr-2 hover:text-foreground transition-colors cursor-pointer rounded px-1 py-0.5 -mx-1 hover:bg-muted min-w-0 truncate`,title:r,children:[r,T]}),t[16]=b,t[17]=r,t[18]=E):E=t[18];let D;t[19]!==o||t[20]!==s?(D=o!==void 0&&s!==void 0&&(0,Q.jsxs)(`span`,{className:`ml-auto mr-2 text-muted-foreground`,children:[`+`,o,` -`,s]}),t[19]=o,t[20]=s,t[21]=D):D=t[21];let O;t[22]!==C||t[23]!==E||t[24]!==D?(O=(0,Q.jsxs)(`div`,{className:`group/path flex items-center gap-2 px-1 bg-muted/50 text-xs text-muted-foreground`,children:[C,w,E,D]}),t[22]=C,t[23]=E,t[24]=D,t[25]=O):O=t[25];let k;t[26]!==_||t[27]!==c||t[28]!==n||t[29]!==g||t[30]!==d?(k=c&&(0,Q.jsx)(`div`,{style:{backgroundColor:_.plain.backgroundColor||(g?`#282c34`:`#fafafa`)},children:n.map((e,t)=>(0,Q.jsx)(`div`,{className:y(`divide-y`,g?`divide-white/5`:`divide-border`),children:e.changes.map((e,t)=>(0,Q.jsx)(Un,{...e,language:d,codeTheme:_},t))},t))}),t[26]=_,t[27]=c,t[28]=n,t[29]=g,t[30]=d,t[31]=k):k=t[31];let A;return t[32]!==O||t[33]!==k?(A=(0,Q.jsx)(`div`,{className:`visualization-container max-w-full overflow-x-auto border border-border rounded-md`,children:(0,Q.jsxs)(`div`,{children:[O,k]})}),t[32]=O,t[33]=k,t[34]=A):A=t[34],A});function Gn(e){let{tokens:t,getTokenProps:n}=e;return(0,Q.jsx)(Q.Fragment,{children:t.map((e,t)=>(0,Q.jsx)(`span`,{children:e.map((e,t)=>(0,Q.jsx)(`span`,{...n({token:e})},t))},t))})}function Kn(e){return e.openFilePreview}function qn(e){return e.activeWorkspace}var Jn=ce.oneDark,Yn=ce.oneLight,Xn=20;function Zn(e){var t;let n=(t=e.split(`.`).pop())==null?void 0:t.toLowerCase();return{ts:`typescript`,tsx:`typescript`,js:`javascript`,jsx:`javascript`,json:`json`,md:`markdown`,css:`css`,html:`html`,py:`python`,go:`go`,rs:`rust`,sh:`bash`,yaml:`yaml`,yml:`yaml`}[n||``]||n||`text`}var Qn=(0,Z.memo)(e=>{let t=(0,$.c)(52),{content:n,path:r,language:i,created:o,highlightLines:s}=e,c;t[0]===s?c=t[1]:(c=s===void 0?[]:s,t[0]=s,t[1]=c);let u=c,[d,f]=(0,Z.useState)(!1),m=B($n),h=I(er),{resolvedMode:g}=a(),_=g===`dark`,v=_?Jn:Yn,b;t[2]!==h||t[3]!==m||t[4]!==r?(b=()=>{h&&m({workspaceId:h.id,path:r,name:r.split(`/`).pop()||r})},t[2]=h,t[3]=m,t[4]=r,t[5]=b):b=t[5];let x=b,S;t[6]!==i||t[7]!==r?(S=i||Zn(r),t[6]=i,t[7]=r,t[8]=S):S=t[8];let C=S,w;t[9]===u?w=t[10]:(w=new Set(u),t[9]=u,t[10]=w);let T=w,E;t[11]===n?E=t[12]:(E=n.split(`
7
+ `),t[11]=n,t[12]=E);let D=E.length,O;t[13]===d?O=t[14]:(O=()=>f(!d),t[13]=d,t[14]=O);let k;t[15]===d?k=t[16]:(k=d?(0,Q.jsx)(Xe,{className:`size-3`}):(0,Q.jsx)(p,{className:`size-3`}),t[15]=d,t[16]=k);let A;t[17]!==O||t[18]!==k?(A=(0,Q.jsx)(`button`,{onClick:O,className:`flex items-center gap-2 px-2 py-1 hover:bg-muted`,children:k}),t[17]=O,t[18]=k,t[19]=A):A=t[19];let j;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,Q.jsx)(De,{className:`size-3`}),t[20]=j):j=t[20];let M;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,Q.jsx)(Ee,{className:`size-2.5 opacity-0 group-hover/path:opacity-100 transition-opacity`}),t[21]=M):M=t[21];let N;t[22]!==x||t[23]!==r?(N=(0,Q.jsxs)(`button`,{type:`button`,onClick:x,className:`flex items-center gap-1 font-mono pr-2 hover:text-foreground transition-colors cursor-pointer rounded px-1 py-0.5 -mx-1 hover:bg-muted min-w-0 truncate`,title:r,children:[r,M]}),t[22]=x,t[23]=r,t[24]=N):N=t[24];let P;t[25]!==d||t[26]!==D?(P=!d&&(0,Q.jsxs)(`span`,{className:`text-xs text-muted-foreground/70`,children:[D,` lines`]}),t[25]=d,t[26]=D,t[27]=P):P=t[27];let F;t[28]===o?F=t[29]:(F=o===!1?(0,Q.jsxs)(`span`,{className:`flex items-center gap-1 text-warning ml-auto mr-2`,children:[(0,Q.jsx)(Te,{className:`size-3`}),`Overwrote`]}):(0,Q.jsxs)(`span`,{className:`flex items-center gap-1 text-success ml-auto mr-2`,children:[(0,Q.jsx)(l,{className:`size-3`}),`Created`]}),t[28]=o,t[29]=F);let L;t[30]!==N||t[31]!==P||t[32]!==F||t[33]!==A?(L=(0,Q.jsxs)(`div`,{className:`group/path flex items-center gap-2 px-1 bg-muted/50 text-xs text-muted-foreground`,children:[A,j,N,P,F]}),t[30]=N,t[31]=P,t[32]=F,t[33]=A,t[34]=L):L=t[34];let R;t[35]===v.plain.backgroundColor?R=t[36]:(R={backgroundColor:v.plain.backgroundColor},t[35]=v.plain.backgroundColor,t[36]=R);let z;t[37]!==d||t[38]!==T||t[39]!==_?(z=e=>{let{tokens:t,getTokenProps:n}=e;return(0,Q.jsx)(Q.Fragment,{children:(d?t:t.slice(0,Xn)).map((e,t)=>(0,Q.jsxs)(`div`,{className:`flex font-mono text-xs ${T.has(t+1)?`bg-yellow-500/20`:``}`,children:[(0,Q.jsx)(`span`,{className:y(`w-10 text-right pr-2 select-none border-r`,_?`text-muted-foreground border-white/10`:`text-muted-foreground border-border`),children:t+1}),(0,Q.jsx)(`span`,{className:`pl-2 flex-1 whitespace-pre overflow-hidden`,children:e.map((e,t)=>(0,Q.jsx)(`span`,{...n({token:e})},t))})]},t))})},t[37]=d,t[38]=T,t[39]=_,t[40]=z):z=t[40];let V;t[41]!==v||t[42]!==n||t[43]!==C||t[44]!==z?(V=(0,Q.jsx)(he,{theme:v,code:n,language:C,children:z}),t[41]=v,t[42]=n,t[43]=C,t[44]=z,t[45]=V):V=t[45];let H;t[46]!==R||t[47]!==V?(H=(0,Q.jsx)(`div`,{style:R,children:V}),t[46]=R,t[47]=V,t[48]=H):H=t[48];let U;return t[49]!==L||t[50]!==H?(U=(0,Q.jsx)(`div`,{className:`visualization-container max-w-full overflow-x-auto border border-border rounded-md`,children:(0,Q.jsxs)(`div`,{children:[L,H]})}),t[49]=L,t[50]=H,t[51]=U):U=t[51],U});function $n(e){return e.openFilePreview}function er(e){return e.activeWorkspace}function tr(e){let t=(0,$.c)(3),{message:n}=e,r=n===void 0?`Success`:n,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Q.jsx)(K,{className:`size-4`}),t[0]=i):i=t[0];let a;return t[1]===r?a=t[2]:(a=(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[i,(0,Q.jsx)(`span`,{className:`break-all`,children:r})]}),t[1]=r,t[2]=a),a}var nr={edit:nt,plus:b,trash:G,search:ke};function rr(e){let t=(0,$.c)(7),{text:n}=e,[r,i]=(0,Z.useState)(!1),a;t[0]===n?a=t[1]:(a=async()=>{await navigator.clipboard.writeText(n),i(!0),setTimeout(()=>i(!1),1500)},t[0]=n,t[1]=a);let o=a,s;t[2]===r?s=t[3]:(s=r?(0,Q.jsx)(`span`,{className:`text-success text-xs`,children:`Copied!`}):(0,Q.jsx)(ie,{className:`size-3`}),t[2]=r,t[3]=s);let c;return t[4]!==o||t[5]!==s?(c=(0,Q.jsx)(`button`,{onClick:o,className:`text-muted-foreground hover:text-foreground transition-colors`,title:`Copy path`,children:s}),t[4]=o,t[5]=s,t[6]=c):c=t[6],c}function ir(e){let t=(0,$.c)(16),{title:n,groups:r,files:i,total:a}=e,o;t[0]===i?o=t[1]:(o=i||[],t[0]=i,t[1]=o);let s;t[2]===o?s=t[3]:(s={label:`Files`,files:o,icon:void 0},t[2]=o,t[3]=s);let c=s,l;t[4]!==c||t[5]!==i||t[6]!==r?(l=r||(i?[c]:[]),t[4]=c,t[5]=i,t[6]=r,t[7]=l):l=t[7];let u=l;if(u.length===0)return null;let d;t[8]!==n||t[9]!==a?(d=n&&(0,Q.jsxs)(`div`,{className:`text-sm font-medium text-foreground`,children:[n,a!==void 0&&(0,Q.jsxs)(`span`,{className:`ml-2 text-muted-foreground`,children:[`(`,a,` files)`]})]}),t[8]=n,t[9]=a,t[10]=d):d=t[10];let f;t[11]===u?f=t[12]:(f=u.map(ar),t[11]=u,t[12]=f);let p;return t[13]!==d||t[14]!==f?(p=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[d,f]}),t[13]=d,t[14]=f,t[15]=p):p=t[15],p}function ar(e,t){return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[e.icon&&(0,Q.jsx)(`span`,{className:`flex items-center`,children:(()=>{let t=nr[e.icon];return(0,Q.jsx)(t,{className:`size-3`})})()}),(0,Q.jsx)(`span`,{children:e.label}),(0,Q.jsxs)(`span`,{className:`text-muted-foreground/50`,children:[`(`,e.files.length,`)`]})]}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-0.5 pl-5`,children:e.files.map(or)})]},t)}function or(e,t){return(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-xs group`,children:[(0,Q.jsx)(De,{className:`size-3 text-muted-foreground shrink-0`}),(0,Q.jsx)(`span`,{className:`font-mono text-foreground/80 truncate`,children:e.path}),e.line!==void 0&&(0,Q.jsxs)(`span`,{className:`text-muted-foreground shrink-0`,children:[`:`,e.line]}),e.action&&(0,Q.jsx)(`span`,{className:y(`text-xs px-1 rounded shrink-0`,e.action===`created`&&`bg-success/20 text-success`,e.action===`modified`&&`bg-warning/20 text-warning`,e.action===`deleted`&&`bg-destructive/20 text-destructive`),children:e.action}),(0,Q.jsx)(rr,{text:e.path})]},t)}function sr(e){let t=(0,$.c)(15),{command:n,stdout:r,stderr:i,exitCode:a}=e,o=a===0,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:`$ `}),t[0]=s):s=t[0];let c;t[1]===n?c=t[2]:(c=(0,Q.jsxs)(`div`,{className:`font-mono text-xs text-muted-foreground truncate flex-1 mr-2`,children:[s,(0,Q.jsx)(`span`,{className:`text-foreground`,children:n})]}),t[1]=n,t[2]=c);let l=`text-xs font-mono px-2 py-0.5 rounded ${o?`bg-muted text-muted-foreground`:`bg-red-500/20 text-red-400`}`,u;t[3]!==a||t[4]!==l?(u=(0,Q.jsxs)(`span`,{className:l,children:[`[`,a,`]`]}),t[3]=a,t[4]=l,t[5]=u):u=t[5];let d;t[6]!==c||t[7]!==u?(d=(0,Q.jsxs)(`div`,{className:`bg-muted px-3 py-2 flex items-center justify-between`,children:[c,u]}),t[6]=c,t[7]=u,t[8]=d):d=t[8];let f;t[9]!==i||t[10]!==r?(f=(r||i)&&(0,Q.jsxs)(`div`,{className:`bg-black px-3 py-2 font-mono text-xs overflow-x-auto`,children:[r&&(0,Q.jsx)(`pre`,{className:`text-gray-300 whitespace-pre-wrap`,children:r}),i&&(0,Q.jsx)(`pre`,{className:`text-red-400 whitespace-pre-wrap mt-1`,children:i})]}),t[9]=i,t[10]=r,t[11]=f):f=t[11];let p;return t[12]!==d||t[13]!==f?(p=(0,Q.jsxs)(`div`,{className:`visualization-container border border-border rounded-md overflow-hidden`,children:[d,f]}),t[12]=d,t[13]=f,t[14]=p):p=t[14],p}var cr={pending:{icon:$e,color:`text-muted-foreground`},in_progress:{icon:te,color:`text-warning`,animate:!0},completed:{icon:K,color:`text-success`},cancelled:{icon:s,color:`text-destructive`}},lr={high:{label:`high`,className:`bg-destructive/20 text-destructive`},medium:{label:``,className:``},low:{label:`low`,className:`text-muted-foreground`}};function ur(e){let t=(0,$.c)(13),{title:n,items:r}=e;if(r.length===0)return null;let i;t[0]===r?i=t[1]:(i=r.filter(mr),t[0]=r,t[1]=i);let a=i.length;r.filter(pr),r.filter(fr);let o;t[2]!==a||t[3]!==r.length||t[4]!==n?(o=(n||r.length>0)&&(0,Q.jsxs)(`div`,{className:`text-sm font-medium text-foreground`,children:[n||`Todo List`,(0,Q.jsxs)(`span`,{className:`ml-2 text-muted-foreground`,children:[`(`,r.length,`)`]}),a>0&&(0,Q.jsxs)(`span`,{className:`ml-2 text-success text-xs`,children:[a,` completed`]})]}),t[2]=a,t[3]=r.length,t[4]=n,t[5]=o):o=t[5];let s;t[6]===r?s=t[7]:(s=r.map(dr),t[6]=r,t[7]=s);let c;t[8]===s?c=t[9]:(c=(0,Q.jsx)(`div`,{className:`flex flex-col gap-1 w-full`,children:s}),t[8]=s,t[9]=c);let l;return t[10]!==o||t[11]!==c?(l=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 w-full overflow-hidden`,children:[o,c]}),t[10]=o,t[11]=c,t[12]=l):l=t[12],l}function dr(e,t){let n=cr[e.status],r=n.icon,i=lr[e.priority];return(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm min-w-0`,children:[(0,Q.jsx)(r,{className:y(`size-4 shrink-0`,n.color,n.animate&&`animate-spin`)}),(0,Q.jsx)(`span`,{className:y(`flex-1 break-all`,e.status===`completed`&&`line-through text-muted-foreground`,e.status===`cancelled`&&`text-muted-foreground`),children:e.content}),i.label&&e.priority===`high`&&(0,Q.jsx)(`span`,{className:y(`text-xs px-1.5 py-0.5 rounded shrink-0`,i.className),children:i.label}),e.priority===`low`&&e.status!==`completed`&&e.status!==`cancelled`&&(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground shrink-0`,children:i.label})]},t)}function fr(e){return e.status===`pending`}function pr(e){return e.status===`in_progress`}function mr(e){return e.status===`completed`}var hr=(0,Z.memo)(function(e){let t=(0,$.c)(38),{visualization:n}=e;if(!n)return null;switch(n.type){case`diff`:{let e;return t[0]!==n.additions||t[1]!==n.deletions||t[2]!==n.hunks||t[3]!==n.language||t[4]!==n.matchInfo||t[5]!==n.path?(e=(0,Q.jsx)(Wn,{path:n.path,hunks:n.hunks,language:n.language,additions:n.additions,deletions:n.deletions,matchInfo:n.matchInfo}),t[0]=n.additions,t[1]=n.deletions,t[2]=n.hunks,t[3]=n.language,t[4]=n.matchInfo,t[5]=n.path,t[6]=e):e=t[6],e}case`diffs`:{let e;t[7]===n.items?e=t[8]:(e=n.items.map(gr),t[7]=n.items,t[8]=e);let r;return t[9]===e?r=t[10]:(r=(0,Q.jsx)(`div`,{className:`space-y-3`,children:e}),t[9]=e,t[10]=r),r}case`code`:{let e;return t[11]!==n.content||t[12]!==n.created||t[13]!==n.highlightLines||t[14]!==n.language||t[15]!==n.path?(e=(0,Q.jsx)(Qn,{path:n.path,content:n.content,language:n.language,created:n.created,highlightLines:n.highlightLines}),t[11]=n.content,t[12]=n.created,t[13]=n.highlightLines,t[14]=n.language,t[15]=n.path,t[16]=e):e=t[16],e}case`file-list`:{let e;return t[17]!==n.files||t[18]!==n.groups||t[19]!==n.title||t[20]!==n.total?(e=(0,Q.jsx)(ir,{title:n.title,groups:n.groups,files:n.files,total:n.total}),t[17]=n.files,t[18]=n.groups,t[19]=n.title,t[20]=n.total,t[21]=e):e=t[21],e}case`table`:{let e;t[22]===n.rows?e=t[23]:(e=JSON.stringify(n.rows,null,2),t[22]=n.rows,t[23]=e);let r;return t[24]===e?r=t[25]:(r=(0,Q.jsx)(`pre`,{className:`text-xs bg-muted/50 border rounded-md p-2 overflow-x-auto`,children:e}),t[24]=e,t[25]=r),r}case`markdown`:{let e;return t[26]===n.content?e=t[27]:(e=(0,Q.jsx)(`div`,{className:`prose prose-sm dark:prose-invert`,children:n.content}),t[26]=n.content,t[27]=e),e}case`none`:{let e;return t[28]===n.message?e=t[29]:(e=(0,Q.jsx)(tr,{message:n.message}),t[28]=n.message,t[29]=e),e}case`shell-output`:{let e;return t[30]!==n.command||t[31]!==n.exitCode||t[32]!==n.stderr||t[33]!==n.stdout?(e=(0,Q.jsx)(sr,{command:n.command,stdout:n.stdout,stderr:n.stderr,exitCode:n.exitCode}),t[30]=n.command,t[31]=n.exitCode,t[32]=n.stderr,t[33]=n.stdout,t[34]=e):e=t[34],e}case`todo-list`:{let e;return t[35]!==n.items||t[36]!==n.title?(e=(0,Q.jsx)(ur,{title:n.title,items:n.items}),t[35]=n.items,t[36]=n.title,t[37]=e):e=t[37],e}default:return null}});function gr(e,t){return(0,Q.jsx)(Wn,{path:e.path,hunks:e.hunks,language:e.language,additions:e.additions,deletions:e.deletions,matchInfo:e.matchInfo},`${e.path}-${t}`)}function _r(e){let t=(0,$.c)(9),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=y(`peer relative flex size-4 shrink-0 items-center justify-center rounded-[4px] border border-input transition-colors outline-none group-has-disabled/field:opacity-50 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground dark:data-checked:bg-primary`,n),t[3]=n,t[4]=i);let a;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Q.jsx)(Ct,{"data-slot":`checkbox-indicator`,className:`grid place-content-center text-current transition-none [&>svg]:size-3.5`,children:(0,Q.jsx)(l,{})}),t[5]=a):a=t[5];let o;return t[6]!==r||t[7]!==i?(o=(0,Q.jsx)(xt,{"data-slot":`checkbox`,className:i,...r,children:a}),t[6]=r,t[7]=i,t[8]=o):o=t[8],o}function vr(e){let t=(0,$.c)(16),{question:n,onSelect:r}=e,[i,a]=(0,Z.useState)(null),o;t[0]===n.description?o=t[1]:(o=n.description&&(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n.description}),t[0]=n.description,t[1]=o);let s;if(t[2]!==n.options||t[3]!==i){let e;t[5]===i?e=t[6]:(e=e=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>a(e.value),className:`flex flex-col items-start gap-1 p-3 rounded-lg border transition-colors text-left ${i===e.value?`border-primary bg-primary/10 ring-1 ring-primary/30`:`border-border hover:border-primary/50 hover:bg-muted/50`}`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 w-full`,children:[(0,Q.jsx)(`div`,{className:`size-4 rounded-full border-2 flex items-center justify-center transition-colors ${i===e.value?`border-primary bg-primary`:`border-muted-foreground`}`,children:i===e.value&&(0,Q.jsx)(`div`,{className:`size-2 rounded-full bg-primary-foreground`})}),(0,Q.jsx)(`span`,{className:`font-medium`,children:e.label})]}),e.description&&(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground pl-6`,children:e.description})]},e.value),t[5]=i,t[6]=e),s=n.options.map(e),t[2]=n.options,t[3]=i,t[4]=s}else s=t[4];let c;t[7]===s?c=t[8]:(c=(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:s}),t[7]=s,t[8]=c);let l;t[9]!==r||t[10]!==i?(l=i!==null&&(0,Q.jsx)(`div`,{className:`flex justify-end`,children:(0,Q.jsx)(q,{size:`sm`,onClick:()=>r(i),children:`Confirm`})}),t[9]=r,t[10]=i,t[11]=l):l=t[11];let u;return t[12]!==o||t[13]!==c||t[14]!==l?(u=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[o,c,l]}),t[12]=o,t[13]=c,t[14]=l,t[15]=u):u=t[15],u}function yr(e){let t=(0,$.c)(36),{question:n,onSelect:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=new Set,t[0]=i):i=t[0];let[a,o]=(0,Z.useState)(i),s;t[1]===n.max?s=t[2]:(s=e=>{o(t=>{let r=new Set(t);if(r.has(e))r.delete(e);else{if(n.max&&r.size>=n.max)return t;r.add(e)}return r})},t[1]=n.max,t[2]=s);let c=s,l;t[3]!==r||t[4]!==n.min||t[5]!==a?(l=()=>{let e=Array.from(a);n.min&&e.length<n.min||r(e)},t[3]=r,t[4]=n.min,t[5]=a,t[6]=l):l=t[6];let u=l,d=!n.min||a.size>=n.min,f=n.max?a.size>=n.max:!1,p;t[7]===n.description?p=t[8]:(p=n.description&&(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n.description}),t[7]=n.description,t[8]=p);let m;if(t[9]!==f||t[10]!==n.options||t[11]!==a||t[12]!==c){let e;t[14]!==f||t[15]!==a||t[16]!==c?(e=e=>{let t=f&&!a.has(e.value);return(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>c(e.value),disabled:t,className:`flex flex-col items-start gap-1 p-3 rounded-lg border transition-colors text-left ${t?`border-border opacity-50 cursor-not-allowed`:a.has(e.value)?`border-primary bg-primary/5 hover:bg-primary/10`:`border-border hover:border-primary/50 hover:bg-muted/50`}`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 w-full`,children:[(0,Q.jsx)(_r,{checked:a.has(e.value),disabled:t,onCheckedChange:()=>c(e.value),className:`pointer-events-none`}),(0,Q.jsx)(`span`,{className:`font-medium pointer-events-none`,children:e.label})]}),e.description&&(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground pl-6`,children:e.description})]},e.value)},t[14]=f,t[15]=a,t[16]=c,t[17]=e):e=t[17],m=n.options.map(e),t[9]=f,t[10]=n.options,t[11]=a,t[12]=c,t[13]=m}else m=t[13];let h;t[18]===m?h=t[19]:(h=(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:m}),t[18]=m,t[19]=h);let g;t[20]!==n.max||t[21]!==n.min?(g=n.min!==void 0&&(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Select at least `,n.min,` option`,n.min>1?`s`:``,n.max!==void 0&&` (up to ${n.max})`]}),t[20]=n.max,t[21]=n.min,t[22]=g):g=t[22];let _;t[23]!==n.max||t[24]!==n.min?(_=n.max!==void 0&&!n.min&&(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Select up to `,n.max,` option`,n.max>1?`s`:``]}),t[23]=n.max,t[24]=n.min,t[25]=_):_=t[25];let v=!d,y;t[26]!==u||t[27]!==a.size||t[28]!==v?(y=(0,Q.jsx)(`div`,{className:`flex justify-end`,children:(0,Q.jsxs)(q,{size:`sm`,onClick:u,disabled:v,children:[`Confirm Selection (`,a.size,`)`]})}),t[26]=u,t[27]=a.size,t[28]=v,t[29]=y):y=t[29];let b;return t[30]!==y||t[31]!==p||t[32]!==h||t[33]!==g||t[34]!==_?(b=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[p,h,g,_,y]}),t[30]=y,t[31]=p,t[32]=h,t[33]=g,t[34]=_,t[35]=b):b=t[35],b}function br(e){let t=(0,$.c)(26),{question:n,onSubmit:r}=e,[i,a]=(0,Z.useState)(n.defaultValue||``),o;t[0]===n.description?o=t[1]:(o=n.description&&(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n.description}),t[0]=n.description,t[1]=o);let s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=e=>a(e.target.value),t[2]=s):s=t[2];let c;t[3]!==n.placeholder||t[4]!==i?(c=(0,Q.jsx)(W,{type:`text`,value:i,onChange:s,placeholder:n.placeholder}),t[3]=n.placeholder,t[4]=i,t[5]=c):c=t[5];let l;t[6]!==r||t[7]!==i?(l=(0,Q.jsx)(q,{variant:`outline`,size:`sm`,onClick:()=>r(i),children:`Skip`}),t[6]=r,t[7]=i,t[8]=l):l=t[8];let u;t[9]!==r||t[10]!==i?(u=()=>r(i),t[9]=r,t[10]=i,t[11]=u):u=t[11];let d;t[12]===i?d=t[13]:(d=i.trim(),t[12]=i,t[13]=d);let f=d.length===0,p;t[14]!==u||t[15]!==f?(p=(0,Q.jsx)(q,{size:`sm`,onClick:u,disabled:f,children:`Submit`}),t[14]=u,t[15]=f,t[16]=p):p=t[16];let m;t[17]!==l||t[18]!==p?(m=(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[l,p]}),t[17]=l,t[18]=p,t[19]=m):m=t[19];let h;t[20]!==c||t[21]!==m?(h=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[c,m]}),t[20]=c,t[21]=m,t[22]=h):h=t[22];let g;return t[23]!==o||t[24]!==h?(g=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[o,h]}),t[23]=o,t[24]=h,t[25]=g):g=t[25],g}function xr(e){var t;let n=(0,$.c)(22),{question:r,onConfirm:i}=e,a=(t=r.defaultValue)==null?!1:t,[o,s]=(0,Z.useState)(null),c;n[0]===r.description?c=n[1]:(c=r.description&&(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:r.description}),n[0]=r.description,n[1]=c);let l=o===!1?`default`:`outline`,u;n[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>s(!1),n[2]=u):u=n[2];let d=a?`No`:`Cancel`,f;n[3]!==l||n[4]!==d?(f=(0,Q.jsx)(q,{variant:l,size:`sm`,onClick:u,children:d}),n[3]=l,n[4]=d,n[5]=f):f=n[5];let p=o===!0?`default`:`outline`,m;n[6]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>s(!0),n[6]=m):m=n[6];let h=a?`Yes`:`Confirm`,g;n[7]!==p||n[8]!==h?(g=(0,Q.jsx)(q,{variant:p,size:`sm`,onClick:m,children:h}),n[7]=p,n[8]=h,n[9]=g):g=n[9];let _;n[10]!==f||n[11]!==g?(_=(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[f,g]}),n[10]=f,n[11]=g,n[12]=_):_=n[12];let v;n[13]!==i||n[14]!==o?(v=o!==null&&(0,Q.jsx)(`div`,{className:`flex justify-end`,children:(0,Q.jsx)(q,{size:`sm`,onClick:()=>i(o),children:`Submit`})}),n[13]=i,n[14]=o,n[15]=v):v=n[15];let y;n[16]!==_||n[17]!==v?(y=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[_,v]}),n[16]=_,n[17]=v,n[18]=y):y=n[18];let b;return n[19]!==c||n[20]!==y?(b=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[c,y]}),n[19]=c,n[20]=y,n[21]=b):b=n[21],b}function Sr(e){let t=(0,$.c)(29),{question:n,onSubmit:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i={},t[0]=i):i=t[0];let[a,o]=(0,Z.useState)(i),s;if(t[1]!==a||t[2]!==n.questions){let e;t[4]===a?e=t[5]:(e=(e,t)=>a[t]!==void 0,t[4]=a,t[5]=e),s=n.questions.every(e),t[1]=a,t[2]=n.questions,t[3]=s}else s=t[3];let c=s,l;t[6]!==a||t[7]!==r||t[8]!==n.questions?(l=()=>{r({type:`form`,answers:n.questions.map((e,t)=>({question:e.question,answer:a[t]}))})},t[6]=a,t[7]=r,t[8]=n.questions,t[9]=l):l=t[9];let u=l,d;t[10]===n.description?d=t[11]:(d=n.description&&(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n.description}),t[10]=n.description,t[11]=d);let f;if(t[12]!==n.questions){let e;t[14]===n.questions.length?e=t[15]:(e=(e,t)=>(0,Q.jsxs)(`div`,{className:`border-l-2 border-primary/30 pl-3`,children:[(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground mb-2`,children:[`Question `,t+1,` of `,n.questions.length]}),(0,Q.jsx)(Cr,{question:e,onAnswer:e=>o(n=>({...n,[t]:e}))})]},t),t[14]=n.questions.length,t[15]=e),f=n.questions.map(e),t[12]=n.questions,t[13]=f}else f=t[13];let p;t[16]===f?p=t[17]:(p=(0,Q.jsx)(`div`,{className:`flex flex-col gap-4`,children:f}),t[16]=f,t[17]=p);let m=!c,h;t[18]===a?h=t[19]:(h=Object.keys(a),t[18]=a,t[19]=h);let g;t[20]!==u||t[21]!==n.questions.length||t[22]!==m||t[23]!==h.length?(g=(0,Q.jsx)(`div`,{className:`flex justify-end`,children:(0,Q.jsxs)(q,{size:`sm`,onClick:u,disabled:m,children:[`Submit All (`,h.length,`/`,n.questions.length,`)`]})}),t[20]=u,t[21]=n.questions.length,t[22]=m,t[23]=h.length,t[24]=g):g=t[24];let _;return t[25]!==d||t[26]!==p||t[27]!==g?(_=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[d,p,g]}),t[25]=d,t[26]=p,t[27]=g,t[28]=_):_=t[28],_}function Cr(e){let t=(0,$.c)(61),{question:n,onAnswer:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=new Set,t[0]=i):i=t[0];let[a,o]=(0,Z.useState)(i),[s,c]=(0,Z.useState)(null);switch(n.type){case`single_select`:{let e;t[1]===n.question?e=t[2]:(e=(0,Q.jsx)(`p`,{className:`text-sm font-medium`,children:n.question}),t[1]=n.question,t[2]=e);let i;if(t[3]!==r||t[4]!==n.options||t[5]!==a){let e;t[7]!==r||t[8]!==a?(e=e=>(0,Q.jsx)(`button`,{type:`button`,onClick:()=>{o(new Set([e.value])),r(e.value)},className:`px-3 py-1.5 text-xs rounded-md border transition-colors ${a.has(e.value)?`border-primary bg-primary/10`:`border-border hover:border-primary/50`}`,children:e.label},e.value),t[7]=r,t[8]=a,t[9]=e):e=t[9],i=n.options.map(e),t[3]=r,t[4]=n.options,t[5]=a,t[6]=i}else i=t[6];let s;t[10]===i?s=t[11]:(s=(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:i}),t[10]=i,t[11]=s);let c;return t[12]!==e||t[13]!==s?(c=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[e,s]}),t[12]=e,t[13]=s,t[14]=c):c=t[14],c}case`multi_select`:{let e;t[15]!==r||t[16]!==n.max?(e=e=>{o(t=>{let i=new Set(t);if(i.has(e))i.delete(e);else if(!n.max||i.size<n.max)i.add(e);else return t;return r(Array.from(i)),i})},t[15]=r,t[16]=n.max,t[17]=e):e=t[17];let i=e,s;t[18]===n.question?s=t[19]:(s=(0,Q.jsx)(`p`,{className:`text-sm font-medium`,children:n.question}),t[18]=n.question,t[19]=s);let c;if(t[20]!==n.options||t[21]!==a||t[22]!==i){let e;t[24]!==a||t[25]!==i?(e=e=>(0,Q.jsx)(`button`,{type:`button`,onClick:()=>i(e.value),className:`px-3 py-1.5 text-xs rounded-md border transition-colors ${a.has(e.value)?`border-primary bg-primary/10`:`border-border hover:border-primary/50`}`,children:e.label},e.value),t[24]=a,t[25]=i,t[26]=e):e=t[26],c=n.options.map(e),t[20]=n.options,t[21]=a,t[22]=i,t[23]=c}else c=t[23];let l;t[27]===c?l=t[28]:(l=(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:c}),t[27]=c,t[28]=l);let u;return t[29]!==s||t[30]!==l?(u=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[s,l]}),t[29]=s,t[30]=l,t[31]=u):u=t[31],u}case`text`:{let e;t[32]===n.question?e=t[33]:(e=(0,Q.jsx)(`p`,{className:`text-sm font-medium`,children:n.question}),t[32]=n.question,t[33]=e);let i;t[34]===r?i=t[35]:(i=e=>r(e.target.value),t[34]=r,t[35]=i);let a;t[36]!==n.defaultValue||t[37]!==n.placeholder||t[38]!==i?(a=(0,Q.jsx)(W,{type:`text`,placeholder:n.placeholder,defaultValue:n.defaultValue,onChange:i}),t[36]=n.defaultValue,t[37]=n.placeholder,t[38]=i,t[39]=a):a=t[39];let o;return t[40]!==e||t[41]!==a?(o=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[e,a]}),t[40]=e,t[41]=a,t[42]=o):o=t[42],o}case`confirm`:{let e;t[43]===n.question?e=t[44]:(e=(0,Q.jsx)(`p`,{className:`text-sm font-medium`,children:n.question}),t[43]=n.question,t[44]=e);let i=s===!1?`default`:`outline`,a;t[45]===r?a=t[46]:(a=()=>{c(!1),r(!1)},t[45]=r,t[46]=a);let o;t[47]!==i||t[48]!==a?(o=(0,Q.jsx)(q,{variant:i,size:`sm`,onClick:a,children:`No`}),t[47]=i,t[48]=a,t[49]=o):o=t[49];let l=s===!0?`default`:`outline`,u;t[50]===r?u=t[51]:(u=()=>{c(!0),r(!0)},t[50]=r,t[51]=u);let d;t[52]!==l||t[53]!==u?(d=(0,Q.jsx)(q,{variant:l,size:`sm`,onClick:u,children:`Yes`}),t[52]=l,t[53]=u,t[54]=d):d=t[54];let f;t[55]!==o||t[56]!==d?(f=(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[o,d]}),t[55]=o,t[56]=d,t[57]=f):f=t[57];let p;return t[58]!==e||t[59]!==f?(p=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[e,f]}),t[58]=e,t[59]=f,t[60]=p):p=t[60],p}}}function wr(e){var t,n,r,i;let a=(0,$.c)(79),{ask:o,onRespond:s}=e,c;a[0]===Symbol.for(`react.memo_cache_sentinel`)?(c={none:`text-muted-foreground`,low:`text-success`,medium:`text-warning`,high:`text-destructive`,critical:`text-destructive`},a[0]=c):c=a[0];let l=c,u=(t=o.intents)==null?void 0:t[0],d=(n=o.action)==null?u==null?void 0:u.action:n,f=(r=(i=o.resource)==null?u==null?void 0:u.resource:i)==null?`shell-command`:r,p=d===`read`?`Reading`:d===`write`?`Writing to`:d===`delete`?`Deleting`:d===`request`?`Requesting`:d===`execute`?`Executing`:null,m,h,g,_,v,y,b,x,S,C,w,T;if(a[1]!==o.allowedScopes||a[2]!==o.description||a[3]!==o.metadata||a[4]!==o.paths||a[5]!==o.risk||a[6]!==d||a[7]!==f||a[8]!==s||a[9]!==p||a[10]!==u){var E;let e=(E=o.allowedScopes)==null?[`once`,`session`,`workspace`]:E,t=(u==null?void 0:u.persistable)===!1?u.nonPersistableReason:void 0,n={};f===`file`&&d===`read`?(n.session=`Allow for This Session`,n.workspace=`Always Allow Reading This File`):f===`file`&&d===`write`?(n.session=`Allow for This Session`,n.workspace=`Always Allow Writing This File`):f===`file`&&d===`delete`?n.session=`Allow for This Session`:f===`network`?(n.session=`Allow for This Session`,n.workspace=`Always Allow This Network Request`):f===`shell-command`&&(n.session=`Allow for This Session`);let r=e=>{if(n[e])return n[e];switch(e){case`once`:return`Allow Once`;case`session`:return`Allow for This Session`;case`workspace`:return`Allow for Workspace`;case`always`:return`Allow for Workspace`;default:return`Allow (${e})`}};if(a[23]!==o.description||a[24]!==o.metadata||a[25]!==o.paths||a[26]!==o.risk||a[27]!==f||a[28]!==p||a[29]!==(u==null?void 0:u.targets)){var D;let e=(D=u==null?void 0:u.targets)==null?[]:D,t=e.length>0?e.map(Er):[],n;a[37]!==o.metadata||a[38]!==f?(n=()=>{var e;return f!==`shell-command`||typeof((e=o.metadata)==null?void 0:e.command)!=`string`?null:(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-xs uppercase text-muted-foreground mb-1`,children:`Command`}),(0,Q.jsx)(`pre`,{className:`text-xs bg-muted/50 border rounded-md p-2 overflow-x-auto whitespace-pre-wrap break-all font-mono`,children:o.metadata.command})]})},a[37]=o.metadata,a[38]=f,a[39]=n):n=a[39];let r=n,i;a[40]!==o.paths||a[41]!==f||a[42]!==p?(i=()=>{let e=o.paths,t=f===`file`||f===`path`||f===`directory`;return!e||e.length===0||!t?null:(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-xs uppercase text-muted-foreground mb-1`,children:p==null?`Accessing`:p}),(0,Q.jsx)(`pre`,{className:`text-xs bg-muted/50 border rounded-md p-2 overflow-x-auto whitespace-pre-wrap break-all font-mono`,children:e.join(`
8
+ `)})]})},a[40]=o.paths,a[41]=f,a[42]=p,a[43]=i):i=a[43];let s=i,c;a[44]!==o.metadata||a[45]!==f?(c=()=>{var e;return f!==`network`||typeof((e=o.metadata)==null?void 0:e.url)!=`string`?null:(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-xs uppercase text-muted-foreground mb-1`,children:`URL`}),(0,Q.jsx)(`pre`,{className:`text-xs bg-muted/50 border rounded-md p-2 overflow-x-auto whitespace-pre-wrap break-all font-mono`,children:o.metadata.url})]})},a[44]=o.metadata,a[45]=f,a[46]=c):c=a[46];let d=c,g=()=>t.length===0||f===`shell-command`?null:(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:t.map(Tr)});if(x=`flex flex-col gap-3`,a[47]===o.description?S=a[48]:(S=o.description&&(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:o.description}),a[47]=o.description,a[48]=S),a[49]!==o.risk){var O,k;C=o.risk&&(0,Q.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,Q.jsxs)(`span`,{className:`text-xs font-medium uppercase ${(O=l[(k=o.risk)==null?`none`:k])==null?`text-muted-foreground`:O}`,children:[`Risk: `,o.risk]})}),a[49]=o.risk,a[50]=C}else C=a[50];a[51]===r?w=a[52]:(w=r(),a[51]=r,a[52]=w),a[53]===s?T=a[54]:(T=s(),a[53]=s,a[54]=T),a[55]===d?m=a[56]:(m=d(),a[55]=d,a[56]=m),h=g(),a[23]=o.description,a[24]=o.metadata,a[25]=o.paths,a[26]=o.risk,a[27]=f,a[28]=p,a[29]=u==null?void 0:u.targets,a[30]=m,a[31]=h,a[32]=x,a[33]=S,a[34]=C,a[35]=w,a[36]=T}else m=a[30],h=a[31],x=a[32],S=a[33],C=a[34],w=a[35],T=a[36];if(a[57]!==o.description||a[58]!==o.metadata){var A;g=(A=o.metadata)!=null&&A.description&&typeof o.metadata.description==`string`&&!o.description?(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:o.metadata.description}):null,a[57]=o.description,a[58]=o.metadata,a[59]=g}else g=a[59];a[60]===t?_=a[61]:(_=t&&(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground italic`,children:[`This command is too dynamic to save as a reusable permission (`,t,`).`]}),a[60]=t,a[61]=_),v=`flex flex-wrap gap-2`,a[62]===s?y=a[63]:(y=(0,Q.jsx)(q,{variant:`destructive`,size:`sm`,onClick:()=>s({type:`permission`,grant:`deny`}),children:`Block`}),a[62]=s,a[63]=y),b=e.map(e=>(0,Q.jsx)(q,{variant:e===`workspace`?`default`:`outline`,size:`sm`,onClick:()=>s({type:`permission`,grant:e}),children:r(e)},e)),a[1]=o.allowedScopes,a[2]=o.description,a[3]=o.metadata,a[4]=o.paths,a[5]=o.risk,a[6]=d,a[7]=f,a[8]=s,a[9]=p,a[10]=u,a[11]=m,a[12]=h,a[13]=g,a[14]=_,a[15]=v,a[16]=y,a[17]=b,a[18]=x,a[19]=S,a[20]=C,a[21]=w,a[22]=T}else m=a[11],h=a[12],g=a[13],_=a[14],v=a[15],y=a[16],b=a[17],x=a[18],S=a[19],C=a[20],w=a[21],T=a[22];let j;a[64]!==v||a[65]!==y||a[66]!==b?(j=(0,Q.jsxs)(`div`,{className:v,children:[y,b]}),a[64]=v,a[65]=y,a[66]=b,a[67]=j):j=a[67];let M;return a[68]!==m||a[69]!==h||a[70]!==g||a[71]!==_||a[72]!==j||a[73]!==x||a[74]!==S||a[75]!==C||a[76]!==w||a[77]!==T?(M=(0,Q.jsxs)(`div`,{className:x,children:[S,C,w,T,m,h,g,_,j]}),a[68]=m,a[69]=h,a[70]=g,a[71]=_,a[72]=j,a[73]=x,a[74]=S,a[75]=C,a[76]=w,a[77]=T,a[78]=M):M=a[78],M}function Tr(e,t){return(0,Q.jsx)(`code`,{className:`text-xs bg-muted/50 border rounded px-1.5 py-0.5 font-mono`,children:e},t)}function Er(e){return e.target.split(`/`).pop()||e.target}function Dr(e){let t=(0,$.c)(15),{ask:n,onRespond:r}=e,i;t[0]===n.capability?i=t[1]:(i=(0,Q.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Client capability request: `,(0,Q.jsx)(`code`,{className:`text-xs bg-muted px-1.5 py-0.5 rounded`,children:n.capability})]}),t[0]=n.capability,t[1]=i);let a;t[2]===n.metadata?a=t[3]:(a=n.metadata&&(0,Q.jsx)(`pre`,{className:`text-xs bg-background border rounded-md p-2 overflow-x-auto`,children:JSON.stringify(n.metadata,null,2)}),t[2]=n.metadata,t[3]=a);let o;t[4]===r?o=t[5]:(o=(0,Q.jsx)(q,{variant:`outline`,size:`sm`,onClick:()=>r(void 0),children:`Not Available`}),t[4]=r,t[5]=o);let s;t[6]===r?s=t[7]:(s=(0,Q.jsx)(q,{size:`sm`,onClick:()=>r(null),children:`Confirm`}),t[6]=r,t[7]=s);let c;t[8]!==o||t[9]!==s?(c=(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[o,s]}),t[8]=o,t[9]=s,t[10]=c):c=t[10];let l;return t[11]!==i||t[12]!==a||t[13]!==c?(l=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[i,a,c]}),t[11]=i,t[12]=a,t[13]=c,t[14]=l):l=t[14],l}function Or(e){let t=(0,$.c)(78),{request:n,onRespond:r}=e,{toolCallId:i,toolName:a,ask:o,requestId:s}=n,c;t[0]!==r||t[1]!==s||t[2]!==i?(c=e=>{r(i,{type:`single_select`,value:e},s)},t[0]=r,t[1]=s,t[2]=i,t[3]=c):c=t[3];let l=c,u;t[4]!==r||t[5]!==s||t[6]!==i?(u=e=>{r(i,{type:`multi_select`,values:e},s)},t[4]=r,t[5]=s,t[6]=i,t[7]=u):u=t[7];let d=u,f;t[8]!==r||t[9]!==s||t[10]!==i?(f=e=>{r(i,{type:`text`,value:e},s)},t[8]=r,t[9]=s,t[10]=i,t[11]=f):f=t[11];let p=f,m;t[12]!==r||t[13]!==s||t[14]!==i?(m=e=>{r(i,{type:`confirm`,confirmed:e},s)},t[12]=r,t[13]=s,t[14]=i,t[15]=m):m=t[15];let h=m,g;t[16]!==r||t[17]!==s||t[18]!==i?(g=e=>{r(i,e,s)},t[16]=r,t[17]=s,t[18]=i,t[19]=g):g=t[19];let _=g,v;t[20]!==r||t[21]!==s||t[22]!==i?(v=e=>{r(i,e,s)},t[20]=r,t[21]=s,t[22]=i,t[23]=v):v=t[23];let y=v,b;t[24]!==o.capability||t[25]!==o.type||t[26]!==r||t[27]!==s||t[28]!==i?(b=e=>{r(i,{type:`client_capability`,capability:o.type===`client_capability`?o.capability:``,result:e},s)},t[24]=o.capability,t[25]=o.type,t[26]=r,t[27]=s,t[28]=i,t[29]=b):b=t[29];let x=b,S;bb0:{if(`type`in o)switch(o.type){case`single_select`:case`multi_select`:case`text`:case`confirm`:case`form`:{let e;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(e={icon:Qe,borderClass:`border-primary/30 bg-primary/5`,iconClass:`text-primary`},t[30]=e):e=t[30],S=e;break bb0}case`permission`:{let e;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(e={icon:J,borderClass:`border-warning/30 bg-warning/5`,iconClass:`text-warning`},t[31]=e):e=t[31],S=e;break bb0}case`client_capability`:{let e;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(e={icon:pe,borderClass:`border-info/30 bg-info/5`,iconClass:`text-info`},t[32]=e):e=t[32],S=e;break bb0}}let e;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(e={icon:J,borderClass:`border-warning/30 bg-warning/5`,iconClass:`text-warning`},t[33]=e):e=t[33],S=e}let C=S,w=C.icon,T=`border ${C.borderClass} rounded-lg p-4 flex flex-col gap-4`,E=`flex items-start gap-2 ${C.iconClass}`,D;t[34]===w?D=t[35]:(D=(0,Q.jsx)(w,{className:`size-4 mt-0.5 shrink-0`}),t[34]=w,t[35]=D);let O;t[36]===a?O=t[37]:(O=(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground uppercase tracking-wide`,children:a}),t[36]=a,t[37]=O);let k;t[38]===o?k=t[39]:(k=`question`in o&&(0,Q.jsx)(`p`,{className:`text-sm font-medium`,children:o.question}),t[38]=o,t[39]=k);let A;t[40]!==O||t[41]!==k?(A=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[O,k]}),t[40]=O,t[41]=k,t[42]=A):A=t[42];let j;t[43]!==E||t[44]!==D||t[45]!==A?(j=(0,Q.jsxs)(`div`,{className:E,children:[D,A]}),t[43]=E,t[44]=D,t[45]=A,t[46]=j):j=t[46];let M;t[47]!==o||t[48]!==l?(M=o.type===`single_select`&&(0,Q.jsx)(vr,{question:o,onSelect:l}),t[47]=o,t[48]=l,t[49]=M):M=t[49];let N;t[50]!==o||t[51]!==d?(N=o.type===`multi_select`&&(0,Q.jsx)(yr,{question:o,onSelect:d}),t[50]=o,t[51]=d,t[52]=N):N=t[52];let P;t[53]!==o||t[54]!==p?(P=o.type===`text`&&(0,Q.jsx)(br,{question:o,onSubmit:p}),t[53]=o,t[54]=p,t[55]=P):P=t[55];let F;t[56]!==o||t[57]!==h?(F=o.type===`confirm`&&(0,Q.jsx)(xr,{question:o,onConfirm:h}),t[56]=o,t[57]=h,t[58]=F):F=t[58];let I;t[59]!==o||t[60]!==_?(I=o.type===`form`&&(0,Q.jsx)(Sr,{question:o,onSubmit:_}),t[59]=o,t[60]=_,t[61]=I):I=t[61];let L;t[62]!==o||t[63]!==y?(L=(o.type===`permission`||!(`type`in o))&&(0,Q.jsx)(wr,{ask:o,onRespond:y}),t[62]=o,t[63]=y,t[64]=L):L=t[64];let R;t[65]!==o||t[66]!==x?(R=o.type===`client_capability`&&(0,Q.jsx)(Dr,{ask:o,onRespond:x}),t[65]=o,t[66]=x,t[67]=R):R=t[67];let z;return t[68]!==j||t[69]!==M||t[70]!==N||t[71]!==P||t[72]!==F||t[73]!==I||t[74]!==L||t[75]!==R||t[76]!==T?(z=(0,Q.jsxs)(`div`,{className:T,children:[j,M,N,P,F,I,L,R]}),t[68]=j,t[69]=M,t[70]=N,t[71]=P,t[72]=F,t[73]=I,t[74]=L,t[75]=R,t[76]=T,t[77]=z):z=t[77],z}var kr=1536,Ar=(0,Z.memo)(function(e){let t=(0,$.c)(16),{content:n,className:r}=e,[i,a]=(0,Z.useState)(!1),o;t[0]===n?o=t[1]:(o=new Blob([n]),t[0]=n,t[1]=o);let s=o.size,c=s>kr,l=c?n.slice(0,kr)+`
9
+ ...`:null;if(!c){let e;return t[2]!==r||t[3]!==n?(e=(0,Q.jsx)(`pre`,{className:r,children:n}),t[2]=r,t[3]=n,t[4]=e):e=t[4],e}let u;t[5]===s?u=t[6]:(u=s>1048576?`${(s/1048576).toFixed(1)} MB`:s>1024?`${(s/1024).toFixed(1)} KB`:`${s} bytes`,t[5]=s,t[6]=u);let d=u,f=i?n:l,p;t[7]!==r||t[8]!==f?(p=(0,Q.jsx)(`pre`,{className:r,children:f}),t[7]=r,t[8]=f,t[9]=p):p=t[9];let m;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>a(Ir),t[10]=m):m=t[10];let h=i?`Show less`:`Show full output (${d})`,g;t[11]===h?g=t[12]:(g=(0,Q.jsx)(`button`,{type:`button`,className:`text-xs text-muted-foreground hover:text-foreground mt-1 transition-colors cursor-pointer`,onClick:m,children:h}),t[11]=h,t[12]=g);let _;return t[13]!==p||t[14]!==g?(_=(0,Q.jsxs)(`div`,{children:[p,g]}),t[13]=p,t[14]=g,t[15]=_):_=t[15],_});function jr(e){switch(e){case`pending`:return(0,Q.jsx)(et,{className:`size-3 text-warning`});case`running`:return(0,Q.jsx)(te,{className:`size-3 text-warning animate-spin`});case`completed`:return(0,Q.jsx)(K,{className:`size-3 text-success`});case`error`:return(0,Q.jsx)(s,{className:`size-3 text-destructive`});case`interrupted`:return(0,Q.jsx)(Ve,{className:`size-3 text-warning`});default:return null}}function Mr(e){if(e.name!==`task`)return null;let t=e.state;if(`childSessionId`in t&&t.childSessionId)return t.childSessionId;let n=`output`in t?t.output:`partialOutput`in t?t.partialOutput:null;if(n&&typeof n==`string`){let e=n.match(/task_id:\s*([a-f0-9-]{36})/i);if(e)return e[1]}return null}function Nr(e){if(e&&typeof e==`object`&&`_visualization`in e)return e._visualization}function Pr(e,t){let n=new Set,r=[e];for(;r.length>0;){let e=r.shift();for(let i of t)i.parentId===e&&!n.has(i.id)&&(n.add(i.id),r.push(i.id))}return n}var Fr=(0,Z.memo)(function({part:e,pendingAskRequests:t,onAskResponse:n,onNavigateToSubagent:r}){let[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(!1),c=e.state,u=c.status,d=(0,Z.useMemo)(()=>{if(!i)return``;try{return JSON.stringify(c.input,null,2)}catch{return String(c.input)}},[c.input,i]),f=(0,Z.useMemo)(()=>!i||u!==`completed`||!(`output`in c)?null:typeof c.output==`string`?c.output:JSON.stringify(c.output,null,2),[u,c,i]),m=u===`completed`&&`output`in c?Nr(c.output):void 0,h=Mr(e),g=D(e=>e.sessions),_=[];if(u===`pending`||u===`running`){let n=t.find(t=>t.toolCallId===e.callId);if(n&&_.push(n),h){let n=Pr(h,g);n.add(h);let r=t.filter(t=>{let r=t.originSessionId&&n.has(t.originSessionId),i=t.sessionId===h;return(r||i)&&t.toolCallId!==e.callId});_.push(...r)}}let v=async()=>{if(`output`in c){let e=typeof c.output==`string`?c.output:JSON.stringify(c.output,null,2);await navigator.clipboard.writeText(e),s(!0),setTimeout(()=>s(!1),2e3)}},y=(()=>{try{let e=JSON.stringify(c.input);return e.length>50?e.slice(0,47)+`...`:e}catch{return String(c.input)}})();return(0,Q.jsxs)(`div`,{className:`my-1`,children:[(0,Q.jsxs)(N,{open:i,onOpenChange:a,children:[(0,Q.jsx)(O,{asChild:!0,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 py-1 cursor-pointer hover:text-foreground transition-colors text-muted-foreground`,children:[jr(u),i?(0,Q.jsx)(Xe,{className:`size-4 text-muted-foreground`}):(0,Q.jsx)(p,{className:`size-4 text-muted-foreground`}),(0,Q.jsx)(Ce,{className:`size-3`}),(0,Q.jsx)(`span`,{className:`text-xs truncate max-w-[120px] sm:max-w-none`,children:e.name}),!i&&(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground font-mono truncate flex-1 min-w-0 hidden sm:block`,children:y}),h&&r&&(0,Q.jsxs)(q,{variant:`ghost`,size:`sm`,className:`ml-auto h-6 w-6 p-0 sm:w-auto sm:px-2`,onClick:e=>{e.stopPropagation(),r(h)},title:`View session`,children:[(0,Q.jsx)(Ee,{className:`size-3`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline ml-1`,children:`View`})]})]})}),i&&(0,Q.jsx)(L,{children:(0,Q.jsxs)(`div`,{className:`pl-5 pb-2 flex flex-col gap-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-xs uppercase text-muted-foreground mb-1`,children:`Input`}),(0,Q.jsx)(Ar,{content:d,className:`text-xs bg-background border rounded-md p-2 overflow-x-auto whitespace-pre-wrap break-words`})]}),(u===`running`||u===`completed`||u===`interrupted`)&&h&&r&&(0,Q.jsxs)(q,{variant:`outline`,className:`w-full`,size:`sm`,onClick:()=>r(h),children:[(0,Q.jsx)(Ee,{className:`size-4`,"data-icon":`inline-start`}),u===`running`?`Watch Subagent`:`View Session`]}),u===`completed`&&f!==null&&(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,Q.jsx)(`div`,{className:`text-xs uppercase text-muted-foreground`,children:`Output`}),(0,Q.jsx)(q,{variant:`ghost`,size:`icon`,onClick:v,className:`size-6`,children:o?(0,Q.jsx)(l,{className:`size-3 text-success`}):(0,Q.jsx)(ie,{className:`size-3`})})]}),(0,Q.jsx)(Ar,{content:f,className:`text-xs bg-success/10 border border-success/20 rounded-md p-2 overflow-x-auto whitespace-pre-wrap break-words`})]}),u===`error`&&`error`in c&&(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-xs uppercase text-muted-foreground mb-1`,children:`Error`}),(0,Q.jsx)(`pre`,{className:`text-xs bg-destructive/10 border border-destructive/20 rounded-md p-2 overflow-x-auto whitespace-pre-wrap break-words text-destructive`,children:c.error})]})]})})]}),_.length>0&&(0,Q.jsx)(`div`,{className:`mt-2 flex flex-col gap-2`,children:_.map(e=>{var t;return(0,Q.jsx)(Or,{request:e,onRespond:n},(t=e.requestId)==null?e.toolCallId:t)})}),u===`completed`&&m&&(0,Q.jsx)(`div`,{className:`mt-2`,children:(0,Q.jsx)(hr,{visualization:m})})]})},(e,t)=>{if(e.part!==t.part||e.onNavigateToSubagent!==t.onNavigateToSubagent||e.onAskResponse!==t.onAskResponse||e.pendingAskRequests.find(t=>t.toolCallId===e.part.callId)!==t.pendingAskRequests.find(e=>e.toolCallId===t.part.callId))return!1;let n=Mr(e.part),r=Mr(t.part);if(n||r){let i=e.pendingAskRequests.filter(e=>e.originSessionId===n||e.originSessionId===r||e.sessionId===n||e.sessionId===r),a=t.pendingAskRequests.filter(e=>e.originSessionId===n||e.originSessionId===r||e.sessionId===n||e.sessionId===r);if(i.length!==a.length||i.some((e,t)=>e!==a[t]))return!1}return!0});function Ir(e){return!e}var Lr=60,Rr=300,zr=16;function Br(e){if(e.length===0)return!1;let t=e[e.length-1];return Ge(t.message)&&t.message.status===`streaming`}function Vr(e){return e.filter(e=>e.type===`text`).map(e=>e.text).join(``)}function Hr(e,t){let n=t.findIndex(t=>t.message.id===e);if(n<0)return null;if(n===0)return e;for(let e=n-1;e>=0;e--){let n=t[e];if(n.message.role===`assistant`&&n.message.status!==`streaming`)return n.message.id}return null}function Ur(){let e=(0,$.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-foreground bg-muted rounded-lg px-3 py-2 border border-border shadow-sm`,children:[(0,Q.jsx)(st,{className:`size-4 animate-pulse`}),(0,Q.jsx)(`span`,{children:`Compacting conversation...`})]}),e[0]=t):t=e[0],t}function Wr(){let e=(0,$.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-green-700 dark:text-green-400 bg-green-500/15 rounded-lg px-3 py-2 border border-green-500/30 shadow-sm`,children:[(0,Q.jsx)(Ze,{className:`size-4`}),(0,Q.jsx)(`span`,{children:`Compaction complete`})]}),e[0]=t):t=e[0],t}function Gr(e){let t=(0,$.c)(8),{message:n,textContent:r,onRetry:i}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs uppercase tracking-wide text-destructive ml-3`,children:[(0,Q.jsx)(We,{className:`size-3`}),`Compaction Failed`]}),t[0]=a):a=t[0];let o=r||n.error||`Compaction failed. The conversation could not be summarized.`,s;t[1]===o?s=t[2]:(s=(0,Q.jsx)(`p`,{className:`text-sm text-destructive/90`,children:o}),t[1]=o,t[2]=s);let c;t[3]===i?c=t[4]:(c=i&&(0,Q.jsxs)(q,{variant:`outline`,size:`sm`,onClick:i,className:`mt-2 h-7 text-xs gap-1.5`,children:[(0,Q.jsx)(Ue,{className:`size-3`}),`Retry`]}),t[3]=i,t[4]=c);let l;return t[5]!==s||t[6]!==c?(l=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1 min-w-0`,children:[a,(0,Q.jsxs)(`div`,{className:`rounded-2xl px-4 py-3 max-w-full bg-destructive/10 border border-destructive/30 rounded-bl-md`,children:[s,c]})]}),t[5]=s,t[6]=c,t[7]=l):l=t[7],l}function Kr(e,t){var n;return(e==null?void 0:e.split(`/`).pop())||(t==null||(n=t.split(`.`).pop())==null?void 0:n.toLowerCase())||``}function qr(e){let t=(0,$.c)(15),{part:n}=e,[r,i]=(0,Z.useState)(!1),a=n.overflow?`overflow`:n.auto?`auto`:`manual`,o;t[0]===r?o=t[1]:(o=()=>i(!r),t[0]=r,t[1]=o);let s;t[2]===r?s=t[3]:(s=r?(0,Q.jsx)(Xe,{className:`size-3`}):(0,Q.jsx)(p,{className:`size-3`}),t[2]=r,t[3]=s);let c=a===`overflow`?`Context overflow`:a===`auto`?`Auto`:`Manual`,l;t[4]===c?l=t[5]:(l=(0,Q.jsxs)(`span`,{className:`border-b border-dashed border-muted-foreground/40 pb-px`,children:[c,` compaction`]}),t[4]=c,t[5]=l);let u;t[6]!==o||t[7]!==s||t[8]!==l?(u=(0,Q.jsxs)(`button`,{onClick:o,className:`flex items-center gap-2 text-xs text-muted-foreground hover:text-foreground transition-colors cursor-pointer`,children:[s,l]}),t[6]=o,t[7]=s,t[8]=l,t[9]=u):u=t[9];let d;t[10]===r?d=t[11]:(d=r&&(0,Q.jsx)(`div`,{className:`mt-2 text-xs text-muted-foreground italic`,children:`Summary available in the assistant message below`}),t[10]=r,t[11]=d);let f;return t[12]!==u||t[13]!==d?(f=(0,Q.jsxs)(`div`,{className:`flex flex-col items-center py-3`,children:[u,d]}),t[12]=u,t[13]=d,t[14]=f):f=t[14],f}var Jr=(0,Z.memo)(function(e){let t=(0,$.c)(15),{parts:n,pendingAskRequests:r,onAskResponse:i,onNavigateToSubagent:a,inverted:o,serverUrl:s}=e,c=o===void 0?!1:o,l;if(t[0]!==c||t[1]!==i||t[2]!==a||t[3]!==n||t[4]!==r||t[5]!==s){let e=[...n].sort(Zr),o;t[7]!==c||t[8]!==i||t[9]!==a||t[10]!==r||t[11]!==s?(o=e=>{switch(e.type){case`text`:return(0,Q.jsx)(`div`,{className:`min-w-0`,children:(0,Q.jsx)(be,{inverted:c,children:e.text||`...`})},e.id);case`reasoning`:return(0,Q.jsx)(`div`,{className:`visualization-container text-muted-foreground text-sm italic border-l-2 border-muted-foreground/30 pl-3 my-2 wrap-break-word`,children:e.text},e.id);case`tool`:return(0,Q.jsx)(Fr,{part:e,pendingAskRequests:r,onAskResponse:i,onNavigateToSubagent:a},e.id);case`image`:return(0,Q.jsx)(`img`,{src:s?_n(s,e.url):e.url,alt:``,className:y(`max-w-full max-h-64 rounded-xl mt-2 object-contain`,c&&`ring-2 ring-white/20`)},e.id);case`file`:{let t=s?_n(s,e.url):e.url,n=Kr(e.mimeType,e.filename),r=e.filename||``,i=r.length>30?r.slice(0,27)+`...`:r||`unnamed`;return(0,Q.jsxs)(`a`,{href:t,className:y(`mt-2 p-2 rounded-lg text-sm flex items-center gap-2 transition-colors`,c?`bg-white/15 hover:bg-white/25 text-primary-foreground`:`bg-muted hover:bg-accent`),target:`_blank`,rel:`noopener noreferrer`,children:[(0,Q.jsx)(we,{className:`size-4 shrink-0`}),(0,Q.jsx)(`span`,{className:`truncate`,children:i}),n&&(0,Q.jsx)(`span`,{className:y(`px-1.5 py-0.5 rounded text-[10px] font-semibold uppercase tracking-wide ml-auto shrink-0`,c?`bg-white/25 text-primary-foreground`:`bg-secondary text-secondary-foreground`),children:n}),(0,Q.jsx)(tt,{className:`size-3.5 shrink-0 opacity-60`})]},e.id)}default:return null}},t[7]=c,t[8]=i,t[9]=a,t[10]=r,t[11]=s,t[12]=o):o=t[12],l=e.map(o),t[0]=c,t[1]=i,t[2]=a,t[3]=n,t[4]=r,t[5]=s,t[6]=l}else l=t[6];let u;return t[13]===l?u=t[14]:(u=(0,Q.jsx)(Q.Fragment,{children:l}),t[13]=l,t[14]=u),u},(e,t)=>!(e.parts!==t.parts||e.inverted!==t.inverted||e.onNavigateToSubagent!==t.onNavigateToSubagent||e.serverUrl!==t.serverUrl||e.pendingAskRequests!==t.pendingAskRequests)),Yr=(0,Z.memo)(function(e){let t=(0,$.c)(47),{item:n,messagesWithParts:r,sessionId:i,pendingAskRequests:a,onAskResponse:o,onNavigateToSubagent:s,onRemoveFromQueue:c,onRevert:l,onFork:u,isMainActiveSession:d,isCompacting:f,onCompact:p,serverUrl:m}=e,h=d===void 0?!1:d,g=f===void 0?!1:f,_;t[0]===n.parts?_=t[1]:(_=n.parts.find(Qr),t[0]=n.parts,t[1]=_);let v=_;if(Ge(n.message)&&n.message.mode===`compact_failed`){let e=n.message,r;t[2]===n.parts?r=t[3]:(r=Vr(n.parts),t[2]=n.parts,t[3]=r);let i=h&&!g?p:void 0,a;return t[4]!==e||t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(Gr,{message:e,textContent:r,onRetry:i}),t[4]=e,t[5]=r,t[6]=i,t[7]=a):a=t[7],a}if(v){let e;return t[8]===v?e=t[9]:(e=(0,Q.jsx)(qr,{part:v}),t[8]=v,t[9]=e),e}let y=!n.isQueued&&n.message.role===`user`,b;t[10]!==y||t[11]!==n.message.id||t[12]!==r?(b=y?Hr(n.message.id,r):null,t[10]=y,t[11]=n.message.id,t[12]=r,t[13]=b):b=t[13];let x=b,S=x===n.message.id,C=n.message,w;t[14]===n.parts?w=t[15]:(w=Vr(n.parts),t[14]=n.parts,t[15]=w);let T;t[16]!==n.isQueued||t[17]!==n.queueId||t[18]!==c?(T=n.isQueued?()=>c(n.queueId):void 0,t[16]=n.isQueued,t[17]=n.queueId,t[18]=c,t[19]=T):T=t[19];let E=y&&x!==null,D;t[20]!==l||t[21]!==x||t[22]!==i?(D=x?()=>l==null?void 0:l(i,x):void 0,t[20]=l,t[21]=x,t[22]=i,t[23]=D):D=t[23];let O=y&&x!==null,k;t[24]!==n.message.id||t[25]!==u||t[26]!==x||t[27]!==i?(k=x?()=>u==null?void 0:u(i,n.message.id):void 0,t[24]=n.message.id,t[25]=u,t[26]=x,t[27]=i,t[28]=k):k=t[28];let A;t[29]!==n.message.role||t[30]!==n.parts||t[31]!==o||t[32]!==s||t[33]!==a||t[34]!==m?(A=n.parts.length===0?(0,Q.jsx)(`span`,{className:`opacity-50`,children:`...`}):(0,Q.jsx)(Jr,{parts:n.parts,pendingAskRequests:a,onAskResponse:o,onNavigateToSubagent:s,inverted:n.message.role===`user`,serverUrl:m}),t[29]=n.message.role,t[30]=n.parts,t[31]=o,t[32]=s,t[33]=a,t[34]=m,t[35]=A):A=t[35];let j;return t[36]!==S||t[37]!==n.isQueued||t[38]!==n.message||t[39]!==O||t[40]!==k||t[41]!==A||t[42]!==w||t[43]!==T||t[44]!==E||t[45]!==D?(j=(0,Q.jsx)(zn,{message:C,textContent:w,isQueued:n.isQueued,onRemove:T,canRevert:E,onRevert:D,canFork:O,onFork:k,isClearAll:S,children:A}),t[36]=S,t[37]=n.isQueued,t[38]=n.message,t[39]=O,t[40]=k,t[41]=A,t[42]=w,t[43]=T,t[44]=E,t[45]=D,t[46]=j):j=t[46],j});function Xr({displayItems:e,messagesWithParts:t,sessionId:n,sessionStatus:r,pendingAskRequests:i,isCompacting:a=!1,compactionSuccess:o=!1,onClearCompactionSuccess:s,onAskResponse:c,onNavigateToSubagent:l,onRemoveFromQueue:u,onRevert:d,onFork:f,onCompact:p,isMainActiveSession:m=!1,autoFollow:h=!0,onAutoScrollChange:g,scrollToBottomRef:_,serverUrl:v}){var y,b;let x=(0,Z.useRef)(null),[S,C]=(0,Z.useState)(!1),w=(0,Z.useRef)(h),T=(0,Z.useRef)(e.length),E=(0,Z.useRef)(0),D=(0,Z.useRef)(!1),O=(0,Z.useRef)(!1),k=(0,Z.useRef)(``),A=(0,Z.useCallback)(e=>{if(e.length===0)return``;let t=e[e.length-1],n=t.parts.filter(e=>e.type===`text`).reduce((e,t)=>e+t.text.length,0);return`${t.message.id}:${Ge(t.message)?t.message.status:`n/a`}:${t.parts.length}:${n}`},[]),j=(0,Z.useRef)(null),M=(0,Z.useRef)(null),N=(0,Z.useRef)(new Map),P=(0,Z.useRef)(e);P.current=e;let F=(0,Z.useCallback)(e=>{let t=P.current[e];if(!t)return Lr+zr;if(t.message.role===`assistant`){let e=100;return t.parts.some(e=>{var t,n;return e.type===`text`&&((t=e.text)==null?void 0:t.includes("```"))||e.type===`tool`&&((n=e.state.input)==null?void 0:n.command)})&&(e=180),t.parts.some(e=>e.type===`tool`)&&(e=Math.max(e,150)),t.parts.some(e=>e.type===`compaction`)&&(e=60),t.message.mode===`compact_failed`&&(e=100),Math.min(Math.max(e+zr,Lr+zr),Rr+zr)}let n=t.parts.length>1?80:60;return Math.min(Math.max(n+zr,Lr+zr),Rr+zr)},[]);(0,Z.useLayoutEffect)(()=>{let e=x.current;if(!e)return;let t=requestAnimationFrame(()=>{e.querySelectorAll(`[data-index]`).forEach(e=>{let t=e.getAttribute(`data-index`);if(t===null)return;let n=parseInt(t,10);N.current.set(n,e.offsetHeight)})});return()=>cancelAnimationFrame(t)},[e.length]);let I=(0,Z.useRef)(null);(0,Z.useLayoutEffect)(()=>{let e=x.current;if(!e)return;I.current&&I.current.disconnect();let t=new ResizeObserver(e=>{e.forEach(e=>{let t=e.target,n=t.getAttribute(`data-index`);if(n===null)return;let r=parseInt(n,10),i=t.offsetHeight;N.current.set(r,i)})});return I.current=t,e.querySelectorAll(`[data-index]`).forEach(e=>t.observe(e)),()=>t.disconnect()},[e.length]);let L=Rn({count:e.length,getScrollElement:()=>x.current,estimateSize:F,overscan:5,getItemKey:t=>{var n,r;let i=e[t];return(n=i==null||(r=i.message)==null?void 0:r.id)==null?`fallback-${t}`:n}});(0,Z.useLayoutEffect)(()=>{w.current=h,T.current=e.length,E.current=0,D.current=!1,k.current=``,e.length!==0&&(L.scrollToIndex(e.length-1,{align:`end`}),D.current=!0)},[n]),(0,Z.useEffect)(()=>{let e=x.current;if(!e)return;let t=e=>{w.current&&e.deltaY<0&&(w.current=!1,g==null||g(!1))};return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},[g]);let R=vn(()=>{if(O.current)return;let e=x.current;if(e)if(w.current){let{scrollTop:t,scrollHeight:n,clientHeight:r}=e;n-t-r>0&&(O.current=!0,e.scrollTop=n,requestAnimationFrame(()=>{O.current=!1}))}else{let{scrollTop:t,scrollHeight:n,clientHeight:r}=e;n-t-r<=5&&(w.current=!0,g==null||g(!0))}});(0,Z.useLayoutEffect)(()=>{C(a)},[a]);let z=A(e);(0,Z.useLayoutEffect)(()=>{let t=e.length,n=T.current,r=t!==n,i=z,a=i!==k.current;k.current=i;let o=t-1,s=0;if(o>=0){var c;s=(c=N.current.get(o))==null?0:c}let l=E.current,u=o>=0&&s>l&&l>0;if(T.current=t,E.current=s,!(t===0||!r&&!a&&!u)){if(n===0&&t>0&&l===0&&!D.current){L.scrollToIndex(t-1,{align:`end`}),D.current=!0;return}w.current&&(x.current.scrollTop=x.current.scrollHeight)}},[e.length,z,L]),(0,Z.useEffect)(()=>{var t;let n=L.getVirtualItems(),r=n.length-1;if(r<0)return;let i=n[r],a=(t=x.current)==null?void 0:t.querySelector(`[data-index="${i.index}"]`);if(j.current&&j.current.disconnect(),a&&(M.current=a,!(!Br(e)||!w.current)))return j.current=new ResizeObserver(t=>{w.current&&Br(e)&&requestAnimationFrame(()=>{w.current&&(x.current.scrollTop=x.current.scrollHeight)})}),j.current.observe(a),()=>{j.current&&(j.current.disconnect(),j.current=null)}},[e,L]),(0,Z.useEffect)(()=>{if(o){let e=setTimeout(()=>{s==null||s()},3e3);return()=>clearTimeout(e)}},[o,s]),(0,Z.useLayoutEffect)(()=>{_&&(_.current=()=>{w.current=!0,O.current=!0,x.current.scrollTop=x.current.scrollHeight,requestAnimationFrame(()=>{O.current=!1})})},[_]),(0,Z.useLayoutEffect)(()=>{w.current=h},[h]);let B=L.getVirtualItems();return(0,Q.jsxs)(`div`,{ref:x,className:`flex-1 min-h-0 overflow-y-auto relative chat-transcript-scrollbar`,style:{WebkitOverflowScrolling:`touch`},onScroll:R,children:[S&&(0,Q.jsx)(`div`,{className:`sticky top-0 z-10 px-4 pt-4 pb-1 bg-gradient-to-b from-background via-background/95 to-transparent`,children:(0,Q.jsx)(Ur,{})}),o&&(0,Q.jsx)(`div`,{className:`sticky top-0 z-10 px-4 pt-4 pb-1 bg-gradient-to-b from-background via-background/95 to-transparent`,children:(0,Q.jsx)(Wr,{})}),r===`closed`&&(0,Q.jsx)(Se,{className:`mx-4 mt-4`,children:(0,Q.jsx)(_e,{children:`This session is archived. You can reopen it from the sidebar.`})}),(0,Q.jsx)(`div`,{className:`relative w-full`,style:{height:`${L.getTotalSize()}px`},children:e.length===0?(0,Q.jsxs)(`div`,{className:`text-center py-16 text-muted-foreground px-4`,children:[(0,Q.jsx)(`p`,{className:`text-lg mb-2`,children:`Start a conversation`}),(0,Q.jsx)(`p`,{className:`text-sm`,children:`Send a message below to begin.`})]}):(0,Q.jsx)(`div`,{className:`absolute top-0 left-0 w-full`,style:{transform:`translateY(${(y=(b=B[0])==null?void 0:b.start)==null?0:y}px)`},children:B.map(r=>{let o=e[r.index];return(0,Q.jsx)(`div`,{"data-index":r.index,ref:L.measureElement,className:`px-4 py-4`,children:(0,Q.jsx)(Yr,{item:o,messagesWithParts:t,sessionId:n,pendingAskRequests:i,onAskResponse:c,onNavigateToSubagent:l,onRemoveFromQueue:u,onRevert:d,onFork:f,isMainActiveSession:m,isCompacting:a,onCompact:p,serverUrl:v})},o.message.id)})})})]})}function Zr(e,t){return e.createdAt-t.createdAt}function Qr(e){return e.type===`compaction`}function $r(e,t,n){let r=e.map(e=>({message:e.message,parts:e.parts,isQueued:!1})),i=t.map(e=>{let t=(e.attachments||[]).map(t=>{var r;let i=n(e.sessionId,t.id,(r=t.accessKey)==null?``:r);return t.kind===`image`?{id:`${e.id}-att-${t.id}`,messageId:e.id,createdAt:e.createdAt,type:`image`,url:i,mimeType:t.mimeType}:{id:`${e.id}-att-${t.id}`,messageId:e.id,createdAt:e.createdAt,type:`file`,url:i,mimeType:t.mimeType||``,filename:t.filename}});return{message:{id:e.id,role:`user`,sessionId:e.sessionId,createdAt:e.createdAt},parts:[...t,...e.content.trim()?[{id:`${e.id}-part`,messageId:e.id,createdAt:e.createdAt,type:`text`,text:e.content}]:[]],isQueued:!0,queueId:e.id}}),a=[...r].sort((e,t)=>e.message.createdAt-t.message.createdAt),o=[...i].sort((e,t)=>e.message.createdAt-t.message.createdAt);return[...a,...o]}function ei(e){var t;let n=(0,$.c)(94),{session:r,messagesWithParts:i,queuedMessages:a,preconfigs:o,prompts:s,models:c,defaultModel:l,onSendMessage:u,onRemoveFromQueue:d,onChangePreconfig:f,onChangeModel:p,onChangeVariant:m,pendingAskRequests:h,onAskResponse:g,onRename:_,usage:v,modelName:y,modelSupportsImage:b,onNavigateToSubagent:x,onNavigateBack:S,isStreaming:C,onInterrupt:w,onRevert:T,onFork:E,onCompact:D,isCompacting:O,compactionSuccess:k,onClearCompactionSuccess:A,serverUrl:j,sdkClient:M,selectedVariant:N,variants:P,inputRef:F,scrollToBottomRef:I,autoFollowToggleRef:L,onClaimControl:R,onReleaseControl:z,onRequestTakeover:B,onRespondTakeover:V}=e,H=!r.parentId&&r.status===`active`,U;n[0]===r.id?U=n[1]:(U=e=>e.controlBySessionId[r.id],n[0]=r.id,n[1]=U);let W=ue(U),G=ge(ni),K=(W==null?void 0:W.status)===`controlled`&&W.controllerClientId!==G,ee=(W==null?void 0:W.status)===`grace`,te=K||ee,[q,J]=(0,Z.useState)(null),Y=(0,Z.useRef)(null),ne;n[2]===Symbol.for(`react.memo_cache_sentinel`)?(ne=e=>{Y.current&&clearTimeout(Y.current),J(e),Y.current=setTimeout(()=>{J(null),Y.current=null},4e3)},n[2]=ne):ne=n[2];let re=ne,ie,ae;n[3]===Symbol.for(`react.memo_cache_sentinel`)?(ie=()=>()=>{Y.current&&clearTimeout(Y.current)},ae=[],n[3]=ie,n[4]=ae):(ie=n[3],ae=n[4]),(0,Z.useEffect)(ie,ae);let oe,ce;n[5]===r.id?(oe=n[6],ce=n[7]):(oe=()=>{let e=null;return ue.subscribe(t=>{t.lastActionRejection!==e&&(e=t.lastActionRejection,e&&e.sessionId===r.id&&re(e.message))})},ce=[r.id,re],n[5]=r.id,n[6]=oe,n[7]=ce),(0,Z.useEffect)(oe,ce);let[de,fe]=(0,Z.useState)(!0),pe;n[8]===I?pe=n[9]:(pe=()=>{fe(e=>{let t=!e;if(t){var n;I==null||(n=I.current)==null||n.call(I)}return t})},n[8]=I,n[9]=pe);let me=pe,he,X;n[10]!==L||n[11]!==me?(he=()=>{L&&(L.current={toggle:()=>{me()}})},X=[L,me],n[10]=L,n[11]=me,n[12]=he,n[13]=X):(he=n[12],X=n[13]),(0,Z.useEffect)(he,X);let _e=(t=M==null?void 0:M.http.attachments.getUrl)==null?ti:t,ve;n[14]!==i||n[15]!==a||n[16]!==_e?(ve=$r(i,a,_e),n[14]=i,n[15]=a,n[16]=_e,n[17]=ve):ve=n[17];let ye=ve,be=i.length>=2,xe;n[18]!==l||n[19]!==O||n[20]!==C||n[21]!==y||n[22]!==c||n[23]!==p||n[24]!==f||n[25]!==m||n[26]!==R||n[27]!==D||n[28]!==w||n[29]!==S||n[30]!==z||n[31]!==_||n[32]!==B||n[33]!==V||n[34]!==o||n[35]!==N||n[36]!==r||n[37]!==be||n[38]!==v||n[39]!==P?(xe=(0,Q.jsx)(Gt,{session:r,preconfigs:o,models:c,defaultModel:l,usage:v,modelName:y,onChangePreconfig:f,onChangeModel:p,onChangeVariant:m,onRename:_,onNavigateBack:S,isStreaming:C,onInterrupt:w,onCompact:D,isCompacting:O,canCompact:be,selectedVariant:N,variants:P,onClaimControl:R,onReleaseControl:z,onRequestTakeover:B,onRespondTakeover:V}),n[18]=l,n[19]=O,n[20]=C,n[21]=y,n[22]=c,n[23]=p,n[24]=f,n[25]=m,n[26]=R,n[27]=D,n[28]=w,n[29]=S,n[30]=z,n[31]=_,n[32]=B,n[33]=V,n[34]=o,n[35]=N,n[36]=r,n[37]=be,n[38]=v,n[39]=P,n[40]=xe):xe=n[40];let Se;n[41]!==E||n[42]!==T||n[43]!==de||n[44]!==k||n[45]!==ye||n[46]!==O||n[47]!==H||n[48]!==i||n[49]!==g||n[50]!==A||n[51]!==D||n[52]!==x||n[53]!==d||n[54]!==h||n[55]!==I||n[56]!==j||n[57]!==r.id||n[58]!==r.status?(Se=(0,Q.jsx)(Xr,{displayItems:ye,messagesWithParts:i,sessionId:r.id,sessionStatus:r.status,pendingAskRequests:h,isCompacting:O,compactionSuccess:k,onClearCompactionSuccess:A,onAskResponse:g,onNavigateToSubagent:x,onRemoveFromQueue:d,onRevert:T,onFork:E,onCompact:D,isMainActiveSession:H,autoFollow:de,onAutoScrollChange:fe,scrollToBottomRef:I,serverUrl:j}),n[41]=E,n[42]=T,n[43]=de,n[44]=k,n[45]=ye,n[46]=O,n[47]=H,n[48]=i,n[49]=g,n[50]=A,n[51]=D,n[52]=x,n[53]=d,n[54]=h,n[55]=I,n[56]=j,n[57]=r.id,n[58]=r.status,n[59]=Se):Se=n[59];let Ce=de?`Auto-follow enabled (Cmd+Shift+F)`:`Auto-follow disabled (Cmd+Shift+F)`,we;n[60]===de?we=n[61]:(we=de?(0,Q.jsx)(Ke,{className:`size-3.5`}):(0,Q.jsx)(le,{className:`size-3.5`}),n[60]=de,n[61]=we);let Te;n[62]!==me||n[63]!==Ce||n[64]!==we?(Te=(0,Q.jsx)(`button`,{onClick:me,className:`absolute bottom-4 right-4 z-50 flex items-center p-1.5 text-xs rounded-full transition-colors cursor-pointer bg-background/80 backdrop-blur-sm hover:bg-background border border-border/50 shadow-sm pointer-events-auto`,title:Ce,children:we}),n[62]=me,n[63]=Ce,n[64]=we,n[65]=Te):Te=n[65];let Ee;n[66]!==Se||n[67]!==Te?(Ee=(0,Q.jsxs)(`div`,{className:`relative flex flex-col flex-1 min-h-0`,children:[Se,Te]}),n[66]=Se,n[67]=Te,n[68]=Ee):Ee=n[68];let De;n[69]!==F||n[70]!==O||n[71]!==te||n[72]!==b||n[73]!==u||n[74]!==s||n[75]!==M||n[76]!==r.id||n[77]!==r.parentId||n[78]!==r.status||n[79]!==r.workspaceId?(De=r.status===`active`&&!r.parentId&&(0,Q.jsx)(hn,{ref:F,onSendMessage:u,disabled:O||te,workspaceId:r.workspaceId,sdkClient:M,prompts:s,sessionId:r.id,modelSupportsImage:b}),n[69]=F,n[70]=O,n[71]=te,n[72]=b,n[73]=u,n[74]=s,n[75]=M,n[76]=r.id,n[77]=r.parentId,n[78]=r.status,n[79]=r.workspaceId,n[80]=De):De=n[80];let Oe;n[81]===r.parentId?Oe=n[82]:(Oe=r.parentId&&(0,Q.jsxs)(`div`,{className:`p-4 border-t border-border bg-muted/50 text-center flex items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,Q.jsx)(se,{className:`size-4`}),`This is a subagent session (read-only)`]}),n[81]=r.parentId,n[82]=Oe);let ke;n[83]===K?ke=n[84]:(ke=K&&(0,Q.jsxs)(`div`,{className:`px-4 py-2 border-t border-border bg-muted/30 text-center flex items-center justify-center gap-2 text-xs text-muted-foreground`,children:[(0,Q.jsx)(lt,{className:`size-3.5`}),`You are observing this session. Input is disabled.`]}),n[83]=K,n[84]=ke);let Ae;n[85]===q?Ae=n[86]:(Ae=q&&(0,Q.jsxs)(`div`,{className:`px-4 py-2 border-t border-orange-500/30 bg-orange-50 dark:bg-orange-950/30 text-center flex items-center justify-center gap-2 text-xs text-orange-600 dark:text-orange-400`,children:[(0,Q.jsx)(lt,{className:`size-3.5`}),q]}),n[85]=q,n[86]=Ae);let je;return n[87]!==xe||n[88]!==Ee||n[89]!==De||n[90]!==Oe||n[91]!==ke||n[92]!==Ae?(je=(0,Q.jsxs)(`div`,{className:`flex flex-col flex-1 min-h-0 relative`,children:[xe,Ee,De,Oe,ke,Ae]}),n[87]=xe,n[88]=Ee,n[89]=De,n[90]=Oe,n[91]=ke,n[92]=Ae,n[93]=je):je=n[93],je}function ti(e,t,n){return`/api/sessions/${encodeURIComponent(e)}/attachments/${encodeURIComponent(t)}/content?key=${encodeURIComponent(n)}`}function ni(e){return e.clientId}function ri(e){var t,n,r;let i=(0,$.c)(77),{serverUrl:a,messagesWithParts:o,inputRef:s,sdkClient:c,onRetry:l,onLogout:u,onSendMessage:d,onRemoveFromQueue:f,onChangePreconfig:p,onChangeModel:m,onChangeVariant:h,onAskResponse:g,onRename:_,onNavigateToSubagent:v,onNavigateBack:y,onInterrupt:b,onRevert:x,onFork:C,onCompact:w,onClearCompactionSuccess:T,scrollToBottomRef:E,autoFollowToggleRef:O,onClaimControl:k,onReleaseControl:A,onRequestTakeover:j,onRespondTakeover:M}=e,N=P(Si),F=P(xi),L=P(bi),R=P(yi),z=P(vi),B=P(_i),V=D(gi),H=D(hi),U=D(mi),W=D(pi),G=D(fi),K=D(di),ee=I(ui),te=I(li),J=I(ci),Y=I(si),ne=S(oi),re;i[0]===ee?re=i[1]:(re=ee.filter(ai),i[0]=ee,i[1]=re);let ie=re,ae=!(V!=null&&V.parentId),oe=(t=V==null?void 0:V.compacting)==null?!1:t,se;i[2]===p?se=i[3]:(se=e=>{p(e)},i[2]=p,i[3]=se);let ce=se,le;i[4]===h?le=i[5]:(le=e=>{h(e)},i[4]=h,i[5]=le);let ue=le,de;i[6]===b?de=i[7]:(de=()=>{b()},i[6]=b,i[7]=de);let fe=de;if(!N){if(L){let e;return i[8]!==F||i[9]!==z||i[10]!==u||i[11]!==l||i[12]!==R||i[13]!==a?(e=(0,Q.jsx)(`div`,{className:`flex w-full h-full items-center justify-center bg-background`,children:(0,Q.jsx)(jt,{serverUrl:a,authError:F,retryCount:R,nextRetryIn:z,onRetry:l,onLogout:u})}),i[8]=F,i[9]=z,i[10]=u,i[11]=l,i[12]=R,i[13]=a,i[14]=e):e=i[14],e}let e;i[15]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(At,{}),i[15]=e):e=i[15];let t;return i[16]===u?t=i[17]:(t=(0,Q.jsxs)(`div`,{className:`flex flex-col w-full h-full items-center justify-center bg-background gap-4`,children:[e,(0,Q.jsx)(q,{variant:`ghost`,size:`sm`,onClick:u,className:`text-muted-foreground`,children:`Change Server`})]}),i[16]=u,i[17]=t),t}if(!V){let e;return i[18]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center text-center text-muted-foreground px-6`,children:[(0,Q.jsx)(`h2`,{className:`mb-2`,children:`Select or create a session`}),(0,Q.jsx)(`p`,{children:`Choose a session from the sidebar or create a new one to start chatting.`})]}),i[18]=e):e=i[18],e}let pe;i[19]===o?pe=i[20]:(pe=o.filter(ii),i[19]=o,i[20]=pe);let me=pe.length>=2,he;if(i[21]!==W||i[22]!==J){let e;i[24]===W?e=i[25]:(e=e=>e.id===W,i[24]=W,i[25]=e),he=J.find(e),i[21]=W,i[22]=J,i[23]=he}else he=i[23];let ge=he,X;i[26]!==V.id||i[27]!==H?(X=H[V.id]||[],i[26]=V.id,i[27]=H,i[28]=X):X=i[28];let _e=ae?ie:ee,ve=ge==null?void 0:ge.variants,ye=(n=ge==null||(r=ge.capabilities)==null||(r=r.input)==null?void 0:r.image)==null?!1:n,be;i[29]!==V.id||i[30]!==V.runningAt||i[31]!==B?(be=B.has(V.id)||!!V.runningAt,i[29]=V.id,i[30]=V.runningAt,i[31]=B,i[32]=be):be=i[32];let xe;i[33]!==me||i[34]!==V.id||i[35]!==w?(xe=me?()=>w(V.id):void 0,i[33]=me,i[34]=V.id,i[35]=w,i[36]=xe):xe=i[36];let Se=a==null?void 0:a,Ce;return i[37]!==O||i[38]!==K||i[39]!==W||i[40]!==V||i[41]!==Y||i[42]!==ce||i[43]!==ue||i[44]!==fe||i[45]!==s||i[46]!==oe||i[47]!==o||i[48]!==J||i[49]!==g||i[50]!==m||i[51]!==k||i[52]!==T||i[53]!==C||i[54]!==y||i[55]!==v||i[56]!==A||i[57]!==f||i[58]!==_||i[59]!==j||i[60]!==M||i[61]!==x||i[62]!==d||i[63]!==ne||i[64]!==te||i[65]!==E||i[66]!==c||i[67]!==G||i[68]!==U||i[69]!==ye||i[70]!==be||i[71]!==xe||i[72]!==Se||i[73]!==X||i[74]!==_e||i[75]!==ve?(Ce=(0,Q.jsx)(ei,{inputRef:s,session:V,messagesWithParts:o,queuedMessages:X,preconfigs:_e,prompts:te,models:J,defaultModel:Y,onSendMessage:d,onRemoveFromQueue:f,onChangePreconfig:ce,onChangeModel:m,onChangeVariant:ue,selectedVariant:G,variants:ve,pendingAskRequests:ne,onAskResponse:g,onRename:_,usage:U,modelName:W,modelSupportsImage:ye,onNavigateToSubagent:v,onNavigateBack:y,isStreaming:be,onInterrupt:fe,onRevert:x,onFork:C,onCompact:xe,isCompacting:oe,compactionSuccess:K,onClearCompactionSuccess:T,serverUrl:Se,sdkClient:c,scrollToBottomRef:E,autoFollowToggleRef:O,onClaimControl:k,onReleaseControl:A,onRequestTakeover:j,onRespondTakeover:M}),i[37]=O,i[38]=K,i[39]=W,i[40]=V,i[41]=Y,i[42]=ce,i[43]=ue,i[44]=fe,i[45]=s,i[46]=oe,i[47]=o,i[48]=J,i[49]=g,i[50]=m,i[51]=k,i[52]=T,i[53]=C,i[54]=y,i[55]=v,i[56]=A,i[57]=f,i[58]=_,i[59]=j,i[60]=M,i[61]=x,i[62]=d,i[63]=ne,i[64]=te,i[65]=E,i[66]=c,i[67]=G,i[68]=U,i[69]=ye,i[70]=be,i[71]=xe,i[72]=Se,i[73]=X,i[74]=_e,i[75]=ve,i[76]=Ce):Ce=i[76],Ce}function ii(e){return e.message.role!==`system`}function ai(e){return e.mode!==`subagent`}function oi(e){return e.pendingRequests}function si(e){return e.defaultModel}function ci(e){return e.models}function li(e){return e.prompts}function ui(e){return e.preconfigs}function di(e){return e.compactionSuccess}function fi(e){return e.selectedVariant}function pi(e){return e.currentModel}function mi(e){return e.sessionUsage}function hi(e){return e.queuedMessages}function gi(e){return e.currentSession}function _i(e){return e.streamingSessionIds}function vi(e){return e.nextRetryIn}function yi(e){return e.retryCount}function bi(e){return e.connectionTimedOut}function xi(e){return e.authError}function Si(e){return e.connected}function Ci(){let e=(0,$.c)(30),t=U(),{chatInputRef:n,scrollToBottomRef:r,autoFollowToggleRef:i}=T(),{sdkClient:a,messagesWithParts:o,serverUrl:s,currentSession:c,isSessionLoading:l,resumeSession:u,revertSession:d,forkSession:f,compactSession:p,removeFromQueue:m,sendChatMessage:h,handleAskResponse:g,handleInterruptSession:_,updateSessionPreconfig:v,updateSessionModel:y,updateSessionVariant:b,handleNavigateBack:x,handleRenameSession:S,setCompactionSuccess:C}=t;if(l){let t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Q.jsx)(kt,{}),e[0]=t):t=e[0],t}if(!c)return null;let w;e[1]===C?w=e[2]:(w=()=>C(!1),e[1]=C,e[2]=w);let E;return e[3]!==i||e[4]!==n||e[5]!==p||e[6]!==f||e[7]!==g||e[8]!==_||e[9]!==x||e[10]!==S||e[11]!==o||e[12]!==m||e[13]!==u||e[14]!==d||e[15]!==r||e[16]!==a||e[17]!==h||e[18]!==s||e[19]!==t.claimControl||e[20]!==t.handleLogout||e[21]!==t.handleRetry||e[22]!==t.releaseControl||e[23]!==t.requestTakeover||e[24]!==t.respondTakeover||e[25]!==w||e[26]!==y||e[27]!==v||e[28]!==b?(E=(0,Q.jsx)(ri,{sdkClient:a,inputRef:n,messagesWithParts:o,serverUrl:s,onRetry:t.handleRetry,onLogout:t.handleLogout,onSendMessage:h,onRemoveFromQueue:m,onChangePreconfig:v,onChangeModel:y,onChangeVariant:b,onAskResponse:g,onRename:S,onNavigateToSubagent:u,onNavigateBack:x,onInterrupt:_,onRevert:d,onFork:f,onCompact:p,onClearCompactionSuccess:w,scrollToBottomRef:r,autoFollowToggleRef:i,onClaimControl:t.claimControl,onReleaseControl:t.releaseControl,onRequestTakeover:t.requestTakeover,onRespondTakeover:t.respondTakeover}),e[3]=i,e[4]=n,e[5]=p,e[6]=f,e[7]=g,e[8]=_,e[9]=x,e[10]=S,e[11]=o,e[12]=m,e[13]=u,e[14]=d,e[15]=r,e[16]=a,e[17]=h,e[18]=s,e[19]=t.claimControl,e[20]=t.handleLogout,e[21]=t.handleRetry,e[22]=t.releaseControl,e[23]=t.requestTakeover,e[24]=t.respondTakeover,e[25]=w,e[26]=y,e[27]=v,e[28]=b,e[29]=E):E=e[29],E}export{Ci as t};