tarsk 0.4.13 → 0.4.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/dist/index.js +712 -67
  2. package/dist/public/assets/account-view-Bj-Sn682.js +1 -0
  3. package/dist/public/assets/api-BuJ1dPr6.js +1 -0
  4. package/dist/public/assets/browser-tab-C9hYTMS0.js +1 -0
  5. package/dist/public/assets/context-menu-DeHLk-VY.js +1 -0
  6. package/dist/public/assets/conversation-history-view-cEjKqUjG.js +1 -0
  7. package/dist/public/assets/dialogs-config-CteuxXdD.js +46 -0
  8. package/dist/public/assets/diff-view-B2VYMGHR.js +3 -0
  9. package/dist/public/assets/explorer-tab-view-CROJs14G.js +2 -0
  10. package/dist/public/assets/explorer-tree-BMhkGVQO.js +1 -0
  11. package/dist/public/assets/explorer-view-BsDRu4DY.js +1 -0
  12. package/dist/public/assets/history-view-zlzHeGwz.js +1 -0
  13. package/dist/public/assets/index-BsVrm-8c.js +80 -0
  14. package/dist/public/assets/index-DyoTajdY.css +1 -0
  15. package/dist/public/assets/onboarding-C0LojpU9.js +1 -0
  16. package/dist/public/assets/onboarding-dialog-DdeXtx1_.js +1 -0
  17. package/dist/public/assets/project-settings-view-a6woZhAb.js +1 -0
  18. package/dist/public/assets/provider-details-view-CMYKkW6H.js +1 -0
  19. package/dist/public/assets/{providers-sidebar-DSrnVDNy.js → providers-sidebar-8XbQfUhe.js} +1 -1
  20. package/dist/public/assets/react-vendor-Bt_xeXcZ.js +17 -0
  21. package/dist/public/assets/settings-view-CrZ7av2I.js +2 -0
  22. package/dist/public/assets/{store-BuY90jLM.js → store-DXPO1PQf.js} +1 -1
  23. package/dist/public/assets/tab-context-B7Q9fKIl.js +1 -0
  24. package/dist/public/assets/{terminal-panel-Zyr6xth3.js → terminal-panel-BxS2vp4u.js} +1 -1
  25. package/dist/public/assets/{textarea-CxhrnOOz.js → textarea-BBmfPFv5.js} +1 -1
  26. package/dist/public/assets/todos-view-E35eshII.js +1 -0
  27. package/dist/public/assets/use-toast-BhhMvy1W.js +1 -0
  28. package/dist/public/assets/{utils-7CkwsQJ0.js → utils-DcGbvYrk.js} +1 -1
  29. package/dist/public/index.html +12 -10
  30. package/package.json +2 -2
  31. package/dist/public/assets/account-view-CXpwWuJZ.js +0 -1
  32. package/dist/public/assets/api-BfUK32d1.js +0 -1
  33. package/dist/public/assets/browser-tab-BdzIB5R4.js +0 -1
  34. package/dist/public/assets/context-menu-CC9JLx5B.js +0 -1
  35. package/dist/public/assets/conversation-history-view-C6iUsZjA.js +0 -1
  36. package/dist/public/assets/dialogs-config-Ofxg1Bn0.js +0 -46
  37. package/dist/public/assets/diff-view-C-Kz7R_T.js +0 -3
  38. package/dist/public/assets/explorer-tab-view-DC8arYcw.js +0 -2
  39. package/dist/public/assets/explorer-tree-BwLCrdfR.js +0 -1
  40. package/dist/public/assets/explorer-view-CPCrOqXp.js +0 -1
  41. package/dist/public/assets/history-view-CAVl9GFy.js +0 -1
  42. package/dist/public/assets/index-BVLzVjoR.css +0 -1
  43. package/dist/public/assets/index-DIWoaAFy.js +0 -30
  44. package/dist/public/assets/onboarding-DTzcWokE.js +0 -1
  45. package/dist/public/assets/onboarding-dialog-BQvu_Nac.js +0 -1
  46. package/dist/public/assets/project-settings-view-CZPKYKCu.js +0 -1
  47. package/dist/public/assets/provider-details-view-BBvKe6Am.js +0 -1
  48. package/dist/public/assets/react-vendor-9yNfIRPs.js +0 -17
  49. package/dist/public/assets/settings-view-D6FAPBQP.js +0 -2
  50. package/dist/public/assets/todos-view-yiH-gaUK.js +0 -1
  51. /package/dist/public/assets/{monaco-CgzMkQ7t.js → monaco-DvsnxTfD.js} +0 -0
@@ -0,0 +1,80 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dialogs-config-CteuxXdD.js","assets/rolldown-runtime-Dw2cE7zH.js","assets/account-view-Bj-Sn682.js","assets/use-toast-BhhMvy1W.js","assets/project-settings-view-a6woZhAb.js","assets/react-vendor-Bt_xeXcZ.js","assets/history-view-zlzHeGwz.js","assets/monaco-DvsnxTfD.js","assets/textarea-BBmfPFv5.js","assets/diff-view-B2VYMGHR.js","assets/context-menu-DeHLk-VY.js","assets/store-DXPO1PQf.js","assets/utils-DcGbvYrk.js","assets/terminal-panel-BxS2vp4u.js","assets/tab-context-B7Q9fKIl.js","assets/explorer-tab-view-CROJs14G.js","assets/browser-tab-C9hYTMS0.js","assets/onboarding-dialog-DdeXtx1_.js","assets/onboarding-C0LojpU9.js","assets/conversation-history-view-cEjKqUjG.js","assets/settings-view-CrZ7av2I.js"])))=>i.map(i=>d[i]);
2
+ import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{$ as t,$i as n,$r as r,$t as i,A as a,An as o,Ar as s,At as c,Bi as l,Bn as u,Br as d,Bt as f,Ci as p,Cn as m,Ct as h,D as g,Dn as _,Dr as v,Dt as y,E as b,Ei as x,Er as S,Et as C,F as w,Fn as T,Fr as E,Ft as D,Gi as O,Gn as k,Gr as A,Gt as j,Hi as M,Hn as N,Ht as P,I as F,Ii as I,In as L,It as R,J as z,Ji as B,Jr as V,Jt as H,Ki as U,Kn as W,Kr as G,Kt as ee,L as te,Li as ne,Ln as K,Lr as re,Lt as ie,M as ae,Mi as oe,Mn as q,Mr as se,Mt as ce,N as le,Ni as ue,Nn as de,Nr as fe,Nt as pe,O as me,Oi as he,Or as ge,Ot as J,P as _e,Pi as ve,Pn as ye,Pr as be,Pt as xe,Q as Se,Qi as Ce,Qr as we,Qt as Te,R as Ee,Rn as De,Rt as Oe,S as ke,Si as Ae,Sn as je,Ti as Me,Tn as Ne,Tr as Pe,Tt as Fe,Ui as Ie,Ur as Le,Ut as Re,Vn as ze,Vr as Be,Vt as Ve,Wi as He,Wn as Ue,Wr as We,Wt as Ge,Xi as Ke,Y as qe,Yi as Je,Z as Ye,Zr as Xe,Zt as Ze,_ as Qe,_i as $e,_t as et,aa as tt,ai as nt,an as rt,at as it,bi as at,bn as ot,bt as st,cn as ct,ct as lt,d as ut,di as dt,dn as ft,dt as pt,ea as mt,ei as ht,en as gt,et as _t,f as vt,fi as yt,ft as bt,g as xt,gi as St,gn as Ct,gt as wt,h as Tt,hi as Et,hn as Dt,ht as Ot,ii as kt,in as At,j as jt,ji as Mt,jn as Nt,jr as Pt,jt as Ft,k as It,ki as Lt,kr as Rt,kt as zt,la as Bt,ln as Vt,lt as Ht,m as Ut,mi as Wt,mt as Gt,na as Kt,nn as qt,o as Jt,oi as Yt,on as Xt,ot as Zt,p as Qt,pn as $t,pt as en,q as tn,qi as nn,qr as rn,qt as an,ra as on,ri as sn,rn as cn,rt as ln,sa as un,si as dn,sn as fn,st as pn,ta as mn,tt as hn,ui as gn,un as _n,ut as vn,v as yn,vn as bn,w as xn,wi as Sn,wn as Cn,wt as wn,x as Tn,xi as En,xn as Dn,xr as On,y as kn,yi as An,yn as jn,yt as Mn,z as Nn,zn as Pn,zr as Fn}from"./dialogs-config-CteuxXdD.js";import{$ as In,A as Ln,B as Rn,C as zn,D as Bn,E as Vn,F as Hn,G as Un,H as Wn,I as Gn,J as Kn,K as qn,L as Jn,M as Yn,N as Xn,O as Zn,P as Qn,Q as $n,R as er,S as tr,T as nr,U as rr,V as ir,X as ar,Y as or,Z as sr,_t as cr,at as lr,b as ur,ct as dr,dt as fr,et as pr,ft as mr,ht as hr,it as gr,j as _r,k as vr,lt as yr,mt as br,nt as xr,ot as Sr,pt as Cr,q as wr,rt as Tr,st as Er,tt as Dr,v as Or,vt as kr,w as Ar,x as jr,y as Mr}from"./react-vendor-Bt_xeXcZ.js";import{a as Nr,c as Pr,d as Fr,f as Ir,i as Lr,l as Rr,n as zr,o as Br,p as Vr,r as Hr,s as Ur,t as Y,u as Wr}from"./store-DXPO1PQf.js";import{t as Gr}from"./textarea-BBmfPFv5.js";import{c as Kr,l as qr,s as Jr,u as Yr}from"./history-view-zlzHeGwz.js";import{n as Xr,t as X}from"./use-toast-BhhMvy1W.js";import{n as Zr,t as Qr}from"./utils-DcGbvYrk.js";import{n as $r,r as ei}from"./onboarding-C0LojpU9.js";import{n as ti,t as ni}from"./tab-context-B7Q9fKIl.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var ri=kr(),Z=e(Bt(),1),Q=un(),$=On();function ii(e){let t=(0,Q.c)(47),{open:n,onOpenChange:r,feedbackName:i,onFeedbackNameChange:a,feedbackEmail:s,onFeedbackEmailChange:c,feedbackText:l,onFeedbackTextChange:d,loadingFeedbackUser:f,submittingFeedback:p,onSubmit:m}=e,h;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsxs)(u,{children:[(0,$.jsx)(ze,{children:`Send Feedback`}),(0,$.jsx)(De,{children:`Share feedback about Tarsk.`})]}),t[0]=h):h=t[0];let g;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(o,{htmlFor:`feedback-name`,children:`Name`}),t[1]=g):g=t[1];let _;t[2]===a?_=t[3]:(_=e=>a(e.target.value),t[2]=a,t[3]=_);let v=p||f,y;t[4]!==i||t[5]!==_||t[6]!==v?(y=(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[g,(0,$.jsx)(Nt,{id:`feedback-name`,value:i,onChange:_,placeholder:`Your name`,disabled:v})]}),t[4]=i,t[5]=_,t[6]=v,t[7]=y):y=t[7];let b;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(o,{htmlFor:`feedback-email`,children:`Email`}),t[8]=b):b=t[8];let x;t[9]===c?x=t[10]:(x=e=>c(e.target.value),t[9]=c,t[10]=x);let S=p||f,C;t[11]!==s||t[12]!==x||t[13]!==S?(C=(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[b,(0,$.jsx)(Nt,{id:`feedback-email`,type:`email`,value:s,onChange:x,placeholder:`you@example.com`,disabled:S})]}),t[11]=s,t[12]=x,t[13]=S,t[14]=C):C=t[14];let w;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(o,{htmlFor:`feedback-text`,children:`Feedback`}),t[15]=w):w=t[15];let T;t[16]===d?T=t[17]:(T=e=>d(e.target.value),t[16]=d,t[17]=T);let E;t[18]!==l||t[19]!==p||t[20]!==T?(E=(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[w,(0,$.jsx)(Gr,{id:`feedback-text`,value:l,onChange:T,placeholder:`Tell us what you think...`,className:`min-h-32`,disabled:p})]}),t[18]=l,t[19]=p,t[20]=T,t[21]=E):E=t[21];let D;t[22]!==E||t[23]!==y||t[24]!==C?(D=(0,$.jsxs)(`div`,{className:`grid gap-4 py-2`,children:[y,C,E]}),t[22]=E,t[23]=y,t[24]=C,t[25]=D):D=t[25];let O;t[26]===r?O=t[27]:(O=()=>r(!1),t[26]=r,t[27]=O);let k;t[28]!==p||t[29]!==O?(k=(0,$.jsx)(q,{variant:`outline`,onClick:O,disabled:p,children:`Cancel`}),t[28]=p,t[29]=O,t[30]=k):k=t[30];let A;t[31]===p?A=t[32]:(A=p?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Et,{className:`mr-2 h-4 w-4 animate-spin`}),`Sending...`]}):`Send Feedback`,t[31]=p,t[32]=A);let j;t[33]!==m||t[34]!==p||t[35]!==A?(j=(0,$.jsx)(q,{onClick:m,disabled:p,children:A}),t[33]=m,t[34]=p,t[35]=A,t[36]=j):j=t[36];let M;t[37]!==k||t[38]!==j?(M=(0,$.jsxs)(Pn,{children:[k,j]}),t[37]=k,t[38]=j,t[39]=M):M=t[39];let N;t[40]!==D||t[41]!==M?(N=(0,$.jsxs)(K,{className:`max-w-xl`,children:[h,D,M]}),t[40]=D,t[41]=M,t[42]=N):N=t[42];let P;return t[43]!==r||t[44]!==n||t[45]!==N?(P=(0,$.jsx)(L,{open:n,onOpenChange:r,children:N}),t[43]=r,t[44]=n,t[45]=N,t[46]=P):P=t[46],P}function ai(e){let t=(0,Q.c)(24),{node:n,level:r,renderNode:i,defaultOpen:a,indent:o,childContainerClassName:s,openState:c,onToggle:l}=e,u=!!(n.children&&n.children.length>0),d=c[n.id]??a,f;t[0]!==n.id||t[1]!==l?(f=()=>l(n.id),t[0]=n.id,t[1]=l,t[2]=f):f=t[2];let p=f,m;t[3]!==u||t[4]!==d||t[5]!==r||t[6]!==n||t[7]!==i||t[8]!==p?(m=i(n,{isOpen:d,level:r,toggle:p,hasChildren:u}),t[3]=u,t[4]=d,t[5]=r,t[6]=n,t[7]=i,t[8]=p,t[9]=m):m=t[9];let h;t[10]!==s||t[11]!==a||t[12]!==u||t[13]!==o||t[14]!==d||t[15]!==r||t[16]!==n.children||t[17]!==l||t[18]!==c||t[19]!==i?(h=u&&d&&(0,$.jsx)(`div`,{style:{paddingLeft:o},className:s,children:n.children.map(e=>(0,$.jsx)(ai,{node:e,level:r+1,renderNode:i,defaultOpen:a,indent:o,childContainerClassName:s,openState:c,onToggle:l},e.id))}),t[10]=s,t[11]=a,t[12]=u,t[13]=o,t[14]=d,t[15]=r,t[16]=n.children,t[17]=l,t[18]=c,t[19]=i,t[20]=h):h=t[20];let g;return t[21]!==m||t[22]!==h?(g=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[m,h]}),t[21]=m,t[22]=h,t[23]=g):g=t[23],g}function oi(e){let t=(0,Q.c)(23),{nodes:n,renderNode:r,resetKey:i,defaultOpen:a,indent:o,childContainerClassName:s,className:c}=e,l=a===void 0?!1:a,u=o===void 0?16:o,d;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(d={},t[0]=d):d=t[0];let[f,p]=(0,Z.useState)(d),[m,h]=(0,Z.useState)(i);i!==m&&(h(i),p({}));let g;t[1]===l?g=t[2]:(g=e=>{p(t=>({...t,[e]:!(t[e]??l)}))},t[1]=l,t[2]=g);let _=g,v;t[3]===c?v=t[4]:(v=N(`min-w-0`,c),t[3]=c,t[4]=v);let y;if(t[5]!==s||t[6]!==l||t[7]!==_||t[8]!==u||t[9]!==n||t[10]!==f||t[11]!==r){let e;t[13]!==s||t[14]!==l||t[15]!==_||t[16]!==u||t[17]!==f||t[18]!==r?(e=e=>(0,$.jsx)(ai,{node:e,level:0,renderNode:r,defaultOpen:l,indent:u,childContainerClassName:s,openState:f,onToggle:_},e.id),t[13]=s,t[14]=l,t[15]=_,t[16]=u,t[17]=f,t[18]=r,t[19]=e):e=t[19],y=n.map(e),t[5]=s,t[6]=l,t[7]=_,t[8]=u,t[9]=n,t[10]=f,t[11]=r,t[12]=y}else y=t[12];let b;return t[20]!==v||t[21]!==y?(b=(0,$.jsx)(`div`,{className:v,children:y}),t[20]=v,t[21]=y,t[22]=b):b=t[22],b}function si(){let[e,t]=(0,Z.useState)(!1),[n,r]=(0,Z.useState)(``),[i,a]=(0,Z.useState)(``),[o,s]=(0,Z.useState)(``),[c,l]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(!1);return(0,Z.useEffect)(()=>{if(!e)return;let t=!0;return l(!0),Zt().then(e=>{t&&(r(t=>t||e.name),a(t=>t||e.email))}).catch(()=>{t&&X({title:`Could not load git details`,description:`You can still submit feedback by entering your name and email manually.`,variant:`destructive`})}).finally(()=>{t&&l(!1)}),()=>{t=!1}},[e]),{showFeedback:e,feedbackName:n,setFeedbackName:r,feedbackEmail:i,setFeedbackEmail:a,feedbackText:o,setFeedbackText:s,loadingFeedbackUser:c,submittingFeedback:u,handleFeedbackDialogChange:e=>{t(e),e||s(``)},handleSubmitFeedback:async()=>{let e=o.trim();if(!e){X({title:`Feedback required`,description:`Please enter your feedback before submitting.`,variant:`destructive`});return}d(!0);try{await Ne(`api/feedback`,{name:n.trim(),email:i.trim(),feedback:e}),X({title:`Feedback sent`,description:`Thanks for sharing your feedback.`}),s(``),t(!1)}catch(e){X({title:`Failed to send feedback`,description:e instanceof Error?e.message:`Please try again.`,variant:`destructive`})}finally{d(!1)}}}}var ci=Z.forwardRef((e,t)=>{let n=(0,Q.c)(23),r,i,a,o,s,c,l,u,d;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4],s=n[5],c=n[6],l=n[7],u=n[8],d=n[9]):({className:i,selected:c,noBackground:o,level:a,basePadding:r,indentSize:u,asChild:d,style:l,...s}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o,n[5]=s,n[6]=c,n[7]=l,n[8]=u,n[9]=d);let f=u===void 0?20:u,p=d===void 0?!1:d,m=a===void 0?void 0:(r??12)+a*f,h=p?T:`div`,g=c&&!o&&`bg-sidebar-accent text-sidebar-accent-foreground font-medium`,_=c&&o&&`font-bold text-foreground`,v;n[10]!==i||n[11]!==g||n[12]!==_?(v=N(`flex items-center gap-2 w-full min-w-0 justify-start px-3 py-2 cursor-pointer rounded-full text-sm transition-colors group overflow-hidden`,`hover:bg-sidebar-accent hover:text-sidebar-accent-foreground`,g,_,i),n[10]=i,n[11]=g,n[12]=_,n[13]=v):v=n[13];let y=m===void 0?void 0:`${m}px`,b;n[14]!==l||n[15]!==y?(b={paddingLeft:y,...l},n[14]=l,n[15]=y,n[16]=b):b=n[16];let x;return n[17]!==h||n[18]!==s||n[19]!==t||n[20]!==v||n[21]!==b?(x=(0,$.jsx)(h,{ref:t,className:v,style:b,...s}),n[17]=h,n[18]=s,n[19]=t,n[20]=v,n[21]=b,n[22]=x):x=n[22],x});ci.displayName=`StandardListItem`;var li=dr,ui=Er,di=Z.forwardRef((e,t)=>{let n=(0,Q.c)(9),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=N(`fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,$.jsx)(Sr,{className:a,...i,ref:t}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});di.displayName=Sr.displayName;var fi=Z.forwardRef((e,t)=>{let n=(0,Q.c)(10),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsx)(di,{}),n[3]=a):a=n[3];let o;n[4]===r?o=n[5]:(o=N(`fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg`,r),n[4]=r,n[5]=o);let s;return n[6]!==i||n[7]!==t||n[8]!==o?(s=(0,$.jsxs)(ui,{children:[a,(0,$.jsx)(gr,{ref:t,className:o,...i})]}),n[6]=i,n[7]=t,n[8]=o,n[9]=s):s=n[9],s});fi.displayName=gr.displayName;var pi=e=>{let t=(0,Q.c)(8),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=N(`flex flex-col space-y-2 text-center sm:text-left`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`div`,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a};pi.displayName=`AlertDialogHeader`;var mi=e=>{let t=(0,Q.c)(8),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=N(`flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`div`,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a};mi.displayName=`AlertDialogFooter`;var hi=Z.forwardRef((e,t)=>{let n=(0,Q.c)(9),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=N(`text-lg font-semibold`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,$.jsx)(yr,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});hi.displayName=yr.displayName;var gi=Z.forwardRef((e,t)=>{let n=(0,Q.c)(9),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=N(`text-sm text-muted-foreground`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,$.jsx)(lr,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});gi.displayName=lr.displayName;var _i=Z.forwardRef((e,t)=>{let n=(0,Q.c)(9),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=N(de(),r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,$.jsx)(xr,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});_i.displayName=xr.displayName;var vi=Z.forwardRef((e,t)=>{let n=(0,Q.c)(9),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=N(de({variant:`outline`}),`mt-2 sm:mt-0`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,$.jsx)(Tr,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});vi.displayName=Tr.displayName;function yi(e){let t=(0,Q.c)(7),{theme:n,setTheme:r}=Zr(),i;t[0]!==r||t[1]!==n?(i=()=>r(n===`dark`?`light`:`dark`),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a,o;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsx)(re,{className:`h-4 w-4 rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0 shrink-0`}),o=(0,$.jsx)(dn,{className:`absolute h-4 w-4 rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100 shrink-0`}),t[3]=a,t[4]=o):(a=t[3],o=t[4]);let s;return t[5]===i?s=t[6]:(s=(0,$.jsxs)(q,{variant:`ghost`,size:`sm`,className:`justify-start gap-2 text-sidebar-foreground shrink-0`,onClick:i,children:[a,o]}),t[5]=i,t[6]=s),s}function bi({children:e,collapsed:t,title:n,onTitleClose:r,subtitle:i,headerAction:a,footer:o,onResetOnboarding:s,onLogoClick:c}){let l=(0,Z.useRef)(0),u=(0,Z.useRef)(null);return(0,Z.useEffect)(()=>()=>{u.current&&clearTimeout(u.current)},[]),(0,$.jsxs)(`div`,{className:`flex flex-col bg-sidebar text-sidebar-foreground m-2.5 mb-6 mr-10 rounded-3xl shadow-2xl overflow-hidden`,style:{containerType:`inline-size`,height:`calc(100% - 24px)`},children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b border-sidebar-border px-4 py-3 h-[61px]`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`div`,{className:`flex h-7 w-7 items-center justify-center overflow-hidden rounded-md border border-sidebar-border shadow-sm`,children:(0,$.jsx)(`img`,{src:`/tarsk.svg`,alt:`Tarsk`,className:`h-full w-full cursor-pointer`,onClick:s||c?async()=>{if(c?.(),s)if(u.current&&clearTimeout(u.current),l.current+=1,l.current>=3){l.current=0;let{resetOnboarding:e}=await cr(async()=>{let{resetOnboarding:e}=await import(`./dialogs-config-CteuxXdD.js`).then(e=>e.b);return{resetOnboarding:e}},__vite__mapDeps([0,1]));e()}else u.current=setTimeout(()=>{l.current=0},500)}:void 0})}),!t&&(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(`span`,{className:`text-sm font-semibold tracking-tight`,children:`Tarsk`}),i&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ke,{className:`h-3 w-3 text-sidebar-foreground/60`}),(0,$.jsx)(`span`,{className:`text-sm font-medium text-sidebar-foreground/80`,children:i})]})]})]}),(n??r??a)&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 ml-auto`,children:[a&&!t&&a,n&&(0,$.jsx)(`span`,{className:`text-xs font-medium text-sidebar-foreground/80`,children:n}),r&&(0,$.jsxs)(q,{variant:`ghost`,size:`icon`,className:`h-7 w-7 text-sidebar-foreground`,onClick:r,children:[(0,$.jsx)(v,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]}),(0,$.jsx)(_,{className:`flex-1`,children:e}),o&&(0,$.jsx)(`div`,{className:`border-t border-sidebar-border`,children:o})]})}var xi=(0,Z.lazy)(()=>cr(()=>import(`./account-view-Bj-Sn682.js`),__vite__mapDeps([2,1,0,3]))),Si=(0,Z.lazy)(()=>cr(()=>import(`./project-settings-view-a6woZhAb.js`),__vite__mapDeps([4,1,5,6,0,7,8,3])));function Ci(e){let t=(0,Q.c)(99),{projects:n,selectedThreadId:r,selectedProjectId:i,processingThreadIds:a,completedThreadIds:o,deletingThreadIds:s,deletingProjectIds:c,onSelectThread:l,onCreateProject:u,onCreateThread:d,onDeleteThread:f,onDeleteProject:p,onNavigateToSettings:m,onDeselect:h,collapsed:g,updateAvailable:v,updatingApp:y,onUpdateApp:b,onRefreshProjects:x}=e,[S,C]=(0,Z.useState)(!1),[w,T]=(0,Z.useState)(null),{showFeedback:E,feedbackName:D,setFeedbackName:O,feedbackEmail:k,setFeedbackEmail:A,feedbackText:j,setFeedbackText:M,loadingFeedbackUser:N,submittingFeedback:P,handleFeedbackDialogChange:F,handleSubmitFeedback:I}=si(),R;t[0]===n?R=t[1]:(R=n.map(wi),t[0]=n,t[1]=R);let z=R,B;t[2]!==g||t[3]!==u?(B=!g&&(0,$.jsxs)(q,{variant:`outline`,size:`sm`,className:`gap-2`,onClick:u,children:[(0,$.jsx)(Xe,{className:`h-4 w-4 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:`New Project`})]}),t[2]=g,t[3]=u,t[4]=B):B=t[4];let V;t[5]!==g||t[6]!==b||t[7]!==v||t[8]!==y?(V=v&&(0,$.jsxs)(q,{variant:`ghost`,size:`sm`,className:`w-full justify-start gap-2 text-emerald-600 dark:text-emerald-400`,onClick:b,disabled:y,children:[y?(0,$.jsx)(Et,{className:`h-4 w-4 animate-spin`}):(0,$.jsx)(ne,{className:`h-4 w-4`}),!g&&(0,$.jsx)(`span`,{className:`truncate`,children:y?`Updating...`:`Update to Latest`})]}),t[5]=g,t[6]=b,t[7]=v,t[8]=y,t[9]=V):V=t[9];let H;t[10]===F?H=t[11]:(H=()=>F(!0),t[10]=F,t[11]=H);let U;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,$.jsx)(yt,{className:`h-4 w-4`}),t[12]=U):U=t[12];let W;t[13]===g?W=t[14]:(W=!g&&(0,$.jsx)(`span`,{className:`truncate`,children:`Feedback`}),t[13]=g,t[14]=W);let G;t[15]!==H||t[16]!==W?(G=(0,$.jsxs)(q,{variant:`ghost`,size:`sm`,className:`flex-1 justify-start gap-2 text-sidebar-foreground`,onClick:H,children:[U,W]}),t[15]=H,t[16]=W,t[17]=G):G=t[17];let ee;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(ee=(0,$.jsx)(mt,{className:`h-4 w-4`}),t[18]=ee):ee=t[18];let te;t[19]===g?te=t[20]:(te=!g&&(0,$.jsx)(`span`,{className:`truncate`,children:`Providers`}),t[19]=g,t[20]=te);let re;t[21]!==m||t[22]!==te?(re=(0,$.jsxs)(q,{variant:`ghost`,size:`sm`,className:`justify-start gap-2 text-sidebar-foreground shrink-0`,onClick:m,children:[ee,te]}),t[21]=m,t[22]=te,t[23]=re):re=t[23];let ie;t[24]!==re||t[25]!==G?(ie=(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[G,re]}),t[24]=re,t[25]=G,t[26]=ie):ie=t[26];let ae,oe;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(ae=()=>C(!0),oe=(0,$.jsx)(Rt,{className:`h-4 w-4`}),t[27]=ae,t[28]=oe):(ae=t[27],oe=t[28]);let se;t[29]===g?se=t[30]:(se=!g&&(0,$.jsx)(`span`,{className:`truncate`,children:`Account`}),t[29]=g,t[30]=se);let ce;t[31]===se?ce=t[32]:(ce=(0,$.jsxs)(q,{variant:`ghost`,size:`sm`,className:`flex-1 justify-start gap-2 text-sidebar-foreground`,onClick:ae,children:[oe,se]}),t[31]=se,t[32]=ce);let le;t[33]===g?le=t[34]:(le=(0,$.jsx)(yi,{collapsed:g}),t[33]=g,t[34]=le);let ue;t[35]!==ce||t[36]!==le?(ue=(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[ce,le]}),t[35]=ce,t[36]=le,t[37]=ue):ue=t[37];let de;t[38]!==ie||t[39]!==ue||t[40]!==V?(de=(0,$.jsxs)(`div`,{className:`px-3 py-2 flex flex-col gap-1`,children:[V,ie,ue]}),t[38]=ie,t[39]=ue,t[40]=V,t[41]=de):de=t[41];let fe;t[42]===n.length?fe=t[43]:(fe=n.length===0&&(0,$.jsx)(`p`,{className:`px-3 py-6 text-center text-xs text-muted-foreground`,children:`No projects yet. Clone a repository to get started.`}),t[42]=n.length,t[43]=fe);let pe;t[44]!==o||t[45]!==c||t[46]!==s||t[47]!==d||t[48]!==p||t[49]!==f||t[50]!==l||t[51]!==a||t[52]!==n||t[53]!==i||t[54]!==r?(pe=(e,t)=>{let{isOpen:u,toggle:m}=t;return e.kind===`project`?(0,$.jsx)(Ti,{project:e.project,isOpen:u,onToggle:m,isDeletingProject:c.includes(e.project.projectId),isSelected:i?e.project.projectId===i:!1,onCreateThread:d,onDeleteProject:p,onProjectSettings:T,hasSelectedThread:e.project.threads.some(e=>e.threadId===r)}):(0,$.jsx)(Ei,{thread:e.thread,projectId:e.projectId,selectedThreadId:r,isProcessing:a.includes(e.thread.threadId),isDeleting:s.includes(e.thread.threadId),isCompleted:o.includes(e.thread.threadId),projectTitlePrefix:`${Ue(n.find(t=>t.projectId===e.projectId))} - `,onSelectThread:l,onDeleteThread:f})},t[44]=o,t[45]=c,t[46]=s,t[47]=d,t[48]=p,t[49]=f,t[50]=l,t[51]=a,t[52]=n,t[53]=i,t[54]=r,t[55]=pe):pe=t[55];let me;t[56]!==z||t[57]!==pe?(me=(0,$.jsx)(oi,{nodes:z,defaultOpen:!0,childContainerClassName:`ml-4 border-l border-sidebar-border pl-2`,renderNode:pe}),t[56]=z,t[57]=pe,t[58]=me):me=t[58];let he;t[59]!==fe||t[60]!==me?(he=(0,$.jsx)(_,{className:`flex-1 w-full`,children:(0,$.jsxs)(`div`,{className:`px-2 py-2 w-full max-w-full overflow-hidden`,children:[fe,me]})}),t[59]=fe,t[60]=me,t[61]=he):he=t[61];let ge;t[62]!==g||t[63]!==h||t[64]!==de||t[65]!==B||t[66]!==he?(ge=(0,$.jsx)(bi,{collapsed:g,onLogoClick:h,headerAction:B,footer:de,children:he}),t[62]=g,t[63]=h,t[64]=de,t[65]=B,t[66]=he,t[67]=ge):ge=t[67];let J=w!==null,_e;t[68]===Symbol.for(`react.memo_cache_sentinel`)?(_e=e=>!e&&T(null),t[68]=_e):_e=t[68];let ve;t[69]===x?ve=t[70]:(ve=()=>{x?.(),T(null)},t[69]=x,t[70]=ve);let ye;t[71]!==w||t[72]!==ve?(ye=(0,$.jsx)(K,{className:`max-w-2xl p-0 overflow-auto max-h-[90vh]`,children:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Si,{projectId:w,onProjectUpdated:ve})})}),t[71]=w,t[72]=ve,t[73]=ye):ye=t[73];let be;t[74]!==J||t[75]!==ye?(be=(0,$.jsx)(L,{open:J,onOpenChange:_e,children:ye}),t[74]=J,t[75]=ye,t[76]=be):be=t[76];let xe;t[77]===I?xe=t[78]:(xe=()=>void I(),t[77]=I,t[78]=xe);let Se;t[79]!==k||t[80]!==D||t[81]!==j||t[82]!==F||t[83]!==N||t[84]!==A||t[85]!==O||t[86]!==M||t[87]!==E||t[88]!==P||t[89]!==xe?(Se=(0,$.jsx)(ii,{open:E,onOpenChange:F,feedbackName:D,onFeedbackNameChange:O,feedbackEmail:k,onFeedbackEmailChange:A,feedbackText:j,onFeedbackTextChange:M,loadingFeedbackUser:N,submittingFeedback:P,onSubmit:xe}),t[79]=k,t[80]=D,t[81]=j,t[82]=F,t[83]=N,t[84]=A,t[85]=O,t[86]=M,t[87]=E,t[88]=P,t[89]=xe,t[90]=Se):Se=t[90];let Ce;t[91]===Symbol.for(`react.memo_cache_sentinel`)?(Ce=(0,$.jsx)(K,{className:`max-w-2xl p-0 overflow-auto max-h-[90vh]`,children:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(xi,{})})}),t[91]=Ce):Ce=t[91];let we;t[92]===S?we=t[93]:(we=(0,$.jsx)(L,{open:S,onOpenChange:C,children:Ce}),t[92]=S,t[93]=we);let Te;return t[94]!==ge||t[95]!==be||t[96]!==Se||t[97]!==we?(Te=(0,$.jsxs)($.Fragment,{children:[ge,be,Se,we]}),t[94]=ge,t[95]=be,t[96]=Se,t[97]=we,t[98]=Te):Te=t[98],Te}function wi(e,t){return{id:e.projectId||e.gitUrl||`project-${t}`,kind:`project`,project:e,children:e.threads.map((t,n)=>({id:t.threadId||`${e.projectId}-${t.title||n}`,kind:`thread`,thread:t,projectId:e.projectId}))}}function Ti(e){let t=(0,Q.c)(26),{project:n,isOpen:r,onToggle:i,isDeletingProject:a,hasSelectedThread:o,isSelected:s,onCreateThread:c,onDeleteProject:l,onProjectSettings:u}=e,d;t[0]===n?d=t[1]:(d=Ue(n),t[0]=n,t[1]=d);let f=d,p=o||s,m=r&&`rotate-90`,h;t[2]===m?h=t[3]:(h=N(`h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform`,m),t[2]=m,t[3]=h);let g;t[4]===h?g=t[5]:(g=(0,$.jsx)(Ke,{className:h}),t[4]=h,t[5]=g);let _;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(Lt,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}),t[6]=_):_=t[6];let v=(o||s)&&`font-bold text-foreground`,y;t[7]===v?y=t[8]:(y=N(`min-w-0 truncate transition-all block`,v),t[7]=v,t[8]=y);let b;t[9]!==f||t[10]!==y?(b=(0,$.jsx)(`span`,{className:y,children:f}),t[9]=f,t[10]=y,t[11]=b):b=t[11];let x;t[12]!==g||t[13]!==b?(x=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1.5 w-0`,children:[g,_,b]}),t[12]=g,t[13]=b,t[14]=x):x=t[14];let S;t[15]!==a||t[16]!==c||t[17]!==l||t[18]!==u||t[19]!==n?(S=(0,$.jsx)(`div`,{className:`flex shrink-0 items-center ml-auto`,children:a?(0,$.jsx)(Et,{className:`h-3.5 w-3.5 shrink-0 animate-spin text-muted-foreground mr-1`}):(0,$.jsxs)(qr,{children:[(0,$.jsxs)(Jr,{children:[(0,$.jsx)(Yr,{asChild:!0,children:(0,$.jsxs)(q,{variant:`ghost`,size:`icon`,className:`h-7 w-7 shrink-0 hidden group-hover:flex items-center justify-center`,onClick:e=>{e.stopPropagation(),u(n.projectId)},children:[(0,$.jsx)(Le,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Project settings`})]})}),(0,$.jsx)(Kr,{side:`right`,children:`Project settings`})]}),(0,$.jsxs)(Jr,{children:[(0,$.jsx)(Yr,{asChild:!0,children:(0,$.jsxs)(q,{variant:`action`,size:`icon-sm`,className:`shrink-0 hidden group-hover:flex items-center justify-center`,onClick:e=>{e.stopPropagation(),c(n.projectId)},children:[(0,$.jsx)(Xe,{}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Add thread`})]})}),(0,$.jsx)(Kr,{side:`right`,children:`Add thread`})]}),n.threads.length===0&&(0,$.jsxs)(Jr,{children:[(0,$.jsx)(Yr,{asChild:!0,children:(0,$.jsxs)(q,{variant:`ghost`,size:`icon-sm`,className:`shrink-0 hidden group-hover:flex items-center justify-center text-muted-foreground hover:bg-destructive hover:text-destructive-foreground transition-colors`,onClick:e=>{e.stopPropagation(),l(n.projectId)},children:[(0,$.jsx)(fe,{}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Delete project`})]})}),(0,$.jsx)(Kr,{side:`right`,children:`Delete project`})]})]})}),t[15]=a,t[16]=c,t[17]=l,t[18]=u,t[19]=n,t[20]=S):S=t[20];let C;return t[21]!==i||t[22]!==x||t[23]!==S||t[24]!==p?(C=(0,$.jsxs)(ci,{selected:p,noBackground:!0,className:`mb-1 h-9`,onClick:i,children:[x,S]}),t[21]=i,t[22]=x,t[23]=S,t[24]=p,t[25]=C):C=t[25],C}function Ei(e){let t=(0,Q.c)(47),{thread:r,projectId:i,selectedThreadId:a,isProcessing:o,isDeleting:s,isCompleted:c,projectTitlePrefix:l,onSelectThread:u,onDeleteThread:d}=e,[f,p]=(0,Z.useState)(!1),m;t[0]!==d||t[1]!==i||t[2]!==r.gitStatusDot||t[3]!==r.threadId?(m=e=>{e.stopPropagation(),r.gitStatusDot?p(!0):d(i,r.threadId)},t[0]=d,t[1]=i,t[2]=r.gitStatusDot,t[3]=r.threadId,t[4]=m):m=t[4];let h=m,g;t[5]!==l||t[6]!==r.threadId||t[7]!==r.title?(g=r.title?.startsWith(l)?r.title.slice(l.length):r.title??r.threadId,t[5]=l,t[6]=r.threadId,t[7]=r.title,t[8]=g):g=t[8];let _=g,v;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(hi,{children:`Delete Thread`}),t[9]=v):v=t[9];let y;t[10]===_?y=t[11]:(y=(0,$.jsxs)(gi,{children:[`Are you sure you want to delete "`,_,`" and all its files? This action cannot be undone.`]}),t[10]=_,t[11]=y);let b;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(vi,{children:`Cancel`}),t[12]=b):b=t[12];let x;t[13]!==d||t[14]!==i||t[15]!==r.threadId?(x=(0,$.jsxs)(`div`,{className:`flex gap-3 justify-end`,children:[b,(0,$.jsx)(_i,{onClick:()=>{p(!1),d(i,r.threadId)},className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:`Delete`})]}),t[13]=d,t[14]=i,t[15]=r.threadId,t[16]=x):x=t[16];let S;t[17]!==y||t[18]!==x?(S=(0,$.jsxs)(fi,{children:[v,y,x]}),t[17]=y,t[18]=x,t[19]=S):S=t[19];let C;t[20]!==f||t[21]!==S?(C=(0,$.jsx)(li,{open:f,onOpenChange:p,children:S}),t[20]=f,t[21]=S,t[22]=C):C=t[22];let w=r.threadId===a,T,E;t[23]!==u||t[24]!==i||t[25]!==r.threadId?(T=()=>u(i,r.threadId),E=e=>{(e.key===`Enter`||e.key===` `)&&u(i,r.threadId)},t[23]=u,t[24]=i,t[25]=r.threadId,t[26]=T,t[27]=E):(T=t[26],E=t[27]);let D;t[28]===r.gitStatusDot?D=t[29]:(D=r.gitStatusDot?(0,$.jsx)(`svg`,{className:`h-3 w-3 shrink-0`,viewBox:`0 0 12 12`,fill:`hsl(var(--brand))`,xmlns:`http://www.w3.org/2000/svg`,children:(0,$.jsx)(`circle`,{cx:`6`,cy:`6`,r:`5`})}):(0,$.jsx)(`svg`,{className:`h-3 w-3 shrink-0 text-muted-foreground`,viewBox:`0 0 12 12`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.0`,xmlns:`http://www.w3.org/2000/svg`,children:(0,$.jsx)(`circle`,{cx:`6`,cy:`6`,r:`4.5`})}),t[28]=r.gitStatusDot,t[29]=D);let O;t[30]===_?O=t[31]:(O=(0,$.jsx)(`div`,{className:`flex-1 min-w-0 w-0`,children:(0,$.jsx)(`span`,{className:`text-sm truncate block`,children:_})}),t[30]=_,t[31]=O);let k;t[32]!==h||t[33]!==c||t[34]!==s||t[35]!==o?(k=o||s?(0,$.jsx)(Et,{className:`ml-auto h-3 w-3 shrink-0 animate-spin text-muted-foreground`}):c?(0,$.jsx)(n,{className:`ml-auto h-3 w-3 shrink-0 text-green-500`}):(0,$.jsx)(`div`,{className:`ml-auto flex items-center gap-1`,children:(0,$.jsxs)(Jr,{children:[(0,$.jsx)(Yr,{asChild:!0,children:(0,$.jsxs)(q,{variant:`ghost`,size:`icon-sm`,className:`shrink-0 opacity-0 group-hover:opacity-100 flex items-center justify-center text-muted-foreground hover:bg-destructive hover:text-destructive-foreground transition-opacity transition-colors`,onClick:h,children:[(0,$.jsx)(fe,{}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Delete thread`})]})}),(0,$.jsx)(Kr,{side:`right`,children:`Delete thread and files from the repo`})]})}),t[32]=h,t[33]=c,t[34]=s,t[35]=o,t[36]=k):k=t[36];let A;t[37]!==T||t[38]!==E||t[39]!==D||t[40]!==O||t[41]!==k||t[42]!==w?(A=(0,$.jsxs)(ci,{selected:w,onClick:T,onKeyDown:E,role:`button`,tabIndex:0,children:[D,O,k]}),t[37]=T,t[38]=E,t[39]=D,t[40]=O,t[41]=k,t[42]=w,t[43]=A):A=t[43];let j;return t[44]!==A||t[45]!==C?(j=(0,$.jsxs)($.Fragment,{children:[C,A]}),t[44]=A,t[45]=C,t[46]=j):j=t[46],j}function Di({content:e,className:t}){let n=(0,Z.useMemo)(()=>!e||typeof e!=`string`?[]:Oi(e),[e]);if(n.length===0)return null;let r=(0,Z.useMemo)(()=>{let e=0;return n.map(t=>{if(t.type===`list`&&t.ordered){let n=e+1;return e+=t.items.length,n}else if(t.type===`list`&&!t.ordered)return 1;else return e=0,1})},[n]);return(0,$.jsx)(`div`,{className:N(`prose-custom space-y-3 min-w-0 break-words`,t),children:n.map((e,t)=>(0,$.jsx)(ki,{block:e,start:r[t]},t))})}function Oi(e){let t=e.split(`
3
+ `),n=[],r=0;for(;r<t.length;){let e=t[r];if(e.trimStart().startsWith("```")){let i=e.trimStart().slice(3).trim(),a=[];for(r++;r<t.length&&!t[r].trimStart().startsWith("```");)a.push(t[r]),r++;n.push({type:`code`,language:i,code:a.join(`
4
+ `)}),r++;continue}let i=e.match(/^(#{1,6})(\s.*)?$/);if(i){n.push({type:`heading`,level:i[1].length,text:i[2]?i[2].trim():``}),r++;continue}if(/^(---|\*\*\*|___)/.test(e.trim())){n.push({type:`hr`}),r++;continue}if(e.includes(`|`)&&r+1<t.length&&t[r+1].match(/^\|?\s*[-:]+/)){let i=e.split(`|`).map(e=>e.trim()).filter(Boolean);r+=2;let a=[];for(;r<t.length&&t[r].includes(`|`);)a.push(t[r].split(`|`).map(e=>e.trim()).filter(Boolean)),r++;n.push({type:`table`,headers:i,rows:a});continue}if(e.startsWith(`> `)){let e=[];for(;r<t.length&&t[r].startsWith(`> `);)e.push(t[r].slice(2)),r++;n.push({type:`blockquote`,text:e.join(`
5
+ `)});continue}if(/^\s*[-*+]\s/.test(e)){let e=[];for(;r<t.length&&/^\s*[-*+]\s/.test(t[r]);)e.push(t[r].replace(/^\s*[-*+]\s/,``)),r++;n.push({type:`list`,ordered:!1,items:e});continue}if(/^\s*\d+\.\s/.test(e)){let e=[];for(;r<t.length&&/^\s*\d+\.\s/.test(t[r]);)e.push(t[r].replace(/^\s*\d+\.\s/,``)),r++;n.push({type:`list`,ordered:!0,items:e});continue}if(e.trim()===``){r++;continue}let a=[];for(;r<t.length&&t[r].trim()!==``&&!t[r].startsWith(`#`)&&!t[r].startsWith("```")&&!t[r].startsWith(`> `)&&!/^\s*[-*+]\s/.test(t[r])&&!/^\s*\d+\.\s/.test(t[r]);)a.push(t[r]),r++;a.length>0&&n.push({type:`paragraph`,text:a.join(`
6
+ `)})}return n}function ki(e){let t=(0,Q.c)(40),{block:n,start:r}=e,i=r===void 0?1:r;switch(n.type){case`heading`:{let e=`h${n.level}`,r,i;t[0]!==e||t[1]!==n.level?(r=e,i=N({1:`text-xl font-bold`,2:`text-lg font-semibold`,3:`text-base font-semibold`,4:`text-sm font-semibold`,5:`text-sm font-medium`,6:`text-xs font-medium`}[n.level]),t[0]=e,t[1]=n.level,t[2]=r,t[3]=i):(r=t[2],i=t[3]);let a;t[4]===n.text?a=t[5]:(a=(0,$.jsx)(Pi,{text:n.text}),t[4]=n.text,t[5]=a);let o;return t[6]!==r||t[7]!==i||t[8]!==a?(o=(0,$.jsx)(r,{className:i,children:a}),t[6]=r,t[7]=i,t[8]=a,t[9]=o):o=t[9],o}case`code`:{let e;return t[10]!==n.code||t[11]!==n.language?(e=(0,$.jsx)(Li,{language:n.language,code:n.code}),t[10]=n.code,t[11]=n.language,t[12]=e):e=t[12],e}case`blockquote`:{let e;return t[13]===n.text?e=t[14]:(e=(0,$.jsx)(`blockquote`,{className:`border-l-2 border-border pl-4 text-muted-foreground italic`,children:(0,$.jsx)(Pi,{text:n.text})}),t[13]=n.text,t[14]=e),e}case`list`:{if(n.ordered){let e;if(t[15]!==n.items||t[16]!==i){let r;t[18]===i?r=t[19]:(r=(e,t)=>(0,$.jsxs)(`li`,{className:`flex gap-1.5`,children:[(0,$.jsxs)(`span`,{className:`shrink-0 select-none tabular-nums`,children:[i+t,`.`]}),(0,$.jsx)(`span`,{children:(0,$.jsx)(Pi,{text:e})})]},t),t[18]=i,t[19]=r),e=n.items.map(r),t[15]=n.items,t[16]=i,t[17]=e}else e=t[17];let r;return t[20]===e?r=t[21]:(r=(0,$.jsx)(`ol`,{className:`space-y-1 text-sm`,children:e}),t[20]=e,t[21]=r),r}let e;t[22]===n.items?e=t[23]:(e=n.items.map(Ni),t[22]=n.items,t[23]=e);let r;return t[24]===e?r=t[25]:(r=(0,$.jsx)(`ul`,{className:`space-y-1 pl-5 text-sm list-outside overflow-visible list-disc`,children:e}),t[24]=e,t[25]=r),r}case`paragraph`:{let e;return t[26]===n.text?e=t[27]:(e=(0,$.jsx)(`p`,{className:`text-sm leading-relaxed whitespace-pre-wrap break-words`,children:(0,$.jsx)(Pi,{text:n.text})}),t[26]=n.text,t[27]=e),e}case`hr`:{let e;return t[28]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`hr`,{className:`border-border`}),t[28]=e):e=t[28],e}case`table`:{let e;t[29]===n.headers?e=t[30]:(e=n.headers.map(Mi),t[29]=n.headers,t[30]=e);let r;t[31]===e?r=t[32]:(r=(0,$.jsx)(`thead`,{children:(0,$.jsx)(`tr`,{className:`border-b border-border bg-muted/50`,children:e})}),t[31]=e,t[32]=r);let i;t[33]===n.rows?i=t[34]:(i=n.rows.map(Ai),t[33]=n.rows,t[34]=i);let a;t[35]===i?a=t[36]:(a=(0,$.jsx)(`tbody`,{children:i}),t[35]=i,t[36]=a);let o;return t[37]!==r||t[38]!==a?(o=(0,$.jsx)(`div`,{className:`overflow-x-auto rounded-md border border-border max-w-full`,children:(0,$.jsxs)(`table`,{className:`w-full text-sm`,children:[r,a]})}),t[37]=r,t[38]=a,t[39]=o):o=t[39],o}default:return null}}function Ai(e,t){return(0,$.jsx)(`tr`,{className:`border-b border-border last:border-0`,children:e.map(ji)},t)}function ji(e,t){return(0,$.jsx)(`td`,{className:`px-3 py-2`,children:e},t)}function Mi(e,t){return(0,$.jsx)(`th`,{className:`px-3 py-2 text-left font-medium`,children:e},t)}function Ni(e,t){return(0,$.jsx)(`li`,{children:(0,$.jsx)(Pi,{text:e})},t)}function Pi(e){let t=(0,Q.c)(4),{text:n}=e,r;t[0]===n?r=t[1]:(r=Ii(n).map(Fi),t[0]=n,t[1]=r);let i;return t[2]===r?i=t[3]:(i=(0,$.jsx)($.Fragment,{children:r}),t[2]=r,t[3]=i),i}function Fi(e,t){switch(e.type){case`bold`:return(0,$.jsx)(`strong`,{className:`font-semibold`,children:e.text},t);case`italic`:return(0,$.jsx)(`em`,{children:e.text},t);case`strikethrough`:return(0,$.jsx)(`del`,{className:`text-muted-foreground`,children:e.text},t);case`code`:return(0,$.jsx)(`code`,{className:`rounded bg-muted/20 px-1.5 py-0.5 text-xs font-mono`,children:e.text},t);case`link`:return(0,$.jsx)(`a`,{href:e.href,className:`text-primary underline underline-offset-2 hover:text-primary/80`,target:`_blank`,rel:`noopener noreferrer`,children:e.text},t);default:return(0,$.jsx)(`span`,{children:e.text},t)}}function Ii(e){let t=[],n=/(`[^`]+`)|(\*\*[^*]+\*\*)|(\*[^*]+\*)|(__[^_]+__)|(_[^_]+_)|(~~[^~]+~~)|(\[[^\]]+\]\([^)]+\))/g,r=0,i;for(;(i=n.exec(e))!==null;){i.index>r&&t.push({type:`text`,text:e.slice(r,i.index)});let n=i[0];if(n.startsWith("`"))t.push({type:`code`,text:n.slice(1,-1)});else if(n.startsWith(`**`))t.push({type:`bold`,text:n.slice(2,-2)});else if(n.startsWith(`__`))t.push({type:`bold`,text:n.slice(2,-2)});else if(n.startsWith(`~~`))t.push({type:`strikethrough`,text:n.slice(2,-2)});else if(n.startsWith(`*`)||n.startsWith(`_`))t.push({type:`italic`,text:n.slice(1,-1)});else if(n.startsWith(`[`)){let e=n.match(/\[([^\]]+)\]\(([^)]+)\)/);e&&t.push({type:`link`,text:e[1],href:e[2]})}r=i.index+n.length}return r<e.length&&t.push({type:`text`,text:e.slice(r)}),t.length>0?t:[{type:`text`,text:e}]}function Li(e){let t=(0,Q.c)(18),{language:r,code:i}=e,[a,o]=(0,Z.useState)(!1),s;t[0]===i?s=t[1]:(s=async()=>{await navigator.clipboard.writeText(i),o(!0),setTimeout(()=>o(!1),2e3)},t[0]=i,t[1]=s);let c=s,l=r||`text`,u;t[2]===l?u=t[3]:(u=(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground font-mono`,children:l}),t[2]=l,t[3]=u);let d;t[4]===a?d=t[5]:(d=a?(0,$.jsx)(n,{}):(0,$.jsx)(M,{}),t[4]=a,t[5]=d);let f;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(`span`,{className:`sr-only`,children:`Copy code`}),t[6]=f):f=t[6];let p;t[7]!==c||t[8]!==d?(p=(0,$.jsxs)(q,{variant:`action`,size:`icon-xs`,onClick:c,children:[d,f]}),t[7]=c,t[8]=d,t[9]=p):p=t[9];let m;t[10]!==u||t[11]!==p?(m=(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border bg-muted/80 px-4 py-2`,children:[u,p]}),t[10]=u,t[11]=p,t[12]=m):m=t[12];let h;t[13]===i?h=t[14]:(h=(0,$.jsx)(`pre`,{className:`overflow-x-auto p-4 max-w-full`,children:(0,$.jsx)(`code`,{className:`text-xs font-mono text-foreground leading-relaxed`,children:i})}),t[13]=i,t[14]=h);let g;return t[15]!==m||t[16]!==h?(g=(0,$.jsxs)(`div`,{className:`group relative overflow-hidden rounded-lg border border-border bg-muted`,children:[m,h]}),t[15]=m,t[16]=h,t[17]=g):g=t[17],g}var Ri=pr,zi=Dr,Bi=Z.forwardRef((e,t)=>{let n=(0,Q.c)(13),r,i,a,o;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4]):({className:r,align:a,sideOffset:o,...i}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let s=a===void 0?`center`:a,c=o===void 0?4:o,l;n[5]===r?l=n[6]:(l=N(`z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,r),n[5]=r,n[6]=l);let u;return n[7]!==s||n[8]!==i||n[9]!==t||n[10]!==c||n[11]!==l?(u=(0,$.jsx)(In,{children:(0,$.jsx)($n,{ref:t,align:s,sideOffset:c,className:l,...i})}),n[7]=s,n[8]=i,n[9]=t,n[10]=c,n[11]=l,n[12]=u):u=n[12],u});Bi.displayName=$n.displayName;function Vi(e){let t=e.toLowerCase();return t.includes(`read`)||t.includes(`file`)?Kt:t.includes(`create`)?Xe:t.includes(`replace`)||t.includes(`edit`)?d:t.includes(`delete`)?B:t.includes(`terminal`)||t.includes(`bash`)||t.includes(`shell`)?E:t.includes(`run`)?S:t.includes(`git`)||t.includes(`branch`)?x:t.includes(`search`)||t.includes(`grep`)||t.includes(`find`)?rn:t.includes(`code`)||t.includes(`debug`)?Ie:t.includes(`test`)?nn:t.includes(`agent`)||t.includes(`subagent`)?Yt:t.includes(`copy`)?M:t.includes(`dir`)||t.includes(`list`)||t.includes(`ls`)?Wt:t.includes(`view`)||t.includes(`show`)?ve:t.includes(`config`)||t.includes(`setting`)?Le:t.includes(`image`)||t.includes(`generate_image`)?An:t.includes(`chat`)||t.includes(`message`)||t.includes(`ask`)?yt:ge}function Hi(e){let t=e.toLowerCase();return t.includes(`bash`)||t.includes(`terminal`)||t.includes(`shell`)?`Ran`:t.includes(`read`)||t.includes(`file`)?`Read`:t===`ast_grep`?`Code Search`:t===`agent`?`Subagent`:t===`generate_image`?`Make Image`:e}function Ui(e,t){if(!t||!e||typeof e!=`string`)return e;try{let n=t.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);return e.replace(new RegExp(n,`g`),`.`)}catch{return e}}function Wi(e){return typeof e==`string`?e:typeof e==`object`&&e?JSON.stringify(e,null,2):String(e)}function Gi(e){let t=e.trim();if(t.startsWith(`{`)&&t.endsWith(`}`)||t.startsWith(`[`)&&t.endsWith(`]`))try{return JSON.parse(t)}catch{return e}return e}function Ki(e){if(typeof e!=`object`||!e)return e;if(Array.isArray(e))return e.map(Ki);let t={};for(let[n,r]of Object.entries(e))if(typeof r==`string`){let e=Gi(r);t[n]=typeof e==`object`?Ki(e):r}else t[n]=Ki(r);return t}function qi(e){if(e==null||typeof e!=`string`)return``;let t=e;return t=t.replace(/\\\\n/g,`
7
+ `),t=t.replace(/\\\\"/g,`"`),t=t.replace(/\\n/g,`
8
+ `),t=t.replace(/\\"/g,`"`),t}function Ji(e){if(e==null)return``;let t=typeof e==`object`&&e?Ki(e):e;return qi(typeof t==`string`?t:t==null?``:JSON.stringify(t,null,2))}function Yi(e){let t=(0,Q.c)(116),{block:n,inline:r,resultContent:i}=e,[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(!1),{state:l}=Nr(),d,f,p,m,h,g,_,v,y,b,x;if(t[0]!==n.id||t[1]!==n.input||t[2]!==n.name||t[3]!==l.projects||t[4]!==l.selectedProjectId||t[5]!==l.selectedThreadId){let e;t[17]===l.selectedProjectId?e=t[18]:(e=e=>e.projectId===l.selectedProjectId,t[17]=l.selectedProjectId,t[18]=e);let r=l.projects.find(e)?.threads.find(e=>e.threadId===l.selectedThreadId)?.path;x=n.name??`Unknown Tool`,y=n.id??`unknown`;let i=n.input,a=i&&typeof i==`object`&&`description`in i,o=a?i.subagent_type:void 0,s;t[19]===o?s=t[20]:(s=o==null?null:JSON.stringify(o),t[19]=o,t[20]=s),_=s,p=i&&typeof i==`object`?i:null,d=x===`agent`&&p&&typeof p.agentName==`string`?p.agentName:null,b=a?null:Ui(Wi(i),r),g=Ui(a?String(i.prompt):null,r),f=Ui(p&&typeof p.command==`string`?p.command:null,r),h=p&&typeof p.pattern==`string`?p.pattern:null,m=p&&typeof p.lang==`string`?p.lang:null,v=Ui(p&&typeof p.path==`string`?p.path:null,r),t[0]=n.id,t[1]=n.input,t[2]=n.name,t[3]=l.projects,t[4]=l.selectedProjectId,t[5]=l.selectedThreadId,t[6]=d,t[7]=f,t[8]=p,t[9]=m,t[10]=h,t[11]=g,t[12]=_,t[13]=v,t[14]=y,t[15]=b,t[16]=x}else d=t[6],f=t[7],p=t[8],m=t[9],h=t[10],g=t[11],_=t[12],v=t[13],y=t[14],b=t[15],x=t[16];let S=v,C=p&&typeof p.offset==`number`?p.offset:null,w=p&&typeof p.limit==`number`?p.limit:null,T=x===`generate_image`&&p&&typeof p.prompt==`string`?p.prompt:null,E,D,k,A,j,M,N;if(t[21]!==d||t[22]!==f||t[23]!==s||t[24]!==a||t[25]!==T||t[26]!==r||t[27]!==p||t[28]!==m||t[29]!==w||t[30]!==C||t[31]!==S||t[32]!==h||t[33]!==g||t[34]!==i||t[35]!==_||t[36]!==y||t[37]!==b||t[38]!==x){N=Symbol.for(`react.early_return_sentinel`);bb0:{let e=Vi(x),n=x===`todo`&&p?p.status:void 0,l=(x===`todo`?n===`done`?nn:n===`working`?U:O:null)??e,v;if(t[46]!==w||t[47]!==C||t[48]!==x?(v=function(){let e=x.charAt(0).toUpperCase()+x.slice(1);return x.toLowerCase()===`bash`&&(e=`Ran`),x.toLowerCase()===`ast_grep`&&(e=`Code Search`),x.toLowerCase()===`generate_image`&&(e=`Make Image`),x.toLowerCase().includes(`read`)&&(C!==null||w!==null)&&(C!==null&&w!==null?e+=` (lines ${C} to ${C+w})`:C===null?e+=` (${w} lines)`:e+=` (from line ${C})`),e},t[46]=w,t[47]=C,t[48]=x,t[49]=v):v=t[49],E=v,r){if(x===`todo`){N=null;break bb0}if(f!==null&&i){let e;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(e=()=>c(!0),t[50]=e):e=t[50];let n=(0,Z.createElement)(l,{className:`h-3.5 w-3.5 shrink-0 text-brand`}),r=E(),a;t[51]===r?a=t[52]:(a=(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:r}),t[51]=r,t[52]=a);let o;t[53]===f?o=t[54]:(o=(0,$.jsx)(`code`,{className:`text-xs font-mono text-muted-foreground break-all rounded bg-muted/60 px-1 py-0.5`,children:f}),t[53]=f,t[54]=o);let d;t[55]===f?d=t[56]:(d=(0,$.jsx)(u,{children:(0,$.jsx)(ze,{children:(0,$.jsx)(`code`,{className:`text-sm font-mono`,children:f})})}),t[55]=f,t[56]=d);let p;t[57]===i?p=t[58]:(p=(0,$.jsx)(`pre`,{className:`text-xs bg-muted p-3 rounded font-mono whitespace-pre-wrap overflow-auto flex-1 text-foreground`,children:i}),t[57]=i,t[58]=p);let m;t[59]!==d||t[60]!==p?(m=(0,$.jsxs)(K,{className:`max-w-3xl max-h-[80vh] flex flex-col`,children:[d,p]}),t[59]=d,t[60]=p,t[61]=m):m=t[61];let h;t[62]!==s||t[63]!==m?(h=(0,$.jsx)(L,{open:s,onOpenChange:c,children:m}),t[62]=s,t[63]=m,t[64]=h):h=t[64],N=(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`button`,{type:`button`,onClick:e,className:`py-0.5 flex items-center gap-2 flex-wrap hover:opacity-70 transition-opacity text-left`,title:`Click to view output`,children:[n,a,o]}),h]});break bb0}let e=g??(b&&!f&&!S&&!h)?(0,$.jsxs)(Ri,{children:[(0,$.jsx)(zi,{asChild:!0,children:(0,$.jsx)(`span`,{title:x,className:`inline-flex`,children:(0,$.jsxs)(`button`,{type:`button`,className:`inline-flex shrink-0 items-center gap-1 rounded p-0.5 text-muted-foreground hover:text-foreground focus:outline-none focus-visible:ring-2 focus-visible:ring-ring`,"aria-label":`Show tool details`,children:[(0,Z.createElement)(l,{className:`h-3.5 w-3.5 text-brand`}),(0,$.jsx)(`span`,{className:`text-xs`,children:E()})]})})}),(0,$.jsx)(Bi,{className:`w-80 max-h-80 overflow-auto`,align:`start`,children:(0,$.jsxs)(`div`,{className:`text-xs text-muted-foreground space-y-2`,children:[(0,$.jsxs)(`div`,{className:`font-mono`,children:[`ID: `,y]}),g?(0,$.jsx)(`div`,{className:`whitespace-pre-wrap leading-relaxed`,children:g}):b?(0,$.jsx)(`pre`,{className:`font-mono whitespace-pre-wrap overflow-auto max-h-48`,children:b}):null]})})]}):(0,$.jsxs)(`span`,{title:x,className:`inline-flex items-center gap-1`,children:[(0,Z.createElement)(l,{className:`h-3.5 w-3.5 shrink-0 text-brand`}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:E()})]}),n;t[65]===f?n=t[66]:(n=f!==null&&(0,$.jsx)(`code`,{className:`text-xs font-mono text-muted-foreground break-all rounded bg-muted/60 px-1 py-0.5`,children:f}),t[65]=f,t[66]=n);let r;t[67]===h?r=t[68]:(r=h!==null&&(0,$.jsx)(`code`,{className:`text-xs font-mono text-muted-foreground break-all rounded bg-muted/60 px-1 py-0.5`,children:h}),t[67]=h,t[68]=r);let a;t[69]===m?a=t[70]:(a=m!==null&&(0,$.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded bg-muted text-muted-foreground`,children:m}),t[69]=m,t[70]=a);let o;t[71]===S?o=t[72]:(o=S!==null&&(0,$.jsx)(`span`,{className:`text-xs font-mono text-muted-foreground truncate max-w-[200px] sm:max-w-[320px]`,title:S,children:S}),t[71]=S,t[72]=o);let p;t[73]===d?p=t[74]:(p=d&&(0,$.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded bg-muted text-muted-foreground font-mono`,children:d}),t[73]=d,t[74]=p);let v;t[75]===_?v=t[76]:(v=_&&(0,$.jsx)(`span`,{className:`text-xs px-2 py-0.5 rounded bg-muted text-muted-foreground`,children:_}),t[75]=_,t[76]=v);let C;t[77]===T?C=t[78]:(C=T!==null&&(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground truncate max-w-[200px] sm:max-w-[320px]`,title:T,children:T}),t[77]=T,t[78]=C);let w;t[79]!==n||t[80]!==r||t[81]!==a||t[82]!==o||t[83]!==p||t[84]!==v||t[85]!==C||t[86]!==e?(w=(0,$.jsxs)(`div`,{className:`py-0.5 flex items-center gap-2 flex-wrap`,children:[e,n,r,a,o,p,v,C]}),t[79]=n,t[80]=r,t[81]=a,t[82]=o,t[83]=p,t[84]=v,t[85]=C,t[86]=e,t[87]=w):w=t[87],N=w;break bb0}M=`mb-3 rounded-lg border border-blue-200 dark:border-blue-800 bg-blue-50 dark:bg-blue-900/20 overflow-hidden`,t[88]===a?D=t[89]:(D=()=>o(!a),t[88]=a,t[89]=D),k=`w-full px-3 py-2 flex items-center gap-2 text-sm font-medium text-blue-900 dark:text-blue-100 hover:bg-blue-100 dark:hover:bg-blue-900/40 transition-colors`,A=x,j=(0,Z.createElement)(l,{className:`h-4 w-4 text-brand`})}t[21]=d,t[22]=f,t[23]=s,t[24]=a,t[25]=T,t[26]=r,t[27]=p,t[28]=m,t[29]=w,t[30]=C,t[31]=S,t[32]=h,t[33]=g,t[34]=i,t[35]=_,t[36]=y,t[37]=b,t[38]=x,t[39]=E,t[40]=D,t[41]=k,t[42]=A,t[43]=j,t[44]=M,t[45]=N}else E=t[39],D=t[40],k=t[41],A=t[42],j=t[43],M=t[44],N=t[45];if(N!==Symbol.for(`react.early_return_sentinel`))return N;let P=E(),F;t[90]===P?F=t[91]:(F=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:P}),t[90]=P,t[91]=F);let I;t[92]===d?I=t[93]:(I=d&&(0,$.jsx)(`span`,{className:`text-xs px-2 py-0.5 rounded bg-blue-200 dark:bg-blue-800 text-blue-800 dark:text-blue-200 font-mono`,children:d}),t[92]=d,t[93]=I);let R;t[94]===_?R=t[95]:(R=_&&(0,$.jsx)(`span`,{className:`text-xs px-2 py-0.5 rounded bg-blue-200 dark:bg-blue-800 text-blue-800 dark:text-blue-200`,children:_}),t[94]=_,t[95]=R);let z;t[96]===a?z=t[97]:(z=a?(0,$.jsx)(Ce,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(Ke,{className:`h-4 w-4 shrink-0`}),t[96]=a,t[97]=z);let B;t[98]!==I||t[99]!==R||t[100]!==z||t[101]!==D||t[102]!==k||t[103]!==A||t[104]!==j||t[105]!==F?(B=(0,$.jsxs)(`button`,{onClick:D,className:k,title:A,children:[j,F,I,R,z]}),t[98]=I,t[99]=R,t[100]=z,t[101]=D,t[102]=k,t[103]=A,t[104]=j,t[105]=F,t[106]=B):B=t[106];let V;t[107]!==a||t[108]!==g||t[109]!==y||t[110]!==b?(V=a&&(0,$.jsxs)(`div`,{className:`px-3 py-2 bg-white dark:bg-slate-950 border-t border-blue-200 dark:border-blue-800`,children:[(0,$.jsxs)(`div`,{className:`text-xs text-muted-foreground mb-2 font-mono text-blue-700 dark:text-blue-300`,children:[`ID: `,y]}),g?(0,$.jsx)(`div`,{className:`text-xs bg-slate-100 dark:bg-slate-900 p-3 rounded whitespace-pre-wrap overflow-auto max-h-64 leading-relaxed`,children:g}):b?(0,$.jsx)(`pre`,{className:`text-xs bg-slate-100 dark:bg-slate-900 p-2 rounded font-mono whitespace-pre-wrap overflow-auto max-h-48`,children:b}):null]}),t[107]=a,t[108]=g,t[109]=y,t[110]=b,t[111]=V):V=t[111];let H;return t[112]!==B||t[113]!==V||t[114]!==M?(H=(0,$.jsxs)(`div`,{className:M,children:[B,V]}),t[112]=B,t[113]=V,t[114]=M,t[115]=H):H=t[115],H}var Xi=(0,Z.createContext)({todos:[],setTodos:()=>{}});function Zi(e){let t=(0,Q.c)(7),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=[],t[0]=r):r=t[0];let[i,a]=(0,Z.useState)(r),o;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(o=e=>{a(e)},t[1]=o):o=t[1];let s=o,c;t[2]===i?c=t[3]:(c={todos:i,setTodos:s},t[2]=i,t[3]=c);let l;return t[4]!==n||t[5]!==c?(l=(0,$.jsx)(Xi.Provider,{value:c,children:n}),t[4]=n,t[5]=c,t[6]=l):l=t[6],l}function Qi(e){let t=[e.result,e.content],n=[];for(let e of t)if(typeof e==`string`)n.push(e);else if(Array.isArray(e))for(let t of e)typeof t==`object`&&t&&`text`in t&&typeof t.text==`string`&&n.push(t.text);for(let e of n){let t=e.trim();if(t.startsWith(`{`))try{let e=JSON.parse(t);if(e&&Array.isArray(e.todos))return e.todos}catch(e){console.error(`Failed to parse todo JSON:`,e)}}return null}function $i(e){let t=(0,Q.c)(17),{todos:n}=e,{todos:r,setTodos:i}=(0,Z.useContext)(Xi),a,o;t[0]!==n||t[1]!==i?(a=()=>{i(n)},o=[n,i],t[0]=n,t[1]=i,t[2]=a,t[3]=o):(a=t[2],o=t[3]),(0,Z.useEffect)(a,o);let s=r.length>0?r:n,c;t[4]===s?c=t[5]:(c=s.filter(ta),t[4]=s,t[5]=c);let l=c.length,u;t[6]===s.length?u=t[7]:(u=s.length===0&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No todo items.`}),t[6]=s.length,t[7]=u);let d;t[8]===s?d=t[9]:(d=s.map(ea),t[8]=s,t[9]=d);let f;t[10]!==l||t[11]!==s.length?(f=s.length>0&&(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground pt-1`,children:[l,`/`,s.length,` completed`]}),t[10]=l,t[11]=s.length,t[12]=f):f=t[12];let p;return t[13]!==u||t[14]!==d||t[15]!==f?(p=(0,$.jsxs)(`div`,{className:`space-y-1`,children:[u,d,f]}),t[13]=u,t[14]=d,t[15]=f,t[16]=p):p=t[16],p}function ea(e){return(0,$.jsxs)(`div`,{className:`flex items-start gap-2 text-sm`,children:[e.status===`done`?(0,$.jsx)(nn,{className:`h-4 w-4 shrink-0 mt-0.5 text-green-500`}):e.status===`working`?(0,$.jsx)(He,{className:`h-4 w-4 shrink-0 mt-0.5 text-yellow-500`}):(0,$.jsx)(O,{className:`h-4 w-4 shrink-0 mt-0.5 text-muted-foreground`}),(0,$.jsx)(`span`,{className:e.status===`done`?`line-through text-muted-foreground`:`text-foreground`,children:e.description})]},e.id)}function ta(e){return e.status===`done`}function na(e){let t=(0,Q.c)(4),{todos:n}=e,{setTodos:r}=(0,Z.useContext)(Xi),i,a;return t[0]!==r||t[1]!==n?(i=()=>{r(n)},a=[n,r],t[0]=r,t[1]=n,t[2]=i,t[3]=a):(i=t[2],a=t[3]),(0,Z.useEffect)(i,a),null}function ra(e){let t=(0,Q.c)(19),{todos:n}=e,[r,i]=(0,Z.useState)(!0),a;t[0]===n?a=t[1]:(a=n.filter(ia),t[0]=n,t[1]=a);let o=a.length;if(n.length===0||o===n.length)return null;let s=`${n.length-o} Tasks To Do`,c;t[2]===r?c=t[3]:(c=()=>i(!r),t[2]=r,t[3]=c);let l;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(St,{className:`h-4 w-4 shrink-0`}),t[4]=l):l=t[4];let u;t[5]===s?u=t[6]:(u=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:s}),t[5]=s,t[6]=u);let d;t[7]===r?d=t[8]:(d=r?(0,$.jsx)(Ce,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(Ke,{className:`h-4 w-4 shrink-0`}),t[7]=r,t[8]=d);let f;t[9]!==c||t[10]!==u||t[11]!==d?(f=(0,$.jsxs)(`button`,{onClick:c,className:`w-full px-3 py-2 flex items-center gap-2 text-sm font-medium text-foreground hover:bg-muted transition-colors text-left`,title:`Todo list`,children:[l,u,d]}),t[9]=c,t[10]=u,t[11]=d,t[12]=f):f=t[12];let p;t[13]!==r||t[14]!==n?(p=r&&(0,$.jsx)(`div`,{className:`px-3 py-3 bg-background border-t border-border`,children:(0,$.jsx)($i,{todos:n})}),t[13]=r,t[14]=n,t[15]=p):p=t[15];let m;return t[16]!==f||t[17]!==p?(m=(0,$.jsxs)(`div`,{className:`mb-3 rounded-lg border border-border bg-muted/50 overflow-hidden`,children:[f,p]}),t[16]=f,t[17]=p,t[18]=m):m=t[18],m}function ia(e){return e.status===`done`}function aa(e){let t=[];if(typeof e==`string`)t.push(e);else if(Array.isArray(e))for(let n of e)typeof n==`object`&&n&&`text`in n&&typeof n.text==`string`&&t.push(n.text);for(let e of t){let t=e.trim();if(t.startsWith(`{`))try{let e=JSON.parse(t);if(e.imageUrl||e.imageData)return{imageUrl:e.imageUrl,imageData:e.imageData,model:e.model}}catch{}}return null}function oa(e){let t=(0,Q.c)(29),{imageUrl:r,imageData:a}=e,[o,s]=(0,Z.useState)(!1),c=a?`data:image/png;base64,${a}`:r??``,l;t[0]===c?l=t[1]:(l=async()=>{let e=`generated-image-${Date.now()}.png`,{path:t}=await i(c.startsWith(`data:`)?{imageData:c.replace(/^data:[^;]+;base64,/,``),filename:e}:{imageUrl:c,filename:e});X({title:`Saved to downloads: ${t.split(`/`).pop()}`})},t[0]=c,t[1]=l);let u=l,d;t[2]===c?d=t[3]:(d=async()=>{await b(c.startsWith(`data:`)?{imageData:c.replace(/^data:[^;]+;base64,/,``)}:{imageUrl:c}),s(!0),setTimeout(()=>s(!1),2e3)},t[2]=c,t[3]=d);let f=d,p;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(p={maxHeight:`512px`},t[4]=p):p=t[4];let m;t[5]===c?m=t[6]:(m=(0,$.jsx)(`img`,{src:c,alt:`Generated image`,className:`max-w-full rounded-lg block`,style:p}),t[5]=c,t[6]=m);let h;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(ne,{className:`h-3.5 w-3.5`}),t[7]=h):h=t[7];let g;t[8]===u?g=t[9]:(g=(0,$.jsx)(Yr,{asChild:!0,children:(0,$.jsx)(`button`,{onClick:u,className:`flex items-center justify-center h-7 w-7 rounded-md bg-background/80 backdrop-blur-sm border border-border text-foreground hover:bg-background transition-colors`,children:h})}),t[8]=u,t[9]=g);let _;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(Kr,{children:`Save image`}),t[10]=_):_=t[10];let v;t[11]===g?v=t[12]:(v=(0,$.jsxs)(Jr,{children:[g,_]}),t[11]=g,t[12]=v);let y;t[13]===o?y=t[14]:(y=o?(0,$.jsx)(n,{className:`h-3.5 w-3.5 text-green-500`}):(0,$.jsx)(M,{className:`h-3.5 w-3.5`}),t[13]=o,t[14]=y);let x;t[15]!==f||t[16]!==y?(x=(0,$.jsx)(Yr,{asChild:!0,children:(0,$.jsx)(`button`,{onClick:f,className:`flex items-center justify-center h-7 w-7 rounded-md bg-background/80 backdrop-blur-sm border border-border text-foreground hover:bg-background transition-colors`,children:y})}),t[15]=f,t[16]=y,t[17]=x):x=t[17];let S=o?`Copied!`:`Copy to clipboard`,C;t[18]===S?C=t[19]:(C=(0,$.jsx)(Kr,{children:S}),t[18]=S,t[19]=C);let w;t[20]!==x||t[21]!==C?(w=(0,$.jsxs)(Jr,{children:[x,C]}),t[20]=x,t[21]=C,t[22]=w):w=t[22];let T;t[23]!==w||t[24]!==v?(T=(0,$.jsx)(`div`,{className:`absolute top-2 right-2 flex gap-1 opacity-0 group-hover/img:opacity-100 transition-opacity`,children:(0,$.jsxs)(qr,{children:[v,w]})}),t[23]=w,t[24]=v,t[25]=T):T=t[25];let E;return t[26]!==T||t[27]!==m?(E=(0,$.jsxs)(`div`,{className:`mb-3 relative group/img inline-block max-w-full`,children:[m,T]}),t[26]=T,t[27]=m,t[28]=E):E=t[28],E}function sa(e){let t=(0,Q.c)(70),{block:n,inline:r}=e,[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(!1),{state:c}=Nr(),l=c.projects,d,f,p,m,h,g,_,v;if(t[0]!==n||t[1]!==r||t[2]!==c.projects||t[3]!==c.selectedProjectId||t[4]!==c.selectedThreadId){g=Symbol.for(`react.early_return_sentinel`);bb0:{let e;t[13]===c.selectedProjectId?e=t[14]:(e=e=>e.projectId===c.selectedProjectId,t[13]=c.selectedProjectId,t[14]=e);let i=l.find(e)?.threads.find(e=>e.threadId===c.selectedThreadId)?.path;v=n.toolName??`Unknown Tool`,_=n.toolCallId??`unknown`;let a=n,o=n.result??a.content,s;t[15]!==a||t[16]!==v?(s=v===`todo`?Qi(a):null,t[15]=a,t[16]=v,t[17]=s):s=t[17];let u=s;if(p=Ui(Ji(o),i),!(p.length>0)&&u===null){g=null;break bb0}if(d=Hi(v),typeof o==`object`&&o){let e=o,n=e.returnDisplay??e.return_display;if(typeof n==`string`&&n.trim()){let e;t[18]===n?e=t[19]:(e=n.trim(),t[18]=n,t[19]=e),d=e}else if(v===`read`||v===`file_read`){let n=e.filePath??e.file_path??e.path??``;if(n){let e;t[20]===n?e=t[21]:(e=n.split(`/`).pop()??n,t[20]=n,t[21]=e),d=`Completed ${e}`}}}else if(o==null){let e;t[22]===v?e=t[23]:(e=Hi(v),t[22]=v,t[23]=e),d=`${e} (no result)`}if(d=Ui(d,i),u!==null){let e;t[24]===u?e=t[25]:(e=(0,$.jsx)(na,{todos:u}),t[24]=u,t[25]=e),g=e;break bb0}if(v===`generate_image`){let e;t[26]===o?e=t[27]:(e=aa(o),t[26]=o,t[27]=e);let n=e;if(n&&(n.imageUrl||n.imageData)){let e;t[28]!==n.imageData||t[29]!==n.imageUrl?(e=(0,$.jsx)(oa,{imageUrl:n.imageUrl,imageData:n.imageData}),t[28]=n.imageData,t[29]=n.imageUrl,t[30]=e):e=t[30],g=e;break bb0}}if(r){g=null;break bb0}let y;t[31]===v?y=t[32]:(y=v.toLowerCase().includes(`bash`),t[31]=v,t[32]=y),f=y,m=p?p.split(`
9
+ `):[],h=f?m.slice(0,3).join(`
10
+ `):p}t[0]=n,t[1]=r,t[2]=c.projects,t[3]=c.selectedProjectId,t[4]=c.selectedThreadId,t[5]=d,t[6]=f,t[7]=p,t[8]=m,t[9]=h,t[10]=g,t[11]=_,t[12]=v}else d=t[5],f=t[6],p=t[7],m=t[8],h=t[9],g=t[10],_=t[11],v=t[12];if(g!==Symbol.for(`react.early_return_sentinel`))return g;let y=h,b=f&&m.length>3;if(f){let e;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(nn,{className:`h-4 w-4 shrink-0`}),t[33]=e):e=t[33];let n;t[34]===d?n=t[35]:(n=(0,$.jsxs)(`div`,{className:`px-3 py-2 flex items-center gap-2 text-sm font-medium text-foreground`,children:[e,(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:d})]}),t[34]=d,t[35]=n);let r;t[36]!==b||t[37]!==y||t[38]!==p||t[39]!==m?(r=p&&(0,$.jsxs)(`div`,{className:`px-3 pb-2 bg-background border-t border-border`,children:[(0,$.jsxs)(`pre`,{className:`text-xs bg-muted p-2 rounded font-mono whitespace-pre-wrap overflow-auto text-foreground text-left mt-2${b?` cursor-pointer hover:bg-muted/80`:``}`,onClick:b?()=>s(!0):void 0,title:b?`Click to see full output`:void 0,children:[y,b&&(0,$.jsxs)(`span`,{className:`text-muted-foreground`,children:[`
11
+ `,`...`]})]}),b&&(0,$.jsxs)(`button`,{type:`button`,onClick:()=>s(!0),className:`mt-1 text-xs text-brand hover:underline`,children:[`Show full output (`,m.length,` lines)`]})]}),t[36]=b,t[37]=y,t[38]=p,t[39]=m,t[40]=r):r=t[40];let i;t[41]!==n||t[42]!==r?(i=(0,$.jsxs)(`div`,{className:`mb-3 rounded-lg border border-border bg-muted/50 overflow-hidden`,children:[n,r]}),t[41]=n,t[42]=r,t[43]=i):i=t[43];let a;t[44]!==o||t[45]!==b||t[46]!==p?(a=b&&(0,$.jsx)(L,{open:o,onOpenChange:s,children:(0,$.jsxs)(K,{className:`max-w-3xl max-h-[80vh] flex flex-col`,children:[(0,$.jsx)(u,{children:(0,$.jsx)(ze,{children:`Full Output`})}),(0,$.jsx)(`pre`,{className:`text-xs bg-muted p-3 rounded font-mono whitespace-pre-wrap overflow-auto flex-1 text-foreground`,children:p})]})}),t[44]=o,t[45]=b,t[46]=p,t[47]=a):a=t[47];let c;return t[48]!==i||t[49]!==a?(c=(0,$.jsxs)($.Fragment,{children:[i,a]}),t[48]=i,t[49]=a,t[50]=c):c=t[50],c}let x;t[51]===i?x=t[52]:(x=()=>a(!i),t[51]=i,t[52]=x);let S=`${v} result`,C;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,$.jsx)(nn,{className:`h-4 w-4 shrink-0`}),t[53]=C):C=t[53];let w;t[54]===d?w=t[55]:(w=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:d}),t[54]=d,t[55]=w);let T;t[56]===i?T=t[57]:(T=i?(0,$.jsx)(Ce,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(Ke,{className:`h-4 w-4 shrink-0`}),t[56]=i,t[57]=T);let E;t[58]!==x||t[59]!==S||t[60]!==w||t[61]!==T?(E=(0,$.jsxs)(`button`,{onClick:x,className:`w-full px-3 py-2 flex items-center gap-2 text-sm font-medium text-foreground hover:bg-muted transition-colors text-left`,title:S,children:[C,w,T]}),t[58]=x,t[59]=S,t[60]=w,t[61]=T,t[62]=E):E=t[62];let D;t[63]!==i||t[64]!==p||t[65]!==_?(D=i&&(0,$.jsxs)(`div`,{className:`px-3 py-2 bg-background border-t border-border`,children:[(0,$.jsxs)(`div`,{className:`text-xs text-muted-foreground mb-2 font-mono`,children:[`Call ID: `,_]}),p&&(0,$.jsx)(`pre`,{className:`text-xs bg-muted p-2 rounded font-mono whitespace-pre-wrap overflow-auto max-h-48 text-foreground text-left`,children:p})]}),t[63]=i,t[64]=p,t[65]=_,t[66]=D):D=t[66];let O;return t[67]!==D||t[68]!==E?(O=(0,$.jsxs)(`div`,{className:`mb-3 rounded-lg border border-border bg-muted/50 overflow-hidden`,children:[E,D]}),t[67]=D,t[68]=E,t[69]=O):O=t[69],O}function ca(e){let t=(0,Q.c)(19),{text:n,isStreaming:r,hasContentAfter:i}=e,a=r===void 0?!1:r,o=i===void 0?!1:i,[s,c]=(0,Z.useState)(null),l=(0,Z.useRef)(a),u=(0,Z.useRef)(o),d,f;if(t[0]!==o||t[1]!==a?(d=()=>{(l.current&&!a||!u.current&&o)&&(0,Z.startTransition)(()=>{c(!1)}),l.current=a,u.current=o},f=[a,o,c],t[0]=o,t[1]=a,t[2]=d,t[3]=f):(d=t[2],f=t[3]),(0,Z.useEffect)(d,f),!n?.trim())return null;let p=s??a,m;t[4]===p?m=t[5]:(m=()=>c(!p),t[4]=p,t[5]=m);let h,g;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(mt,{className:`h-4 w-4 shrink-0 text-brand`}),g=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:`Thinking`}),t[6]=h,t[7]=g):(h=t[6],g=t[7]);let _;t[8]===p?_=t[9]:(_=p?(0,$.jsx)(Ce,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(Ke,{className:`h-4 w-4 shrink-0`}),t[8]=p,t[9]=_);let v;t[10]!==m||t[11]!==_?(v=(0,$.jsxs)(`button`,{onClick:m,className:`w-full py-2 flex items-center gap-2 text-sm font-medium text-foreground hover:bg-muted/50 transition-colors text-left`,title:`Thinking`,children:[h,g,_]}),t[10]=m,t[11]=_,t[12]=v):v=t[12];let y;t[13]!==p||t[14]!==n?(y=p&&(0,$.jsx)(`div`,{className:`py-2 border-t border-border`,children:(0,$.jsx)(`div`,{className:`text-xs text-muted-foreground leading-relaxed whitespace-pre-wrap`,children:n})}),t[13]=p,t[14]=n,t[15]=y):y=t[15];let b;return t[16]!==y||t[17]!==v?(b=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[v,y]}),t[16]=y,t[17]=v,t[18]=b):b=t[18],b}function la({toolCall:e,className:t}){let{state:n,dispatch:r}=Nr(),[i,a]=(0,Z.useState)(!1),o=n.toolCallProgress[e.id];return(0,Z.useMemo)(()=>{if(!n.isStreaming)return{isActive:!1,isCompleted:!0};let t=!1,r=!1;for(let i of n.streamingSegments)if(i.type===`thinking`){for(let n of i.chunks)if(n.includes(e.id))try{let i=JSON.parse(n);if(Array.isArray(i))for(let n of i)n.type===`tool_use`&&n.id===e.id&&(t=!0),n.type===`tool-result`&&n.toolCallId===e.id&&(r=!0,t=!1)}catch{}}return t&&!n.isStreaming&&(r=!0,t=!1),{isActive:t,isCompleted:r}},[n.isStreaming,n.streamingSegments,e.id]).isActive?(0,$.jsxs)(`div`,{className:N(`border border-blue-200 dark:border-blue-800 bg-blue-50 dark:bg-blue-900/20 rounded-lg overflow-hidden mb-2`,t),children:[(0,$.jsxs)(`div`,{className:`px-3 py-2 flex items-center gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 flex-1`,children:[(0,$.jsx)(Et,{className:`h-3.5 w-3.5 animate-spin`}),(0,$.jsx)(`span`,{className:`text-sm font-medium text-blue-900 dark:text-blue-100`,children:e.name}),(0,$.jsx)(`span`,{className:`text-xs text-blue-700 dark:text-blue-300`,children:`running`})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(`button`,{onClick:()=>{a(e=>!e)},className:`p-1 hover:bg-blue-200 dark:hover:bg-blue-800 rounded transition-colors`,title:i?`Collapse`:`Expand`,children:i?(0,$.jsx)(Je,{className:`h-3.5 w-3.5`}):(0,$.jsx)(Ce,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(`button`,{onClick:()=>{r({type:Y.StopStream});let t={type:`tool-result`,toolCallId:e.id,toolName:e.name,result:`Tool execution was cancelled by the user. The command was taking too long or required user approval.`,isError:!0,content:`Tool execution was cancelled by the user. The command was taking too long or required user approval.`};r({type:Y.AppendStreamChunk,chunkType:`content`,content:JSON.stringify([t]),segments:n.streamingSegments})},className:`p-1 hover:bg-red-200 dark:hover:bg-red-800 rounded transition-colors text-red-600 dark:text-red-400`,title:`Stop tool execution`,children:(0,$.jsx)(v,{className:`h-3.5 w-3.5`})})]})]}),i&&(0,$.jsxs)(`div`,{className:`px-3 py-2 bg-white dark:bg-slate-950 border-t border-blue-200 dark:border-blue-800 min-h-[8rem] overflow-auto`,children:[(0,$.jsxs)(`div`,{className:`text-xs text-muted-foreground mb-2 font-mono text-blue-700 dark:text-blue-300`,children:[`ID: `,e.id]}),(0,$.jsxs)(`div`,{className:`mb-2`,children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground mb-1`,children:`Input:`}),(0,$.jsx)(`pre`,{className:`text-xs bg-slate-100 dark:bg-slate-900 p-2 rounded font-mono whitespace-pre-wrap overflow-auto max-h-48 border border-slate-200 dark:border-slate-700`,children:(e=>JSON.stringify(e,null,2))(e.input)})]}),o&&(0,$.jsxs)(`div`,{className:`mb-2`,children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground mb-1`,children:`Progress:`}),(0,$.jsxs)(`div`,{className:`text-xs bg-green-50 dark:bg-green-900/20 p-2 rounded border border-green-200 dark:border-green-800`,children:[(0,$.jsx)(`div`,{className:`text-green-700 dark:text-green-300 font-mono`,children:o.delta}),o.partial?.content?.[0]?.arguments&&typeof o.partial.content[0].arguments==`object`&&`content`in o.partial.content[0].arguments&&typeof o.partial.content[0].arguments.content==`string`&&(0,$.jsxs)(`div`,{className:`mt-1 text-green-600 dark:text-green-400 font-mono text-xs`,children:[`Building: `,o.partial.content[0].arguments.content.slice(-50),o.partial.content[0].arguments.content.length>50&&`...`]})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-blue-600 dark:text-blue-400`,children:[(0,$.jsx)(Et,{className:`h-3 w-3 animate-spin`}),`Executing`,o&&` with progress`,`...`]})]})]}):null}function ua(e){let t=(0,Q.c)(51),{toolCallId:r,question:i,options:a,context:o}=e,[s,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(``),[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(null),_;t[0]!==p||t[1]!==r?(_=async e=>{if(!(!e.trim()||p)){m(!0);try{await Vt(r,e.trim()),f(e.trim()),u(!0)}catch(e){console.error(`Failed to submit answer:`,e),m(!1),g(null)}}},t[0]=p,t[1]=r,t[2]=_):_=t[2];let v=_,y;t[3]!==v||t[4]!==p||t[5]!==l?(y=e=>{l||p||(g(e),v(e))},t[3]=v,t[4]=p,t[5]=l,t[6]=y):y=t[6];let b=y,x;t[7]!==s||t[8]!==v||t[9]!==p||t[10]!==l?(x=()=>{if(l||p)return;let e=s.trim();e&&v(e)},t[7]=s,t[8]=v,t[9]=p,t[10]=l,t[11]=x):x=t[11];let S=x,C;t[12]===S?C=t[13]:(C=e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),S())},t[12]=S,t[13]=C);let w=C;if(l){let e,r;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(n,{className:`h-4 w-4`}),r=(0,$.jsx)(`span`,{className:`font-medium`,children:`Answered:`}),t[14]=e,t[15]=r):(e=t[14],r=t[15]);let i;return t[16]===d?i=t[17]:(i=(0,$.jsx)(`div`,{className:`rounded-lg border border-green-200 dark:border-green-800 bg-green-50 dark:bg-green-900/20 p-3 my-2`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-green-800 dark:text-green-200`,children:[e,r,(0,$.jsx)(`span`,{children:d})]})}),t[16]=d,t[17]=i),i}let T;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(U,{className:`h-5 w-5 text-brand dark:text-brand shrink-0 mt-0.5`}),t[18]=T):T=t[18];let E;t[19]===i?E=t[20]:(E=(0,$.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:(0,$.jsx)(Di,{content:i})}),t[19]=i,t[20]=E);let D;t[21]===o?D=t[22]:(D=o&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:o}),t[21]=o,t[22]=D);let O;t[23]!==E||t[24]!==D?(O=(0,$.jsxs)(`div`,{className:`flex items-start gap-2 mb-3`,children:[T,(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[E,D]})]}),t[23]=E,t[24]=D,t[25]=O):O=t[25];let k;t[26]!==b||t[27]!==p||t[28]!==a||t[29]!==h?(k=a&&a.length>0&&(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2 mb-3`,children:a.map(e=>{let t=h===e;return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>b(e),disabled:p,className:N(`rounded-md border px-3 py-1.5 text-sm transition-colors disabled:opacity-50 flex items-center gap-1.5`,t?`border-brand bg-brand/20 dark:bg-brand/30 text-foreground font-medium`:`border-brand/30 dark:border-brand/40 bg-background text-foreground hover:bg-brand/10 dark:hover:bg-brand/20`),children:[t&&(0,$.jsx)(n,{className:`h-3.5 w-3.5 text-brand`}),e]},e)})}),t[26]=b,t[27]=p,t[28]=a,t[29]=h,t[30]=k):k=t[30];let A;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(A=e=>c(e.target.value),t[31]=A):A=t[31];let j=a?.length?`Or type a custom answer...`:`Type your answer...`,M;t[32]!==s||t[33]!==w||t[34]!==p||t[35]!==j?(M=(0,$.jsx)(`input`,{type:`text`,value:s,onChange:A,onKeyDown:w,placeholder:j,disabled:p,className:`flex-1 rounded-md border border-brand/30 dark:border-brand/40 bg-background px-3 py-1.5 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-brand dark:focus:ring-brand disabled:opacity-50`}),t[32]=s,t[33]=w,t[34]=p,t[35]=j,t[36]=M):M=t[36];let P;t[37]!==s||t[38]!==p?(P=p||!s.trim(),t[37]=s,t[38]=p,t[39]=P):P=t[39];let F;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,$.jsx)(G,{className:`h-4 w-4`}),t[40]=F):F=t[40];let I;t[41]!==S||t[42]!==P?(I=(0,$.jsx)(`button`,{type:`button`,onClick:S,disabled:P,className:`rounded-md bg-brand px-3 py-1.5 text-sm text-white hover:bg-brand/90 transition-colors disabled:opacity-50`,children:F}),t[41]=S,t[42]=P,t[43]=I):I=t[43];let L;t[44]!==M||t[45]!==I?(L=(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[M,I]}),t[44]=M,t[45]=I,t[46]=L):L=t[46];let R;return t[47]!==L||t[48]!==O||t[49]!==k?(R=(0,$.jsxs)(`div`,{className:`rounded-lg border border-brand/20 dark:border-brand/30 bg-brand/5 dark:bg-brand/10 p-4 my-2`,children:[O,k,L]}),t[47]=L,t[48]=O,t[49]=k,t[50]=R):R=t[50],R}function da(e){let t=(0,Q.c)(50),{toolCallId:n,intention:r,code:i}=e,{state:a}=Nr(),o=a.selectedThreadId,[s,c]=(0,Z.useState)(`running`),[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)(null),m=(0,Z.useRef)(!1),h=(0,Z.useRef)(null),g;t[0]!==i||t[1]!==r||t[2]!==s||t[3]!==o||t[4]!==n?(g=()=>{if(m.current||s!==`running`||!o)return;m.current=!0;let e=window.location.origin;window.location.port===`5173`&&(e=`http://${window.location.hostname}:641`);let t=new Blob([`
12
+ self.onmessage = async (e) => {
13
+ if (e.data.type === 'START') {
14
+ const { threadId, apiBaseUrl, code } = e.data;
15
+
16
+ self.callTool = async function(toolName, params) {
17
+ const response = await fetch(apiBaseUrl + '/api/browser-js/execute-tool', {
18
+ method: 'POST',
19
+ headers: { 'Content-Type': 'application/json' },
20
+ body: JSON.stringify({ threadId, toolName, params })
21
+ });
22
+ if (!response.ok) {
23
+ let errText = await response.text();
24
+ try {
25
+ const parsed = JSON.parse(errText);
26
+ const e = parsed.error || {};
27
+ errText = e.details || e.message || errText;
28
+ } catch (_) {}
29
+ return { text: null, error: 'Tool ' + toolName + ' failed: ' + errText };
30
+ }
31
+ const json = await response.json();
32
+ const text = json.content && json.content[0] ? json.content[0].text : null;
33
+ return { text, error: null };
34
+ };
35
+
36
+ try {
37
+ const AsyncFunction = Object.getPrototypeOf(async function(){}).constructor;
38
+ const userFunc = new AsyncFunction('callTool', code);
39
+ const res = await userFunc(self.callTool);
40
+ self.postMessage({ type: 'DONE', result: res !== undefined ? res : null });
41
+ } catch (err) {
42
+ self.postMessage({ type: 'ERROR', error: err.stack || err.message || String(err) });
43
+ }
44
+ }
45
+ };
46
+ `],{type:`application/javascript`}),a=URL.createObjectURL(t),l=new Worker(a);return console.log(`[web-worker] sending to worker:`,{toolCallId:n,intention:r,codeLength:i.length}),h.current=setTimeout(async()=>{console.error(`[web-worker] timed out after 10 seconds:`,{toolCallId:n,intention:r}),c(`error`),p(`Web worker timed out after 10 seconds`);try{await _n(n,{error:`Web worker timed out after 10 seconds`})}catch(e){console.error(`Failed to submit browser js timeout error`,e)}l.terminate(),URL.revokeObjectURL(a)},1e4),l.onmessage=async e=>{if(h.current&&clearTimeout(h.current),console.log(`[web-worker] received from worker:`,e.data.type,e.data.type===`DONE`?e.data.result:e.data.error),e.data.type===`DONE`){c(`success`);let t=e.data.result;d(t==null?null:typeof t==`string`?t:JSON.stringify(t,null,2));try{await _n(n,e.data.result)}catch(e){console.error(`Failed to submit browser js result`,e)}}else if(e.data.type===`ERROR`){c(`error`),p(e.data.error);try{await _n(n,{error:e.data.error})}catch(e){console.error(`Failed to submit browser js error`,e)}}l.terminate(),URL.revokeObjectURL(a)},l.onerror=async e=>{h.current&&clearTimeout(h.current);let t=e.message||(e instanceof Error?e.toString():JSON.stringify(e));c(`error`),p(t);try{await _n(n,{error:t})}catch(e){console.error(`Failed to submit browser js outer error`,e)}l.terminate(),URL.revokeObjectURL(a)},l.postMessage({type:`START`,threadId:o,apiBaseUrl:e,code:i}),()=>{l.terminate(),URL.revokeObjectURL(a)}},t[0]=i,t[1]=r,t[2]=s,t[3]=o,t[4]=n,t[5]=g):g=t[5];let _;t[6]!==i||t[7]!==s||t[8]!==o||t[9]!==n?(_=[n,i,o,s],t[6]=i,t[7]=s,t[8]=o,t[9]=n,t[10]=_):_=t[10],(0,Z.useEffect)(g,_);let[v,y]=(0,Z.useState)(!1);if(s===`running`){let e;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(l,{className:`h-4 w-4 shrink-0 text-brand animate-pulse`}),t[11]=e):e=t[11];let n=r||`Executing Browser JS...`,i;return t[12]===n?i=t[13]:(i=(0,$.jsx)(`div`,{className:`overflow-hidden`,children:(0,$.jsxs)(`div`,{className:`w-full py-2 flex items-center gap-2 text-sm font-medium text-foreground`,children:[e,(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:n})]})}),t[12]=n,t[13]=i),i}if(s===`success`){let e;t[14]===v?e=t[15]:(e=()=>y(!v),t[14]=v,t[15]=e);let n;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(l,{className:`h-4 w-4 shrink-0 text-brand`}),t[16]=n):n=t[16];let a=r||`Browser JS Executed Successfully`,o;t[17]===a?o=t[18]:(o=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:a}),t[17]=a,t[18]=o);let s;t[19]===v?s=t[20]:(s=v?(0,$.jsx)(Ce,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(Ke,{className:`h-4 w-4 shrink-0`}),t[19]=v,t[20]=s);let c;t[21]!==e||t[22]!==o||t[23]!==s?(c=(0,$.jsxs)(`button`,{onClick:e,className:`w-full py-2 flex items-center gap-2 text-sm font-medium text-foreground hover:bg-muted/50 transition-colors text-left`,children:[n,o,s]}),t[21]=e,t[22]=o,t[23]=s,t[24]=c):c=t[24];let d;t[25]!==i||t[26]!==v||t[27]!==u?(d=v&&(0,$.jsxs)(`div`,{className:`py-2 border-t border-border flex flex-col gap-2`,children:[(0,$.jsx)(`pre`,{className:`text-xs text-muted-foreground leading-relaxed whitespace-pre-wrap`,children:i}),u!=null&&(0,$.jsx)(`pre`,{className:`text-xs text-foreground leading-relaxed whitespace-pre-wrap border-t border-border pt-2`,children:u})]}),t[25]=i,t[26]=v,t[27]=u,t[28]=d):d=t[28];let f;return t[29]!==c||t[30]!==d?(f=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[c,d]}),t[29]=c,t[30]=d,t[31]=f):f=t[31],f}let b;t[32]===v?b=t[33]:(b=()=>y(!v),t[32]=v,t[33]=b);let x;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(l,{className:`h-4 w-4 shrink-0 text-destructive`}),t[34]=x):x=t[34];let S=r||`Browser JS Execution Failed`,C;t[35]===S?C=t[36]:(C=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:S}),t[35]=S,t[36]=C);let w;t[37]===v?w=t[38]:(w=v?(0,$.jsx)(Ce,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(Ke,{className:`h-4 w-4 shrink-0`}),t[37]=v,t[38]=w);let T;t[39]!==b||t[40]!==C||t[41]!==w?(T=(0,$.jsxs)(`button`,{onClick:b,className:`w-full py-2 flex items-center gap-2 text-sm font-medium text-foreground hover:bg-muted/50 transition-colors text-left`,children:[x,C,w]}),t[39]=b,t[40]=C,t[41]=w,t[42]=T):T=t[42];let E;t[43]!==i||t[44]!==f||t[45]!==v?(E=v&&(0,$.jsxs)(`div`,{className:`py-2 border-t border-border flex flex-col gap-2`,children:[(0,$.jsx)(`pre`,{className:`text-xs text-muted-foreground leading-relaxed whitespace-pre-wrap`,children:f}),(0,$.jsx)(`pre`,{className:`text-xs text-muted-foreground leading-relaxed whitespace-pre-wrap`,children:i})]}),t[43]=i,t[44]=f,t[45]=v,t[46]=E):E=t[46];let D;return t[47]!==T||t[48]!==E?(D=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[T,E]}),t[47]=T,t[48]=E,t[49]=D):D=t[49],D}function fa(e){let t=[];for(let n of e){if(n.type!==`tool-result`||n.toolName!==`todo`)continue;let e=[n.result,n.content];for(let n of e){let e=[];if(typeof n==`string`)e.push(n);else if(Array.isArray(n))for(let t of n)typeof t==`object`&&t&&`text`in t&&typeof t.text==`string`&&e.push(t.text);for(let n of e)try{let e=JSON.parse(n.trim());e&&Array.isArray(e.todos)&&(t=e.todos)}catch{}}}return t}function pa(e){let t=(0,Q.c)(29),{src:r}=e,[a,o]=(0,Z.useState)(!1),s;t[0]===r?s=t[1]:(s=async()=>{let e=`generated-image-${Date.now()}.png`,{path:t}=await i(r.startsWith(`data:`)?{imageData:r.replace(/^data:[^;]+;base64,/,``),filename:e}:{imageUrl:r,filename:e});X({title:`Saved to downloads: ${t.split(`/`).pop()}`})},t[0]=r,t[1]=s);let c=s,l;t[2]===r?l=t[3]:(l=async()=>{await b(r.startsWith(`data:`)?{imageData:r.replace(/^data:[^;]+;base64,/,``)}:{imageUrl:r}),o(!0),setTimeout(()=>o(!1),2e3)},t[2]=r,t[3]=l);let u=l,d;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(d={maxHeight:`512px`},t[4]=d):d=t[4];let f;t[5]===r?f=t[6]:(f=(0,$.jsx)(`img`,{src:r,alt:`Generated image`,className:`max-w-full rounded-lg border border-border block`,style:d}),t[5]=r,t[6]=f);let p;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(ne,{className:`h-3.5 w-3.5`}),t[7]=p):p=t[7];let m;t[8]===c?m=t[9]:(m=(0,$.jsx)(Yr,{asChild:!0,children:(0,$.jsx)(`button`,{onClick:c,className:`flex items-center justify-center h-7 w-7 rounded-md bg-background/80 backdrop-blur-sm border border-border text-foreground hover:bg-background transition-colors`,children:p})}),t[8]=c,t[9]=m);let h;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(Kr,{children:`Save image`}),t[10]=h):h=t[10];let g;t[11]===m?g=t[12]:(g=(0,$.jsxs)(Jr,{children:[m,h]}),t[11]=m,t[12]=g);let _;t[13]===a?_=t[14]:(_=a?(0,$.jsx)(n,{className:`h-3.5 w-3.5 text-green-500`}):(0,$.jsx)(M,{className:`h-3.5 w-3.5`}),t[13]=a,t[14]=_);let v;t[15]!==u||t[16]!==_?(v=(0,$.jsx)(Yr,{asChild:!0,children:(0,$.jsx)(`button`,{onClick:u,className:`flex items-center justify-center h-7 w-7 rounded-md bg-background/80 backdrop-blur-sm border border-border text-foreground hover:bg-background transition-colors`,children:_})}),t[15]=u,t[16]=_,t[17]=v):v=t[17];let y=a?`Copied!`:`Copy to clipboard`,x;t[18]===y?x=t[19]:(x=(0,$.jsx)(Kr,{children:y}),t[18]=y,t[19]=x);let S;t[20]!==v||t[21]!==x?(S=(0,$.jsxs)(Jr,{children:[v,x]}),t[20]=v,t[21]=x,t[22]=S):S=t[22];let C;t[23]!==S||t[24]!==g?(C=(0,$.jsx)(`div`,{className:`absolute top-2 right-2 flex gap-1 opacity-0 group-hover/img:opacity-100 transition-opacity`,children:(0,$.jsxs)(qr,{children:[g,S]})}),t[23]=S,t[24]=g,t[25]=C):C=t[25];let w;return t[26]!==C||t[27]!==f?(w=(0,$.jsxs)(`div`,{className:`mt-2 relative group/img inline-block max-w-full`,children:[f,C]}),t[26]=C,t[27]=f,t[28]=w):w=t[28],w}function ma(e,t){let n=e.find(e=>e.type===`tool-result`&&e.toolCallId===t);if(!n)return;let r=n,i=r.result??r.content;if(i!=null)return typeof i==`string`?i:JSON.stringify(i,null,2)}function ha(e,t,n,r){return e.name===`ask_user`?(0,$.jsx)(ua,{toolCallId:e.id,question:JSON.stringify(e.input?.question??``),options:e.input?.options,context:e.input?.context},t):e.name===`run_web_worker`?(0,$.jsx)(da,{toolCallId:e.id,intention:e.input?.intention??``,code:e.input?.code??``},t):n?(0,$.jsxs)(`span`,{children:[(0,$.jsx)(la,{toolCall:e}),(0,$.jsx)(Yi,{inline:!0,block:e,resultContent:r})]},t):(0,$.jsx)(Yi,{inline:!0,block:e,resultContent:r},t)}function ga(e){let t=(0,Q.c)(64),{message:n}=e,r=n.sender===`user`,i,a,o,s,c,u;if(t[0]!==r||t[1]!==n.content||t[2]!==n.isThinking||t[3]!==n.metadata||t[4]!==n.model||t[5]!==n.timestamp){let e=r?null:Ir(n.content),d;t[12]===n.timestamp?d=t[13]:(d=n.timestamp?new Date(n.timestamp).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}):``,t[12]=n.timestamp,t[13]=d);let f=d,p=r?`flex-row-reverse`:`flex-row`;t[14]===p?c=t[15]:(c=N(`group flex gap-3 px-4 py-4`,p),t[14]=p,t[15]=c);let m=r?`bg-foreground`:`bg-muted`,h;t[16]===m?h=t[17]:(h=N(`flex h-7 w-7 shrink-0 items-center justify-center rounded-full`,m),t[16]=m,t[17]=h);let g;t[18]===r?g=t[19]:(g=r?(0,$.jsx)(Rt,{className:`h-3.5 w-3.5 text-background`}):(0,$.jsx)(mn,{className:`h-3.5 w-3.5 text-muted-foreground`}),t[18]=r,t[19]=g),t[20]!==h||t[21]!==g?(u=(0,$.jsx)(`div`,{className:h,children:g}),t[20]=h,t[21]=g,t[22]=u):u=t[22];let _=r&&`items-end`;t[23]===_?o=t[24]:(o=N(`flex flex-1 flex-col gap-1 min-w-0`,_),t[23]=_,t[24]=o);let v=r&&`flex-row-reverse`,y;t[25]===v?y=t[26]:(y=N(`flex items-center gap-2`,v),t[25]=v,t[26]=y);let b=r?`You`:`Agent`,x;t[27]===b?x=t[28]:(x=(0,$.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:b}),t[27]=b,t[28]=x);let S;t[29]===f?S=t[30]:(S=f&&(0,$.jsxs)(`span`,{className:`flex items-center gap-1 text-[10px] text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity`,children:[(0,$.jsx)(He,{className:`h-2.5 w-2.5`}),f]}),t[29]=f,t[30]=S);let C;t[31]===n.model?C=t[32]:(C=n.model&&(0,$.jsxs)(`span`,{className:`flex items-center gap-1 text-[10px] text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity`,children:[(0,$.jsx)(l,{className:`h-2.5 w-2.5`}),ei(n.model)]}),t[31]=n.model,t[32]=C);let w;t[33]===n.metadata?w=t[34]:(w=n.metadata?.processingTimeMs&&(0,$.jsxs)(`span`,{className:`flex items-center gap-1 text-[10px] text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity`,children:[(0,$.jsx)(be,{className:`h-2.5 w-2.5`}),n.metadata.processingTimeMs>=6e4?`${Math.floor(n.metadata.processingTimeMs/6e4)}m ${Math.round(n.metadata.processingTimeMs%6e4/1e3)}s`:`${Math.round(n.metadata.processingTimeMs/1e3)}s`]}),t[33]=n.metadata,t[34]=w);let T;t[35]===n.metadata?T=t[36]:(T=n.metadata?.tokenCount&&(0,$.jsxs)(`span`,{className:`text-[10px] text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity`,children:[n.metadata.tokenCount.toLocaleString(),` tokens`]}),t[35]=n.metadata,t[36]=T),t[37]!==y||t[38]!==x||t[39]!==S||t[40]!==C||t[41]!==w||t[42]!==T?(s=(0,$.jsxs)(`div`,{className:y,children:[x,S,C,w,T]}),t[37]=y,t[38]=x,t[39]=S,t[40]=C,t[41]=w,t[42]=T,t[43]=s):s=t[43];let E=r?`bg-foreground text-background`:`bg-muted text-foreground`;t[44]===E?i=t[45]:(i=N(`rounded-xl px-4 py-3 flex flex-col gap-0.5 min-w-0`,E),t[44]=E,t[45]=i),a=n.isThinking?(()=>{let e=Vr(n.content);return e?.length?e.map((t,n)=>t.type===`tool_use`?ha(t,n,!1,ma(e,t.id)):t.type===`tool-result`?(0,$.jsx)(sa,{inline:!0,block:t},n):t.type===`reasoning`&&`text`in t?(0,$.jsx)(ca,{text:Fr(t.text)},n):null):(0,$.jsx)(`div`,{className:`text-xs text-muted-foreground leading-relaxed whitespace-pre-wrap`,children:(0,$.jsx)(Di,{content:Fr(n.content)})})})():e?(()=>{let t=fa(e),n=e.filter(ya);return(0,$.jsxs)($.Fragment,{children:[e.map((t,n)=>t.type===`tool_use`&&t.name===`todo`||t.type===`tool-result`&&t.toolName===`todo`?t.type===`tool-result`?(0,$.jsx)(sa,{inline:!0,block:t},n):null:t.type===`tool_use`&&t.name===`ask_user`?null:(0,$.jsx)(`div`,{children:t.type===`reasoning`&&`text`in t?(0,$.jsx)(ca,{text:Fr(t.text)}):t.type===`text`&&`text`in t?(0,$.jsx)(Di,{content:Fr(t.text)}):t.type===`tool_use`?ha(t,void 0,!1,ma(e,t.id)):t.type===`tool-result`?(0,$.jsx)(sa,{inline:!0,block:t}):null},n)),t.length>0&&(0,$.jsx)(ra,{todos:t}),n.map(va)]})})():(0,$.jsx)(Di,{content:Fr(n.content)}),t[0]=r,t[1]=n.content,t[2]=n.isThinking,t[3]=n.metadata,t[4]=n.model,t[5]=n.timestamp,t[6]=i,t[7]=a,t[8]=o,t[9]=s,t[10]=c,t[11]=u}else i=t[6],a=t[7],o=t[8],s=t[9],c=t[10],u=t[11];let d;t[46]!==i||t[47]!==a?(d=(0,$.jsx)(`div`,{className:i,children:a}),t[46]=i,t[47]=a,t[48]=d):d=t[48];let f;t[49]!==n.generatedImageData||t[50]!==n.generatedImageUrl?(f=(n.generatedImageUrl||n.generatedImageData)&&(0,$.jsx)(pa,{src:n.generatedImageData?`data:image/png;base64,${n.generatedImageData}`:n.generatedImageUrl}),t[49]=n.generatedImageData,t[50]=n.generatedImageUrl,t[51]=f):f=t[51];let p;t[52]===n.attachments?p=t[53]:(p=n.attachments&&n.attachments.length>0&&(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5 mt-1`,children:n.attachments.map(_a)}),t[52]=n.attachments,t[53]=p);let m;t[54]!==o||t[55]!==s||t[56]!==d||t[57]!==f||t[58]!==p?(m=(0,$.jsxs)(`div`,{className:o,children:[s,d,f,p]}),t[54]=o,t[55]=s,t[56]=d,t[57]=f,t[58]=p,t[59]=m):m=t[59];let h;return t[60]!==m||t[61]!==c||t[62]!==u?(h=(0,$.jsxs)(`div`,{className:c,children:[u,m]}),t[60]=m,t[61]=c,t[62]=u,t[63]=h):h=t[63],h}function _a(e,t){return(0,$.jsxs)(`span`,{className:`flex items-center gap-1 rounded-md bg-muted px-2 py-1 text-[10px] text-muted-foreground`,children:[(0,$.jsx)(ht,{className:`h-2.5 w-2.5`}),e.fileName]},t)}function va(e,t){return(0,$.jsx)(ua,{toolCallId:e.id,question:JSON.stringify(e.input?.question??``),options:e.input?.options,context:e.input?.context},`ask-${t}`)}function ya(e){return e.type===`tool_use`&&e.name===`ask_user`}function ba(e){let t=(0,Q.c)(21),{segments:n,model:r}=e,i,a,o,s,c;if(t[0]!==r||t[1]!==n){let e=Pr(n),u=t=>e[t].type===`reasoning`?e.slice(t+1).length>0:!1;s=`group flex gap-3 px-4 py-4`,t[7]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(`div`,{className:`flex h-7 w-7 shrink-0 self-end items-center justify-center rounded-full bg-brand animate-radial-pulse-brand`,children:(0,$.jsx)(mn,{className:`h-3.5 w-3.5 text-white`})}),t[7]=c):c=t[7],i=`flex flex-1 flex-col gap-1 min-w-0`;let d;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:`Agent`}),t[8]=d):d=t[8];let f;t[9]===r?f=t[10]:(f=r&&(0,$.jsxs)(`span`,{className:`flex items-center gap-1 text-[10px] text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity`,children:[(0,$.jsx)(l,{className:`h-2.5 w-2.5`}),ei(r)]}),t[9]=r,t[10]=f),t[11]===f?a=t[12]:(a=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[d,f]}),t[11]=f,t[12]=a),o=e.length>0?(()=>{let t=fa(e),n=e.filter(Sa);return(0,$.jsxs)(`div`,{className:`rounded-xl bg-muted px-4 py-3 text-foreground flex flex-col gap-0.5 min-w-0`,children:[e.map((t,n)=>t.type===`tool_use`&&t.name===`todo`||t.type===`tool-result`&&t.toolName===`todo`?t.type===`tool-result`?(0,$.jsx)(sa,{inline:!0,block:t},`b-${n}`):null:t.type===`tool_use`&&t.name===`ask_user`?null:(0,$.jsx)(`div`,{children:t.type===`reasoning`&&`text`in t?(0,$.jsx)(ca,{text:Fr(t.text),isStreaming:!0,hasContentAfter:u(n)}):t.type===`text`&&`text`in t?(0,$.jsx)(Di,{content:Fr(t.text)}):t.type===`tool_use`?ha(t,void 0,!0,ma(e,t.id)):t.type===`tool-result`?(0,$.jsx)(sa,{inline:!0,block:t}):null},`b-${n}`)),t.length>0&&(0,$.jsx)(ra,{todos:t}),n.map(xa)]})})():(0,$.jsx)(`div`,{className:`rounded-xl bg-muted px-4 py-3 min-w-0`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-center gap-1.5`,children:[(0,$.jsx)(`div`,{className:`h-2 w-2 rounded-full bg-muted-foreground/40 animate-bounce [animation-delay:0ms]`}),(0,$.jsx)(`div`,{className:`h-2 w-2 rounded-full bg-muted-foreground/40 animate-bounce [animation-delay:150ms]`}),(0,$.jsx)(`div`,{className:`h-2 w-2 rounded-full bg-muted-foreground/40 animate-bounce [animation-delay:300ms]`})]})}),t[0]=r,t[1]=n,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c}else i=t[2],a=t[3],o=t[4],s=t[5],c=t[6];let u;t[13]!==i||t[14]!==a||t[15]!==o?(u=(0,$.jsxs)(`div`,{className:i,children:[a,o]}),t[13]=i,t[14]=a,t[15]=o,t[16]=u):u=t[16];let d;return t[17]!==s||t[18]!==c||t[19]!==u?(d=(0,$.jsxs)(`div`,{className:s,children:[c,u]}),t[17]=s,t[18]=c,t[19]=u,t[20]=d):d=t[20],d}function xa(e,t){return(0,$.jsx)(ua,{toolCallId:e.id,question:JSON.stringify(e.input?.question??``),options:e.input?.options,context:e.input?.context},`ask-${t}`)}function Sa(e){return e.type===`tool_use`&&e.name===`ask_user`}var Ca=(0,Z.memo)(ba,(e,t)=>{if(e.model!==t.model||e.segments.length!==t.segments.length)return!1;for(let n=0;n<e.segments.length;n++){if(e.segments[n].type!==t.segments[n].type||e.segments[n].chunks.length!==t.segments[n].chunks.length)return!1;for(let r=0;r<e.segments[n].chunks.length;r++)if(e.segments[n].chunks[r]!==t.segments[n].chunks[r])return!1}return!0});function wa(e){let t=(0,Q.c)(34),{projects:n,onSelectProject:i,onCreateThread:a,onConnectRepo:o,onNewApp:s,onOpenFolder:c}=e,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(`img`,{src:`/tarsk-color.svg`,alt:`Tarsk`,className:`h-16 w-16 rounded-lg`}),t[0]=l):l=t[0];let u;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight text-foreground text-balance`,children:`Let's build it!`}),t[1]=u):u=t[1];let d=n.length===0?`Start or connect your first project`:`Select a project to start coding`,f;t[2]===d?f=t[3]:(f=(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3`,children:[l,(0,$.jsxs)(`div`,{className:`text-center`,children:[u,(0,$.jsx)(`p`,{className:`mt-1 text-base text-muted-foreground`,children:d})]})]}),t[2]=d,t[3]=f);let p;if(t[4]!==a||t[5]!==i||t[6]!==n){let e;t[8]!==a||t[9]!==i?(e=e=>(0,$.jsxs)(`button`,{type:`button`,className:`flex w-56 flex-col gap-2 rounded-xl border border-border bg-background p-4 text-left shadow-sm transition-colors hover:bg-muted`,onClick:()=>{e.threads.length===0?a(e.projectId):i(e.projectId,e.threads[0].threadId)},children:[(0,$.jsx)(Lt,{className:`h-5 w-5 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`text-sm text-foreground leading-snug font-medium`,children:e.name}),(0,$.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[e.threads.length,` thread`,e.threads.length===1?``:`s`]})]},e.projectId),t[8]=a,t[9]=i,t[10]=e):e=t[10],p=n.map(e),t[4]=a,t[5]=i,t[6]=n,t[7]=p}else p=t[7];let m,h,g;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(x,{className:`h-5 w-5 text-muted-foreground`}),h=(0,$.jsx)(`span`,{className:`text-sm text-foreground leading-snug font-medium`,children:`Connect a repo`}),g=(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Clone an existing repository`}),t[11]=m,t[12]=h,t[13]=g):(m=t[11],h=t[12],g=t[13]);let _;t[14]===o?_=t[15]:(_=(0,$.jsxs)(`button`,{type:`button`,className:`flex w-56 flex-col gap-2 rounded-xl border border-border bg-background p-4 text-left shadow-sm transition-colors hover:bg-muted`,onClick:o,children:[m,h,g]}),t[14]=o,t[15]=_);let v,y,b;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(r,{className:`h-5 w-5 text-muted-foreground`}),y=(0,$.jsx)(`span`,{className:`text-sm text-foreground leading-snug font-medium`,children:`New App`}),b=(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Create a new project from template`}),t[16]=v,t[17]=y,t[18]=b):(v=t[16],y=t[17],b=t[18]);let S;t[19]===s?S=t[20]:(S=(0,$.jsxs)(`button`,{type:`button`,className:`flex w-56 flex-col gap-2 rounded-xl border border-border bg-background p-4 text-left shadow-sm transition-colors hover:bg-muted`,onClick:s,children:[v,y,b]}),t[19]=s,t[20]=S);let C,w,T;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,$.jsx)(he,{className:`h-5 w-5 text-muted-foreground`}),w=(0,$.jsx)(`span`,{className:`text-sm text-foreground leading-snug font-medium`,children:`Open Folder`}),T=(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Use an existing local folder`}),t[21]=C,t[22]=w,t[23]=T):(C=t[21],w=t[22],T=t[23]);let E;t[24]===c?E=t[25]:(E=(0,$.jsxs)(`button`,{type:`button`,className:`flex w-56 flex-col gap-2 rounded-xl border border-border bg-background p-4 text-left shadow-sm transition-colors hover:bg-muted`,onClick:c,children:[C,w,T]}),t[24]=c,t[25]=E);let D;t[26]!==S||t[27]!==E||t[28]!==p||t[29]!==_?(D=(0,$.jsxs)(`div`,{className:`flex flex-wrap justify-center gap-3`,children:[p,_,S,E]}),t[26]=S,t[27]=E,t[28]=p,t[29]=_,t[30]=D):D=t[30];let O;return t[31]!==D||t[32]!==f?(O=(0,$.jsxs)(`div`,{className:`mx-auto flex max-w-3xl flex-1 flex-col items-center justify-center gap-8 px-4`,children:[f,D]}),t[31]=D,t[32]=f,t[33]=O):O=t[33],O}function Ta(e){let t=(0,Q.c)(37),{messages:n,isStreaming:r,streamingSegments:i,streamingModel:a,isCreatingProject:o,isProcessingThread:s,selectedThreadId:c,projects:l,projectsLoading:u,onSelectThread:d,onCreateThread:f,onConnectRepo:p,onNewApp:m,onOpenFolder:h,error:g,onClearError:_}=e,v=(0,Z.useRef)(null),y;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(y=()=>{v.current&&(v.current.scrollTop=v.current.scrollHeight)},t[0]=y):y=t[0];let b;t[1]!==n||t[2]!==i?(b=[n,i],t[1]=n,t[2]=i,t[3]=b):b=t[3],(0,Z.useEffect)(y,b);let x=n.length===0&&!r&&!o&&!c,S=x&&`flex flex-col items-center justify-center`,C;t[4]===S?C=t[5]:(C=N(`flex-1 overflow-y-auto`,S),t[4]=S,t[5]=C);let w;t[6]!==p||t[7]!==f||t[8]!==m||t[9]!==h||t[10]!==d||t[11]!==l||t[12]!==u||t[13]!==x?(w=x&&(0,$.jsx)(`div`,{className:`transition-opacity duration-500 ease-in-out ${u?`opacity-0`:`opacity-100`}`,children:(0,$.jsx)(wa,{projects:l,onSelectProject:d,onCreateThread:f,onConnectRepo:p,onNewApp:m,onOpenFolder:h})}),t[6]=p,t[7]=f,t[8]=m,t[9]=h,t[10]=d,t[11]=l,t[12]=u,t[13]=x,t[14]=w):w=t[14];let T;t[15]===n?T=t[16]:(T=n.map(Ea),t[15]=n,t[16]=T);let E;t[17]!==o||t[18]!==s||t[19]!==r||t[20]!==a||t[21]!==i?(E=(r||o||s)&&(0,$.jsx)(Ca,{segments:i,model:a}),t[17]=o,t[18]=s,t[19]=r,t[20]=a,t[21]=i,t[22]=E):E=t[22];let D;t[23]!==g||t[24]!==_?(D=g&&(0,$.jsxs)(`div`,{className:`mx-4 my-2 rounded-lg border border-destructive/30 bg-destructive/5 px-4 py-3`,children:[(0,$.jsx)(`p`,{className:`text-sm text-destructive`,children:g}),(0,$.jsx)(`button`,{type:`button`,className:`mt-1 text-xs text-destructive underline underline-offset-2 hover:text-destructive/80`,onClick:_,children:`Dismiss`})]}),t[23]=g,t[24]=_,t[25]=D):D=t[25];let O;t[26]!==T||t[27]!==E||t[28]!==D?(O=(0,$.jsxs)(`div`,{className:`mx-auto max-w-3xl pb-4 w-full min-w-0`,children:[T,E,D]}),t[26]=T,t[27]=E,t[28]=D,t[29]=O):O=t[29];let k;t[30]!==c||t[31]!==O?(k=(0,$.jsx)(Zi,{children:O},c),t[30]=c,t[31]=O,t[32]=k):k=t[32];let A;return t[33]!==k||t[34]!==C||t[35]!==w?(A=(0,$.jsxs)(`div`,{ref:v,className:C,children:[w,k]}),t[33]=k,t[34]=C,t[35]=w,t[36]=A):A=t[36],A}function Ea(e){return(0,$.jsx)(ga,{message:e},e.messageId)}var Da=()=>{if(typeof window>`u`)return null;let e=window.SpeechRecognition||window.webkitSpeechRecognition;return e?new e:null};function Oa(){let e=(0,Q.c)(14),[t,n]=(0,Z.useState)(!1),[r,i]=(0,Z.useState)(``),[a,o]=(0,Z.useState)(null),[s,c]=(0,Z.useState)(!1),l=(0,Z.useRef)(null),u=(0,Z.useRef)(``),d,f;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>{try{let e=Da();e?(e.continuous=!0,e.interimResults=!0,e.lang=`en-US`,e.onstart=()=>{n(!0),o(null),u.current=``},e.onresult=e=>{let t=``;for(let n=e.resultIndex;n<e.results.length;n++){let r=e.results[n][0].transcript;e.results[n].isFinal?i(e=>e+r+` `):t+=r}u.current=t},e.onerror=e=>{console.error(`Speech recognition error:`,e.error),o(e.error||`An error occurred during speech recognition`)},e.onend=()=>{n(!1)},l.current=e,c(!0)):(c(!1),o(`Speech Recognition API is not supported in your browser`))}catch(e){console.error(`Failed to initialize speech recognition:`,e),c(!1),o(`Failed to initialize speech recognition`)}return()=>{l.current&&l.current.abort()}},f=[],e[0]=d,e[1]=f):(d=e[0],f=e[1]),(0,Z.useEffect)(d,f);let p;e[2]===t?p=e[3]:(p=()=>{l.current&&!t&&l.current.start()},e[2]=t,e[3]=p);let m=p,h;e[4]===t?h=e[5]:(h=()=>{l.current&&t&&l.current.stop()},e[4]=t,e[5]=h);let g=h,_;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(_=()=>{i(``),u.current=``},e[6]=_):_=e[6];let v=_,y;return e[7]!==a||e[8]!==t||e[9]!==s||e[10]!==m||e[11]!==g||e[12]!==r?(y={isListening:t,transcript:r,error:a,startListening:m,stopListening:g,resetTranscript:v,isSupported:s},e[7]=a,e[8]=t,e[9]=s,e[10]=m,e[11]=g,e[12]=r,e[13]=y):y=e[13],y}function ka({initialValue:e}={}){let{state:t,dispatch:n}=Nr(),[r,i]=(0,Z.useState)(e??``),[a,o]=(0,Z.useState)(-1),[s,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)(0),[d,f]=(0,Z.useState)([]),[p,m]=(0,Z.useState)(()=>(t.selectedThreadId?t.projectModelSelections[t.selectedThreadId]:void 0)??null),h=(0,Z.useRef)(p?.id??``),g=(0,Z.useRef)(p?.provider??``),_=(0,Z.useRef)(null),[v,y]=(0,Z.useState)(!1),[b,x]=(0,Z.useState)(!1),[S,C]=(0,Z.useState)([]),[w,T]=(0,Z.useState)(!1),[E,D]=(0,Z.useState)(!1),[O,k]=(0,Z.useState)([]),[A,j]=(0,Z.useState)(null),[M,N]=(0,Z.useState)([]),[P,F]=(0,Z.useState)(!1),[I,L]=(0,Z.useState)(``),[R,z]=(0,Z.useState)(0),[B,V]=(0,Z.useState)([]),[H,U]=(0,Z.useState)([]),[W,G]=(0,Z.useState)(!1),[ee,te]=(0,Z.useState)(``),ne=(0,Z.useRef)(null),K=(0,Z.useRef)(null),re=(0,Z.useRef)(null),ie=(0,Z.useRef)(null),ae=(0,Z.useRef)(null),oe=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{h.current=p?.id??``,g.current=p?.provider??``},[p?.id,p?.provider]);let q=(0,Z.useCallback)((e,r)=>{m(e);let i=t.selectedThreadId;if(!i||(n({type:Y.SetProjectModel,threadId:i,model:e}),r?.persist===!1))return;let a=`${i}:${e.provider??``}:${e.id}`;_.current!==a&&(_.current=a,console.log(`[useChatInputState] Persisting model to thread:`,{threadId:i,model:{id:e.id,provider:e.provider}}),bn(i,{model:e.id,modelProvider:e.provider}).then(()=>{_.current===a&&(_.current=null),console.log(`[useChatInputState] Model persisted successfully`)}).catch(e=>{_.current===a&&(_.current=null),console.error(`Failed to save model to thread:`,e)}))},[t.selectedThreadId,n]);(0,Z.useEffect)(()=>{(async()=>{let e=t.selectedProjectId?t.projects.find(e=>e.projectId===t.selectedProjectId)?.threads.find(e=>e.threadId===t.selectedThreadId):void 0,n=t.selectedThreadId?t.projectModelSelections[t.selectedThreadId]:void 0,r=e?.model??n?.id??null,i=e?.modelProvider??n?.provider??null;console.log(`[useChatInputState] Loading models for thread:`,{threadId:t.selectedThreadId,projectId:t.selectedProjectId,currentThread:e?{model:e.model,modelProvider:e.modelProvider}:void 0,storedModel:n?{id:n.id,provider:n.provider}:void 0,savedModelId:r,savedModelProvider:i});try{let e=await Se(),t=Object.values(e).flat();if(t.length===0){f([]),m(null);return}f(t);let n=r&&i?t.find(e=>e.id===r&&e.provider===i)??null:null,a=t[0],o=n??a,s=!n&&!!(r||i),c=h.current===o.id&&g.current===o.provider;console.log(`[useChatInputState] Model selection decision:`,{matchedSavedModel:n?{id:n.id}:null,fallbackModel:{id:a.id},modelToSelect:{id:o.id},shouldPersistFallback:s,hasSameSelection:c,currentSelected:{id:h.current,provider:g.current}}),c||q(o,{persist:s})}catch(e){console.error(`Failed to load enabled models:`,e)}})()},[t.selectedThreadId,t.selectedProjectId,t.projects,q]);let se=(0,Z.useRef)(q);(0,Z.useEffect)(()=>{se.current=q},[q]),(0,Z.useEffect)(()=>{t.configUpdatedAt!==0&&(async()=>{try{let e=await Se(),t=Object.values(e).flat();if(t.length>0){f(t);let e=h.current,n=g.current;t.some(t=>t.id===e&&t.provider===n)||se.current(t[0],{persist:!0})}}catch(e){console.error(`Failed to reload enabled models:`,e)}})()},[t.configUpdatedAt]),(0,Z.useEffect)(()=>{!E||O.length>0||(async()=>{try{let e=await Ye(),t=Object.values(e).flat();t.length>0&&(k(t),j(e=>e??t[0]))}catch(e){console.error(`Failed to load image models:`,e)}})()},[E,O.length]);let[ce,le]=(0,Z.useState)(t.selectedThreadId);return(0,Z.useEffect)(()=>{t.selectedThreadId!==ce&&setTimeout(()=>{le(t.selectedThreadId),N([]),F(!1),V([]),U([]),G(!1),T(!1),D(!1)},0)},[t.selectedThreadId,ce]),(0,Z.useEffect)(()=>{t.selectedThreadId&&wn(t.selectedThreadId).then(({commands:e,skills:t})=>{console.log(`Loaded slash commands:`,e,`skills:`,t),V(e),U(t)}).catch(e=>console.error(`Failed to load slash commands and skills:`,e))},[t.selectedThreadId]),(0,Z.useEffect)(()=>{t.focusChatInput&&t.selectedThreadId&&!t.isStreaming&&(K.current?.focus(),n({type:Y.ClearFocusChatInput}))},[t.focusChatInput,t.selectedThreadId,t.isStreaming,n]),(0,Z.useEffect)(()=>{let e=e=>{re.current&&!re.current.contains(e.target)&&y(!1),ie.current&&!ie.current.contains(e.target)&&x(!1)};if(v||b)return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[v,b]),{message:r,setMessage:i,historyIndex:a,setHistoryIndex:o,draftMessage:s,setDraftMessage:c,cursorPosition:l,setCursorPosition:u,availableModels:d,setAvailableModels:f,selectedModel:p,setSelectedModel:q,selectedModelIdRef:h,showModelMenu:v,setShowModelMenu:y,showPlusMenu:b,setShowPlusMenu:x,attachments:S,setAttachments:C,planMode:w,setPlanMode:T,imageMode:E,setImageMode:D,availableImageModels:O,setAvailableImageModels:k,selectedImageModel:A,setSelectedImageModel:j,allFiles:M,setAllFiles:N,showSuggestions:P,setShowSuggestions:F,suggestionQuery:I,setSuggestionQuery:L,selectedIndex:R,setSelectedIndex:z,slashCommands:B,setSlashCommands:V,skills:H,setSkills:U,showCommandSuggestions:W,setShowCommandSuggestions:G,commandQuery:ee,setCommandQuery:te,fileInputRef:ne,textareaRef:K,modelMenuRef:re,plusMenuRef:ie,suggestionsRef:ae,commandSuggestionsRef:oe,handleNewChat:async()=>{if(t.selectedThreadId)try{let e=await xn(t.selectedThreadId);n({type:Y.ClearMessages}),console.log(`New conversation started:`,e);let r=await _t(t.selectedThreadId);n({type:Y.SetMessages,messages:r.messages})}catch(e){console.error(`Failed to start new chat:`,e)}},state:t,dispatch:n}}var Aa=e=>{ut(e)};function ja(e){let t=(0,Q.c)(99),{message:n,setMessage:r,attachments:i,selectedModel:a,onSend:o,isStreaming:s,selectedThreadId:c,isListening:l,stopListening:u,resetTranscript:d,dispatch:f,historyIndex:p,setHistoryIndex:m,draftMessage:h,setDraftMessage:g,cursorPosition:_,setCursorPosition:v,showSuggestions:y,setShowSuggestions:b,suggestionQuery:x,setSuggestionQuery:S,allFiles:C,setAllFiles:w,selectedIndex:T,setSelectedIndex:E,showCommandSuggestions:D,setShowCommandSuggestions:O,commandQuery:k,setCommandQuery:A,slashCommands:j,skills:M,textareaRef:N,setAttachments:P,planMode:F,setPlanMode:I,imageMode:L,selectedImageModel:R}=e,z;t[0]!==i||t[1]!==f||t[2]!==L||t[3]!==l||t[4]!==s||t[5]!==n||t[6]!==o||t[7]!==F||t[8]!==d||t[9]!==R||t[10]!==a||t[11]!==c||t[12]!==P||t[13]!==g||t[14]!==m||t[15]!==r||t[16]!==u||t[17]!==N?(z=()=>{if(!n.trim()&&i.length===0||!c)return;let e=L?R:a;e&&(l&&(u(),d()),s?f({type:Y.EnqueueChatMessage,message:{id:`queued-${Date.now()}`,threadId:c,message:n,model:e.id,attachments:i,provider:e.provider,planMode:F,imageMode:L}}):o(n,e.id,i,e.provider,F,L),Aa(n),r(``),P([]),m(-1),g(``),N.current&&(N.current.style.height=`auto`))},t[0]=i,t[1]=f,t[2]=L,t[3]=l,t[4]=s,t[5]=n,t[6]=o,t[7]=F,t[8]=d,t[9]=R,t[10]=a,t[11]=c,t[12]=P,t[13]=g,t[14]=m,t[15]=r,t[16]=u,t[17]=N,t[18]=z):z=t[18];let B=z,V;t[19]!==_||t[20]!==n||t[21]!==r||t[22]!==b||t[23]!==x||t[24]!==N?(V=e=>{let t=n.substring(0,_-x.length-1);r(`${t}${e} ${n.substring(_)}`),b(!1),setTimeout(()=>{if(N.current){N.current.focus();let n=t.length+e.length+1;N.current.setSelectionRange(n,n)}},0)},t[19]=_,t[20]=n,t[21]=r,t[22]=b,t[23]=x,t[24]=N,t[25]=V):V=t[25];let H=V,U;t[26]!==k||t[27]!==_||t[28]!==n||t[29]!==r||t[30]!==I||t[31]!==O||t[32]!==N?(U=e=>{let t=n.substring(0,_-k.length-1),i=n.substring(_);r(`${t}${e.content}${i}`),O(!1),setTimeout(()=>{if(N.current){N.current.focus();let n=t.length+e.content.length;N.current.setSelectionRange(n,n)}},0),e.metadata.mode===`plan`&&I(!0)},t[26]=k,t[27]=_,t[28]=n,t[29]=r,t[30]=I,t[31]=O,t[32]=N,t[33]=U):U=t[33];let W=U,G;t[34]!==k||t[35]!==_||t[36]!==n||t[37]!==r||t[38]!==O||t[39]!==N?(G=e=>{let t=n.substring(0,_-k.length-1),i=n.substring(_),a=e.name.includes(` `)?`/"${e.name}"`:`/${e.name}`;r(`${t}${a}${i}`),O(!1),setTimeout(()=>{if(N.current){N.current.focus();let e=t.length+a.length;N.current.setSelectionRange(e,e)}},0)},t[34]=k,t[35]=_,t[36]=n,t[37]=r,t[38]=O,t[39]=N,t[40]=G):G=t[40];let ee=G,te,ne,K,re;if(t[41]!==C||t[42]!==k||t[43]!==h||t[44]!==B||t[45]!==p||t[46]!==W||t[47]!==H||t[48]!==ee||t[49]!==n||t[50]!==T||t[51]!==c||t[52]!==w||t[53]!==A||t[54]!==v||t[55]!==g||t[56]!==m||t[57]!==r||t[58]!==E||t[59]!==O||t[60]!==b||t[61]!==S||t[62]!==D||t[63]!==y||t[64]!==M||t[65]!==j||t[66]!==x){K=e=>{if(D){if(e.key===`ArrowDown`){e.preventDefault(),E((T+1)%te.length);return}if(e.key===`ArrowUp`){e.preventDefault(),E((T-1+te.length)%te.length);return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault();let t=te[T];t&&(t.type===`command`?W(t.data):ee(t.data));return}if(e.key===`Escape`){O(!1);return}}if(y){let t=ne.length>0;if(e.key===`ArrowDown`&&t){e.preventDefault(),E((T+1)%ne.length);return}if(e.key===`ArrowUp`&&t){e.preventDefault(),E((T-1+ne.length)%ne.length);return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault(),ne[T]&&H(ne[T]);return}if(e.key===`Escape`){b(!1);return}}if(e.key===`Enter`&&!e.shiftKey){e.preventDefault(),B();return}let t=Ut();t.length!==0&&(e.key===`ArrowUp`?(e.preventDefault(),p===-1?(g(n),m(t.length-1),r(t[t.length-1])):p>0&&(m(p-1),r(t[p-1]))):e.key===`ArrowDown`&&(e.preventDefault(),p>0?(m(p-1),r(t[p-1])):p===0&&(m(-1),r(h))))};let e;t[71]!==C||t[72]!==c||t[73]!==w||t[74]!==A||t[75]!==v||t[76]!==r||t[77]!==E||t[78]!==O||t[79]!==b||t[80]!==S?(e=e=>{let t=e.target.value,n=e.target.selectionStart;r(t),v(n);let i=t.substring(0,n),a=i.lastIndexOf(`/`);if(a!==-1){let e=a>0?i[a-1]:``;if(a===0||/\s/.test(e)){let e=i.substring(a+1);e.includes(` `)?O(!1):(A(e),O(!0),b(!1),E(0))}else O(!1)}else{O(!1);let e=i.lastIndexOf(`#`);if(e!==-1){let t=e>0?i[e-1]:``;if(e===0||/\s/.test(t)){let t=i.substring(e+1);t.includes(` `)?b(!1):(S(t),b(!0),E(0),C.length===0&&c&&J(c).then(e=>{w(e)}).catch(Pa))}else b(!1)}else b(!1)}let o=e.target;o.style.height=`auto`,o.style.height=`${Math.min(o.scrollHeight,160)}px`},t[71]=C,t[72]=c,t[73]=w,t[74]=A,t[75]=v,t[76]=r,t[77]=E,t[78]=O,t[79]=b,t[80]=S,t[81]=e):e=t[81],re=e;let i;if(t[82]!==k||t[83]!==M||t[84]!==j){let e;t[86]===k?e=t[87]:(e=e=>e.name.toLowerCase().includes(k.toLowerCase()),t[86]=k,t[87]=e);let n=j.filter(e),r;t[88]===k?r=t[89]:(r=e=>e.name.toLowerCase().includes(k.toLowerCase()),t[88]=k,t[89]=r);let a=M.filter(r);i=[...n.map(Na),...a.map(Ma)],t[82]=k,t[83]=M,t[84]=j,t[85]=i}else i=t[85];te=i.slice(0,10),ne=y?C.filter(e=>e.toLowerCase().includes(x.toLowerCase())).slice(0,10):[],t[41]=C,t[42]=k,t[43]=h,t[44]=B,t[45]=p,t[46]=W,t[47]=H,t[48]=ee,t[49]=n,t[50]=T,t[51]=c,t[52]=w,t[53]=A,t[54]=v,t[55]=g,t[56]=m,t[57]=r,t[58]=E,t[59]=O,t[60]=b,t[61]=S,t[62]=D,t[63]=y,t[64]=M,t[65]=j,t[66]=x,t[67]=te,t[68]=ne,t[69]=K,t[70]=re}else te=t[67],ne=t[68],K=t[69],re=t[70];let ie;return t[90]!==te||t[91]!==ne||t[92]!==K||t[93]!==B||t[94]!==re||t[95]!==W||t[96]!==H||t[97]!==ee?(ie={handleSend:B,handleKeyDown:K,handleTextareaInput:re,insertFileReference:H,insertCommand:W,insertSkill:ee,allSuggestions:te,fileSuggestions:ne},t[90]=te,t[91]=ne,t[92]=K,t[93]=B,t[94]=re,t[95]=W,t[96]=H,t[97]=ee,t[98]=ie):ie=t[98],ie}function Ma(e){return{type:`skill`,data:e}}function Na(e){return{type:`command`,data:e}}function Pa(e){return console.error(`Failed to fetch files:`,e)}function Fa(e){let t=(0,Q.c)(21),{visible:n,commands:r,skills:i,query:a,selectedIndex:o,onSelectCommand:s,onSelectSkill:c,onMouseEnterSuggestion:l,containerRef:u}=e;if(!n)return null;let d;if(t[0]!==r||t[1]!==a||t[2]!==i){let e;t[4]===a?e=t[5]:(e=e=>e.name.toLowerCase().includes(a.toLowerCase()),t[4]=a,t[5]=e);let n=r.filter(e),o;t[6]===a?o=t[7]:(o=e=>e.name.toLowerCase().includes(a.toLowerCase()),t[6]=a,t[7]=o);let s=i.filter(o);d=[...n.map(La),...s.map(Ia)].slice(0,10),t[0]=r,t[1]=a,t[2]=i,t[3]=d}else d=t[3];let f=d,p;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(E,{className:`h-3 w-3`}),t[8]=p):p=t[8];let m=a&&` matching "${a}"`,h;t[9]===m?h=t[10]:(h=(0,$.jsxs)(`div`,{className:`px-2 py-1.5 text-xs font-semibold text-muted-foreground border-b border-border/50 mb-1 flex items-center gap-2`,children:[p,`Commands & Skills`,m]}),t[9]=m,t[10]=h);let g;t[11]!==f||t[12]!==l||t[13]!==s||t[14]!==c||t[15]!==o?(g=f.length>0?f.map((e,t)=>{let n=t===o;if(e.type===`command`){let r=e.data;return(0,$.jsxs)(`button`,{type:`button`,className:N(`flex w-full flex-col gap-1 rounded-lg px-3 py-2 text-left transition-colors`,n?`bg-accent text-accent-foreground`:`text-popover-foreground hover:bg-accent/50`),onClick:()=>s(r),onMouseEnter:()=>l(t),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(E,{className:`h-3 w-3 text-muted-foreground`}),(0,$.jsxs)(`span`,{className:`font-medium`,children:[`/`,r.name]}),r.metadata.argumentHint&&(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:r.metadata.argumentHint}),r.scope===`project`&&(0,$.jsx)(`span`,{className:`ml-auto text-[10px] rounded-full bg-primary/10 px-1.5 py-0.5 text-primary`,children:`project`})]}),r.metadata.description&&(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:r.metadata.description})]},`cmd-${r.name}`)}else{let r=e.data;return(0,$.jsxs)(`button`,{type:`button`,className:N(`flex w-full flex-col gap-1 rounded-lg px-3 py-2 text-left transition-colors`,n?`bg-accent text-accent-foreground`:`text-popover-foreground hover:bg-accent/50`),onClick:()=>c(r),onMouseEnter:()=>l(t),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(S,{className:`h-3 w-3 text-amber-500`}),(0,$.jsxs)(`span`,{className:`font-medium`,children:[`/`,r.name]}),(0,$.jsx)(`span`,{className:`ml-auto text-[10px] rounded-full bg-amber-500/10 px-1.5 py-0.5 text-amber-700 dark:text-amber-400`,children:`skill`}),r.scope===`project`&&(0,$.jsx)(`span`,{className:`text-[10px] rounded-full bg-primary/10 px-1.5 py-0.5 text-primary`,children:`project`})]}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:r.description})]},`skill-${r.name}`)}}):(0,$.jsxs)(`div`,{className:`px-3 py-4 text-center text-xs text-muted-foreground`,children:[`No commands or skills found.`,(0,$.jsx)(`br`,{}),(0,$.jsxs)(`span`,{className:`text-[10px]`,children:[`Create commands in `,(0,$.jsx)(`code`,{className:`bg-muted px-1 rounded`,children:`.agents/commands/`}),` or skills in `,(0,$.jsx)(`code`,{className:`bg-muted px-1 rounded`,children:`.agents/skills/`})]})]}),t[11]=f,t[12]=l,t[13]=s,t[14]=c,t[15]=o,t[16]=g):g=t[16];let _;return t[17]!==u||t[18]!==h||t[19]!==g?(_=(0,$.jsxs)(`div`,{ref:u,className:`absolute bottom-full left-0 mb-2 w-full max-h-64 overflow-y-auto rounded-xl border border-border bg-popover p-1 shadow-lg z-50 animate-in fade-in slide-in-from-bottom-2`,children:[h,g]}),t[17]=u,t[18]=h,t[19]=g,t[20]=_):_=t[20],_}function Ia(e){return{type:`skill`,data:e}}function La(e){return{type:`command`,data:e}}function Ra(e){return e.startsWith(`image/`)}function za(e){let t=(0,Q.c)(7),{attachments:n,onRemove:r}=e;if(n.length===0)return null;let i;if(t[0]!==n||t[1]!==r){let e;t[3]===r?e=t[4]:(e=(e,t)=>(0,$.jsx)(`div`,{className:`group relative flex items-center gap-1 rounded-md bg-muted text-xs text-muted-foreground`,children:Ra(e.mimeType)?(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.content}`,alt:e.fileName,className:`h-16 w-16 rounded-md object-cover`}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>r(t),className:`absolute -right-1.5 -top-1.5 flex h-4 w-4 items-center justify-center rounded-full bg-foreground text-background opacity-0 transition-opacity group-hover:opacity-100`,children:[(0,$.jsx)(v,{className:`h-2.5 w-2.5`}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Remove attachment`})]})]}):(0,$.jsxs)(`span`,{className:`flex items-center gap-1 px-2 py-1`,children:[(0,$.jsx)(ht,{className:`h-3 w-3`}),e.fileName,(0,$.jsxs)(`button`,{type:`button`,onClick:()=>r(t),className:`ml-1 hover:text-foreground`,children:[(0,$.jsx)(v,{className:`h-3 w-3`}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Remove attachment`})]})]})},t),t[3]=r,t[4]=e),i=n.map(e),t[0]=n,t[1]=r,t[2]=i}else i=t[2];let a;return t[5]===i?a=t[6]:(a=(0,$.jsx)(`div`,{className:`mb-2 flex flex-wrap gap-1.5`,children:i}),t[5]=i,t[6]=a),a}function Ba(e,t){let n=e.target.files;if(!n||n.length===0)return;let r=Array.from(n),i=r.length,a=Array.from({length:i}),o=0;e.target.value=``,r.forEach((e,n)=>{let r=new FileReader;r.onload=()=>{let s=r.result.split(`,`)[1];a[n]={fileName:e.name,content:s,mimeType:e.type||`application/octet-stream`},o+=1,o===i&&t(a)},r.readAsDataURL(e)})}function Va(e){let t=(0,Q.c)(16),{showSuggestions:n,fileSuggestions:r,suggestionQuery:i,selectedIndex:a,onSelectFile:o,onMouseEnterSuggestion:s,containerRef:c}=e;if(!n||r.length===0)return null;let l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(rn,{className:`h-3 w-3`}),t[0]=l):l=t[0];let u;t[1]===i?u=t[2]:(u=(0,$.jsxs)(`div`,{className:`px-2 py-1.5 text-xs font-semibold text-muted-foreground border-b border-border/50 mb-1 flex items-center gap-2`,children:[l,`Files matching "`,i,`"`]}),t[1]=i,t[2]=u);let d;if(t[3]!==r||t[4]!==s||t[5]!==o||t[6]!==a){let e;t[8]!==s||t[9]!==o||t[10]!==a?(e=(e,t)=>{let n=e.split(`/`).pop()??e;return(0,$.jsxs)(`button`,{type:`button`,className:N(`flex w-full items-center gap-2 rounded-lg px-3 py-2 text-sm text-left transition-colors`,t===a?`bg-accent text-accent-foreground`:`text-popover-foreground hover:bg-accent/50`),onClick:()=>o(e),onMouseEnter:()=>s(t),children:[e.endsWith(`.ts`)||e.endsWith(`.tsx`)||e.endsWith(`.js`)||e.endsWith(`.jsx`)?(0,$.jsx)(ue,{className:`h-4 w-4 text-blue-500`}):(0,$.jsx)(Mt,{className:`h-4 w-4 text-muted-foreground`}),(0,$.jsxs)(`div`,{className:`flex flex-col overflow-hidden`,children:[(0,$.jsx)(`span`,{className:`truncate font-medium`,children:n}),(0,$.jsx)(`span`,{className:`truncate text-[10px] text-muted-foreground opacity-70`,children:e})]})]},e)},t[8]=s,t[9]=o,t[10]=a,t[11]=e):e=t[11],d=r.map(e),t[3]=r,t[4]=s,t[5]=o,t[6]=a,t[7]=d}else d=t[7];let f;return t[12]!==c||t[13]!==u||t[14]!==d?(f=(0,$.jsxs)(`div`,{ref:c,className:`absolute bottom-full left-0 mb-2 w-full max-h-64 overflow-y-auto rounded-xl border border-border bg-popover p-1 shadow-lg z-50 animate-in fade-in slide-in-from-bottom-2`,children:[u,d]}),t[12]=c,t[13]=u,t[14]=d,t[15]=f):f=t[15],f}function Ha(e){let t=(0,Q.c)(3),{provider:n}=e;if(!n)return null;let r=`https://models.tarsk.io/svg/${n}.svg`,i=`${n} logo`,a;return t[0]!==r||t[1]!==i?(a=(0,$.jsx)(`img`,{src:r,alt:i,className:`h-3.5 w-3.5 flex-shrink-0`,onError:Ua}),t[0]=r,t[1]=i,t[2]=a):a=t[2],a}function Ua(e){e.currentTarget.style.visibility=`hidden`}function Wa(e){let t=(0,Q.c)(24),{availableModels:n,selectedModel:r,onModelSelect:i}=e,[a,o]=Z.useState(!1),s=Z.useRef(null),c,l;t[0]===a?(c=t[1],l=t[2]):(c=()=>{let e=e=>{s.current&&!s.current.contains(e.target)&&o(!1)};if(a)return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},l=[a],t[0]=a,t[1]=c,t[2]=l),Z.useEffect(c,l);let u;t[3]===i?u=t[4]:(u=e=>{i(e),o(!1)},t[3]=i,t[4]=u);let d=u,f;t[5]===a?f=t[6]:(f=()=>o(!a),t[5]=a,t[6]=f);let p=r?.provider,m;t[7]===p?m=t[8]:(m=(0,$.jsx)(Ha,{provider:p}),t[7]=p,t[8]=m);let h;t[9]===r?h=t[10]:(h=r?ei(r.id):`No model`,t[9]=r,t[10]=h);let g;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(Ce,{className:`h-3 w-3`}),t[11]=g):g=t[11];let _;t[12]!==f||t[13]!==m||t[14]!==h?(_=(0,$.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1 rounded-md px-2 py-1 text-xs text-muted-foreground hover:bg-muted hover:text-foreground transition-colors`,onClick:f,children:[m,h,g]}),t[12]=f,t[13]=m,t[14]=h,t[15]=_):_=t[15];let v;t[16]!==n||t[17]!==d||t[18]!==r?.id||t[19]!==a?(v=a&&(0,$.jsx)(`div`,{className:`absolute bottom-full left-0 mb-1 w-80 max-h-80 overflow-y-auto rounded-lg border border-border bg-popover p-1 shadow-md z-50`,children:Object.entries(n.reduce(Ga,{})).map(e=>{let[t,n]=e;return(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 px-3 py-1.5 text-xs font-semibold text-muted-foreground uppercase tracking-wide`,children:[(0,$.jsx)(Ha,{provider:t}),t]}),n.map(e=>(0,$.jsx)(`button`,{type:`button`,className:`flex w-full items-center whitespace-nowrap rounded-md px-3 py-1.5 pl-8 text-sm text-popover-foreground hover:bg-accent ${e.id===r?.id?`bg-accent font-medium`:``}`,onClick:()=>d(e),children:ei(e.id)},e.id))]},t)})}),t[16]=n,t[17]=d,t[18]=r?.id,t[19]=a,t[20]=v):v=t[20];let y;return t[21]!==v||t[22]!==_?(y=(0,$.jsxs)(`div`,{className:`relative`,ref:s,children:[_,v]}),t[21]=v,t[22]=_,t[23]=y):y=t[23],y}function Ga(e,t){let n=t.provider??`Other`;return e[n]||(e[n]=[]),e[n].push(t),e}function Ka(e){let t=(0,Q.c)(26),{onFileAttach:n,onPlanModeToggle:r,onImageModeToggle:i,onNewChat:a}=e,[o,s]=Z.useState(!1),c=Z.useRef(null),l,u;t[0]===o?(l=t[1],u=t[2]):(l=()=>{let e=e=>{c.current&&!c.current.contains(e.target)&&s(!1)};if(o)return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},u=[o],t[0]=o,t[1]=l,t[2]=u),Z.useEffect(l,u);let d;t[3]===n?d=t[4]:(d=()=>{n(),s(!1)},t[3]=n,t[4]=d);let f=d,p;t[5]===r?p=t[6]:(p=()=>{r(),s(!1)},t[5]=r,t[6]=p);let m=p,h;t[7]===i?h=t[8]:(h=()=>{i(),s(!1)},t[7]=i,t[8]=h);let g=h,_;t[9]===a?_=t[10]:(_=()=>{s(!1),a()},t[9]=a,t[10]=_);let v=_,y;t[11]===o?y=t[12]:(y=()=>s(!o),t[11]=o,t[12]=y);let b,x;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(Xe,{}),x=(0,$.jsx)(`span`,{className:`sr-only`,children:`More options`}),t[13]=b,t[14]=x):(b=t[13],x=t[14]);let S;t[15]===y?S=t[16]:(S=(0,$.jsxs)(q,{variant:`action`,size:`icon-sm`,onClick:y,children:[b,x]}),t[15]=y,t[16]=S);let C;t[17]!==f||t[18]!==g||t[19]!==v||t[20]!==m||t[21]!==o?(C=o&&(0,$.jsxs)(`div`,{className:`absolute bottom-full left-0 mb-1 w-48 rounded-lg border border-border bg-popover p-1 shadow-md z-50`,children:[(0,$.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 rounded-md px-3 py-2 text-sm text-popover-foreground hover:bg-accent`,onClick:f,children:[(0,$.jsx)(ht,{className:`h-3.5 w-3.5`}),`Attach File`]}),(0,$.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 rounded-md px-3 py-2 text-sm text-popover-foreground hover:bg-accent`,onClick:m,children:[(0,$.jsx)($e,{className:`h-3.5 w-3.5`}),`Plan Mode`]}),(0,$.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 rounded-md px-3 py-2 text-sm text-popover-foreground hover:bg-accent`,onClick:g,children:[(0,$.jsx)(at,{className:`h-3.5 w-3.5`}),`Image Mode`]}),(0,$.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 rounded-md px-3 py-2 text-sm text-popover-foreground hover:bg-accent`,onClick:v,children:[(0,$.jsx)(oe,{className:`h-3.5 w-3.5`}),`New Chat`]})]}),t[17]=f,t[18]=g,t[19]=v,t[20]=m,t[21]=o,t[22]=C):C=t[22];let w;return t[23]!==S||t[24]!==C?(w=(0,$.jsxs)(`div`,{className:`relative`,ref:c,children:[S,C]}),t[23]=S,t[24]=C,t[25]=w):w=t[25],w}function qa(e){let t=(0,Q.c)(14),{onToggleSpeech:n}=e,{isListening:r,isSupported:i}=Oa();if(!i)return null;let a=r?`bg-red-500/20 text-red-500 hover:bg-red-500/30`:`text-muted-foreground hover:text-background`,o;t[0]===r?o=t[1]:(o=r?(0,$.jsx)(dt,{}):(0,$.jsx)(gn,{}),t[0]=r,t[1]=o);let s=r?`Stop listening`:`Start listening`,c;t[2]===s?c=t[3]:(c=(0,$.jsx)(`span`,{className:`sr-only`,children:s}),t[2]=s,t[3]=c);let l;t[4]!==n||t[5]!==a||t[6]!==o||t[7]!==c?(l=(0,$.jsx)(Yr,{asChild:!0,children:(0,$.jsxs)(q,{variant:`ghost`,size:`icon-sm`,className:a,onClick:n,children:[o,c]})}),t[4]=n,t[5]=a,t[6]=o,t[7]=c,t[8]=l):l=t[8];let u=r?`Stop listening`:`Start listening`,d;t[9]===u?d=t[10]:(d=(0,$.jsx)(Kr,{side:`top`,className:`bg-popover text-popover-foreground`,children:u}),t[9]=u,t[10]=d);let f;return t[11]!==l||t[12]!==d?(f=(0,$.jsxs)(Jr,{children:[l,d]}),t[11]=l,t[12]=d,t[13]=f):f=t[13],f}function Ja({threadId:e,currentConversationId:t,children:n}){let[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)(null),[s,c]=(0,Z.useState)(null),[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(null),[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(!1);if((0,Z.useEffect)(()=>{if(!p||h||!e)return;async function n(){u(!0),f(null);try{let n=(await Fe(e)).currentConversationId??t,[r,a]=await Promise.allSettled([zt(e).catch(e=>{throw console.error(`Thread usage summary failed:`,e),e}),n?ln(e,n).catch(e=>{throw console.error(`Conversation usage failed:`,e),e}):Promise.resolve(null)]);if(r.status===`fulfilled`)i(r.value);else throw console.error(`Failed to fetch thread usage summary:`,r.reason),r.reason;if(a?.status===`fulfilled`&&a.value){if(o(a.value),a.value.model?.model){let e=a.value.model.model,t=a.value.model.provider,n=t&&e?`${t}/${e}`:e;console.log(`Fetching model info for:`,n,`(provider:`,t,`model:`,e+`)`),Ht(n).then(c).catch(e=>{console.warn(`Failed to fetch model info:`,e)})}}else if(a?.status===`rejected`)throw console.error(`Failed to fetch conversation usage:`,a.reason),a.reason;g(!0)}catch(e){console.error(`[TokenUsageTooltip] Failed to load usage data:`,e),f(`Failed to load usage data`)}finally{u(!1)}}n()},[p,h,e,t]),!e||e===``)return console.log(`[TokenUsageTooltip] No valid threadId, returning children only`),(0,$.jsx)($.Fragment,{children:n});let _=e=>e==null||e===0?`0`:e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toString();return e?(0,$.jsxs)(Jr,{open:p,onOpenChange:e=>{m(e),!e&&h&&g(!1)},children:[(0,$.jsx)(Yr,{asChild:!0,children:n}),(0,$.jsx)(Kr,{side:`top`,align:`center`,className:`max-w-xs`,children:(0,$.jsxs)(`div`,{className:`text-xs text-muted-foreground space-y-2`,children:[l&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(mt,{className:`h-3 w-3 animate-pulse`}),(0,$.jsx)(`span`,{children:`Loading usage...`})]}),d&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-red-500`,children:[(0,$.jsx)(mt,{className:`h-3 w-3`}),(0,$.jsx)(`span`,{children:`Failed to load usage`})]}),!l&&!d&&r&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(mt,{className:`h-3 w-3`}),(0,$.jsxs)(`span`,{className:`font-medium`,children:[_(r.totalTokens),` tokens`]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(se,{className:`h-3 w-3`}),(0,$.jsxs)(`span`,{children:[r.conversationCount,` chats`]})]})]}),a&&(0,$.jsxs)(`div`,{className:`border-t border-border pt-2 space-y-1`,children:[(0,$.jsx)(`div`,{className:`text-xs font-semibold text-foreground`,children:`Current Chat:`}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(S,{className:`h-3 w-3`}),(0,$.jsxs)(`span`,{children:[((e,t)=>{let n=_(e);return t?`${n} (${Math.round(e/t*100)}%)`:n})(a.footprint?.totalTokens??a.usage.totalTokens,typeof s?.context_length==`number`?s.context_length:void 0),` `,`tokens`]})]}),a.model.model&&(0,$.jsxs)(`div`,{className:`text-muted-foreground`,children:[a.model.model,s?.context_length&&(0,$.jsxs)(`span`,{className:`ml-1`,children:[_(typeof s.context_length==`number`?s.context_length:0),` `,`context)`]})]})]}),(0,$.jsxs)(`div`,{className:`border-t border-border pt-2 flex items-center gap-3 text-[10px] text-muted-foreground`,children:[(0,$.jsxs)(`span`,{children:[`In: `,_(r.totalInputTokens)]}),(0,$.jsxs)(`span`,{children:[`Out: `,_(r.totalOutputTokens)]}),(0,$.jsxs)(`span`,{children:[`Avg: `,_(r.averageTokensPerConversation),`/chat`]})]})]})]})})]}):(0,$.jsx)($.Fragment,{children:n})}function Ya(e){let t=(0,Q.c)(7),{threadId:n}=e,[r,i]=(0,Z.useState)(),a,o;if(t[0]===n?(a=t[1],o=t[2]):(a=()=>{(async function(){if(n)try{i((await Fe(n)).currentConversationId)}catch(e){console.error(`Failed to fetch thread data:`,e)}})()},o=[n],t[0]=n,t[1]=a,t[2]=o),(0,Z.useEffect)(a,o),!n||n===``)return null;let s;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsxs)(q,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground hover:text-background`,children:[(0,$.jsx)(se,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`sr-only`,children:`View token usage`})]}),t[3]=s):s=t[3];let c;return t[4]!==r||t[5]!==n?(c=(0,$.jsx)(Ja,{threadId:n,currentConversationId:r,children:s}),t[4]=r,t[5]=n,t[6]=c):c=t[6],c}function Xa(e){let t=(0,Q.c)(8),{queuedMessages:n,onRemoveQueuedMessage:r}=e;if(n.length===0)return null;let i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground`,children:`Queued messages`}),t[0]=i):i=t[0];let a;if(t[1]!==r||t[2]!==n){let e;t[4]===r?e=t[5]:(e=e=>(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3 rounded-md border border-border/60 bg-background px-3 py-2 text-sm`,children:[(0,$.jsx)(`p`,{className:`flex-1 whitespace-pre-wrap text-foreground`,children:e.message}),(0,$.jsx)(`button`,{type:`button`,className:`rounded-full p-1 text-muted-foreground transition-colors hover:bg-foreground hover:text-background`,onClick:()=>r(e.id),"aria-label":`Remove queued message`,children:(0,$.jsx)(v,{className:`h-3.5 w-3.5`})})]},e.id),t[4]=r,t[5]=e),a=n.map(e),t[1]=r,t[2]=n,t[3]=a}else a=t[3];let o;return t[6]===a?o=t[7]:(o=(0,$.jsxs)(`div`,{className:`mb-3 rounded-lg border border-border/60 bg-muted/30 px-4 py-3`,children:[i,(0,$.jsx)(`div`,{className:`mt-2 flex flex-col gap-2`,children:a})]}),t[6]=a,t[7]=o),o}function Za(e){let t=(0,Q.c)(152),{onSend:n,onStop:r,isStreaming:i,disabled:a,initialValue:o,queuedMessages:s,onRemoveQueuedMessage:c,isOverlay:l}=e,u=i===void 0?!1:i,d=l===void 0?!1:l,{isListening:f,transcript:p,startListening:m,stopListening:h,resetTranscript:g}=Oa(),_;t[0]===o?_=t[1]:(_={initialValue:o},t[0]=o,t[1]=_);let{message:y,setMessage:b,historyIndex:x,setHistoryIndex:S,draftMessage:C,setDraftMessage:w,cursorPosition:T,setCursorPosition:E,availableModels:D,selectedModel:O,setSelectedModel:k,attachments:A,setAttachments:j,planMode:M,setPlanMode:N,imageMode:P,setImageMode:F,availableImageModels:I,selectedImageModel:L,setSelectedImageModel:R,allFiles:z,setAllFiles:B,showSuggestions:V,setShowSuggestions:H,suggestionQuery:U,setSuggestionQuery:W,selectedIndex:G,setSelectedIndex:ee,slashCommands:te,skills:ne,showCommandSuggestions:K,setShowCommandSuggestions:re,commandQuery:ie,setCommandQuery:ae,fileInputRef:oe,textareaRef:se,suggestionsRef:ce,commandSuggestionsRef:le,handleNewChat:ue,state:de,dispatch:fe}=ka(_),pe=P?L:O,me=P?I:D,he=de.selectedThreadId??void 0,ge;t[2]!==z||t[3]!==A||t[4]!==ie||t[5]!==T||t[6]!==fe||t[7]!==C||t[8]!==x||t[9]!==P||t[10]!==f||t[11]!==u||t[12]!==y||t[13]!==n||t[14]!==M||t[15]!==g||t[16]!==L||t[17]!==G||t[18]!==O||t[19]!==B||t[20]!==j||t[21]!==ae||t[22]!==E||t[23]!==w||t[24]!==S||t[25]!==b||t[26]!==N||t[27]!==ee||t[28]!==re||t[29]!==H||t[30]!==W||t[31]!==K||t[32]!==V||t[33]!==ne||t[34]!==te||t[35]!==h||t[36]!==U||t[37]!==he||t[38]!==se?(ge={message:y,setMessage:b,attachments:A,selectedModel:O,onSend:n,isStreaming:u,selectedThreadId:he,isListening:f,stopListening:h,resetTranscript:g,dispatch:fe,historyIndex:x,setHistoryIndex:S,draftMessage:C,setDraftMessage:w,cursorPosition:T,setCursorPosition:E,showSuggestions:V,setShowSuggestions:H,suggestionQuery:U,setSuggestionQuery:W,allFiles:z,setAllFiles:B,selectedIndex:G,setSelectedIndex:ee,showCommandSuggestions:K,setShowCommandSuggestions:re,commandQuery:ie,setCommandQuery:ae,slashCommands:te,skills:ne,textareaRef:se,setAttachments:j,planMode:M,setPlanMode:N,imageMode:P,selectedImageModel:L},t[2]=z,t[3]=A,t[4]=ie,t[5]=T,t[6]=fe,t[7]=C,t[8]=x,t[9]=P,t[10]=f,t[11]=u,t[12]=y,t[13]=n,t[14]=M,t[15]=g,t[16]=L,t[17]=G,t[18]=O,t[19]=B,t[20]=j,t[21]=ae,t[22]=E,t[23]=w,t[24]=S,t[25]=b,t[26]=N,t[27]=ee,t[28]=re,t[29]=H,t[30]=W,t[31]=K,t[32]=V,t[33]=ne,t[34]=te,t[35]=h,t[36]=U,t[37]=he,t[38]=se,t[39]=ge):ge=t[39];let{handleSend:J,handleKeyDown:_e,handleTextareaInput:ve,insertFileReference:ye,insertCommand:be,insertSkill:xe,fileSuggestions:Se}=ja(ge),Ce=Z.useRef(``),we,Te;t[40]!==b||t[41]!==p?(we=()=>{if(p&&p!==Ce.current){let e=p.substring(Ce.current.length);b(t=>(t.endsWith(` `),t+e)),Ce.current=p}},Te=[p,b],t[40]=b,t[41]=p,t[42]=we,t[43]=Te):(we=t[42],Te=t[43]),Z.useEffect(we,Te);let Ee;t[44]===j?Ee=t[45]:(Ee=e=>{let t=e.clipboardData?.items;if(!t)return;let n=Array.from(t).filter($a);if(n.length!==0){e.preventDefault();for(let e of n){let t=e.getAsFile();if(!t)continue;let n=new FileReader;n.onload=()=>{let e=n.result.split(`,`)[1];j(n=>[...n,{fileName:t.name||`pasted-image.${t.type.split(`/`)[1]||`png`}`,content:e,mimeType:t.type}])},n.readAsDataURL(t)}}},t[44]=j,t[45]=Ee);let De=Ee,Oe;t[46]!==f||t[47]!==g||t[48]!==m||t[49]!==h?(Oe=()=>{f?(h(),g()):(g(),m())},t[46]=f,t[47]=g,t[48]=m,t[49]=h,t[50]=Oe):Oe=t[50];let ke=Oe,Ae=d?`absolute inset-x-0 bottom-0 mx-auto w-full max-w-3xl px-4 pb-4 pointer-events-none`:`relative mx-auto w-full max-w-3xl px-4 pb-4`,je;t[51]!==M||t[52]!==N?(je=M&&(0,$.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 rounded-md bg-accent px-3 py-1.5`,children:[(0,$.jsx)($e,{className:`h-3.5 w-3.5 text-accent-foreground`}),(0,$.jsx)(`span`,{className:`text-xs text-accent-foreground font-medium`,children:`Plan Mode`}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>N(!1),className:`ml-auto`,children:[(0,$.jsx)(v,{className:`h-3 w-3 text-accent-foreground`}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Exit plan mode`})]})]}),t[51]=M,t[52]=N,t[53]=je):je=t[53];let Me;t[54]!==P||t[55]!==F?(Me=P&&(0,$.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 rounded-md bg-accent px-3 py-1.5`,children:[(0,$.jsx)(at,{className:`h-3.5 w-3.5 text-accent-foreground`}),(0,$.jsx)(`span`,{className:`text-xs text-accent-foreground font-medium`,children:`Image Mode`}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>F(!1),className:`ml-auto`,children:[(0,$.jsx)(v,{className:`h-3 w-3 text-accent-foreground`}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Exit image mode`})]})]}),t[54]=P,t[55]=F,t[56]=Me):Me=t[56];let Ne=`flex flex-col rounded-2xl border focus-within:ring-2 focus-within:ring-brand pointer-events-auto ${d?`border-border/50 bg-background/80 shadow-lg backdrop-blur-sm`:`border-border bg-background shadow-2xl`}`,Pe;t[57]!==c||t[58]!==s?(Pe=(0,$.jsx)(Xa,{queuedMessages:s,onRemoveQueuedMessage:c}),t[57]=c,t[58]=s,t[59]=Pe):Pe=t[59];let Fe;t[60]!==a||t[61]!==_e||t[62]!==De||t[63]!==ve||t[64]!==y||t[65]!==se?(Fe=(0,$.jsx)(`textarea`,{ref:se,value:y,onChange:ve,onKeyDown:_e,onPaste:De,placeholder:`Ask Tarsk anything, # for files, / for commands & skills`,rows:1,className:`w-full resize-none bg-transparent px-6 pt-4 pb-4 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none`,disabled:a}),t[60]=a,t[61]=_e,t[62]=De,t[63]=ve,t[64]=y,t[65]=se,t[66]=Fe):Fe=t[66];let Ie;t[67]!==ie||t[68]!==le||t[69]!==be||t[70]!==xe||t[71]!==G||t[72]!==ee||t[73]!==K||t[74]!==ne||t[75]!==te?(Ie=(0,$.jsx)(Fa,{visible:K,commands:te,skills:ne,query:ie,selectedIndex:G,onSelectCommand:be,onSelectSkill:xe,onMouseEnterSuggestion:ee,containerRef:le}),t[67]=ie,t[68]=le,t[69]=be,t[70]=xe,t[71]=G,t[72]=ee,t[73]=K,t[74]=ne,t[75]=te,t[76]=Ie):Ie=t[76];let Le;t[77]!==Se||t[78]!==ye||t[79]!==G||t[80]!==ee||t[81]!==V||t[82]!==U||t[83]!==ce?(Le=(0,$.jsx)(Va,{showSuggestions:V,fileSuggestions:Se,suggestionQuery:U,selectedIndex:G,onSelectFile:ye,onMouseEnterSuggestion:ee,containerRef:ce}),t[77]=Se,t[78]=ye,t[79]=G,t[80]=ee,t[81]=V,t[82]=U,t[83]=ce,t[84]=Le):Le=t[84];let Re;t[85]!==A||t[86]!==O?.id||t[87]!==O?.name||t[88]!==O?.supportsImages||t[89]!==j?(Re=A.length>0&&(0,$.jsxs)(`div`,{className:`px-4`,children:[(0,$.jsx)(za,{attachments:A,onRemove:e=>j(t=>t.filter((t,n)=>n!==e))}),A.some(Qa)&&O?.supportsImages===!1&&(0,$.jsxs)(`div`,{className:`mb-2 flex items-center gap-1.5 text-xs text-amber-500`,children:[(0,$.jsx)(Pt,{className:`h-3 w-3 shrink-0`}),(0,$.jsxs)(`span`,{children:[`Images are not supported by `,O?.name||O?.id]})]})]}),t[85]=A,t[86]=O?.id,t[87]=O?.name,t[88]=O?.supportsImages,t[89]=j,t[90]=Re):Re=t[90];let ze;t[91]===oe?ze=t[92]:(ze=()=>oe.current?.click(),t[91]=oe,t[92]=ze);let Be;t[93]===N?Be=t[94]:(Be=()=>N(!0),t[93]=N,t[94]=Be);let Ve;t[95]===F?Ve=t[96]:(Ve=()=>F(!0),t[95]=F,t[96]=Ve);let He;t[97]!==ue||t[98]!==ze||t[99]!==Be||t[100]!==Ve?(He=(0,$.jsx)(Ka,{onFileAttach:ze,onPlanModeToggle:Be,onImageModeToggle:Ve,onNewChat:ue}),t[97]=ue,t[98]=ze,t[99]=Be,t[100]=Ve,t[101]=He):He=t[101];let Ue;t[102]===ke?Ue=t[103]:(Ue=(0,$.jsx)(qa,{onToggleSpeech:ke}),t[102]=ke,t[103]=Ue);let We=de.selectedThreadId??void 0,Ge;t[104]===We?Ge=t[105]:(Ge=(0,$.jsx)(Ya,{threadId:We}),t[104]=We,t[105]=Ge);let Ke=P?R:k,qe;t[106]!==me||t[107]!==pe||t[108]!==Ke?(qe=(0,$.jsx)(Wa,{availableModels:me,selectedModel:pe,onModelSelect:Ke}),t[106]=me,t[107]=pe,t[108]=Ke,t[109]=qe):qe=t[109];let Je;t[110]!==He||t[111]!==Ue||t[112]!==Ge||t[113]!==qe?(Je=(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[He,Ue,Ge,qe]}),t[110]=He,t[111]=Ue,t[112]=Ge,t[113]=qe,t[114]=Je):Je=t[114];let Ye=u?r:J,Xe;t[115]!==A.length||t[116]!==a||t[117]!==pe||t[118]!==u||t[119]!==y?(Xe=!u&&((a??!1)||!y.trim()&&A.length===0||!pe),t[115]=A.length,t[116]=a,t[117]=pe,t[118]=u,t[119]=y,t[120]=Xe):Xe=t[120];let Ze;t[121]===u?Ze=t[122]:(Ze=u?(0,$.jsx)(Fn,{className:`h-3 w-3 fill-current`}):(0,$.jsx)(on,{className:`h-3 w-3`}),t[121]=u,t[122]=Ze);let Qe=u?`Stop generation`:`Send message`,et;t[123]===Qe?et=t[124]:(et=(0,$.jsx)(`span`,{className:`sr-only`,children:Qe}),t[123]=Qe,t[124]=et);let tt;t[125]!==Ye||t[126]!==Xe||t[127]!==Ze||t[128]!==et?(tt=(0,$.jsxs)(q,{size:`icon`,className:`h-7 w-7 rounded-full`,onClick:Ye,disabled:Xe,children:[Ze,et]}),t[125]=Ye,t[126]=Xe,t[127]=Ze,t[128]=et,t[129]=tt):tt=t[129];let nt;t[130]!==Je||t[131]!==tt?(nt=(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-3 pb-2`,children:[Je,tt]}),t[130]=Je,t[131]=tt,t[132]=nt):nt=t[132];let rt;t[133]!==Ne||t[134]!==Pe||t[135]!==Fe||t[136]!==Ie||t[137]!==Le||t[138]!==Re||t[139]!==nt?(rt=(0,$.jsxs)(`div`,{className:Ne,children:[Pe,Fe,Ie,Le,Re,nt]}),t[133]=Ne,t[134]=Pe,t[135]=Fe,t[136]=Ie,t[137]=Le,t[138]=Re,t[139]=nt,t[140]=rt):rt=t[140];let it;t[141]===j?it=t[142]:(it=e=>Ba(e,e=>j(t=>[...t,...e])),t[141]=j,t[142]=it);let ot;t[143]!==oe||t[144]!==it?(ot=(0,$.jsx)(`input`,{ref:oe,type:`file`,multiple:!0,className:`hidden`,onChange:it}),t[143]=oe,t[144]=it,t[145]=ot):ot=t[145];let st;return t[146]!==Ae||t[147]!==je||t[148]!==Me||t[149]!==rt||t[150]!==ot?(st=(0,$.jsxs)(`div`,{className:Ae,children:[je,Me,rt,ot]}),t[146]=Ae,t[147]=je,t[148]=Me,t[149]=rt,t[150]=ot,t[151]=st):st=t[151],st}function Qa(e){return e.mimeType.startsWith(`image/`)}function $a(e){return e.type.startsWith(`image/`)}function eo({threadId:e}){let[t,n]=(0,Z.useState)(!1),[r,i]=(0,Z.useState)(null);return(0,Z.useEffect)(()=>{e&&hn(e).then(i).catch(()=>{})},[e]),(0,$.jsx)(`div`,{className:`flex items-center justify-end gap-2 px-8 py-2 mt-[-1rem] min-h-[2.25rem]`,children:e&&(0,$.jsxs)(Jr,{children:[(0,$.jsx)(Yr,{asChild:!0,children:(0,$.jsx)(q,{variant:`ghost`,size:`icon`,className:`h-6 w-6 opacity-50 hover:opacity-80`,onClick:async()=>{if(!(!e||t)){n(!0);try{let t=await hn(e);await navigator.clipboard.writeText(t)}finally{n(!1)}}},disabled:t,"aria-label":`Copy repository folder path`,children:(0,$.jsx)(he,{className:`h-3 w-3`})})}),(0,$.jsxs)(Kr,{side:`top`,className:`bg-slate-900 text-white`,children:[(0,$.jsx)(`div`,{children:`Copy repository folder path`}),r&&(0,$.jsx)(`div`,{className:`opacity-70 text-xs`,children:r})]})]})})}function to(){let{state:e,dispatch:t}=Nr(),[n,r]=(0,Z.useState)(null),[i,a]=(0,Z.useState)(!1),o=(0,Z.useRef)(``),s=(0,Z.useRef)(``),c=(0,Z.useRef)([]),l=(0,Z.useRef)(!1),u=(0,Z.useRef)(null),d=(0,Z.useRef)(null),f=(0,Z.useRef)(()=>{}),[p,m]=(0,Z.useState)(null),h=(0,Z.useRef)(!1),g=(0,Z.useRef)(!1),_=(0,Z.useRef)(null),v=(0,Z.useRef)(null),y=(0,Z.useRef)(null),{selectedThreadId:b,selectedProjectId:x,messages:S,queuedChatMessages:C,isStreaming:w,streamingModel:T,processingThreadIds:E}=e,D=!!(b&&E.includes(b)),O=(0,Z.useCallback)(n=>{if(u.current=null,d.current=null,h.current){h.current=!1;return}let r=c.current,i=Ur(r)||`...`;if(_.current&&(r.length===0||i===`...`)){let r={messageId:`msg-${Date.now()}-error`,sender:`agent`,content:`Error: ${_.current}`,contentType:`text`,timestamp:new Date().toISOString(),model:e.streamingModel||n,isThinking:!1};t({type:Y.AddMessage,message:r}),t({type:Y.ResetStream}),b&&t({type:Y.RemoveProcessingThread,threadId:b}),_.current=null;return}let a={messageId:`msg-${Date.now()}-agent`,sender:`agent`,content:i,contentType:`markdown`,timestamp:new Date().toISOString(),model:e.streamingModel||n,isThinking:!1};o.current=``,s.current=``,c.current=[],_.current=null,t({type:Y.AddMessage,message:a}),t({type:Y.ResetStream}),b&&(t({type:Y.MarkThreadCompleted,threadId:b}),t({type:Y.RemoveProcessingThread,threadId:b}))},[e.streamingModel,t,b]);(0,Z.useEffect)(()=>{f.current=O},[O]);let k=(0,Z.useCallback)(()=>{b&&m(b),h.current=!0,b&&Xt(b),u.current&&=(u.current.abort(),null),d.current&&=(d.current(),null),o.current=``,s.current=``,c.current=[],_.current=null;let n={messageId:`msg-${Date.now()}-stopped`,sender:`agent`,content:`I've stopped working on your request.`,contentType:`text`,timestamp:new Date().toISOString(),model:e.streamingModel||`default`,isThinking:!1};t({type:Y.AddMessage,message:n}),t({type:Y.ResetStream}),b&&(t({type:Y.MarkThreadCompleted,threadId:b}),t({type:Y.RemoveProcessingThread,threadId:b}))},[b,t,e.streamingModel]);(0,Z.useEffect)(()=>{g.current&&!w&&u.current&&(u.current.abort(),u.current=null,d.current&&=(d.current(),null),f.current(T||`default`)),g.current=w},[w,T]),(0,Z.useEffect)(()=>{if(v.current&&=(clearTimeout(v.current),null),w){let e=12e4,t=n=>{v.current&&=(clearTimeout(v.current),null),v.current=setTimeout(()=>{let n=Date.now(),r=y?.current??null;if(r!=null){let i=n-r;if(i<e){t(e-i);return}}console.warn(`[stream-safety] Streaming stuck for 2 minutes with no activity, auto-finalizing`),u.current&&=(u.current.abort(),null),d.current&&=(d.current(),null),f.current(T||`default`)},n)},n=e;if(y?.current!=null){let t=Date.now()-y.current;n=t>=e?0:e-t}t(n)}return()=>{v.current&&=(clearTimeout(v.current),null)}},[w,T]),(0,Z.useEffect)(()=>()=>{u.current&&=(u.current.abort(),null),d.current&&=(d.current(),null),t({type:Y.ResetStream})},[b,t]),(0,Z.useEffect)(()=>{if(!b)return;let e=!1;async function n(){try{let n=await _t(b);e||t({type:Y.SetMessages,messages:n.messages})}catch(n){console.error(`Failed to load chat history:`,n),e||t({type:Y.SetMessages,messages:[]})}}return n(),()=>{e=!0}},[b,x,t]),(0,Z.useEffect)(()=>{if(!b||!D||w)return;let e=new AbortController;return u.current=e,t({type:Y.ResetStream}),t({type:Y.SetStreaming,isStreaming:!0}),o.current=``,s.current=``,c.current=[],l.current=!1,_.current=null,ft(b,e.signal).then(n=>{if(!n||e.signal.aborted){f.current(`default`);return}d.current=H(n,e=>{if(e.type===`error`){let t=e.content||`Unknown error occurred`;_.current=t,r(t);return}if(e.type!==`message`){if(e.type===`toolcall_delta`){e.partial?.content?.[0]?.id&&e.delta&&t({type:Y.UpdateToolCallProgress,toolCallId:e.partial.content[0].id,progress:{toolCallId:e.partial.content[0].id,toolName:e.partial.content[0].name,delta:e.delta,partial:e.partial}});return}if(e.model&&t({type:Y.SetStreamModel,model:e.model}),e.type===`thinking`||e.isThinking){s.current+=e.content??``;let n=Rr(c.current,`thinking`,e.content??``);c.current=n,t({type:Y.AppendStreamChunk,chunkType:`thinking`,content:e.content??``,segments:n})}else if(e.type===`result`)l.current=!0,o.current=e.content??``,c.current=Wr(c.current,e.content??``),t({type:Y.SetStreamContent,content:e.content??``});else{if(l.current)return;o.current+=e.content??``;let n=Rr(c.current,`content`,e.content??``);c.current=n,t({type:Y.AppendStreamChunk,chunkType:`content`,content:e.content??``,segments:n})}}},()=>{f.current(`default`)},e=>{if(e.includes(`AbortError`)||e.includes(`canceled`)||e.includes(`BodyStreamBuffer was aborted`)){f.current(`default`);return}_.current=e,r(e)},e=>{if(e.role===`assistant`){let n=e.content??``,r=typeof n==`string`?n:JSON.stringify(n);if(e.isThinking??!1){s.current+=r;let e=Rr(c.current,`thinking`,r);c.current=e,t({type:Y.AppendStreamChunk,chunkType:`thinking`,content:r,segments:e});return}let i=!1;if(typeof n==`object`&&Array.isArray(n)&&n.length>0)i=!0;else if(typeof r==`string`&&r.trim().startsWith(`[`))try{let e=JSON.parse(r);i=Array.isArray(e)&&e.length>0}catch{}if(i)l.current=!0,o.current=r,c.current=Wr(c.current,r),t({type:Y.SetStreamContent,content:r});else{o.current+=r;let e=Rr(c.current,`content`,r);c.current=e,t({type:Y.AppendStreamChunk,chunkType:`content`,content:r,segments:e})}}else if(e.role===`tool`){let n=e.content??``,r=typeof n==`string`?n:JSON.stringify(n);if(r){o.current+=r;let e=Rr(c.current,`content`,r);c.current=e,t({type:Y.AppendStreamChunk,chunkType:`content`,content:r,segments:e})}}})}).catch(e=>{if(e instanceof Error&&e.name===`AbortError`){t({type:Y.ResetStream});return}if(e instanceof Error&&e.message.includes(`not currently processing`)){t({type:Y.ResetStream});return}console.error(`Failed to subscribe to chat stream:`,e),t({type:Y.ResetStream})}),()=>{e.abort(),d.current&&=(d.current(),null)}},[b,D]);let A=(0,Z.useCallback)(async(e,n,i,p,h,g)=>{if(!b)return;r(null),m(null),u.current&&u.current.abort(),d.current&&d.current();let v={messageId:`msg-${Date.now()}`,sender:`user`,content:e,contentType:`text`,timestamp:new Date().toISOString(),model:n,attachments:i.map(e=>({fileName:e.fileName,content:e.content,mimeType:e.mimeType}))};t({type:Y.AddMessage,message:v});let y=e.trim().replace(/\n/g,` `).slice(0,100);if(x&&b&&(bn(b,{title:y}).catch(e=>{console.error(`Failed to update thread title:`,e)}),t({type:Y.UpdateThreadTitle,projectId:x,threadId:b,title:y})),g){let r=p??void 0;if(!r&&typeof n==`string`){let e=n.split(/[:/]/)[0]?.trim();e&&(r=e)}if(!r){let e={messageId:`msg-${Date.now()}-error`,sender:`agent`,content:`Image generation is not available because no provider is configured for the selected model.`,contentType:`text`,timestamp:new Date().toISOString(),model:n,isThinking:!1};t({type:Y.AddMessage,message:e}),t({type:Y.ResetStream});return}t({type:Y.SetStreaming,isStreaming:!0});try{let i=await z(e,n,r,b),a={messageId:`msg-${Date.now()}-agent`,sender:`agent`,content:e,contentType:`text`,timestamp:new Date().toISOString(),model:n,isThinking:!1,generatedImageUrl:i.imageUrl,generatedImageData:i.imageData};t({type:Y.AddMessage,message:a})}catch(e){let r=e instanceof Error?e.message:`Image generation failed`,i={messageId:`msg-${Date.now()}-error`,sender:`agent`,content:`Error: ${r}`,contentType:`text`,timestamp:new Date().toISOString(),model:n,isThinking:!1};t({type:Y.AddMessage,message:i})}finally{t({type:Y.ResetStream})}return}t({type:Y.ResetStream}),t({type:Y.SetStreaming,isStreaming:!0}),o.current=``,l.current=!1;let S=new AbortController;u.current=S;try{let a=await At(b,e,n,i,S.signal,p,h);if(!a){f.current(n);return}d.current=H(a,e=>{if(e.type===`error`){let t=e.content||`Unknown error occurred`;_.current=t,r(t);return}if(e.type!==`message`){if(e.type===`toolcall_delta`){if(e.partial?.content?.[0]?.id&&e.delta){let n=e.partial.content[0].id,r=e.partial.content[0].name;t({type:Y.UpdateToolCallProgress,toolCallId:n,progress:{toolCallId:n,toolName:r,delta:e.delta,partial:e.partial}})}return}if(e.model&&t({type:Y.SetStreamModel,model:e.model}),e.type===`thinking`||e.isThinking){s.current+=e.content??``;let n=Rr(c.current,`thinking`,e.content??``);c.current=n,t({type:Y.AppendStreamChunk,chunkType:`thinking`,content:e.content??``,segments:n})}else if(e.type===`result`)l.current=!0,o.current=e.content??``,c.current=Wr(c.current,e.content??``),t({type:Y.SetStreamContent,content:e.content??``});else{if(l.current)return;o.current+=e.content??``;let n=Rr(c.current,`content`,e.content??``);c.current=n,t({type:Y.AppendStreamChunk,chunkType:`content`,content:e.content??``,segments:n})}}},()=>{f.current(n)},e=>{if(e.includes(`AbortError`)||e.includes(`canceled`)||e.includes(`BodyStreamBuffer was aborted`)){f.current(n);return}_.current=e,r(e)},e=>{if(e.role===`assistant`){let n=e.content??``,r=typeof n==`string`?n:JSON.stringify(n);if(e.isThinking??!1){s.current+=r;let e=Rr(c.current,`thinking`,r);c.current=e,t({type:Y.AppendStreamChunk,chunkType:`thinking`,content:r,segments:e});return}let i=!1;if(typeof n==`object`&&Array.isArray(n)&&n.length>0)i=!0;else if(typeof r==`string`&&r.trim().startsWith(`[`))try{let e=JSON.parse(r);i=Array.isArray(e)&&e.length>0}catch{}if(i)l.current=!0,o.current=r,c.current=Wr(c.current,r),t({type:Y.SetStreamContent,content:r});else{o.current+=r;let e=Rr(c.current,`content`,r);c.current=e,t({type:Y.AppendStreamChunk,chunkType:`content`,content:r,segments:e})}}else if(e.role===`tool`){let n=e.content??``,r=typeof n==`string`?n:JSON.stringify(n);if(r){o.current+=r;let e=Rr(c.current,`content`,r);c.current=e,t({type:Y.AppendStreamChunk,chunkType:`content`,content:r,segments:e})}}})}catch(e){if(e instanceof Error&&e.name===`AbortError`||e instanceof Error&&e.message.includes(`BodyStreamBuffer was aborted`))return;if(e instanceof kn){t({type:Y.ResetStream}),a(!0);return}r(e instanceof Error?e.message:`Failed to send message. Please ensure the CLI server is running on localhost:641`),_.current=e instanceof Error?e.message:`Failed to send message. Please ensure the CLI server is running on localhost:641`,t({type:Y.ResetStream})}},[b,x,t]);(0,Z.useEffect)(()=>{let n=e.pendingChatMessage;if(!n||w||n.threadId!==b)return;let r=setTimeout(()=>{t({type:Y.ClearPendingChatMessage}),A(n.message,n.model,[],n.provider)},100);return()=>clearTimeout(r)},[e.pendingChatMessage,w,b,t,A]);let j=(0,Z.useMemo)(()=>b?C.filter(e=>e.threadId===b):[],[b,C]),M=(0,Z.useRef)(!1);return(0,Z.useEffect)(()=>{if(w||!b||j.length===0||M.current)return;let[e]=j;M.current=!0,t({type:Y.RemoveQueuedChatMessage,queuedMessageId:e.id});let n=setTimeout(()=>{A(e.message,e.model,e.attachments,e.provider,e.planMode),M.current=!1},0);return()=>{clearTimeout(n),M.current=!1}},[t,A,w,j,b]),{error:n,setError:r,handleSend:A,handleStop:k,isStreaming:w,selectedThreadId:b,queuedMessagesForThread:j,handleRemoveQueuedMessage:(0,Z.useCallback)(e=>{let n=j.find(t=>t.id===e);t({type:Y.RemoveQueuedChatMessage,queuedMessageId:e}),!(!n||w||S.length>0||!b)&&A(n.message,n.model,n.attachments,n.provider,n.planMode)},[t,A,w,S.length,j,b]),showEmptyBalanceDialog:i,setShowEmptyBalanceDialog:a}}function no(e){let t=(0,Q.c)(10),{open:n,onClose:r}=e,i=hr(),a;t[0]===r?a=t[1]:(a=e=>{e||r()},t[0]=r,t[1]=a);let o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsxs)(pi,{children:[(0,$.jsx)(hi,{children:`Balance empty`}),(0,$.jsx)(gi,{children:`You have no prompts remaining. Purchase additional prompts to continue.`})]}),t[2]=o):o=t[2];let s;t[3]!==i||t[4]!==r?(s=(0,$.jsxs)(fi,{children:[o,(0,$.jsx)(mi,{children:(0,$.jsx)(q,{onClick:()=>{r(),i(`/settings/account`)},children:`Go to Account`})})]}),t[3]=i,t[4]=r,t[5]=s):s=t[5];let c;return t[6]!==n||t[7]!==a||t[8]!==s?(c=(0,$.jsx)(li,{open:n,onOpenChange:a,children:s}),t[6]=n,t[7]=a,t[8]=s,t[9]=c):c=t[9],c}function ro(){let e=(0,Q.c)(20),{state:t}=Nr(),{isCreatingProject:n}=t,{handleSend:r,handleStop:i,isStreaming:a,selectedThreadId:o,queuedMessagesForThread:s,handleRemoveQueuedMessage:c,showEmptyBalanceDialog:l,setShowEmptyBalanceDialog:u}=to(),d=t.pendingChatMessage?.threadId===o,f=a||d,p;e[0]===u?p=e[1]:(p=()=>u(!1),e[0]=u,e[1]=p);let m;e[2]!==l||e[3]!==p?(m=(0,$.jsx)(no,{open:l,onClose:p}),e[2]=l,e[3]=p,e[4]=m):m=e[4];let h=!o&&!n,g;e[5]!==f||e[6]!==c||e[7]!==r||e[8]!==i||e[9]!==s||e[10]!==h?(g=(0,$.jsx)(Za,{onSend:r,onStop:i,isStreaming:f,disabled:h,initialValue:``,queuedMessages:s,onRemoveQueuedMessage:c,isOverlay:!1}),e[5]=f,e[6]=c,e[7]=r,e[8]=i,e[9]=s,e[10]=h,e[11]=g):g=e[11];let _=o??void 0,v;e[12]===_?v=e[13]:(v=(0,$.jsx)(eo,{threadId:_}),e[12]=_,e[13]=v);let y;e[14]!==g||e[15]!==v?(y=(0,$.jsxs)(`div`,{className:`relative mx-auto min-w-[400px] w-[90vw] max-w-3xl`,children:[g,v]}),e[14]=g,e[15]=v,e[16]=y):y=e[16];let b;return e[17]!==m||e[18]!==y?(b=(0,$.jsxs)($.Fragment,{children:[m,y]}),e[17]=m,e[18]=y,e[19]=b):b=e[19],b}async function io(e){return je(`api/projects/${Dn(e)}/todos`)}async function ao(e,t){return Ne(`api/projects/${Dn(e)}/todos`,{description:t})}async function oo(e,t,n){return Cn(`api/projects/${Dn(e)}/todos/${Dn(t)}`,n)}async function so(e,t){await ot(`api/projects/${Dn(e)}/todos/${Dn(t)}`)}var co={Ready:[{label:`Plan`,target:`Plan`},{label:`Build`,target:`Build`}],Plan:[{label:`Build`,target:`Build`}],Build:[{label:`Test`,target:`Test`},{label:`Review`,target:`Review`}],Test:[{label:`Review`,target:`Review`}],Review:[{label:`Done`,target:`Done`}],Done:[]};function lo({todo:e,projectId:t,onUpdate:n,onEdit:r,onAction:i,onThreadSelect:a}){let[o,s]=(0,Z.useState)(!1),c=co[e.status]??[];function l(t){t.stopPropagation(),e.threadId&&a&&a(e.threadId)}async function u(r,a){r.stopPropagation(),s(!0);try{i?await i(e,a):n(await oo(t,e.id,{status:a,working:a!==`Done`}))}finally{s(!1)}}return(0,$.jsxs)(`div`,{className:N(`rounded-lg border bg-card p-3 shadow-sm space-y-2 cursor-pointer hover:bg-accent/50 transition-colors`,e.working&&`border-primary/50 bg-primary/5`),onClick:t=>{t.stopPropagation(),r(e)},children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium leading-tight`,children:e.title}),e.working&&(0,$.jsx)(Et,{className:`h-3 w-3 animate-spin text-primary shrink-0`})]}),(c.length>0||e.status!==`Ready`&&e.threadId&&a)&&(0,$.jsxs)(`div`,{className:`flex gap-1.5 flex-wrap items-center pt-1`,children:[c.map(t=>(0,$.jsxs)(Jr,{children:[(0,$.jsx)(Yr,{asChild:!0,children:(0,$.jsx)(q,{size:`sm`,variant:`outline`,className:`h-6 px-2 text-xs`,onClick:e=>void u(e,t.target),disabled:o||e.working,children:t.label})}),(0,$.jsx)(Kr,{side:`top`,children:e.status===`Ready`&&t.target===`Build`?`Implement this on a new branch of the project`:t.target===`Review`?`Review the code changes for this task`:t.target===`Done`?`Mark the task as done`:t.label})]},t.target)),e.status!==`Ready`&&e.threadId&&a&&(0,$.jsxs)(Jr,{children:[(0,$.jsx)(Yr,{asChild:!0,children:(0,$.jsxs)(q,{size:`icon`,variant:`ghost`,className:`h-7 w-7 shrink-0 group-hover:flex items-center justify-center`,onClick:l,children:[(0,$.jsx)(I,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Open thread`})]})}),(0,$.jsx)(Kr,{side:`right`,children:`Open thread`})]})]})]})}var uo=`Please analyze this task and create a detailed implementation plan.
47
+
48
+ Task description:
49
+ {description}`,fo="\nWrite your complete plan to the file `{todoId}-plan.md` in the current directory.",po=`Act as a Quality Assurance Manager. Rephrase the task into a rigorous test case: {description}`,mo=`Code review: The systematic examination of code to find mistakes, ensure it follows best practices, and identify areas for improvement
50
+ Directions:
51
+ Carefully read through the list of code changes creating a todo list of code to review.
52
+ Analyze the code structure, variable names, functions, and logic flow
53
+ Look for any syntax errors, bugs, or inefficiencies
54
+ Consider best practices for the specific programming language used
55
+ Provide clear and constructive feedback on areas that could be improved
56
+ If applicable, include examples of how to refactor problematic code
57
+ Offer praise for portions of the code that are well-written and follow best practices
58
+
59
+ Task description:
60
+ {description}`,ho={plan:uo,test:po,review:mo},go={plan:`planPrompt`,test:`testPrompt`,review:`reviewPrompt`};function _o(e,t){let n=e?.[go[t]];return n&&n.trim()?n:ho[t]}function vo(e,t,n,r){let i=e.replace(/\{description\}/g,r);return t===`plan`&&(i+=fo.replace(/\{todoId\}/g,n)),i}var yo=[`Ready`,`Plan`,`Build`,`Test`,`Review`,`Done`],bo={Ready:`border-t-slate-400`,Plan:`border-t-blue-400`,Build:`border-t-orange-400`,Test:`border-t-yellow-400`,Review:`border-t-purple-400`,Done:`border-t-green-400`};async function xo(e,t){let n=e.getReader(),r=new TextDecoder,i=``,a=null;try{for(;;){let{done:e,value:o}=await n.read();if(e)break;i+=r.decode(o,{stream:!0});let s=i.split(`
61
+ `);i=s.pop()??``;for(let e of s){let n=e.trim();if(n)try{let e=JSON.parse(n);e.type===`progress`&&typeof e.threadId==`string`&&!a&&(a=e.threadId,t(a))}catch{}}}}catch{}return a}async function So(e){let t=e.getReader();try{for(;;){let{done:e}=await t.read();if(e)break}}catch{}}async function Co(e){let t=e.getReader(),n=new TextDecoder,r=``,i=``;try{for(;;){let{done:e,value:a}=await t.read();if(e)break;r+=n.decode(a,{stream:!0});let o=r.split(`
62
+ `);r=o.pop()??``;for(let e of o){let t=e.trim();if(t)try{let e=JSON.parse(t);e.type===`token`&&e.content?i+=e.content:e.type===`result`&&e.content&&(i=e.content)}catch{}}}}catch{}return i}function wo({projectId:e,addOpen:t,onAddOpenChange:n,onThreadSelect:r}){let{state:i,dispatch:a}=Nr(),[o,s]=(0,Z.useState)([]),[c,l]=(0,Z.useState)(!0),[d,f]=(0,Z.useState)(null),[p,m]=(0,Z.useState)(``),[h,g]=(0,Z.useState)(!1),[v,y]=(0,Z.useState)(!1),[b,x]=(0,Z.useState)(null),[S,C]=(0,Z.useState)(``),[w,T]=(0,Z.useState)(!1),[E,D]=(0,Z.useState)(!1),O=(0,Z.useCallback)(async()=>{try{let t=await io(e),n=t.filter(e=>e.threadId&&e.status!==`Done`),r=[...t];await Promise.all(n.map(async t=>{try{await Fe(t.threadId)}catch(n){if(n instanceof Error&&n.message.includes(`not found`)){let n=await oo(e,t.id,{status:`Done`}),i=r.findIndex(e=>e.id===t.id);i!==-1&&(r[i]=n);return}}})),s(r)}catch(e){console.error(`Failed to fetch project todos:`,e)}finally{l(!1)}},[e]);(0,Z.useEffect)(()=>{O()},[O]),(0,Z.useEffect)(()=>{if(!o.some(e=>e.working))return;let t=setInterval(async()=>{try{let n=await io(e);s(n),n.some(e=>e.working)||clearInterval(t)}catch(e){console.error(`Failed to poll project todos:`,e)}},2e3);return()=>clearInterval(t)},[o,e]),(0,Z.useEffect)(()=>{t&&m(``)},[t]);function k(e){m(e.description),f({todo:e})}function A(){f(null),m(``)}async function j(){if(p.trim()){g(!0);try{let t=await ao(e,p);s(e=>[...e,t]),n(!1),m(``)}finally{g(!1)}}}async function M(){if(!(!p.trim()||!d)){g(!0);try{let t=await oo(e,d.todo.id,{description:p});s(e=>e.map(e=>e.id===t.id?t:e)),A()}finally{g(!1)}}}async function P(){if(d){g(!0);try{await so(e,d.todo.id),s(e=>e.filter(e=>e.id!==d.todo.id)),A()}finally{g(!1)}}}function F(e){s(t=>t.map(t=>t.id===e.id?e:t))}async function I(t){let n=i.selectedThreadId?i.projectModelSelections[i.selectedThreadId]:void 0,r=i.projects.find(t=>t.projectId===e),o=r?.threads.find(e=>e.threadId===i.selectedThreadId),s=n?.id??o?.model,c=n?.provider??o?.modelProvider;if(!s||!c)throw console.error(`No model or provider found for project`,e,o),Error(`No model configuration found. Please configure a model and provider for this project first.`);let l=await jt(e);if(!l)return;let u=null,d=await xo(l,n=>{oo(e,t.id,{status:`Plan`,working:!0,threadId:n}).then(e=>{u=e,F(e)})});if(!d)return;u||F(await oo(e,t.id,{status:`Plan`,working:!0,threadId:d}));let f=n??{id:s,provider:c,name:s,description:``};a({type:Y.SetProjectModel,threadId:d,model:f}),bn(d,{model:s,modelProvider:c});let p=await At(d,vo(_o(r,`plan`),`plan`,t.id,t.description),s,[],void 0,c);p&&So(p)}async function R(t){let n=await jt(e);if(!n)return;let r=null,i=await xo(n,n=>{oo(e,t.id,{status:`Build`,working:!0,threadId:n}).then(e=>{r=e,F(e)})});if(!i)return;r||F(await oo(e,t.id,{status:`Build`,working:!0,threadId:i}));let o=await Fe(i),s=o.model,c=o.modelProvider;if(!s||!c)try{let t=(await je(`api/threads?projectId=${encodeURIComponent(e)}`)||[]).map(e=>{let t=e;return{threadId:t.threadId??t.id,model:t.model??void 0,modelProvider:t.modelProvider??void 0}}).find(e=>e.model&&e.modelProvider);t&&(s=t.model,c=t.modelProvider)}catch(e){console.error(`Failed to get project threads:`,e)}if(!s||!c)throw Error(`No model configuration found. Please configure a model and provider for this project first.`);a({type:Y.SetProjectModel,threadId:i,model:{id:s,provider:c,name:s,description:``}}),bn(i,{model:s,modelProvider:c}),console.log(`Sending chat message with provider:`,i,t.description,c);let l=await At(i,t.description,s,[],void 0,c);l&&So(l)}async function z(t){try{let n=await jt(e);if(!n){y(!1),x(null);return}let r=null;if(r=await xo(n,e=>{r=e}),!r){y(!1),x(null);return}let a=await Fe(r),o=a.model,s=a.modelProvider;if(!o||!s)try{let t=(await je(`api/threads?projectId=${encodeURIComponent(e)}`)||[]).map(e=>{let t=e;return{model:t.model??void 0,modelProvider:t.modelProvider??void 0}}).find(e=>e.model&&e.modelProvider);t&&(o=t.model,s=t.modelProvider)}catch(e){console.error(`Failed to get project threads:`,e)}if(!o||!s){Ee(e,r),y(!1),x(null);return}let c=vo(_o(i.projects.find(t=>t.projectId===e),`test`),`test`,t.id,t.description),l=await At(r,c,o,[],void 0,s);l&&C(await Co(l)),Ee(e,r)}catch(e){console.error(`Failed to generate test case:`,e),y(!1),x(null)}finally{T(!1)}}function B(e){x(e),C(``),T(!0),y(!0),z(e)}function V(){y(!1),x(null),C(``)}async function H(){if(!b||!S.trim())return;let t=b,n=S;V(),D(!0);try{let r=await jt(e);if(!r)return;let i=null,o=await xo(r,n=>{oo(e,t.id,{status:`Test`,working:!0,threadId:n}).then(e=>{i=e,F(e)})});if(!o)return;i||F(await oo(e,t.id,{status:`Test`,working:!0,threadId:o}));let s=await Fe(o),c=s.model,l=s.modelProvider;if(!c||!l)try{let t=(await je(`api/threads?projectId=${encodeURIComponent(e)}`)||[]).map(e=>{let t=e;return{model:t.model??void 0,modelProvider:t.modelProvider??void 0}}).find(e=>e.model&&e.modelProvider);t&&(c=t.model,l=t.modelProvider)}catch(e){console.error(`Failed to get project threads:`,e)}if(!c||!l)throw Error(`No model configuration found. Please configure a model and provider for this project first.`);a({type:Y.SetProjectModel,threadId:o,model:{id:c,provider:l,name:c,description:``}}),bn(o,{model:c,modelProvider:l});let u=await At(o,n,c,[],void 0,l);u&&So(u)}finally{D(!1)}}async function U(t){let n=await jt(e);if(!n)return;let r=null,o=await xo(n,n=>{oo(e,t.id,{status:`Review`,working:!0,threadId:n}).then(e=>{r=e,F(e)})});if(!o)return;r||F(await oo(e,t.id,{status:`Review`,working:!0,threadId:o}));let s=await Fe(o),c=s.model,l=s.modelProvider;if(!c||!l)try{let t=(await je(`api/threads?projectId=${encodeURIComponent(e)}`)||[]).map(e=>{let t=e;return{threadId:t.threadId??t.id,model:t.model??void 0,modelProvider:t.modelProvider??void 0}}).find(e=>e.model&&e.modelProvider);t&&(c=t.model,l=t.modelProvider)}catch(e){console.error(`Failed to get project threads:`,e)}if(!c||!l)throw Error(`No model configuration found. Please configure a model and provider for this project first.`);a({type:Y.SetProjectModel,threadId:o,model:{id:c,provider:l,name:c,description:``}}),bn(o,{model:c,modelProvider:l});let u=await At(o,vo(_o(i.projects.find(t=>t.projectId===e),`review`),`review`,t.id,t.description),c,[],void 0,l);u&&So(u)}async function W(t,n){n===`Plan`?await I(t):n===`Build`?await R(t):n===`Test`?B(t):n===`Review`?await U(t):F(await oo(e,t.id,{status:n,working:n!==`Done`}))}return c?(0,$.jsx)(`div`,{className:`flex items-center justify-center h-64`,children:(0,$.jsx)(Et,{className:`h-6 w-6 animate-spin text-muted-foreground`})}):(0,$.jsxs)(`div`,{className:`flex h-full min-h-0`,children:[(0,$.jsx)(`div`,{className:`flex gap-3 overflow-x-auto pb-8 flex-1 min-h-0`,children:yo.map(t=>{let i=o.filter(e=>e.status===t),a=t===`Ready`;return(0,$.jsxs)(`div`,{className:N(`flex flex-col rounded-lg border border-t-4 bg-muted/30 min-w-[200px] w-[200px] shrink-0`,bo[t]),children:[(0,$.jsxs)(`div`,{className:`px-3 py-2 flex items-center justify-between`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wide`,children:t}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground bg-muted rounded-full px-1.5 py-0.5`,children:i.length})]}),(0,$.jsx)(_,{className:`flex-1 px-2 pb-2`,children:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[a&&(0,$.jsxs)(q,{variant:`outline`,size:`sm`,className:`w-full h-8 border-dashed text-muted-foreground hover:text-foreground`,onClick:()=>n(!0),children:[(0,$.jsx)(Xe,{className:`h-3 w-3 mr-1`}),`Add Task`]}),i.map(t=>(0,$.jsx)(lo,{todo:t,projectId:e,onUpdate:F,onEdit:k,onAction:W,onThreadSelect:r},t.id))]})})]},t)})}),(0,$.jsx)(L,{open:t,onOpenChange:n,children:(0,$.jsxs)(K,{className:`sm:max-w-2xl`,children:[(0,$.jsx)(u,{children:(0,$.jsx)(ze,{children:`Add Task`})}),(0,$.jsxs)(`div`,{className:`py-2`,children:[(0,$.jsx)(Gr,{placeholder:`Describe what needs to be done...`,value:p,onChange:e=>m(e.target.value),rows:12,className:`resize-none text-sm`,autoFocus:!0,onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&j()}}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1.5`,children:`A title will be generated automatically from your description.`})]}),(0,$.jsx)(Pn,{children:(0,$.jsx)(q,{onClick:()=>void j(),disabled:h||!p.trim(),children:h?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Et,{className:`h-3 w-3 animate-spin mr-1`}),`Generating title...`]}):`Add`})})]})}),(0,$.jsx)(L,{open:v,onOpenChange:e=>!e&&V(),children:(0,$.jsxs)(K,{className:`sm:max-w-2xl`,children:[(0,$.jsx)(u,{children:(0,$.jsx)(ze,{children:`Test Case`})}),(0,$.jsx)(`div`,{className:`py-2`,children:w?(0,$.jsxs)(`div`,{className:`flex items-center justify-center h-32 gap-2 text-muted-foreground`,children:[(0,$.jsx)(Et,{className:`h-4 w-4 animate-spin`}),(0,$.jsx)(`span`,{className:`text-sm`,children:`Generating test case...`})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Gr,{value:S,onChange:e=>C(e.target.value),rows:12,className:`resize-none text-sm`,autoFocus:!0}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1.5`,children:`Review or edit the test case before confirming.`})]})}),(0,$.jsxs)(Pn,{children:[(0,$.jsx)(q,{variant:`outline`,onClick:V,disabled:w,children:`Cancel`}),(0,$.jsx)(q,{onClick:()=>void H(),disabled:w||!S.trim()||E,children:E?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Et,{className:`h-3 w-3 animate-spin mr-1`}),`Starting...`]}):`Confirm`})]})]})}),(0,$.jsx)(L,{open:d!==null,onOpenChange:e=>!e&&A(),children:(0,$.jsxs)(K,{className:`sm:max-w-2xl`,children:[(0,$.jsx)(u,{children:(0,$.jsx)(ze,{children:`Edit Task`})}),(0,$.jsx)(`div`,{className:`py-2`,children:(0,$.jsx)(Gr,{placeholder:`Describe what needs to be done...`,value:p,onChange:e=>m(e.target.value),rows:12,className:`resize-none text-sm`,autoFocus:!0,onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&M()}})}),(0,$.jsxs)(Pn,{className:`gap-2 sm:gap-0`,children:[(0,$.jsx)(q,{variant:`destructive`,onClick:()=>void P(),disabled:h,className:`mr-auto`,children:`Delete`}),(0,$.jsx)(q,{onClick:()=>void M(),disabled:h||!p.trim(),children:h?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Et,{className:`h-3 w-3 animate-spin mr-1`}),`Saving...`]}):`Save`})]})]})})]})}function To({projectId:e}){let{state:t,dispatch:n}=Nr(),{projects:r}=t,[i,a]=(0,Z.useState)(!1),o=hr(),{setActiveMainTab:s}=ti();async function c(i){if(r.find(t=>t.projectId===e)){o(`/`),s(`chat`);try{let{getProjects:r,invalidateProjectsCache:a}=await cr(async()=>{let{getProjects:e,invalidateProjectsCache:t}=await import(`./dialogs-config-CteuxXdD.js`).then(e=>e.b);return{getProjects:e,invalidateProjectsCache:t}},__vite__mapDeps([0,1]));a();let o=await r();n({type:Y.SetProjects,projects:o.projects});let s=o.projects.find(t=>t.projectId===e);if(s&&s.threads.find(e=>e.threadId===i)){(t.selectedThreadId!==i||t.selectedProjectId!==e)&&n({type:Y.SelectThread,threadId:i,projectId:e});try{let e=await et();n({type:Y.SetProcessingThreads,threadIds:e})}catch(e){console.error(`Failed to fetch processing threads after thread selection:`,e)}}}catch(r){console.error(`Failed to refresh projects for thread selection:`,r),(t.selectedThreadId!==i||t.selectedProjectId!==e)&&n({type:Y.SelectThread,threadId:i,projectId:e});try{let e=await et();n({type:Y.SetProcessingThreads,threadIds:e})}catch(e){console.error(`Failed to fetch processing threads after fallback thread selection:`,e)}}}}return(0,$.jsx)(`div`,{className:`flex h-full flex-col overflow-hidden`,children:(0,$.jsx)(`div`,{className:`flex-1 overflow-hidden pt-8 pl-4`,children:(0,$.jsx)(wo,{projectId:e,addOpen:i,onAddOpenChange:a,onThreadSelect:c})})})}var Eo=(0,Z.lazy)(()=>cr(()=>import(`./diff-view-B2VYMGHR.js`),__vite__mapDeps([9,1,5,6,0,7,10,8,11,12]))),Do=(0,Z.lazy)(()=>cr(()=>import(`./dialogs-config-CteuxXdD.js`).then(e=>e.t),__vite__mapDeps([0,1])));function Oo(e){let t=(0,Q.c)(48),{onCreateThread:n}=e,{state:r,dispatch:i}=Nr(),a=hr(),o=br(),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(null),{selectedThreadId:d,messages:f,isCreatingProject:p,processingThreadIds:m,projects:h,projectsLoading:g,isStreaming:_,streamingSegments:v,streamingModel:y}=r,b;t[0]!==m||t[1]!==d?(b=d&&m.includes(d),t[0]=m,t[1]=d,t[2]=b):b=t[2];let x=!!b,S;t[3]!==i||t[4]!==r.sidebarOpen?(S=()=>{r.sidebarOpen&&i({type:Y.ToggleSidebar})},t[3]=i,t[4]=r.sidebarOpen,t[5]=S):S=t[5];let C=S,w;t[6]===C?w=t[7]:(w=()=>{C(),u(`clone`),c(!0)},t[6]=C,t[7]=w);let T=w,E;t[8]===C?E=t[9]:(E=()=>{C(),u(`webapp`),c(!0)},t[8]=C,t[9]=E);let D=E,O;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(O=async(e,t)=>{try{await me(e,t),c(!1),u(null)}catch(e){console.error(`Failed to clone repository:`,e)}},t[10]=O):O=t[10];let k=O,A;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(A=async(e,t,n)=>{try{await It(e,t,n),c(!1),u(null)}catch(e){console.error(`Failed to create project:`,e)}},t[11]=A):A=t[11];let M=A,N;t[12]===C?N=t[13]:(N=async()=>{C();try{await j(),c(!1),u(null)}catch(e){console.error(`Failed to open folder:`,e)}},t[12]=C,t[13]=N);let P=N,F=o.pathname===`/review`,I=o.pathname===`/todos`,L;t[14]===a?L=t[15]:(L=()=>{a(`/`)},t[14]=a,t[15]=L);let R=L,{selectedProjectId:z}=r,B;t[16]!==C||t[17]!==i||t[18]!==T||t[19]!==R||t[20]!==D||t[21]!==P||t[22]!==p||t[23]!==x||t[24]!==_||t[25]!==f||t[26]!==n||t[27]!==h||t[28]!==g||t[29]!==F||t[30]!==z||t[31]!==d||t[32]!==y||t[33]!==v||t[34]!==I?(B=I&&z?(0,$.jsx)(To,{projectId:z}):F&&d?(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:`Loading diff view...`}),children:(0,$.jsx)(Eo,{threadId:d,onExit:R})}):(0,$.jsx)(Ta,{messages:f,isStreaming:_,streamingSegments:v,streamingModel:y,isCreatingProject:p,isProcessingThread:x,selectedThreadId:d,projects:h,projectsLoading:g,onSelectThread:(e,t)=>{C(),i({type:Y.SelectThread,projectId:e,threadId:t})},onCreateThread:n,onConnectRepo:T,onNewApp:D,onOpenFolder:P,error:null,onClearError:ko}),t[16]=C,t[17]=i,t[18]=T,t[19]=R,t[20]=D,t[21]=P,t[22]=p,t[23]=x,t[24]=_,t[25]=f,t[26]=n,t[27]=h,t[28]=g,t[29]=F,t[30]=z,t[31]=d,t[32]=y,t[33]=v,t[34]=I,t[35]=B):B=t[35];let V;t[36]!==F||t[37]!==d||t[38]!==I?(V=!F&&!I&&d&&(0,$.jsx)(ro,{}),t[36]=F,t[37]=d,t[38]=I,t[39]=V):V=t[39];let H=l??void 0,U;t[40]!==s||t[41]!==P||t[42]!==H?(U=(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Do,{open:s,onOpenChange:c,initialMode:H,onSubmitClone:k,onSubmitWebApp:M,onOpenFolder:P})}),t[40]=s,t[41]=P,t[42]=H,t[43]=U):U=t[43];let W;return t[44]!==V||t[45]!==U||t[46]!==B?(W=(0,$.jsxs)(`div`,{className:`flex h-full flex-col`,children:[B,V,U]}),t[44]=V,t[45]=U,t[46]=B,t[47]=W):W=t[47],W}function ko(){}function Ao(e){let t=(0,Q.c)(5),{children:n,className:r}=e,i;t[0]===r?i=t[1]:(i=N(`flex min-h-[71px] shrink-0 items-center gap-2 px-4 py-2`,r),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,$.jsx)(`header`,{className:i,children:n}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a}var jo=qn,Mo=sr,No=Kn,Po=Z.forwardRef((e,t)=>{let n=(0,Q.c)(14),r,i,a,o;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4]):({className:i,inset:a,children:r,...o}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let s=a&&`pl-8`,c;n[5]!==i||n[6]!==s?(c=N(`flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0`,s,i),n[5]=i,n[6]=s,n[7]=c):c=n[7];let l;n[8]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(Ke,{className:`ml-auto`}),n[8]=l):l=n[8];let u;return n[9]!==r||n[10]!==o||n[11]!==t||n[12]!==c?(u=(0,$.jsxs)(ar,{ref:t,className:c,...o,children:[r,l]}),n[9]=r,n[10]=o,n[11]=t,n[12]=c,n[13]=u):u=n[13],u});Po.displayName=ar.displayName;var Fo=Z.forwardRef((e,t)=>{let n=(0,Q.c)(9),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=N(`z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,$.jsx)(or,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});Fo.displayName=or.displayName;var Io=Z.forwardRef((e,t)=>{let n=(0,Q.c)(11),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({className:r,sideOffset:a,...i}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o=a===void 0?4:a,s;n[4]===r?s=n[5]:(s=N(`z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,r),n[4]=r,n[5]=s);let c;return n[6]!==i||n[7]!==t||n[8]!==o||n[9]!==s?(c=(0,$.jsx)(rr,{children:(0,$.jsx)(er,{ref:t,sideOffset:o,className:s,...i})}),n[6]=i,n[7]=t,n[8]=o,n[9]=s,n[10]=c):c=n[10],c});Io.displayName=er.displayName;var Lo=Z.forwardRef((e,t)=>{let n=(0,Q.c)(11),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({className:r,inset:i,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o=i&&`pl-8`,s;n[4]!==r||n[5]!==o?(s=N(`relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0`,o,r),n[4]=r,n[5]=o,n[6]=s):s=n[6];let c;return n[7]!==a||n[8]!==t||n[9]!==s?(c=(0,$.jsx)(Rn,{ref:t,className:s,...a}),n[7]=a,n[8]=t,n[9]=s,n[10]=c):c=n[10],c});Lo.displayName=Rn.displayName;var Ro=Z.forwardRef((e,t)=>{let r=(0,Q.c)(14),i,a,o,s;r[0]===e?(i=r[1],a=r[2],o=r[3],s=r[4]):({className:o,children:a,checked:i,...s}=e,r[0]=e,r[1]=i,r[2]=a,r[3]=o,r[4]=s);let c;r[5]===o?c=r[6]:(c=N(`relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,o),r[5]=o,r[6]=c);let l;r[7]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,$.jsx)(ir,{children:(0,$.jsx)(n,{className:`h-4 w-4`})})}),r[7]=l):l=r[7];let u;return r[8]!==i||r[9]!==a||r[10]!==s||r[11]!==t||r[12]!==c?(u=(0,$.jsxs)(Jn,{ref:t,className:c,checked:i,...s,children:[l,a]}),r[8]=i,r[9]=a,r[10]=s,r[11]=t,r[12]=c,r[13]=u):u=r[13],u});Ro.displayName=Jn.displayName;var zo=Z.forwardRef((e,t)=>{let n=(0,Q.c)(12),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({className:i,children:r,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o;n[4]===i?o=n[5]:(o=N(`relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,i),n[4]=i,n[5]=o);let s;n[6]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,$.jsx)(ir,{children:(0,$.jsx)(O,{className:`h-2 w-2 fill-current`})})}),n[6]=s):s=n[6];let c;return n[7]!==r||n[8]!==a||n[9]!==t||n[10]!==o?(c=(0,$.jsxs)(Un,{ref:t,className:o,...a,children:[s,r]}),n[7]=r,n[8]=a,n[9]=t,n[10]=o,n[11]=c):c=n[11],c});zo.displayName=Un.displayName;var Bo=Z.forwardRef((e,t)=>{let n=(0,Q.c)(11),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({className:r,inset:i,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o=i&&`pl-8`,s;n[4]!==r||n[5]!==o?(s=N(`px-2 py-1.5 text-sm font-semibold`,o,r),n[4]=r,n[5]=o,n[6]=s):s=n[6];let c;return n[7]!==a||n[8]!==t||n[9]!==s?(c=(0,$.jsx)(Wn,{ref:t,className:s,...a}),n[7]=a,n[8]=t,n[9]=s,n[10]=c):c=n[10],c});Bo.displayName=Wn.displayName;var Vo=Z.forwardRef((e,t)=>{let n=(0,Q.c)(9),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=N(`-mx-1 my-1 h-px bg-muted`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,$.jsx)(wr,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});Vo.displayName=wr.displayName;var Ho=e=>{let t=(0,Q.c)(8),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=N(`ml-auto text-xs tracking-widest opacity-60`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`span`,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a};Ho.displayName=`DropdownMenuShortcut`;var Uo=`VS Code`,Wo={"VS Code":`vscode`,Cursor:`cursor`,Windsurf:`windsurf`,Xcode:`xcode`,"Android Studio":`android-studio`,Kiro:`kiro`,Terminal:`terminal`};function Go({projectId:e,threadId:n,openWith:r}){let[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)([]),[c,l]=(0,Z.useState)(r??Uo),[u,d]=(0,Z.useState)(!0);(0,Z.useEffect)(()=>{(async()=>{try{let e=await t();s(e),!c&&e.length>0&&l(e[0])}catch(e){console.error(`Failed to fetch available programs:`,e),s([Uo])}finally{d(!1)}})()},[]),(0,Z.useEffect)(()=>{r&&o.includes(r)&&l(r)},[r,o,l]);let f=async t=>{try{a(!0),l(t),await Dt(e,t),n?await an(n,t):await ee(e,t),X({title:`Success`,description:`Opened project in ${t}`})}catch(e){console.error(`Failed to open project in ${t}:`,e);let n=`Failed to open project in ${t}`;if(e instanceof Error){let t=e;n=t.details?t.details:e.message}X({title:`Error`,description:n,variant:`destructive`})}finally{a(!1)}};return u?(0,$.jsx)(q,{variant:`outline`,size:`sm`,className:`h-8`,disabled:!0,children:(0,$.jsx)(`div`,{className:`h-4 w-4 animate-pulse bg-muted rounded`})}):(0,$.jsxs)(`div`,{className:`flex items-center gap-0`,children:[(0,$.jsx)(q,{variant:`outline`,size:`sm`,className:`h-8 rounded-r-none border-r-0 border-transparent`,disabled:i,onClick:async()=>{await f(c)},title:`Open in ${c}`,children:(0,$.jsx)(`img`,{src:`/ide/${Wo[c]||Wo[Uo]}.svg`,alt:c,className:`h-4 w-4`})}),(0,$.jsxs)(jo,{children:[(0,$.jsx)(Mo,{asChild:!0,children:(0,$.jsx)(q,{variant:`outline`,size:`sm`,className:`h-8 w-8 rounded-l-none px-1 border-transparent`,disabled:i,children:(0,$.jsx)(Ce,{className:`h-3.5 w-3.5`})})}),(0,$.jsx)(Io,{align:`end`,children:o.map(e=>(0,$.jsxs)(Lo,{onClick:()=>f(e),disabled:i,className:`flex items-center gap-2`,children:[(0,$.jsx)(`img`,{src:`/ide/${Wo[e]||Wo[Uo]}.svg`,alt:e,className:`h-4 w-4`}),e]},e))})]})]})}function Ko(e,t){return t?`Creating PR...`:e.status===`Behind`&&!e.hasChanges&&!e.hasUnpushedCommits?`Sync`:e.hasChanges?`Commit`:e.prExists&&e.prState===`OPEN`&&!e.hasChanges&&!e.hasUnpushedCommits?`Open PR`:e.commitsAheadOfDefault&&!e.prExists&&!e.hasChanges?`Create PR`:e.hasUnpushedCommits&&e.prExists?`Update PR`:`Commit`}function qo(e,t){return t?(0,$.jsx)(Et,{className:`h-3.5 w-3.5 animate-spin`}):e.status===`Behind`&&!e.hasChanges&&!e.hasUnpushedCommits?(0,$.jsx)(tt,{className:`h-3.5 w-3.5`}):e.hasChanges?(0,$.jsx)(Me,{className:`h-3.5 w-3.5`}):e.prExists&&e.prState===`OPEN`&&!e.hasChanges&&!e.hasUnpushedCommits?(0,$.jsx)(I,{className:`h-3.5 w-3.5`}):(0,$.jsx)(Sn,{className:`h-3.5 w-3.5`})}function Jo(e){return e.status===`Behind`&&!e.hasChanges&&!e.hasUnpushedCommits?`Your branch "${e.currentBranch}" is behind "${e.defaultBranch??`main`}". This will rebase and sync with the latest changes`:e.hasChanges?e.changedFilesCount>0?`Commit ${e.changedFilesCount} changed file${e.changedFilesCount===1?``:`s`}`:`No changes to commit`:e.prExists&&e.prState===`OPEN`&&!e.hasChanges&&!e.hasUnpushedCommits?`View pull request in GitHub`:e.commitsAheadOfDefault&&!e.prExists&&!e.hasChanges?`Create pull request for committed changes`:e.hasUnpushedCommits&&e.prExists?`Update pull request with unpushed commits`:`No actions available`}function Yo(e,t){return t?!0:e.status===`Behind`&&!e.hasChanges&&!e.hasUnpushedCommits||e.prExists&&e.prState===`OPEN`&&!e.hasChanges&&!e.hasUnpushedCommits||e.commitsAheadOfDefault&&!e.prExists&&!e.hasChanges?!1:!e.hasChanges&&!e.hasUnpushedCommits}function Xo(e){return e.hasChanges||e.status===`Behind`&&!e.hasChanges&&!e.hasUnpushedCommits||e.commitsAheadOfDefault&&!e.prExists&&!e.hasChanges}function Zo(e){let t=(0,Q.c)(102),{branchStatus:n,currentBranch:r,remoteUrl:i,hasRemoteBranch:a,hasUnpushedCommits:o,canCreateRepo:c,repoUrl:l,isRefreshing:u,isBrandState:d,gitUser:f,availableBranches:m,isLoadingBranches:h,onBranchSubMenuOpen:g,onCheckoutBranch:_,isDirectCommitMode:v,isLoading:y,isLoadingHistory:b,onFetch:S,onPull:C,onPush:w,onOpenHistory:T,onNewBranch:E,onCreatePR:D,onCreateRepo:O,onViewInGitHub:k}=e,A=`h-8 w-8 rounded-l-none px-1 border-transparent${d?` bg-brand text-brand-foreground hover:bg-brand/90 hover:text-brand-foreground`:``}`,j;t[0]===u?j=t[1]:(j=u?(0,$.jsx)(Et,{className:`h-3.5 w-3.5 animate-spin`}):(0,$.jsx)(Ce,{className:`h-3.5 w-3.5`}),t[0]=u,t[1]=j);let M;t[2]!==y||t[3]!==A||t[4]!==j?(M=(0,$.jsx)(Mo,{asChild:!0,children:(0,$.jsx)(q,{variant:`outline`,size:`sm`,className:A,disabled:y,children:j})}),t[2]=y,t[3]=A,t[4]=j,t[5]=M):M=t[5];let N;t[6]===g?N=t[7]:(N=async e=>{e&&await g()},t[6]=g,t[7]=N);let P;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,$.jsx)(x,{className:`h-3 w-3 shrink-0`}),t[8]=P):P=t[8];let F=r||`Unknown`,L;t[9]===F?L=t[10]:(L=(0,$.jsxs)(Po,{className:`gap-2 text-xs`,children:[P,(0,$.jsx)(`span`,{className:`font-medium`,children:F})]}),t[9]=F,t[10]=L);let R;t[11]!==m||t[12]!==r||t[13]!==y||t[14]!==h||t[15]!==_?(R=h?(0,$.jsxs)(`div`,{className:`px-2 py-1.5 text-xs text-muted-foreground flex items-center gap-2`,children:[(0,$.jsx)(Et,{className:`h-3 w-3 animate-spin`}),`Loading branches…`]}):m.length===0?(0,$.jsx)(`div`,{className:`px-2 py-1.5 text-xs text-muted-foreground`,children:`No branches found`}):m.map(e=>(0,$.jsxs)(Lo,{disabled:e===r||y,onClick:()=>void _(e),children:[(0,$.jsx)(x,{className:`h-3.5 w-3.5 mr-2 shrink-0`}),(0,$.jsx)(`span`,{className:e===r?`font-semibold text-foreground`:``,children:e}),e===r&&(0,$.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:`current`})]},e)),t[11]=m,t[12]=r,t[13]=y,t[14]=h,t[15]=_,t[16]=R):R=t[16];let z;t[17]===R?z=t[18]:(z=(0,$.jsx)(Fo,{children:R}),t[17]=R,t[18]=z);let B;t[19]!==N||t[20]!==L||t[21]!==z?(B=(0,$.jsxs)(No,{onOpenChange:N,children:[L,z]}),t[19]=N,t[20]=L,t[21]=z,t[22]=B):B=t[22];let V;t[23]!==n||t[24]!==i?(V=n===`Behind`&&(0,$.jsxs)(`div`,{className:`px-2 py-1 text-xs text-amber-600`,children:[`Branch is behind `,i?`origin`:`remote`]}),t[23]=n,t[24]=i,t[25]=V):V=t[25];let H;t[26]===f?H=t[27]:(H=f&&(0,$.jsxs)(`div`,{className:`px-2 py-1 text-xs text-muted-foreground`,children:[(0,$.jsx)(`span`,{className:`font-medium`,children:`User:`}),` `,f]}),t[26]=f,t[27]=H);let U;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,$.jsx)(Vo,{}),t[28]=U):U=t[28];let W;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(W=(0,$.jsx)(ne,{className:`h-3.5 w-3.5 mr-2`}),t[29]=W):W=t[29];let G;t[30]!==y||t[31]!==S?(G=(0,$.jsx)(Yr,{asChild:!0,children:(0,$.jsxs)(Lo,{onClick:S,disabled:y,children:[W,`Fetch`]})}),t[30]=y,t[31]=S,t[32]=G):G=t[32];let ee;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(ee=(0,$.jsx)(Kr,{side:`right`,children:`Download latest information from remote without merging changes`}),t[33]=ee):ee=t[33];let te;t[34]===G?te=t[35]:(te=(0,$.jsx)(qr,{children:(0,$.jsxs)(Jr,{children:[G,ee]})}),t[34]=G,t[35]=te);let K;t[36]!==a||t[37]!==y||t[38]!==C?(K=()=>{a&&!y&&C()},t[36]=a,t[37]=y,t[38]=C,t[39]=K):K=t[39];let re=!a||y?`opacity-50 cursor-not-allowed`:``,ie;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(ie=(0,$.jsx)(tt,{className:`h-3.5 w-3.5 mr-2`}),t[40]=ie):ie=t[40];let ae;t[41]!==K||t[42]!==re?(ae=(0,$.jsx)(Yr,{asChild:!0,children:(0,$.jsxs)(Lo,{onClick:K,className:re,children:[ie,`Pull`]})}),t[41]=K,t[42]=re,t[43]=ae):ae=t[43];let oe=a?`Pull latest changes from remote`:`No remote branch to pull from`,se;t[44]===oe?se=t[45]:(se=(0,$.jsx)(Kr,{side:`right`,children:oe}),t[44]=oe,t[45]=se);let ce;t[46]!==ae||t[47]!==se?(ce=(0,$.jsx)(qr,{children:(0,$.jsxs)(Jr,{children:[ae,se]})}),t[46]=ae,t[47]=se,t[48]=ce):ce=t[48];let le;t[49]!==a||t[50]!==y||t[51]!==w?(le=!a&&(0,$.jsx)(qr,{children:(0,$.jsxs)(Jr,{children:[(0,$.jsx)(Yr,{asChild:!0,children:(0,$.jsxs)(Lo,{onClick:w,disabled:y,children:[(0,$.jsx)(s,{className:`h-3.5 w-3.5 mr-2`}),`Push Branch to Remote`]})}),(0,$.jsx)(Kr,{side:`right`,children:`Create remote branch and push local commits`})]})}),t[49]=a,t[50]=y,t[51]=w,t[52]=le):le=t[52];let ue;t[53]!==o||t[54]!==y||t[55]!==w?(ue=()=>{o&&!y&&w()},t[53]=o,t[54]=y,t[55]=w,t[56]=ue):ue=t[56];let de=!o||y?`opacity-50 cursor-not-allowed`:``,fe;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(fe=(0,$.jsx)(s,{className:`h-3.5 w-3.5 mr-2`}),t[57]=fe):fe=t[57];let pe;t[58]!==ue||t[59]!==de?(pe=(0,$.jsx)(Yr,{asChild:!0,children:(0,$.jsxs)(Lo,{onClick:ue,className:de,children:[fe,`Push Commits`]})}),t[58]=ue,t[59]=de,t[60]=pe):pe=t[60];let me=o?y?`Push in progress...`:`Push your uncommitted commits to the remote branch`:`No commits to push - your branch is up to date with remote`,he;t[61]===me?he=t[62]:(he=(0,$.jsx)(Kr,{side:`right`,children:me}),t[61]=me,t[62]=he);let ge;t[63]!==pe||t[64]!==he?(ge=(0,$.jsx)(qr,{children:(0,$.jsxs)(Jr,{children:[pe,he]})}),t[63]=pe,t[64]=he,t[65]=ge):ge=t[65];let J=y||b,_e;t[66]===Symbol.for(`react.memo_cache_sentinel`)?(_e=(0,$.jsx)(En,{className:`h-3.5 w-3.5 mr-2`}),t[66]=_e):_e=t[66];let ve;t[67]!==T||t[68]!==J?(ve=(0,$.jsxs)(Lo,{onClick:T,disabled:J,children:[_e,`History`]}),t[67]=T,t[68]=J,t[69]=ve):ve=t[69];let ye;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(ye=(0,$.jsx)(x,{className:`h-3.5 w-3.5 mr-2`}),t[70]=ye):ye=t[70];let be;t[71]!==y||t[72]!==E?(be=(0,$.jsxs)(Lo,{onClick:E,disabled:y,children:[ye,`New Branch`]}),t[71]=y,t[72]=E,t[73]=be):be=t[73];let xe;t[74]!==v||t[75]!==y||t[76]!==D?(xe=!v&&(0,$.jsxs)(Lo,{onClick:D,disabled:y,children:[(0,$.jsx)(Sn,{className:`h-3.5 w-3.5 mr-2`}),`Create Pull Request`]}),t[74]=v,t[75]=y,t[76]=D,t[77]=xe):xe=t[77];let Se;t[78]!==c||t[79]!==y||t[80]!==O?(Se=c&&(0,$.jsxs)(Lo,{onClick:O,disabled:y,children:[(0,$.jsx)(p,{className:`h-3.5 w-3.5 mr-2`}),`Create Repo`]}),t[78]=c,t[79]=y,t[80]=O,t[81]=Se):Se=t[81];let we;t[82]!==y||t[83]!==k||t[84]!==l?(we=l&&(0,$.jsxs)(Lo,{onClick:k,disabled:y,children:[(0,$.jsx)(I,{className:`h-3.5 w-3.5 mr-2`}),`View in GitHub`]}),t[82]=y,t[83]=k,t[84]=l,t[85]=we):we=t[85];let Te;t[86]!==B||t[87]!==V||t[88]!==H||t[89]!==te||t[90]!==ce||t[91]!==le||t[92]!==ge||t[93]!==ve||t[94]!==be||t[95]!==xe||t[96]!==Se||t[97]!==we?(Te=(0,$.jsxs)(Io,{align:`end`,children:[B,V,H,U,te,ce,le,ge,ve,be,xe,Se,we]}),t[86]=B,t[87]=V,t[88]=H,t[89]=te,t[90]=ce,t[91]=le,t[92]=ge,t[93]=ve,t[94]=be,t[95]=xe,t[96]=Se,t[97]=we,t[98]=Te):Te=t[98];let Ee;return t[99]!==M||t[100]!==Te?(Ee=(0,$.jsxs)(jo,{children:[M,Te]}),t[99]=M,t[100]=Te,t[101]=Ee):Ee=t[101],Ee}function Qo(){return{autoGenerateCommitMessage:vt(),autoGeneratePRInfo:Qt(),privateRepositoryDefault:Tt()}}function $o(e){e.autoGenerateCommitMessage!==void 0&&xt(e.autoGenerateCommitMessage),e.autoGeneratePRInfo!==void 0&&Qe(e.autoGeneratePRInfo),e.privateRepositoryDefault!==void 0&&yn(e.privateRepositoryDefault)}function es(e){return e?!0:(X({title:`Error`,description:`No thread selected`,variant:`destructive`}),!1)}function ts(e){let t=(0,Q.c)(57),{open:n,onOpenChange:r,commitMessage:i,onCommitMessageChange:a,autoGenerateCommitMessage:s,onAutoGenerateChange:c,isGeneratingMessage:l,isLoading:d,onGenerateMessage:f,onCommit:p,currentBranch:m}=e,h;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(ze,{children:`Commit Changes`}),t[0]=h):h=t[0];let g;t[1]===m?g=t[2]:(g=(0,$.jsxs)(u,{children:[h,(0,$.jsxs)(De,{children:[`Enter a commit message for your changes on branch `,m]})]}),t[1]=m,t[2]=g);let _;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(o,{htmlFor:`commit-message`,children:`Commit Message`}),t[3]=_):_=t[3];let v;t[4]===a?v=t[5]:(v=e=>a(e.target.value),t[4]=a,t[5]=v);let y;t[6]!==i||t[7]!==v?(y=(0,$.jsx)(Gr,{id:`commit-message`,placeholder:`Enter commit message...`,value:i,onChange:v,rows:4,className:`pr-10`}),t[6]=i,t[7]=v,t[8]=y):y=t[8];let b=l||d,x;t[9]===l?x=t[10]:(x=l?(0,$.jsx)(Et,{className:`h-3.5 w-3.5 animate-spin`}):(0,$.jsx)(Be,{className:`h-3.5 w-3.5`}),t[9]=l,t[10]=x);let S;t[11]!==f||t[12]!==b||t[13]!==x?(S=(0,$.jsx)(Yr,{asChild:!0,children:(0,$.jsx)(q,{type:`button`,variant:`ghost`,size:`icon`,className:`absolute top-2 right-2 h-6 w-6`,onClick:f,disabled:b,children:x})}),t[11]=f,t[12]=b,t[13]=x,t[14]=S):S=t[14];let C=l?`Generating commit message...`:`Generate commit message with AI`,w;t[15]===C?w=t[16]:(w=(0,$.jsx)(Kr,{children:C}),t[15]=C,t[16]=w);let T;t[17]!==w||t[18]!==S?(T=(0,$.jsx)(qr,{children:(0,$.jsxs)(Jr,{children:[S,w]})}),t[17]=w,t[18]=S,t[19]=T):T=t[19];let E;t[20]!==T||t[21]!==y?(E=(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[_,(0,$.jsxs)(`div`,{className:`relative`,children:[y,T]})]}),t[20]=T,t[21]=y,t[22]=E):E=t[22];let D;t[23]===c?D=t[24]:(D=e=>c(e===!0),t[23]=c,t[24]=D);let O;t[25]!==s||t[26]!==D?(O=(0,$.jsx)($r,{id:`auto-generate`,checked:s,onCheckedChange:D}),t[25]=s,t[26]=D,t[27]=O):O=t[27];let k;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,$.jsx)(o,{htmlFor:`auto-generate`,className:`text-sm font-normal`,children:`Auto generate commit messages`}),t[28]=k):k=t[28];let A;t[29]===O?A=t[30]:(A=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[O,k]}),t[29]=O,t[30]=A);let j;t[31]!==E||t[32]!==A?(j=(0,$.jsxs)(`div`,{className:`grid gap-4 py-4`,children:[E,A]}),t[31]=E,t[32]=A,t[33]=j):j=t[33];let M;t[34]===r?M=t[35]:(M=()=>r(!1),t[34]=r,t[35]=M);let N;t[36]!==d||t[37]!==M?(N=(0,$.jsx)(q,{variant:`outline`,onClick:M,disabled:d,children:`Cancel`}),t[36]=d,t[37]=M,t[38]=N):N=t[38];let P;t[39]!==i||t[40]!==d?(P=d||!i.trim(),t[39]=i,t[40]=d,t[41]=P):P=t[41];let F=d?`Committing...`:`Commit`,I;t[42]!==p||t[43]!==P||t[44]!==F?(I=(0,$.jsx)(q,{onClick:p,disabled:P,children:F}),t[42]=p,t[43]=P,t[44]=F,t[45]=I):I=t[45];let R;t[46]!==N||t[47]!==I?(R=(0,$.jsxs)(Pn,{children:[N,I]}),t[46]=N,t[47]=I,t[48]=R):R=t[48];let z;t[49]!==j||t[50]!==g||t[51]!==R?(z=(0,$.jsxs)(K,{children:[g,j,R]}),t[49]=j,t[50]=g,t[51]=R,t[52]=z):z=t[52];let B;return t[53]!==r||t[54]!==n||t[55]!==z?(B=(0,$.jsx)(L,{open:n,onOpenChange:r,children:z}),t[53]=r,t[54]=n,t[55]=z,t[56]=B):B=t[56],B}function ns(e){let t=(0,Q.c)(62),{open:n,onOpenChange:r,prTitle:i,onPrTitleChange:a,prDescription:s,onPrDescriptionChange:c,isGeneratingPRInfo:l,isLoading:d,onGeneratePRInfo:f,onCreatePR:p,currentBranch:m,autoGeneratePRInfo:h,onAutoGeneratePRInfoChange:g}=e,_;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(ze,{children:`Create Pull Request`}),t[0]=_):_=t[0];let v;t[1]===m?v=t[2]:(v=(0,$.jsxs)(u,{children:[_,(0,$.jsxs)(De,{children:[`Create a pull request for branch `,m]})]}),t[1]=m,t[2]=v);let y;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(o,{htmlFor:`pr-title`,children:`Title (optional)`}),t[3]=y):y=t[3];let b=m||`Enter PR title...`,x;t[4]===a?x=t[5]:(x=e=>a(e.target.value),t[4]=a,t[5]=x);let S;t[6]!==i||t[7]!==b||t[8]!==x?(S=(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[y,(0,$.jsx)(Nt,{id:`pr-title`,placeholder:b,value:i,onChange:x})]}),t[6]=i,t[7]=b,t[8]=x,t[9]=S):S=t[9];let C;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,$.jsx)(o,{htmlFor:`pr-description`,children:`Description (optional)`}),t[10]=C):C=t[10];let w;t[11]===c?w=t[12]:(w=e=>c(e.target.value),t[11]=c,t[12]=w);let T;t[13]!==s||t[14]!==w?(T=(0,$.jsx)(Gr,{id:`pr-description`,placeholder:`Enter PR description...`,value:s,onChange:w,rows:4,className:`pr-10`}),t[13]=s,t[14]=w,t[15]=T):T=t[15];let E=l||d,D;t[16]===l?D=t[17]:(D=l?(0,$.jsx)(Et,{className:`h-3.5 w-3.5 animate-spin`}):(0,$.jsx)(Be,{className:`h-3.5 w-3.5`}),t[16]=l,t[17]=D);let O;t[18]!==f||t[19]!==E||t[20]!==D?(O=(0,$.jsx)(Yr,{asChild:!0,children:(0,$.jsx)(q,{type:`button`,variant:`ghost`,size:`icon`,className:`absolute top-2 right-2 h-6 w-6`,onClick:f,disabled:E,children:D})}),t[18]=f,t[19]=E,t[20]=D,t[21]=O):O=t[21];let k=l?`Generating PR description...`:`Generate PR title and description with AI`,A;t[22]===k?A=t[23]:(A=(0,$.jsx)(Kr,{children:k}),t[22]=k,t[23]=A);let j;t[24]!==O||t[25]!==A?(j=(0,$.jsx)(qr,{children:(0,$.jsxs)(Jr,{children:[O,A]})}),t[24]=O,t[25]=A,t[26]=j):j=t[26];let M;t[27]!==j||t[28]!==T?(M=(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[C,(0,$.jsxs)(`div`,{className:`relative`,children:[T,j]})]}),t[27]=j,t[28]=T,t[29]=M):M=t[29];let N;t[30]===g?N=t[31]:(N=e=>g(e===!0),t[30]=g,t[31]=N);let P;t[32]!==h||t[33]!==N?(P=(0,$.jsx)($r,{id:`auto-generate-pr`,checked:h,onCheckedChange:N}),t[32]=h,t[33]=N,t[34]=P):P=t[34];let F;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,$.jsx)(o,{htmlFor:`auto-generate-pr`,className:`text-sm font-normal`,children:`Auto generate PR title and description`}),t[35]=F):F=t[35];let I;t[36]===P?I=t[37]:(I=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[P,F]}),t[36]=P,t[37]=I);let R;t[38]!==M||t[39]!==I||t[40]!==S?(R=(0,$.jsxs)(`div`,{className:`grid gap-4 py-4`,children:[S,M,I]}),t[38]=M,t[39]=I,t[40]=S,t[41]=R):R=t[41];let z;t[42]===r?z=t[43]:(z=()=>r(!1),t[42]=r,t[43]=z);let B;t[44]!==d||t[45]!==z?(B=(0,$.jsx)(q,{variant:`outline`,onClick:z,disabled:d,children:`Cancel`}),t[44]=d,t[45]=z,t[46]=B):B=t[46];let V=d?`Creating...`:`Create PR`,H;t[47]!==d||t[48]!==p||t[49]!==V?(H=(0,$.jsx)(q,{onClick:p,disabled:d,children:V}),t[47]=d,t[48]=p,t[49]=V,t[50]=H):H=t[50];let U;t[51]!==B||t[52]!==H?(U=(0,$.jsxs)(Pn,{children:[B,H]}),t[51]=B,t[52]=H,t[53]=U):U=t[53];let W;t[54]!==v||t[55]!==R||t[56]!==U?(W=(0,$.jsxs)(K,{children:[v,R,U]}),t[54]=v,t[55]=R,t[56]=U,t[57]=W):W=t[57];let G;return t[58]!==r||t[59]!==n||t[60]!==W?(G=(0,$.jsx)(L,{open:n,onOpenChange:r,children:W}),t[58]=r,t[59]=n,t[60]=W,t[61]=G):G=t[61],G}function rs(e){let t=(0,Q.c)(48),{open:n,onOpenChange:r,repoName:i,onRepoNameChange:a,repoDescription:s,onRepoDescriptionChange:c,isPrivateRepo:l,onPrivateRepoChange:d,isLoading:f,onCreateRepo:p}=e,m;t[0]!==r||t[1]!==c||t[2]!==a?(m=e=>{e||(a(``),c(``)),r(e)},t[0]=r,t[1]=c,t[2]=a,t[3]=m):m=t[3];let h;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsxs)(u,{children:[(0,$.jsx)(ze,{children:`Create GitHub Repository`}),(0,$.jsx)(De,{children:`Create a new GitHub repository and push your local repository`})]}),t[4]=h):h=t[4];let g;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(o,{htmlFor:`repo-name`,children:`Repository Name (optional)`}),t[5]=g):g=t[5];let _;t[6]===a?_=t[7]:(_=e=>a(e.target.value),t[6]=a,t[7]=_);let v;t[8]!==i||t[9]!==_?(v=(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[g,(0,$.jsx)(Nt,{id:`repo-name`,placeholder:`Leave empty to use current folder name`,value:i,onChange:_})]}),t[8]=i,t[9]=_,t[10]=v):v=t[10];let y;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(o,{htmlFor:`repo-description`,children:`Description (optional)`}),t[11]=y):y=t[11];let b;t[12]===c?b=t[13]:(b=e=>c(e.target.value),t[12]=c,t[13]=b);let x;t[14]!==s||t[15]!==b?(x=(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[y,(0,$.jsx)(Gr,{id:`repo-description`,placeholder:`Enter repository description...`,value:s,onChange:b,rows:3})]}),t[14]=s,t[15]=b,t[16]=x):x=t[16];let S;t[17]===d?S=t[18]:(S=e=>d(e===!0),t[17]=d,t[18]=S);let C;t[19]!==l||t[20]!==S?(C=(0,$.jsx)($r,{id:`repo-private`,checked:l,onCheckedChange:S}),t[19]=l,t[20]=S,t[21]=C):C=t[21];let w;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(o,{htmlFor:`repo-private`,className:`text-sm font-normal`,children:`Private repository`}),t[22]=w):w=t[22];let T;t[23]===C?T=t[24]:(T=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[C,w]}),t[23]=C,t[24]=T);let E;t[25]!==T||t[26]!==v||t[27]!==x?(E=(0,$.jsxs)(`div`,{className:`grid gap-4 py-4`,children:[v,x,T]}),t[25]=T,t[26]=v,t[27]=x,t[28]=E):E=t[28];let D;t[29]===r?D=t[30]:(D=()=>r(!1),t[29]=r,t[30]=D);let O;t[31]!==f||t[32]!==D?(O=(0,$.jsx)(q,{variant:`outline`,onClick:D,disabled:f,children:`Cancel`}),t[31]=f,t[32]=D,t[33]=O):O=t[33];let k=f?`Creating...`:`Create & Push`,A;t[34]!==f||t[35]!==p||t[36]!==k?(A=(0,$.jsx)(q,{onClick:p,disabled:f,children:k}),t[34]=f,t[35]=p,t[36]=k,t[37]=A):A=t[37];let j;t[38]!==O||t[39]!==A?(j=(0,$.jsxs)(Pn,{children:[O,A]}),t[38]=O,t[39]=A,t[40]=j):j=t[40];let M;t[41]!==E||t[42]!==j?(M=(0,$.jsxs)(K,{children:[h,E,j]}),t[41]=E,t[42]=j,t[43]=M):M=t[43];let N;return t[44]!==n||t[45]!==m||t[46]!==M?(N=(0,$.jsx)(L,{open:n,onOpenChange:m,children:M}),t[44]=n,t[45]=m,t[46]=M,t[47]=N):N=t[47],N}function is(e){let t=(0,Q.c)(28),{open:n,onOpenChange:r,commits:i,displayedCommits:a,isLoadingMore:o,onScroll:s,currentBranch:c}=e,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(ze,{children:`Commit History`}),t[0]=l):l=t[0];let d;t[1]===c?d=t[2]:(d=(0,$.jsxs)(u,{children:[l,(0,$.jsxs)(De,{children:[`Recent commits on branch `,c]})]}),t[1]=c,t[2]=d);let f;t[3]===a?f=t[4]:(f=a.length>0?a.map(as):(0,$.jsx)(`p`,{className:`text-sm text-slate-500 text-center py-8`,children:`No commits found`}),t[3]=a,t[4]=f);let p;t[5]===o?p=t[6]:(p=o&&(0,$.jsx)(`div`,{className:`p-3 text-center`,children:(0,$.jsx)(Et,{className:`h-4 w-4 animate-spin inline`})}),t[5]=o,t[6]=p);let m;t[7]!==i.length||t[8]!==a.length||t[9]!==o?(m=a.length<i.length&&!o&&(0,$.jsx)(`div`,{className:`p-3 text-center text-xs text-slate-500`,children:`Scroll to load more`}),t[7]=i.length,t[8]=a.length,t[9]=o,t[10]=m):m=t[10];let h;t[11]!==f||t[12]!==p||t[13]!==m?(h=(0,$.jsxs)(`div`,{className:`divide-y`,children:[f,p,m]}),t[11]=f,t[12]=p,t[13]=m,t[14]=h):h=t[14];let g;t[15]!==s||t[16]!==h?(g=(0,$.jsx)(`div`,{className:`flex-1 overflow-y-auto border rounded-lg`,onScroll:s,children:h}),t[15]=s,t[16]=h,t[17]=g):g=t[17];let _;t[18]===r?_=t[19]:(_=(0,$.jsx)(Pn,{children:(0,$.jsx)(q,{onClick:()=>r(!1),children:`Close`})}),t[18]=r,t[19]=_);let v;t[20]!==d||t[21]!==g||t[22]!==_?(v=(0,$.jsxs)(K,{className:`max-w-2xl max-h-[80vh] flex flex-col`,children:[d,g,_]}),t[20]=d,t[21]=g,t[22]=_,t[23]=v):v=t[23];let y;return t[24]!==r||t[25]!==n||t[26]!==v?(y=(0,$.jsx)(L,{open:n,onOpenChange:r,children:v}),t[24]=r,t[25]=n,t[26]=v,t[27]=y):y=t[27],y}function as(e){return(0,$.jsxs)(`div`,{className:`p-3 hover:bg-slate-50 dark:hover:bg-slate-900 transition-colors`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium break-words`,children:e.message}),(0,$.jsxs)(`p`,{className:`text-xs text-slate-600 dark:text-slate-400 mt-1`,children:[(0,$.jsx)(`span`,{className:`font-mono`,children:e.hash.substring(0,7)}),` •`,` `,e.author,` • `,new Date(e.date).toLocaleDateString()]})]},e.hash)}function os(e){let t=(0,Q.c)(15),{open:n,onOpenChange:r,isLoading:i,onPushAndCreatePR:a,onCancel:o}=e,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsxs)(u,{children:[(0,$.jsx)(ze,{children:`Push Branch First`}),(0,$.jsx)(De,{children:`Your branch needs to be pushed to the remote before creating a pull request. Would you like to push it now?`})]}),t[0]=s):s=t[0];let c;t[1]!==i||t[2]!==o?(c=(0,$.jsx)(q,{variant:`outline`,onClick:o,disabled:i,children:`Cancel`}),t[1]=i,t[2]=o,t[3]=c):c=t[3];let l=i?`Pushing...`:`Push & Create PR`,d;t[4]!==i||t[5]!==a||t[6]!==l?(d=(0,$.jsx)(q,{onClick:a,disabled:i,children:l}),t[4]=i,t[5]=a,t[6]=l,t[7]=d):d=t[7];let f;t[8]!==c||t[9]!==d?(f=(0,$.jsxs)(K,{children:[s,(0,$.jsxs)(Pn,{children:[c,d]})]}),t[8]=c,t[9]=d,t[10]=f):f=t[10];let p;return t[11]!==r||t[12]!==n||t[13]!==f?(p=(0,$.jsx)(L,{open:n,onOpenChange:r,children:f}),t[11]=r,t[12]=n,t[13]=f,t[14]=p):p=t[14],p}function ss(e){let t=(0,Q.c)(27),{open:n,onOpenChange:r,onCommitFirst:i,onStashAndPull:a,onCancel:o,isLoading:s}=e,c=s===void 0?!1:s,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsxs)(u,{children:[(0,$.jsxs)(ze,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Pt,{className:`h-5 w-5 text-amber-500`}),`Uncommitted Changes Detected`]}),(0,$.jsx)(De,{children:`You have uncommitted changes. You need to handle them before pulling from the remote branch.`})]}),t[0]=l):l=t[0];let d;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`Choose how you want to proceed:`}),t[1]=d):d=t[1];let f;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(Me,{className:`h-4 w-4 mr-2`}),t[2]=f):f=t[2];let p;t[3]!==c||t[4]!==i?(p=(0,$.jsxs)(q,{onClick:i,disabled:c,className:`w-full justify-start`,variant:`outline`,children:[f,`Commit changes first, then pull`]}),t[3]=c,t[4]=i,t[5]=p):p=t[5];let m;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(nt,{className:`h-4 w-4 mr-2`}),t[6]=m):m=t[6];let h;t[7]!==c||t[8]!==a?(h=(0,$.jsxs)(q,{onClick:a,disabled:c,className:`w-full justify-start`,variant:`outline`,children:[m,`Stash changes → Pull → Restore changes`]}),t[7]=c,t[8]=a,t[9]=h):h=t[9];let g;t[10]!==p||t[11]!==h?(g=(0,$.jsxs)(`div`,{className:`space-y-2`,children:[p,h]}),t[10]=p,t[11]=h,t[12]=g):g=t[12];let _;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(`strong`,{children:`Commit first:`}),t[13]=_):_=t[13];let v;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsxs)(`div`,{className:`text-xs text-muted-foreground mt-4`,children:[_,` Safe option, preserves changes in your commit history`,(0,$.jsx)(`br`,{}),(0,$.jsx)(`strong`,{children:`Stash and pull:`}),` Temporary option, changes will be restored after pulling`]}),t[14]=v):v=t[14];let y;t[15]===g?y=t[16]:(y=(0,$.jsx)(`div`,{className:`py-4`,children:(0,$.jsxs)(`div`,{className:`space-y-3`,children:[d,g,v]})}),t[15]=g,t[16]=y);let b;t[17]!==c||t[18]!==o?(b=(0,$.jsx)(Pn,{children:(0,$.jsx)(q,{variant:`ghost`,onClick:o,disabled:c,children:`Cancel`})}),t[17]=c,t[18]=o,t[19]=b):b=t[19];let x;t[20]!==y||t[21]!==b?(x=(0,$.jsxs)(K,{className:`sm:max-w-[425px]`,children:[l,y,b]}),t[20]=y,t[21]=b,t[22]=x):x=t[22];let S;return t[23]!==r||t[24]!==n||t[25]!==x?(S=(0,$.jsx)(L,{open:n,onOpenChange:r,children:x}),t[23]=r,t[24]=n,t[25]=x,t[26]=S):S=t[26],S}function cs(e){let t=(0,Q.c)(19),{open:n,onOpenChange:r,onNewBranch:i,onJustOpen:a,isLoading:o,defaultBranch:s}=e,c=o===void 0?!1:o,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(ze,{children:`Pull Request Merged`}),t[0]=l):l=t[0];let d=s?` from ${s}`:``,f;t[1]===d?f=t[2]:(f=(0,$.jsxs)(u,{children:[l,(0,$.jsxs)(De,{children:[`As the pull request has been merged a new branch will be created`,d,`.`]})]}),t[1]=d,t[2]=f);let p;t[3]!==c||t[4]!==a?(p=(0,$.jsx)(q,{variant:`ghost`,onClick:a,disabled:c,children:`Just Open`}),t[3]=c,t[4]=a,t[5]=p):p=t[5];let m;t[6]!==c||t[7]!==i?(m=(0,$.jsx)(q,{onClick:i,disabled:c,children:`New Branch`}),t[6]=c,t[7]=i,t[8]=m):m=t[8];let h;t[9]!==p||t[10]!==m?(h=(0,$.jsxs)(Pn,{children:[p,m]}),t[9]=p,t[10]=m,t[11]=h):h=t[11];let g;t[12]!==f||t[13]!==h?(g=(0,$.jsxs)(K,{children:[f,h]}),t[12]=f,t[13]=h,t[14]=g):g=t[14];let _;return t[15]!==r||t[16]!==n||t[17]!==g?(_=(0,$.jsx)(L,{open:n,onOpenChange:r,children:g}),t[15]=r,t[16]=n,t[17]=g,t[18]=_):_=t[18],_}function ls(e){let t=(0,Q.c)(35),{open:n,onOpenChange:r,branchName:i,onBranchNameChange:a,isLoading:s,onCreateBranch:c}=e,l;t[0]!==i||t[1]!==s||t[2]!==c?(l=e=>{e.key===`Enter`&&i.trim()&&!s&&c()},t[0]=i,t[1]=s,t[2]=c,t[3]=l):l=t[3];let d=l,f;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsxs)(u,{children:[(0,$.jsx)(ze,{children:`New Branch`}),(0,$.jsx)(De,{children:`Enter a name for the new branch.`})]}),t[4]=f):f=t[4];let p;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(o,{htmlFor:`branch-name`,children:`Branch Name`}),t[5]=p):p=t[5];let m;t[6]===a?m=t[7]:(m=e=>a(e.target.value),t[6]=a,t[7]=m);let h;t[8]!==i||t[9]!==d||t[10]!==s||t[11]!==m?(h=(0,$.jsx)(`div`,{className:`grid gap-4 py-4`,children:(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[p,(0,$.jsx)(Nt,{id:`branch-name`,placeholder:`e.g. feature/my-feature`,value:i,onChange:m,onKeyDown:d,disabled:s,autoFocus:!0})]})}),t[8]=i,t[9]=d,t[10]=s,t[11]=m,t[12]=h):h=t[12];let g;t[13]===r?g=t[14]:(g=()=>r(!1),t[13]=r,t[14]=g);let _;t[15]!==s||t[16]!==g?(_=(0,$.jsx)(q,{variant:`outline`,onClick:g,disabled:s,children:`Cancel`}),t[15]=s,t[16]=g,t[17]=_):_=t[17];let v;t[18]!==i||t[19]!==s?(v=s||!i.trim(),t[18]=i,t[19]=s,t[20]=v):v=t[20];let y=s?`Creating...`:`Create Branch`,b;t[21]!==c||t[22]!==v||t[23]!==y?(b=(0,$.jsx)(q,{onClick:c,disabled:v,children:y}),t[21]=c,t[22]=v,t[23]=y,t[24]=b):b=t[24];let x;t[25]!==b||t[26]!==_?(x=(0,$.jsxs)(Pn,{children:[_,b]}),t[25]=b,t[26]=_,t[27]=x):x=t[27];let S;t[28]!==x||t[29]!==h?(S=(0,$.jsxs)(K,{children:[f,h,x]}),t[28]=x,t[29]=h,t[30]=S):S=t[30];let C;return t[31]!==r||t[32]!==n||t[33]!==S?(C=(0,$.jsx)(L,{open:n,onOpenChange:r,children:S}),t[31]=r,t[32]=n,t[33]=S,t[34]=C):C=t[34],C}var us=3e4;function ds(e){let[t,n]=(0,Z.useState)(!1),[r,i]=(0,Z.useState)(0),[a,o]=(0,Z.useState)(!1),[s,l]=(0,Z.useState)(``),[u,d]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(``),[m,h]=(0,Z.useState)(!1),[g,_]=(0,Z.useState)(void 0),[v,y]=(0,Z.useState)(!1),[b,x]=(0,Z.useState)(`Up to date`),[S,C]=(0,Z.useState)(null),[w,T]=(0,Z.useState)(!1),[E,D]=(0,Z.useState)(void 0),[O,k]=(0,Z.useState)(void 0),[A,j]=(0,Z.useState)(!1),[M,N]=(0,Z.useState)(!1),P=(0,Z.useRef)(!0),F=(0,Z.useCallback)(e=>{n(e.hasChanges),i(e.changedFilesCount),o(e.hasUnpushedCommits),l(e.currentBranch),y(e.hasRemoteBranch),d(e.isOnGitHub),p(e.remoteUrl),h(e.canCreateRepo),_(e.repoUrl),x(e.status),C(e.defaultBranch??null),T(e.prExists),D(e.prUrl),k(e.prState),j(e.commitsAheadOfDefault??!1)},[]),I=(0,Z.useCallback)(async(t=!1)=>{if(!e)return;let n=setTimeout(()=>N(!0),100);try{let n=`unified-git-status-${e}`;t&&jn.invalidate(n),F(await jn.get(n,()=>c(e,t),us))}catch(e){console.error(`Failed to fetch unified git status:`,e)}finally{clearTimeout(n),N(!1)}},[e,F]);return(0,Z.useEffect)(()=>{e&&(async()=>{if(P.current){let t=`unified-git-status-${e}`,n=jn.getSync(t);n&&F(n),P.current=!1}await I()})()},[e,I,F]),{hasChanges:t,changedFilesCount:r,hasUnpushedCommits:a,hasRemoteBranch:v,currentBranch:s,isOnGitHub:u,remoteUrl:f,canCreateRepo:m,repoUrl:g,status:b,defaultBranch:S,prExists:w,prUrl:E,prState:O,commitsAheadOfDefault:A,isRefreshing:M,fetchUnifiedStatus:I}}function fs(e){let t=e.split(`/`);return t.length>=2?{provider:t[0],model:t.slice(1).join(`/`)}:{provider:void 0,model:e}}function ps(e,t,n){let[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)(!1),s=()=>{let t=e?n[e]:void 0;return t?.id?t.provider?{provider:t.provider,model:t.id}:fs(t.id):{provider:void 0,model:void 0}};return{isGeneratingMessage:r,isGeneratingPRInfo:a,generateCommitMessageWithAI:async()=>{if(!e)return null;try{i(!0);let{provider:t,model:n}=s();return await tn(e,n,t)}catch(e){return console.error(`Failed to generate commit message:`,e),X({title:`Error`,description:e instanceof Error?e.message:`Failed to generate commit message`,variant:`destructive`}),null}finally{i(!1)}},generatePRInfoWithAI:async()=>{if(!e)return null;try{o(!0);let{provider:t,model:n}=s(),r=await qe(e,n,t);return X({title:`Success`,description:`PR title and description generated`}),r}catch(e){return console.error(`Failed to generate PR info:`,e),X({title:`Error`,description:e instanceof Error?e.message:`Failed to generate PR info`,variant:`destructive`}),null}finally{o(!1)}}}}function ms({projectId:e,threadId:t}){let{state:n,dispatch:r}=Nr(),[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(``),[h,_]=(0,Z.useState)(``),[v,y]=(0,Z.useState)(``),[b,x]=(0,Z.useState)(!1),[S,C]=(0,Z.useState)(null),w=(0,Z.useRef)(!1),T=(0,Z.useRef)(!1),[E,O]=(0,Z.useState)(!1),[k,A]=(0,Z.useState)([]),[j,M]=(0,Z.useState)(!1),[N,F]=(0,Z.useState)([]),[I,L]=(0,Z.useState)(!1),[z,B]=(0,Z.useState)(!1),[V,H]=(0,Z.useState)(``),[U,W]=(0,Z.useState)(``),[G,ee]=(0,Z.useState)(``),[te,ne]=(0,Z.useState)(!1),[K,re]=(0,Z.useState)(!1),[ae,oe]=(0,Z.useState)(!1),[se,le]=(0,Z.useState)(!1),[ue,de]=(0,Z.useState)(``),[fe,me]=(0,Z.useState)([]),[he,ge]=(0,Z.useState)(!1),J=ds(t),_e=ps(t,e,n.projectModelSelections);async function ve(){P();let e=await st();r({type:Y.SetProjects,projects:e.projects})}let[ye,be]=(0,Z.useState)(()=>Qo()),Se=n.projects.find(t=>t.projectId===e),Ce=Se?.commitMethod===Jt.Direct;(0,Z.useEffect)(()=>{function e(){document.visibilityState===`visible`&&J.fetchUnifiedStatus(!0)}return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[J.fetchUnifiedStatus]),(0,Z.useEffect)(()=>{z&&Se?.name&&!V&&H(Se.name)},[z,Se?.name,V]),(0,Z.useEffect)(()=>{$o(ye)},[ye]),(0,Z.useEffect)(()=>{let e=!0;return pn().then(t=>{e&&ee(t)}).catch(()=>{}),()=>{e=!1}},[]),(0,Z.useEffect)(()=>{if(!c){T.current=!1;return}if(c&&ye.autoGenerateCommitMessage&&!p.trim()&&t&&!T.current){T.current=!0;async function e(){let e=await _e.generateCommitMessageWithAI();e&&m(e)}e()}},[c,ye.autoGenerateCommitMessage,t,_e,p]),(0,Z.useEffect)(()=>{if(!u){w.current=!1;return}if(console.log(`[pr-auto-gen] useEffect triggered`,{isPRDialogOpen:u,autoGeneratePRInfo:ye.autoGeneratePRInfo,prTitleEmpty:!h.trim(),prDescriptionEmpty:!v.trim(),threadId:t,hasThreadId:!!t,generationAlreadyStarted:w.current}),u&&ye.autoGeneratePRInfo&&!h.trim()&&!v.trim()&&t&&!w.current){console.log(`[pr-auto-gen] Starting auto-generation...`),w.current=!0;async function e(){let e=await _e.generatePRInfoWithAI();e&&(console.log(`[pr-auto-gen] Setting PR info:`,e.title.substring(0,50)),_(e.title),y(e.description))}e()}else console.log(`[pr-auto-gen] Skipping auto-generation - conditions not met`)},[u,ye.autoGeneratePRInfo,t,_e,h,v]),(0,Z.useEffect)(()=>{console.log(`Unified status changed:`,{prExists:J.prExists,prState:J.prState,threadId:t}),J.prExists&&J.prState===`MERGED`&&(console.log(`Merged PR detected, opening dialog`),oe(!0))},[J.prExists,J.prState,t]),(0,Z.useEffect)(()=>{!n.isStreaming&&n.completedThreadIds.includes(n.selectedThreadId??``)&&(J.fetchUnifiedStatus(!0),r({type:Y.ClearThreadCompleted,threadId:n.selectedThreadId??``}))},[n.isStreaming,n.completedThreadIds,n.selectedThreadId,J,r]);async function we(){if(p.trim()&&es(t))try{a(!0),await ce(t,p),m(``),l(!1),await J.fetchUnifiedStatus(!0),ve(),X({title:`Changes committed successfully`,description:`Your changes have been committed to '${J.currentBranch}'.`}),K&&(re(!1),await je())}catch(e){console.error(`Failed to commit:`,e),X({title:`Commit failed`,description:e instanceof Error?e.message:`Failed to commit changes`,variant:`destructive`})}finally{a(!1)}}async function Te(){if(J.status===`Behind`&&!J.hasChanges&&!J.hasUnpushedCommits){await Ie();return}if(J.hasChanges){l(!0);return}if(J.prExists&&J.prState===`OPEN`&&!J.hasChanges&&!J.hasUnpushedCommits){J.prUrl&&await Ge(J.prUrl);return}if(J.commitsAheadOfDefault&&!J.prExists&&!J.hasChanges){d(!0);return}if(J.hasUnpushedCommits&&J.prExists){await ke();return}}async function Ee(){let e=await _e.generateCommitMessageWithAI();e&&m(e)}async function De(){if(es(t))try{a(!0),await D(t),await J.fetchUnifiedStatus()}catch(e){console.error(`Failed to fetch:`,e)}finally{a(!1)}}async function ke(){if(es(t))try{a(!0),await Oe(t),await J.fetchUnifiedStatus(!0),ve(),J.hasRemoteBranch?X({title:`Branch pushed successfully`,description:`Your branch '${J.currentBranch}' has been pushed to the remote.`}):X({title:`Push completed`,description:`Changes have been pushed successfully.`})}catch(e){console.error(`Failed to push:`,e),X({title:`Push failed`,description:e instanceof Error?e.message:`Failed to push to remote`,variant:`destructive`})}finally{a(!1)}}async function Ae(){if(es(t)){if(J.hasChanges){ne(!0);return}await je()}}async function je(){try{a(!0),await ie(t),await J.fetchUnifiedStatus(!0),ve(),X({title:`Pull successful`,description:`Latest changes have been pulled from remote.`})}catch(e){console.error(`Failed to pull:`,e),X({title:`Pull failed`,description:e instanceof Error?e.message:`Failed to pull from remote`,variant:`destructive`})}finally{a(!1)}}function Me(){ne(!1),re(!0),l(!0)}async function Ne(){ne(!1),await je()}async function Pe(){if(t)try{a(!0);let e=await pe(t,J.defaultBranch??void 0);P();let n=await st();r({type:Y.SetProjects,projects:n.projects}),X({title:`New branch created`,description:`Created new branch "${e.branchName}" on current thread`}),oe(!1),await J.fetchUnifiedStatus(!0),setTimeout(()=>void J.fetchUnifiedStatus(!0),1500)}catch(e){console.error(`Failed to create new branch:`,e),X({title:`Failed to create new branch`,description:e instanceof Error?e.message:`Unknown error occurred`,variant:`destructive`})}finally{a(!1)}}async function Fe(){if(!(!t||!ue.trim()))try{a(!0);let e=await pe(t,J.defaultBranch??void 0,ue.trim());P();let n=await st();r({type:Y.SetProjects,projects:n.projects}),X({title:`New branch created`,description:`Switched to branch "${e.branchName}"`}),de(``),le(!1),await J.fetchUnifiedStatus(!0),setTimeout(()=>void J.fetchUnifiedStatus(!0),1500)}catch(e){X({title:`Failed to create branch`,description:e instanceof Error?e.message:`Unknown error occurred`,variant:`destructive`})}finally{a(!1)}}async function Ie(){if(!es(t)){console.log(`[sync] Thread operation validation failed`);return}try{console.log(`[sync] Starting branch sync for thread: ${t}`),console.log(`[sync] Current branch: ${J.currentBranch}, Default branch: ${J.defaultBranch}`),a(!0),console.log(`[sync] Calling gitSyncBranch API...`);let e=await f(t);console.log(`[sync] ✓ gitSyncBranch API call successful`),console.log(`[sync] Result:`,e),console.log(`[sync] Refreshing git status...`),await J.fetchUnifiedStatus(!0),ve(),console.log(`[sync] ✓ Git status refreshed`),X({title:`Branch synced successfully`,description:`Your branch '${J.currentBranch}' has been synced with the latest changes`}),console.log(`[sync] ✓ Sync operation completed successfully`)}catch(e){console.error(`[sync] ✗ Failed to sync branch:`,e),X({title:`Sync failed`,description:e instanceof Error?e.message:`Failed to sync with default branch`,variant:`destructive`})}finally{a(!1)}}async function Le(){if(es(t))try{a(!0),s(!0);let e=await xe(t,h,v);e.prUrl&&await Ge(e.prUrl),_(``),y(``),d(!1),await J.fetchUnifiedStatus(),ve()}catch(e){console.error(`Failed to create PR:`,e);let t=e instanceof Error?e.message:`Failed to create PR`;t.includes(`push the current branch`)||t.includes(`--head flag`)?(d(!1),Be({title:h,description:v})):X({title:`Create PR Failed`,description:t,variant:`destructive`})}finally{a(!1),s(!1)}}async function Re(){if(es(t))try{a(!0);let e=await g(t,V,U,ye.privateRepositoryDefault);e.repoUrl&&setTimeout(()=>{Ge(e.repoUrl)},3e3),H(``),W(``),B(!1),await J.fetchUnifiedStatus(),ve()}catch(e){console.error(`Failed to create repo:`,e)}finally{a(!1)}}async function ze(){let e=await _e.generatePRInfoWithAI();e&&(_(e.title),y(e.description))}async function Be(e){let n=e??S;if(!(!t||!n))try{a(!0),s(!0);try{await Oe(t)}catch(e){let n=e?.message??``;if(n.includes(`non-fast-forward`)||n.includes(`Updates were rejected because the tip of your current branch is behind`)){console.log(`[push-and-pr] Non-fast-forward error detected, pulling first...`),X({title:`Syncing branch before push`,description:`Your branch is behind remote. Pulling latest changes first...`});try{await f(t),console.log(`[push-and-pr] ✓ Pull completed, retrying push...`),await Oe(t),console.log(`[push-and-pr] ✓ Push succeeded after pull`)}catch(t){throw console.error(`[push-and-pr] Pull failed:`,t),e}}else throw e}let e=await xe(t,n.title,n.description);e.prUrl&&await Ge(e.prUrl),_(``),y(``),C(null),x(!1),await J.fetchUnifiedStatus(),ve()}catch(e){console.error(`Failed to push and create PR:`,e),X({title:`Push & Create PR Failed`,description:e instanceof Error?e.message:`Failed to push and create PR`,variant:`destructive`})}finally{a(!1),s(!1)}}async function Ve(){if(es(t))try{M(!0);let e=await it(t,100);A(e),F(e.slice(0,10)),O(!0)}catch(e){console.error(`Failed to fetch git history:`,e)}finally{M(!1)}}function He(){I||(L(!0),setTimeout(()=>{let e=N.length+10;F(k.slice(0,e)),L(!1)},300))}function Ue(e){let t=e.currentTarget;t.scrollHeight-t.scrollTop-t.clientHeight<100&&N.length<k.length&&!I&&He()}let We=Xo(J);async function Ke(){if(!he){ge(!0);try{me((await R(t)).branches)}catch{me([])}finally{ge(!1)}}}async function qe(e){if(e!==J.currentBranch){a(!0);try{await Ft(t,e),await J.fetchUnifiedStatus(!0),X({title:`Switched to branch "${e}"`})}catch(e){X({title:`Failed to switch branch`,description:e instanceof Error?e.message:String(e),variant:`destructive`})}finally{a(!1)}}}function Je(){de(``),le(!0)}function Ye(){J.repoUrl&&Ge(J.repoUrl)}function Xe(){x(!1),C(null)}function Ze(){oe(!1),J.fetchUnifiedStatus(!0)}return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-0`,children:[(0,$.jsx)(qr,{children:(0,$.jsxs)(Jr,{children:[(0,$.jsx)(Yr,{asChild:!0,children:(0,$.jsxs)(q,{variant:`outline`,size:`sm`,className:`h-8 rounded-r-none border-r-0 gap-1.5 border-transparent${We?` bg-brand text-brand-foreground hover:bg-brand/90 hover:text-brand-foreground`:``}`,disabled:Yo(J,i),onClick:Te,children:[qo(J,o),Ko(J,o)]})}),(0,$.jsx)(Kr,{children:Jo(J)})]})}),(0,$.jsx)(Zo,{branchStatus:J.status,currentBranch:J.currentBranch,remoteUrl:J.remoteUrl,hasRemoteBranch:J.hasRemoteBranch,hasUnpushedCommits:J.hasUnpushedCommits,canCreateRepo:J.canCreateRepo,repoUrl:J.repoUrl,isRefreshing:J.isRefreshing,isBrandState:We,gitUser:G,availableBranches:fe,isLoadingBranches:he,onBranchSubMenuOpen:Ke,onCheckoutBranch:qe,isDirectCommitMode:Ce,isLoading:i,isLoadingHistory:j,onFetch:()=>void De(),onPull:()=>void Ae(),onPush:()=>void ke(),onOpenHistory:()=>void Ve(),onNewBranch:Je,onCreatePR:()=>d(!0),onCreateRepo:()=>B(!0),onViewInGitHub:Ye})]}),(0,$.jsx)(ts,{open:c,onOpenChange:l,commitMessage:p,onCommitMessageChange:m,autoGenerateCommitMessage:ye.autoGenerateCommitMessage,onAutoGenerateChange:e=>be(t=>({...t,autoGenerateCommitMessage:e})),isGeneratingMessage:_e.isGeneratingMessage,isLoading:i,onGenerateMessage:Ee,onCommit:we,currentBranch:J.currentBranch}),(0,$.jsx)(ns,{open:u,onOpenChange:d,prTitle:h,onPrTitleChange:_,prDescription:v,onPrDescriptionChange:y,isGeneratingPRInfo:_e.isGeneratingPRInfo,isLoading:i,onGeneratePRInfo:ze,onCreatePR:Le,currentBranch:J.currentBranch,autoGeneratePRInfo:ye.autoGeneratePRInfo,onAutoGeneratePRInfoChange:e=>be(t=>({...t,autoGeneratePRInfo:e}))}),(0,$.jsx)(os,{open:b,onOpenChange:x,isLoading:i,onPushAndCreatePR:Be,onCancel:Xe}),(0,$.jsx)(rs,{open:z,onOpenChange:B,repoName:V,onRepoNameChange:H,repoDescription:U,onRepoDescriptionChange:W,isPrivateRepo:ye.privateRepositoryDefault,onPrivateRepoChange:e=>be(t=>({...t,privateRepositoryDefault:e})),isLoading:i,onCreateRepo:Re}),(0,$.jsx)(is,{open:E,onOpenChange:O,commits:k,displayedCommits:N,isLoadingMore:I,onScroll:Ue,currentBranch:J.currentBranch}),(0,$.jsx)(ss,{open:te,onOpenChange:ne,onCommitFirst:Me,onStashAndPull:Ne,onCancel:()=>ne(!1),isLoading:i}),(0,$.jsx)(cs,{open:ae,onOpenChange:oe,onNewBranch:Pe,onJustOpen:Ze,isLoading:i,defaultBranch:J.defaultBranch??void 0}),(0,$.jsx)(ls,{open:se,onOpenChange:le,branchName:ue,onBranchNameChange:de,isLoading:i,onCreateBranch:Fe})]})}var hs=`Play.Square.RotateCcw.Terminal.Bug.TestTube.FlaskConical.Wrench.Hammer.Zap.Search.FileCode.Code2.History.Settings.Activity.Cpu.Server.Database.Package.Box.GitBranch.Layers.ExternalLink.Eye.Shield.Flag.Star.Monitor.Smartphone`.split(`.`);function gs({open:e,onOpenChange:t,projectId:r,commands:i,onRefresh:a}){let[s,c]=(0,Z.useState)(null),[l,d]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(!1),[m,h]=(0,Z.useState)([]),[g,_]=(0,Z.useState)(0),[y,b]=(0,Z.useState)(!1),x=(0,Z.useRef)(null),S=(0,Z.useRef)(null),C=()=>{c({id:crypto.randomUUID(),name:``,icon:`Play`,commandLine:``}),p(!1),h([])},w=e=>{c({...e}),p(!1),h([])},T=async()=>{try{b(!0);let e=await pt(r);h(e.scripts),_(0),p(e.scripts.length>0)}catch(e){console.error(`Failed to load package scripts:`,e),X({title:`Error`,description:`Failed to load package scripts`,variant:`destructive`})}finally{b(!1)}},E=e=>{c(t=>t?{...t,name:e.name,commandLine:e.commandLine,relativeFolder:e.relativePath||``}:null),p(!1),h([]),x.current?.focus()},D=e=>{f&&(e.key===`ArrowDown`?(e.preventDefault(),_(e=>e<m.length-1?e+1:e)):e.key===`ArrowUp`?(e.preventDefault(),_(e=>e>0?e-1:0)):e.key===`Enter`?(e.preventDefault(),g<m.length&&E(m[g])):e.key===`Escape`&&(e.preventDefault(),p(!1),h([])))};(0,Z.useEffect)(()=>{let e=e=>{S.current&&!S.current.contains(e.target)&&(p(!1),h([]))};return f&&document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[f]);let O=async e=>{try{await _e(r,e),X({title:`Success`,description:`Command deleted`}),a()}catch{X({title:`Error`,description:`Failed to delete command`,variant:`destructive`})}};return(0,$.jsx)(L,{open:e,onOpenChange:t,children:(0,$.jsxs)(K,{className:`sm:max-w-[500px]`,children:[(0,$.jsxs)(u,{children:[(0,$.jsx)(ze,{children:`Project Commands`}),(0,$.jsx)(De,{children:`Manage custom commands for this project.`})]}),(0,$.jsx)(`div`,{className:`py-4 flex flex-col gap-4`,children:s?(0,$.jsxs)(`div`,{className:`p-4 border rounded-lg bg-muted/30 flex flex-col gap-4 animate-in slide-in-from-top-2`,children:[(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[(0,$.jsx)(o,{htmlFor:`name`,children:`Command Name`}),(0,$.jsx)(Nt,{id:`name`,value:s.name,onChange:e=>c({...s,name:e.target.value}),placeholder:`e.g. Run Tests`,autoComplete:`off`})]}),(0,$.jsxs)(`div`,{className:`grid gap-2 relative`,children:[(0,$.jsx)(o,{htmlFor:`commandLine`,children:`Command Line`}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(Gr,{ref:x,id:`commandLine`,value:s.commandLine,onChange:e=>c({...s,commandLine:e.target.value}),onKeyDown:D,placeholder:`e.g. npm test`,className:`font-mono text-xs min-h-[100px] resize-none pr-10`}),(0,$.jsx)(qr,{children:(0,$.jsxs)(Jr,{children:[(0,$.jsx)(Yr,{asChild:!0,children:(0,$.jsx)(q,{type:`button`,variant:`ghost`,size:`icon`,className:`absolute right-2 top-2 h-6 w-6 text-muted-foreground transition-colors`,onClick:()=>void T(),disabled:y,children:(0,$.jsx)(Ce,{className:`h-4 w-4`})})}),(0,$.jsx)(Kr,{children:(0,$.jsx)(`p`,{children:`Discover package scripts`})})]})})]}),f&&(0,$.jsx)(`div`,{ref:S,className:`absolute bottom-full left-0 right-0 mb-2 max-h-60 overflow-y-auto rounded-lg border border-border bg-popover shadow-lg z-50`,children:(0,$.jsxs)(`div`,{className:`p-2`,children:[(0,$.jsxs)(`div`,{className:`px-2 py-1.5 text-xs font-semibold text-muted-foreground border-b border-border/50 mb-1 flex items-center gap-2`,children:[(0,$.jsx)(Ce,{className:`h-3 w-3`}),`Available Scripts `,y&&`(loading...)`]}),m.length>0?(()=>{let e={};m.forEach(t=>{e[t.relativePath]||(e[t.relativePath]=[]),e[t.relativePath].push(t)});let t=Object.keys(e).sort(),n=0;return t.map(t=>{let r=e[t].sort((e,t)=>e.name.localeCompare(t.name));return(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`px-3 py-1.5 text-xs font-semibold text-muted-foreground/70 bg-muted/30`,children:t}),r.map(e=>{let t=n===g;return n++,(0,$.jsxs)(`button`,{type:`button`,className:N(`flex w-full flex-col gap-1 rounded-lg mx-1 px-3 py-2 text-left transition-colors`,t?`bg-accent text-accent-foreground`:`text-popover-foreground hover:bg-accent/50`),onClick:()=>E(e),onMouseEnter:()=>_(n-1),children:[(0,$.jsx)(`span`,{className:`font-medium`,children:e.name}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground font-mono`,children:e.commandLine})]},e.commandLine)})]},t)})})():(0,$.jsx)(`div`,{className:`px-3 py-4 text-center text-xs text-muted-foreground`,children:y?`Loading scripts...`:`No package scripts found`})]})})]}),(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[(0,$.jsx)(o,{htmlFor:`relativeFolder`,children:`Relative Folder`}),(0,$.jsx)(Nt,{id:`relativeFolder`,value:s.relativeFolder??``,onChange:e=>c({...s,relativeFolder:e.target.value}),placeholder:`e.g. frontend, packages/api (optional)`,autoComplete:`off`}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Folder path relative to project root where the command will be executed. Leave empty to run from project root.`})]}),(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[(0,$.jsx)(o,{children:`Icon`}),(0,$.jsx)(`div`,{className:`grid grid-cols-10 gap-1 p-2 bg-background rounded-md border border-border`,children:hs.map(e=>{let t=Pe[e]||U;return(0,$.jsx)(q,{variant:s.icon===e?`default`:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:()=>c({...s,icon:e}),title:e,children:(0,$.jsx)(t,{className:`h-4 w-4`})},e)})})]}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2 mt-2`,children:[(0,$.jsxs)(q,{variant:`ghost`,size:`sm`,onClick:()=>c(null),children:[(0,$.jsx)(v,{className:`h-4 w-4 mr-2`}),` Cancel`]}),(0,$.jsxs)(q,{size:`sm`,onClick:async()=>{if(!s?.name||!s?.commandLine){X({title:`Error`,description:`Name and Command Line are required`,variant:`destructive`});return}try{d(!0),await Te(r,s),X({title:`Success`,description:`Command saved`}),c(null),a()}catch{X({title:`Error`,description:`Failed to save command`,variant:`destructive`})}finally{d(!1)}},disabled:l,children:[(0,$.jsx)(n,{className:`h-4 w-4 mr-2`}),` `,l?`Saving...`:`Save Command`]})]})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 max-h-[400px] overflow-y-auto pr-2`,children:[i.length===0&&(0,$.jsx)(`div`,{className:`text-center py-8 text-muted-foreground border-2 border-dashed rounded-lg`,children:`No commands defined yet.`}),i.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between p-3 rounded-md border border-border bg-card hover:bg-muted/50 cursor-pointer group transition-colors`,onClick:()=>w(e),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`div`,{className:`p-2 bg-muted rounded`,children:(0,$.jsx)(Pe[e.icon]||we,{className:`h-4 w-4`})}),(0,$.jsxs)(`div`,{className:`flex flex-col`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium`,children:e.name}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground line-clamp-1 font-mono`,children:e.commandLine})]})]}),(0,$.jsx)(`div`,{className:`flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,$.jsx)(q,{variant:`ghost`,size:`icon`,className:`h-8 w-8 text-muted-foreground hover:bg-destructive hover:text-destructive-foreground transition-colors`,onClick:t=>{t.stopPropagation(),O(e.id)},children:(0,$.jsx)(fe,{className:`h-4 w-4`})})})]},e.id))]}),(0,$.jsxs)(q,{variant:`outline`,className:`w-full border-dashed`,onClick:C,children:[(0,$.jsx)(Xe,{className:`h-4 w-4 mr-2`}),` Add New Command`]})]})})]})})}function _s(){let e=(0,Q.c)(27),{state:t}=Nr(),{selectedProjectId:n,selectedThreadId:r,projects:i}=t,{dispatch:a}=Br(r),[o,s]=(0,Z.useState)(!1),c,l,u,d,f;if(e[0]!==a||e[1]!==i||e[2]!==n||e[3]!==r||e[4]!==t.isRunningCommand){f=Symbol.for(`react.early_return_sentinel`);bb0:{let o;e[10]===n?o=e[11]:(o=e=>e.projectId===n,e[10]=n,e[11]=o),c=i.find(o)?.commands??[];let p;e[12]!==a||e[13]!==n||e[14]!==r?(p=e=>{!n||!r||a({type:Y.QueueTerminalCommand,threadId:r,command:e.commandLine,relativeFolder:e.relativeFolder})},e[12]=a,e[13]=n,e[14]=r,e[15]=p):p=e[15];let m=p,h;if(e[16]===a?h=e[17]:(h=async()=>{a({type:Y.ConfigUpdated})},e[16]=a,e[17]=h),l=h,!n){f=null;break bb0}u=`flex items-center gap-1`,d=c.length===0?(0,$.jsx)(qr,{children:(0,$.jsxs)(Jr,{children:[(0,$.jsx)(Yr,{asChild:!0,children:(0,$.jsx)(q,{variant:`action`,size:`icon-md`,onClick:()=>s(!0),children:(0,$.jsx)(We,{})})}),(0,$.jsx)(Kr,{children:`Manage commands`})]})}):(0,$.jsx)($.Fragment,{children:(0,$.jsxs)(qr,{children:[c.map(e=>{let n=Pe[e.icon]||we;return(0,$.jsxs)(Jr,{children:[(0,$.jsx)(Yr,{asChild:!0,children:(0,$.jsx)(q,{variant:`action`,size:`icon-md`,onClick:()=>m({commandLine:e.commandLine,relativeFolder:e.relativeFolder}),disabled:t.isRunningCommand,children:(0,$.jsx)(n,{})})}),(0,$.jsx)(Kr,{children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,$.jsx)(`span`,{className:`font-medium`,children:e.name}),(0,$.jsx)(`span`,{className:`text-[10px] opacity-70 font-mono whitespace-pre-wrap max-w-[300px] max-h-[100px] overflow-y-auto`,children:e.commandLine})]})})]},e.id)}),(0,$.jsxs)(Jr,{children:[(0,$.jsx)(Yr,{asChild:!0,children:(0,$.jsx)(q,{variant:`action`,size:`icon-md`,className:`ml-1`,onClick:()=>s(!0),children:(0,$.jsx)(We,{})})}),(0,$.jsx)(Kr,{children:`Manage commands`})]})]})})}e[0]=a,e[1]=i,e[2]=n,e[3]=r,e[4]=t.isRunningCommand,e[5]=c,e[6]=l,e[7]=u,e[8]=d,e[9]=f}else c=e[5],l=e[6],u=e[7],d=e[8],f=e[9];if(f!==Symbol.for(`react.early_return_sentinel`))return f;let p;e[18]!==c||e[19]!==l||e[20]!==n||e[21]!==o?(p=(0,$.jsx)(gs,{open:o,onOpenChange:s,projectId:n,commands:c,onRefresh:l}),e[18]=c,e[19]=l,e[20]=n,e[21]=o,e[22]=p):p=e[22];let m;return e[23]!==u||e[24]!==d||e[25]!==p?(m=(0,$.jsxs)(`div`,{className:u,children:[d,p]}),e[23]=u,e[24]=d,e[25]=p,e[26]=m):m=e[26],m}function vs({projectId:e,runCommand:t,large:n}){let{state:r}=Nr(),{selectedThreadId:i}=r,{dispatch:a}=Br(i),{setActiveMainTab:o,setDevServerUrl:s,devServerRunning:c,setDevServerRunning:l,devServerLoading:u,setDevServerLoading:d}=ti();(0,Z.useEffect)(()=>{(async()=>{try{l((await Re(e)).isRunning)}catch{l(!1)}})()},[e]);let f=async()=>{if(!t)return;d(!0),a({type:Y.ClearTerminalOutput}),a({type:Y.SetTerminalOpen,open:!1}),a({type:Y.AppendTerminalLine,line:{type:`system`,content:`Starting dev server: ${t}`}});let n=!1,r=setTimeout(()=>{n=!0,a({type:Y.SetTerminalOpen,open:!0})},3e3);try{console.log(`Starting dev server for project:`,e,`thread:`,i);let t=await rt(e,i??void 0);if(!t){clearTimeout(r),X({title:`Error`,description:`Failed to start dev server`,variant:`destructive`}),a({type:Y.AppendTerminalLine,line:{type:`error`,content:`Failed to start dev server`}}),d(!1);return}let c=t.getReader(),u=new TextDecoder;l(!0);let f=!1,p=!1,m=null;for(m=setTimeout(()=>{p||d(!1)},3e3);;){let{done:e,value:t}=await c.read();if(e)break;let i=u.decode(t,{stream:!0});try{let e=i.split(`
63
+ `).filter(e=>e.trim());for(let t of e)try{let e=JSON.parse(t);p||(p=!0,d(!1),m&&clearTimeout(m)),(e.type===`stdout`||e.type===`stderr`)&&a({type:Y.AppendTerminalLine,line:{type:`output`,content:e.content}}),e.type===`url`&&e.url&&(clearTimeout(r),a({type:Y.AppendTerminalLine,line:{type:`system`,content:`✓ Server running at: ${e.url}`}}),s(e.url),o(`browser`),n&&setTimeout(()=>{a({type:Y.SetTerminalOpen,open:!1})},100),f=!0),e.type===`complete`&&e.exitCode!==0&&(clearTimeout(r),a({type:Y.SetTerminalOpen,open:!0}),o(`terminal`)),e.type===`error`&&e.content&&a({type:Y.AppendTerminalLine,line:{type:`error`,content:e.content}})}catch{i.trim()&&a({type:Y.AppendTerminalLine,line:{type:`output`,content:i}})}}catch{i.trim()&&a({type:Y.AppendTerminalLine,line:{type:`output`,content:i}})}}clearTimeout(r),m&&clearTimeout(m),d(!1),f||a({type:Y.AppendTerminalLine,line:{type:`system`,content:`Server is running but URL could not be detected`}})}catch(e){clearTimeout(r),l(!1),d(!1);let t=e instanceof Error?e.message:`Failed to start dev server`;a({type:Y.AppendTerminalLine,line:{type:`error`,content:t}}),X({title:`Error`,description:t,variant:`destructive`})}},p=async()=>{d(!0);try{await fn(e),l(!1),s(null),a({type:Y.AppendTerminalLine,line:{type:`system`,content:`Server stopped`}})}catch(e){let t=e instanceof Error?e.message:`Failed to stop dev server`;a({type:Y.AppendTerminalLine,line:{type:`error`,content:t}}),X({title:`Error`,description:t,variant:`destructive`})}finally{d(!1)}},m=!!t;return n?(0,$.jsxs)(`button`,{onClick:c?p:f,disabled:u||!c&&!m,className:`flex flex-col items-center gap-3 group disabled:opacity-40 disabled:cursor-not-allowed ${c?`text-orange-500`:`text-muted-foreground`}`,children:[u?(0,$.jsx)(Et,{className:`h-10 w-10 animate-spin`}):c?(0,$.jsx)(Fn,{className:`h-10 w-10 fill-current`}):(0,$.jsx)(we,{className:`h-10 w-10 fill-current group-hover:text-foreground transition-colors`}),(0,$.jsx)(`span`,{className:`text-sm group-hover:text-foreground transition-colors`,children:u?`Starting...`:c?`Stop dev server`:`Start dev server`})]}):(0,$.jsx)($.Fragment,{children:(0,$.jsx)(qr,{children:(0,$.jsxs)(Jr,{children:[(0,$.jsx)(Yr,{asChild:!0,children:(0,$.jsxs)(q,{variant:`ghost`,size:`icon`,className:`h-8 w-8 ${c?`text-orange-500 bg-orange-500/10`:`text-muted-foreground`}`,onClick:c?p:f,disabled:u||!c&&!m,children:[u?(0,$.jsx)(Et,{className:`h-4 w-4 animate-spin`}):c?(0,$.jsx)(Fn,{className:`h-4 w-4 fill-current`}):(0,$.jsx)(we,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`sr-only`,children:c?`Stop dev server`:`Start dev server`})]})}),(0,$.jsx)(Kr,{children:c?`Stop dev server`:m?`Start dev server: ${t}`:`Set run command in project settings`})]})})})}function ys(e){let t=(0,Q.c)(3),{children:n,className:r}=e,i=`flex items-center gap-2 rounded-full shadow-md ${r===void 0?``:r}`,a;return t[0]!==n||t[1]!==i?(a=(0,$.jsx)(`div`,{className:i,children:n}),t[0]=n,t[1]=i,t[2]=a):a=t[2],a}function bs({threadId:e}){let{dispatch:t}=Nr(),{setTerminalNotification:n}=ti(),[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)(new Set),s=(0,Z.useRef)(new Map);(0,Z.useEffect)(()=>((async()=>{try{let t=await Mn(e);if(t.length===0){i(null);return}i(t),o(new Set(t.filter(e=>e.isRunning).map(e=>e.name)))}catch{i(null)}})(),()=>{for(let e of s.current.values())e.abort();s.current.clear()}),[e]);let c=async r=>{if(a.has(r.name)){let n=s.current.get(r.name);n&&(n.abort(),s.current.delete(r.name));try{await ct(e,r.name)}catch{}t({type:Y.AppendTerminalLine,threadId:e,line:{type:`system`,content:`■ ${r.friendlyName} stopped`}}),o(e=>{let t=new Set(e);return t.delete(r.name),t})}else{let i=new AbortController;s.current.set(r.name,i),o(e=>new Set([...e,r.name])),n(!0),t({type:Y.AppendTerminalLine,threadId:e,line:{type:`system`,content:`▶ ${r.friendlyName}`}});try{let n=await Ze(e,r.name,r.command,{signal:i.signal});if(n){let r=n.getReader(),i=new TextDecoder,a=``;try{for(;;){let{done:n,value:o}=await r.read();if(n)break;a+=i.decode(o,{stream:!0});let s=a.split(`
64
+ `);a=s.pop()??``;for(let n of s)if(n.trim())try{let r=JSON.parse(n);typeof r==`string`?t({type:Y.AppendTerminalLine,threadId:e,line:{type:`output`,content:r}}):r.type===`error`&&t({type:Y.AppendTerminalLine,threadId:e,line:{type:`error`,content:r.message}})}catch{t({type:Y.AppendTerminalLine,threadId:e,line:{type:`output`,content:n}})}}if(a.trim())try{let n=JSON.parse(a);typeof n==`string`?t({type:Y.AppendTerminalLine,threadId:e,line:{type:`output`,content:n}}):n.type===`error`&&t({type:Y.AppendTerminalLine,threadId:e,line:{type:`error`,content:n.message}})}catch{t({type:Y.AppendTerminalLine,threadId:e,line:{type:`output`,content:a}})}}finally{r.releaseLock()}}t({type:Y.AppendTerminalLine,threadId:e,line:{type:`system`,content:`✓ ${r.friendlyName} done`}})}catch{}finally{s.current.delete(r.name),o(e=>{let t=new Set(e);return t.delete(r.name),t})}}};if(!r)return null;let l=r.reduce((e,t)=>(e[t.workspace]||(e[t.workspace]=[]),e[t.workspace].push(t),e),{}),u=Object.entries(l).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>[e,[...t].sort((e,t)=>e.friendlyName.localeCompare(t.friendlyName))]),d=u.length>1;return(0,$.jsxs)(jo,{children:[(0,$.jsx)(qr,{children:(0,$.jsxs)(Jr,{children:[(0,$.jsx)(Yr,{asChild:!0,children:(0,$.jsx)(Mo,{asChild:!0,children:(0,$.jsx)(q,{variant:`action`,size:`icon-md`,children:(0,$.jsx)(V,{})})})}),(0,$.jsx)(Kr,{children:`Project Scripts`})]})}),(0,$.jsx)(Io,{align:`end`,className:`min-w-[180px]`,children:d?u.map(([e,t])=>(0,$.jsxs)(No,{children:[(0,$.jsx)(Po,{children:e}),(0,$.jsx)(Fo,{className:`max-h-[min(400px,80vh)] overflow-y-auto`,children:t.map(e=>(0,$.jsxs)(Lo,{onClick:()=>{c(e)},className:`gap-2`,children:[a.has(e.name)?(0,$.jsx)(Et,{className:`h-3 w-3 animate-spin shrink-0`}):(0,$.jsx)(`div`,{className:`h-3 w-3 shrink-0`}),e.friendlyName]},e.name))})]},e)):u[0]?.[1].map(e=>(0,$.jsxs)(Lo,{onClick:()=>{c(e)},className:`gap-2`,children:[a.has(e.name)?(0,$.jsx)(Et,{className:`h-3 w-3 animate-spin shrink-0`}):(0,$.jsx)(`div`,{className:`h-3 w-3 shrink-0`}),e.friendlyName]},e.name))})]})}var xs=Z.forwardRef((e,t)=>{let n=(0,Q.c)(9),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=N(`grid gap-2`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,$.jsx)(Gn,{className:a,...i,ref:t}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});xs.displayName=Gn.displayName;var Ss=Z.forwardRef((e,t)=>{let n=(0,Q.c)(10),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=N(`aspect-square h-4 w-4 rounded-full border border-brand text-brand ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50`,r),n[3]=r,n[4]=a);let o;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(Qn,{className:`flex items-center justify-center`,children:(0,$.jsx)(O,{className:`h-2.5 w-2.5 fill-current text-current`})}),n[5]=o):o=n[5];let s;return n[6]!==i||n[7]!==t||n[8]!==a?(s=(0,$.jsx)(Hn,{ref:t,className:a,...i,children:o}),n[6]=i,n[7]=t,n[8]=a,n[9]=s):s=n[9],s});Ss.displayName=Hn.displayName;function Cs({threadId:e,onSkillCreated:t}){let[n,r]=(0,Z.useState)(``),[i,a]=(0,Z.useState)(``),[s,c]=(0,Z.useState)(`local`),[l,u]=(0,Z.useState)(!1),d=n.toLowerCase().replace(/\s+/g,`-`).replace(/[^a-z0-9-]/g,``).replace(/-+/g,`-`).replace(/^-|-$/g,``),f=d.length>0&&d.length<=64;return e?(0,$.jsxs)(`div`,{className:`max-w-2xl mx-auto p-6`,children:[(0,$.jsxs)(`div`,{className:`mb-6`,children:[(0,$.jsx)(`h1`,{className:`text-2xl font-bold`,children:`Add Skill`}),(0,$.jsx)(`p`,{className:`text-muted-foreground`,children:`Create a new agent skill. The skill will be saved as a SKILL.md file in the .agents/skills folder.`})]}),(0,$.jsxs)(`div`,{className:`space-y-6`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(o,{htmlFor:`skillName`,children:`Skill Name`}),(0,$.jsx)(Nt,{id:`skillName`,value:n,onChange:e=>r(e.target.value),placeholder:`e.g. Code Review`,disabled:l}),n&&(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Folder name: `,(0,$.jsx)(`span`,{className:`font-mono`,children:d||`...`})]})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(o,{htmlFor:`skillDescription`,children:`Description`}),(0,$.jsx)(Gr,{id:`skillDescription`,value:i,onChange:e=>a(e.target.value),placeholder:`Describe when Tarsk should apply this skill`,className:`resize-none min-h-[120px]`,disabled:l})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(o,{children:`Scope`}),(0,$.jsxs)(xs,{value:s,onValueChange:e=>c(e),className:`flex gap-4`,disabled:l,children:[(0,$.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,$.jsx)(Ss,{value:`local`,id:`scope-local`}),(0,$.jsx)(o,{htmlFor:`scope-local`,className:`font-normal cursor-pointer`,children:`Local (this project)`})]}),(0,$.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,$.jsx)(Ss,{value:`global`,id:`scope-global`,disabled:!0}),(0,$.jsx)(o,{htmlFor:`scope-global`,className:`font-normal cursor-pointer text-muted-foreground`,children:`Global (coming soon)`})]})]}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:s===`local`?`This skill will only be available for this project.`:`This skill will be available across all projects (coming soon).`})]}),(0,$.jsx)(`div`,{className:`border-t pt-4 flex justify-end`,children:(0,$.jsx)(q,{onClick:async()=>{if(!(!f||!i.trim()||!e)){u(!0);try{let n=await le(e,d,i.trim());X({title:`Skill created`,description:`Skill '${d}' was created successfully.`}),r(``),a(``),c(`local`),t?.(n.path,`SKILL.md`)}catch(e){X({title:`Error`,description:e instanceof Error?e.message:`Failed to create skill`,variant:`destructive`})}finally{u(!1)}}},disabled:!f||!i.trim()||l,children:l?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Et,{className:`mr-2 h-4 w-4 animate-spin`}),`Creating...`]}):(0,$.jsxs)($.Fragment,{children:[`Continue`,(0,$.jsx)(Ke,{className:`ml-2 h-4 w-4`})]})})})]})]}):(0,$.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,$.jsxs)(`div`,{className:`text-center`,children:[(0,$.jsx)(`h2`,{className:`text-lg font-semibold text-muted-foreground mb-2`,children:`No Thread Selected`}),(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Please select a thread to add a skill.`})]})})}var ws=Z.forwardRef((e,t)=>{let n=(0,Q.c)(10),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=N(`peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input`,r),n[3]=r,n[4]=a);let o;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(Xn,{className:N(`pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0`)}),n[5]=o):o=n[5];let s;return n[6]!==i||n[7]!==t||n[8]!==a?(s=(0,$.jsx)(Yn,{className:a,...i,ref:t,children:o}),n[6]=i,n[7]=t,n[8]=a,n[9]=s):s=n[9],s});ws.displayName=Yn.displayName;function Ts({threadId:e,onRuleCreated:t}){let[n,r]=(0,Z.useState)(``),[i,a]=(0,Z.useState)(``),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(`local`),[d,f]=(0,Z.useState)(!1),p=n.toLowerCase().replace(/\s+/g,`-`).replace(/[^a-z0-9-]/g,``).replace(/-+/g,`-`).replace(/^-|-$/g,``),m=p.length>0&&p.length<=64;return e?(0,$.jsxs)(`div`,{className:`max-w-2xl mx-auto p-6`,children:[(0,$.jsxs)(`div`,{className:`mb-6`,children:[(0,$.jsx)(`h1`,{className:`text-2xl font-bold`,children:`Add Rule`}),(0,$.jsx)(`p`,{className:`text-muted-foreground`,children:`Create a new agent rule. The rule will be saved as a .md file in the .agents/rules folder.`})]}),(0,$.jsxs)(`div`,{className:`space-y-6`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(o,{htmlFor:`ruleName`,children:`Rule Name`}),(0,$.jsx)(Nt,{id:`ruleName`,value:n,onChange:e=>r(e.target.value),placeholder:`e.g. Code Style Guide`,disabled:d}),n&&(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`File name: `,(0,$.jsxs)(`span`,{className:`font-mono`,children:[p||`...`,`.md`]})]})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(o,{htmlFor:`ruleDescription`,children:`Description`}),(0,$.jsx)(Gr,{id:`ruleDescription`,value:i,onChange:e=>a(e.target.value),placeholder:`Describe when Tarsk should apply this rule...`,className:`resize-none min-h-[120px]`,disabled:d})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(o,{htmlFor:`alwaysApply`,children:`Always Apply`}),(0,$.jsx)(ws,{id:`alwaysApply`,checked:s,onCheckedChange:c,disabled:d})]}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:s?`This rule will be automatically added to context for all conversations.`:`Only the rule description will be added to context, allowing the agent to read the rule file when needed.`})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(o,{children:`Scope`}),(0,$.jsxs)(xs,{value:l,onValueChange:e=>u(e),className:`flex gap-4`,disabled:d,children:[(0,$.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,$.jsx)(Ss,{value:`local`,id:`scope-local`}),(0,$.jsx)(o,{htmlFor:`scope-local`,className:`font-normal cursor-pointer`,children:`Local (this project)`})]}),(0,$.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,$.jsx)(Ss,{value:`global`,id:`scope-global`,disabled:!0}),(0,$.jsx)(o,{htmlFor:`scope-global`,className:`font-normal cursor-pointer text-muted-foreground`,children:`Global (coming soon)`})]})]}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:l===`local`?`This rule will only be available for this project.`:`This rule will be available across all projects (coming soon).`})]}),(0,$.jsx)(`div`,{className:`border-t pt-4 flex justify-end`,children:(0,$.jsx)(q,{onClick:async()=>{if(!(!m||!e)){f(!0);try{let n=`---
65
+ description: ${i.trim()}
66
+ alwaysApply: ${s}
67
+ ---
68
+
69
+ Place your rule instructions here as markdown.
70
+ `;await qt(e,`.agents/rules/${p}.md`,n),X({title:`Rule created`,description:`Rule '${p}' was created successfully.`}),r(``),a(``),c(!1),u(`local`),t?.(p)}catch(e){X({title:`Error`,description:e instanceof Error?e.message:`Failed to create rule`,variant:`destructive`})}finally{f(!1)}}},disabled:!m||!i.trim()||d,children:d?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Et,{className:`mr-2 h-4 w-4 animate-spin`}),`Creating...`]}):(0,$.jsxs)($.Fragment,{children:[`Continue`,(0,$.jsx)(Ke,{className:`ml-2 h-4 w-4`})]})})})]})]}):(0,$.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,$.jsxs)(`div`,{className:`text-center`,children:[(0,$.jsx)(`h2`,{className:`text-lg font-semibold text-muted-foreground mb-2`,children:`No Thread Selected`}),(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Please select a thread to add a rule.`})]})})}function Es({threadId:e,onAgentCreated:t}){let[n,r]=(0,Z.useState)(``),[i,a]=(0,Z.useState)(``),[s,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)(`local`),[d,f]=(0,Z.useState)(!1),p=n.toLowerCase().replace(/\s+/g,`-`).replace(/[^a-z0-9-]/g,``).replace(/-+/g,`-`).replace(/^-|-$/g,``),m=p.length>0&&p.length<=64;return e?(0,$.jsxs)(`div`,{className:`max-w-2xl mx-auto p-6`,children:[(0,$.jsxs)(`div`,{className:`mb-6`,children:[(0,$.jsx)(`h1`,{className:`text-2xl font-bold`,children:`Add Agent`}),(0,$.jsx)(`p`,{className:`text-muted-foreground`,children:`Create a new subagent. The agent will be saved as an AGENT.md file in the .agents/agents folder.`})]}),(0,$.jsxs)(`div`,{className:`space-y-6`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(o,{htmlFor:`agentName`,children:`Agent Name`}),(0,$.jsx)(Nt,{id:`agentName`,value:n,onChange:e=>r(e.target.value),placeholder:`e.g. Security Reviewer`,disabled:d}),n&&(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Folder name: `,(0,$.jsx)(`span`,{className:`font-mono`,children:p||`...`})]})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(o,{htmlFor:`agentDescription`,children:`Description`}),(0,$.jsx)(Gr,{id:`agentDescription`,value:i,onChange:e=>a(e.target.value),placeholder:`Describe what this agent does and when it should be invoked`,className:`resize-none min-h-[120px]`,disabled:d})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(o,{htmlFor:`agentTools`,children:`Allowed Tools (optional)`}),(0,$.jsx)(Nt,{id:`agentTools`,value:s,onChange:e=>c(e.target.value),placeholder:`e.g. read grep glob`,disabled:d}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Space-separated list of tools this agent can use. Leave empty to allow all coding tools.`})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(o,{children:`Scope`}),(0,$.jsxs)(xs,{value:l,onValueChange:e=>u(e),className:`flex gap-4`,disabled:d,children:[(0,$.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,$.jsx)(Ss,{value:`local`,id:`scope-local`}),(0,$.jsx)(o,{htmlFor:`scope-local`,className:`font-normal cursor-pointer`,children:`Local (this project)`})]}),(0,$.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,$.jsx)(Ss,{value:`global`,id:`scope-global`,disabled:!0}),(0,$.jsx)(o,{htmlFor:`scope-global`,className:`font-normal cursor-pointer text-muted-foreground`,children:`Global (coming soon)`})]})]}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:l===`local`?`This agent will only be available for this project.`:`This agent will be available across all projects (coming soon).`})]}),(0,$.jsx)(`div`,{className:`border-t pt-4 flex justify-end`,children:(0,$.jsx)(q,{onClick:async()=>{if(!(!m||!i.trim()||!e)){f(!0);try{let n=await ae(e,p,i.trim(),s.trim()||void 0);X({title:`Agent created`,description:`Agent '${p}' was created successfully.`}),r(``),a(``),c(``),u(`local`),t?.(n.path,`AGENT.md`)}catch(e){X({title:`Error`,description:e instanceof Error?e.message:`Failed to create agent`,variant:`destructive`})}finally{f(!1)}}},disabled:!m||!i.trim()||d,children:d?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Et,{className:`mr-2 h-4 w-4 animate-spin`}),`Creating...`]}):(0,$.jsxs)($.Fragment,{children:[`Continue`,(0,$.jsx)(Ke,{className:`ml-2 h-4 w-4`})]})})})]})]}):(0,$.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,$.jsxs)(`div`,{className:`text-center`,children:[(0,$.jsx)(`h2`,{className:`text-lg font-semibold text-muted-foreground mb-2`,children:`No Thread Selected`}),(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Please select a thread to add an agent.`})]})})}function Ds({projectId:e,threadId:t,onCommandCreated:n}){let[r,i]=(0,Z.useState)(``),[s,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)(``),[d,f]=(0,Z.useState)(`default`),[p,m]=(0,Z.useState)(`local`),[h,g]=(0,Z.useState)(!1),_=r.toLowerCase().replace(/\s+/g,`-`).replace(/[^a-z0-9-]/g,``).replace(/-+/g,`-`).replace(/^-|-$/g,``),v=_.length>0&&_.length<=64;return e?(0,$.jsxs)(`div`,{className:`max-w-2xl mx-auto p-6`,children:[(0,$.jsxs)(`div`,{className:`mb-6`,children:[(0,$.jsx)(`h1`,{className:`text-2xl font-bold`,children:`Add Slash Command`}),(0,$.jsx)(`p`,{className:`text-muted-foreground`,children:`Create a new slash command. The command will be saved as a .md file in the ~/.agents/commands folder.`})]}),(0,$.jsxs)(`div`,{className:`space-y-6`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(o,{htmlFor:`commandName`,children:`Command Name`}),(0,$.jsx)(Nt,{id:`commandName`,value:r,onChange:e=>i(e.target.value),placeholder:`e.g. review`,disabled:h}),r&&(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Command: `,(0,$.jsxs)(`span`,{className:`font-mono`,children:[`/`,_||`...`]})]})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(o,{htmlFor:`commandDescription`,children:`Description`}),(0,$.jsx)(Nt,{id:`commandDescription`,value:s,onChange:e=>c(e.target.value),placeholder:`Brief description shown in autocomplete`,disabled:h})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(o,{htmlFor:`argumentHint`,children:`Argument Hint (optional)`}),(0,$.jsx)(Nt,{id:`argumentHint`,value:l,onChange:e=>u(e.target.value),placeholder:`e.g. <focus-area> or <branch-name>`,disabled:h}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Shows after the command name to guide users what to type`})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(o,{children:`Mode`}),(0,$.jsxs)(xs,{value:d,onValueChange:e=>f(e),className:`flex gap-4`,disabled:h,children:[(0,$.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,$.jsx)(Ss,{value:`default`,id:`mode-default`}),(0,$.jsx)(o,{htmlFor:`mode-default`,className:`font-normal cursor-pointer`,children:`Default`})]}),(0,$.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,$.jsx)(Ss,{value:`plan`,id:`mode-plan`}),(0,$.jsx)(o,{htmlFor:`mode-plan`,className:`font-normal cursor-pointer`,children:`Plan`})]})]}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:d===`default`?`Standard chat mode`:`Activates plan mode when this command is used`})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(o,{children:`Scope`}),(0,$.jsxs)(xs,{value:p,onValueChange:e=>m(e),className:`flex gap-4`,disabled:h,children:[(0,$.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,$.jsx)(Ss,{value:`local`,id:`scope-local`}),(0,$.jsx)(o,{htmlFor:`scope-local`,className:`font-normal cursor-pointer`,children:`Local (this project)`})]}),(0,$.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,$.jsx)(Ss,{value:`global`,id:`scope-global`,disabled:!0}),(0,$.jsx)(o,{htmlFor:`scope-global`,className:`font-normal cursor-pointer text-muted-foreground`,children:`Global (coming soon)`})]})]}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:p===`local`?`This command will only be available for this project.`:`This command will be available across all projects (coming soon).`})]}),(0,$.jsx)(`div`,{className:`border-t pt-4 flex justify-end`,children:(0,$.jsx)(q,{onClick:async()=>{if(!(!v||!e)){g(!0);try{await a(_,``,{description:s.trim()||void 0,argumentHint:l.trim()||void 0,mode:d===`plan`?`plan`:void 0},p===`global`?`global`:`project`,t??void 0),X({title:`Command created`,description:`Command '/${_}' was created successfully.`}),i(``),c(``),u(``),f(`default`),m(`local`),n?.(_)}catch(e){X({title:`Error`,description:e instanceof Error?e.message:`Failed to create command`,variant:`destructive`})}finally{g(!1)}}},disabled:!v||h,children:h?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Et,{className:`mr-2 h-4 w-4 animate-spin`}),`Creating...`]}):(0,$.jsxs)($.Fragment,{children:[`Continue`,(0,$.jsx)(Ke,{className:`ml-2 h-4 w-4`})]})})})]})]}):(0,$.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,$.jsxs)(`div`,{className:`text-center`,children:[(0,$.jsx)(`h2`,{className:`text-lg font-semibold text-muted-foreground mb-2`,children:`No Project Selected`}),(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Please select a project to add a slash command.`})]})})}function Os(e){let[t,n]=(0,Z.useState)([]),[r,i]=(0,Z.useState)(!1),a=(0,Z.useCallback)(async()=>{if(e){i(!0);try{let t=await lt(e);n(Object.entries(t.servers??{}).map(([e,t])=>({name:e,config:t})))}catch{n([])}finally{i(!1)}}},[e]);return(0,Z.useEffect)(()=>{a()},[a]),{installedServers:t,loadingConfig:r,loadInstalledServers:a}}function ks(){let e=(0,Q.c)(5),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=[],e[0]=t):t=e[0];let[n,r]=(0,Z.useState)(t),i,a;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(i=()=>{en().then(r).catch(()=>r([]))},a=[],e[1]=i,e[2]=a):(i=e[1],a=e[2]),(0,Z.useEffect)(i,a);let o;return e[3]===n?o=e[4]:(o={popularServers:n},e[3]=n,e[4]=o),o}async function As(e,t,n){await gt(e,t,n)}async function js(e,t){await w(e,t)}function Ms({projectPath:e,serverName:t,onBack:n}){let{installedServers:r}=Os(e),i=!!t,[a,s]=(0,Z.useState)(``),[c,l]=(0,Z.useState)(``),[u,d]=(0,Z.useState)(``),[f,p]=(0,Z.useState)([]),[m,h]=(0,Z.useState)(!1),[g,_]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(null),[x,S]=(0,Z.useState)(i),[C,w]=(0,Z.useState)(``),[T,E]=(0,Z.useState)(``),[D,O]=(0,Z.useState)(``),[k,A]=(0,Z.useState)([]);(0,Z.useEffect)(()=>{if(i&&t){let e=r.find(e=>e.name===t);if(e){s(e.name),l(e.config.command);let t=e.config.args.join(`
71
+ `);d(t);let n=Object.entries(e.config.env??{}).map(([e,t])=>({key:e,value:t}));p(n),w(e.name),E(e.config.command),O(t),A(n),S(!1)}}else S(!1)},[r,t,i]);let j=(0,Z.useCallback)(()=>{p(e=>[...e,{key:``,value:``}])},[]),M=(0,Z.useCallback)(e=>{p(t=>t.filter((t,n)=>n!==e))},[]),N=(0,Z.useCallback)((e,t)=>{p(n=>n.map((n,r)=>r===e?{...n,key:t}:n))},[]),P=(0,Z.useCallback)((e,t)=>{p(n=>n.map((n,r)=>r===e?{...n,value:t}:n))},[]),F=()=>{let e=u.split(`
72
+ `).map(e=>e.trim()).filter(Boolean),t={};for(let{key:e,value:n}of f)e.trim()&&(t[e.trim()]=n);return{command:c.trim(),args:e,...Object.keys(t).length>0?{env:t}:{}}},I=async()=>{b(null);let t=a.trim(),r=c.trim();if(!t){b(`Server name is required`);return}if(!r){b(`Command is required`);return}h(!0);try{if(!e)throw Error(`No project path`);await As(e,C||t,F()),X({title:`Success`,description:i?`MCP server configuration saved`:`MCP server added`}),n()}catch(e){b(e instanceof Error?e.message:`Failed to save server`)}finally{h(!1)}},L=async()=>{if(e){_(!0);try{await js(e,C),X({title:`Success`,description:`MCP server removed`}),n()}catch(e){b(e instanceof Error?e.message:`Failed to delete server`)}finally{_(!1)}}},R=i?c!==T||u!==D||JSON.stringify(f)!==JSON.stringify(k):a.trim()!==``||c.trim()!==``||u.trim()!==``||f.length>0;return x?(0,$.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading server configuration...`})}):(0,$.jsxs)(`div`,{className:`max-w-2xl mx-auto p-6`,children:[(0,$.jsxs)(`div`,{className:`mb-6`,children:[(0,$.jsx)(`h1`,{className:`text-2xl font-bold`,children:i?a:`Add MCP Server`}),(0,$.jsx)(`p`,{className:`text-muted-foreground`,children:i?`Edit MCP Server configuration.`:`Configure a new MCP Server.`})]}),(0,$.jsxs)(`div`,{className:`space-y-6`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(o,{htmlFor:`server-name`,children:`Server name`}),(0,$.jsx)(Nt,{id:`server-name`,placeholder:`e.g. filesystem`,value:a,onChange:e=>s(e.target.value),disabled:i}),i&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Server name cannot be changed`})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(o,{htmlFor:`server-command`,children:`Command`}),(0,$.jsx)(Nt,{id:`server-command`,placeholder:`e.g. npx`,value:c,onChange:e=>l(e.target.value),className:`text-sm`})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(o,{htmlFor:`server-args`,children:[`Arguments `,(0,$.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:`(one per line)`})]}),(0,$.jsx)(Gr,{id:`server-args`,placeholder:`-y
73
+ @modelcontextprotocol/server-filesystem
74
+ /path/to/dir`,value:u,onChange:e=>d(e.target.value),className:`font-mono text-xs min-h-[80px] resize-none`})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(o,{children:`Environment variables`}),(0,$.jsxs)(q,{variant:`ghost`,size:`sm`,onClick:j,className:`h-6 px-2 text-xs`,children:[(0,$.jsx)(Xe,{className:`h-3 w-3 mr-1`}),`Add variable`]})]}),f.length===0?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground py-1`,children:`No environment variables configured`}):(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:f.map((e,t)=>(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Nt,{placeholder:`KEY`,value:e.key,onChange:e=>N(t,e.target.value),className:`font-mono text-xs w-[35%]`}),(0,$.jsx)(Nt,{placeholder:`value`,value:e.value,onChange:e=>P(t,e.target.value),className:`font-mono text-xs flex-1`}),(0,$.jsx)(q,{variant:`ghost`,size:`icon`,onClick:()=>M(t),className:`h-9 w-9 flex-shrink-0`,children:(0,$.jsx)(v,{className:`h-3.5 w-3.5`})})]},t))})]}),y&&(0,$.jsx)(`p`,{className:`text-sm text-destructive`,children:y}),(0,$.jsxs)(`div`,{className:`border-t pt-4 flex items-center justify-between`,children:[i&&(0,$.jsx)(q,{variant:`destructive`,onClick:L,disabled:g||m,children:g?`Removing...`:`Remove`}),!i&&(0,$.jsx)(`div`,{}),(0,$.jsx)(q,{onClick:I,disabled:m||g||!R,children:m?i?`Saving...`:`Adding...`:i?`Save`:`Add`})]})]})]})}function Ns(e){let t=(0,Q.c)(23),{name:r,description:i,installed:a,onClick:o,onOpen:s,onUninstall:c}=e,l=`flex flex-col gap-2 p-2.5 rounded-lg border border-border bg-card text-left transition-colors w-full ${a?``:`hover:bg-accent/50 cursor-pointer`}`,u=a?void 0:o,d=a?void 0:`button`,f;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(`div`,{className:`flex-shrink-0 h-6 w-6 rounded-md bg-muted flex items-center justify-center`,children:(0,$.jsx)(A,{className:`h-3 w-3 text-muted-foreground`})}),t[0]=f):f=t[0];let p;t[1]===r?p=t[2]:(p=(0,$.jsx)(`span`,{className:`font-medium text-sm truncate`,children:r}),t[1]=r,t[2]=p);let m;t[3]===a?m=t[4]:(m=a&&(0,$.jsx)(qr,{delayDuration:300,children:(0,$.jsxs)(Jr,{children:[(0,$.jsx)(Yr,{asChild:!0,children:(0,$.jsx)(`span`,{className:`flex-shrink-0 h-4 w-4 rounded-full bg-green-500/15 flex items-center justify-center`,children:(0,$.jsx)(n,{className:`h-2.5 w-2.5 text-green-600 dark:text-green-400`})})}),(0,$.jsx)(Kr,{children:`Installed`})]})}),t[3]=a,t[4]=m);let h;t[5]!==p||t[6]!==m?(h=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[f,p,m]}),t[5]=p,t[6]=m,t[7]=h):h=t[7];let g;t[8]!==a||t[9]!==s||t[10]!==c?(g=a&&(0,$.jsxs)(`div`,{className:`flex items-center gap-1 flex-shrink-0`,children:[s&&(0,$.jsx)(qr,{delayDuration:300,children:(0,$.jsxs)(Jr,{children:[(0,$.jsx)(Yr,{asChild:!0,children:(0,$.jsx)(q,{variant:`ghost`,size:`icon-sm`,onClick:e=>{e.stopPropagation(),s()},children:(0,$.jsx)(I,{className:`h-3.5 w-3.5`})})}),(0,$.jsx)(Kr,{children:`Open in Explorer`})]})}),c&&(0,$.jsx)(qr,{delayDuration:300,children:(0,$.jsxs)(Jr,{children:[(0,$.jsx)(Yr,{asChild:!0,children:(0,$.jsx)(q,{variant:`ghost`,size:`icon-sm`,onClick:e=>{e.stopPropagation(),c()},className:`text-destructive hover:text-destructive`,children:(0,$.jsx)(fe,{className:`h-3.5 w-3.5`})})}),(0,$.jsx)(Kr,{children:`Remove`})]})})]}),t[8]=a,t[9]=s,t[10]=c,t[11]=g):g=t[11];let _;t[12]!==h||t[13]!==g?(_=(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[h,g]}),t[12]=h,t[13]=g,t[14]=_):_=t[14];let v;t[15]===i?v=t[16]:(v=(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground line-clamp-3`,children:i}),t[15]=i,t[16]=v);let y;return t[17]!==l||t[18]!==v||t[19]!==u||t[20]!==d||t[21]!==_?(y=(0,$.jsxs)(`div`,{className:l,onClick:u,role:d,children:[_,v]}),t[17]=l,t[18]=v,t[19]=u,t[20]=d,t[21]=_,t[22]=y):y=t[22],y}var Ps=Ln,Fs=Z.forwardRef((e,t)=>{let n=(0,Q.c)(9),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=N(`inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,$.jsx)(vr,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});Fs.displayName=vr.displayName;var Is=Z.forwardRef((e,t)=>{let n=(0,Q.c)(9),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=N(`inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,$.jsx)(_r,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});Is.displayName=_r.displayName;var Ls=Z.forwardRef((e,t)=>{let n=(0,Q.c)(9),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=N(`mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,$.jsx)(Zn,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});Ls.displayName=Zn.displayName;function Rs(e){let t=[];for(let n of e)n.type===`file`&&t.push(n.path),n.children&&t.push(...Rs(n.children));return t}function zs({projectPath:e,threadId:t,onClose:n}){let{installedServers:r,loadInstalledServers:i}=Os(e),{popularServers:o}=ks(),{setActiveMainTab:s,setPendingExplorerPath:c,triggerExplorerRefresh:l,setExplorerClearPath:d}=ti(),[f,p]=(0,Z.useState)(`mcp`),[m,g]=(0,Z.useState)(``),[_,v]=(0,Z.useState)(null),[b,x]=(0,Z.useState)(null),[S,C]=(0,Z.useState)(new Set),[w,T]=(0,Z.useState)(new Map),[E,D]=(0,Z.useState)([]),[O,k]=(0,Z.useState)([]),[A,j]=(0,Z.useState)([]),[M,N]=(0,Z.useState)([]);(0,Z.useEffect)(()=>{Ot().then(D).catch(()=>D([])),bt().then(k).catch(()=>k([])),Gt().then(j).catch(()=>j([])),wt().then(N).catch(()=>N([]))},[]),(0,Z.useEffect)(()=>{t&&(y(t).then(e=>C(new Set(Rs(e)))).catch(()=>{}),h(t).then(e=>T(new Map(e.map(e=>[e.name,e.filePath])))).catch(()=>{}))},[t]);let P=(0,Z.useCallback)(e=>{p(e),g(``)},[]),F=(0,Z.useCallback)(e=>{let t=m.trim().toLowerCase();return t?e.filter(e=>e.name.toLowerCase().includes(t)||e.description.toLowerCase().includes(t)):e},[m]),I=(0,Z.useMemo)(()=>F(o),[o,F]),R=(0,Z.useMemo)(()=>F(E),[E,F]),z=(0,Z.useMemo)(()=>F(O),[O,F]),B=(0,Z.useMemo)(()=>F(A),[A,F]),V=(0,Z.useMemo)(()=>F(M),[M,F]),H=(0,Z.useCallback)(async t=>{if(!e)return;let n=t.name.toLowerCase().replace(/\s+/g,`-`);if(!r.some(e=>e.name===n||e.name===t.id)){v(t.id);try{await As(e,n,{command:t.command,args:t.args,...Object.keys(t.env??{}).length>0?{env:t.env}:{}}),await i(),l(),X({title:`MCP server installed`,description:t.name})}catch(e){X({title:`Error`,description:e instanceof Error?e.message:`Failed to install server`,variant:`destructive`})}finally{v(null)}}},[e,r,i,l]),U=(0,Z.useCallback)(async t=>{if(!e)return;let n=t.name.toLowerCase().replace(/\s+/g,`-`);try{await js(e,n),await i(),l(),X({title:`MCP server removed`,description:t.name})}catch(e){X({title:`Error`,description:e instanceof Error?e.message:`Failed to remove server`,variant:`destructive`})}},[e,i,l]),W=(0,Z.useCallback)(()=>{c(`.agents/mcp.json`),s(`explorer`),n()},[c,s,n]),G=(0,Z.useCallback)(e=>{c(`.agents/skills/${e.id}/SKILL.md`),s(`explorer`),n()},[c,s,n]),ee=(0,Z.useCallback)(e=>{c(`.agents/agents/${e.id}/AGENT.md`),s(`explorer`),n()},[c,s,n]),ne=(0,Z.useCallback)(e=>{c(`.agents/rules/${e.name}.md`),s(`explorer`),n()},[c,s,n]),re=(0,Z.useCallback)(e=>{let t=w.get(e.name);t&&(c(t),s(`explorer`),n())},[w,c,s,n]),ie=(0,Z.useCallback)(async e=>{if(!t)return;let n=`.agents/skills/${e.id}/SKILL.md`;try{await Nn(t,`.agents/skills/${e.id}`),C(e=>{let t=new Set(e);return t.delete(n),t}),d(`.agents/skills/${e.id}`),l(),X({title:`Skill removed`,description:e.name})}catch(e){X({title:`Error`,description:e instanceof Error?e.message:`Failed to remove skill`,variant:`destructive`})}},[t,l,d]),ae=(0,Z.useCallback)(async e=>{if(!t)return;let n=`.agents/agents/${e.id}/AGENT.md`;try{await Nn(t,`.agents/agents/${e.id}`),C(e=>{let t=new Set(e);return t.delete(n),t}),d(`.agents/agents/${e.id}`),l(),X({title:`Agent removed`,description:e.name})}catch(e){X({title:`Error`,description:e instanceof Error?e.message:`Failed to remove agent`,variant:`destructive`})}},[t,l,d]),oe=(0,Z.useCallback)(async e=>{if(!t)return;let n=`.agents/rules/${e.name}.md`;try{await Nn(t,n),C(e=>{let t=new Set(e);return t.delete(n),t}),d(n),l(),X({title:`Rule removed`,description:e.name})}catch(e){X({title:`Error`,description:e instanceof Error?e.message:`Failed to remove rule`,variant:`destructive`})}},[t,l,d]),se=(0,Z.useCallback)(async e=>{let t=w.get(e.name);if(t)try{await te(t),T(t=>{let n=new Map(t);return n.delete(e.name),n}),d(t),l(),X({title:`Command removed`,description:`/${e.name}`})}catch(e){X({title:`Error`,description:e instanceof Error?e.message:`Failed to remove command`,variant:`destructive`})}},[w,l,d]),ce=(0,Z.useCallback)((e,t,n,r)=>{x({name:e,gitHubRepo:t,gitHubFolder:n,onConfirm:r})},[]),le=(0,Z.useCallback)(async e=>{let n=`.agents/skills/${e.id}/SKILL.md`;if(!t||S.has(n))return;let r=async()=>{v(e.id);try{if(e.gitHubRepo&&e.gitHubFolder)await Ve(t,e.gitHubRepo,e.gitHubFolder,`.agents/skills/${e.id}`);else{let r=[`---`,`name: ${e.id}`,`description: ${e.description}`];e.allowedTools&&r.push(`allowed-tools: ${e.allowedTools}`),e.license&&r.push(`license: ${e.license}`),r.push(`---`,``,e.instructions),await qt(t,n,r.join(`
75
+ `))}C(e=>new Set(e).add(n)),l(),X({title:`Skill installed`,description:e.name})}catch(e){X({title:`Error`,description:e instanceof Error?e.message:`Failed to install skill`,variant:`destructive`})}finally{v(null)}};e.gitHubRepo&&e.gitHubFolder?ce(e.name,e.gitHubRepo,e.gitHubFolder,r):await r()},[t,S,l,ce]),ue=(0,Z.useCallback)(async e=>{let n=`.agents/agents/${e.id}/AGENT.md`;if(!t||S.has(n))return;let r=async()=>{v(e.id);try{if(e.gitHubRepo&&e.gitHubFolder)await Ve(t,e.gitHubRepo,e.gitHubFolder,`.agents/agents/${e.id}`);else{let r=[`---`,`name: ${e.id}`,`description: ${e.description}`];e.tools&&r.push(`tools: ${e.tools}`),r.push(`---`,``,e.systemPrompt),await qt(t,n,r.join(`
76
+ `))}C(e=>new Set(e).add(n)),l(),X({title:`Agent installed`,description:e.name})}catch(e){X({title:`Error`,description:e instanceof Error?e.message:`Failed to install agent`,variant:`destructive`})}finally{v(null)}};e.gitHubRepo&&e.gitHubFolder?ce(e.name,e.gitHubRepo,e.gitHubFolder,r):await r()},[t,S,l,ce]),de=(0,Z.useCallback)(async e=>{let n=`.agents/rules/${e.name}.md`;if(!t||S.has(n))return;let r=async()=>{v(e.id);try{e.gitHubRepo&&e.gitHubFolder?await Ve(t,e.gitHubRepo,e.gitHubFolder,`.agents/rules`):await qt(t,n,[`---`,`description: ${e.description}`,`alwaysApply: ${e.alwaysApply??!1}`,`---`,``,e.content].join(`
77
+ `)),C(e=>new Set(e).add(n)),l(),X({title:`Rule installed`,description:e.name})}catch(e){X({title:`Error`,description:e instanceof Error?e.message:`Failed to install rule`,variant:`destructive`})}finally{v(null)}};e.gitHubRepo&&e.gitHubFolder?ce(e.name,e.gitHubRepo,e.gitHubFolder,r):await r()},[t,S,l,ce]),fe=(0,Z.useCallback)(async e=>{if(!t||w.has(e.name))return;let n=async()=>{v(e.id);try{if(e.gitHubRepo&&e.gitHubFolder){let n=`.agents/commands`;await Ve(t,e.gitHubRepo,e.gitHubFolder,n);let r=`${n}/${e.name}.md`;T(t=>new Map(t).set(e.name,r))}else{let n=await a(e.name,e.content,{description:e.description,argumentHint:e.argumentHint},`project`,t);T(t=>new Map(t).set(e.name,n.filePath))}l(),X({title:`Command installed`,description:`/${e.name}`})}catch(e){X({title:`Error`,description:e instanceof Error?e.message:`Failed to install command`,variant:`destructive`})}finally{v(null)}};e.gitHubRepo&&e.gitHubFolder?ce(e.name,e.gitHubRepo,e.gitHubFolder,n):await n()},[t,w,l,ce]);function pe({items:e,onInstall:n,isInstalled:r,noThreadWarning:i,onOpen:a,onUninstall:o}){return e.length===0&&m.trim()?(0,$.jsxs)(`p`,{className:`text-sm text-muted-foreground text-center py-8`,children:[`No results for "`,m,`"`]}):e.length===0?(0,$.jsx)(`div`,{className:`flex items-center justify-center py-16`,children:(0,$.jsx)(Et,{className:`h-5 w-5 animate-spin text-muted-foreground`})}):(0,$.jsxs)($.Fragment,{children:[i&&!t&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground bg-muted rounded-md px-3 py-2`,children:`Open a thread to install items into your project.`}),(0,$.jsx)(`div`,{className:`grid gap-2`,style:{gridTemplateColumns:`repeat(auto-fill, minmax(min(220px, 100%), 1fr))`},children:e.map(e=>{let t=r(e);return(0,$.jsxs)(`div`,{className:`relative`,children:[_===e.id&&(0,$.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-background/60 rounded-lg z-10`,children:(0,$.jsx)(Et,{className:`h-4 w-4 animate-spin`})}),(0,$.jsx)(Ns,{name:e.name,description:e.description,installed:t,onClick:()=>n(e),onOpen:t&&a?()=>a(e):void 0,onUninstall:t&&o?()=>o(e):void 0})]},e.id)})})]})}return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(L,{open:b!==null,onOpenChange:e=>{e||x(null)},children:(0,$.jsxs)(K,{children:[(0,$.jsxs)(u,{children:[(0,$.jsxs)(ze,{children:[`Install `,b?.name]}),(0,$.jsxs)(De,{children:[`Install `,(0,$.jsx)(`strong`,{children:b?.name}),` from`,` `,(0,$.jsx)(`strong`,{children:b?.gitHubRepo}),` (`,b?.gitHubFolder,`)?`]})]}),(0,$.jsxs)(Pn,{className:`flex-row gap-2 sm:justify-between`,children:[(0,$.jsx)(q,{variant:`outline`,onClick:()=>{b&&Ge(`${b.gitHubRepo.replace(/\.git$/,``)}/tree/HEAD/${b.gitHubFolder}`)},children:`More Information`}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(q,{variant:`outline`,onClick:()=>x(null),children:`No`}),(0,$.jsx)(q,{onClick:()=>{let e=b;x(null),e&&e.onConfirm()},children:`Yes`})]})]})]})}),(0,$.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,$.jsxs)(`div`,{className:`p-6 pb-0 space-y-4 flex-shrink-0`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Marketplace`}),(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:{mcp:`Browse and install popular MCP servers`,skills:`Reusable instruction sets that guide agent behavior`,agents:`Specialized sub-agents for focused tasks`,rules:`Coding standards and project-wide guidelines`,commands:`Slash commands for quick prompts`}[f]})]}),(0,$.jsx)(Ps,{value:f,onValueChange:P,children:(0,$.jsxs)(Fs,{className:`w-full`,children:[(0,$.jsx)(Is,{value:`mcp`,className:`flex-1`,children:`MCP`}),(0,$.jsx)(Is,{value:`skills`,className:`flex-1`,children:`Skills`}),(0,$.jsx)(Is,{value:`agents`,className:`flex-1`,children:`Agents`}),(0,$.jsx)(Is,{value:`rules`,className:`flex-1`,children:`Rules`}),(0,$.jsx)(Is,{value:`commands`,className:`flex-1`,children:`Commands`})]})}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(rn,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground pointer-events-none`}),(0,$.jsx)(Nt,{placeholder:`Search ${f===`mcp`?`servers`:f}...`,value:m,onChange:e=>g(e.target.value),className:`pl-8`})]})]}),(0,$.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-6 pt-4 space-y-3`,children:[f===`mcp`&&(0,$.jsx)($.Fragment,{children:o.length===0?(0,$.jsx)(`div`,{className:`flex items-center justify-center py-16`,children:(0,$.jsx)(Et,{className:`h-5 w-5 animate-spin text-muted-foreground`})}):I.length===0?(0,$.jsxs)(`p`,{className:`text-sm text-muted-foreground text-center py-8`,children:[`No results for "`,m,`"`]}):(0,$.jsx)(`div`,{className:`grid gap-2`,style:{gridTemplateColumns:`repeat(auto-fill, minmax(min(220px, 100%), 1fr))`},children:I.map(e=>{let t=e.name.toLowerCase().replace(/\s+/g,`-`),n=r.some(n=>n.name===t||n.name===e.id);return(0,$.jsxs)(`div`,{className:`relative`,children:[_===e.id&&(0,$.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-background/60 rounded-lg z-10`,children:(0,$.jsx)(Et,{className:`h-4 w-4 animate-spin`})}),(0,$.jsx)(Ns,{name:e.name,description:e.description,installed:n,onClick:()=>void H(e),onOpen:n?W:void 0,onUninstall:n?()=>void U(e):void 0})]},e.id)})})}),f===`skills`&&(0,$.jsx)(pe,{items:R,onInstall:e=>void le(e),isInstalled:e=>S.has(`.agents/skills/${e.id}/SKILL.md`),noThreadWarning:!0,onOpen:G,onUninstall:e=>void ie(e)}),f===`agents`&&(0,$.jsx)(pe,{items:z,onInstall:e=>void ue(e),isInstalled:e=>S.has(`.agents/agents/${e.id}/AGENT.md`),noThreadWarning:!0,onOpen:ee,onUninstall:e=>void ae(e)}),f===`rules`&&(0,$.jsx)(pe,{items:B,onInstall:e=>void de(e),isInstalled:e=>S.has(`.agents/rules/${e.name}.md`),noThreadWarning:!0,onOpen:ne,onUninstall:e=>void oe(e)}),f===`commands`&&(0,$.jsx)(pe,{items:V,onInstall:e=>void fe(e),isInstalled:e=>w.has(e.name),noThreadWarning:!0,onOpen:re,onUninstall:e=>void se(e)})]})]})]})}var Bs=[{value:`plan`,label:`Plan`,field:`planPrompt`,defaultPrompt:uo},{value:`review`,label:`Code Review`,field:`reviewPrompt`,defaultPrompt:mo},{value:`test`,label:`Test`,field:`testPrompt`,defaultPrompt:po}];function Vs({open:e,onOpenChange:t,projectId:n}){let{state:r}=Nr(),[i,a]=(0,Z.useState)({plan:``,review:``,test:``}),[o,s]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{if(!e)return;let t=r.projects.find(e=>e.projectId===n);a({plan:t?.planPrompt??``,review:t?.reviewPrompt??``,test:t?.testPrompt??``})},[e,n,r.projects]);async function c(){s(!0);try{await $t(n,{planPrompt:i.plan.trim()===uo?null:i.plan.trim()||null,testPrompt:i.test.trim()===po?null:i.test.trim()||null,reviewPrompt:i.review.trim()===mo?null:i.review.trim()||null}),P(),X({title:`AI prompt settings saved`}),t(!1)}catch(e){X({title:`Error`,description:e instanceof Error?e.message:`Failed to save prompt settings`,variant:`destructive`})}finally{s(!1)}}function l(e,t){a(n=>({...n,[e]:t}))}return(0,$.jsx)(L,{open:e,onOpenChange:t,children:(0,$.jsxs)(K,{className:`max-w-2xl`,children:[(0,$.jsxs)(u,{children:[(0,$.jsx)(ze,{children:`AI Prompt Settings`}),(0,$.jsx)(De,{children:`Customize the prompts used when running Plan, Code Review, and Test actions from the task board. Leave empty to use the default prompt.`})]}),(0,$.jsxs)(Ps,{defaultValue:`plan`,className:`w-full`,children:[(0,$.jsx)(Fs,{className:`w-full`,children:Bs.map(e=>(0,$.jsx)(Is,{value:e.value,className:`flex-1`,children:e.label},e.value))}),Bs.map(e=>(0,$.jsxs)(Ls,{value:e.value,children:[(0,$.jsx)(Gr,{value:i[e.value]||e.defaultPrompt,onChange:t=>l(e.value,t.target.value),className:`min-h-[250px] font-mono text-sm resize-none`,placeholder:e.defaultPrompt,disabled:o}),(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground mt-1.5`,children:[`Use `,(0,$.jsx)(`code`,{className:`text-xs`,children:`{description}`}),` for the task description. Leave empty to use the default.`]})]},e.value))]}),(0,$.jsx)(Pn,{children:(0,$.jsx)(q,{onClick:()=>void c(),disabled:o,children:o?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Et,{className:`mr-2 h-4 w-4 animate-spin`}),`Saving...`]}):`Save`})})]})})}function Hs(){let e=hr(),{state:t}=Nr(),{selectedProjectId:n,selectedThreadId:r,projects:i}=t,a=i.find(e=>e.projectId===n),[o,s]=(0,Z.useState)(null),[c,l]=(0,Z.useState)(``),[d,f]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{o!==`instructions`||!r||(f(!0),C(r,`AGENTS.md`).then(e=>l(e.content)).catch(()=>l(``)).finally(()=>f(!1)))},[o,r]);let h=async()=>{if(r){m(!0);try{await qt(r,`AGENTS.md`,c),X({title:`Instructions saved`}),s(null)}catch(e){X({title:`Error`,description:e instanceof Error?e.message:`Failed to save instructions`,variant:`destructive`})}finally{m(!1)}}};return n?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(qr,{children:(0,$.jsxs)(jo,{children:[(0,$.jsxs)(Jr,{children:[(0,$.jsx)(Yr,{asChild:!0,children:(0,$.jsx)(Mo,{asChild:!0,children:(0,$.jsx)(q,{variant:`action`,size:`icon-md`,children:(0,$.jsx)(mt,{})})})}),(0,$.jsx)(Kr,{children:`AI`})]}),(0,$.jsxs)(Io,{align:`end`,children:[(0,$.jsx)(Lo,{onSelect:()=>s(`mcp`),children:`Add MCP Server`}),(0,$.jsx)(Lo,{onSelect:()=>s(`skill`),children:`Add Skill`}),(0,$.jsx)(Lo,{onSelect:()=>s(`rule`),children:`Add Rule`}),(0,$.jsx)(Lo,{onSelect:()=>s(`slash-command`),children:`Add Slash Command`}),(0,$.jsx)(Lo,{onSelect:()=>s(`subagent`),children:`Add Subagent`}),(0,$.jsx)(Vo,{}),(0,$.jsx)(Lo,{onSelect:()=>s(`ai-settings`),children:`Settings`}),(0,$.jsx)(Lo,{onSelect:()=>s(`instructions`),disabled:!r,children:`Instructions`}),(0,$.jsx)(Lo,{onSelect:()=>void e(`/settings?tab=providers`),children:`Model Providers`}),(0,$.jsx)(Vo,{}),(0,$.jsx)(Lo,{onSelect:()=>s(`marketplace`),children:`Marketplace`})]})]})}),(0,$.jsx)(L,{open:o===`mcp`,onOpenChange:e=>!e&&s(null),children:(0,$.jsx)(K,{className:`max-w-2xl max-h-[90vh] overflow-y-auto p-0`,children:(0,$.jsx)(`div`,{className:`w-full`,children:(0,$.jsx)(Ms,{projectPath:a?.projectPath,onBack:()=>s(null)})})})}),(0,$.jsx)(L,{open:o===`marketplace`,onOpenChange:e=>!e&&s(null),children:(0,$.jsx)(K,{className:`max-w-3xl h-[80vh] overflow-y-auto p-0`,children:(0,$.jsx)(zs,{projectPath:a?.projectPath,threadId:r,onClose:()=>s(null)})})}),(0,$.jsx)(L,{open:o===`skill`,onOpenChange:e=>!e&&s(null),children:(0,$.jsx)(K,{className:`max-w-2xl max-h-[90vh] overflow-y-auto p-0`,children:(0,$.jsx)(Cs,{threadId:r,onSkillCreated:()=>s(null)})})}),(0,$.jsx)(L,{open:o===`rule`,onOpenChange:e=>!e&&s(null),children:(0,$.jsx)(K,{className:`max-w-2xl max-h-[90vh] overflow-y-auto p-0`,children:(0,$.jsx)(Ts,{threadId:r,onRuleCreated:()=>s(null)})})}),(0,$.jsx)(L,{open:o===`slash-command`,onOpenChange:e=>!e&&s(null),children:(0,$.jsx)(K,{className:`max-w-2xl max-h-[90vh] overflow-y-auto p-0`,children:(0,$.jsx)(Ds,{projectId:n,threadId:r,onCommandCreated:()=>s(null)})})}),(0,$.jsx)(L,{open:o===`subagent`,onOpenChange:e=>!e&&s(null),children:(0,$.jsx)(K,{className:`max-w-2xl max-h-[90vh] overflow-y-auto p-0`,children:(0,$.jsx)(Es,{threadId:r,onAgentCreated:()=>s(null)})})}),n&&(0,$.jsx)(Vs,{open:o===`ai-settings`,onOpenChange:e=>!e&&s(null),projectId:n}),(0,$.jsx)(L,{open:o===`instructions`,onOpenChange:e=>!e&&s(null),children:(0,$.jsxs)(K,{className:`max-w-2xl`,children:[(0,$.jsxs)(u,{children:[(0,$.jsx)(ze,{children:`Instructions`}),(0,$.jsx)(De,{children:`Add context like coding guidelines and expectations that are relevant for all conversations (this is stored in the agents.md file)`})]}),d?(0,$.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,$.jsx)(Et,{className:`h-5 w-5 animate-spin text-muted-foreground`})}):(0,$.jsx)(Gr,{value:c,onChange:e=>l(e.target.value),className:`min-h-[300px] font-mono text-sm resize-none`,placeholder:`Add instructions for your agent in AGENTS.md...`,disabled:p}),(0,$.jsxs)(Pn,{children:[(0,$.jsx)(q,{variant:`outline`,onClick:()=>s(null),children:`Cancel`}),(0,$.jsx)(q,{onClick:()=>void h(),disabled:d||p,children:p?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Et,{className:`mr-2 h-4 w-4 animate-spin`}),`Saving...`]}):`Save`})]})]})})]}):null}function Us(){let e=(0,Q.c)(44),{state:t,dispatch:n}=Nr(),{selectedThreadId:r,selectedProjectId:i,projects:a,sidebarOpen:o}=t,s;if(e[0]!==a||e[1]!==i){let t;e[3]===i?t=e[4]:(t=e=>e.projectId===i,e[3]=i,e[4]=t),s=a.find(t),e[0]=a,e[1]=i,e[2]=s}else s=e[2];let c=s,l=!o,u=l&&`h-auto py-3 flex-col items-start gap-3 md:flex-row md:items-center md:h-[71px] md:py-0 md:gap-2`,d;e[5]===u?d=e[6]:(d=N(u),e[5]=u,e[6]=d);let f;e[7]===n?f=e[8]:(f=()=>n({type:Y.ToggleSidebar}),e[7]=n,e[8]=f);let p;e[9]===o?p=e[10]:(p=o?(0,$.jsx)(kt,{className:`h-4 w-4`}):(0,$.jsx)(sn,{className:`h-4 w-4`}),e[9]=o,e[10]=p);let m;e[11]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(`span`,{className:`sr-only`,children:`Toggle sidebar`}),e[11]=m):m=e[11];let h;e[12]!==f||e[13]!==p?(h=(0,$.jsxs)(q,{variant:`ghost`,size:`icon`,className:`h-8 w-8 text-muted-foreground shrink-0`,onClick:f,children:[p,m]}),e[12]=f,e[13]=p,e[14]=h):h=e[14];let g;e[15]!==a||e[16]!==i||e[17]!==r?(g=r&&(0,$.jsxs)(`div`,{className:`flex flex-col`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:k(a,i)}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:W(a,r)})]}),e[15]=a,e[16]=i,e[17]=r,e[18]=g):g=e[18];let _;e[19]!==h||e[20]!==g?(_=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[h,g]}),e[19]=h,e[20]=g,e[21]=_):_=e[21];let v=l?`ml-0`:`ml-auto`,y;e[22]===v?y=e[23]:(y=N(`flex flex-wrap items-center justify-end gap-2`,v,`md:ml-auto`),e[22]=v,e[23]=y);let b;e[24]!==c?.runCommand||e[25]!==i||e[26]!==r?(b=i&&(0,$.jsxs)(ys,{children:[(0,$.jsx)(vs,{projectId:i,runCommand:c?.runCommand}),r&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(bs,{threadId:r}),(0,$.jsx)(_s,{}),(0,$.jsx)(Hs,{})]})]}),e[24]=c?.runCommand,e[25]=i,e[26]=r,e[27]=b):b=e[27];let x;e[28]!==i||e[29]!==r?(x=r&&i&&(0,$.jsx)(ys,{children:(0,$.jsx)(ms,{projectId:i,threadId:r})}),e[28]=i,e[29]=r,e[30]=x):x=e[30];let S;e[31]!==c?.openWith||e[32]!==i||e[33]!==r?(S=r&&i&&(0,$.jsx)(ys,{children:(0,$.jsx)(Go,{projectId:i,threadId:r,openWith:c?.openWith})}),e[31]=c?.openWith,e[32]=i,e[33]=r,e[34]=S):S=e[34];let C;e[35]!==y||e[36]!==b||e[37]!==x||e[38]!==S?(C=(0,$.jsxs)(`div`,{className:y,children:[b,x,S]}),e[35]=y,e[36]=b,e[37]=x,e[38]=S,e[39]=C):C=e[39];let w;return e[40]!==C||e[41]!==d||e[42]!==_?(w=(0,$.jsxs)(Ao,{className:d,children:[_,C]}),e[40]=C,e[41]=d,e[42]=_,e[43]=w):w=e[43],w}function Ws(e){let t=(0,Q.c)(13),{open:n,projectName:r,onOpenChange:i,onConfirm:a}=e,o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(hi,{children:`Delete Project`}),t[0]=o):o=t[0];let s;t[1]===r?s=t[2]:(s=(0,$.jsxs)(pi,{children:[o,(0,$.jsxs)(gi,{children:[`Are you sure you want to delete`,` `,(0,$.jsxs)(`span`,{className:`font-semibold text-foreground`,children:[`"`,r,`"`]}),`? This will remove the project and all its data. This action cannot be undone.`]})]}),t[1]=r,t[2]=s);let c;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(vi,{children:`Cancel`}),t[3]=c):c=t[3];let l;t[4]===a?l=t[5]:(l=(0,$.jsxs)(mi,{children:[c,(0,$.jsx)(_i,{onClick:a,className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:`Delete`})]}),t[4]=a,t[5]=l);let u;t[6]!==s||t[7]!==l?(u=(0,$.jsxs)(fi,{children:[s,l]}),t[6]=s,t[7]=l,t[8]=u):u=t[8];let d;return t[9]!==i||t[10]!==n||t[11]!==u?(d=(0,$.jsx)(li,{open:n,onOpenChange:i,children:u}),t[9]=i,t[10]=n,t[11]=u,t[12]=d):d=t[12],d}function Gs(e){let t=(0,Q.c)(28),{open:n,setupScripts:r,onConfirm:i}=e;if(r.length===0)return null;let a;t[0]===i?a=t[1]:(a=e=>{e||i(!1)},t[0]=i,t[1]=a);let o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(hi,{children:`Install dependencies?`}),t[2]=o):o=t[2];let s=r.length===1?``:`s`,c;t[3]!==r.length||t[4]!==s?(c=(0,$.jsxs)(pi,{children:[o,(0,$.jsxs)(gi,{children:[`Found `,r.length,` package`,s,` with dependencies to install:`]})]}),t[3]=r.length,t[4]=s,t[5]=c):c=t[5];let l;t[6]===r?l=t[7]:(l=r.map(Ks),t[6]=r,t[7]=l);let u;t[8]===l?u=t[9]:(u=(0,$.jsx)(`div`,{className:`my-4 max-h-60 overflow-y-auto`,children:(0,$.jsx)(`div`,{className:`space-y-2`,children:l})}),t[8]=l,t[9]=u);let d;t[10]===i?d=t[11]:(d=(0,$.jsx)(vi,{onClick:()=>i(!1),children:`No`}),t[10]=i,t[11]=d);let f;t[12]===i?f=t[13]:(f=()=>i(!0),t[12]=i,t[13]=f);let p;t[14]!==r.length||t[15]!==f?(p=(0,$.jsxs)(_i,{onClick:f,children:[`Install All (`,r.length,`)`]}),t[14]=r.length,t[15]=f,t[16]=p):p=t[16];let m;t[17]!==d||t[18]!==p?(m=(0,$.jsxs)(mi,{children:[d,p]}),t[17]=d,t[18]=p,t[19]=m):m=t[19];let h;t[20]!==m||t[21]!==c||t[22]!==u?(h=(0,$.jsxs)(fi,{className:`max-w-2xl`,children:[c,u,m]}),t[20]=m,t[21]=c,t[22]=u,t[23]=h):h=t[23];let g;return t[24]!==n||t[25]!==a||t[26]!==h?(g=(0,$.jsx)(li,{open:n,onOpenChange:a,children:h}),t[24]=n,t[25]=a,t[26]=h,t[27]=g):g=t[27],g}function Ks(e,t){let n=e.match(/^cd "([^"]+)" && (.+)$/),r=n?n[1]:`root`,i=n?n[2]:e;return(0,$.jsx)(`div`,{className:`flex items-center justify-between p-3 rounded-lg border bg-muted/50`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-blue-500`}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`font-medium text-sm`,children:r||`root`}),(0,$.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:i})]})]})},t)}function qs(){let e=(0,Q.c)(6),[t,n]=(0,Z.useState)(!0),r,i;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{let e=!0;return(async()=>{try{let t=await fetch(`${m()}/health`,{method:`GET`});e&&n(t.ok)}catch{e&&n(!1)}})(),()=>{e=!1}},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),(0,Z.useEffect)(r,i);let a=Js;if(t)return null;let o;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=m(),e[2]=o):o=e[2];let s=o,c,l;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsxs)(pi,{children:[(0,$.jsx)(hi,{children:`Service unavailable`}),(0,$.jsx)(gi,{children:`Service is not currently up. Please ensure the backend is running at the address below, then retry.`})]}),l=(0,$.jsx)(`div`,{className:`rounded-md bg-muted px-3 py-2 text-xs font-mono text-muted-foreground`,children:s}),e[3]=c,e[4]=l):(c=e[3],l=e[4]);let u;return e[5]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(li,{open:!0,children:(0,$.jsxs)(fi,{children:[c,l,(0,$.jsx)(mi,{children:(0,$.jsx)(q,{onClick:a,children:`Retry`})})]})}),e[5]=u):u=e[5],u}function Js(){window.location.assign(window.location.href)}var Ys=e=>{let t=(0,Q.c)(8),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=N(`flex h-full w-full data-[panel-group-direction=vertical]:flex-col`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(Vn,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a},Xs=nr,Zs=e=>{let t=(0,Q.c)(12),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({withHandle:i,className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===n?a=t[5]:(a=N(`relative flex w-px items-center justify-center bg-transparent after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:-translate-y-1/2 data-[panel-group-direction=vertical]:after:translate-x-0 [&[data-panel-group-direction=vertical]>div]:rotate-90`,n),t[4]=n,t[5]=a);let o;t[6]===i?o=t[7]:(o=i&&(0,$.jsx)(`div`,{className:`hidden z-10 flex h-4 w-3 items-center justify-center rounded-sm border bg-border`,children:(0,$.jsx)(Ae,{className:`h-2.5 w-2.5`})}),t[6]=i,t[7]=o);let s;return t[8]!==r||t[9]!==a||t[10]!==o?(s=(0,$.jsx)(Bn,{className:a,...r,children:o}),t[8]=r,t[9]=a,t[10]=o,t[11]=s):s=t[11],s},Qs=jr,$s=Z.forwardRef((e,t)=>{let n=(0,Q.c)(9),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=N(`fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,$.jsx)(Ar,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});$s.displayName=Ar.displayName;var ec=ye(`group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full`,{variants:{variant:{default:`border bg-background text-foreground`,destructive:`destructive group border-destructive bg-destructive text-destructive-foreground`}},defaultVariants:{variant:`default`}}),tc=Z.forwardRef((e,t)=>{let n=(0,Q.c)(11),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({className:r,variant:a,...i}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o;n[4]!==r||n[5]!==a?(o=N(ec({variant:a}),r),n[4]=r,n[5]=a,n[6]=o):o=n[6];let s;return n[7]!==i||n[8]!==t||n[9]!==o?(s=(0,$.jsx)(tr,{ref:t,className:o,...i}),n[7]=i,n[8]=t,n[9]=o,n[10]=s):s=n[10],s});tc.displayName=tr.displayName;var nc=Z.forwardRef((e,t)=>{let n=(0,Q.c)(9),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=N(`inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors hover:bg-secondary focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,$.jsx)(Or,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});nc.displayName=Or.displayName;var rc=Z.forwardRef((e,t)=>{let n=(0,Q.c)(10),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=N(`absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-2 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600`,r),n[3]=r,n[4]=a);let o;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(v,{className:`h-4 w-4`}),n[5]=o):o=n[5];let s;return n[6]!==i||n[7]!==t||n[8]!==a?(s=(0,$.jsx)(Mr,{ref:t,className:a,"toast-close":``,...i,children:o}),n[6]=i,n[7]=t,n[8]=a,n[9]=s):s=n[9],s});rc.displayName=Mr.displayName;var ic=Z.forwardRef((e,t)=>{let n=(0,Q.c)(9),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=N(`text-sm font-semibold`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,$.jsx)(zn,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});ic.displayName=zn.displayName;var ac=Z.forwardRef((e,t)=>{let n=(0,Q.c)(9),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=N(`text-sm opacity-90`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,$.jsx)(ur,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});ac.displayName=ur.displayName;function oc(){let e=(0,Q.c)(5),{toasts:t}=Xr(),n;e[0]===t?n=e[1]:(n=t.map(sc),e[0]=t,e[1]=n);let r;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)($s,{}),e[2]=r):r=e[2];let i;return e[3]===n?i=e[4]:(i=(0,$.jsxs)(Qs,{children:[n,r]}),e[3]=n,e[4]=i),i}function sc(e){let{id:t,title:n,description:r,action:i,...a}=e;return(0,$.jsxs)(tc,{...a,children:[(0,$.jsxs)(`div`,{className:`grid gap-1`,children:[n&&(0,$.jsx)(ic,{children:n}),r&&(0,$.jsx)(ac,{children:r})]}),i,(0,$.jsx)(rc,{})]},t)}function cc(){let e=(0,Q.c)(4),{resolvedTheme:t,theme:n}=Zr(),r,i;return e[0]!==t||e[1]!==n?(r=()=>{if(window.tarsk?.setNativeTheme){let e=n===`system`?`system`:t||`system`;window.tarsk.setNativeTheme(e)}},i=[t,n],e[0]=t,e[1]=n,e[2]=r,e[3]=i):(r=e[2],i=e[3]),(0,Z.useEffect)(r,i),null}function lc(e){let t=(0,Q.c)(7),n,r;t[0]===e?(n=t[1],r=t[2]):({children:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(cc,{}),t[3]=i):i=t[3];let a;return t[4]!==n||t[5]!==r?(a=(0,$.jsxs)(Qr,{...r,children:[i,n]}),t[4]=n,t[5]=r,t[6]=a):a=t[6],a}function uc(){let{state:e,dispatch:t}=Nr(),{toast:n}=Xr(),r=Br(`project-creation`).dispatch,[i,a]=(0,Z.useState)(null),o=(0,Z.useCallback)(async()=>{try{t({type:Y.SetProjectsLoading,projectsLoading:!0});let e=await st();t({type:Y.SetProjects,projects:e.projects})}catch(e){console.error(`Failed to refresh projects:`,e)}finally{t({type:Y.SetProjectsLoading,projectsLoading:!1})}},[t]),s=(0,Z.useCallback)(async(n,r)=>{try{await cn(n,r)}catch(e){console.error(`Failed to select thread:`,e)}(e.selectedThreadId!==r||e.selectedProjectId!==n)&&t({type:Y.SelectThread,threadId:r,projectId:n})},[t,e.selectedThreadId,e.selectedProjectId]),c=(0,Z.useCallback)(async e=>{t({type:Y.SetCreatingProject,isCreating:!0});try{let n=await e.apiCall();if(!n){t({type:Y.SetCreatingProject,isCreating:!1}),await o();return}let i=e.useTerminalDispatch?r:t;i({type:Y.ClearTerminalOutput}),i({type:Y.SetTerminalOpen,open:!0}),i({type:Y.AppendTerminalLine,line:{type:`system`,content:e.initialMessage}});let s=n.getReader(),c=new TextDecoder,l=``,u=null,d=!1,f=null,p=null;for(;;){let{done:n,value:r}=await s.read();if(n)break;l+=c.decode(r,{stream:!0});let o=l.split(`
78
+ `);l=o.pop()??``;for(let n of o){let r=n.trim();if(r)try{let n=JSON.parse(r);if(n.type===`progress`)!d&&n.threadId&&n.projectId&&(d=!0,f=n.projectId,p=n.threadId,t({type:Y.AddCreatingProject,projectId:n.projectId,threadId:n.threadId,projectName:e.optimisticProjectName,gitUrl:e.gitUrl??``}),t({type:Y.AddProcessingThread,threadId:n.threadId})),t({type:Y.AppendTerminalLine,...e.useTerminalDispatch?{threadId:p??`project-creation`}:{},line:{type:`output`,content:n.message}});else if(n.type===`complete`){if(n.project){u=n.project.id;let r=e.includeThreadPath&&n.project.threads?.length>0?`${n.project.path}/${n.project.threads[0]}`:n.project.path;i({type:Y.AppendTerminalLine,line:{type:`system`,content:`Project created successfully at: ${r}`}}),t({type:Y.SetTerminalOpen,open:!1}),e.handleSetupScript&&n.suggestedSetupScript&&a({projectId:n.project.id,command:n.suggestedSetupScript,remainingScripts:n.project.pendingSetupScripts??[]})}}else n.type===`error`&&(d&&f&&(t({type:Y.RemoveCreatingProject,projectId:f}),p&&t({type:Y.RemoveProcessingThread,threadId:p})),t({type:Y.AppendTerminalLine,...e.useTerminalDispatch?{threadId:p??`project-creation`}:{},line:{type:`error`,content:`Error: ${n.message}`}}))}catch(t){console.error(`Failed to parse ${e.logTag} event`,t)}}}t({type:Y.SetCreatingProject,isCreating:!1}),d&&p&&t({type:Y.RemoveProcessingThread,threadId:p}),P();let m=await st();if(t({type:Y.SetProjects,projects:m.projects}),t({type:Y.SetProjectsLoading,projectsLoading:!1}),u){let e=m.projects.find(e=>e.projectId===u);if(e&&e.threads.length>0){let n=e.threads[0].threadId;t({type:Y.SelectThread,threadId:n,projectId:u,focusInput:!0})}}}catch(n){console.error(`Failed to ${e.logTag}:`,n),t({type:Y.SetCreatingProject,isCreating:!1}),(e.useTerminalDispatch?r:t)({type:Y.AppendTerminalLine,line:{type:`error`,content:`${e.catchErrorPrefix}: ${n instanceof Error?n.message:`Unknown error`}`}})}},[t,o,r]),l=(0,Z.useCallback)(async(e,t)=>{let n=e.split(`/`).pop()?.replace(`.git`,``)??`project`;await c({apiCall:()=>me(e,t),initialMessage:`Cloning repository: ${e}...`,optimisticProjectName:n,gitUrl:e,useTerminalDispatch:!0,includeThreadPath:!0,handleSetupScript:!0,logTag:`create project`,catchErrorPrefix:`Failed to create project`})},[c]),u=(0,Z.useCallback)(async(e,t,n)=>{await c({apiCall:()=>It(e,t,n),initialMessage:`Creating app "${e}"...`,optimisticProjectName:e,useTerminalDispatch:!1,handleSetupScript:!1,logTag:`create web app`,catchErrorPrefix:`Failed to create web app`})},[c]),d=(0,Z.useCallback)(async(r,i)=>{try{let a=i??(()=>{let t=e.projects.find(e=>e.projectId===r)?.threads.map(e=>e.title)??[],n=/^thread-(\d+)$/i,i=0;for(let e of t){let t=e.match(n);t&&(i=Math.max(i,parseInt(t[1],10)))}return`thread-${i+1}`})(),s=await jt(r,i);if(!s){await o();return}let c=s.getReader(),l=new TextDecoder,u=``,d=!1,f=null,p=!0,m=[{type:`system`,content:`Creating thread "${a}"...`}];try{for(;;){let{done:e,value:i}=await c.read();if(e)break;u+=l.decode(i,{stream:!0});let o=u.split(`
79
+ `);u=o.pop()??``;for(let e of o){let i=e.trim();if(i)try{let e=JSON.parse(i);if(e.type===`progress`){if(!d&&e.threadId){d=!0,f=e.threadId,t({type:Y.AddCreatingThread,projectId:r,threadId:e.threadId,title:a}),t({type:Y.AddProcessingThread,threadId:e.threadId}),t({type:Y.ClearTerminalOutput,threadId:f});for(let e of m)t({type:Y.AppendTerminalLine,threadId:f,line:e});m.length=0}let n={type:`output`,content:e.message};f?t({type:Y.AppendTerminalLine,threadId:f,line:n}):m.push(n)}else if(e.type===`error`){d&&f&&(t({type:Y.RemoveCreatingThread,projectId:r,threadId:f}),t({type:Y.RemoveProcessingThread,threadId:f}));let i={type:`error`,content:`Error: ${e.message}`};f?t({type:Y.AppendTerminalLine,threadId:f,line:i}):m.push(i),console.error(`Thread creation error:`,e.message),n({title:`Thread Creation Failed`,description:e.message,variant:`destructive`}),p=!1}}catch(e){console.error(`Failed to parse thread event`,e)}}}d&&f&&t({type:Y.RemoveProcessingThread,threadId:f}),P(),await o(),f&&p&&t({type:Y.SelectThread,threadId:f,projectId:r,focusInput:!0})}catch(e){throw d&&f&&(t({type:Y.RemoveCreatingThread,projectId:r,threadId:f}),t({type:Y.RemoveProcessingThread,threadId:f})),n({title:`Thread Creation Failed`,description:e instanceof Error?e.message:String(e),variant:`destructive`}),e}}catch(e){console.error(`Failed to create thread:`,e);let r=`Failed to create thread: ${e instanceof Error?e.message:`Unknown error`}`;throw t({type:Y.AppendTerminalLine,line:{type:`error`,content:r}}),n({variant:`destructive`,title:`Thread Creation Failed`,description:r}),e}},[o,t,e.projects,n]),f=(0,Z.useCallback)(async(n,r)=>{t({type:Y.AddDeletingThread,threadId:r});try{await Ee(n,r),P(),await o(),e.selectedThreadId===r&&t({type:Y.SelectThread,threadId:``,projectId:``})}catch(e){console.error(`Failed to delete thread:`,e)}finally{t({type:Y.RemoveDeletingThread,threadId:r})}},[o,e.selectedThreadId,t]),p=(0,Z.useCallback)(async n=>{t({type:Y.AddDeletingProject,projectId:n});let r=e.projects.find(e=>e.projectId===n)?.threads.map(e=>e.threadId)??[];for(let e of r)t({type:Y.AddDeletingThread,threadId:e});try{await F(n),await o(),e.selectedProjectId===n&&t({type:Y.SelectThread,threadId:``,projectId:``})}catch(e){console.error(`Failed to delete project:`,e)}finally{t({type:Y.RemoveDeletingProject,projectId:n});for(let e of r)t({type:Y.RemoveDeletingThread,threadId:e})}},[o,e.selectedProjectId,e.projects,t]),m=(0,Z.useCallback)(async e=>{let n=i;if(a(null),!n||!e)return;let{projectId:r,command:s,remainingScripts:c}=n,l=[s,...c||[]];try{t({type:Y.SetCreatingProject,isCreating:!0}),t({type:Y.SetTerminalOpen,open:!0}),t({type:Y.AppendTerminalLine,line:{type:`system`,content:`Installing dependencies for ${l.length} package${l.length===1?``:`s`}...`}});for(let e=0;e<l.length;e++){let n=l[e],i=n.match(/^cd "([^"]+)" && (.+)$/),a=i?i[1]:`root`;t({type:Y.AppendTerminalLine,line:{type:`system`,content:`Installing package ${e+1}/${l.length} in ${a}...`}}),t({type:Y.AppendTerminalLine,line:{type:`output`,content:`📦 Installing dependencies in ${a}: ${n}`}});let o=await Ct(r,n,!0);if(o){let e=o.getReader(),n=new TextDecoder,r=``;for(;;){let{done:i,value:a}=await e.read();if(i)break;r+=n.decode(a,{stream:!0});let o=r.split(`
80
+ `);r=o.pop()??``;for(let e of o)if(e.trim())try{let n=JSON.parse(e);typeof n==`string`?t({type:Y.AppendTerminalLine,line:{type:`output`,content:n}}):n.type===`error`&&t({type:Y.AppendTerminalLine,line:{type:`error`,content:n.message}})}catch{t({type:Y.AppendTerminalLine,line:{type:`output`,content:e}})}}if(r.trim())try{let e=JSON.parse(r);typeof e==`string`?t({type:Y.AppendTerminalLine,line:{type:`output`,content:e}}):e.type===`error`&&t({type:Y.AppendTerminalLine,line:{type:`error`,content:e.message}})}catch{t({type:Y.AppendTerminalLine,line:{type:`output`,content:r}})}}e<l.length-1&&(t({type:Y.AppendTerminalLine,line:{type:`system`,content:``}}),t({type:Y.AppendTerminalLine,line:{type:`system`,content:`---`}}),t({type:Y.AppendTerminalLine,line:{type:`system`,content:``}}))}t({type:Y.AppendTerminalLine,line:{type:`system`,content:`All dependencies installed successfully!`}}),t({type:Y.SetCreatingProject,isCreating:!1}),await o()}catch(e){t({type:Y.SetCreatingProject,isCreating:!1}),console.error(`Failed to run setup script:`,e),t({type:Y.AppendTerminalLine,line:{type:`error`,content:`Failed to run setup script: ${e instanceof Error?e.message:`Unknown error`}`}})}},[i,t,o]);(0,Z.useEffect)(()=>{let n=!0;async function r(){try{t({type:Y.SetProjectsLoading,projectsLoading:!0});let r=await st();if(!n)return;if(t({type:Y.SetProjects,projects:r.projects}),!e.selectedThreadId)for(let e of r.projects){let n=e.threads.find(e=>e.isSelected);if(n){t({type:Y.SelectThread,threadId:n.threadId,projectId:e.projectId});break}}}catch(e){console.error(`Failed to load projects:`,e)}finally{n&&t({type:Y.SetProjectsLoading,projectsLoading:!1})}}return r(),()=>{n=!1}},[t,e.selectedThreadId,e.configUpdatedAt]);let h=(0,Z.useCallback)(async()=>{await c({apiCall:j,initialMessage:`Opening folder...`,optimisticProjectName:`Opening folder...`,useTerminalDispatch:!0,handleSetupScript:!0,logTag:`open folder`,catchErrorPrefix:`Failed to open folder`})},[c]);return{projects:e.projects,selectedProjectId:e.selectedProjectId,selectedThreadId:e.selectedThreadId,refreshProjects:o,handleSelectThread:s,handleCreateProject:l,handleCreateWebApp:u,handleOpenFolder:h,handleCreateThread:d,handleDeleteThread:f,confirmDeleteProject:p,pendingSetupScriptConfirmation:i,resolveSetupScriptConfirmation:m}}function dc(){let e=(0,Q.c)(2),[t,n]=(0,Z.useState)(fc),r,i;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{let e=()=>n(!0),t=()=>n(!1);return window.addEventListener(`focus`,e),window.addEventListener(`blur`,t),()=>{window.removeEventListener(`focus`,e),window.removeEventListener(`blur`,t)}},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),(0,Z.useEffect)(r,i),t}function fc(){return document.hasFocus()}var pc=null;function mc(){pc??=new Audio(`/pop.wav`),pc.currentTime=0,pc.play().catch(e=>{console.debug(`Could not play completion sound:`,e)})}function hc(){let{state:e,dispatch:t}=Nr(),n=dc(),r=(0,Z.useRef)(null),i=(0,Z.useRef)(!1),a=(0,Z.useRef)([]),o=(0,Z.useRef)(e),s=(0,Z.useRef)(n);(0,Z.useEffect)(()=>{o.current=e},[e]),(0,Z.useEffect)(()=>{s.current=n},[n]);let c=(0,Z.useCallback)(async()=>{try{let e=await et(),n=a.current.filter(t=>!e.includes(t));for(let e of n)e!==o.current.selectedThreadId&&t({type:Y.MarkThreadCompleted,threadId:e});return n.length>0&&!s.current&&mc(),a.current=e,t({type:Y.SetProcessingThreads,threadIds:e}),e}catch(e){return console.error(`Failed to fetch processing threads:`,e),[]}},[t]);(0,Z.useEffect)(()=>{let e=()=>{if(r.current||i.current)return;i.current=!0;let e=async()=>{(await c()).length>0||o.current.isStreaming||o.current.isCreatingProject?r.current=setTimeout(e,1e3):(r.current=null,i.current=!1)};e()},t=()=>{r.current&&=(clearTimeout(r.current),null),i.current=!1};return e(),()=>{t()}},[e.isStreaming,e.isCreatingProject,c]);let l=(0,Z.useCallback)(e=>{t({type:Y.ClearThreadCompleted,threadId:e})},[t]);return{processingThreadIds:e.processingThreadIds,completedThreadIds:e.completedThreadIds,isThreadProcessing:t=>e.processingThreadIds.includes(t),isThreadCompleted:t=>e.completedThreadIds.includes(t),clearCompleted:l}}var gc=768;function _c(){let e=(0,Q.c)(2),[t,n]=Z.useState(void 0),r,i;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{let e=window.matchMedia(`(max-width: ${gc-1}px)`),t=()=>{n(window.innerWidth<gc)};return e.addEventListener(`change`,t),n(window.innerWidth<gc),()=>e.removeEventListener(`change`,t)},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),Z.useEffect(r,i),!!t}var vc=(0,Z.lazy)(()=>cr(()=>import(`./terminal-panel-BxS2vp4u.js`).then(e=>({default:e.TerminalPanel})),__vite__mapDeps([13,1,0,11,14]))),yc=(0,Z.lazy)(()=>cr(()=>import(`./todos-view-E35eshII.js`).then(e=>({default:e.TodosView})),[])),bc=(0,Z.lazy)(()=>cr(()=>import(`./diff-view-B2VYMGHR.js`),__vite__mapDeps([9,1,5,6,0,7,10,8,11,12]))),xc=(0,Z.lazy)(()=>cr(()=>import(`./explorer-tab-view-CROJs14G.js`),__vite__mapDeps([15,1,5,6,0,7,11,14]))),Sc=(0,Z.lazy)(()=>cr(()=>import(`./browser-tab-C9hYTMS0.js`).then(e=>({default:e.BrowserTab})),__vite__mapDeps([16,1,0,11,14]))),Cc=(0,Z.lazy)(()=>cr(()=>import(`./dialogs-config-CteuxXdD.js`).then(e=>e.t),__vite__mapDeps([0,1]))),wc=(0,Z.lazy)(()=>cr(()=>import(`./onboarding-dialog-DdeXtx1_.js`),__vite__mapDeps([17,18,1,6,0]))),Tc=(0,Z.lazy)(()=>cr(()=>import(`./conversation-history-view-cEjKqUjG.js`),__vite__mapDeps([19,6,1,0]))),Ec=(0,Z.lazy)(()=>cr(()=>import(`./settings-view-CrZ7av2I.js`),__vite__mapDeps([20,1,5,6,0,7])));function Dc(){let{state:e,dispatch:t}=Nr(),n=hr(),r=br(),i=_c(),{projects:a,handleSelectThread:o,handleCreateProject:s,handleCreateWebApp:c,handleOpenFolder:l,handleCreateThread:u,handleDeleteThread:d,confirmDeleteProject:f,refreshProjects:p,pendingSetupScriptConfirmation:m,resolveSetupScriptConfirmation:h}=uc(),{processingThreadIds:g,completedThreadIds:_,clearCompleted:v}=hc(),[y,b]=(0,Z.useState)(`chat`),[x,S]=(0,Z.useState)(null),[C,w]=(0,Z.useState)(!1),[T,E]=(0,Z.useState)(!1),[D,O]=(0,Z.useState)(!1),[k,A]=(0,Z.useState)(null),[j,M]=(0,Z.useState)(0),[N,P]=(0,Z.useState)(null),[F,I]=(0,Z.useState)(0),{terminalState:L}=Br(e.selectedThreadId),R=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{L.open&&e.selectedThreadId===R.current&&b(`terminal`),R.current=e.selectedThreadId},[L.open,e.selectedThreadId]);let[z,B]=(0,Z.useState)(!1),[V,H]=(0,Z.useState)(!1),[U,W]=(0,Z.useState)(!1),[G,ee]=(0,Z.useState)(null),[te,ne]=(0,Z.useState)(!1),[K,re]=(0,Z.useState)(!1),ie=(0,Z.useRef)(null),ae=r.pathname.startsWith(`/settings`),oe=r.pathname===`/review`,q=r.pathname===`/todos`;(0,Z.useEffect)(()=>{r.pathname===`/`&&y===`tasks`&&b(`chat`)},[r.pathname]);let se=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{let n=ae||oe||q;if(n&&se.current===null)se.current=e.sidebarOpen,e.sidebarOpen&&t({type:Y.ToggleSidebar});else if(!n&&se.current!==null){let n=se.current;se.current=null,n&&!e.sidebarOpen&&t({type:Y.ToggleSidebar})}},[ae,oe,q]),(0,Z.useEffect)(()=>{(async()=>{try{(await ke()).updateAvailable&&ne(!0)}catch{}})()},[]);let ce=(0,Z.useCallback)(async()=>{re(!0);try{await Tn()}catch{re(!1)}},[]);(0,Z.useEffect)(()=>{U||(async()=>{try{(await vn()).onboardingCompleted||H(!0)}catch(e){console.error(`Failed to check onboarding status:`,e)}finally{W(!0)}})()},[U]),(0,Z.useEffect)(()=>{V||t({type:Y.ConfigUpdated})},[V,t]);let le=(0,Z.useCallback)(e=>{let t=a.find(t=>t.projectId===e);t&&ee({id:t.projectId,name:Ue(t)})},[a]),ue=(0,Z.useCallback)(e=>{u(e,void 0)},[u]),de=(0,Z.useCallback)(async(a,s)=>{v(s),r.pathname!==`/`&&n(`/`),b(`chat`),e.selectedThreadId!==s&&I(e=>e+1),await o(a,s),i&&e.sidebarOpen&&t({type:Y.ToggleSidebar})},[o,i,e.sidebarOpen,e.selectedThreadId,t,v,r.pathname,n]);(0,Z.useEffect)(()=>{e.sidebarOpen?ie.current?.expand():ie.current?.collapse()},[e.sidebarOpen]);let fe={activeMainTab:y,setActiveMainTab:b,devServerUrl:x,setDevServerUrl:S,devServerRunning:C,setDevServerRunning:w,devServerLoading:T,setDevServerLoading:E,terminalNotification:D,setTerminalNotification:O,pendingExplorerPath:k,setPendingExplorerPath:A,explorerRefreshTick:j,triggerExplorerRefresh:()=>M(e=>e+1),explorerClearPath:N,setExplorerClearPath:P,browserResetTrigger:F,triggerBrowserReset:()=>I(e=>e+1)};return(0,$.jsx)(ni.Provider,{value:fe,children:(0,$.jsxs)(qr,{delayDuration:200,children:[(0,$.jsxs)(Ys,{direction:`horizontal`,className:`h-screen bg-background`,children:[(0,$.jsx)(Xs,{ref:ie,defaultSize:i?100:25,minSize:i?50:12,maxSize:i?100:32,collapsible:!0,collapsedSize:0,className:`border-r border-transparent`,children:(0,$.jsx)(`div`,{className:`h-full overflow-hidden`,children:(0,$.jsx)(Ci,{projects:a,selectedThreadId:e.selectedThreadId,selectedProjectId:e.selectedProjectId,processingThreadIds:g,completedThreadIds:_,deletingThreadIds:e.deletingThreadIds,deletingProjectIds:e.deletingProjectIds,onSelectThread:de,onCreateProject:()=>B(!0),onCreateThread:ue,onDeleteThread:d,onDeleteProject:le,onNavigateToSettings:()=>void n(`/settings/providers`),onDeselect:()=>t({type:Y.ClearSelection}),updateAvailable:te,updatingApp:K,onUpdateApp:ce,onRefreshProjects:p})})}),!i&&(0,$.jsx)(Zs,{withHandle:!0,className:e.sidebarOpen?`ml-[-40px]`:``}),(0,$.jsx)(Xs,{minSize:40,className:`overflow-hidden ${i&&e.sidebarOpen?`hidden`:``}`,children:(0,$.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden`,children:[!oe&&!ae&&!q&&(0,$.jsx)(Us,{}),!oe&&!ae&&!q&&e.selectedThreadId&&(0,$.jsx)(`div`,{className:`flex border-b border-border shrink-0`,children:[`Chat`,`Explorer`,`Review`,`Browser`,`Terminal`,`Tasks`,`History`].map(e=>{let t=e.toLowerCase();return(0,$.jsxs)(`button`,{onClick:()=>{b(t),t===`terminal`&&O(!1)},className:`relative px-4 py-2 text-sm font-medium transition-colors ${y===t?`border-b-2 border-primary text-foreground -mb-px`:`text-muted-foreground hover:text-foreground`}`,children:[e,t===`terminal`&&D&&y!==`terminal`&&(0,$.jsx)(`span`,{className:`absolute top-1.5 right-1 h-1.5 w-1.5 rounded-full bg-brand`})]},t)})}),(0,$.jsx)(`main`,{className:`flex-1 overflow-hidden${!oe&&!ae&&!q&&y!==`chat`?` hidden`:``}`,children:(0,$.jsxs)(Cr,{children:[(0,$.jsx)(mr,{path:`/settings/:tab?`,element:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Ec,{})})}),(0,$.jsx)(mr,{path:`/settings/project/:projectId`,element:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Ec,{})})}),(0,$.jsx)(mr,{path:`/settings/add-skill`,element:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Ec,{})})}),(0,$.jsx)(mr,{path:`/settings/add-command`,element:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Ec,{})})}),(0,$.jsx)(mr,{path:`/settings/mcp-server-edit`,element:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Ec,{})})}),(0,$.jsx)(mr,{path:`*`,element:(0,$.jsx)(Oo,{onCreateThread:ue})})]})}),(0,$.jsx)(`div`,{className:`flex-1 overflow-hidden${y===`terminal`&&!oe&&!ae&&!q?``:` hidden`}`,children:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(vc,{})})}),(0,$.jsx)(`div`,{className:`flex-1 overflow-hidden${y===`browser`&&!oe&&!ae&&!q?``:` hidden`}`,children:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Sc,{})})}),!oe&&!ae&&!q&&y!==`chat`&&y!==`terminal`&&y!==`browser`&&(y===`explorer`?(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(xc,{})}):y===`tasks`&&e.selectedProjectId?(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(yc,{projectId:e.selectedProjectId})}):y===`history`?(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Tc,{isOpen:!0,onClose:()=>b(`chat`),initialFilter:e.selectedProjectId?{type:`project`,id:e.selectedProjectId}:void 0,projects:a,inline:!0})}):y===`review`&&e.selectedThreadId?(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(bc,{threadId:e.selectedThreadId,onExit:()=>b(`chat`)})}):(0,$.jsx)(`div`,{className:`flex-1 overflow-hidden`}))]})}),(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Cc,{open:z,onOpenChange:B,onSubmitClone:s,onSubmitWebApp:c,onOpenFolder:l})}),(0,$.jsx)(Ws,{open:G!==null,projectName:G?.name,onOpenChange:e=>!e&&ee(null),onConfirm:()=>{G&&(f(G.id),ee(null))}}),(0,$.jsx)(Gs,{open:m!==null,setupScripts:m?[m.command,...m.remainingScripts||[]]:[],onConfirm:h}),(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(wc,{open:V,onOpenChange:H,onComplete:()=>{W(!0),p()}})}),(0,$.jsx)(qs,{})]}),(0,$.jsx)(oc,{})]})})}function Oc(){let e=(0,Q.c)(5),[t,n]=(0,Z.useReducer)(Hr,Lr),r;e[0]===t?r=e[1]:(r={state:t,dispatch:n},e[0]=t,e[1]=r);let i;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(Dc,{}),e[2]=i):i=e[2];let a;return e[3]===r?a=e[4]:(a=(0,$.jsx)(lc,{attribute:`class`,defaultTheme:`system`,enableSystem:!0,storageKey:`tarsk-theme`,children:(0,$.jsx)(zr.Provider,{value:r,children:i})}),e[3]=r,e[4]=a),a}var kc=!1;window.addEventListener(`resize`,()=>{kc||=(window.__electrobunWebviewId&&(document.body.style.height=`calc(100% - 26px)`),!0)}),(0,ri.createRoot)(document.getElementById(`root`)).render((0,$.jsx)(Z.StrictMode,{children:(0,$.jsx)(fr,{children:(0,$.jsx)(Oc,{})})}));export{gi as _,Ls as a,oi as b,vs as c,ro as d,bi as f,fi as g,vi as h,Ps as i,Ao as l,_i as m,Xs as n,Fs as o,li as p,Ys as r,Is as s,Zs as t,To as u,hi as v,ci as y};