tarsk 0.4.21 → 0.4.23

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 (49) hide show
  1. package/dist/index.js +543 -352
  2. package/dist/public/assets/{account-view-D1kGyryt.js → account-view-D5WVMsrD.js} +1 -1
  3. package/dist/public/assets/{alert-dialog-Bk7neo_n.js → alert-dialog-2Kcr7vcf.js} +1 -1
  4. package/dist/public/assets/{api-DL5XaoTS.js → api-XK7H2gI0.js} +1 -1
  5. package/dist/public/assets/{browser-tab-BUOT-D_w.js → browser-tab-CgLMsYM8.js} +1 -1
  6. package/dist/public/assets/chat-input-container-VXGAcgnU.js +1 -0
  7. package/dist/public/assets/context-menu-sx0fb5uQ.js +1 -0
  8. package/dist/public/assets/conversation-history-view-IVxKEbP_.js +1 -0
  9. package/dist/public/assets/{dialogs-config-DmDjliuA.js → dialogs-config-3Hr2GRdt.js} +2 -2
  10. package/dist/public/assets/{diff-view-DXIv51Tn.js → diff-view-v-bVp3Zf.js} +2 -2
  11. package/dist/public/assets/{explorer-tab-view-tyn_6pBh.js → explorer-tab-view-CsPSJADk.js} +2 -2
  12. package/dist/public/assets/explorer-tree-DXXm8_b9.js +1 -0
  13. package/dist/public/assets/{explorer-view-Bw3-gTSX.js → explorer-view-8g0_dmv4.js} +1 -1
  14. package/dist/public/assets/history-view-Cyhu-ped.js +1 -0
  15. package/dist/public/assets/index-DsX2aOD3.js +50 -0
  16. package/dist/public/assets/onboarding-DzgFi5ix.js +1 -0
  17. package/dist/public/assets/onboarding-dialog-lFFrB1GZ.js +1 -0
  18. package/dist/public/assets/{page-toolbar-CvreDTwj.js → page-toolbar-De9hbhUD.js} +1 -1
  19. package/dist/public/assets/{project-settings-view-BJYR_l3u.js → project-settings-view-CVYvsVWo.js} +1 -1
  20. package/dist/public/assets/{provider-details-view-B1eTEo0M.js → provider-details-view-Cp_INkPg.js} +1 -1
  21. package/dist/public/assets/providers-sidebar-Dc3Gk1we.js +1 -0
  22. package/dist/public/assets/react-vendor-4OUTOTE0.js +17 -0
  23. package/dist/public/assets/resizable-D62plzWh.js +1 -0
  24. package/dist/public/assets/{run-stop-button-iZHomql0.js → run-stop-button-ClYpPnNG.js} +2 -2
  25. package/dist/public/assets/{settings-view-C38jeeqJ.js → settings-view-BWQrM94z.js} +2 -2
  26. package/dist/public/assets/{side-panel-container-BqWSTCOr.js → side-panel-container-Bkpb7_cb.js} +2 -2
  27. package/dist/public/assets/{standard-list-item-CpBjveM0.js → standard-list-item-DUKJ8HEG.js} +1 -1
  28. package/dist/public/assets/{store-CAPnOXso.js → store-CJdxpohI.js} +1 -1
  29. package/dist/public/assets/{tab-context-Bmd79Rk0.js → tab-context-D2auNMAI.js} +1 -1
  30. package/dist/public/assets/{tabs-DEmnnGvq.js → tabs-DI_KCGYt.js} +1 -1
  31. package/dist/public/assets/{terminal-panel-r8cb3-tk.js → terminal-panel-4EVJwsCQ.js} +2 -2
  32. package/dist/public/assets/{textarea-BjfyGfGR.js → textarea-Dg4M60Yx.js} +1 -1
  33. package/dist/public/assets/todos-view-D3JYa8fa.js +1 -0
  34. package/dist/public/assets/{use-toast-C9B1H3P9.js → use-toast-C3jyoS6i.js} +1 -1
  35. package/dist/public/assets/{utils-BG_JNnOl.js → utils-4yrqj6yI.js} +1 -1
  36. package/dist/public/index.html +18 -18
  37. package/package.json +1 -1
  38. package/dist/public/assets/chat-input-container-2a99CMGs.js +0 -1
  39. package/dist/public/assets/context-menu-DHHElhQ1.js +0 -1
  40. package/dist/public/assets/conversation-history-view-HVFzgO9e.js +0 -1
  41. package/dist/public/assets/explorer-tree-DOg67ane.js +0 -1
  42. package/dist/public/assets/history-view-BOjZoBCb.js +0 -1
  43. package/dist/public/assets/index-DAw9BEzt.js +0 -50
  44. package/dist/public/assets/onboarding-BgEjTEKs.js +0 -1
  45. package/dist/public/assets/onboarding-dialog-EiVl-ynw.js +0 -1
  46. package/dist/public/assets/providers-sidebar-Df50eL_5.js +0 -1
  47. package/dist/public/assets/react-vendor-CaS5zjF7.js +0 -17
  48. package/dist/public/assets/resizable-DJ5w1ZWX.js +0 -1
  49. package/dist/public/assets/todos-view-MAb840dD.js +0 -1
@@ -0,0 +1,50 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/account-view-D5WVMsrD.js","assets/rolldown-runtime-B1FJdls4.js","assets/dialogs-config-3Hr2GRdt.js","assets/use-toast-C3jyoS6i.js","assets/project-settings-view-CVYvsVWo.js","assets/react-vendor-4OUTOTE0.js","assets/history-view-Cyhu-ped.js","assets/monaco-c-HyCuEi.js","assets/textarea-Dg4M60Yx.js","assets/dist-CIGnaqp2.js","assets/diff-view-v-bVp3Zf.js","assets/chat-input-container-VXGAcgnU.js","assets/onboarding-DzgFi5ix.js","assets/alert-dialog-2Kcr7vcf.js","assets/store-CJdxpohI.js","assets/tab-context-D2auNMAI.js","assets/page-toolbar-De9hbhUD.js","assets/context-menu-sx0fb5uQ.js","assets/resizable-D62plzWh.js","assets/standard-list-item-DUKJ8HEG.js","assets/utils-4yrqj6yI.js","assets/terminal-panel-4EVJwsCQ.js","assets/explorer-tab-view-CsPSJADk.js","assets/browser-tab-CgLMsYM8.js","assets/run-stop-button-ClYpPnNG.js","assets/onboarding-dialog-lFFrB1GZ.js","assets/conversation-history-view-IVxKEbP_.js","assets/settings-view-BWQrM94z.js","assets/side-panel-container-Bkpb7_cb.js"])))=>i.map(i=>d[i]);
2
+ import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{$r as t,$t as n,A as r,Ar as i,At as a,B as o,Bn as s,Cn as c,Cr as l,Dn as u,Dr as d,Dt as f,E as p,Ei as m,En as h,Et as g,F as _,Fr as v,Ft as y,Gi as b,Gr as x,Gt as S,Hi as C,Hn as w,Hr as T,Ht as E,I as D,Ii as O,In as k,Ir as A,It as j,J as M,Ji as N,Jn as P,Jr as F,Jt as I,Ki as L,Kn as R,Kr as z,Kt as ee,L as B,Lr as te,Lt as ne,M as V,Mi as re,Mn as H,Mr as ie,Mt as ae,N as oe,Nn as se,Nr as ce,Nt as le,O as ue,Oi as de,Or as fe,Ot as pe,P as me,Pn as U,Pr as he,Pt as ge,Qi as _e,R as ve,Ri as ye,Rn as be,Rt as xe,S as W,Si as Se,Sn as Ce,Ti as we,Tn as Te,Un as Ee,Ur as De,Ut as Oe,Vn as ke,Vt as Ae,Wi as je,Wn as G,Wt as Me,X as Ne,Xi as Pe,Yi as Fe,Yr as Ie,Zi as Le,Zr as Re,Zt as ze,_ as Be,_n as Ve,_t as He,aa as Ue,ai as We,an as Ge,bi as Ke,bn as qe,bt as Je,ct as Ye,da as Xe,dn as Ze,dt as Qe,ea as $e,ei as et,en as tt,et as nt,f as rt,ft as it,g as at,gi as ot,gt as st,h as ct,hi as lt,hn as ut,ht as dt,ia as ft,ii as pt,in as mt,it as ht,j as gt,ji as _t,jr as vt,k as yt,ki as bt,kn as xt,kr as St,la as Ct,li as wt,lt as Tt,mi as Et,mt as Dt,na as Ot,ni as kt,nn as At,o as jt,oi as Mt,on as Nt,ot as Pt,p as Ft,pi as It,pt as Lt,qi as Rt,qn as zt,qr as Bt,qt as Vt,ra as Ht,ri as Ut,sa as Wt,si as Gt,st as Kt,ta as qt,ti as Jt,tn as Yt,ua as Xt,un as Zt,ut as Qt,v as $t,vn as en,vt as tn,wn as nn,wt as rn,x as an,xt as on,z as sn,zi as cn,zn as ln,zr as un,zt as dn}from"./dialogs-config-3Hr2GRdt.js";import{$ as fn,A as pn,C as mn,G as hn,H as gn,I as _n,K as vn,L as yn,M as bn,N as xn,O as Sn,P as Cn,Q as wn,R as Tn,S as En,U as Dn,V as On,W as kn,b as An,et as jn,ft as Mn,gt as Nn,ht as Pn,j as Fn,k as In,mt as Ln,nt as Rn,pt as zn,q as Bn,tt as Vn,v as Hn,vt as Un,w as Wn,x as Gn,y as Kn,yt as qn,z as Jn}from"./react-vendor-4OUTOTE0.js";import{a as Yn,c as Xn,d as Zn,f as Qn,i as $n,n as er,o as tr,p as nr,r as rr,t as K}from"./store-CJdxpohI.js";import{t as ir}from"./textarea-Dg4M60Yx.js";import{c as q,l as ar,s as J,u as Y}from"./history-view-Cyhu-ped.js";import{a as or,c as sr,i as cr,l as lr,n as ur,o as dr,r as fr,s as pr,t as mr}from"./chat-input-container-VXGAcgnU.js";import{n as hr,t as X}from"./use-toast-C3jyoS6i.js";import{t as gr}from"./standard-list-item-DUKJ8HEG.js";import{a as _r,c as vr,i as yr,n as br,o as xr,r as Sr,s as Cr,t as wr}from"./alert-dialog-2Kcr7vcf.js";import{n as Tr,t as Er}from"./utils-4yrqj6yI.js";import{t as Dr}from"./side-panel-container-Bkpb7_cb.js";import{n as Or,t as kr}from"./tab-context-D2auNMAI.js";import{n as Ar,r as jr}from"./onboarding-DzgFi5ix.js";import{n as Mr,t as Nr}from"./run-stop-button-ClYpPnNG.js";import{i as Pr,n as Fr,r as Ir,t as Lr}from"./tabs-DI_KCGYt.js";import{t as Rr}from"./page-toolbar-De9hbhUD.js";import{n as zr,r as Br,t as Vr}from"./resizable-D62plzWh.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 Z=e(Xe(),1),Hr=qn(),Q=Ct(),Ur=1e10,Wr=1e3;function Gr(e,t){let n=e.map(e=>`"${e}"`).join(`, `);return Error(`This RPC instance cannot ${t} because the transport did not provide one or more of these methods: ${n}`)}function Kr(e={}){let t={},n={},r;function i(e){n.unregisterHandler&&n.unregisterHandler(),n=e,n.registerHandler?.(x)}function a(e){if(typeof e==`function`){r=e;return}r=(t,n)=>{let r=e[t];if(r)return r(n);let i=e._;if(!i)throw Error(`The requested method has no handler: ${String(t)}`);return i(t,n)}}let{maxRequestTime:o=Wr}=e;e.transport&&i(e.transport),e.requestHandler&&a(e.requestHandler),e._debugHooks&&(t=e._debugHooks);let s=0;function c(){return s<=Ur?++s:s=0}let l=new Map,u=new Map;function d(e,...r){let i=r[0];return new Promise((r,a)=>{if(!n.send)throw Gr([`send`],`make requests`);let s=c(),d={type:`request`,id:s,method:e,params:i};l.set(s,{resolve:r,reject:a}),o!==1/0&&u.set(s,setTimeout(()=>{u.delete(s),l.delete(s),a(Error(`RPC request timed out.`))},o)),t.onSend?.(d),n.send(d)})}let f=new Proxy(d,{get:(e,t,n)=>t in e?Reflect.get(e,t,n):e=>d(t,e)}),p=f;function m(e,...r){let i=r[0];if(!n.send)throw Gr([`send`],`send messages`);let a={type:`message`,id:e,payload:i};t.onSend?.(a),n.send(a)}let h=new Proxy(m,{get:(e,t,n)=>t in e?Reflect.get(e,t,n):e=>m(t,e)}),g=h,_=new Map,v=new Set;function y(e,t){if(!n.registerHandler)throw Gr([`registerHandler`],`register message listeners`);if(e===`*`){v.add(t);return}_.has(e)||_.set(e,new Set),_.get(e).add(t)}function b(e,t){if(e===`*`){v.delete(t);return}_.get(e)?.delete(t),_.get(e)?.size===0&&_.delete(e)}async function x(e){if(t.onReceive?.(e),!(`type`in e))throw Error(`Message does not contain a type.`);if(e.type===`request`){if(!n.send||!r)throw Gr([`send`,`requestHandler`],`handle requests`);let{id:i,method:a,params:o}=e,s;try{s={type:`response`,id:i,success:!0,payload:await r(a,o)}}catch(e){if(!(e instanceof Error))throw e;s={type:`response`,id:i,success:!1,error:e.message}}t.onSend?.(s),n.send(s);return}if(e.type===`response`){let t=u.get(e.id);t!=null&&clearTimeout(t),u.delete(e.id);let{resolve:n,reject:r}=l.get(e.id)??{};l.delete(e.id),e.success?n?.(e.payload):r?.(Error(e.error));return}if(e.type===`message`){for(let t of v)t(e.id,e.payload);let t=_.get(e.id);if(!t)return;for(let n of t)n(e.payload);return}throw Error(`Unexpected RPC message type: ${e.type}`)}return{setTransport:i,setRequestHandler:a,request:f,requestProxy:p,send:h,sendProxy:g,addMessageListener:y,removeMessageListener:b,proxy:{send:g,request:p}}}function qr(e,t){let n=Kr({maxRequestTime:t.maxRequestTime,requestHandler:{...t.handlers.requests,...t.extraRequestHandlers},transport:{registerHandler:()=>{}}}),r=t.handlers.messages;return r&&n.addMessageListener(`*`,((e,t)=>{let n=r[`*`];n&&n(e,t);let i=r[e];i&&i(t)})),n}var Jr=window.__electrobunWebviewId,Yr=window.__electrobunRpcSocketPort,Xr=class{bunSocket;rpc;rpcHandler;constructor(e){this.rpc=e.rpc,this.init()}init(){this.initSocketToBun(),window.__electrobun.receiveMessageFromBun=this.receiveMessageFromBun.bind(this),this.rpc&&this.rpc.setTransport(this.createTransport())}initSocketToBun(){let e=new WebSocket(`ws://localhost:${Yr}/socket?webviewId=${Jr}`);this.bunSocket=e,e.addEventListener(`open`,()=>{}),e.addEventListener(`message`,async e=>{let t=e.data;if(typeof t==`string`)try{let e=JSON.parse(t),n=await window.__electrobun_decrypt(e.encryptedData,e.iv,e.tag);this.rpcHandler?.(JSON.parse(n))}catch(e){console.error(`Error parsing bun message:`,e)}else t instanceof Blob||console.error(`UNKNOWN DATA TYPE RECEIVED:`,e.data)}),e.addEventListener(`error`,e=>{console.error(`Socket error:`,e)}),e.addEventListener(`close`,e=>{})}createTransport(){let e=this;return{send(t){try{let n=JSON.stringify(t);e.bunBridge(n)}catch(e){console.error(`bun: failed to serialize message to webview`,e)}},registerHandler(t){e.rpcHandler=t}}}async bunBridge(e){if(this.bunSocket?.readyState===WebSocket.OPEN)try{let{encryptedData:t,iv:n,tag:r}=await window.__electrobun_encrypt(e),i=JSON.stringify({encryptedData:t,iv:n,tag:r});this.bunSocket.send(i);return}catch(e){console.error(`Error sending message to bun via socket:`,e)}window.__electrobunBunBridge?.postMessage(e)}receiveMessageFromBun(e){this.rpcHandler&&this.rpcHandler(e)}static defineRPC(e){return qr(`webview`,{...e,extraRequestHandlers:{evaluateJavascriptWithResponse:({script:e})=>new Promise(t=>{try{let n=Function(e)();n instanceof Promise?n.then(e=>{t(e)}).catch(e=>{console.error(`bun: async script execution failed`,e),t(String(e))}):t(n)}catch(e){console.error(`bun: failed to eval script`,e),t(String(e))}})}})}},$=l();function Zr(e){let t=(0,Q.c)(47),{open:n,onOpenChange:r,feedbackName:i,onFeedbackNameChange:a,feedbackEmail:o,onFeedbackEmailChange:c,feedbackText:l,onFeedbackTextChange:u,loadingFeedbackUser:d,submittingFeedback:f,onSubmit:p}=e,m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsxs)(w,{children:[(0,$.jsx)(Ee,{children:`Send Feedback`}),(0,$.jsx)(s,{children:`Share feedback about Tarsk.`})]}),t[0]=m):m=t[0];let h;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(H,{htmlFor:`feedback-name`,children:`Name`}),t[1]=h):h=t[1];let g;t[2]===a?g=t[3]:(g=e=>a(e.target.value),t[2]=a,t[3]=g);let _=f||d,v;t[4]!==i||t[5]!==g||t[6]!==_?(v=(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[h,(0,$.jsx)(se,{id:`feedback-name`,value:i,onChange:g,placeholder:`Your name`,disabled:_})]}),t[4]=i,t[5]=g,t[6]=_,t[7]=v):v=t[7];let y;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(H,{htmlFor:`feedback-email`,children:`Email`}),t[8]=y):y=t[8];let b;t[9]===c?b=t[10]:(b=e=>c(e.target.value),t[9]=c,t[10]=b);let x=f||d,S;t[11]!==o||t[12]!==b||t[13]!==x?(S=(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[y,(0,$.jsx)(se,{id:`feedback-email`,type:`email`,value:o,onChange:b,placeholder:`you@example.com`,disabled:x})]}),t[11]=o,t[12]=b,t[13]=x,t[14]=S):S=t[14];let C;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,$.jsx)(H,{htmlFor:`feedback-text`,children:`Feedback`}),t[15]=C):C=t[15];let T;t[16]===u?T=t[17]:(T=e=>u(e.target.value),t[16]=u,t[17]=T);let E;t[18]!==l||t[19]!==f||t[20]!==T?(E=(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[C,(0,$.jsx)(ir,{id:`feedback-text`,value:l,onChange:T,placeholder:`Tell us what you think...`,className:`min-h-32`,disabled:f})]}),t[18]=l,t[19]=f,t[20]=T,t[21]=E):E=t[21];let D;t[22]!==E||t[23]!==v||t[24]!==S?(D=(0,$.jsxs)(`div`,{className:`grid gap-4 py-2`,children:[v,S,E]}),t[22]=E,t[23]=v,t[24]=S,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]!==f||t[29]!==O?(k=(0,$.jsx)(U,{variant:`outline`,onClick:O,disabled:f,children:`Cancel`}),t[28]=f,t[29]=O,t[30]=k):k=t[30];let A;t[31]===f?A=t[32]:(A=f?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ot,{className:`mr-2 h-4 w-4 animate-spin`}),`Sending...`]}):`Send Feedback`,t[31]=f,t[32]=A);let j;t[33]!==p||t[34]!==f||t[35]!==A?(j=(0,$.jsx)(U,{onClick:p,disabled:f,children:A}),t[33]=p,t[34]=f,t[35]=A,t[36]=j):j=t[36];let M;t[37]!==k||t[38]!==j?(M=(0,$.jsxs)(ke,{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)(ln,{className:`max-w-xl`,children:[m,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)(be,{open:n,onOpenChange:r,children:N}),t[43]=r,t[44]=n,t[45]=N,t[46]=P):P=t[46],P}function Qr(){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),[d,f]=(0,Z.useState)(!1);return(0,Z.useEffect)(()=>{if(!e)return;let t=!0;return l(!0),Kt().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:d,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}f(!0);try{await u(`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{f(!1)}}}}function $r(e){let t=(0,Q.c)(8),{collapsed:n}=e,{theme:r,setTheme:i}=Tr();if(n)return null;let a;t[0]!==i||t[1]!==r?(a=()=>i(r===`dark`?`light`:`dark`),t[0]=i,t[1]=r,t[2]=a):a=t[2];let o,s,c;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(un,{className:`h-4 w-4 rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0`}),s=(0,$.jsx)(Gt,{className:`absolute h-4 w-4 rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100`}),c=(0,$.jsx)(`span`,{className:`sr-only`,children:`Toggle theme`}),t[3]=o,t[4]=s,t[5]=c):(o=t[3],s=t[4],c=t[5]);let l;return t[6]===a?l=t[7]:(l=(0,$.jsxs)(U,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground hover:text-background`,onClick:a,children:[o,s,c]}),t[6]=a,t[7]=l),l}function ei({threadId:e,currentConversationId:t,children:n}){let[r,i]=(0,Z.useState)(null),[o,s]=(0,Z.useState)(null),[c,l]=(0,Z.useState)(null),[u,d]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(null),[m,h]=(0,Z.useState)(!1),[_,v]=(0,Z.useState)(!1);if((0,Z.useEffect)(()=>{if(!m||_||!e)return;async function n(){d(!0),p(null);try{let n=(await g(e)).currentConversationId??t,[r,o]=await Promise.allSettled([a(e).catch(e=>{throw console.error(`Thread usage summary failed:`,e),e}),n?ht(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(o?.status===`fulfilled`&&o.value){if(s(o.value),o.value.model?.model){let e=o.value.model.model,t=o.value.model.provider,n=t&&e?`${t}/${e}`:e;console.log(`Fetching model info for:`,n,`(provider:`,t,`model:`,e+`)`),Qt(n).then(l).catch(e=>{console.warn(`Failed to fetch model info:`,e)})}}else if(o?.status===`rejected`)throw console.error(`Failed to fetch conversation usage:`,o.reason),o.reason;v(!0)}catch(e){console.error(`[TokenUsageTooltip] Failed to load usage data:`,e),p(`Failed to load usage data`)}finally{d(!1)}}n()},[m,_,e,t]),!e||e===``)return console.log(`[TokenUsageTooltip] No valid threadId, returning children only`),(0,$.jsx)($.Fragment,{children:n});let y=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)(J,{open:m,onOpenChange:e=>{h(e),!e&&_&&v(!1)},children:[(0,$.jsx)(Y,{asChild:!0,children:n}),(0,$.jsx)(q,{side:`top`,align:`center`,className:`max-w-xs`,children:(0,$.jsxs)(`div`,{className:`text-xs text-muted-foreground space-y-2`,children:[u&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Ot,{className:`h-3 w-3 animate-pulse`}),(0,$.jsx)(`span`,{children:`Loading usage...`})]}),f&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Ot,{className:`h-3 w-3`}),(0,$.jsx)(`span`,{children:`No usage information for this thread`})]}),!u&&!f&&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)(Ot,{className:`h-3 w-3`}),(0,$.jsxs)(`span`,{className:`font-medium`,children:[y(r.totalTokens),` tokens`]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(he,{className:`h-3 w-3`}),(0,$.jsxs)(`span`,{children:[r.conversationCount,` chats`]})]})]}),o&&(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)(fe,{className:`h-3 w-3`}),(0,$.jsxs)(`span`,{children:[((e,t)=>{let n=y(e);return t?`${n} (${Math.round(e/t*100)}%)`:n})(o.footprint?.totalTokens??o.usage.totalTokens,typeof c?.context_length==`number`?c.context_length:void 0),` `,`tokens`]})]}),o.model.model&&(0,$.jsxs)(`div`,{className:`text-muted-foreground`,children:[o.model.model,c?.context_length&&(0,$.jsxs)(`span`,{className:`ml-1`,children:[y(typeof c.context_length==`number`?c.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: `,y(r.totalInputTokens)]}),(0,$.jsxs)(`span`,{children:[`Out: `,y(r.totalOutputTokens)]}),(0,$.jsxs)(`span`,{children:[`Avg: `,y(r.averageTokensPerConversation),`/chat`]})]})]})]})})]}):(0,$.jsx)($.Fragment,{children:n})}function ti(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 g(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)(U,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground hover:text-background`,children:[(0,$.jsx)(he,{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)(ei,{threadId:n,currentConversationId:r,children:s}),t[4]=r,t[5]=n,t[6]=c):c=t[6],c}var ni=(0,Z.lazy)(()=>Un(()=>import(`./account-view-D5WVMsrD.js`),__vite__mapDeps([0,1,2,3]))),ri=(0,Z.lazy)(()=>Un(()=>import(`./project-settings-view-CVYvsVWo.js`),__vite__mapDeps([4,1,5,6,2,7,8,3])));function ii(e){let n=(0,Q.c)(101),{projects:r,selectedThreadId:i,selectedProjectId:a,processingThreadIds:o,completedThreadIds:s,deletingThreadIds:c,deletingProjectIds:l,onSelectThread:u,onCreateProject:d,onCreateThread:f,onDeleteThread:p,onDeleteProject:m,onNavigateToSettings:h,onDeselect:g,collapsed:_,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}=Qr(),L;n[0]===r?L=n[1]:(L=r.map(ai),n[0]=r,n[1]=L);let z=L,ee;n[2]!==_||n[3]!==d?(ee=!_&&(0,$.jsxs)(U,{variant:`outline`,size:`sm`,className:`gap-2`,onClick:d,children:[(0,$.jsx)(t,{className:`h-4 w-4 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:`New Project`})]}),n[2]=_,n[3]=d,n[4]=ee):ee=n[4];let B;n[5]!==_||n[6]!==b||n[7]!==v||n[8]!==y?(B=v&&(0,$.jsxs)(U,{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)(ot,{className:`h-4 w-4 animate-spin`}):(0,$.jsx)(cn,{className:`h-4 w-4`}),!_&&(0,$.jsx)(`span`,{className:`truncate`,children:y?`Updating...`:`Update to Latest`})]}),n[5]=_,n[6]=b,n[7]=v,n[8]=y,n[9]=B):B=n[9];let te;n[10]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,$.jsx)(Ot,{className:`h-4 w-4`}),n[10]=te):te=n[10];let ne;n[11]===_?ne=n[12]:(ne=!_&&(0,$.jsx)(`span`,{className:`truncate`,children:`Providers`}),n[11]=_,n[12]=ne);let V;n[13]!==h||n[14]!==ne?(V=(0,$.jsx)(`div`,{className:`flex items-center gap-1`,children:(0,$.jsxs)(U,{variant:`ghost`,size:`sm`,className:`justify-start gap-2 text-sidebar-foreground shrink-0`,onClick:h,children:[te,ne]})}),n[13]=h,n[14]=ne,n[15]=V):V=n[15];let re,H;n[16]===Symbol.for(`react.memo_cache_sentinel`)?(re=()=>C(!0),H=(0,$.jsx)(vt,{className:`h-4 w-4`}),n[16]=re,n[17]=H):(re=n[16],H=n[17]);let ie;n[18]===_?ie=n[19]:(ie=!_&&(0,$.jsx)(`span`,{className:`truncate`,children:`Account`}),n[18]=_,n[19]=ie);let ae;n[20]===ie?ae=n[21]:(ae=(0,$.jsxs)(U,{variant:`ghost`,size:`sm`,className:`flex-1 justify-start gap-2 text-sidebar-foreground`,onClick:re,children:[H,ie]}),n[20]=ie,n[21]=ae);let oe;n[22]===F?oe=n[23]:(oe=()=>F(!0),n[22]=F,n[23]=oe);let se,ce;n[24]===Symbol.for(`react.memo_cache_sentinel`)?(se=(0,$.jsx)(It,{className:`h-4 w-4`}),ce=(0,$.jsx)(`span`,{className:`sr-only`,children:`Feedback`}),n[24]=se,n[25]=ce):(se=n[24],ce=n[25]);let le;n[26]===oe?le=n[27]:(le=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(U,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground hover:text-background`,onClick:oe,children:[se,ce]})}),n[26]=oe,n[27]=le);let ue;n[28]===Symbol.for(`react.memo_cache_sentinel`)?(ue=(0,$.jsx)(q,{children:`Send feedback to the Tarsk team`}),n[28]=ue):ue=n[28];let de;n[29]===le?de=n[30]:(de=(0,$.jsx)(ar,{children:(0,$.jsxs)(J,{children:[le,ue]})}),n[29]=le,n[30]=de);let fe=i??void 0,pe;n[31]===fe?pe=n[32]:(pe=(0,$.jsx)(ti,{threadId:fe}),n[31]=fe,n[32]=pe);let me;n[33]===_?me=n[34]:(me=(0,$.jsx)($r,{collapsed:_}),n[33]=_,n[34]=me);let he;n[35]!==ae||n[36]!==de||n[37]!==pe||n[38]!==me?(he=(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[ae,de,pe,me]}),n[35]=ae,n[36]=de,n[37]=pe,n[38]=me,n[39]=he):he=n[39];let ge;n[40]!==he||n[41]!==B||n[42]!==V?(ge=(0,$.jsxs)(`div`,{className:`px-3 py-2 flex flex-col gap-1`,children:[B,V,he]}),n[40]=he,n[41]=B,n[42]=V,n[43]=ge):ge=n[43];let _e;n[44]===r.length?_e=n[45]:(_e=r.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.`}),n[44]=r.length,n[45]=_e);let ve;n[46]!==s||n[47]!==l||n[48]!==c||n[49]!==f||n[50]!==m||n[51]!==p||n[52]!==u||n[53]!==o||n[54]!==r||n[55]!==a||n[56]!==i?(ve=(e,t)=>{let{isOpen:n,toggle:d}=t;return e.kind===`project`?(0,$.jsx)(oi,{project:e.project,isOpen:n,onToggle:d,isDeletingProject:l.includes(e.project.projectId),isSelected:a?e.project.projectId===a:!1,onCreateThread:f,onDeleteProject:m,onProjectSettings:T,hasSelectedThread:e.project.threads.some(e=>e.threadId===i)}):(0,$.jsx)(si,{thread:e.thread,projectId:e.projectId,selectedThreadId:i,isProcessing:o.includes(e.thread.threadId),isDeleting:c.includes(e.thread.threadId),isCompleted:s.includes(e.thread.threadId),projectTitlePrefix:`${R(r.find(t=>t.projectId===e.projectId))} - `,onSelectThread:u,onDeleteThread:p})},n[46]=s,n[47]=l,n[48]=c,n[49]=f,n[50]=m,n[51]=p,n[52]=u,n[53]=o,n[54]=r,n[55]=a,n[56]=i,n[57]=ve):ve=n[57];let ye;n[58]!==z||n[59]!==ve?(ye=(0,$.jsx)(lr,{nodes:z,defaultOpen:!0,childContainerClassName:`ml-4 border-l border-sidebar-border pl-2`,renderNode:ve}),n[58]=z,n[59]=ve,n[60]=ye):ye=n[60];let xe;n[61]!==_e||n[62]!==ye?(xe=(0,$.jsx)(xt,{className:`flex-1 w-full`,children:(0,$.jsxs)(`div`,{className:`px-2 py-2 w-full max-w-full overflow-hidden`,children:[_e,ye]})}),n[61]=_e,n[62]=ye,n[63]=xe):xe=n[63];let W;n[64]!==_||n[65]!==g||n[66]!==ee||n[67]!==ge||n[68]!==xe?(W=(0,$.jsx)(Dr,{collapsed:_,onLogoClick:g,headerAction:ee,footer:ge,children:xe}),n[64]=_,n[65]=g,n[66]=ee,n[67]=ge,n[68]=xe,n[69]=W):W=n[69];let Se=w!==null,Ce;n[70]===Symbol.for(`react.memo_cache_sentinel`)?(Ce=e=>!e&&T(null),n[70]=Ce):Ce=n[70];let we;n[71]===x?we=n[72]:(we=()=>{x?.(),T(null)},n[71]=x,n[72]=we);let Te;n[73]!==w||n[74]!==we?(Te=(0,$.jsx)(ln,{className:`max-w-2xl p-0 overflow-auto max-h-[90vh]`,children:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(ri,{projectId:w,onProjectUpdated:we})})}),n[73]=w,n[74]=we,n[75]=Te):Te=n[75];let Ee;n[76]!==Se||n[77]!==Te?(Ee=(0,$.jsx)(be,{open:Se,onOpenChange:Ce,children:Te}),n[76]=Se,n[77]=Te,n[78]=Ee):Ee=n[78];let De;n[79]===I?De=n[80]:(De=()=>void I(),n[79]=I,n[80]=De);let Oe;n[81]!==k||n[82]!==D||n[83]!==j||n[84]!==F||n[85]!==N||n[86]!==A||n[87]!==O||n[88]!==M||n[89]!==E||n[90]!==P||n[91]!==De?(Oe=(0,$.jsx)(Zr,{open:E,onOpenChange:F,feedbackName:D,onFeedbackNameChange:O,feedbackEmail:k,onFeedbackEmailChange:A,feedbackText:j,onFeedbackTextChange:M,loadingFeedbackUser:N,submittingFeedback:P,onSubmit:De}),n[81]=k,n[82]=D,n[83]=j,n[84]=F,n[85]=N,n[86]=A,n[87]=O,n[88]=M,n[89]=E,n[90]=P,n[91]=De,n[92]=Oe):Oe=n[92];let ke;n[93]===Symbol.for(`react.memo_cache_sentinel`)?(ke=(0,$.jsx)(ln,{className:`max-w-2xl p-0 overflow-auto max-h-[90vh]`,children:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(ni,{})})}),n[93]=ke):ke=n[93];let Ae;n[94]===S?Ae=n[95]:(Ae=(0,$.jsx)(be,{open:S,onOpenChange:C,children:ke}),n[94]=S,n[95]=Ae);let je;return n[96]!==W||n[97]!==Ee||n[98]!==Oe||n[99]!==Ae?(je=(0,$.jsxs)($.Fragment,{children:[W,Ee,Oe,Ae]}),n[96]=W,n[97]=Ee,n[98]=Oe,n[99]=Ae,n[100]=je):je=n[100],je}function ai(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 oi(e){let n=(0,Q.c)(26),{project:r,isOpen:i,onToggle:a,isDeletingProject:o,hasSelectedThread:s,isSelected:c,onCreateThread:l,onDeleteProject:u,onProjectSettings:d}=e,f;n[0]===r?f=n[1]:(f=R(r),n[0]=r,n[1]=f);let p=f,m=s||c,h=i&&`rotate-90`,g;n[2]===h?g=n[3]:(g=G(`h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform`,h),n[2]=h,n[3]=g);let _;n[4]===g?_=n[5]:(_=(0,$.jsx)(_e,{className:g}),n[4]=g,n[5]=_);let y;n[6]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(re,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}),n[6]=y):y=n[6];let b=(s||c)&&`font-bold text-foreground`,S;n[7]===b?S=n[8]:(S=G(`min-w-0 truncate transition-all block`,b),n[7]=b,n[8]=S);let C;n[9]!==p||n[10]!==S?(C=(0,$.jsx)(`span`,{className:S,children:p}),n[9]=p,n[10]=S,n[11]=C):C=n[11];let w;n[12]!==_||n[13]!==C?(w=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1.5 w-0`,children:[_,y,C]}),n[12]=_,n[13]=C,n[14]=w):w=n[14];let T;n[15]!==o||n[16]!==l||n[17]!==u||n[18]!==d||n[19]!==r?(T=(0,$.jsx)(`div`,{className:`flex shrink-0 items-center ml-auto`,children:o?(0,$.jsx)(ot,{className:`h-3.5 w-3.5 shrink-0 animate-spin text-muted-foreground mr-1`}):(0,$.jsxs)(ar,{children:[(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(U,{variant:`ghost`,size:`icon`,className:`h-7 w-7 shrink-0 hidden group-hover:flex items-center justify-center`,onClick:e=>{e.stopPropagation(),d(r.projectId)},children:[(0,$.jsx)(x,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Project settings`})]})}),(0,$.jsx)(q,{side:`right`,children:`Project settings`})]}),(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(U,{variant:`action`,size:`icon-sm`,className:`shrink-0 hidden group-hover:flex items-center justify-center`,onClick:e=>{e.stopPropagation(),l(r.projectId)},children:[(0,$.jsx)(t,{}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Add thread`})]})}),(0,$.jsx)(q,{side:`right`,children:`Add thread`})]}),r.threads.length===0&&(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(U,{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(),u(r.projectId)},children:[(0,$.jsx)(v,{}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Delete project`})]})}),(0,$.jsx)(q,{side:`right`,children:`Delete project`})]})]})}),n[15]=o,n[16]=l,n[17]=u,n[18]=d,n[19]=r,n[20]=T):T=n[20];let E;return n[21]!==a||n[22]!==w||n[23]!==T||n[24]!==m?(E=(0,$.jsxs)(gr,{selected:m,noBackground:!0,className:`mb-1 h-9`,onClick:a,children:[w,T]}),n[21]=a,n[22]=w,n[23]=T,n[24]=m,n[25]=E):E=n[25],E}function si(e){let t=(0,Q.c)(47),{thread:n,projectId:r,selectedThreadId:i,isProcessing:a,isDeleting:o,isCompleted:s,projectTitlePrefix:c,onSelectThread:l,onDeleteThread:u}=e,[d,f]=(0,Z.useState)(!1),p;t[0]!==u||t[1]!==r||t[2]!==n.gitStatusDot||t[3]!==n.threadId?(p=e=>{e.stopPropagation(),n.gitStatusDot?f(!0):u(r,n.threadId)},t[0]=u,t[1]=r,t[2]=n.gitStatusDot,t[3]=n.threadId,t[4]=p):p=t[4];let m=p,h;t[5]!==c||t[6]!==n.threadId||t[7]!==n.title?(h=n.title?.startsWith(c)?n.title.slice(c.length):n.title??n.threadId,t[5]=c,t[6]=n.threadId,t[7]=n.title,t[8]=h):h=t[8];let g=h,_;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(vr,{children:`Delete Thread`}),t[9]=_):_=t[9];let y;t[10]===g?y=t[11]:(y=(0,$.jsxs)(_r,{children:[`Are you sure you want to delete "`,g,`" and all its files? This action cannot be undone.`]}),t[10]=g,t[11]=y);let b;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(Sr,{children:`Cancel`}),t[12]=b):b=t[12];let x;t[13]!==u||t[14]!==r||t[15]!==n.threadId?(x=(0,$.jsxs)(`div`,{className:`flex gap-3 justify-end`,children:[b,(0,$.jsx)(br,{onClick:()=>{f(!1),u(r,n.threadId)},className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:`Delete`})]}),t[13]=u,t[14]=r,t[15]=n.threadId,t[16]=x):x=t[16];let S;t[17]!==y||t[18]!==x?(S=(0,$.jsxs)(yr,{children:[_,y,x]}),t[17]=y,t[18]=x,t[19]=S):S=t[19];let C;t[20]!==d||t[21]!==S?(C=(0,$.jsx)(wr,{open:d,onOpenChange:f,children:S}),t[20]=d,t[21]=S,t[22]=C):C=t[22];let w=n.threadId===i,T,E;t[23]!==l||t[24]!==r||t[25]!==n.threadId?(T=()=>l(r,n.threadId),E=e=>{(e.key===`Enter`||e.key===` `)&&l(r,n.threadId)},t[23]=l,t[24]=r,t[25]=n.threadId,t[26]=T,t[27]=E):(T=t[26],E=t[27]);let D;t[28]===n.gitStatusDot?D=t[29]:(D=n.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]=n.gitStatusDot,t[29]=D);let O;t[30]===g?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:g})}),t[30]=g,t[31]=O);let k;t[32]!==m||t[33]!==s||t[34]!==o||t[35]!==a?(k=a||o?(0,$.jsx)(ot,{className:`ml-auto h-3 w-3 shrink-0 animate-spin text-muted-foreground`}):s?(0,$.jsx)(qt,{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)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(U,{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:m,children:[(0,$.jsx)(v,{}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Delete thread`})]})}),(0,$.jsx)(q,{side:`right`,children:`Delete thread and files from the repo`})]})}),t[32]=m,t[33]=s,t[34]=o,t[35]=a,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)(gr,{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}var ci=e(Xt(),1),li=.1,ui=10,di=1.25,fi=.001;function pi(){let e=(0,Q.c)(15),[t,n]=(0,Z.useState)(1),r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r={x:0,y:0},e[0]=r):r=e[0];let[i,a]=(0,Z.useState)(r),[o,s]=(0,Z.useState)(!1),c=(0,Z.useRef)(null),l=mi,u;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>n(e=>l(e*di)),e[1]=u):u=e[1];let d=u,f;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=()=>n(e=>l(e/di)),e[2]=f):f=e[2];let p=f,m;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>{n(1),a({x:0,y:0})},e[3]=m):m=e[3];let h=m,g;e[4]===i?g=e[5]:(g=e=>{e.preventDefault(),s(!0),c.current={x:e.clientX,y:e.clientY,ox:i.x,oy:i.y}},e[4]=i,e[5]=g);let _=g,v;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(v=e=>{c.current&&a({x:c.current.ox+(e.clientX-c.current.x),y:c.current.oy+(e.clientY-c.current.y)})},e[6]=v):v=e[6];let y=v,b;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(b=()=>{s(!1),c.current=null},e[7]=b):b=e[7];let x=b,S=(0,Z.useRef)(null),C,w;e[8]===Symbol.for(`react.memo_cache_sentinel`)?(C=()=>{let e=S.current;if(!e)return;let t=function(e){e.preventDefault();let t=-e.deltaY*fi;n(e=>l(e*(1+t)))};return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},w=[],e[8]=C,e[9]=w):(C=e[8],w=e[9]),(0,Z.useEffect)(C,w);let T;return e[10]!==o||e[11]!==i||e[12]!==_||e[13]!==t?(T={scale:t,offset:i,isDragging:o,containerRef:S,zoomIn:d,zoomOut:p,reset:h,onMouseDown:_,onMouseMove:y,onMouseUp:x},e[10]=o,e[11]=i,e[12]=_,e[13]=t,e[14]=T):T=e[14],T}function mi(e){return Math.min(Math.max(e,li),ui)}function hi(){let e=(0,Q.c)(2),[t,n]=(0,Z.useState)(!1),r,i;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{let e=function(){n(document.documentElement.classList.contains(`dark`))};e();let t=new MutationObserver(e);return t.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`]}),()=>t.disconnect()},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),(0,Z.useEffect)(r,i),t}function gi(e,t){let[n,r]=(0,Z.useState)(null),[i,a]=(0,Z.useState)(!1);return(0,Z.useEffect)(()=>{let n=!1;async function i(){try{let{renderMermaidSVG:i}=await Un(async()=>{let{renderMermaidSVG:e}=await import(`./dist-CIGnaqp2.js`);return{renderMermaidSVG:e}},__vite__mapDeps([9,1])),o=i(e,{bg:t?`#18181B`:`#FFFFFF`,fg:t?`#FAFAFA`:`#27272A`,transparent:!1,padding:32});n||(r(o),a(!1))}catch(e){console.error(`Mermaid render error:`,e),n||a(!0)}}return i(),()=>{n=!0}},[e,t]),{svgOutput:n,renderError:i}}function _i(e){let n=(0,Q.c)(69),{svgOutput:r,onClose:i}=e,{scale:a,offset:o,isDragging:s,containerRef:c,zoomIn:l,zoomOut:u,reset:d,onMouseDown:f,onMouseMove:p,onMouseUp:m}=pi(),h,g;n[0]===i?(h=n[1],g=n[2]):(h=()=>{let e=function(e){e.key===`Escape`&&i()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},g=[i],n[0]=i,n[1]=h,n[2]=g),(0,Z.useEffect)(h,g);let _;n[3]===Symbol.for(`react.memo_cache_sentinel`)?(_=[],n[3]=_):_=n[3],(0,Z.useEffect)(vi,_);let v;n[4]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(`span`,{className:`text-xs font-mono text-muted-foreground`,children:`mermaid diagram`}),n[4]=v):v=n[4];let y,b;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(wt,{className:`h-3.5 w-3.5`}),b=(0,$.jsx)(`span`,{className:`sr-only`,children:`Zoom out`}),n[5]=y,n[6]=b):(y=n[5],b=n[6]);let x;n[7]===u?x=n[8]:(x=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(U,{variant:`ghost`,size:`icon-xs`,onClick:u,children:[y,b]})}),n[7]=u,n[8]=x);let S;n[9]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,$.jsx)(q,{children:`Zoom out`}),n[9]=S):S=n[9];let C;n[10]===x?C=n[11]:(C=(0,$.jsxs)(J,{children:[x,S]}),n[10]=x,n[11]=C);let w;n[12]===a?w=n[13]:(w=Math.round(a*100),n[12]=a,n[13]=w);let T;n[14]!==d||n[15]!==w?(T=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,onClick:d,className:`min-w-[3rem] px-2 py-1 text-xs font-mono text-muted-foreground hover:text-foreground hover:bg-muted rounded transition-colors`,children:[w,`%`]})}),n[14]=d,n[15]=w,n[16]=T):T=n[16];let E;n[17]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,$.jsx)(q,{children:`Reset zoom`}),n[17]=E):E=n[17];let D;n[18]===T?D=n[19]:(D=(0,$.jsxs)(J,{children:[T,E]}),n[18]=T,n[19]=D);let O,k;n[20]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,$.jsx)(t,{className:`h-3.5 w-3.5`}),k=(0,$.jsx)(`span`,{className:`sr-only`,children:`Zoom in`}),n[20]=O,n[21]=k):(O=n[20],k=n[21]);let A;n[22]===l?A=n[23]:(A=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(U,{variant:`ghost`,size:`icon-xs`,onClick:l,children:[O,k]})}),n[22]=l,n[23]=A);let j;n[24]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,$.jsx)(q,{children:`Zoom in`}),n[24]=j):j=n[24];let M;n[25]===A?M=n[26]:(M=(0,$.jsxs)(J,{children:[A,j]}),n[25]=A,n[26]=M);let N,P;n[27]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,$.jsx)(Re,{className:`h-3.5 w-3.5`}),P=(0,$.jsx)(`span`,{className:`sr-only`,children:`Reset view`}),n[27]=N,n[28]=P):(N=n[27],P=n[28]);let F;n[29]===d?F=n[30]:(F=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(U,{variant:`ghost`,size:`icon-xs`,onClick:d,children:[N,P]})}),n[29]=d,n[30]=F);let I;n[31]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,$.jsx)(q,{children:`Reset view`}),n[31]=I):I=n[31];let L;n[32]===F?L=n[33]:(L=(0,$.jsxs)(J,{children:[F,I]}),n[32]=F,n[33]=L);let R;n[34]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,$.jsx)(`div`,{className:`w-px h-4 bg-border mx-1`}),n[34]=R):R=n[34];let z,ee;n[35]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,$.jsx)(St,{className:`h-3.5 w-3.5`}),ee=(0,$.jsx)(`span`,{className:`sr-only`,children:`Close`}),n[35]=z,n[36]=ee):(z=n[35],ee=n[36]);let B;n[37]===i?B=n[38]:(B=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(U,{variant:`ghost`,size:`icon-xs`,onClick:i,children:[z,ee]})}),n[37]=i,n[38]=B);let te;n[39]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,$.jsx)(q,{children:`Close (Esc)`}),n[39]=te):te=n[39];let ne;n[40]===B?ne=n[41]:(ne=(0,$.jsxs)(J,{children:[B,te]}),n[40]=B,n[41]=ne);let V;n[42]!==D||n[43]!==M||n[44]!==L||n[45]!==ne||n[46]!==C?(V=(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 bg-background/90 border-b border-border shrink-0`,children:[v,(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[C,D,M,L,R,ne]})]}),n[42]=D,n[43]=M,n[44]=L,n[45]=ne,n[46]=C,n[47]=V):V=n[47];let re=s?`cursor-grabbing`:`cursor-grab`,H;n[48]===re?H=n[49]:(H=G(`flex-1 overflow-hidden select-none`,re),n[48]=re,n[49]=H);let ie=`translate(${o.x}px, ${o.y}px) scale(${a})`,ae=s?`none`:`transform 0.1s ease-out`,oe;n[50]!==ie||n[51]!==ae?(oe={transform:ie,transformOrigin:`center center`,transition:ae},n[50]=ie,n[51]=ae,n[52]=oe):oe=n[52];let se;n[53]===r?se=n[54]:(se={__html:r},n[53]=r,n[54]=se);let ce;n[55]!==oe||n[56]!==se?(ce=(0,$.jsx)(`div`,{className:`w-full h-full flex items-center justify-center`,style:oe,dangerouslySetInnerHTML:se}),n[55]=oe,n[56]=se,n[57]=ce):ce=n[57];let le;n[58]!==c||n[59]!==f||n[60]!==p||n[61]!==m||n[62]!==H||n[63]!==ce?(le=(0,$.jsx)(`div`,{ref:c,className:H,onMouseDown:f,onMouseMove:p,onMouseUp:m,onMouseLeave:m,children:ce}),n[58]=c,n[59]=f,n[60]=p,n[61]=m,n[62]=H,n[63]=ce,n[64]=le):le=n[64];let ue;n[65]===Symbol.for(`react.memo_cache_sentinel`)?(ue=(0,$.jsx)(`div`,{className:`shrink-0 px-4 py-2 text-center text-xs text-muted-foreground/60 bg-background/60 border-t border-border`,children:`Scroll to zoom · Drag to pan · Esc to close`}),n[65]=ue):ue=n[65];let de;return n[66]!==V||n[67]!==le?(de=(0,ci.createPortal)((0,$.jsx)(ar,{children:(0,$.jsxs)(`div`,{className:`fixed inset-0 z-50 flex flex-col bg-black/85 backdrop-blur-sm`,role:`dialog`,"aria-modal":`true`,"aria-label":`Diagram fullscreen view`,children:[V,le,ue]})}),document.body),n[66]=V,n[67]=le,n[68]=de):de=n[68],de}function vi(){return document.body.style.overflow=`hidden`,yi}function yi(){document.body.style.overflow=``}function bi(e){let t=(0,Q.c)(51),{content:n,className:r}=e,[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(!1),{svgOutput:c,renderError:l}=gi(n,hi()),u;t[0]===n?u=t[1]:(u=async function(){await navigator.clipboard.writeText(n),a(!0),setTimeout(()=>a(!1),2e3)},t[0]=n,t[1]=u);let d=u,f=l?`mermaid (render error)`:`mermaid diagram`,p;t[2]===f?p=t[3]:(p=(0,$.jsx)(`span`,{className:`text-xs font-mono text-muted-foreground`,children:f}),t[2]=f,t[3]=p);let m;t[4]!==l||t[5]!==c?(m=c&&!l&&(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(U,{variant:`action`,size:`icon-xs`,onClick:()=>s(!0),children:[(0,$.jsx)(Et,{}),(0,$.jsx)(`span`,{className:`sr-only`,children:`View fullscreen`})]})}),(0,$.jsx)(q,{children:`View fullscreen`})]}),t[4]=l,t[5]=c,t[6]=m):m=t[6];let h;t[7]===i?h=t[8]:(h=i?(0,$.jsx)(qt,{}):(0,$.jsx)(je,{}),t[7]=i,t[8]=h);let g;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(`span`,{className:`sr-only`,children:`Copy mermaid code`}),t[9]=g):g=t[9];let _;t[10]!==d||t[11]!==h?(_=(0,$.jsxs)(U,{variant:`action`,size:`icon-xs`,onClick:d,children:[h,g]}),t[10]=d,t[11]=h,t[12]=_):_=t[12];let v;t[13]!==m||t[14]!==_?(v=(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[m,_]}),t[13]=m,t[14]=_,t[15]=v):v=t[15];let y;t[16]!==p||t[17]!==v?(y=(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border bg-muted/80 px-4 py-2`,children:[p,v]}),t[16]=p,t[17]=v,t[18]=y):y=t[18];let b=y;if(l){let e;t[19]===r?e=t[20]:(e=G(`group relative overflow-hidden rounded-lg border border-border bg-muted`,r),t[19]=r,t[20]=e);let i;t[21]===n?i=t[22]:(i=(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:n})}),t[21]=n,t[22]=i);let a;return t[23]!==b||t[24]!==e||t[25]!==i?(a=(0,$.jsxs)(`div`,{className:e,children:[b,i]}),t[23]=b,t[24]=e,t[25]=i,t[26]=a):a=t[26],a}if(!c){let e;t[27]===r?e=t[28]:(e=G(`group relative overflow-hidden rounded-lg border border-border bg-muted`,r),t[27]=r,t[28]=e);let n;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(`div`,{className:`p-4 text-xs text-muted-foreground`,children:`Rendering diagram…`}),t[29]=n):n=t[29];let i;return t[30]!==b||t[31]!==e?(i=(0,$.jsxs)(`div`,{className:e,children:[b,n]}),t[30]=b,t[31]=e,t[32]=i):i=t[32],i}let x;t[33]===r?x=t[34]:(x=G(`group relative overflow-hidden rounded-lg border border-border bg-muted`,r),t[33]=r,t[34]=x);let S;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(S=()=>s(!0),t[35]=S):S=t[35];let C;t[36]===c?C=t[37]:(C=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`block w-full text-left cursor-zoom-in p-4 max-w-full overflow-hidden [&_svg]:max-w-full [&_svg]:h-auto hover:bg-muted/70 transition-colors`,onClick:S,dangerouslySetInnerHTML:{__html:c}})}),t[36]=c,t[37]=C);let w;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(q,{children:`Click to view fullscreen`}),t[38]=w):w=t[38];let T;t[39]===C?T=t[40]:(T=(0,$.jsxs)(J,{children:[C,w]}),t[39]=C,t[40]=T);let E;t[41]!==b||t[42]!==x||t[43]!==T?(E=(0,$.jsxs)(`div`,{className:x,children:[b,T]}),t[41]=b,t[42]=x,t[43]=T,t[44]=E):E=t[44];let D;t[45]!==o||t[46]!==c?(D=o&&(0,$.jsx)(_i,{svgOutput:c,onClose:()=>s(!1)}),t[45]=o,t[46]=c,t[47]=D):D=t[47];let O;return t[48]!==E||t[49]!==D?(O=(0,$.jsxs)(ar,{children:[E,D]}),t[48]=E,t[49]=D,t[50]=O):O=t[50],O}var xi=`graph.flowchart.sequenceDiagram.classDiagram.stateDiagram.erDiagram.journey.gantt.pie.quadrantChart.requirementDiagram.gitgraph.mindmap.timeline.zenuml.sankey.block.architecture.c4.packet.circuit.flowchart LR.flowchart TD.flowchart BT.flowchart RL.graph LR.graph TD.graph BT.graph RL`.split(`.`),Si=[/-->/,/--\./,/-\./,/==>/,/--\|/,/\w+\[\w+\]/,/\w+\(\w+\)/,/\w+\{\w+\}/,/\w+>\w+\]/,/\w+\(\w+\)/,/\w+\[\(\w+\)\]/,/participant\s+\w+/,/actor\s+\w+/,/Note over \w+/,/loop\s+/,/alt\s+/,/opt\s+/,/class\s+\w+/,/interface\s+\w+/,/enum\s+\w+/,/\[\*\]/,/\[\*\]/,/title\s+/,/direction\s+/,/subgraph\s+/];function Ci(e){if(!e||typeof e!=`string`)return!1;let t=e.split(`
3
+ `).map(e=>e.trim()).filter(e=>e.length>0);if(t.length===0)return!1;if(/```mermaid\s*\n([\s\S]*?)\n```/.test(e))return!0;let n=t[0].toLowerCase();if(xi.some(e=>n===e.toLowerCase()||n.startsWith(e.toLowerCase()+` `)))return!0;let r=0;for(let t of Si)t.test(e)&&r++;return r>=2}function wi(e){if(!Ci(e))return null;let t=/```mermaid\s*\n([\s\S]*?)\n```/.exec(e);if(t)return t[1].trim();let n=e.split(`
4
+ `).map(e=>e.trim()).filter(e=>e.length>0)[0].toLowerCase();return xi.some(e=>n===e.toLowerCase()||n.startsWith(e.toLowerCase()+` `))?e.trim():null}var Ti=(0,Z.memo)(function({content:e,className:t,enableMermaid:n=!1}){let r=(0,Z.useMemo)(()=>!e||typeof e!=`string`?[]:Ei(e,n),[e,n]);if(r.length===0)return null;let i=(0,Z.useMemo)(()=>{let e=0;return r.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})},[r]);return(0,$.jsx)(`div`,{className:G(`prose-custom space-y-3 min-w-0 break-words`,t),children:r.map((e,t)=>(0,$.jsx)(Di,{block:e,start:i[t]},t))})});function Ei(e,t=!1){let n=e.split(`
5
+ `),r=[],i=0;for(;i<n.length;){let e=n[i];if(e.trimStart().startsWith("```")){let a=e.trimStart().slice(3).trim(),o=[];for(i++;i<n.length&&!n[i].trimStart().startsWith("```");)o.push(n[i]),i++;t&&(a===`mermaid`||Ci(o.join(`
6
+ `)))?r.push({type:`mermaid`,code:o.join(`
7
+ `)}):r.push({type:`code`,language:a,code:o.join(`
8
+ `)}),i++;continue}let a=e.match(/^(#{1,6})(\s.*)?$/);if(a){r.push({type:`heading`,level:a[1].length,text:a[2]?a[2].trim():``}),i++;continue}if(/^(---|\*\*\*|___)/.test(e.trim())){r.push({type:`hr`}),i++;continue}if(e.includes(`|`)&&i+1<n.length&&n[i+1].match(/^\|?\s*[-:]+/)){let t=e.split(`|`).map(e=>e.trim()).filter(Boolean);i+=2;let a=[];for(;i<n.length&&n[i].includes(`|`);)a.push(n[i].split(`|`).map(e=>e.trim()).filter(Boolean)),i++;r.push({type:`table`,headers:t,rows:a});continue}if(e.startsWith(`> `)){let e=[];for(;i<n.length&&n[i].startsWith(`> `);)e.push(n[i].slice(2)),i++;r.push({type:`blockquote`,text:e.join(`
9
+ `)});continue}if(/^\s*[-*+]\s/.test(e)){let e=[];for(;i<n.length&&/^\s*[-*+]\s/.test(n[i]);)e.push(n[i].replace(/^\s*[-*+]\s/,``)),i++;r.push({type:`list`,ordered:!1,items:e});continue}if(/^\s*\d+\.\s/.test(e)){let e=[];for(;i<n.length&&/^\s*\d+\.\s/.test(n[i]);)e.push(n[i].replace(/^\s*\d+\.\s/,``)),i++;r.push({type:`list`,ordered:!0,items:e});continue}if(e.trim()===``){i++;continue}let o=[];for(;i<n.length&&n[i].trim()!==``&&!n[i].startsWith(`#`)&&!n[i].startsWith("```")&&!n[i].startsWith(`> `)&&!/^\s*[-*+]\s/.test(n[i])&&!/^\s*\d+\.\s/.test(n[i]);)o.push(n[i]),i++;if(o.length>0){let e=o.join(`
10
+ `);if(t&&Ci(e)){let t=wi(e);t?r.push({type:`mermaid`,code:t}):r.push({type:`paragraph`,text:e})}else r.push({type:`paragraph`,text:e})}}return r}var Di=(0,Z.memo)(function(e){let t=(0,Q.c)(42),{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=G({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)(Oi,{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)(Ai,{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)(Oi,{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)(Oi,{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(ji),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)(Oi,{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(Pi),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}case`mermaid`:{let e;return t[40]===n.code?e=t[41]:(e=(0,$.jsx)(bi,{content:n.code}),t[40]=n.code,t[41]=e),e}default:return null}}),Oi=(0,Z.memo)(function(e){let t=(0,Q.c)(6),{text:n}=e,r;t[0]===n?r=t[1]:(r=ki(n),t[0]=n,t[1]=r);let i=r,a;t[2]===i?a=t[3]:(a=i.map(Fi),t[2]=i,t[3]=a);let o;return t[4]===a?o=t[5]:(o=(0,$.jsx)($.Fragment,{children:a}),t[4]=a,t[5]=o),o});function ki(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 Ai(e){let t=(0,Q.c)(18),{language:n,code:r}=e,[i,a]=(0,Z.useState)(!1),o;t[0]===r?o=t[1]:(o=async()=>{await navigator.clipboard.writeText(r),a(!0),setTimeout(()=>a(!1),2e3)},t[0]=r,t[1]=o);let s=o,c=n||`text`,l;t[2]===c?l=t[3]:(l=(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground font-mono`,children:c}),t[2]=c,t[3]=l);let u;t[4]===i?u=t[5]:(u=i?(0,$.jsx)(qt,{}):(0,$.jsx)(je,{}),t[4]=i,t[5]=u);let d;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(`span`,{className:`sr-only`,children:`Copy code`}),t[6]=d):d=t[6];let f;t[7]!==s||t[8]!==u?(f=(0,$.jsxs)(U,{variant:`action`,size:`icon-xs`,onClick:s,children:[u,d]}),t[7]=s,t[8]=u,t[9]=f):f=t[9];let p;t[10]!==l||t[11]!==f?(p=(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border bg-muted/80 px-4 py-2`,children:[l,f]}),t[10]=l,t[11]=f,t[12]=p):p=t[12];let m;t[13]===r?m=t[14]:(m=(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:r})}),t[13]=r,t[14]=m);let h;return t[15]!==p||t[16]!==m?(h=(0,$.jsxs)(`div`,{className:`group relative overflow-hidden rounded-lg border border-border bg-muted`,children:[p,m]}),t[15]=p,t[16]=m,t[17]=h):h=t[17],h}function ji(e,t){return(0,$.jsx)(`li`,{children:(0,$.jsx)(Oi,{text:e})},t)}function Mi(e,t){return(0,$.jsx)(`th`,{className:`px-3 py-2 text-left font-medium`,children:(0,$.jsx)(Oi,{text:e})},t)}function Ni(e,t){return(0,$.jsx)(`td`,{className:`px-3 py-2`,children:(0,$.jsx)(Oi,{text:e})},t)}function Pi(e,t){return(0,$.jsx)(`tr`,{className:`border-b border-border last:border-0`,children:e.map(Ni)},t)}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 n=e.toLowerCase();return n.includes(`read`)||n.includes(`file`)?ft:n.includes(`create`)?t:n.includes(`replace`)||n.includes(`edit`)?T:n.includes(`delete`)?Pe:n.includes(`terminal`)||n.includes(`bash`)||n.includes(`shell`)?te:n.includes(`run`)?fe:n.includes(`git`)||n.includes(`branch`)?bt:n.includes(`search`)||n.includes(`grep`)||n.includes(`find`)?F:n.includes(`code`)||n.includes(`debug`)?b:n.includes(`test`)?Fe:n.includes(`agent`)||n.includes(`subagent`)?Mt:n.includes(`copy`)?je:n.includes(`dir`)||n.includes(`list`)||n.includes(`ls`)?lt:n.includes(`view`)||n.includes(`show`)?O:n.includes(`config`)||n.includes(`setting`)?x:n.includes(`image`)||n.includes(`generate_image`)?Ke:n.includes(`chat`)||n.includes(`message`)||n.includes(`ask`)?It:i}function Li(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 Ri(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 zi(e){return typeof e==`string`?e:typeof e==`object`&&e?JSON.stringify(e,null,2):String(e)}function Bi(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 Vi(e){if(typeof e!=`object`||!e)return e;if(Array.isArray(e))return e.map(Vi);let t={};for(let[n,r]of Object.entries(e))if(typeof r==`string`){let e=Bi(r);t[n]=typeof e==`object`?Vi(e):r}else t[n]=Vi(r);return t}function Hi(e){if(e==null||typeof e!=`string`)return``;let t=e;return t=t.replace(/\\\\n/g,`
11
+ `),t=t.replace(/\\\\"/g,`"`),t=t.replace(/\\n/g,`
12
+ `),t=t.replace(/\\"/g,`"`),t}function Ui(e){if(e==null)return``;let t=typeof e==`object`&&e?Vi(e):e;return Hi(typeof t==`string`?t:t==null?``:JSON.stringify(t,null,2))}function Wi(e,t){let n=e.name??`Unknown Tool`,r=e.id??`unknown`,i=e.input,a=i&&typeof i==`object`?i:null,o=i&&typeof i==`object`&&`description`in i,s=o?i.subagent_type:void 0,c=s==null?null:JSON.stringify(s),l=n===`agent`&&a&&typeof a.agentName==`string`?a.agentName:null,u=o?null:Ri(zi(i),t),d=Ri(o?String(i.prompt):null,t),f=Ri(a&&typeof a.command==`string`?a.command:null,t),p=a&&typeof a.pattern==`string`?a.pattern:null,m=a&&typeof a.lang==`string`?a.lang:null,h=n===`code_search`,g=h&&a&&typeof a.query==`string`?a.query:null,_=h&&a&&typeof a.filePath==`string`?a.filePath:null,v=h&&a&&typeof a.fileGlob==`string`?a.fileGlob:null,y=Ri(a&&typeof a.path==`string`?a.path:null,t),b=a&&typeof a.offset==`number`?a.offset:null,x=a&&typeof a.limit==`number`?a.limit:null,S=n.toLowerCase(),C=S.includes(`read`)||S.includes(`write`)||S.includes(`edit`),w=S.includes(`edit`),T=C&&a&&typeof a.path==`string`?a.path:null,E=T?T.split(`/`).pop()??T:null,D=w&&a&&typeof a.oldText==`string`?a.oldText:null,O=w&&a&&typeof a.newText==`string`?a.newText:null,k=D!==null&&O!==null,A=n===`generate_image`&&a&&typeof a.prompt==`string`?a.prompt:null,j=n===`todo`&&a?a.status:void 0,M=Ii(n),P=(n===`todo`?j===`done`?Fe:j===`working`?N:Rt:null)??M,F=n.charAt(0).toUpperCase()+n.slice(1);S===`bash`&&(F=`Ran`),S===`code_search`&&(F=`Code Search`),S===`generate_image`&&(F=`Make Image`),S.includes(`read`)&&(b!==null||x!==null)&&(b!==null&&x!==null?F+=` (lines ${b} to ${b+x})`:b===null?F+=` (${x} lines)`:F+=` (from line ${b})`);let I=`default`;return S===`bash`||S.includes(`terminal`)||S.includes(`shell`)?I=`bash`:C?I=`file`:h||S===`find`||S.includes(`search`)||S.includes(`grep`)?I=`search`:S===`agent`||S.includes(`subagent`)||o?I=`agent`:S===`todo`?I=`todo`:S===`generate_image`&&(I=`imageGen`),{toolType:I,toolName:n,toolId:r,displayName:F,icon:P,inputObj:a,toolInput:u,command:f,pattern:p,codeSearchQuery:g,codeSearchFilePath:_,codeSearchFileGlob:v,isFileTool:C,isEditTool:w,filePath:T,fileDisplayName:E,editOldText:D,editNewText:O,hasEditDiff:k,path:y,offset:b,limit:x,prompt:d,agentName:l,subagentType:c,lang:m,imageGenPrompt:A,todoStatus:j}}function Gi(e){let t=(0,Q.c)(11),{open:n,onOpenChange:r,title:i,content:a}=e,o;t[0]===i?o=t[1]:(o=(0,$.jsx)(w,{children:(0,$.jsx)(Ee,{children:(0,$.jsx)(`code`,{className:`text-sm font-mono`,children:i})})}),t[0]=i,t[1]=o);let s;t[2]===a?s=t[3]:(s=(0,$.jsx)(`pre`,{className:`text-xs bg-muted p-3 rounded font-mono whitespace-pre-wrap overflow-auto flex-1 text-foreground`,children:a}),t[2]=a,t[3]=s);let c;t[4]!==o||t[5]!==s?(c=(0,$.jsxs)(ln,{className:`max-w-3xl h-[80vh] flex flex-col`,children:[o,s]}),t[4]=o,t[5]=s,t[6]=c):c=t[6];let l;return t[7]!==r||t[8]!==n||t[9]!==c?(l=(0,$.jsx)(be,{open:n,onOpenChange:r,children:c}),t[7]=r,t[8]=n,t[9]=c,t[10]=l):l=t[10],l}function Ki(e){let t=(0,Q.c)(9),{oldText:n,newText:r}=e,i,a,o;if(t[0]!==r||t[1]!==n){let e=n.split(`
13
+ `),s=r.split(`
14
+ `);i=`text-xs font-mono whitespace-pre-wrap overflow-auto`,a=e.map(Ji),o=s.map(qi),t[0]=r,t[1]=n,t[2]=i,t[3]=a,t[4]=o}else i=t[2],a=t[3],o=t[4];let s;return t[5]!==i||t[6]!==a||t[7]!==o?(s=(0,$.jsxs)(`pre`,{className:i,children:[a,o]}),t[5]=i,t[6]=a,t[7]=o,t[8]=s):s=t[8],s}function qi(e,t){return(0,$.jsxs)(`div`,{className:`bg-green-500/10 text-green-600 dark:text-green-400`,children:[(0,$.jsx)(`span`,{className:`select-none opacity-50 mr-2`,children:`+`}),e]},`new-${t}`)}function Ji(e,t){return(0,$.jsxs)(`div`,{className:`bg-red-500/10 text-red-600 dark:text-red-400`,children:[(0,$.jsx)(`span`,{className:`select-none opacity-50 mr-2`,children:`-`}),e]},`old-${t}`)}function Yi(e){let t=(0,Q.c)(2),{name:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded bg-muted text-muted-foreground font-mono`,children:n}),t[0]=n,t[1]=r),r}function Xi(e){let t=(0,Q.c)(2),{type:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(`span`,{className:`text-xs px-2 py-0.5 rounded bg-muted text-muted-foreground`,children:n}),t[0]=n,t[1]=r),r}function Zi(e){let t=(0,Q.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(`code`,{className:`text-xs font-mono text-muted-foreground break-all rounded bg-muted/60 px-1 py-0.5`,children:n}),t[0]=n,t[1]=r),r}function Qi(e){let t=(0,Q.c)(55),{data:n,inline:r,resultContent:i}=e,[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(!1);if(r){if(n.command!==null&&i){let e;t[0]===n.icon?e=t[1]:(e=(0,Z.createElement)(n.icon,{className:`h-3.5 w-3.5 shrink-0 text-brand`}),t[0]=n.icon,t[1]=e);let r;t[2]===n.displayName?r=t[3]:(r=(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n.displayName}),t[2]=n.displayName,t[3]=r);let a;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(a=()=>c(!0),t[4]=a):a=t[4];let o;t[5]===n.command?o=t[6]:(o=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:a,className:`text-xs font-mono text-muted-foreground hover:underline break-all cursor-pointer`,children:n.command})}),t[5]=n.command,t[6]=o);let l;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(q,{children:`View output`}),t[7]=l):l=t[7];let u;t[8]===o?u=t[9]:(u=(0,$.jsxs)(J,{children:[o,l]}),t[8]=o,t[9]=u);let d;t[10]!==e||t[11]!==r||t[12]!==u?(d=(0,$.jsxs)(`div`,{className:`py-0.5 flex items-center gap-2 flex-wrap`,children:[e,r,u]}),t[10]=e,t[11]=r,t[12]=u,t[13]=d):d=t[13];let f;t[14]!==n.command||t[15]!==s||t[16]!==i?(f=(0,$.jsx)(Gi,{open:s,onOpenChange:c,title:n.command,content:i}),t[14]=n.command,t[15]=s,t[16]=i,t[17]=f):f=t[17];let p;return t[18]!==d||t[19]!==f?(p=(0,$.jsxs)($.Fragment,{children:[d,f]}),t[18]=d,t[19]=f,t[20]=p):p=t[20],p}let e=n.toolName,r;t[21]===n.icon?r=t[22]:(r=(0,Z.createElement)(n.icon,{className:`h-3.5 w-3.5 shrink-0 text-brand`}),t[21]=n.icon,t[22]=r);let a;t[23]===n.displayName?a=t[24]:(a=(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n.displayName}),t[23]=n.displayName,t[24]=a);let o;t[25]!==n.toolName||t[26]!==r||t[27]!==a?(o=(0,$.jsxs)(`span`,{title:e,className:`inline-flex items-center gap-1`,children:[r,a]}),t[25]=n.toolName,t[26]=r,t[27]=a,t[28]=o):o=t[28];let l;t[29]===n.command?l=t[30]:(l=n.command!==null&&(0,$.jsx)(`code`,{className:`text-xs font-mono text-muted-foreground break-all rounded bg-muted/60 px-1 py-0.5`,children:n.command}),t[29]=n.command,t[30]=l);let u;return t[31]!==o||t[32]!==l?(u=(0,$.jsxs)(`div`,{className:`py-0.5 flex items-center gap-2 flex-wrap`,children:[o,l]}),t[31]=o,t[32]=l,t[33]=u):u=t[33],u}let l;t[34]===a?l=t[35]:(l=()=>o(!a),t[34]=a,t[35]=l);let u=n.toolName,d;t[36]===n.icon?d=t[37]:(d=(0,Z.createElement)(n.icon,{className:`h-4 w-4 text-brand`}),t[36]=n.icon,t[37]=d);let f;t[38]===n.displayName?f=t[39]:(f=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:n.displayName}),t[38]=n.displayName,t[39]=f);let p;t[40]===a?p=t[41]:(p=a?(0,$.jsx)($e,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(_e,{className:`h-4 w-4 shrink-0`}),t[40]=a,t[41]=p);let m;t[42]!==n.toolName||t[43]!==l||t[44]!==d||t[45]!==f||t[46]!==p?(m=(0,$.jsxs)(`button`,{onClick:l,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:u,children:[d,f,p]}),t[42]=n.toolName,t[43]=l,t[44]=d,t[45]=f,t[46]=p,t[47]=m):m=t[47];let h;t[48]!==n.toolId||t[49]!==n.toolInput||t[50]!==a?(h=a&&(0,$.jsxs)(`div`,{className:`py-2 border-t border-border`,children:[(0,$.jsxs)(`div`,{className:`text-xs text-muted-foreground mb-2 font-mono`,children:[`ID: `,n.toolId]}),n.toolInput?(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:n.toolInput}):null]}),t[48]=n.toolId,t[49]=n.toolInput,t[50]=a,t[51]=h):h=t[51];let g;return t[52]!==m||t[53]!==h?(g=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[m,h]}),t[52]=m,t[53]=h,t[54]=g):g=t[54],g}var $i=jn,ea=Vn,ta=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=G(`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)(fn,{children:(0,$.jsx)(wn,{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});ta.displayName=wn.displayName;function na(e){let t=(0,Q.c)(45),{data:n,inline:r,rootPath:i,onOpenFile:a}=e,[o,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(!1),u;t[0]!==n.filePath||t[1]!==a||t[2]!==i?(u=function(){!n.filePath||!a||a(i&&n.filePath.startsWith(i)?n.filePath.slice(i.length+1):n.filePath)},t[0]=n.filePath,t[1]=a,t[2]=i,t[3]=u):u=t[3];let d=u;if(r){let e=!!(n.toolInput&&!n.command&&!n.path&&!n.pattern&&!n.fileDisplayName),r;t[4]!==n.displayName||t[5]!==n.icon||t[6]!==n.toolId||t[7]!==n.toolInput||t[8]!==n.toolName||t[9]!==e?(r=e?(0,$.jsxs)($i,{children:[(0,$.jsx)(ea,{asChild:!0,children:(0,$.jsx)(`span`,{title:n.toolName,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)(n.icon,{className:`h-3.5 w-3.5 text-brand`}),(0,$.jsx)(`span`,{className:`text-xs`,children:n.displayName})]})})}),(0,$.jsx)(ta,{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: `,n.toolId]}),(0,$.jsx)(`pre`,{className:`font-mono whitespace-pre-wrap overflow-auto max-h-48`,children:n.toolInput})]})})]}):(0,$.jsxs)(`span`,{title:n.toolName,className:`inline-flex items-center gap-1`,children:[(0,Z.createElement)(n.icon,{className:`h-3.5 w-3.5 shrink-0 text-brand`}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n.displayName})]}),t[4]=n.displayName,t[5]=n.icon,t[6]=n.toolId,t[7]=n.toolInput,t[8]=n.toolName,t[9]=e,t[10]=r):r=t[10];let a;t[11]!==n.editNewText||t[12]!==n.editOldText||t[13]!==n.fileDisplayName||t[14]!==n.filePath||t[15]!==n.hasEditDiff||t[16]!==n.path||t[17]!==c||t[18]!==d||t[19]!==i?(a=n.fileDisplayName?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:n.hasEditDiff?()=>l(!0):d,className:G(`text-xs font-mono truncate max-w-[200px] sm:max-w-[320px] cursor-pointer`,`text-muted-foreground hover:underline`),children:n.fileDisplayName})}),(0,$.jsx)(q,{children:n.hasEditDiff?`View diff`:n.filePath?Ri(n.filePath,i)??n.filePath:n.fileDisplayName})]}),n.hasEditDiff&&(0,$.jsx)(be,{open:c,onOpenChange:l,children:(0,$.jsxs)(ln,{className:`max-w-2xl h-[80vh] flex flex-col`,children:[(0,$.jsx)(w,{children:(0,$.jsx)(Ee,{children:(0,$.jsx)(`code`,{className:`text-sm font-mono`,children:Ri(n.filePath,i)??n.filePath})})}),(0,$.jsx)(`div`,{className:`overflow-auto flex-1 rounded border border-border bg-muted/30 p-3`,children:(0,$.jsx)(Ki,{oldText:n.editOldText,newText:n.editNewText})})]})})]}):n.path===null?null:(0,$.jsx)(`span`,{className:`text-xs font-mono text-muted-foreground truncate max-w-[200px] sm:max-w-[320px]`,title:n.path,children:n.path}),t[11]=n.editNewText,t[12]=n.editOldText,t[13]=n.fileDisplayName,t[14]=n.filePath,t[15]=n.hasEditDiff,t[16]=n.path,t[17]=c,t[18]=d,t[19]=i,t[20]=a):a=t[20];let o;return t[21]!==r||t[22]!==a?(o=(0,$.jsxs)(`div`,{className:`py-0.5 flex items-center gap-2 flex-wrap`,children:[r,a]}),t[21]=r,t[22]=a,t[23]=o):o=t[23],o}let f;t[24]===o?f=t[25]:(f=()=>s(!o),t[24]=o,t[25]=f);let p=n.toolName,m;t[26]===n.icon?m=t[27]:(m=(0,Z.createElement)(n.icon,{className:`h-4 w-4 text-brand`}),t[26]=n.icon,t[27]=m);let h;t[28]===n.displayName?h=t[29]:(h=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:n.displayName}),t[28]=n.displayName,t[29]=h);let g;t[30]===o?g=t[31]:(g=o?(0,$.jsx)($e,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(_e,{className:`h-4 w-4 shrink-0`}),t[30]=o,t[31]=g);let _;t[32]!==n.toolName||t[33]!==f||t[34]!==m||t[35]!==h||t[36]!==g?(_=(0,$.jsxs)(`button`,{onClick:f,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:p,children:[m,h,g]}),t[32]=n.toolName,t[33]=f,t[34]=m,t[35]=h,t[36]=g,t[37]=_):_=t[37];let v;t[38]!==n.toolId||t[39]!==n.toolInput||t[40]!==o?(v=o&&(0,$.jsxs)(`div`,{className:`py-2 border-t border-border`,children:[(0,$.jsxs)(`div`,{className:`text-xs text-muted-foreground mb-2 font-mono`,children:[`ID: `,n.toolId]}),n.toolInput?(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:n.toolInput}):null]}),t[38]=n.toolId,t[39]=n.toolInput,t[40]=o,t[41]=v):v=t[41];let y;return t[42]!==_||t[43]!==v?(y=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[_,v]}),t[42]=_,t[43]=v,t[44]=y):y=t[44],y}function ra(e){let t=(0,Q.c)(8),{data:n}=e,r=n.toolName===`code_search`,i;t[0]!==n.codeSearchFileGlob||t[1]!==n.codeSearchFilePath||t[2]!==n.codeSearchQuery||t[3]!==n.pattern||t[4]!==r?(i=r?(0,$.jsxs)($.Fragment,{children:[n.codeSearchQuery!==null&&(0,$.jsx)(Zi,{children:n.codeSearchQuery}),n.pattern!==null&&(0,$.jsxs)(Zi,{children:[`/`,n.pattern,`/`]}),n.codeSearchFilePath!==null&&(0,$.jsx)(Zi,{children:n.codeSearchFilePath}),n.codeSearchFileGlob!==null&&(0,$.jsx)(Zi,{children:n.codeSearchFileGlob})]}):n.pattern!==null&&(0,$.jsx)(Zi,{children:n.pattern}),t[0]=n.codeSearchFileGlob,t[1]=n.codeSearchFilePath,t[2]=n.codeSearchQuery,t[3]=n.pattern,t[4]=r,t[5]=i):i=t[5];let a;return t[6]===i?a=t[7]:(a=(0,$.jsx)($.Fragment,{children:i}),t[6]=i,t[7]=a),a}function ia(e){let t=(0,Q.c)(67),{data:n,inline:r,resultContent:i}=e,[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(!1),l=n.toolName===`code_search`,u=n.codeSearchQuery??n.pattern??n.codeSearchFilePath??n.codeSearchFileGlob??`search`;if(r){if(i&&(l||n.toolName===`find`||n.pattern!==null)){let e;t[0]===n.icon?e=t[1]:(e=(0,Z.createElement)(n.icon,{className:`h-3.5 w-3.5 shrink-0 text-brand`}),t[0]=n.icon,t[1]=e);let r;t[2]===n.displayName?r=t[3]:(r=(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n.displayName}),t[2]=n.displayName,t[3]=r);let a;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(a=()=>c(!0),t[4]=a):a=t[4];let o;t[5]===u?o=t[6]:(o=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:a,className:`text-xs font-mono text-muted-foreground hover:underline break-all cursor-pointer`,children:u})}),t[5]=u,t[6]=o);let l;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(q,{children:`View results`}),t[7]=l):l=t[7];let d;t[8]===o?d=t[9]:(d=(0,$.jsxs)(J,{children:[o,l]}),t[8]=o,t[9]=d);let f;t[10]!==e||t[11]!==r||t[12]!==d?(f=(0,$.jsxs)(`div`,{className:`py-0.5 flex items-center gap-2 flex-wrap`,children:[e,r,d]}),t[10]=e,t[11]=r,t[12]=d,t[13]=f):f=t[13];let p;t[14]!==s||t[15]!==i||t[16]!==u?(p=(0,$.jsx)(Gi,{open:s,onOpenChange:c,title:u,content:i}),t[14]=s,t[15]=i,t[16]=u,t[17]=p):p=t[17];let m;return t[18]!==f||t[19]!==p?(m=(0,$.jsxs)($.Fragment,{children:[f,p]}),t[18]=f,t[19]=p,t[20]=m):m=t[20],m}let e=n.toolName,r;t[21]===n.icon?r=t[22]:(r=(0,Z.createElement)(n.icon,{className:`h-3.5 w-3.5 shrink-0 text-brand`}),t[21]=n.icon,t[22]=r);let a;t[23]===n.displayName?a=t[24]:(a=(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n.displayName}),t[23]=n.displayName,t[24]=a);let o;t[25]!==n.toolName||t[26]!==r||t[27]!==a?(o=(0,$.jsxs)(`span`,{title:e,className:`inline-flex items-center gap-1`,children:[r,a]}),t[25]=n.toolName,t[26]=r,t[27]=a,t[28]=o):o=t[28];let d;t[29]===n?d=t[30]:(d=(0,$.jsx)(ra,{data:n}),t[29]=n,t[30]=d);let f;t[31]===n.lang?f=t[32]:(f=n.lang!==null&&(0,$.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded bg-muted text-muted-foreground`,children:n.lang}),t[31]=n.lang,t[32]=f);let p;return t[33]!==o||t[34]!==d||t[35]!==f?(p=(0,$.jsxs)(`div`,{className:`py-0.5 flex items-center gap-2 flex-wrap`,children:[o,d,f]}),t[33]=o,t[34]=d,t[35]=f,t[36]=p):p=t[36],p}let d;t[37]===a?d=t[38]:(d=()=>o(!a),t[37]=a,t[38]=d);let f=n.toolName,p;t[39]===n.icon?p=t[40]:(p=(0,Z.createElement)(n.icon,{className:`h-4 w-4 text-brand`}),t[39]=n.icon,t[40]=p);let m;t[41]===n.displayName?m=t[42]:(m=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:n.displayName}),t[41]=n.displayName,t[42]=m);let h;t[43]!==n.codeSearchFileGlob||t[44]!==n.codeSearchFilePath||t[45]!==n.codeSearchQuery||t[46]!==n.pattern||t[47]!==l?(h=l&&(0,$.jsxs)($.Fragment,{children:[n.codeSearchQuery!==null&&(0,$.jsx)(`code`,{className:`text-xs font-mono bg-muted text-muted-foreground rounded px-1 py-0.5 truncate max-w-[150px]`,children:n.codeSearchQuery}),n.pattern!==null&&(0,$.jsxs)(`code`,{className:`text-xs font-mono bg-muted text-muted-foreground rounded px-1 py-0.5 truncate max-w-[150px]`,children:[`/`,n.pattern,`/`]}),n.codeSearchFilePath!==null&&(0,$.jsx)(`code`,{className:`text-xs font-mono bg-muted text-muted-foreground rounded px-1 py-0.5 truncate max-w-[150px]`,children:n.codeSearchFilePath}),n.codeSearchFileGlob!==null&&(0,$.jsx)(`code`,{className:`text-xs font-mono bg-muted text-muted-foreground rounded px-1 py-0.5 truncate max-w-[150px]`,children:n.codeSearchFileGlob})]}),t[43]=n.codeSearchFileGlob,t[44]=n.codeSearchFilePath,t[45]=n.codeSearchQuery,t[46]=n.pattern,t[47]=l,t[48]=h):h=t[48];let g;t[49]===a?g=t[50]:(g=a?(0,$.jsx)($e,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(_e,{className:`h-4 w-4 shrink-0`}),t[49]=a,t[50]=g);let _;t[51]!==n.toolName||t[52]!==d||t[53]!==p||t[54]!==m||t[55]!==h||t[56]!==g?(_=(0,$.jsxs)(`button`,{onClick:d,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:f,children:[p,m,h,g]}),t[51]=n.toolName,t[52]=d,t[53]=p,t[54]=m,t[55]=h,t[56]=g,t[57]=_):_=t[57];let v;t[58]!==n.toolId||t[59]!==n.toolInput||t[60]!==a||t[61]!==l||t[62]!==i?(v=a&&(0,$.jsxs)(`div`,{className:`py-2 border-t border-border`,children:[(0,$.jsxs)(`div`,{className:`text-xs text-muted-foreground mb-2 font-mono`,children:[`ID: `,n.toolId]}),n.toolInput?(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:n.toolInput}):null,l&&i&&(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-64 mt-2`,children:i})]}),t[58]=n.toolId,t[59]=n.toolInput,t[60]=a,t[61]=l,t[62]=i,t[63]=v):v=t[63];let y;return t[64]!==_||t[65]!==v?(y=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[_,v]}),t[64]=_,t[65]=v,t[66]=y):y=t[66],y}function aa(e){let t=(0,Q.c)(57),{data:n,inline:r}=e,[i,a]=(0,Z.useState)(!1);if(r){let e=n.toolName,r;t[0]===n.icon?r=t[1]:(r=(0,Z.createElement)(n.icon,{className:`h-3.5 w-3.5 text-brand`}),t[0]=n.icon,t[1]=r);let i;t[2]===n.displayName?i=t[3]:(i=(0,$.jsx)(`span`,{className:`text-xs`,children:n.displayName}),t[2]=n.displayName,t[3]=i);let a;t[4]!==r||t[5]!==i?(a=(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:[r,i]}),t[4]=r,t[5]=i,t[6]=a):a=t[6];let o;t[7]!==n.toolName||t[8]!==a?(o=(0,$.jsx)(ea,{asChild:!0,children:(0,$.jsx)(`span`,{title:e,className:`inline-flex`,children:a})}),t[7]=n.toolName,t[8]=a,t[9]=o):o=t[9];let s;t[10]===n.toolId?s=t[11]:(s=(0,$.jsxs)(`div`,{className:`font-mono`,children:[`ID: `,n.toolId]}),t[10]=n.toolId,t[11]=s);let c;t[12]!==n.prompt||t[13]!==n.toolInput?(c=n.prompt?(0,$.jsx)(`div`,{className:`whitespace-pre-wrap leading-relaxed`,children:n.prompt}):n.toolInput?(0,$.jsx)(`pre`,{className:`font-mono whitespace-pre-wrap overflow-auto max-h-48`,children:n.toolInput}):null,t[12]=n.prompt,t[13]=n.toolInput,t[14]=c):c=t[14];let l;t[15]!==s||t[16]!==c?(l=(0,$.jsx)(ta,{className:`w-80 max-h-80 overflow-auto`,align:`start`,children:(0,$.jsxs)(`div`,{className:`text-xs text-muted-foreground space-y-2`,children:[s,c]})}),t[15]=s,t[16]=c,t[17]=l):l=t[17];let u;t[18]!==o||t[19]!==l?(u=(0,$.jsxs)($i,{children:[o,l]}),t[18]=o,t[19]=l,t[20]=u):u=t[20];let d;t[21]===n.agentName?d=t[22]:(d=n.agentName&&(0,$.jsx)(Yi,{name:n.agentName}),t[21]=n.agentName,t[22]=d);let f;t[23]===n.subagentType?f=t[24]:(f=n.subagentType&&(0,$.jsx)(Xi,{type:n.subagentType}),t[23]=n.subagentType,t[24]=f);let p;return t[25]!==d||t[26]!==f||t[27]!==u?(p=(0,$.jsxs)(`div`,{className:`py-0.5 flex items-center gap-2 flex-wrap`,children:[u,d,f]}),t[25]=d,t[26]=f,t[27]=u,t[28]=p):p=t[28],p}let o;t[29]===i?o=t[30]:(o=()=>a(!i),t[29]=i,t[30]=o);let s=n.toolName,c;t[31]===n.icon?c=t[32]:(c=(0,Z.createElement)(n.icon,{className:`h-4 w-4 text-brand`}),t[31]=n.icon,t[32]=c);let l;t[33]===n.displayName?l=t[34]:(l=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:n.displayName}),t[33]=n.displayName,t[34]=l);let u;t[35]===n.agentName?u=t[36]:(u=n.agentName&&(0,$.jsx)(Yi,{name:n.agentName}),t[35]=n.agentName,t[36]=u);let d;t[37]===n.subagentType?d=t[38]:(d=n.subagentType&&(0,$.jsx)(Xi,{type:n.subagentType}),t[37]=n.subagentType,t[38]=d);let f;t[39]===i?f=t[40]:(f=i?(0,$.jsx)($e,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(_e,{className:`h-4 w-4 shrink-0`}),t[39]=i,t[40]=f);let p;t[41]!==n.toolName||t[42]!==o||t[43]!==c||t[44]!==l||t[45]!==u||t[46]!==d||t[47]!==f?(p=(0,$.jsxs)(`button`,{onClick:o,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:s,children:[c,l,u,d,f]}),t[41]=n.toolName,t[42]=o,t[43]=c,t[44]=l,t[45]=u,t[46]=d,t[47]=f,t[48]=p):p=t[48];let m;t[49]!==n.prompt||t[50]!==n.toolId||t[51]!==n.toolInput||t[52]!==i?(m=i&&(0,$.jsxs)(`div`,{className:`py-2 border-t border-border`,children:[(0,$.jsxs)(`div`,{className:`text-xs text-muted-foreground mb-2 font-mono`,children:[`ID: `,n.toolId]}),n.prompt?(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:n.prompt}):n.toolInput?(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:n.toolInput}):null]}),t[49]=n.prompt,t[50]=n.toolId,t[51]=n.toolInput,t[52]=i,t[53]=m):m=t[53];let h;return t[54]!==p||t[55]!==m?(h=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[p,m]}),t[54]=p,t[55]=m,t[56]=h):h=t[56],h}function oa(e){let t=(0,Q.c)(21),{data:n,inline:r}=e,[i,a]=(0,Z.useState)(!1);if(r)return null;let o;t[0]===i?o=t[1]:(o=()=>a(!i),t[0]=i,t[1]=o);let s=n.toolName,c;t[2]===n.icon?c=t[3]:(c=(0,Z.createElement)(n.icon,{className:`h-4 w-4 text-brand`}),t[2]=n.icon,t[3]=c);let l;t[4]===n.displayName?l=t[5]:(l=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:n.displayName}),t[4]=n.displayName,t[5]=l);let u;t[6]===i?u=t[7]:(u=i?(0,$.jsx)($e,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(_e,{className:`h-4 w-4 shrink-0`}),t[6]=i,t[7]=u);let d;t[8]!==n.toolName||t[9]!==o||t[10]!==c||t[11]!==l||t[12]!==u?(d=(0,$.jsxs)(`button`,{onClick:o,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:s,children:[c,l,u]}),t[8]=n.toolName,t[9]=o,t[10]=c,t[11]=l,t[12]=u,t[13]=d):d=t[13];let f;t[14]!==n.toolId||t[15]!==n.toolInput||t[16]!==i?(f=i&&(0,$.jsxs)(`div`,{className:`py-2 border-t border-border`,children:[(0,$.jsxs)(`div`,{className:`text-xs text-muted-foreground mb-2 font-mono`,children:[`ID: `,n.toolId]}),n.toolInput?(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:n.toolInput}):null]}),t[14]=n.toolId,t[15]=n.toolInput,t[16]=i,t[17]=f):f=t[17];let p;return t[18]!==d||t[19]!==f?(p=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[d,f]}),t[18]=d,t[19]=f,t[20]=p):p=t[20],p}function sa(e){let t=(0,Q.c)(34),{data:n,inline:r}=e,[i,a]=(0,Z.useState)(!1);if(r){let e=n.toolName,r;t[0]===n.icon?r=t[1]:(r=(0,Z.createElement)(n.icon,{className:`h-3.5 w-3.5 shrink-0 text-brand`}),t[0]=n.icon,t[1]=r);let i;t[2]===n.displayName?i=t[3]:(i=(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n.displayName}),t[2]=n.displayName,t[3]=i);let a;t[4]!==n.toolName||t[5]!==r||t[6]!==i?(a=(0,$.jsxs)(`span`,{title:e,className:`inline-flex items-center gap-1`,children:[r,i]}),t[4]=n.toolName,t[5]=r,t[6]=i,t[7]=a):a=t[7];let o;t[8]===n.imageGenPrompt?o=t[9]:(o=n.imageGenPrompt!==null&&(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground truncate max-w-[200px] sm:max-w-[320px]`,title:n.imageGenPrompt,children:n.imageGenPrompt}),t[8]=n.imageGenPrompt,t[9]=o);let s;return t[10]!==a||t[11]!==o?(s=(0,$.jsxs)(`div`,{className:`py-0.5 flex items-center gap-2 flex-wrap`,children:[a,o]}),t[10]=a,t[11]=o,t[12]=s):s=t[12],s}let o;t[13]===i?o=t[14]:(o=()=>a(!i),t[13]=i,t[14]=o);let s=n.toolName,c;t[15]===n.icon?c=t[16]:(c=(0,Z.createElement)(n.icon,{className:`h-4 w-4 text-brand`}),t[15]=n.icon,t[16]=c);let l;t[17]===n.displayName?l=t[18]:(l=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:n.displayName}),t[17]=n.displayName,t[18]=l);let u;t[19]===i?u=t[20]:(u=i?(0,$.jsx)($e,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(_e,{className:`h-4 w-4 shrink-0`}),t[19]=i,t[20]=u);let d;t[21]!==n.toolName||t[22]!==o||t[23]!==c||t[24]!==l||t[25]!==u?(d=(0,$.jsxs)(`button`,{onClick:o,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:s,children:[c,l,u]}),t[21]=n.toolName,t[22]=o,t[23]=c,t[24]=l,t[25]=u,t[26]=d):d=t[26];let f;t[27]!==n.toolId||t[28]!==n.toolInput||t[29]!==i?(f=i&&(0,$.jsxs)(`div`,{className:`py-2 border-t border-border`,children:[(0,$.jsxs)(`div`,{className:`text-xs text-muted-foreground mb-2 font-mono`,children:[`ID: `,n.toolId]}),n.toolInput?(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:n.toolInput}):null]}),t[27]=n.toolId,t[28]=n.toolInput,t[29]=i,t[30]=f):f=t[30];let p;return t[31]!==d||t[32]!==f?(p=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[d,f]}),t[31]=d,t[32]=f,t[33]=p):p=t[33],p}function ca(e){let t=(0,Q.c)(35),{data:n,inline:r}=e,[i,a]=(0,Z.useState)(!1);if(r){let e=!!(n.prompt??(n.toolInput&&!n.command&&!n.path&&!n.pattern&&!n.fileDisplayName)),r;t[0]!==n.displayName||t[1]!==n.icon||t[2]!==n.prompt||t[3]!==n.toolId||t[4]!==n.toolInput||t[5]!==n.toolName||t[6]!==e?(r=e?(0,$.jsxs)($i,{children:[(0,$.jsx)(ea,{asChild:!0,children:(0,$.jsx)(`span`,{title:n.toolName,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)(n.icon,{className:`h-3.5 w-3.5 text-brand`}),(0,$.jsx)(`span`,{className:`text-xs`,children:n.displayName})]})})}),(0,$.jsx)(ta,{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: `,n.toolId]}),n.prompt?(0,$.jsx)(`div`,{className:`whitespace-pre-wrap leading-relaxed`,children:n.prompt}):n.toolInput?(0,$.jsx)(`pre`,{className:`font-mono whitespace-pre-wrap overflow-auto max-h-48`,children:n.toolInput}):null]})})]}):(0,$.jsxs)(`span`,{title:n.toolName,className:`inline-flex items-center gap-1`,children:[(0,Z.createElement)(n.icon,{className:`h-3.5 w-3.5 shrink-0 text-brand`}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n.displayName})]}),t[0]=n.displayName,t[1]=n.icon,t[2]=n.prompt,t[3]=n.toolId,t[4]=n.toolInput,t[5]=n.toolName,t[6]=e,t[7]=r):r=t[7];let i;t[8]===n.path?i=t[9]:(i=n.path!==null&&(0,$.jsx)(`span`,{className:`text-xs font-mono text-muted-foreground truncate max-w-[200px] sm:max-w-[320px]`,title:n.path,children:n.path}),t[8]=n.path,t[9]=i);let a;return t[10]!==r||t[11]!==i?(a=(0,$.jsxs)(`div`,{className:`py-0.5 flex items-center gap-2 flex-wrap`,children:[r,i]}),t[10]=r,t[11]=i,t[12]=a):a=t[12],a}let o;t[13]===i?o=t[14]:(o=()=>a(!i),t[13]=i,t[14]=o);let s=n.toolName,c;t[15]===n.icon?c=t[16]:(c=(0,Z.createElement)(n.icon,{className:`h-4 w-4 text-brand`}),t[15]=n.icon,t[16]=c);let l;t[17]===n.displayName?l=t[18]:(l=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:n.displayName}),t[17]=n.displayName,t[18]=l);let u;t[19]===i?u=t[20]:(u=i?(0,$.jsx)($e,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(_e,{className:`h-4 w-4 shrink-0`}),t[19]=i,t[20]=u);let d;t[21]!==n.toolName||t[22]!==o||t[23]!==c||t[24]!==l||t[25]!==u?(d=(0,$.jsxs)(`button`,{onClick:o,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:s,children:[c,l,u]}),t[21]=n.toolName,t[22]=o,t[23]=c,t[24]=l,t[25]=u,t[26]=d):d=t[26];let f;t[27]!==n.prompt||t[28]!==n.toolId||t[29]!==n.toolInput||t[30]!==i?(f=i&&(0,$.jsxs)(`div`,{className:`py-2 border-t border-border`,children:[(0,$.jsxs)(`div`,{className:`text-xs text-muted-foreground mb-2 font-mono`,children:[`ID: `,n.toolId]}),n.prompt?(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:n.prompt}):n.toolInput?(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:n.toolInput}):null]}),t[27]=n.prompt,t[28]=n.toolId,t[29]=n.toolInput,t[30]=i,t[31]=f):f=t[31];let p;return t[32]!==d||t[33]!==f?(p=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[d,f]}),t[32]=d,t[33]=f,t[34]=p):p=t[34],p}function la(e){let t=(0,Q.c)(34),{block:n,inline:r,resultContent:i}=e,{state:a}=Yn(),{setPendingExplorerPath:o,setActiveMainTab:s}=Or(),c;if(t[0]!==a.projects||t[1]!==a.selectedProjectId||t[2]!==a.selectedThreadId){let e;t[4]===a.selectedProjectId?e=t[5]:(e=e=>e.projectId===a.selectedProjectId,t[4]=a.selectedProjectId,t[5]=e),c=a.projects.find(e)?.threads.find(e=>e.threadId===a.selectedThreadId),t[0]=a.projects,t[1]=a.selectedProjectId,t[2]=a.selectedThreadId,t[3]=c}else c=t[3];let l=c?.path,u=Wi(n,l),d;t[6]!==s||t[7]!==o?(d=function(e){o(e),s(`explorer`)},t[6]=s,t[7]=o,t[8]=d):d=t[8];let f=d;switch(u.toolType){case`bash`:{let e;return t[9]!==u||t[10]!==r||t[11]!==i?(e=(0,$.jsx)(Qi,{data:u,inline:r,resultContent:i}),t[9]=u,t[10]=r,t[11]=i,t[12]=e):e=t[12],e}case`file`:{let e;return t[13]!==u||t[14]!==f||t[15]!==r||t[16]!==l?(e=(0,$.jsx)(na,{data:u,inline:r,rootPath:l,onOpenFile:f}),t[13]=u,t[14]=f,t[15]=r,t[16]=l,t[17]=e):e=t[17],e}case`search`:{let e;return t[18]!==u||t[19]!==r||t[20]!==i?(e=(0,$.jsx)(ia,{data:u,inline:r,resultContent:i}),t[18]=u,t[19]=r,t[20]=i,t[21]=e):e=t[21],e}case`agent`:{let e;return t[22]!==u||t[23]!==r?(e=(0,$.jsx)(aa,{data:u,inline:r}),t[22]=u,t[23]=r,t[24]=e):e=t[24],e}case`todo`:{let e;return t[25]!==u||t[26]!==r?(e=(0,$.jsx)(oa,{data:u,inline:r}),t[25]=u,t[26]=r,t[27]=e):e=t[27],e}case`imageGen`:{let e;return t[28]!==u||t[29]!==r?(e=(0,$.jsx)(sa,{data:u,inline:r}),t[28]=u,t[29]=r,t[30]=e):e=t[30],e}default:{let e;return t[31]!==u||t[32]!==r?(e=(0,$.jsx)(ca,{data:u,inline:r}),t[31]=u,t[32]=r,t[33]=e):e=t[33],e}}}function ua(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 da(e){let t=(0,Q.c)(29),{imageUrl:n,imageData:r}=e,[i,a]=(0,Z.useState)(!1),o=r?`data:image/png;base64,${r}`:n??``,s;t[0]===o?s=t[1]:(s=async()=>{let e=`generated-image-${Date.now()}.png`,{path:t}=await Yt(o.startsWith(`data:`)?{imageData:o.replace(/^data:[^;]+;base64,/,``),filename:e}:{imageUrl:o,filename:e});X({title:`Saved to downloads: ${t.split(`/`).pop()}`})},t[0]=o,t[1]=s);let c=s,l;t[2]===o?l=t[3]:(l=async()=>{await p(o.startsWith(`data:`)?{imageData:o.replace(/^data:[^;]+;base64,/,``)}:{imageUrl:o}),a(!0),setTimeout(()=>a(!1),2e3)},t[2]=o,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]===o?f=t[6]:(f=(0,$.jsx)(`img`,{src:o,alt:`Generated image`,className:`max-w-full rounded-lg block`,style:d}),t[5]=o,t[6]=f);let m;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(cn,{className:`h-3.5 w-3.5`}),t[7]=m):m=t[7];let h;t[8]===c?h=t[9]:(h=(0,$.jsx)(Y,{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:m})}),t[8]=c,t[9]=h);let g;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(q,{children:`Save image`}),t[10]=g):g=t[10];let _;t[11]===h?_=t[12]:(_=(0,$.jsxs)(J,{children:[h,g]}),t[11]=h,t[12]=_);let v;t[13]===i?v=t[14]:(v=i?(0,$.jsx)(qt,{className:`h-3.5 w-3.5 text-green-500`}):(0,$.jsx)(je,{className:`h-3.5 w-3.5`}),t[13]=i,t[14]=v);let y;t[15]!==u||t[16]!==v?(y=(0,$.jsx)(Y,{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:v})}),t[15]=u,t[16]=v,t[17]=y):y=t[17];let b=i?`Copied!`:`Copy to clipboard`,x;t[18]===b?x=t[19]:(x=(0,$.jsx)(q,{children:b}),t[18]=b,t[19]=x);let S;t[20]!==y||t[21]!==x?(S=(0,$.jsxs)(J,{children:[y,x]}),t[20]=y,t[21]=x,t[22]=S):S=t[22];let C;t[23]!==S||t[24]!==_?(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)(ar,{children:[_,S]})}),t[23]=S,t[24]=_,t[25]=C):C=t[25];let w;return t[26]!==C||t[27]!==f?(w=(0,$.jsxs)(`div`,{className:`mb-3 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 fa(e){let t=(0,Q.c)(72),{block:n,inline:r,sequence:i}=e,a=i===void 0?0:i,[o,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(!1),{state:u}=Yn(),d=u.projects,f,p,m,h,g,_,v,y;if(t[0]!==n||t[1]!==r||t[2]!==a||t[3]!==u.projects||t[4]!==u.selectedProjectId||t[5]!==u.selectedThreadId){_=Symbol.for(`react.early_return_sentinel`);bb0:{let e;t[14]===u.selectedProjectId?e=t[15]:(e=e=>e.projectId===u.selectedProjectId,t[14]=u.selectedProjectId,t[15]=e);let i=d.find(e)?.threads.find(e=>e.threadId===u.selectedThreadId)?.path;y=n.toolName??`Unknown Tool`,v=n.toolCallId??`unknown`;let o=n,s=n.result??o.content,c;t[16]!==o||t[17]!==y?(c=y===`todo`?sr(o):null,t[16]=o,t[17]=y,t[18]=c):c=t[18];let l=c;if(m=Ri(Ui(s),i),!(m.length>0)&&l===null){_=null;break bb0}if(f=Li(y),typeof s==`object`&&s){let e=s,n=e.returnDisplay??e.return_display;if(typeof n==`string`&&n.trim()){let e;t[19]===n?e=t[20]:(e=n.trim(),t[19]=n,t[20]=e),f=e}else if(y===`read`||y===`file_read`){let n=e.filePath??e.file_path??e.path??``;if(n){let e;t[21]===n?e=t[22]:(e=n.split(`/`).pop()??n,t[21]=n,t[22]=e),f=`Completed ${e}`}}}else if(s==null){let e;t[23]===y?e=t[24]:(e=Li(y),t[23]=y,t[24]=e),f=`${e} (no result)`}if(f=Ri(f,i),l!==null){let e;t[25]!==a||t[26]!==l?(e=(0,$.jsx)(dr,{todos:l,sequence:a}),t[25]=a,t[26]=l,t[27]=e):e=t[27],_=e;break bb0}if(y===`generate_image`){let e;t[28]===s?e=t[29]:(e=ua(s),t[28]=s,t[29]=e);let n=e;if(n&&(n.imageUrl||n.imageData)){let e;t[30]!==n.imageData||t[31]!==n.imageUrl?(e=(0,$.jsx)(da,{imageUrl:n.imageUrl,imageData:n.imageData}),t[30]=n.imageData,t[31]=n.imageUrl,t[32]=e):e=t[32],_=e;break bb0}}if(r){_=null;break bb0}let b;t[33]===y?b=t[34]:(b=y.toLowerCase().includes(`bash`),t[33]=y,t[34]=b),p=b,h=m?m.split(`
15
+ `):[],g=p?h.slice(0,3).join(`
16
+ `):m}t[0]=n,t[1]=r,t[2]=a,t[3]=u.projects,t[4]=u.selectedProjectId,t[5]=u.selectedThreadId,t[6]=f,t[7]=p,t[8]=m,t[9]=h,t[10]=g,t[11]=_,t[12]=v,t[13]=y}else f=t[6],p=t[7],m=t[8],h=t[9],g=t[10],_=t[11],v=t[12],y=t[13];if(_!==Symbol.for(`react.early_return_sentinel`))return _;let b=g,x=p&&h.length>3;if(p){let e;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Fe,{className:`h-4 w-4 shrink-0`}),t[35]=e):e=t[35];let n;t[36]===f?n=t[37]:(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:f})]}),t[36]=f,t[37]=n);let r;t[38]!==x||t[39]!==b||t[40]!==m||t[41]!==h?(r=m&&(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${x?` cursor-pointer hover:bg-muted/80`:``}`,onClick:x?()=>l(!0):void 0,title:x?`Click to see full output`:void 0,children:[b,x&&(0,$.jsxs)(`span`,{className:`text-muted-foreground`,children:[`
17
+ `,`...`]})]}),x&&(0,$.jsxs)(`button`,{type:`button`,onClick:()=>l(!0),className:`mt-1 text-xs text-brand hover:underline`,children:[`Show full output (`,h.length,` lines)`]})]}),t[38]=x,t[39]=b,t[40]=m,t[41]=h,t[42]=r):r=t[42];let i;t[43]!==n||t[44]!==r?(i=(0,$.jsxs)(`div`,{className:`mb-3 rounded-lg border border-border bg-muted/50 overflow-hidden`,children:[n,r]}),t[43]=n,t[44]=r,t[45]=i):i=t[45];let a;t[46]!==c||t[47]!==x||t[48]!==m?(a=x&&(0,$.jsx)(be,{open:c,onOpenChange:l,children:(0,$.jsxs)(ln,{className:`max-w-3xl max-h-[80vh] flex flex-col`,children:[(0,$.jsx)(w,{children:(0,$.jsx)(Ee,{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:m})]})}),t[46]=c,t[47]=x,t[48]=m,t[49]=a):a=t[49];let o;return t[50]!==i||t[51]!==a?(o=(0,$.jsxs)($.Fragment,{children:[i,a]}),t[50]=i,t[51]=a,t[52]=o):o=t[52],o}let S;t[53]===o?S=t[54]:(S=()=>s(!o),t[53]=o,t[54]=S);let C=`${y} result`,T;t[55]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(Fe,{className:`h-4 w-4 shrink-0`}),t[55]=T):T=t[55];let E;t[56]===f?E=t[57]:(E=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:f}),t[56]=f,t[57]=E);let D;t[58]===o?D=t[59]:(D=o?(0,$.jsx)($e,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(_e,{className:`h-4 w-4 shrink-0`}),t[58]=o,t[59]=D);let O;t[60]!==S||t[61]!==C||t[62]!==E||t[63]!==D?(O=(0,$.jsxs)(`button`,{onClick:S,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:C,children:[T,E,D]}),t[60]=S,t[61]=C,t[62]=E,t[63]=D,t[64]=O):O=t[64];let k;t[65]!==o||t[66]!==m||t[67]!==v?(k=o&&(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: `,v]}),m&&(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:m})]}),t[65]=o,t[66]=m,t[67]=v,t[68]=k):k=t[68];let A;return t[69]!==O||t[70]!==k?(A=(0,$.jsxs)(`div`,{className:`mb-3 rounded-lg border border-border bg-muted/50 overflow-hidden`,children:[O,k]}),t[69]=O,t[70]=k,t[71]=A):A=t[71],A}function pa(e){let t=(0,Q.c)(22),{text:n,label:r,isStreaming:i,hasContentAfter:a}=e,o=i===void 0?!1:i,s=a===void 0?!1:a,[c,l]=(0,Z.useState)(null),u=(0,Z.useRef)(o),d=(0,Z.useRef)(s),f,p;if(t[0]!==s||t[1]!==o?(f=()=>{(u.current&&!o||!d.current&&s)&&(0,Z.startTransition)(()=>{l(!1)}),u.current=o,d.current=s},p=[o,s,l],t[0]=s,t[1]=o,t[2]=f,t[3]=p):(f=t[2],p=t[3]),(0,Z.useEffect)(f,p),!n?.trim())return null;let m=c??o,h;t[4]===m?h=t[5]:(h=()=>l(!m),t[4]=m,t[5]=h);let g=r??`Thinking`,_;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(Ot,{className:`h-4 w-4 shrink-0 text-brand`}),t[6]=_):_=t[6];let v=r??`Thinking`,y;t[7]===v?y=t[8]:(y=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:v}),t[7]=v,t[8]=y);let b;t[9]===m?b=t[10]:(b=m?(0,$.jsx)($e,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(_e,{className:`h-4 w-4 shrink-0`}),t[9]=m,t[10]=b);let x;t[11]!==b||t[12]!==h||t[13]!==g||t[14]!==y?(x=(0,$.jsxs)(`button`,{onClick:h,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:g,children:[_,y,b]}),t[11]=b,t[12]=h,t[13]=g,t[14]=y,t[15]=x):x=t[15];let S;t[16]!==m||t[17]!==n?(S=m&&(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[16]=m,t[17]=n,t[18]=S):S=t[18];let C;return t[19]!==x||t[20]!==S?(C=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[x,S]}),t[19]=x,t[20]=S,t[21]=C):C=t[21],C}function ma({toolCall:e,className:t}){let{state:n,dispatch:r}=Yn(),[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:G(`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)(ot,{className:`h-3.5 w-3.5 animate-spin`}),(0,$.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:e.name===`bash`?`Run`:e.name.charAt(0).toUpperCase()+e.name.slice(1)}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.name===`bash`&&typeof e.input?.command==`string`?`run "${e.input.command}"`:typeof e.input?.description==`string`?e.input.description:`running`})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(`button`,{onClick:()=>{a(e=>!e)},className:`p-1 hover:bg-muted/50 rounded transition-colors`,title:i?`Collapse`:`Expand`,children:i?(0,$.jsx)(Le,{className:`h-3.5 w-3.5`}):(0,$.jsx)($e,{className:`h-3.5 w-3.5`})}),(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(`button`,{onClick:()=>{r({type:K.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:K.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`,children:(0,$.jsx)(St,{className:`h-3.5 w-3.5`})})}),(0,$.jsx)(q,{className:`bg-red-600 text-white border-red-600`,children:`Stop this process`})]})]})]}),i&&(0,$.jsxs)(`div`,{className:`py-2 border-t border-border min-h-[8rem] overflow-auto`,children:[(0,$.jsxs)(`div`,{className:`text-xs text-muted-foreground mb-2 font-mono`,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-muted-foreground`,children:[(0,$.jsx)(ot,{className:`h-3 w-3 animate-spin`}),`Executing`,o&&` with progress`,`...`]})]})]}):null}function ha(e){let t=(0,Q.c)(51),{toolCallId:n,question:r,options:i,context:a,answeredText:o}=e,[s,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)(!!o),[d,f]=(0,Z.useState)(o??``),[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(null),_;t[0]!==p||t[1]!==n?(_=async e=>{if(!(!e.trim()||p)){m(!0);try{await Ze(n,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]=n,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,n;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(qt,{className:`h-4 w-4`}),n=(0,$.jsx)(`span`,{className:`font-medium`,children:`Answered:`}),t[14]=e,t[15]=n):(e=t[14],n=t[15]);let r;return t[16]===d?r=t[17]:(r=(0,$.jsx)(`div`,{className:`rounded-lg p-3 my-2`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[e,n,(0,$.jsx)(`span`,{children:d})]})}),t[16]=d,t[17]=r),r}let T;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(N,{className:`h-5 w-5 text-brand shrink-0 mt-0.5`}),t[18]=T):T=t[18];let E;t[19]===r?E=t[20]:(E=(0,$.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:(0,$.jsx)(Ti,{content:r})}),t[19]=r,t[20]=E);let D;t[21]===a?D=t[22]:(D=a&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:a}),t[21]=a,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]!==i||t[29]!==h?(k=i&&i.length>0&&(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2 mb-3`,children:i.map(e=>{let t=h===e;return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>b(e),disabled:p,className:G(`rounded-md border px-3 py-1.5 text-sm font-medium transition-colors disabled:opacity-50 flex items-center gap-1.5`,t?`border-foreground/20 bg-accent text-accent-foreground`:`border-foreground/20 bg-background text-foreground hover:bg-accent hover:text-accent-foreground`),children:[t&&(0,$.jsx)(qt,{className:`h-3.5 w-3.5 text-foreground`}),e]},e)})}),t[26]=b,t[27]=p,t[28]=i,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=i?.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-border bg-background px-3 py-1.5 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring 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)(Ue,{className:`h-3 w-3`}),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:`h-7 w-7 rounded-full bg-primary text-primary-foreground hover:bg-primary/90 transition-colors disabled:opacity-50 flex items-center justify-center shrink-0`,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-t border-border 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 ga(e){let t=(0,Q.c)(46),{toolCallId:n,intention:r,code:i}=e,{state:a}=Yn(),o=a.selectedThreadId,s;t[0]===n?s=t[1]:(s=cr(n),t[0]=n,t[1]=s);let c=s,[l,u]=(0,Z.useState)(c?.status??`running`),d;t[2]===c?d=t[3]:(d=()=>{if(!c||c.status!==`success`)return null;let e=c.result;return e==null?null:typeof e==`string`?e:JSON.stringify(e,null,2)},t[2]=c,t[3]=d);let[f,p]=(0,Z.useState)(d),[m,h]=(0,Z.useState)(c?.error??null),g,_;t[4]===n?(g=t[5],_=t[6]):(g=()=>or(n,()=>{let e=cr(n);if(e)if(u(e.status),e.status===`success`){let t=e.result;p(t==null?null:typeof t==`string`?t:JSON.stringify(t,null,2))}else e.status===`error`&&h(e.error??null)}),_=[n],t[4]=n,t[5]=g,t[6]=_),(0,Z.useEffect)(g,_);let v,y;t[7]!==i||t[8]!==o||t[9]!==n?(v=()=>{o&&fr(n,i,o)},y=[n,i,o],t[7]=i,t[8]=o,t[9]=n,t[10]=v,t[11]=y):(v=t[10],y=t[11]),(0,Z.useEffect)(v,y);let[b,x]=(0,Z.useState)(!1),S;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(S=()=>x(_a),t[12]=S):S=t[12];let w=S;if(l===`running`){let e;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(C,{className:`h-4 w-4 shrink-0 text-brand animate-pulse`}),t[13]=e):e=t[13];let n=r||`Executing Browser JS...`,i;return t[14]===n?i=t[15]:(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[14]=n,t[15]=i),i}if(l===`success`){let e;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(C,{className:`h-4 w-4 shrink-0 text-brand`}),t[16]=e):e=t[16];let n=r||`Browser JS Executed Successfully`,a;t[17]===n?a=t[18]:(a=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:n}),t[17]=n,t[18]=a);let o;t[19]===b?o=t[20]:(o=b?(0,$.jsx)($e,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(_e,{className:`h-4 w-4 shrink-0`}),t[19]=b,t[20]=o);let s;t[21]!==a||t[22]!==o?(s=(0,$.jsxs)(`button`,{onClick:w,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:[e,a,o]}),t[21]=a,t[22]=o,t[23]=s):s=t[23];let c;t[24]!==i||t[25]!==b||t[26]!==f?(c=b&&(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}),f!=null&&(0,$.jsx)(`pre`,{className:`text-xs text-foreground leading-relaxed whitespace-pre-wrap border-t border-border pt-2`,children:f})]}),t[24]=i,t[25]=b,t[26]=f,t[27]=c):c=t[27];let l;return t[28]!==s||t[29]!==c?(l=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[s,c]}),t[28]=s,t[29]=c,t[30]=l):l=t[30],l}let T;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(C,{className:`h-4 w-4 shrink-0 text-destructive`}),t[31]=T):T=t[31];let E=r||`Browser JS Execution Failed`,D;t[32]===E?D=t[33]:(D=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:E}),t[32]=E,t[33]=D);let O;t[34]===b?O=t[35]:(O=b?(0,$.jsx)($e,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(_e,{className:`h-4 w-4 shrink-0`}),t[34]=b,t[35]=O);let k;t[36]!==D||t[37]!==O?(k=(0,$.jsxs)(`button`,{onClick:w,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:[T,D,O]}),t[36]=D,t[37]=O,t[38]=k):k=t[38];let A;t[39]!==i||t[40]!==m||t[41]!==b?(A=b&&(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:m}),(0,$.jsx)(`pre`,{className:`text-xs text-muted-foreground leading-relaxed whitespace-pre-wrap`,children:i})]}),t[39]=i,t[40]=m,t[41]=b,t[42]=A):A=t[42];let j;return t[43]!==k||t[44]!==A?(j=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[k,A]}),t[43]=k,t[44]=A,t[45]=j):j=t[45],j}function _a(e){return!e}function va(e){let t=(0,Q.c)(29),{src:n}=e,[r,i]=(0,Z.useState)(!1),a;t[0]===n?a=t[1]:(a=async()=>{let e=`generated-image-${Date.now()}.png`,{path:t}=await Yt(n.startsWith(`data:`)?{imageData:n.replace(/^data:[^;]+;base64,/,``),filename:e}:{imageUrl:n,filename:e});X({title:`Saved to downloads: ${t.split(`/`).pop()}`})},t[0]=n,t[1]=a);let o=a,s;t[2]===n?s=t[3]:(s=async()=>{await p(n.startsWith(`data:`)?{imageData:n.replace(/^data:[^;]+;base64,/,``)}:{imageUrl:n}),i(!0),setTimeout(()=>i(!1),2e3)},t[2]=n,t[3]=s);let c=s,l;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(l={maxHeight:`512px`},t[4]=l):l=t[4];let u;t[5]===n?u=t[6]:(u=(0,$.jsx)(`img`,{src:n,alt:`Generated image`,className:`max-w-full rounded-lg border border-border block`,style:l}),t[5]=n,t[6]=u);let d;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(cn,{className:`h-3.5 w-3.5`}),t[7]=d):d=t[7];let f;t[8]===o?f=t[9]:(f=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(`button`,{onClick:o,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:d})}),t[8]=o,t[9]=f);let m;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(q,{children:`Save image`}),t[10]=m):m=t[10];let h;t[11]===f?h=t[12]:(h=(0,$.jsxs)(J,{children:[f,m]}),t[11]=f,t[12]=h);let g;t[13]===r?g=t[14]:(g=r?(0,$.jsx)(qt,{className:`h-3.5 w-3.5 text-green-500`}):(0,$.jsx)(je,{className:`h-3.5 w-3.5`}),t[13]=r,t[14]=g);let _;t[15]!==c||t[16]!==g?(_=(0,$.jsx)(Y,{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:g})}),t[15]=c,t[16]=g,t[17]=_):_=t[17];let v=r?`Copied!`:`Copy to clipboard`,y;t[18]===v?y=t[19]:(y=(0,$.jsx)(q,{children:v}),t[18]=v,t[19]=y);let b;t[20]!==_||t[21]!==y?(b=(0,$.jsxs)(J,{children:[_,y]}),t[20]=_,t[21]=y,t[22]=b):b=t[22];let x;t[23]!==b||t[24]!==h?(x=(0,$.jsx)(`div`,{className:`absolute top-2 right-2 flex gap-1 opacity-0 group-hover/img:opacity-100 transition-opacity`,children:(0,$.jsxs)(ar,{children:[h,b]})}),t[23]=b,t[24]=h,t[25]=x):x=t[25];let S;return t[26]!==x||t[27]!==u?(S=(0,$.jsxs)(`div`,{className:`mt-2 relative group/img inline-block max-w-full`,children:[u,x]}),t[26]=x,t[27]=u,t[28]=S):S=t[28],S}function ya(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 ba(e,t,n,r){return e.name===`ask_user`?(0,$.jsx)(ha,{toolCallId:e.id,question:JSON.stringify(e.input?.question??``),options:e.input?.options,context:e.input?.context,answeredText:r},t):e.name===`run_js`||e.name===`run_web_worker`?(0,$.jsx)(ga,{toolCallId:e.id,intention:e.input?.intention??``,code:e.input?.code??``},t):n?(0,$.jsxs)(`span`,{children:[(0,$.jsx)(ma,{toolCall:e}),(0,$.jsx)(la,{inline:!0,block:e,resultContent:r})]},t):(0,$.jsx)(la,{inline:!0,block:e,resultContent:r},t)}function xa({message:e,threadId:t,messageIndex:n=0}){let r=e.sender===`user`,i=r?null:Qn(e.content),[a,o]=(0,Z.useState)(!1),s=e.timestamp?new Date(e.timestamp).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}):``;async function c(){if(!(!e.checkpointRef||!t||a)){o(!0);try{let n=await ze(t,e.checkpointRef);n.success?X({title:`Checkpoint restored`,description:`Working tree restored to before this agent run.`}):X({title:`Restore failed`,description:n.error??`Could not restore checkpoint.`,variant:`destructive`})}catch(e){X({title:`Restore failed`,description:e instanceof Error?e.message:`Unknown error`,variant:`destructive`})}finally{o(!1)}}}return(0,$.jsxs)(`div`,{className:G(`group flex gap-3 px-4 py-4`,r?`flex-row-reverse`:`flex-row`),children:[(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-1 shrink-0`,children:[(0,$.jsx)(`div`,{className:G(`flex h-7 w-7 items-center justify-center rounded-full`,r?`bg-foreground`:`bg-muted`),children:r?(0,$.jsx)(vt,{className:`h-3.5 w-3.5 text-background`}):(0,$.jsx)(Ht,{className:`h-3.5 w-3.5 text-muted-foreground`})}),r&&e.checkpointRef&&(0,$.jsx)(ar,{children:(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(`button`,{onClick:c,disabled:a,className:`flex items-center justify-center h-5 w-5 rounded-md text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity hover:text-foreground hover:bg-muted disabled:opacity-50`,children:(0,$.jsx)(Re,{className:G(`h-3 w-3`,a&&`animate-spin`)})})}),(0,$.jsx)(q,{side:`left`,children:`Restore checkpoint`})]})})]}),(0,$.jsxs)(`div`,{className:G(`flex flex-1 flex-col gap-1 min-w-0`,r&&`items-end`),children:[(0,$.jsxs)(`div`,{className:G(`flex items-center gap-2`,r&&`flex-row-reverse`),children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:r?`You`:`Agent`}),s&&(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`}),s]}),e.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)(C,{className:`h-2.5 w-2.5`}),jr(e.model)]}),e.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)(A,{className:`h-2.5 w-2.5`}),e.metadata.processingTimeMs>=6e4?`${Math.floor(e.metadata.processingTimeMs/6e4)}m ${Math.round(e.metadata.processingTimeMs%6e4/1e3)}s`:`${Math.round(e.metadata.processingTimeMs/1e3)}s`]}),e.metadata?.tokenCount&&(0,$.jsxs)(`span`,{className:`text-[10px] text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity`,children:[e.metadata.tokenCount.toLocaleString(),` tokens`]})]}),(0,$.jsx)(`div`,{className:G(`rounded-xl px-4 py-3 flex flex-col gap-0.5 min-w-0`,r?`bg-foreground text-background`:`bg-muted text-foreground`),children:e.isThinking?(()=>{let t=nr(e.content);return t?.length?t.map((e,n)=>e.type===`tool_use`?ba(e,n,!1,ya(t,e.id)):e.type===`tool-result`?(0,$.jsx)(fa,{inline:!0,block:e},n):e.type===`reasoning`&&`text`in e?(0,$.jsx)(pa,{text:Zn(e.text),label:e.label},n):null):(0,$.jsx)(`div`,{className:`text-xs text-muted-foreground leading-relaxed whitespace-pre-wrap`,children:(0,$.jsx)(Ti,{content:Zn(e.content),enableMermaid:!0})})})():i?(()=>{let e=i.filter(e=>e.type===`tool_use`&&e.name===`ask_user`);return(0,$.jsxs)($.Fragment,{children:[i.map((e,t)=>e.type===`tool_use`&&e.name===`todo`||e.type===`tool-result`&&e.toolName===`todo`?e.type===`tool-result`?(0,$.jsx)(fa,{inline:!0,sequence:n,block:e},t):null:e.type===`tool_use`&&e.name===`ask_user`||e.type===`tool-result`&&e.toolName===`ask_user`?null:(0,$.jsx)(`div`,{children:e.type===`reasoning`&&`text`in e?(0,$.jsx)(pa,{text:Zn(e.text),label:e.label}):e.type===`text`&&`text`in e?(0,$.jsx)(Ti,{content:Zn(e.text),enableMermaid:!0}):e.type===`tool_use`?ba(e,void 0,!1,ya(i,e.id)):e.type===`tool-result`?(0,$.jsx)(fa,{inline:!0,block:e}):null},t)),e.map((e,t)=>(0,$.jsx)(ha,{toolCallId:e.id,question:JSON.stringify(e.input?.question??``),options:e.input?.options,context:e.input?.context,answeredText:ya(i,e.id)},`ask-${t}`))]})})():(0,$.jsx)(Ti,{content:Zn(e.content),enableMermaid:!0})}),(e.generatedImageUrl||e.generatedImageData)&&(0,$.jsx)(va,{src:e.generatedImageData?`data:image/png;base64,${e.generatedImageData}`:e.generatedImageUrl}),e.attachments&&e.attachments.length>0&&(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5 mt-1`,children:e.attachments.map((e,t)=>(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)(kt,{className:`h-2.5 w-2.5`}),e.fileName]},t))})]})]})}function Sa(e){let t=(0,Q.c)(24),{segments:n,model:r,isCreatingProject:i,isProcessingThread:a,totalMessages:o}=e,s=o===void 0?0:o,c,l,u,d,f;if(t[0]!==i||t[1]!==a||t[2]!==r||t[3]!==n||t[4]!==s){let e=Xn(n),o=t=>e[t].type===`reasoning`?e.slice(t+1).length>0:!1;d=`group flex gap-3 px-4 py-4`,t[10]===Symbol.for(`react.memo_cache_sentinel`)?(f=(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)(Ht,{className:`h-3.5 w-3.5 text-white`})}),t[10]=f):f=t[10],c=`flex flex-1 flex-col gap-1 min-w-0`;let p;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:`Agent`}),t[11]=p):p=t[11];let m;t[12]===r?m=t[13]:(m=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)(C,{className:`h-2.5 w-2.5`}),jr(r)]}),t[12]=r,t[13]=m),t[14]===m?l=t[15]:(l=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[p,m]}),t[14]=m,t[15]=l),u=e.length>0?(()=>{let t=e.filter(Ca);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)(fa,{inline:!0,sequence:s,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)(pa,{text:Zn(t.text),label:t.label,isStreaming:!0,hasContentAfter:o(n)}):t.type===`text`&&`text`in t?(0,$.jsx)(Ti,{content:Zn(t.text),enableMermaid:!0}):t.type===`tool_use`?ba(t,void 0,!0,ya(e,t.id)):t.type===`tool-result`?(0,$.jsx)(fa,{inline:!0,block:t}):null},`b-${n}`)),t.map((t,n)=>(0,$.jsx)(ha,{toolCallId:t.id,question:JSON.stringify(t.input?.question??``),options:t.input?.options,context:t.input?.context,answeredText:ya(e,t.id)},`ask-${n}`))]})})():i||a?(0,$.jsx)(`div`,{className:`rounded-xl bg-muted px-4 py-3 min-w-0 text-foreground`,children:(0,$.jsx)(pa,{text:`Setting up workspace and running install commands...`,label:`Installing`,isStreaming:!0,hasContentAfter:!1})}):(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]=i,t[1]=a,t[2]=r,t[3]=n,t[4]=s,t[5]=c,t[6]=l,t[7]=u,t[8]=d,t[9]=f}else c=t[5],l=t[6],u=t[7],d=t[8],f=t[9];let p;t[16]!==c||t[17]!==l||t[18]!==u?(p=(0,$.jsxs)(`div`,{className:c,children:[l,u]}),t[16]=c,t[17]=l,t[18]=u,t[19]=p):p=t[19];let m;return t[20]!==d||t[21]!==f||t[22]!==p?(m=(0,$.jsxs)(`div`,{className:d,children:[f,p]}),t[20]=d,t[21]=f,t[22]=p,t[23]=m):m=t[23],m}function Ca(e){return e.type===`tool_use`&&e.name===`ask_user`}var wa=(0,Z.memo)(Sa,(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 Ta(e){let t=(0,Q.c)(34),{projects:n,onSelectProject:r,onCreateThread:i,onConnectRepo:a,onNewApp:o,onOpenFolder:s}=e,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(`img`,{src:`/tarsk-color.svg`,alt:`Tarsk`,className:`h-16 w-16 rounded-lg`}),t[0]=c):c=t[0];let l;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight text-foreground text-balance`,children:`Let's build it!`}),t[1]=l):l=t[1];let u=n.length===0?`Start or connect your first project`:`Select a project to start coding`,d;t[2]===u?d=t[3]:(d=(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3`,children:[c,(0,$.jsxs)(`div`,{className:`text-center`,children:[l,(0,$.jsx)(`p`,{className:`mt-1 text-base text-muted-foreground`,children:u})]})]}),t[2]=u,t[3]=d);let f;if(t[4]!==i||t[5]!==r||t[6]!==n){let e;t[8]!==i||t[9]!==r?(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?i(e.projectId):r(e.projectId,e.threads[0].threadId)},children:[(0,$.jsx)(re,{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]=i,t[9]=r,t[10]=e):e=t[10],f=n.map(e),t[4]=i,t[5]=r,t[6]=n,t[7]=f}else f=t[7];let p,m,h;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(bt,{className:`h-5 w-5 text-muted-foreground`}),m=(0,$.jsx)(`span`,{className:`text-sm text-foreground leading-snug font-medium`,children:`Connect a repo`}),h=(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Clone an existing repository`}),t[11]=p,t[12]=m,t[13]=h):(p=t[11],m=t[12],h=t[13]);let g;t[14]===a?g=t[15]:(g=(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:a,children:[p,m,h]}),t[14]=a,t[15]=g);let _,v,y;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(Jt,{className:`h-5 w-5 text-muted-foreground`}),v=(0,$.jsx)(`span`,{className:`text-sm text-foreground leading-snug font-medium`,children:`New App`}),y=(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Create a new project from template`}),t[16]=_,t[17]=v,t[18]=y):(_=t[16],v=t[17],y=t[18]);let b;t[19]===o?b=t[20]:(b=(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:[_,v,y]}),t[19]=o,t[20]=b);let x,S,C;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(_t,{className:`h-5 w-5 text-muted-foreground`}),S=(0,$.jsx)(`span`,{className:`text-sm text-foreground leading-snug font-medium`,children:`Open Folder`}),C=(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Use an existing local folder`}),t[21]=x,t[22]=S,t[23]=C):(x=t[21],S=t[22],C=t[23]);let w;t[24]===s?w=t[25]:(w=(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:[x,S,C]}),t[24]=s,t[25]=w);let T;t[26]!==b||t[27]!==w||t[28]!==f||t[29]!==g?(T=(0,$.jsxs)(`div`,{className:`flex flex-wrap justify-center gap-3`,children:[f,g,b,w]}),t[26]=b,t[27]=w,t[28]=f,t[29]=g,t[30]=T):T=t[30];let E;return t[31]!==T||t[32]!==d?(E=(0,$.jsxs)(`div`,{className:`mx-auto flex max-w-3xl flex-1 flex-col items-center justify-center gap-8 px-4`,children:[d,T]}),t[31]=T,t[32]=d,t[33]=E):E=t[33],E}function Ea(e){let t=(0,Q.c)(20),{project:n}=e,{setDevServerRunning:r}=Or(),[i,a]=(0,Z.useState)(!1),{startServer:o}=Mr(),s;t[0]!==n||t[1]!==r?(s=()=>{if(!n?.projectId)return;let e=async()=>{try{let e=await Me(n.projectId);a(e.isRunning),r(e.isRunning)}catch{a(!1),r(!1)}};e();let t=setInterval(e,2e3);return()=>clearInterval(t)},t[0]=n,t[1]=r,t[2]=s):s=t[2];let c=n?.projectId,l;t[3]===c?l=t[4]:(l=[c],t[3]=c,t[4]=l),(0,Z.useEffect)(s,l);let u=!i&&n?.runCommand,d;t[5]!==n||t[6]!==o?(d=()=>{n&&o(n)},t[5]=n,t[6]=o,t[7]=d):d=t[7];let f=d,p;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(`img`,{src:`/tarsk-color.svg`,alt:`Tarsk`,className:`h-16 w-16 rounded-lg`}),t[8]=p):p=t[8];let m=n?.name??`Project`,h;t[9]===m?h=t[10]:(h=(0,$.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight text-foreground text-balance`,children:m}),t[9]=m,t[10]=h);let g;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(`p`,{className:`mt-2 text-base text-muted-foreground`,children:`What would you like to build today?`}),t[11]=g):g=t[11];let _;t[12]===h?_=t[13]:(_=(0,$.jsxs)(`div`,{className:`text-center`,children:[h,g]}),t[12]=h,t[13]=_);let v;t[14]!==f||t[15]!==u?(v=u&&(0,$.jsx)(`button`,{type:`button`,onClick:f,className:`inline-flex items-center gap-2 rounded-full bg-primary px-4 py-2 text-sm font-medium text-primary-foreground hover:bg-primary/90 transition-colors`,children:`Start App`}),t[14]=f,t[15]=u,t[16]=v):v=t[16];let y;return t[17]!==v||t[18]!==_?(y=(0,$.jsx)(`div`,{className:`flex-1 flex flex-col items-center justify-center`,children:(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-6 px-4`,children:[p,_,v]})}),t[17]=v,t[18]=_,t[19]=y):y=t[19],y}var Da=(0,Z.createContext)(null),Oa=(0,Z.forwardRef)((e,t)=>{let n=(0,Q.c)(9),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({style:a,children:r,...i}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o;return n[4]!==r||n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,$.jsx)(`div`,{ref:t,style:a,...i,className:`mx-auto max-w-3xl w-full min-w-0`,children:r}),n[4]=r,n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});Oa.displayName=`MessageList`;function ka(){let e=(0,Q.c)(13),t=(0,Z.useContext)(Da);if(!t)return null;let{isStreaming:n,isCreatingProject:r,isProcessingThread:i,streamingSegments:a,streamingModel:o,totalMessages:s,error:c,onClearError:l}=t,u;e[0]!==r||e[1]!==i||e[2]!==n||e[3]!==o||e[4]!==a||e[5]!==s?(u=(n||r||i)&&(0,$.jsx)(wa,{segments:a,model:o,isCreatingProject:r,isProcessingThread:i,totalMessages:s}),e[0]=r,e[1]=i,e[2]=n,e[3]=o,e[4]=a,e[5]=s,e[6]=u):u=e[6];let d;e[7]!==c||e[8]!==l?(d=c&&(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:c}),(0,$.jsx)(`button`,{type:`button`,className:`mt-1 text-xs text-destructive underline underline-offset-2 hover:text-destructive/80`,onClick:l,children:`Dismiss`})]}),e[7]=c,e[8]=l,e[9]=d):d=e[9];let f;return e[10]!==u||e[11]!==d?(f=(0,$.jsxs)(`div`,{className:`mx-auto max-w-3xl w-full min-w-0 pb-4`,children:[u,d]}),e[10]=u,e[11]=d,e[12]=f):f=e[12],f}var Aa={List:Oa,Footer:ka};function ja(e){let t=(0,Q.c)(43),{messages:n,isStreaming:r,streamingSegments:i,streamingModel:a,isCreatingProject:o,isProcessingThread:s,selectedThreadId:c,selectedProjectId:l,projects:u,projectsLoading:d,onSelectThread:f,onCreateThread:p,onConnectRepo:m,onNewApp:h,onOpenFolder:g,error:_,onClearError:v}=e,y=(0,Z.useRef)(null),b=(0,Z.useRef)(0),x=(0,Z.useRef)(!1),S;t[0]!==r||t[1]!==n.length?(S=()=>{let e=n.length>b.current,t=x.current&&!r;(r||e||t)&&requestAnimationFrame(()=>{y.current?.scrollTo({top:2**53-1,behavior:`smooth`})}),b.current=n.length,x.current=r},t[0]=r,t[1]=n.length,t[2]=S):S=t[2];let C;t[3]!==r||t[4]!==n||t[5]!==i.length?(C=[r,n,i.length],t[3]=r,t[4]=n,t[5]=i.length,t[6]=C):C=t[6],(0,Z.useEffect)(S,C);let w=n.length===0&&!r&&!o&&!c,T=n.length===0&&!r&&!o&&c,E;if(t[7]!==u||t[8]!==l){let e;t[10]===l?e=t[11]:(e=e=>e.projectId===l,t[10]=l,t[11]=e),E=u.find(e),t[7]=u,t[8]=l,t[9]=E}else E=t[9];let D=E;if(w){let e=`transition-opacity duration-500 ease-in-out ${d?`opacity-0`:`opacity-100`}`,n;t[12]!==m||t[13]!==p||t[14]!==h||t[15]!==g||t[16]!==f||t[17]!==u?(n=(0,$.jsx)(Ta,{projects:u,onSelectProject:f,onCreateThread:p,onConnectRepo:m,onNewApp:h,onOpenFolder:g}),t[12]=m,t[13]=p,t[14]=h,t[15]=g,t[16]=f,t[17]=u,t[18]=n):n=t[18];let r;return t[19]!==e||t[20]!==n?(r=(0,$.jsx)(`div`,{className:`flex-1 flex flex-col items-center justify-center`,children:(0,$.jsx)(`div`,{className:e,children:n})}),t[19]=e,t[20]=n,t[21]=r):r=t[21],r}if(T){let e;return t[22]===D?e=t[23]:(e=(0,$.jsx)(Ea,{project:D}),t[22]=D,t[23]=e),e}let O;t[24]!==_||t[25]!==o||t[26]!==s||t[27]!==r||t[28]!==n.length||t[29]!==v||t[30]!==a||t[31]!==i?(O={isStreaming:r,isCreatingProject:o,isProcessingThread:s,streamingSegments:i,streamingModel:a,totalMessages:n.length,error:_,onClearError:v},t[24]=_,t[25]=o,t[26]=s,t[27]=r,t[28]=n.length,t[29]=v,t[30]=a,t[31]=i,t[32]=O):O=t[32];let k=O,A;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(A=G(`flex-1 overflow-hidden`),t[33]=A):A=t[33];let j;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(j={height:`100%`},t[34]=j):j=t[34];let M;t[35]===c?M=t[36]:(M=(e,t)=>(0,$.jsx)(xa,{message:t,threadId:c,messageIndex:e}),t[35]=c,t[36]=M);let N;t[37]!==n||t[38]!==M?(N=(0,$.jsx)(Rn,{ref:y,style:j,data:n,itemContent:M,overscan:500,components:Aa}),t[37]=n,t[38]=M,t[39]=N):N=t[39];let P;return t[40]!==k||t[41]!==N?(P=(0,$.jsx)(`div`,{className:A,children:(0,$.jsx)(Da.Provider,{value:k,children:N})}),t[40]=k,t[41]=N,t[42]=P):P=t[42],P}async function Ma(e){return nn(`api/projects/${c(e)}/todos`)}async function Na(e,t){return u(`api/projects/${c(e)}/todos`,{description:t})}async function Pa(e,t,n){return h(`api/projects/${c(e)}/todos/${c(t)}`,n)}async function Fa(e,t){await Ce(`api/projects/${c(e)}/todos/${c(t)}`)}var Ia={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 La({todo:e,projectId:t,onUpdate:n,onEdit:r,onAction:i,onThreadSelect:a}){let[o,s]=(0,Z.useState)(!1),c=Ia[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 Pa(t,e.id,{status:a,working:a!==`Done`}))}finally{s(!1)}}return(0,$.jsxs)(`div`,{className:G(`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)(ot,{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)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(U,{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)(q,{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)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(U,{size:`icon`,variant:`ghost`,className:`h-7 w-7 shrink-0 group-hover:flex items-center justify-center`,onClick:l,children:[(0,$.jsx)(ye,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Open thread`})]})}),(0,$.jsx)(q,{side:`right`,children:`Open thread`})]})]})]})}var Ra=`Please analyze this task and create a detailed implementation plan.
18
+
19
+ Task description:
20
+ {description}`,za="\nWrite your complete plan to the file `{todoId}-plan.md` in the current directory.",Ba=`Act as a Quality Assurance Manager. Rephrase the task into a rigorous test case: {description}`,Va=`Code review: The systematic examination of code to find mistakes, ensure it follows best practices, and identify areas for improvement
21
+ Directions:
22
+ Carefully read through the list of code changes creating a todo list of code to review.
23
+ Analyze the code structure, variable names, functions, and logic flow
24
+ Look for any syntax errors, bugs, or inefficiencies
25
+ Consider best practices for the specific programming language used
26
+ Provide clear and constructive feedback on areas that could be improved
27
+ If applicable, include examples of how to refactor problematic code
28
+ Offer praise for portions of the code that are well-written and follow best practices
29
+
30
+ Task description:
31
+ {description}`,Ha={plan:Ra,test:Ba,review:Va},Ua={plan:`planPrompt`,test:`testPrompt`,review:`reviewPrompt`};function Wa(e,t){let n=e?.[Ua[t]];return n&&n.trim()?n:Ha[t]}function Ga(e,t,n,r){let i=e.replace(/\{description\}/g,r);return t===`plan`&&(i+=za.replace(/\{todoId\}/g,n)),i}var Ka=[`Ready`,`Plan`,`Build`,`Test`,`Review`,`Done`],qa={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 Ja(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(`
32
+ `);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 Ya(e){let t=e.getReader();try{for(;;){let{done:e}=await t.read();if(e)break}}catch{}}async function Xa(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(`
33
+ `);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 Za({projectId:e,addOpen:n,onAddOpenChange:r,onThreadSelect:i}){let{state:a,dispatch:o}=Yn(),[s,c]=(0,Z.useState)([]),[l,u]=(0,Z.useState)(!0),[d,f]=(0,Z.useState)(null),[p,m]=(0,Z.useState)(``),[h,_]=(0,Z.useState)(!1),[v,y]=(0,Z.useState)(!1),[b,x]=(0,Z.useState)(null),[S,C]=(0,Z.useState)(``),[T,E]=(0,Z.useState)(!1),[D,O]=(0,Z.useState)(!1),k=(0,Z.useCallback)(async()=>{try{let t=await Ma(e),n=t.filter(e=>e.threadId&&e.status!==`Done`),r=[...t];await Promise.all(n.map(async t=>{try{await g(t.threadId)}catch(n){if(n instanceof Error&&n.message.includes(`not found`)){let n=await Pa(e,t.id,{status:`Done`}),i=r.findIndex(e=>e.id===t.id);i!==-1&&(r[i]=n);return}}})),c(r)}catch(e){console.error(`Failed to fetch project todos:`,e)}finally{u(!1)}},[e]);(0,Z.useEffect)(()=>{k()},[k]),(0,Z.useEffect)(()=>{if(!s.some(e=>e.working))return;let t=setInterval(async()=>{try{let n=await Ma(e);c(n),n.some(e=>e.working)||clearInterval(t)}catch(e){console.error(`Failed to poll project todos:`,e)}},2e3);return()=>clearInterval(t)},[s,e]),(0,Z.useEffect)(()=>{n&&m(``)},[n]);function A(e){m(e.description),f({todo:e})}function j(){f(null),m(``)}async function M(){if(p.trim()){_(!0);try{let t=await Na(e,p);c(e=>[...e,t]),r(!1),m(``)}finally{_(!1)}}}async function N(){if(!(!p.trim()||!d)){_(!0);try{let t=await Pa(e,d.todo.id,{description:p});c(e=>e.map(e=>e.id===t.id?t:e)),j()}finally{_(!1)}}}async function P(){if(d){_(!0);try{await Fa(e,d.todo.id),c(e=>e.filter(e=>e.id!==d.todo.id)),j()}finally{_(!1)}}}function F(e){c(t=>t.map(t=>t.id===e.id?e:t))}async function I(t){let n=a.selectedThreadId?a.projectModelSelections[a.selectedThreadId]:void 0,r=a.projects.find(t=>t.projectId===e),i=r?.threads.find(e=>e.threadId===a.selectedThreadId),s=n?.id??i?.model,c=n?.provider??i?.modelProvider;if(!s||!c)throw console.error(`No model or provider found for project`,e,i),Error(`No model configuration found. Please configure a model and provider for this project first.`);let l=await V(e);if(!l)return;let u=null,d=await Ja(l,n=>{Pa(e,t.id,{status:`Plan`,working:!0,threadId:n}).then(e=>{u=e,F(e)})});if(!d)return;u||F(await Pa(e,t.id,{status:`Plan`,working:!0,threadId:d}));let f=n??{id:s,provider:c,name:s,description:``};o({type:K.SetProjectModel,threadId:d,model:f}),qe(d,{model:s,modelProvider:c});let p=await Nt(d,Ga(Wa(r,`plan`),`plan`,t.id,t.description),s,[],void 0,c);p&&Ya(p)}async function L(t){let n=await V(e);if(!n)return;let r=null,i=await Ja(n,n=>{Pa(e,t.id,{status:`Build`,working:!0,threadId:n}).then(e=>{r=e,F(e)})});if(!i)return;r||F(await Pa(e,t.id,{status:`Build`,working:!0,threadId:i}));let a=await g(i),s=a.model,c=a.modelProvider;if(!s||!c)try{let t=(await nn(`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.`);o({type:K.SetProjectModel,threadId:i,model:{id:s,provider:c,name:s,description:``}}),qe(i,{model:s,modelProvider:c}),console.log(`Sending chat message with provider:`,i,t.description,c);let l=await Nt(i,t.description,s,[],void 0,c);l&&Ya(l)}async function R(t){try{let n=await V(e);if(!n){y(!1),x(null);return}let r=null;if(r=await Ja(n,e=>{r=e}),!r){y(!1),x(null);return}let i=await g(r),o=i.model,s=i.modelProvider;if(!o||!s)try{let t=(await nn(`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){sn(e,r),y(!1),x(null);return}let c=Ga(Wa(a.projects.find(t=>t.projectId===e),`test`),`test`,t.id,t.description),l=await Nt(r,c,o,[],void 0,s);l&&C(await Xa(l)),sn(e,r)}catch(e){console.error(`Failed to generate test case:`,e),y(!1),x(null)}finally{E(!1)}}function z(e){x(e),C(``),E(!0),y(!0),R(e)}function ee(){y(!1),x(null),C(``)}async function B(){if(!b||!S.trim())return;let t=b,n=S;ee(),O(!0);try{let r=await V(e);if(!r)return;let i=null,a=await Ja(r,n=>{Pa(e,t.id,{status:`Test`,working:!0,threadId:n}).then(e=>{i=e,F(e)})});if(!a)return;i||F(await Pa(e,t.id,{status:`Test`,working:!0,threadId:a}));let s=await g(a),c=s.model,l=s.modelProvider;if(!c||!l)try{let t=(await nn(`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.`);o({type:K.SetProjectModel,threadId:a,model:{id:c,provider:l,name:c,description:``}}),qe(a,{model:c,modelProvider:l});let u=await Nt(a,n,c,[],void 0,l);u&&Ya(u)}finally{O(!1)}}async function te(t){let n=await V(e);if(!n)return;let r=null,i=await Ja(n,n=>{Pa(e,t.id,{status:`Review`,working:!0,threadId:n}).then(e=>{r=e,F(e)})});if(!i)return;r||F(await Pa(e,t.id,{status:`Review`,working:!0,threadId:i}));let s=await g(i),c=s.model,l=s.modelProvider;if(!c||!l)try{let t=(await nn(`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.`);o({type:K.SetProjectModel,threadId:i,model:{id:c,provider:l,name:c,description:``}}),qe(i,{model:c,modelProvider:l});let u=await Nt(i,Ga(Wa(a.projects.find(t=>t.projectId===e),`review`),`review`,t.id,t.description),c,[],void 0,l);u&&Ya(u)}async function ne(t,n){n===`Plan`?await I(t):n===`Build`?await L(t):n===`Test`?z(t):n===`Review`?await te(t):F(await Pa(e,t.id,{status:n,working:n!==`Done`}))}return l?(0,$.jsx)(`div`,{className:`flex items-center justify-center h-64`,children:(0,$.jsx)(ot,{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:Ka.map(n=>{let a=s.filter(e=>e.status===n),o=n===`Ready`;return(0,$.jsxs)(`div`,{className:G(`flex flex-col rounded-lg border border-t-4 bg-muted/30 min-w-[200px] w-[200px] shrink-0`,qa[n]),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:n}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground bg-muted rounded-full px-1.5 py-0.5`,children:a.length})]}),(0,$.jsx)(xt,{className:`flex-1 px-2 pb-2`,children:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[o&&(0,$.jsxs)(U,{variant:`outline`,size:`sm`,className:`w-full h-8 border-dashed text-muted-foreground hover:text-foreground`,onClick:()=>r(!0),children:[(0,$.jsx)(t,{className:`h-3 w-3 mr-1`}),`Add Task`]}),a.map(t=>(0,$.jsx)(La,{todo:t,projectId:e,onUpdate:F,onEdit:A,onAction:ne,onThreadSelect:i},t.id))]})})]},n)})}),(0,$.jsx)(be,{open:n,onOpenChange:r,children:(0,$.jsxs)(ln,{className:`sm:max-w-2xl`,children:[(0,$.jsx)(w,{children:(0,$.jsx)(Ee,{children:`Add Task`})}),(0,$.jsxs)(`div`,{className:`py-2`,children:[(0,$.jsx)(ir,{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,$.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1.5`,children:`A title will be generated automatically from your description.`})]}),(0,$.jsx)(ke,{children:(0,$.jsx)(U,{onClick:()=>void M(),disabled:h||!p.trim(),children:h?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ot,{className:`h-3 w-3 animate-spin mr-1`}),`Generating title...`]}):`Add`})})]})}),(0,$.jsx)(be,{open:v,onOpenChange:e=>!e&&ee(),children:(0,$.jsxs)(ln,{className:`sm:max-w-2xl`,children:[(0,$.jsx)(w,{children:(0,$.jsx)(Ee,{children:`Test Case`})}),(0,$.jsx)(`div`,{className:`py-2`,children:T?(0,$.jsxs)(`div`,{className:`flex items-center justify-center h-32 gap-2 text-muted-foreground`,children:[(0,$.jsx)(ot,{className:`h-4 w-4 animate-spin`}),(0,$.jsx)(`span`,{className:`text-sm`,children:`Generating test case...`})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ir,{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)(ke,{children:[(0,$.jsx)(U,{variant:`outline`,onClick:ee,disabled:T,children:`Cancel`}),(0,$.jsx)(U,{onClick:()=>void B(),disabled:T||!S.trim()||D,children:D?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ot,{className:`h-3 w-3 animate-spin mr-1`}),`Starting...`]}):`Confirm`})]})]})}),(0,$.jsx)(be,{open:d!==null,onOpenChange:e=>!e&&j(),children:(0,$.jsxs)(ln,{className:`sm:max-w-2xl`,children:[(0,$.jsx)(w,{children:(0,$.jsx)(Ee,{children:`Edit Task`})}),(0,$.jsx)(`div`,{className:`py-2`,children:(0,$.jsx)(ir,{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)&&N()}})}),(0,$.jsxs)(ke,{className:`gap-2 sm:gap-0`,children:[(0,$.jsx)(U,{variant:`destructive`,onClick:()=>void P(),disabled:h,className:`mr-auto`,children:`Delete`}),(0,$.jsx)(U,{onClick:()=>void N(),disabled:h||!p.trim(),children:h?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ot,{className:`h-3 w-3 animate-spin mr-1`}),`Saving...`]}):`Save`})]})]})})]})}var Qa=[{value:`plan`,label:`Plan`,field:`planPrompt`,defaultPrompt:Ra},{value:`review`,label:`Code Review`,field:`reviewPrompt`,defaultPrompt:Va},{value:`test`,label:`Test`,field:`testPrompt`,defaultPrompt:Ba}];function $a({open:e,onOpenChange:t,projectId:n}){let{state:r}=Yn(),[i,a]=(0,Z.useState)({plan:``,review:``,test:``}),[o,c]=(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 l(){c(!0);try{await ut(n,{planPrompt:i.plan.trim()===Ra?null:i.plan.trim()||null,testPrompt:i.test.trim()===Ba?null:i.test.trim()||null,reviewPrompt:i.review.trim()===Va?null:i.review.trim()||null}),Oe(),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{c(!1)}}function u(e,t){a(n=>({...n,[e]:t}))}return(0,$.jsx)(be,{open:e,onOpenChange:t,children:(0,$.jsxs)(ln,{className:`max-w-2xl`,children:[(0,$.jsxs)(w,{children:[(0,$.jsx)(Ee,{children:`AI Prompt Settings`}),(0,$.jsx)(s,{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)(Lr,{defaultValue:`plan`,className:`w-full`,children:[(0,$.jsx)(Ir,{className:`w-full`,children:Qa.map(e=>(0,$.jsx)(Pr,{value:e.value,className:`flex-1`,children:e.label},e.value))}),Qa.map(e=>(0,$.jsxs)(Fr,{value:e.value,children:[(0,$.jsx)(ir,{value:i[e.value]||e.defaultPrompt,onChange:t=>u(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)(ke,{children:(0,$.jsx)(U,{onClick:()=>void l(),disabled:o,children:o?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ot,{className:`mr-2 h-4 w-4 animate-spin`}),`Saving...`]}):`Save`})})]})})}function eo({projectId:e}){let{state:t,dispatch:n}=Yn(),{projects:r}=t,[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(!1),c=Nn(),{setActiveMainTab:l}=Or();async function u(i){if(r.find(t=>t.projectId===e)){c(`/`),l(`chat`);try{let{getProjects:r,invalidateProjectsCache:a}=await Un(async()=>{let{getProjects:e,invalidateProjectsCache:t}=await import(`./dialogs-config-3Hr2GRdt.js`).then(e=>e.b);return{getProjects:e,invalidateProjectsCache:t}},__vite__mapDeps([2,1]));a();let o=await r();n({type:K.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:K.SelectThread,threadId:i,projectId:e});try{let e=await tn();n({type:K.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:K.SelectThread,threadId:i,projectId:e});try{let e=await tn();n({type:K.SetProcessingThreads,threadIds:e})}catch(e){console.error(`Failed to fetch processing threads after fallback thread selection:`,e)}}}}return(0,$.jsxs)(`div`,{className:`relative flex h-full flex-col overflow-hidden`,children:[(0,$.jsx)(`div`,{className:`flex-1 overflow-hidden pt-8 pl-4`,children:(0,$.jsx)(Za,{projectId:e,addOpen:i,onAddOpenChange:a,onThreadSelect:u})}),(0,$.jsx)(U,{variant:`outline`,size:`icon`,className:`absolute bottom-8 right-4`,onClick:()=>s(!0),children:(0,$.jsx)(x,{className:`h-4 w-4`})}),(0,$.jsx)($a,{open:o,onOpenChange:s,projectId:e})]})}var to=(0,Z.lazy)(()=>Un(()=>import(`./diff-view-v-bVp3Zf.js`),__vite__mapDeps([10,1,5,6,2,7,11,12,13,14,15,16,17,18,19,8,20]))),no=(0,Z.lazy)(()=>Un(()=>import(`./dialogs-config-3Hr2GRdt.js`).then(e=>e.t),__vite__mapDeps([2,1])));function ro(e){let t=(0,Q.c)(52),{onCreateThread:n}=e,{state:i,dispatch:a}=Yn(),o=Nn(),s=Pn(),[c,l]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(null),{selectedThreadId:f,messages:p,isCreatingProject:m,processingThreadIds:h,projects:g,projectsLoading:_,isStreaming:v,streamingSegments:y,streamingModel:b}=i,x;t[0]!==h||t[1]!==f?(x=f&&h.includes(f),t[0]=h,t[1]=f,t[2]=x):x=t[2];let S=!!x,C;t[3]!==a||t[4]!==i.sidebarOpen?(C=()=>{i.sidebarOpen&&a({type:K.ToggleSidebar})},t[3]=a,t[4]=i.sidebarOpen,t[5]=C):C=t[5];let w=C,T;t[6]===w?T=t[7]:(T=()=>{w(),d(`clone`),l(!0)},t[6]=w,t[7]=T);let E=T,D;t[8]===w?D=t[9]:(D=()=>{w(),d(`webapp`),l(!0)},t[8]=w,t[9]=D);let O=D,k;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(k=async(e,t)=>{try{await yt(e,t),l(!1),d(null)}catch(e){console.error(`Failed to clone repository:`,e)}},t[10]=k):k=t[10];let A=k,j;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(j=async(e,t,n)=>{try{await r(e,t,n),l(!1),d(null)}catch(e){console.error(`Failed to create project:`,e)}},t[11]=j):j=t[11];let M=j,N;t[12]===w?N=t[13]:(N=async()=>{w();try{await ee(),l(!1),d(null)}catch(e){console.error(`Failed to open folder:`,e)}},t[12]=w,t[13]=N);let P=N,F=s.pathname===`/review`,I=s.pathname===`/todos`,L;t[14]===o?L=t[15]:(L=()=>{o(`/`)},t[14]=o,t[15]=L);let R=L,{selectedProjectId:z}=i,B;t[16]!==w||t[17]!==a||t[18]!==E||t[19]!==R||t[20]!==O||t[21]!==P||t[22]!==m||t[23]!==S||t[24]!==v||t[25]!==p||t[26]!==n||t[27]!==g||t[28]!==_||t[29]!==F||t[30]!==z||t[31]!==f||t[32]!==b||t[33]!==y||t[34]!==I?(B=I&&z?(0,$.jsx)(eo,{projectId:z}):F&&f?(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:`Loading diff view...`}),children:(0,$.jsx)(to,{threadId:f,onExit:R})}):(0,$.jsx)(ja,{messages:p,isStreaming:v,streamingSegments:y,streamingModel:b,isCreatingProject:m,isProcessingThread:S,selectedThreadId:f,selectedProjectId:z,projects:g,projectsLoading:_,onSelectThread:(e,t)=>{w(),a({type:K.SelectThread,projectId:e,threadId:t})},onCreateThread:n,onConnectRepo:E,onNewApp:O,onOpenFolder:P,error:null,onClearError:io}),t[16]=w,t[17]=a,t[18]=E,t[19]=R,t[20]=O,t[21]=P,t[22]=m,t[23]=S,t[24]=v,t[25]=p,t[26]=n,t[27]=g,t[28]=_,t[29]=F,t[30]=z,t[31]=f,t[32]=b,t[33]=y,t[34]=I,t[35]=B):B=t[35];let te;t[36]!==p||t[37]!==F||t[38]!==f||t[39]!==I?(te=!F&&!I&&f&&(0,$.jsx)(mr,{messages:p}),t[36]=p,t[37]=F,t[38]=f,t[39]=I,t[40]=te):te=t[40];let ne=u??void 0,V;t[41]!==c||t[42]!==P||t[43]!==ne?(V=(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(no,{open:c,onOpenChange:l,initialMode:ne,onSubmitClone:A,onSubmitWebApp:M,onOpenFolder:P})}),t[41]=c,t[42]=P,t[43]=ne,t[44]=V):V=t[44];let re;t[45]!==te||t[46]!==V||t[47]!==B?(re=(0,$.jsxs)(`div`,{className:`flex h-full flex-col`,children:[B,te,V]}),t[45]=te,t[46]=V,t[47]=B,t[48]=re):re=t[48];let H;return t[49]!==f||t[50]!==re?(H=(0,$.jsx)(pr,{threadId:f,children:re}),t[49]=f,t[50]=re,t[51]=H):H=t[51],H}function io(){}var ao=gn,oo=Bn,so=kn,co=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=G(`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)(_e,{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)(vn,{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});co.displayName=vn.displayName;var lo=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=G(`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)(hn,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});lo.displayName=hn.displayName;var uo=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=G(`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)(Jn,{children:(0,$.jsx)(Cn,{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});uo.displayName=Cn.displayName;var fo=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=G(`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)(_n,{ref:t,className:s,...a}),n[7]=a,n[8]=t,n[9]=s,n[10]=c):c=n[10],c});fo.displayName=_n.displayName;var 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:a,children:i,checked:r,...o}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let s;n[5]===a?s=n[6]:(s=G(`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`,a),n[5]=a,n[6]=s);let c;n[7]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,$.jsx)(yn,{children:(0,$.jsx)(qt,{className:`h-4 w-4`})})}),n[7]=c):c=n[7];let l;return n[8]!==r||n[9]!==i||n[10]!==o||n[11]!==t||n[12]!==s?(l=(0,$.jsxs)(xn,{ref:t,className:s,checked:r,...o,children:[c,i]}),n[8]=r,n[9]=i,n[10]=o,n[11]=t,n[12]=s,n[13]=l):l=n[13],l});po.displayName=xn.displayName;var mo=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=G(`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)(yn,{children:(0,$.jsx)(Rt,{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)(On,{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});mo.displayName=On.displayName;var ho=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=G(`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)(Tn,{ref:t,className:s,...a}),n[7]=a,n[8]=t,n[9]=s,n[10]=c):c=n[10],c});ho.displayName=Tn.displayName;var go=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=G(`-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)(Dn,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});go.displayName=Dn.displayName;var _o=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=G(`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};_o.displayName=`DropdownMenuShortcut`;var vo=`VS Code`,yo={"VS Code":`vscode`,Cursor:`cursor`,Windsurf:`windsurf`,Xcode:`xcode`,"Android Studio":`android-studio`,Kiro:`kiro`,Terminal:`terminal`};function bo({projectId:e,threadId:t,openWith:n}){let[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)([]),[s,c]=(0,Z.useState)(n??vo),[l,u]=(0,Z.useState)(!0);(0,Z.useEffect)(()=>{(async()=>{try{let e=await nt();o(e),!s&&e.length>0&&c(e[0])}catch(e){console.error(`Failed to fetch available programs:`,e),o([vo])}finally{u(!1)}})()},[]),(0,Z.useEffect)(()=>{n&&a.includes(n)&&c(n)},[n,a,c]);let d=async n=>{try{i(!0),c(n),await Ve(e,n),t?await I(t,n):await Vt(e,n),X({title:`Success`,description:`Opened project in ${n}`})}catch(e){console.error(`Failed to open project in ${n}:`,e);let t=`Failed to open project in ${n}`;if(e instanceof Error){let n=e;t=n.details?n.details:e.message}X({title:`Error`,description:t,variant:`destructive`})}finally{i(!1)}};return l?(0,$.jsx)(U,{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)(U,{variant:`outline`,size:`sm`,className:`h-8 rounded-r-none border-r-0 border-transparent`,disabled:r,onClick:async()=>{await d(s)},title:`Open in ${s}`,children:(0,$.jsx)(`img`,{src:`/ide/${yo[s]||yo[vo]}.svg`,alt:s,className:`h-4 w-4`})}),(0,$.jsxs)(ao,{children:[(0,$.jsx)(oo,{asChild:!0,children:(0,$.jsx)(U,{variant:`outline`,size:`sm`,className:`h-8 w-8 rounded-l-none px-1 border-transparent`,disabled:r,children:(0,$.jsx)($e,{className:`h-3.5 w-3.5`})})}),(0,$.jsx)(uo,{align:`end`,children:a.map(e=>(0,$.jsxs)(fo,{onClick:()=>d(e),disabled:r,className:`flex items-center gap-2`,children:[(0,$.jsx)(`img`,{src:`/ide/${yo[e]||yo[vo]}.svg`,alt:e,className:`h-4 w-4`}),e]},e))})]})]})}function xo(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 So(e,t){return t?(0,$.jsx)(ot,{className:`h-3.5 w-3.5 animate-spin`}):e.status===`Behind`&&!e.hasChanges&&!e.hasUnpushedCommits?(0,$.jsx)(Wt,{className:`h-3.5 w-3.5`}):e.hasChanges?(0,$.jsx)(de,{className:`h-3.5 w-3.5`}):e.prExists&&e.prState===`OPEN`&&!e.hasChanges&&!e.hasUnpushedCommits?(0,$.jsx)(ye,{className:`h-3.5 w-3.5`}):(0,$.jsx)(m,{className:`h-3.5 w-3.5`})}function Co(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 wo(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 To(e){return e.hasChanges||e.status===`Behind`&&!e.hasChanges&&!e.hasUnpushedCommits||e.commitsAheadOfDefault&&!e.prExists&&!e.hasChanges}function Eo(e){let t=(0,Q.c)(102),{branchStatus:n,currentBranch:r,remoteUrl:i,hasRemoteBranch:a,hasUnpushedCommits:o,canCreateRepo:s,repoUrl:c,isRefreshing:l,isBrandState:u,gitUser:d,availableBranches:f,isLoadingBranches:p,onBranchSubMenuOpen:h,onCheckoutBranch:g,isDirectCommitMode:_,isLoading:v,isLoadingHistory:y,onFetch:b,onPull:x,onPush:S,onOpenHistory:C,onNewBranch:w,onCreatePR:T,onCreateRepo:E,onViewInGitHub:D}=e,O=`h-8 w-8 rounded-l-none px-1 border-transparent${u?` bg-brand text-brand-foreground hover:bg-brand/90 hover:text-brand-foreground`:``}`,k;t[0]===l?k=t[1]:(k=l?(0,$.jsx)(ot,{className:`h-3.5 w-3.5 animate-spin`}):(0,$.jsx)($e,{className:`h-3.5 w-3.5`}),t[0]=l,t[1]=k);let A;t[2]!==v||t[3]!==O||t[4]!==k?(A=(0,$.jsx)(oo,{asChild:!0,children:(0,$.jsx)(U,{variant:`outline`,size:`sm`,className:O,disabled:v,children:k})}),t[2]=v,t[3]=O,t[4]=k,t[5]=A):A=t[5];let j;t[6]===h?j=t[7]:(j=async e=>{e&&await h()},t[6]=h,t[7]=j);let M;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,$.jsx)(bt,{className:`h-3 w-3 shrink-0`}),t[8]=M):M=t[8];let N=r||`Unknown`,P;t[9]===N?P=t[10]:(P=(0,$.jsxs)(co,{className:`gap-2 text-xs`,children:[M,(0,$.jsx)(`span`,{className:`font-medium`,children:N})]}),t[9]=N,t[10]=P);let F;t[11]!==f||t[12]!==r||t[13]!==v||t[14]!==p||t[15]!==g?(F=p?(0,$.jsxs)(`div`,{className:`px-2 py-1.5 text-xs text-muted-foreground flex items-center gap-2`,children:[(0,$.jsx)(ot,{className:`h-3 w-3 animate-spin`}),`Loading branches…`]}):f.length===0?(0,$.jsx)(`div`,{className:`px-2 py-1.5 text-xs text-muted-foreground`,children:`No branches found`}):f.map(e=>(0,$.jsxs)(fo,{disabled:e===r||v,onClick:()=>void g(e),children:[(0,$.jsx)(bt,{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]=f,t[12]=r,t[13]=v,t[14]=p,t[15]=g,t[16]=F):F=t[16];let I;t[17]===F?I=t[18]:(I=(0,$.jsx)(lo,{children:F}),t[17]=F,t[18]=I);let L;t[19]!==j||t[20]!==P||t[21]!==I?(L=(0,$.jsxs)(so,{onOpenChange:j,children:[P,I]}),t[19]=j,t[20]=P,t[21]=I,t[22]=L):L=t[22];let R;t[23]!==n||t[24]!==i?(R=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]=R):R=t[25];let z;t[26]===d?z=t[27]:(z=d&&(0,$.jsxs)(`div`,{className:`px-2 py-1 text-xs text-muted-foreground`,children:[(0,$.jsx)(`span`,{className:`font-medium`,children:`User:`}),` `,d]}),t[26]=d,t[27]=z);let ee;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(ee=(0,$.jsx)(go,{}),t[28]=ee):ee=t[28];let B;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,$.jsx)(cn,{className:`h-3.5 w-3.5 mr-2`}),t[29]=B):B=t[29];let te;t[30]!==v||t[31]!==b?(te=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(fo,{onClick:b,disabled:v,children:[B,`Fetch`]})}),t[30]=v,t[31]=b,t[32]=te):te=t[32];let ne;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(ne=(0,$.jsx)(q,{side:`right`,children:`Download latest information from remote without merging changes`}),t[33]=ne):ne=t[33];let V;t[34]===te?V=t[35]:(V=(0,$.jsx)(ar,{children:(0,$.jsxs)(J,{children:[te,ne]})}),t[34]=te,t[35]=V);let re;t[36]!==a||t[37]!==v||t[38]!==x?(re=()=>{a&&!v&&x()},t[36]=a,t[37]=v,t[38]=x,t[39]=re):re=t[39];let H=!a||v?`opacity-50 cursor-not-allowed`:``,ae;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(ae=(0,$.jsx)(Wt,{className:`h-3.5 w-3.5 mr-2`}),t[40]=ae):ae=t[40];let oe;t[41]!==re||t[42]!==H?(oe=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(fo,{onClick:re,className:H,children:[ae,`Pull`]})}),t[41]=re,t[42]=H,t[43]=oe):oe=t[43];let se=a?`Pull latest changes from remote`:`No remote branch to pull from`,ce;t[44]===se?ce=t[45]:(ce=(0,$.jsx)(q,{side:`right`,children:se}),t[44]=se,t[45]=ce);let le;t[46]!==oe||t[47]!==ce?(le=(0,$.jsx)(ar,{children:(0,$.jsxs)(J,{children:[oe,ce]})}),t[46]=oe,t[47]=ce,t[48]=le):le=t[48];let ue;t[49]!==a||t[50]!==v||t[51]!==S?(ue=!a&&(0,$.jsx)(ar,{children:(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(fo,{onClick:S,disabled:v,children:[(0,$.jsx)(ie,{className:`h-3.5 w-3.5 mr-2`}),`Push Branch to Remote`]})}),(0,$.jsx)(q,{side:`right`,children:`Create remote branch and push local commits`})]})}),t[49]=a,t[50]=v,t[51]=S,t[52]=ue):ue=t[52];let de;t[53]!==o||t[54]!==v||t[55]!==S?(de=()=>{o&&!v&&S()},t[53]=o,t[54]=v,t[55]=S,t[56]=de):de=t[56];let fe=!o||v?`opacity-50 cursor-not-allowed`:``,pe;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(pe=(0,$.jsx)(ie,{className:`h-3.5 w-3.5 mr-2`}),t[57]=pe):pe=t[57];let me;t[58]!==de||t[59]!==fe?(me=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(fo,{onClick:de,className:fe,children:[pe,`Push Commits`]})}),t[58]=de,t[59]=fe,t[60]=me):me=t[60];let he=o?v?`Push in progress...`:`Push your uncommitted commits to the remote branch`:`No commits to push - your branch is up to date with remote`,ge;t[61]===he?ge=t[62]:(ge=(0,$.jsx)(q,{side:`right`,children:he}),t[61]=he,t[62]=ge);let _e;t[63]!==me||t[64]!==ge?(_e=(0,$.jsx)(ar,{children:(0,$.jsxs)(J,{children:[me,ge]})}),t[63]=me,t[64]=ge,t[65]=_e):_e=t[65];let ve=v||y,be;t[66]===Symbol.for(`react.memo_cache_sentinel`)?(be=(0,$.jsx)(Se,{className:`h-3.5 w-3.5 mr-2`}),t[66]=be):be=t[66];let xe;t[67]!==C||t[68]!==ve?(xe=(0,$.jsxs)(fo,{onClick:C,disabled:ve,children:[be,`History`]}),t[67]=C,t[68]=ve,t[69]=xe):xe=t[69];let W;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(W=(0,$.jsx)(bt,{className:`h-3.5 w-3.5 mr-2`}),t[70]=W):W=t[70];let Ce;t[71]!==v||t[72]!==w?(Ce=(0,$.jsxs)(fo,{onClick:w,disabled:v,children:[W,`New Branch`]}),t[71]=v,t[72]=w,t[73]=Ce):Ce=t[73];let Te;t[74]!==_||t[75]!==v||t[76]!==T?(Te=!_&&(0,$.jsxs)(fo,{onClick:T,disabled:v,children:[(0,$.jsx)(m,{className:`h-3.5 w-3.5 mr-2`}),`Create Pull Request`]}),t[74]=_,t[75]=v,t[76]=T,t[77]=Te):Te=t[77];let Ee;t[78]!==s||t[79]!==v||t[80]!==E?(Ee=s&&(0,$.jsxs)(fo,{onClick:E,disabled:v,children:[(0,$.jsx)(we,{className:`h-3.5 w-3.5 mr-2`}),`Create Repo`]}),t[78]=s,t[79]=v,t[80]=E,t[81]=Ee):Ee=t[81];let De;t[82]!==v||t[83]!==D||t[84]!==c?(De=c&&(0,$.jsxs)(fo,{onClick:D,disabled:v,children:[(0,$.jsx)(ye,{className:`h-3.5 w-3.5 mr-2`}),`View in GitHub`]}),t[82]=v,t[83]=D,t[84]=c,t[85]=De):De=t[85];let Oe;t[86]!==L||t[87]!==R||t[88]!==z||t[89]!==V||t[90]!==le||t[91]!==ue||t[92]!==_e||t[93]!==xe||t[94]!==Ce||t[95]!==Te||t[96]!==Ee||t[97]!==De?(Oe=(0,$.jsxs)(uo,{align:`end`,children:[L,R,z,ee,V,le,ue,_e,xe,Ce,Te,Ee,De]}),t[86]=L,t[87]=R,t[88]=z,t[89]=V,t[90]=le,t[91]=ue,t[92]=_e,t[93]=xe,t[94]=Ce,t[95]=Te,t[96]=Ee,t[97]=De,t[98]=Oe):Oe=t[98];let ke;return t[99]!==A||t[100]!==Oe?(ke=(0,$.jsxs)(ao,{children:[A,Oe]}),t[99]=A,t[100]=Oe,t[101]=ke):ke=t[101],ke}function Do(){return{autoGenerateCommitMessage:rt(),autoGeneratePRInfo:Ft(),privateRepositoryDefault:ct()}}function Oo(e){e.autoGenerateCommitMessage!==void 0&&at(e.autoGenerateCommitMessage),e.autoGeneratePRInfo!==void 0&&Be(e.autoGeneratePRInfo),e.privateRepositoryDefault!==void 0&&$t(e.privateRepositoryDefault)}function ko(e){return e?!0:(X({title:`Error`,description:`No thread selected`,variant:`destructive`}),!1)}function Ao(e){let t=(0,Q.c)(57),{open:n,onOpenChange:r,commitMessage:i,onCommitMessageChange:a,autoGenerateCommitMessage:o,onAutoGenerateChange:c,isGeneratingMessage:l,isLoading:u,onGenerateMessage:d,onCommit:f,currentBranch:p}=e,m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(Ee,{children:`Commit Changes`}),t[0]=m):m=t[0];let h;t[1]===p?h=t[2]:(h=(0,$.jsxs)(w,{children:[m,(0,$.jsxs)(s,{children:[`Enter a commit message for your changes on branch `,p]})]}),t[1]=p,t[2]=h);let g;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(H,{htmlFor:`commit-message`,children:`Commit Message`}),t[3]=g):g=t[3];let _;t[4]===a?_=t[5]:(_=e=>a(e.target.value),t[4]=a,t[5]=_);let v;t[6]!==i||t[7]!==_?(v=(0,$.jsx)(ir,{id:`commit-message`,placeholder:`Enter commit message...`,value:i,onChange:_,rows:4,className:`pr-10`}),t[6]=i,t[7]=_,t[8]=v):v=t[8];let y=l||u,b;t[9]===l?b=t[10]:(b=l?(0,$.jsx)(ot,{className:`h-3.5 w-3.5 animate-spin`}):(0,$.jsx)(De,{className:`h-3.5 w-3.5`}),t[9]=l,t[10]=b);let x;t[11]!==d||t[12]!==y||t[13]!==b?(x=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(U,{type:`button`,variant:`ghost`,size:`icon`,className:`absolute top-2 right-2 h-6 w-6`,onClick:d,disabled:y,children:b})}),t[11]=d,t[12]=y,t[13]=b,t[14]=x):x=t[14];let S=l?`Generating commit message...`:`Generate commit message with AI`,C;t[15]===S?C=t[16]:(C=(0,$.jsx)(q,{children:S}),t[15]=S,t[16]=C);let T;t[17]!==C||t[18]!==x?(T=(0,$.jsx)(ar,{children:(0,$.jsxs)(J,{children:[x,C]})}),t[17]=C,t[18]=x,t[19]=T):T=t[19];let E;t[20]!==T||t[21]!==v?(E=(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[g,(0,$.jsxs)(`div`,{className:`relative`,children:[v,T]})]}),t[20]=T,t[21]=v,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]!==o||t[26]!==D?(O=(0,$.jsx)(Ar,{id:`auto-generate`,checked:o,onCheckedChange:D}),t[25]=o,t[26]=D,t[27]=O):O=t[27];let k;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,$.jsx)(H,{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]!==u||t[37]!==M?(N=(0,$.jsx)(U,{variant:`outline`,onClick:M,disabled:u,children:`Cancel`}),t[36]=u,t[37]=M,t[38]=N):N=t[38];let P;t[39]!==i||t[40]!==u?(P=u||!i.trim(),t[39]=i,t[40]=u,t[41]=P):P=t[41];let F=u?`Committing...`:`Commit`,I;t[42]!==f||t[43]!==P||t[44]!==F?(I=(0,$.jsx)(U,{onClick:f,disabled:P,children:F}),t[42]=f,t[43]=P,t[44]=F,t[45]=I):I=t[45];let L;t[46]!==N||t[47]!==I?(L=(0,$.jsxs)(ke,{children:[N,I]}),t[46]=N,t[47]=I,t[48]=L):L=t[48];let R;t[49]!==j||t[50]!==h||t[51]!==L?(R=(0,$.jsxs)(ln,{children:[h,j,L]}),t[49]=j,t[50]=h,t[51]=L,t[52]=R):R=t[52];let z;return t[53]!==r||t[54]!==n||t[55]!==R?(z=(0,$.jsx)(be,{open:n,onOpenChange:r,children:R}),t[53]=r,t[54]=n,t[55]=R,t[56]=z):z=t[56],z}function jo(e){let t=(0,Q.c)(62),{open:n,onOpenChange:r,prTitle:i,onPrTitleChange:a,prDescription:o,onPrDescriptionChange:c,isGeneratingPRInfo:l,isLoading:u,onGeneratePRInfo:d,onCreatePR:f,currentBranch:p,autoGeneratePRInfo:m,onAutoGeneratePRInfoChange:h}=e,g;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(Ee,{children:`Create Pull Request`}),t[0]=g):g=t[0];let _;t[1]===p?_=t[2]:(_=(0,$.jsxs)(w,{children:[g,(0,$.jsxs)(s,{children:[`Create a pull request for branch `,p]})]}),t[1]=p,t[2]=_);let v;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(H,{htmlFor:`pr-title`,children:`Title (optional)`}),t[3]=v):v=t[3];let y=p||`Enter PR title...`,b;t[4]===a?b=t[5]:(b=e=>a(e.target.value),t[4]=a,t[5]=b);let x;t[6]!==i||t[7]!==y||t[8]!==b?(x=(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[v,(0,$.jsx)(se,{id:`pr-title`,placeholder:y,value:i,onChange:b})]}),t[6]=i,t[7]=y,t[8]=b,t[9]=x):x=t[9];let S;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,$.jsx)(H,{htmlFor:`pr-description`,children:`Description (optional)`}),t[10]=S):S=t[10];let C;t[11]===c?C=t[12]:(C=e=>c(e.target.value),t[11]=c,t[12]=C);let T;t[13]!==o||t[14]!==C?(T=(0,$.jsx)(ir,{id:`pr-description`,placeholder:`Enter PR description...`,value:o,onChange:C,rows:4,className:`pr-10`}),t[13]=o,t[14]=C,t[15]=T):T=t[15];let E=l||u,D;t[16]===l?D=t[17]:(D=l?(0,$.jsx)(ot,{className:`h-3.5 w-3.5 animate-spin`}):(0,$.jsx)(De,{className:`h-3.5 w-3.5`}),t[16]=l,t[17]=D);let O;t[18]!==d||t[19]!==E||t[20]!==D?(O=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(U,{type:`button`,variant:`ghost`,size:`icon`,className:`absolute top-2 right-2 h-6 w-6`,onClick:d,disabled:E,children:D})}),t[18]=d,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)(q,{children:k}),t[22]=k,t[23]=A);let j;t[24]!==O||t[25]!==A?(j=(0,$.jsx)(ar,{children:(0,$.jsxs)(J,{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:[S,(0,$.jsxs)(`div`,{className:`relative`,children:[T,j]})]}),t[27]=j,t[28]=T,t[29]=M):M=t[29];let N;t[30]===h?N=t[31]:(N=e=>h(e===!0),t[30]=h,t[31]=N);let P;t[32]!==m||t[33]!==N?(P=(0,$.jsx)(Ar,{id:`auto-generate-pr`,checked:m,onCheckedChange:N}),t[32]=m,t[33]=N,t[34]=P):P=t[34];let F;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,$.jsx)(H,{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 L;t[38]!==M||t[39]!==I||t[40]!==x?(L=(0,$.jsxs)(`div`,{className:`grid gap-4 py-4`,children:[x,M,I]}),t[38]=M,t[39]=I,t[40]=x,t[41]=L):L=t[41];let R;t[42]===r?R=t[43]:(R=()=>r(!1),t[42]=r,t[43]=R);let z;t[44]!==u||t[45]!==R?(z=(0,$.jsx)(U,{variant:`outline`,onClick:R,disabled:u,children:`Cancel`}),t[44]=u,t[45]=R,t[46]=z):z=t[46];let ee=u?`Creating...`:`Create PR`,B;t[47]!==u||t[48]!==f||t[49]!==ee?(B=(0,$.jsx)(U,{onClick:f,disabled:u,children:ee}),t[47]=u,t[48]=f,t[49]=ee,t[50]=B):B=t[50];let te;t[51]!==z||t[52]!==B?(te=(0,$.jsxs)(ke,{children:[z,B]}),t[51]=z,t[52]=B,t[53]=te):te=t[53];let ne;t[54]!==_||t[55]!==L||t[56]!==te?(ne=(0,$.jsxs)(ln,{children:[_,L,te]}),t[54]=_,t[55]=L,t[56]=te,t[57]=ne):ne=t[57];let V;return t[58]!==r||t[59]!==n||t[60]!==ne?(V=(0,$.jsx)(be,{open:n,onOpenChange:r,children:ne}),t[58]=r,t[59]=n,t[60]=ne,t[61]=V):V=t[61],V}function Mo(e){let t=(0,Q.c)(48),{open:n,onOpenChange:r,repoName:i,onRepoNameChange:a,repoDescription:o,onRepoDescriptionChange:c,isPrivateRepo:l,onPrivateRepoChange:u,isLoading:d,onCreateRepo:f}=e,p;t[0]!==r||t[1]!==c||t[2]!==a?(p=e=>{e||(a(``),c(``)),r(e)},t[0]=r,t[1]=c,t[2]=a,t[3]=p):p=t[3];let m;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsxs)(w,{children:[(0,$.jsx)(Ee,{children:`Create GitHub Repository`}),(0,$.jsx)(s,{children:`Create a new GitHub repository and push your local repository`})]}),t[4]=m):m=t[4];let h;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(H,{htmlFor:`repo-name`,children:`Repository Name (optional)`}),t[5]=h):h=t[5];let g;t[6]===a?g=t[7]:(g=e=>a(e.target.value),t[6]=a,t[7]=g);let _;t[8]!==i||t[9]!==g?(_=(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[h,(0,$.jsx)(se,{id:`repo-name`,placeholder:`Leave empty to use current folder name`,value:i,onChange:g})]}),t[8]=i,t[9]=g,t[10]=_):_=t[10];let v;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(H,{htmlFor:`repo-description`,children:`Description (optional)`}),t[11]=v):v=t[11];let y;t[12]===c?y=t[13]:(y=e=>c(e.target.value),t[12]=c,t[13]=y);let b;t[14]!==o||t[15]!==y?(b=(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[v,(0,$.jsx)(ir,{id:`repo-description`,placeholder:`Enter repository description...`,value:o,onChange:y,rows:3})]}),t[14]=o,t[15]=y,t[16]=b):b=t[16];let x;t[17]===u?x=t[18]:(x=e=>u(e===!0),t[17]=u,t[18]=x);let S;t[19]!==l||t[20]!==x?(S=(0,$.jsx)(Ar,{id:`repo-private`,checked:l,onCheckedChange:x}),t[19]=l,t[20]=x,t[21]=S):S=t[21];let C;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,$.jsx)(H,{htmlFor:`repo-private`,className:`text-sm font-normal`,children:`Private repository`}),t[22]=C):C=t[22];let T;t[23]===S?T=t[24]:(T=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[S,C]}),t[23]=S,t[24]=T);let E;t[25]!==T||t[26]!==_||t[27]!==b?(E=(0,$.jsxs)(`div`,{className:`grid gap-4 py-4`,children:[_,b,T]}),t[25]=T,t[26]=_,t[27]=b,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]!==d||t[32]!==D?(O=(0,$.jsx)(U,{variant:`outline`,onClick:D,disabled:d,children:`Cancel`}),t[31]=d,t[32]=D,t[33]=O):O=t[33];let k=d?`Creating...`:`Create & Push`,A;t[34]!==d||t[35]!==f||t[36]!==k?(A=(0,$.jsx)(U,{onClick:f,disabled:d,children:k}),t[34]=d,t[35]=f,t[36]=k,t[37]=A):A=t[37];let j;t[38]!==O||t[39]!==A?(j=(0,$.jsxs)(ke,{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)(ln,{children:[m,E,j]}),t[41]=E,t[42]=j,t[43]=M):M=t[43];let N;return t[44]!==n||t[45]!==p||t[46]!==M?(N=(0,$.jsx)(be,{open:n,onOpenChange:p,children:M}),t[44]=n,t[45]=p,t[46]=M,t[47]=N):N=t[47],N}function No(e){let t=(0,Q.c)(28),{open:n,onOpenChange:r,commits:i,displayedCommits:a,isLoadingMore:o,onScroll:c,currentBranch:l}=e,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(Ee,{children:`Commit History`}),t[0]=u):u=t[0];let d;t[1]===l?d=t[2]:(d=(0,$.jsxs)(w,{children:[u,(0,$.jsxs)(s,{children:[`Recent commits on branch `,l]})]}),t[1]=l,t[2]=d);let f;t[3]===a?f=t[4]:(f=a.length>0?a.map(Po):(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)(ot,{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]!==c||t[16]!==h?(g=(0,$.jsx)(`div`,{className:`flex-1 overflow-y-auto border rounded-lg`,onScroll:c,children:h}),t[15]=c,t[16]=h,t[17]=g):g=t[17];let _;t[18]===r?_=t[19]:(_=(0,$.jsx)(ke,{children:(0,$.jsx)(U,{onClick:()=>r(!1),children:`Close`})}),t[18]=r,t[19]=_);let v;t[20]!==d||t[21]!==g||t[22]!==_?(v=(0,$.jsxs)(ln,{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)(be,{open:n,onOpenChange:r,children:v}),t[24]=r,t[25]=n,t[26]=v,t[27]=y):y=t[27],y}function Po(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 Fo(e){let t=(0,Q.c)(15),{open:n,onOpenChange:r,isLoading:i,onPushAndCreatePR:a,onCancel:o}=e,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsxs)(w,{children:[(0,$.jsx)(Ee,{children:`Push Branch First`}),(0,$.jsx)(s,{children:`Your branch needs to be pushed to the remote before creating a pull request. Would you like to push it now?`})]}),t[0]=c):c=t[0];let l;t[1]!==i||t[2]!==o?(l=(0,$.jsx)(U,{variant:`outline`,onClick:o,disabled:i,children:`Cancel`}),t[1]=i,t[2]=o,t[3]=l):l=t[3];let u=i?`Pushing...`:`Push & Create PR`,d;t[4]!==i||t[5]!==a||t[6]!==u?(d=(0,$.jsx)(U,{onClick:a,disabled:i,children:u}),t[4]=i,t[5]=a,t[6]=u,t[7]=d):d=t[7];let f;t[8]!==l||t[9]!==d?(f=(0,$.jsxs)(ln,{children:[c,(0,$.jsxs)(ke,{children:[l,d]})]}),t[8]=l,t[9]=d,t[10]=f):f=t[10];let p;return t[11]!==r||t[12]!==n||t[13]!==f?(p=(0,$.jsx)(be,{open:n,onOpenChange:r,children:f}),t[11]=r,t[12]=n,t[13]=f,t[14]=p):p=t[14],p}function Io(e){let t=(0,Q.c)(27),{open:n,onOpenChange:r,onCommitFirst:i,onStashAndPull:a,onCancel:o,isLoading:c}=e,l=c===void 0?!1:c,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsxs)(w,{children:[(0,$.jsxs)(Ee,{className:`flex items-center gap-2`,children:[(0,$.jsx)(ce,{className:`h-5 w-5 text-amber-500`}),`Uncommitted Changes Detected`]}),(0,$.jsx)(s,{children:`You have uncommitted changes. You need to handle them before pulling from the remote branch.`})]}),t[0]=u):u=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)(de,{className:`h-4 w-4 mr-2`}),t[2]=f):f=t[2];let p;t[3]!==l||t[4]!==i?(p=(0,$.jsxs)(U,{onClick:i,disabled:l,className:`w-full justify-start`,variant:`outline`,children:[f,`Commit changes first, then pull`]}),t[3]=l,t[4]=i,t[5]=p):p=t[5];let m;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(We,{className:`h-4 w-4 mr-2`}),t[6]=m):m=t[6];let h;t[7]!==l||t[8]!==a?(h=(0,$.jsxs)(U,{onClick:a,disabled:l,className:`w-full justify-start`,variant:`outline`,children:[m,`Stash changes → Pull → Restore changes`]}),t[7]=l,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]!==l||t[18]!==o?(b=(0,$.jsx)(ke,{children:(0,$.jsx)(U,{variant:`ghost`,onClick:o,disabled:l,children:`Cancel`})}),t[17]=l,t[18]=o,t[19]=b):b=t[19];let x;t[20]!==y||t[21]!==b?(x=(0,$.jsxs)(ln,{className:`sm:max-w-[425px]`,children:[u,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)(be,{open:n,onOpenChange:r,children:x}),t[23]=r,t[24]=n,t[25]=x,t[26]=S):S=t[26],S}function Lo(e){let t=(0,Q.c)(19),{open:n,onOpenChange:r,onNewBranch:i,onJustOpen:a,isLoading:o,defaultBranch:c}=e,l=o===void 0?!1:o,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(Ee,{children:`Pull Request Merged`}),t[0]=u):u=t[0];let d=c?` from ${c}`:``,f;t[1]===d?f=t[2]:(f=(0,$.jsxs)(w,{children:[u,(0,$.jsxs)(s,{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]!==l||t[4]!==a?(p=(0,$.jsx)(U,{variant:`ghost`,onClick:a,disabled:l,children:`Just Open`}),t[3]=l,t[4]=a,t[5]=p):p=t[5];let m;t[6]!==l||t[7]!==i?(m=(0,$.jsx)(U,{onClick:i,disabled:l,children:`New Branch`}),t[6]=l,t[7]=i,t[8]=m):m=t[8];let h;t[9]!==p||t[10]!==m?(h=(0,$.jsxs)(ke,{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)(ln,{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)(be,{open:n,onOpenChange:r,children:g}),t[15]=r,t[16]=n,t[17]=g,t[18]=_):_=t[18],_}function Ro(e){let t=(0,Q.c)(35),{open:n,onOpenChange:r,branchName:i,onBranchNameChange:a,isLoading:o,onCreateBranch:c}=e,l;t[0]!==i||t[1]!==o||t[2]!==c?(l=e=>{e.key===`Enter`&&i.trim()&&!o&&c()},t[0]=i,t[1]=o,t[2]=c,t[3]=l):l=t[3];let u=l,d;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsxs)(w,{children:[(0,$.jsx)(Ee,{children:`New Branch`}),(0,$.jsx)(s,{children:`Enter a name for the new branch.`})]}),t[4]=d):d=t[4];let f;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(H,{htmlFor:`branch-name`,children:`Branch Name`}),t[5]=f):f=t[5];let p;t[6]===a?p=t[7]:(p=e=>a(e.target.value),t[6]=a,t[7]=p);let m;t[8]!==i||t[9]!==u||t[10]!==o||t[11]!==p?(m=(0,$.jsx)(`div`,{className:`grid gap-4 py-4`,children:(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[f,(0,$.jsx)(se,{id:`branch-name`,placeholder:`e.g. feature/my-feature`,value:i,onChange:p,onKeyDown:u,disabled:o,autoFocus:!0})]})}),t[8]=i,t[9]=u,t[10]=o,t[11]=p,t[12]=m):m=t[12];let h;t[13]===r?h=t[14]:(h=()=>r(!1),t[13]=r,t[14]=h);let g;t[15]!==o||t[16]!==h?(g=(0,$.jsx)(U,{variant:`outline`,onClick:h,disabled:o,children:`Cancel`}),t[15]=o,t[16]=h,t[17]=g):g=t[17];let _;t[18]!==i||t[19]!==o?(_=o||!i.trim(),t[18]=i,t[19]=o,t[20]=_):_=t[20];let v=o?`Creating...`:`Create Branch`,y;t[21]!==c||t[22]!==_||t[23]!==v?(y=(0,$.jsx)(U,{onClick:c,disabled:_,children:v}),t[21]=c,t[22]=_,t[23]=v,t[24]=y):y=t[24];let b;t[25]!==y||t[26]!==g?(b=(0,$.jsxs)(ke,{children:[g,y]}),t[25]=y,t[26]=g,t[27]=b):b=t[27];let x;t[28]!==b||t[29]!==m?(x=(0,$.jsxs)(ln,{children:[d,m,b]}),t[28]=b,t[29]=m,t[30]=x):x=t[30];let S;return t[31]!==r||t[32]!==n||t[33]!==x?(S=(0,$.jsx)(be,{open:n,onOpenChange:r,children:x}),t[31]=r,t[32]=n,t[33]=x,t[34]=S):S=t[34],S}function zo(e){let t=e.split(`/`);return t.length>=2?{provider:t[0],model:t.slice(1).join(`/`)}:{provider:void 0,model:e}}function Bo(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}:zo(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 M(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 Ne(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 Vo({projectId:e,threadId:t}){let{state:n,dispatch:r}=Yn(),[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(``),[m,h]=(0,Z.useState)(``),[g,_]=(0,Z.useState)(``),[v,b]=(0,Z.useState)(!1),[x,C]=(0,Z.useState)(null),w=(0,Z.useRef)(!1),T=(0,Z.useRef)(!1),[E,D]=(0,Z.useState)(!1),[O,k]=(0,Z.useState)([]),[A,M]=(0,Z.useState)(!1),[N,P]=(0,Z.useState)([]),[F,I]=(0,Z.useState)(!1),[L,R]=(0,Z.useState)(!1),[z,ee]=(0,Z.useState)(``),[B,te]=(0,Z.useState)(``),[V,re]=(0,Z.useState)(``),[H,ie]=(0,Z.useState)(!1),[oe,se]=(0,Z.useState)(!1),[ce,de]=(0,Z.useState)(!1),[fe,pe]=(0,Z.useState)(!1),[me,he]=(0,Z.useState)(``),[_e,ve]=(0,Z.useState)([]),[ye,be]=(0,Z.useState)(!1),W=ur(t),Se=Bo(t,e,n.projectModelSelections);async function Ce(){Oe();let e=await on();r({type:K.SetProjects,projects:e.projects})}let[we,Te]=(0,Z.useState)(()=>Do()),Ee=n.projects.find(t=>t.projectId===e),De=Ee?.commitMethod===jt.Direct;(0,Z.useEffect)(()=>{function e(){document.visibilityState===`visible`&&W.fetchUnifiedStatus(!0)}return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[W.fetchUnifiedStatus]),(0,Z.useEffect)(()=>{L&&Ee?.name&&!z&&ee(Ee.name)},[L,Ee?.name,z]),(0,Z.useEffect)(()=>{Oo(we)},[we]),(0,Z.useEffect)(()=>{let e=!0;return Ye().then(t=>{e&&re(t)}).catch(()=>{}),()=>{e=!1}},[]),(0,Z.useEffect)(()=>{if(!c){T.current=!1;return}if(c&&we.autoGenerateCommitMessage&&!f.trim()&&t&&!T.current){T.current=!0;async function e(){let e=await Se.generateCommitMessageWithAI();e&&p(e)}e()}},[c,we.autoGenerateCommitMessage,t,Se,f]),(0,Z.useEffect)(()=>{if(!u){w.current=!1;return}if(console.log(`[pr-auto-gen] useEffect triggered`,{isPRDialogOpen:u,autoGeneratePRInfo:we.autoGeneratePRInfo,prTitleEmpty:!m.trim(),prDescriptionEmpty:!g.trim(),threadId:t,hasThreadId:!!t,generationAlreadyStarted:w.current}),u&&we.autoGeneratePRInfo&&!m.trim()&&!g.trim()&&t&&!w.current){console.log(`[pr-auto-gen] Starting auto-generation...`),w.current=!0;async function e(){let e=await Se.generatePRInfoWithAI();e&&(console.log(`[pr-auto-gen] Setting PR info:`,e.title.substring(0,50)),h(e.title),_(e.description))}e()}else console.log(`[pr-auto-gen] Skipping auto-generation - conditions not met`)},[u,we.autoGeneratePRInfo,t,Se,m,g]),(0,Z.useEffect)(()=>{console.log(`Unified status changed:`,{prExists:W.prExists,prState:W.prState,threadId:t}),W.prExists&&W.prState===`MERGED`&&(console.log(`Merged PR detected, opening dialog`),de(!0))},[W.prExists,W.prState,t]),(0,Z.useEffect)(()=>{!n.isStreaming&&n.completedThreadIds.includes(n.selectedThreadId??``)&&(W.fetchUnifiedStatus(!0),r({type:K.ClearThreadCompleted,threadId:n.selectedThreadId??``}))},[n.isStreaming,n.completedThreadIds,n.selectedThreadId,W,r]);async function ke(){if(f.trim()&&ko(t))try{a(!0),await le(t,f),p(``),l(!1),await W.fetchUnifiedStatus(!0),Ce(),X({title:`Changes committed successfully`,description:`Your changes have been committed to '${W.currentBranch}'.`}),oe&&(se(!1),await Fe())}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 je(){if(W.status===`Behind`&&!W.hasChanges&&!W.hasUnpushedCommits){await Be();return}if(W.hasChanges){l(!0);return}if(W.prExists&&W.prState===`OPEN`&&!W.hasChanges&&!W.hasUnpushedCommits){W.prUrl&&await S(W.prUrl);return}if(W.commitsAheadOfDefault&&!W.prExists&&!W.hasChanges){d(!0);return}if(W.hasUnpushedCommits&&W.prExists){await Ne();return}}async function G(){let e=await Se.generateCommitMessageWithAI();e&&p(e)}async function Me(){if(ko(t))try{a(!0),await j(t),await W.fetchUnifiedStatus()}catch(e){console.error(`Failed to fetch:`,e)}finally{a(!1)}}async function Ne(){if(ko(t))try{a(!0),await dn(t),await W.fetchUnifiedStatus(!0),Ce(),W.hasRemoteBranch?X({title:`Branch pushed successfully`,description:`Your branch '${W.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 Pe(){if(ko(t)){if(W.hasChanges){ie(!0);return}await Fe()}}async function Fe(){try{a(!0),await xe(t),await W.fetchUnifiedStatus(!0),Ce(),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 Ie(){ie(!1),se(!0),l(!0)}async function Le(){ie(!1),await Fe()}async function Re(){if(t)try{a(!0);let e=await ge(t,W.defaultBranch??void 0);Oe();let n=await on();r({type:K.SetProjects,projects:n.projects}),X({title:`New branch created`,description:`Created new branch "${e.branchName}" on current thread`}),de(!1),await W.fetchUnifiedStatus(!0),setTimeout(()=>void W.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 ze(){if(!(!t||!me.trim()))try{a(!0);let e=await ge(t,W.defaultBranch??void 0,me.trim());Oe();let n=await on();r({type:K.SetProjects,projects:n.projects}),X({title:`New branch created`,description:`Switched to branch "${e.branchName}"`}),he(``),pe(!1),await W.fetchUnifiedStatus(!0),setTimeout(()=>void W.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 Be(){if(!ko(t)){console.log(`[sync] Thread operation validation failed`);return}try{console.log(`[sync] Starting branch sync for thread: ${t}`),console.log(`[sync] Current branch: ${W.currentBranch}, Default branch: ${W.defaultBranch}`),a(!0),console.log(`[sync] Calling gitSyncBranch API...`);let e=await Ae(t);console.log(`[sync] ✓ gitSyncBranch API call successful`),console.log(`[sync] Result:`,e),console.log(`[sync] Refreshing git status...`),await W.fetchUnifiedStatus(!0),Ce(),console.log(`[sync] ✓ Git status refreshed`),X({title:`Branch synced successfully`,description:`Your branch '${W.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 Ve(){if(ko(t))try{a(!0),s(!0);let e=await y(t,m,g);e.prUrl&&await S(e.prUrl),h(``),_(``),d(!1),await W.fetchUnifiedStatus(),Ce()}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),We({title:m,description:g})):X({title:`Create PR Failed`,description:t,variant:`destructive`})}finally{a(!1),s(!1)}}async function He(){if(ko(t))try{a(!0);let e=await ue(t,z,B,we.privateRepositoryDefault);e.repoUrl&&setTimeout(()=>{S(e.repoUrl)},3e3),ee(``),te(``),R(!1),await W.fetchUnifiedStatus(),Ce()}catch(e){console.error(`Failed to create repo:`,e)}finally{a(!1)}}async function Ue(){let e=await Se.generatePRInfoWithAI();e&&(h(e.title),_(e.description))}async function We(e){let n=e??x;if(!(!t||!n))try{a(!0),s(!0);try{await dn(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 Ae(t),console.log(`[push-and-pr] ✓ Pull completed, retrying push...`),await dn(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 y(t,n.title,n.description);e.prUrl&&await S(e.prUrl),h(``),_(``),C(null),b(!1),await W.fetchUnifiedStatus(),Ce()}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 Ge(){if(ko(t))try{M(!0);let e=await Pt(t,100);k(e),P(e.slice(0,10)),D(!0)}catch(e){console.error(`Failed to fetch git history:`,e)}finally{M(!1)}}function Ke(){F||(I(!0),setTimeout(()=>{let e=N.length+10;P(O.slice(0,e)),I(!1)},300))}function qe(e){let t=e.currentTarget;t.scrollHeight-t.scrollTop-t.clientHeight<100&&N.length<O.length&&!F&&Ke()}let Je=To(W);async function Xe(){if(!ye){be(!0);try{ve((await ne(t)).branches)}catch{ve([])}finally{be(!1)}}}async function Ze(e){if(e!==W.currentBranch){a(!0);try{await ae(t,e),await W.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 Qe(){he(``),pe(!0)}function $e(){W.repoUrl&&S(W.repoUrl)}function et(){b(!1),C(null)}function tt(){de(!1),W.fetchUnifiedStatus(!0)}return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-0`,children:[(0,$.jsx)(ar,{children:(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(U,{variant:`outline`,size:`sm`,className:`h-8 rounded-r-none border-r-0 gap-1.5 border-transparent${Je?` bg-brand text-brand-foreground hover:bg-brand/90 hover:text-brand-foreground`:``}`,disabled:wo(W,i),onClick:je,children:[So(W,o),xo(W,o)]})}),(0,$.jsx)(q,{children:Co(W)})]})}),(0,$.jsx)(Eo,{branchStatus:W.status,currentBranch:W.currentBranch,remoteUrl:W.remoteUrl,hasRemoteBranch:W.hasRemoteBranch,hasUnpushedCommits:W.hasUnpushedCommits,canCreateRepo:W.canCreateRepo,repoUrl:W.repoUrl,isRefreshing:W.isRefreshing,isBrandState:Je,gitUser:V,availableBranches:_e,isLoadingBranches:ye,onBranchSubMenuOpen:Xe,onCheckoutBranch:Ze,isDirectCommitMode:De,isLoading:i,isLoadingHistory:A,onFetch:()=>void Me(),onPull:()=>void Pe(),onPush:()=>void Ne(),onOpenHistory:()=>void Ge(),onNewBranch:Qe,onCreatePR:()=>d(!0),onCreateRepo:()=>R(!0),onViewInGitHub:$e})]}),(0,$.jsx)(Ao,{open:c,onOpenChange:l,commitMessage:f,onCommitMessageChange:p,autoGenerateCommitMessage:we.autoGenerateCommitMessage,onAutoGenerateChange:e=>Te(t=>({...t,autoGenerateCommitMessage:e})),isGeneratingMessage:Se.isGeneratingMessage,isLoading:i,onGenerateMessage:G,onCommit:ke,currentBranch:W.currentBranch}),(0,$.jsx)(jo,{open:u,onOpenChange:d,prTitle:m,onPrTitleChange:h,prDescription:g,onPrDescriptionChange:_,isGeneratingPRInfo:Se.isGeneratingPRInfo,isLoading:i,onGeneratePRInfo:Ue,onCreatePR:Ve,currentBranch:W.currentBranch,autoGeneratePRInfo:we.autoGeneratePRInfo,onAutoGeneratePRInfoChange:e=>Te(t=>({...t,autoGeneratePRInfo:e}))}),(0,$.jsx)(Fo,{open:v,onOpenChange:b,isLoading:i,onPushAndCreatePR:We,onCancel:et}),(0,$.jsx)(Mo,{open:L,onOpenChange:R,repoName:z,onRepoNameChange:ee,repoDescription:B,onRepoDescriptionChange:te,isPrivateRepo:we.privateRepositoryDefault,onPrivateRepoChange:e=>Te(t=>({...t,privateRepositoryDefault:e})),isLoading:i,onCreateRepo:He}),(0,$.jsx)(No,{open:E,onOpenChange:D,commits:O,displayedCommits:N,isLoadingMore:F,onScroll:qe,currentBranch:W.currentBranch}),(0,$.jsx)(Io,{open:H,onOpenChange:ie,onCommitFirst:Ie,onStashAndPull:Le,onCancel:()=>ie(!1),isLoading:i}),(0,$.jsx)(Lo,{open:ce,onOpenChange:de,onNewBranch:Re,onJustOpen:tt,isLoading:i,defaultBranch:W.defaultBranch??void 0}),(0,$.jsx)(Ro,{open:fe,onOpenChange:pe,branchName:me,onBranchNameChange:he,isLoading:i,onCreateBranch:ze})]})}var Ho=`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 Uo({open:e,onOpenChange:n,projectId:r,commands:i,onRefresh:a}){let[o,c]=(0,Z.useState)(null),[l,u]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(!1),[m,h]=(0,Z.useState)([]),[g,y]=(0,Z.useState)(0),[b,x]=(0,Z.useState)(!1),S=(0,Z.useRef)(null),C=(0,Z.useRef)(null),T=()=>{c({id:crypto.randomUUID(),name:``,icon:`Play`,commandLine:``}),p(!1),h([])},E=e=>{c({...e}),p(!1),h([])},D=async()=>{try{x(!0);let e=await it(r);h(e.scripts),y(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{x(!1)}},O=e=>{c(t=>t?{...t,name:e.name,commandLine:e.commandLine,relativeFolder:e.relativePath||``}:null),p(!1),h([]),S.current?.focus()},k=e=>{f&&(e.key===`ArrowDown`?(e.preventDefault(),y(e=>e<m.length-1?e+1:e)):e.key===`ArrowUp`?(e.preventDefault(),y(e=>e>0?e-1:0)):e.key===`Enter`?(e.preventDefault(),g<m.length&&O(m[g])):e.key===`Escape`&&(e.preventDefault(),p(!1),h([])))};(0,Z.useEffect)(()=>{let e=e=>{C.current&&!C.current.contains(e.target)&&(p(!1),h([]))};return f&&document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[f]);let A=async e=>{try{await _(r,e),X({title:`Success`,description:`Command deleted`}),a()}catch{X({title:`Error`,description:`Failed to delete command`,variant:`destructive`})}};return(0,$.jsx)(be,{open:e,onOpenChange:n,children:(0,$.jsxs)(ln,{className:`sm:max-w-[500px]`,children:[(0,$.jsxs)(w,{children:[(0,$.jsx)(Ee,{children:`Project Commands`}),(0,$.jsx)(s,{children:`Manage custom commands for this project.`})]}),(0,$.jsx)(`div`,{className:`py-4 flex flex-col gap-4`,children:o?(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)(H,{htmlFor:`name`,children:`Command Name`}),(0,$.jsx)(se,{id:`name`,value:o.name,onChange:e=>c({...o,name:e.target.value}),placeholder:`e.g. Run Tests`,autoComplete:`off`})]}),(0,$.jsxs)(`div`,{className:`grid gap-2 relative`,children:[(0,$.jsx)(H,{htmlFor:`commandLine`,children:`Command Line`}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(ir,{ref:S,id:`commandLine`,value:o.commandLine,onChange:e=>c({...o,commandLine:e.target.value}),onKeyDown:k,placeholder:`e.g. npm test`,className:`font-mono text-xs min-h-[100px] resize-none pr-10`}),(0,$.jsx)(ar,{children:(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(U,{type:`button`,variant:`ghost`,size:`icon`,className:`absolute right-2 top-2 h-6 w-6 text-muted-foreground transition-colors`,onClick:()=>void D(),disabled:b,children:(0,$.jsx)($e,{className:`h-4 w-4`})})}),(0,$.jsx)(q,{children:(0,$.jsx)(`p`,{children:`Discover package scripts`})})]})})]}),f&&(0,$.jsx)(`div`,{ref:C,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)($e,{className:`h-3 w-3`}),`Available Scripts `,b&&`(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:G(`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:()=>O(e),onMouseEnter:()=>y(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:b?`Loading scripts...`:`No package scripts found`})]})})]}),(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[(0,$.jsx)(H,{htmlFor:`relativeFolder`,children:`Relative Folder`}),(0,$.jsx)(se,{id:`relativeFolder`,value:o.relativeFolder??``,onChange:e=>c({...o,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)(H,{children:`Icon`}),(0,$.jsx)(`div`,{className:`grid grid-cols-10 gap-1 p-2 bg-background rounded-md border border-border`,children:Ho.map(e=>{let t=d[e]||N;return(0,$.jsx)(U,{variant:o.icon===e?`default`:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:()=>c({...o,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)(U,{variant:`ghost`,size:`sm`,onClick:()=>c(null),children:[(0,$.jsx)(St,{className:`h-4 w-4 mr-2`}),` Cancel`]}),(0,$.jsxs)(U,{size:`sm`,onClick:async()=>{if(!o?.name||!o?.commandLine){X({title:`Error`,description:`Name and Command Line are required`,variant:`destructive`});return}try{u(!0),await tt(r,o),X({title:`Success`,description:`Command saved`}),c(null),a()}catch{X({title:`Error`,description:`Failed to save command`,variant:`destructive`})}finally{u(!1)}},disabled:l,children:[(0,$.jsx)(qt,{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:()=>E(e),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`div`,{className:`p-2 bg-muted rounded`,children:(0,$.jsx)(d[e.icon]||et,{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)(U,{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(),A(e.id)},children:(0,$.jsx)(v,{className:`h-4 w-4`})})})]},e.id))]}),(0,$.jsxs)(U,{variant:`outline`,className:`w-full border-dashed`,onClick:T,children:[(0,$.jsx)(t,{className:`h-4 w-4 mr-2`}),` Add New Command`]})]})})]})})}function Wo(){let e=(0,Q.c)(27),{state:t}=Yn(),{selectedProjectId:n,selectedThreadId:r,projects:i}=t,{dispatch:a}=tr(r),[o,s]=(0,Z.useState)(!1),c,l,u,f,p;if(e[0]!==a||e[1]!==i||e[2]!==n||e[3]!==r||e[4]!==t.isRunningCommand){p=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 m;e[12]!==a||e[13]!==n||e[14]!==r?(m=e=>{!n||!r||a({type:K.QueueTerminalCommand,threadId:r,command:e.commandLine,relativeFolder:e.relativeFolder})},e[12]=a,e[13]=n,e[14]=r,e[15]=m):m=e[15];let h=m,g;if(e[16]===a?g=e[17]:(g=async()=>{a({type:K.ConfigUpdated})},e[16]=a,e[17]=g),l=g,!n){p=null;break bb0}u=`flex items-center gap-1`,f=c.length===0?(0,$.jsx)(ar,{children:(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(U,{variant:`action`,size:`icon-md`,onClick:()=>s(!0),children:(0,$.jsx)(z,{})})}),(0,$.jsx)(q,{children:`Manage commands`})]})}):(0,$.jsx)($.Fragment,{children:(0,$.jsxs)(ar,{children:[c.map(e=>{let n=d[e.icon]||et;return(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(U,{variant:`action`,size:`icon-md`,onClick:()=>h({commandLine:e.commandLine,relativeFolder:e.relativeFolder}),disabled:t.isRunningCommand,children:(0,$.jsx)(n,{})})}),(0,$.jsx)(q,{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)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(U,{variant:`action`,size:`icon-md`,className:`ml-1`,onClick:()=>s(!0),children:(0,$.jsx)(z,{})})}),(0,$.jsx)(q,{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]=f,e[9]=p}else c=e[5],l=e[6],u=e[7],f=e[8],p=e[9];if(p!==Symbol.for(`react.early_return_sentinel`))return p;let m;e[18]!==c||e[19]!==l||e[20]!==n||e[21]!==o?(m=(0,$.jsx)(Uo,{open:o,onOpenChange:s,projectId:n,commands:c,onRefresh:l}),e[18]=c,e[19]=l,e[20]=n,e[21]=o,e[22]=m):m=e[22];let h;return e[23]!==u||e[24]!==f||e[25]!==m?(h=(0,$.jsxs)(`div`,{className:u,children:[f,m]}),e[23]=u,e[24]=f,e[25]=m,e[26]=h):h=e[26],h}function Go(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 Ko({threadId:e}){let{dispatch:t}=Yn(),{setTerminalNotification:r}=Or(),[i,a]=(0,Z.useState)(null),[o,s]=(0,Z.useState)(new Set),c=(0,Z.useRef)(new Map);(0,Z.useEffect)(()=>((async()=>{try{let t=await Je(e);if(t.length===0){a(null);return}a(t),s(new Set(t.filter(e=>e.isRunning).map(e=>e.name)))}catch{a(null)}})(),()=>{for(let e of c.current.values())e.abort();c.current.clear()}),[e]);let l=async i=>{if(o.has(i.name)){let n=c.current.get(i.name);n&&(n.abort(),c.current.delete(i.name));try{await Zt(e,i.name)}catch{}t({type:K.AppendTerminalLine,threadId:e,line:{type:`system`,content:`■ ${i.friendlyName} stopped`}}),s(e=>{let t=new Set(e);return t.delete(i.name),t})}else{let a=new AbortController;c.current.set(i.name,a),s(e=>new Set([...e,i.name])),r(!0),t({type:K.AppendTerminalLine,threadId:e,line:{type:`system`,content:`▶ ${i.friendlyName}`}});try{let r=await n(e,i.name,i.command,{signal:a.signal});if(r){let n=r.getReader(),i=new TextDecoder,a=``;try{for(;;){let{done:r,value:o}=await n.read();if(r)break;a+=i.decode(o,{stream:!0});let s=a.split(`
34
+ `);a=s.pop()??``;for(let n of s)if(n.trim())try{let r=JSON.parse(n);typeof r==`string`?t({type:K.AppendTerminalLine,threadId:e,line:{type:`output`,content:r}}):r.type===`error`&&t({type:K.AppendTerminalLine,threadId:e,line:{type:`error`,content:r.message}})}catch{t({type:K.AppendTerminalLine,threadId:e,line:{type:`output`,content:n}})}}if(a.trim())try{let n=JSON.parse(a);typeof n==`string`?t({type:K.AppendTerminalLine,threadId:e,line:{type:`output`,content:n}}):n.type===`error`&&t({type:K.AppendTerminalLine,threadId:e,line:{type:`error`,content:n.message}})}catch{t({type:K.AppendTerminalLine,threadId:e,line:{type:`output`,content:a}})}}finally{n.releaseLock()}}t({type:K.AppendTerminalLine,threadId:e,line:{type:`system`,content:`✓ ${i.friendlyName} done`}})}catch{}finally{c.current.delete(i.name),s(e=>{let t=new Set(e);return t.delete(i.name),t})}}};if(!i)return null;let u=i.reduce((e,t)=>(e[t.workspace]||(e[t.workspace]=[]),e[t.workspace].push(t),e),{}),d=Object.entries(u).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>[e,[...t].sort((e,t)=>e.friendlyName.localeCompare(t.friendlyName))]),f=d.length>1;return(0,$.jsxs)(ao,{children:[(0,$.jsx)(ar,{children:(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(oo,{asChild:!0,children:(0,$.jsx)(U,{variant:`action`,size:`icon-md`,children:(0,$.jsx)(Ie,{})})})}),(0,$.jsx)(q,{children:`Project Scripts`})]})}),(0,$.jsx)(uo,{align:`end`,className:`min-w-[180px]`,children:f?d.map(([e,t])=>(0,$.jsxs)(so,{children:[(0,$.jsx)(co,{children:e}),(0,$.jsx)(lo,{className:`max-h-[min(400px,80vh)] overflow-y-auto`,children:t.map(e=>(0,$.jsxs)(fo,{onClick:()=>{l(e)},className:`gap-2`,children:[o.has(e.name)?(0,$.jsx)(ot,{className:`h-3 w-3 animate-spin shrink-0`}):(0,$.jsx)(`div`,{className:`h-3 w-3 shrink-0`}),e.friendlyName]},e.name))})]},e)):d[0]?.[1].map(e=>(0,$.jsxs)(fo,{onClick:()=>{l(e)},className:`gap-2`,children:[o.has(e.name)?(0,$.jsx)(ot,{className:`h-3 w-3 animate-spin shrink-0`}):(0,$.jsx)(`div`,{className:`h-3 w-3 shrink-0`}),e.friendlyName]},e.name))})]})}var qo=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=G(`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)(bn,{className:a,...i,ref:t}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});qo.displayName=bn.displayName;var Jo=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=G(`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)(pn,{className:`flex items-center justify-center`,children:(0,$.jsx)(Rt,{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)(Fn,{ref:t,className:a,...i,children:o}),n[6]=i,n[7]=t,n[8]=a,n[9]=s):s=n[9],s});Jo.displayName=Fn.displayName;function Yo({threadId:e,onSkillCreated:t}){let[n,r]=(0,Z.useState)(``),[i,a]=(0,Z.useState)(``),[o,s]=(0,Z.useState)(`local`),[c,l]=(0,Z.useState)(!1),u=n.toLowerCase().replace(/\s+/g,`-`).replace(/[^a-z0-9-]/g,``).replace(/-+/g,`-`).replace(/^-|-$/g,``),d=u.length>0&&u.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)(H,{htmlFor:`skillName`,children:`Skill Name`}),(0,$.jsx)(se,{id:`skillName`,value:n,onChange:e=>r(e.target.value),placeholder:`e.g. Code Review`,disabled:c}),n&&(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Folder name: `,(0,$.jsx)(`span`,{className:`font-mono`,children:u||`...`})]})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(H,{htmlFor:`skillDescription`,children:`Description`}),(0,$.jsx)(ir,{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:c})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(H,{children:`Scope`}),(0,$.jsxs)(qo,{value:o,onValueChange:e=>s(e),className:`flex gap-4`,disabled:c,children:[(0,$.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,$.jsx)(Jo,{value:`local`,id:`scope-local`}),(0,$.jsx)(H,{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)(Jo,{value:`global`,id:`scope-global`,disabled:!0}),(0,$.jsx)(H,{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:o===`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)(U,{onClick:async()=>{if(!(!d||!i.trim()||!e)){l(!0);try{let n=await me(e,u,i.trim());X({title:`Skill created`,description:`Skill '${u}' was created successfully.`}),r(``),a(``),s(`local`),t?.(n.path,`SKILL.md`)}catch(e){X({title:`Error`,description:e instanceof Error?e.message:`Failed to create skill`,variant:`destructive`})}finally{l(!1)}}},disabled:!d||!i.trim()||c,children:c?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ot,{className:`mr-2 h-4 w-4 animate-spin`}),`Creating...`]}):(0,$.jsxs)($.Fragment,{children:[`Continue`,(0,$.jsx)(_e,{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 Xo=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=G(`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)(In,{className:G(`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)(Sn,{className:a,...i,ref:t,children:o}),n[6]=i,n[7]=t,n[8]=a,n[9]=s):s=n[9],s});Xo.displayName=Sn.displayName;function Zo({threadId:e,onRuleCreated:t}){let[n,r]=(0,Z.useState)(``),[i,a]=(0,Z.useState)(``),[o,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(`local`),[u,d]=(0,Z.useState)(!1),f=n.toLowerCase().replace(/\s+/g,`-`).replace(/[^a-z0-9-]/g,``).replace(/-+/g,`-`).replace(/^-|-$/g,``),p=f.length>0&&f.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)(H,{htmlFor:`ruleName`,children:`Rule Name`}),(0,$.jsx)(se,{id:`ruleName`,value:n,onChange:e=>r(e.target.value),placeholder:`e.g. Code Style Guide`,disabled:u}),n&&(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`File name: `,(0,$.jsxs)(`span`,{className:`font-mono`,children:[f||`...`,`.md`]})]})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(H,{htmlFor:`ruleDescription`,children:`Description`}),(0,$.jsx)(ir,{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:u})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(H,{htmlFor:`alwaysApply`,children:`Always Apply`}),(0,$.jsx)(Xo,{id:`alwaysApply`,checked:o,onCheckedChange:s,disabled:u})]}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:o?`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)(H,{children:`Scope`}),(0,$.jsxs)(qo,{value:c,onValueChange:e=>l(e),className:`flex gap-4`,disabled:u,children:[(0,$.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,$.jsx)(Jo,{value:`local`,id:`scope-local`}),(0,$.jsx)(H,{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)(Jo,{value:`global`,id:`scope-global`,disabled:!0}),(0,$.jsx)(H,{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:c===`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)(U,{onClick:async()=>{if(!(!p||!e)){d(!0);try{let n=`---
35
+ description: ${i.trim()}
36
+ alwaysApply: ${o}
37
+ ---
38
+
39
+ Place your rule instructions here as markdown.
40
+ `;await mt(e,`.agents/rules/${f}.md`,n),X({title:`Rule created`,description:`Rule '${f}' was created successfully.`}),r(``),a(``),s(!1),l(`local`),t?.(f)}catch(e){X({title:`Error`,description:e instanceof Error?e.message:`Failed to create rule`,variant:`destructive`})}finally{d(!1)}}},disabled:!p||!i.trim()||u,children:u?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ot,{className:`mr-2 h-4 w-4 animate-spin`}),`Creating...`]}):(0,$.jsxs)($.Fragment,{children:[`Continue`,(0,$.jsx)(_e,{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 Qo({threadId:e,onAgentCreated:t}){let[n,r]=(0,Z.useState)(``),[i,a]=(0,Z.useState)(``),[o,s]=(0,Z.useState)(``),[c,l]=(0,Z.useState)(`local`),[u,d]=(0,Z.useState)(!1),f=n.toLowerCase().replace(/\s+/g,`-`).replace(/[^a-z0-9-]/g,``).replace(/-+/g,`-`).replace(/^-|-$/g,``),p=f.length>0&&f.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)(H,{htmlFor:`agentName`,children:`Agent Name`}),(0,$.jsx)(se,{id:`agentName`,value:n,onChange:e=>r(e.target.value),placeholder:`e.g. Security Reviewer`,disabled:u}),n&&(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Folder name: `,(0,$.jsx)(`span`,{className:`font-mono`,children:f||`...`})]})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(H,{htmlFor:`agentDescription`,children:`Description`}),(0,$.jsx)(ir,{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:u})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(H,{htmlFor:`agentTools`,children:`Allowed Tools (optional)`}),(0,$.jsx)(se,{id:`agentTools`,value:o,onChange:e=>s(e.target.value),placeholder:`e.g. read grep glob`,disabled:u}),(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)(H,{children:`Scope`}),(0,$.jsxs)(qo,{value:c,onValueChange:e=>l(e),className:`flex gap-4`,disabled:u,children:[(0,$.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,$.jsx)(Jo,{value:`local`,id:`scope-local`}),(0,$.jsx)(H,{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)(Jo,{value:`global`,id:`scope-global`,disabled:!0}),(0,$.jsx)(H,{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:c===`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)(U,{onClick:async()=>{if(!(!p||!i.trim()||!e)){d(!0);try{let n=await oe(e,f,i.trim(),o.trim()||void 0);X({title:`Agent created`,description:`Agent '${f}' was created successfully.`}),r(``),a(``),s(``),l(`local`),t?.(n.path,`AGENT.md`)}catch(e){X({title:`Error`,description:e instanceof Error?e.message:`Failed to create agent`,variant:`destructive`})}finally{d(!1)}}},disabled:!p||!i.trim()||u,children:u?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ot,{className:`mr-2 h-4 w-4 animate-spin`}),`Creating...`]}):(0,$.jsxs)($.Fragment,{children:[`Continue`,(0,$.jsx)(_e,{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 $o({projectId:e,threadId:t,onCommandCreated:n}){let[r,i]=(0,Z.useState)(``),[a,o]=(0,Z.useState)(``),[s,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)(`default`),[d,f]=(0,Z.useState)(`local`),[p,m]=(0,Z.useState)(!1),h=r.toLowerCase().replace(/\s+/g,`-`).replace(/[^a-z0-9-]/g,``).replace(/-+/g,`-`).replace(/^-|-$/g,``),g=h.length>0&&h.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)(H,{htmlFor:`commandName`,children:`Command Name`}),(0,$.jsx)(se,{id:`commandName`,value:r,onChange:e=>i(e.target.value),placeholder:`e.g. review`,disabled:p}),r&&(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Command: `,(0,$.jsxs)(`span`,{className:`font-mono`,children:[`/`,h||`...`]})]})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(H,{htmlFor:`commandDescription`,children:`Description`}),(0,$.jsx)(se,{id:`commandDescription`,value:a,onChange:e=>o(e.target.value),placeholder:`Brief description shown in autocomplete`,disabled:p})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(H,{htmlFor:`argumentHint`,children:`Argument Hint (optional)`}),(0,$.jsx)(se,{id:`argumentHint`,value:s,onChange:e=>c(e.target.value),placeholder:`e.g. <focus-area> or <branch-name>`,disabled:p}),(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)(H,{children:`Mode`}),(0,$.jsxs)(qo,{value:l,onValueChange:e=>u(e),className:`flex gap-4`,disabled:p,children:[(0,$.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,$.jsx)(Jo,{value:`default`,id:`mode-default`}),(0,$.jsx)(H,{htmlFor:`mode-default`,className:`font-normal cursor-pointer`,children:`Default`})]}),(0,$.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,$.jsx)(Jo,{value:`plan`,id:`mode-plan`}),(0,$.jsx)(H,{htmlFor:`mode-plan`,className:`font-normal cursor-pointer`,children:`Plan`})]})]}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:l===`default`?`Standard chat mode`:`Activates plan mode when this command is used`})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(H,{children:`Scope`}),(0,$.jsxs)(qo,{value:d,onValueChange:e=>f(e),className:`flex gap-4`,disabled:p,children:[(0,$.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,$.jsx)(Jo,{value:`local`,id:`scope-local`}),(0,$.jsx)(H,{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)(Jo,{value:`global`,id:`scope-global`,disabled:!0}),(0,$.jsx)(H,{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:d===`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)(U,{onClick:async()=>{if(!(!g||!e)){m(!0);try{await gt(h,``,{description:a.trim()||void 0,argumentHint:s.trim()||void 0,mode:l===`plan`?`plan`:void 0},d===`global`?`global`:`project`,t??void 0),X({title:`Command created`,description:`Command '/${h}' was created successfully.`}),i(``),o(``),c(``),u(`default`),f(`local`),n?.(h)}catch(e){X({title:`Error`,description:e instanceof Error?e.message:`Failed to create command`,variant:`destructive`})}finally{m(!1)}}},disabled:!g||p,children:p?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ot,{className:`mr-2 h-4 w-4 animate-spin`}),`Creating...`]}):(0,$.jsxs)($.Fragment,{children:[`Continue`,(0,$.jsx)(_e,{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 es(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 Tt(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 ts(){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=()=>{Dt().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 ns(e,t,n){await At(e,t,n)}async function rs(e,t){await D(e,t)}function is({projectPath:e,serverName:n,onBack:r}){let{installedServers:i}=es(e),a=!!n,[o,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),[v,y]=(0,Z.useState)(null),[b,x]=(0,Z.useState)(a),[S,C]=(0,Z.useState)(``),[w,T]=(0,Z.useState)(``),[E,D]=(0,Z.useState)(``),[O,k]=(0,Z.useState)([]);(0,Z.useEffect)(()=>{if(a&&n){let e=i.find(e=>e.name===n);if(e){s(e.name),l(e.config.command);let t=e.config.args.join(`
41
+ `);d(t);let n=Object.entries(e.config.env??{}).map(([e,t])=>({key:e,value:t}));p(n),C(e.name),T(e.config.command),D(t),k(n),x(!1)}}else x(!1)},[i,n,a]);let A=(0,Z.useCallback)(()=>{p(e=>[...e,{key:``,value:``}])},[]),j=(0,Z.useCallback)(e=>{p(t=>t.filter((t,n)=>n!==e))},[]),M=(0,Z.useCallback)((e,t)=>{p(n=>n.map((n,r)=>r===e?{...n,key:t}:n))},[]),N=(0,Z.useCallback)((e,t)=>{p(n=>n.map((n,r)=>r===e?{...n,value:t}:n))},[]),P=()=>{let e=u.split(`
42
+ `).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}:{}}},F=async()=>{y(null);let t=o.trim(),n=c.trim();if(!t){y(`Server name is required`);return}if(!n){y(`Command is required`);return}h(!0);try{if(!e)throw Error(`No project path`);await ns(e,S||t,P()),X({title:`Success`,description:a?`MCP server configuration saved`:`MCP server added`}),r()}catch(e){y(e instanceof Error?e.message:`Failed to save server`)}finally{h(!1)}},I=async()=>{if(e){_(!0);try{await rs(e,S),X({title:`Success`,description:`MCP server removed`}),r()}catch(e){y(e instanceof Error?e.message:`Failed to delete server`)}finally{_(!1)}}},L=a?c!==w||u!==E||JSON.stringify(f)!==JSON.stringify(O):o.trim()!==``||c.trim()!==``||u.trim()!==``||f.length>0;return b?(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:a?o:`Add MCP Server`}),(0,$.jsx)(`p`,{className:`text-muted-foreground`,children:a?`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)(H,{htmlFor:`server-name`,children:`Server name`}),(0,$.jsx)(se,{id:`server-name`,placeholder:`e.g. filesystem`,value:o,onChange:e=>s(e.target.value),disabled:a}),a&&(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)(H,{htmlFor:`server-command`,children:`Command`}),(0,$.jsx)(se,{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)(H,{htmlFor:`server-args`,children:[`Arguments `,(0,$.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:`(one per line)`})]}),(0,$.jsx)(ir,{id:`server-args`,placeholder:`-y
43
+ @modelcontextprotocol/server-filesystem
44
+ /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)(H,{children:`Environment variables`}),(0,$.jsxs)(U,{variant:`ghost`,size:`sm`,onClick:A,className:`h-6 px-2 text-xs`,children:[(0,$.jsx)(t,{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)(se,{placeholder:`KEY`,value:e.key,onChange:e=>M(t,e.target.value),className:`font-mono text-xs w-[35%]`}),(0,$.jsx)(se,{placeholder:`value`,value:e.value,onChange:e=>N(t,e.target.value),className:`font-mono text-xs flex-1`}),(0,$.jsx)(U,{variant:`ghost`,size:`icon`,onClick:()=>j(t),className:`h-9 w-9 flex-shrink-0`,children:(0,$.jsx)(St,{className:`h-3.5 w-3.5`})})]},t))})]}),v&&(0,$.jsx)(`p`,{className:`text-sm text-destructive`,children:v}),(0,$.jsxs)(`div`,{className:`border-t pt-4 flex items-center justify-between`,children:[a&&(0,$.jsx)(U,{variant:`destructive`,onClick:I,disabled:g||m,children:g?`Removing...`:`Remove`}),!a&&(0,$.jsx)(`div`,{}),(0,$.jsx)(U,{onClick:F,disabled:m||g||!L,children:m?a?`Saving...`:`Adding...`:a?`Save`:`Add`})]})]})]})}function as(e){let t=(0,Q.c)(23),{name:n,description:r,installed:i,onClick:a,onOpen:o,onUninstall:s}=e,c=`flex flex-col gap-2 p-2.5 rounded-lg border border-border bg-card text-left transition-colors w-full ${i?``:`hover:bg-accent/50 cursor-pointer`}`,l=i?void 0:a,u=i?void 0:`button`,d;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(`div`,{className:`flex-shrink-0 h-6 w-6 rounded-md bg-muted flex items-center justify-center`,children:(0,$.jsx)(Bt,{className:`h-3 w-3 text-muted-foreground`})}),t[0]=d):d=t[0];let f;t[1]===n?f=t[2]:(f=(0,$.jsx)(`span`,{className:`font-medium text-sm truncate`,children:n}),t[1]=n,t[2]=f);let p;t[3]===i?p=t[4]:(p=i&&(0,$.jsx)(ar,{delayDuration:300,children:(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{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)(qt,{className:`h-2.5 w-2.5 text-green-600 dark:text-green-400`})})}),(0,$.jsx)(q,{children:`Installed`})]})}),t[3]=i,t[4]=p);let m;t[5]!==f||t[6]!==p?(m=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[d,f,p]}),t[5]=f,t[6]=p,t[7]=m):m=t[7];let h;t[8]!==i||t[9]!==o||t[10]!==s?(h=i&&(0,$.jsxs)(`div`,{className:`flex items-center gap-1 flex-shrink-0`,children:[o&&(0,$.jsx)(ar,{delayDuration:300,children:(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(U,{variant:`ghost`,size:`icon-sm`,onClick:e=>{e.stopPropagation(),o()},children:(0,$.jsx)(ye,{className:`h-3.5 w-3.5`})})}),(0,$.jsx)(q,{children:`Open in Explorer`})]})}),s&&(0,$.jsx)(ar,{delayDuration:300,children:(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(U,{variant:`ghost`,size:`icon-sm`,onClick:e=>{e.stopPropagation(),s()},className:`text-destructive hover:text-destructive`,children:(0,$.jsx)(v,{className:`h-3.5 w-3.5`})})}),(0,$.jsx)(q,{children:`Remove`})]})})]}),t[8]=i,t[9]=o,t[10]=s,t[11]=h):h=t[11];let g;t[12]!==m||t[13]!==h?(g=(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[m,h]}),t[12]=m,t[13]=h,t[14]=g):g=t[14];let _;t[15]===r?_=t[16]:(_=(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground line-clamp-3`,children:r}),t[15]=r,t[16]=_);let y;return t[17]!==c||t[18]!==_||t[19]!==l||t[20]!==u||t[21]!==g?(y=(0,$.jsxs)(`div`,{className:c,onClick:l,role:u,children:[g,_]}),t[17]=c,t[18]=_,t[19]=l,t[20]=u,t[21]=g,t[22]=y):y=t[22],y}function os(e){let t=[];for(let n of e)n.type===`file`&&t.push(n.path),n.children&&t.push(...os(n.children));return t}function ss({projectPath:e,threadId:t,onClose:n}){let{installedServers:r,loadInstalledServers:i}=es(e),{popularServers:a}=ts(),{setActiveMainTab:c,setPendingExplorerPath:l,triggerExplorerRefresh:u,setExplorerClearPath:d}=Or(),[f,p]=(0,Z.useState)(`mcp`),[m,h]=(0,Z.useState)(``),[g,_]=(0,Z.useState)(null),[v,y]=(0,Z.useState)(null),[b,x]=(0,Z.useState)(new Set),[C,T]=(0,Z.useState)(new Map),[D,O]=(0,Z.useState)([]),[k,A]=(0,Z.useState)([]),[j,M]=(0,Z.useState)([]),[N,P]=(0,Z.useState)([]);(0,Z.useEffect)(()=>{st().then(O).catch(()=>O([])),Lt().then(A).catch(()=>A([])),dt().then(M).catch(()=>M([])),He().then(P).catch(()=>P([]))},[]),(0,Z.useEffect)(()=>{t&&(pe(t).then(e=>x(new Set(os(e)))).catch(()=>{}),rn(t).then(e=>T(new Map(e.map(e=>[e.name,e.filePath])))).catch(()=>{}))},[t]);let I=(0,Z.useCallback)(e=>{p(e),h(``)},[]),L=(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]),R=(0,Z.useMemo)(()=>L(a),[a,L]),z=(0,Z.useMemo)(()=>L(D),[D,L]),ee=(0,Z.useMemo)(()=>L(k),[k,L]),B=(0,Z.useMemo)(()=>L(j),[j,L]),te=(0,Z.useMemo)(()=>L(N),[N,L]),ne=(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)){_(t.id);try{await ns(e,n,{command:t.command,args:t.args,...Object.keys(t.env??{}).length>0?{env:t.env}:{}}),await i(),u(),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{_(null)}}},[e,r,i,u]),V=(0,Z.useCallback)(async t=>{if(!e)return;let n=t.name.toLowerCase().replace(/\s+/g,`-`);try{await rs(e,n),await i(),u(),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,u]),re=(0,Z.useCallback)(()=>{l(`.agents/mcp.json`),c(`explorer`),n()},[l,c,n]),H=(0,Z.useCallback)(e=>{l(`.agents/skills/${e.id}/SKILL.md`),c(`explorer`),n()},[l,c,n]),ie=(0,Z.useCallback)(e=>{l(`.agents/agents/${e.id}/AGENT.md`),c(`explorer`),n()},[l,c,n]),ae=(0,Z.useCallback)(e=>{l(`.agents/rules/${e.name}.md`),c(`explorer`),n()},[l,c,n]),oe=(0,Z.useCallback)(e=>{let t=C.get(e.name);t&&(l(t),c(`explorer`),n())},[C,l,c,n]),ce=(0,Z.useCallback)(async e=>{if(!t)return;let n=`.agents/skills/${e.id}/SKILL.md`;try{await o(t,`.agents/skills/${e.id}`),x(e=>{let t=new Set(e);return t.delete(n),t}),d(`.agents/skills/${e.id}`),u(),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,u,d]),le=(0,Z.useCallback)(async e=>{if(!t)return;let n=`.agents/agents/${e.id}/AGENT.md`;try{await o(t,`.agents/agents/${e.id}`),x(e=>{let t=new Set(e);return t.delete(n),t}),d(`.agents/agents/${e.id}`),u(),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,u,d]),ue=(0,Z.useCallback)(async e=>{if(!t)return;let n=`.agents/rules/${e.name}.md`;try{await o(t,n),x(e=>{let t=new Set(e);return t.delete(n),t}),d(n),u(),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,u,d]),de=(0,Z.useCallback)(async e=>{let t=C.get(e.name);if(t)try{await ve(t),T(t=>{let n=new Map(t);return n.delete(e.name),n}),d(t),u(),X({title:`Command removed`,description:`/${e.name}`})}catch(e){X({title:`Error`,description:e instanceof Error?e.message:`Failed to remove command`,variant:`destructive`})}},[C,u,d]),fe=(0,Z.useCallback)((e,t,n,r)=>{y({name:e,gitHubRepo:t,gitHubFolder:n,onConfirm:r})},[]),me=(0,Z.useCallback)(async e=>{let n=`.agents/skills/${e.id}/SKILL.md`;if(!t||b.has(n))return;let r=async()=>{_(e.id);try{if(e.gitHubRepo&&e.gitHubFolder)await E(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 mt(t,n,r.join(`
45
+ `))}x(e=>new Set(e).add(n)),u(),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{_(null)}};e.gitHubRepo&&e.gitHubFolder?fe(e.name,e.gitHubRepo,e.gitHubFolder,r):await r()},[t,b,u,fe]),he=(0,Z.useCallback)(async e=>{let n=`.agents/agents/${e.id}/AGENT.md`;if(!t||b.has(n))return;let r=async()=>{_(e.id);try{if(e.gitHubRepo&&e.gitHubFolder)await E(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 mt(t,n,r.join(`
46
+ `))}x(e=>new Set(e).add(n)),u(),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{_(null)}};e.gitHubRepo&&e.gitHubFolder?fe(e.name,e.gitHubRepo,e.gitHubFolder,r):await r()},[t,b,u,fe]),ge=(0,Z.useCallback)(async e=>{let n=`.agents/rules/${e.name}.md`;if(!t||b.has(n))return;let r=async()=>{_(e.id);try{e.gitHubRepo&&e.gitHubFolder?await E(t,e.gitHubRepo,e.gitHubFolder,`.agents/rules`):await mt(t,n,[`---`,`description: ${e.description}`,`alwaysApply: ${e.alwaysApply??!1}`,`---`,``,e.content].join(`
47
+ `)),x(e=>new Set(e).add(n)),u(),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{_(null)}};e.gitHubRepo&&e.gitHubFolder?fe(e.name,e.gitHubRepo,e.gitHubFolder,r):await r()},[t,b,u,fe]),_e=(0,Z.useCallback)(async e=>{if(!t||C.has(e.name))return;let n=async()=>{_(e.id);try{if(e.gitHubRepo&&e.gitHubFolder){let n=`.agents/commands`;await E(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 gt(e.name,e.content,{description:e.description,argumentHint:e.argumentHint},`project`,t);T(t=>new Map(t).set(e.name,n.filePath))}u(),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{_(null)}};e.gitHubRepo&&e.gitHubFolder?fe(e.name,e.gitHubRepo,e.gitHubFolder,n):await n()},[t,C,u,fe]);function ye({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)(ot,{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:[g===e.id&&(0,$.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-background/60 rounded-lg z-10`,children:(0,$.jsx)(ot,{className:`h-4 w-4 animate-spin`})}),(0,$.jsx)(as,{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)(be,{open:v!==null,onOpenChange:e=>{e||y(null)},children:(0,$.jsxs)(ln,{children:[(0,$.jsxs)(w,{children:[(0,$.jsxs)(Ee,{children:[`Install `,v?.name]}),(0,$.jsxs)(s,{children:[`Install `,(0,$.jsx)(`strong`,{children:v?.name}),` from`,` `,(0,$.jsx)(`strong`,{children:v?.gitHubRepo}),` (`,v?.gitHubFolder,`)?`]})]}),(0,$.jsxs)(ke,{className:`flex-row gap-2 sm:justify-between`,children:[(0,$.jsx)(U,{variant:`outline`,onClick:()=>{v&&S(`${v.gitHubRepo.replace(/\.git$/,``)}/tree/HEAD/${v.gitHubFolder}`)},children:`More Information`}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(U,{variant:`outline`,onClick:()=>y(null),children:`No`}),(0,$.jsx)(U,{onClick:()=>{let e=v;y(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)(Lr,{value:f,onValueChange:I,children:(0,$.jsxs)(Ir,{className:`w-full`,children:[(0,$.jsx)(Pr,{value:`mcp`,className:`flex-1`,children:`MCP`}),(0,$.jsx)(Pr,{value:`skills`,className:`flex-1`,children:`Skills`}),(0,$.jsx)(Pr,{value:`agents`,className:`flex-1`,children:`Agents`}),(0,$.jsx)(Pr,{value:`rules`,className:`flex-1`,children:`Rules`}),(0,$.jsx)(Pr,{value:`commands`,className:`flex-1`,children:`Commands`})]})}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(F,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground pointer-events-none`}),(0,$.jsx)(se,{placeholder:`Search ${f===`mcp`?`servers`:f}...`,value:m,onChange:e=>h(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:a.length===0?(0,$.jsx)(`div`,{className:`flex items-center justify-center py-16`,children:(0,$.jsx)(ot,{className:`h-5 w-5 animate-spin text-muted-foreground`})}):R.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:R.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:[g===e.id&&(0,$.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-background/60 rounded-lg z-10`,children:(0,$.jsx)(ot,{className:`h-4 w-4 animate-spin`})}),(0,$.jsx)(as,{name:e.name,description:e.description,installed:n,onClick:()=>void ne(e),onOpen:n?re:void 0,onUninstall:n?()=>void V(e):void 0})]},e.id)})})}),f===`skills`&&(0,$.jsx)(ye,{items:z,onInstall:e=>void me(e),isInstalled:e=>b.has(`.agents/skills/${e.id}/SKILL.md`),noThreadWarning:!0,onOpen:H,onUninstall:e=>void ce(e)}),f===`agents`&&(0,$.jsx)(ye,{items:ee,onInstall:e=>void he(e),isInstalled:e=>b.has(`.agents/agents/${e.id}/AGENT.md`),noThreadWarning:!0,onOpen:ie,onUninstall:e=>void le(e)}),f===`rules`&&(0,$.jsx)(ye,{items:B,onInstall:e=>void ge(e),isInstalled:e=>b.has(`.agents/rules/${e.name}.md`),noThreadWarning:!0,onOpen:ae,onUninstall:e=>void ue(e)}),f===`commands`&&(0,$.jsx)(ye,{items:te,onInstall:e=>void _e(e),isInstalled:e=>C.has(e.name),noThreadWarning:!0,onOpen:oe,onUninstall:e=>void de(e)})]})]})]})}function cs(){let e=Nn(),{state:t}=Yn(),{selectedProjectId:n,selectedThreadId:r,projects:i}=t,a=i.find(e=>e.projectId===n),[o,c]=(0,Z.useState)(null),[l,u]=(0,Z.useState)(``),[d,p]=(0,Z.useState)(!1),[m,h]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{o!==`instructions`||!r||(p(!0),f(r,`AGENTS.md`).then(e=>u(e.content)).catch(()=>u(``)).finally(()=>p(!1)))},[o,r]);let g=async()=>{if(r){h(!0);try{await mt(r,`AGENTS.md`,l),X({title:`Instructions saved`}),c(null)}catch(e){X({title:`Error`,description:e instanceof Error?e.message:`Failed to save instructions`,variant:`destructive`})}finally{h(!1)}}};return n?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ar,{children:(0,$.jsxs)(ao,{children:[(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(oo,{asChild:!0,children:(0,$.jsx)(U,{variant:`action`,size:`icon-md`,children:(0,$.jsx)(Ot,{})})})}),(0,$.jsx)(q,{children:`AI`})]}),(0,$.jsxs)(uo,{align:`end`,children:[(0,$.jsx)(fo,{onSelect:()=>c(`mcp`),children:`Add MCP Server`}),(0,$.jsx)(fo,{onSelect:()=>c(`skill`),children:`Add Skill`}),(0,$.jsx)(fo,{onSelect:()=>c(`rule`),children:`Add Rule`}),(0,$.jsx)(fo,{onSelect:()=>c(`slash-command`),children:`Add Slash Command`}),(0,$.jsx)(fo,{onSelect:()=>c(`subagent`),children:`Add Subagent`}),(0,$.jsx)(go,{}),(0,$.jsx)(fo,{onSelect:()=>c(`instructions`),disabled:!r,children:`Instructions`}),(0,$.jsx)(fo,{onSelect:()=>void e(`/settings?tab=providers`),children:`Model Providers`}),(0,$.jsx)(go,{}),(0,$.jsx)(fo,{onSelect:()=>c(`marketplace`),children:`Marketplace`})]})]})}),(0,$.jsx)(be,{open:o===`mcp`,onOpenChange:e=>!e&&c(null),children:(0,$.jsx)(ln,{className:`max-w-2xl max-h-[90vh] overflow-y-auto p-0`,children:(0,$.jsx)(`div`,{className:`w-full`,children:(0,$.jsx)(is,{projectPath:a?.projectPath,onBack:()=>c(null)})})})}),(0,$.jsx)(be,{open:o===`marketplace`,onOpenChange:e=>!e&&c(null),children:(0,$.jsx)(ln,{className:`max-w-3xl h-[80vh] overflow-y-auto p-0`,children:(0,$.jsx)(ss,{projectPath:a?.projectPath,threadId:r,onClose:()=>c(null)})})}),(0,$.jsx)(be,{open:o===`skill`,onOpenChange:e=>!e&&c(null),children:(0,$.jsx)(ln,{className:`max-w-2xl max-h-[90vh] overflow-y-auto p-0`,children:(0,$.jsx)(Yo,{threadId:r,onSkillCreated:()=>c(null)})})}),(0,$.jsx)(be,{open:o===`rule`,onOpenChange:e=>!e&&c(null),children:(0,$.jsx)(ln,{className:`max-w-2xl max-h-[90vh] overflow-y-auto p-0`,children:(0,$.jsx)(Zo,{threadId:r,onRuleCreated:()=>c(null)})})}),(0,$.jsx)(be,{open:o===`slash-command`,onOpenChange:e=>!e&&c(null),children:(0,$.jsx)(ln,{className:`max-w-2xl max-h-[90vh] overflow-y-auto p-0`,children:(0,$.jsx)($o,{projectId:n,threadId:r,onCommandCreated:()=>c(null)})})}),(0,$.jsx)(be,{open:o===`subagent`,onOpenChange:e=>!e&&c(null),children:(0,$.jsx)(ln,{className:`max-w-2xl max-h-[90vh] overflow-y-auto p-0`,children:(0,$.jsx)(Qo,{threadId:r,onAgentCreated:()=>c(null)})})}),(0,$.jsx)(be,{open:o===`instructions`,onOpenChange:e=>!e&&c(null),children:(0,$.jsxs)(ln,{className:`max-w-2xl`,children:[(0,$.jsxs)(w,{children:[(0,$.jsx)(Ee,{children:`Instructions`}),(0,$.jsx)(s,{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)(ot,{className:`h-5 w-5 animate-spin text-muted-foreground`})}):(0,$.jsx)(ir,{value:l,onChange:e=>u(e.target.value),className:`min-h-[300px] font-mono text-sm resize-none`,placeholder:`Add instructions for your agent in AGENTS.md...`,disabled:m}),(0,$.jsxs)(ke,{children:[(0,$.jsx)(U,{variant:`outline`,onClick:()=>c(null),children:`Cancel`}),(0,$.jsx)(U,{onClick:()=>void g(),disabled:d||m,children:m?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ot,{className:`mr-2 h-4 w-4 animate-spin`}),`Saving...`]}):`Save`})]})]})})]}):null}function ls(){let e=(0,Q.c)(44),{state:t,dispatch:n}=Yn(),{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=G(u),e[5]=u,e[6]=d);let f;e[7]===n?f=e[8]:(f=()=>n({type:K.ToggleSidebar}),e[7]=n,e[8]=f);let p;e[9]===o?p=e[10]:(p=o?(0,$.jsx)(pt,{className:`h-4 w-4`}):(0,$.jsx)(Ut,{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)(U,{variant:`ghost`,size:`icon`,className:`h-8 w-8 text-muted-foreground shrink-0 electrobun-webkit-app-region-no-drag`,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:zt(a,i)}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:P(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=G(`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)(Go,{className:`electrobun-webkit-app-region-no-drag`,children:[(0,$.jsx)(Nr,{projectId:i,runCommand:c?.runCommand}),r&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ko,{threadId:r}),(0,$.jsx)(Wo,{}),(0,$.jsx)(cs,{})]})]}),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)(Go,{className:`electrobun-webkit-app-region-no-drag`,children:(0,$.jsx)(Vo,{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)(Go,{className:`electrobun-webkit-app-region-no-drag`,children:(0,$.jsx)(bo,{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)(Rr,{className:d,children:[_,C]}),e[40]=C,e[41]=d,e[42]=_,e[43]=w):w=e[43],w}function us(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)(vr,{children:`Delete Project`}),t[0]=o):o=t[0];let s;t[1]===r?s=t[2]:(s=(0,$.jsxs)(Cr,{children:[o,(0,$.jsxs)(_r,{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)(Sr,{children:`Cancel`}),t[3]=c):c=t[3];let l;t[4]===a?l=t[5]:(l=(0,$.jsxs)(xr,{children:[c,(0,$.jsx)(br,{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)(yr,{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)(wr,{open:n,onOpenChange:i,children:u}),t[9]=i,t[10]=n,t[11]=u,t[12]=d):d=t[12],d}function ds(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)(vr,{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)(Cr,{children:[o,(0,$.jsxs)(_r,{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(fs),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)(Sr,{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)(br,{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)(xr,{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)(yr,{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)(wr,{open:n,onOpenChange:a,children:h}),t[24]=n,t[25]=a,t[26]=h,t[27]=g):g=t[27],g}function fs(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 ps(){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(`${Te()}/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=ms;if(t)return null;let o;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=Te(),e[2]=o):o=e[2];let s=o,c,l;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsxs)(Cr,{children:[(0,$.jsx)(vr,{children:`Service unavailable`}),(0,$.jsx)(_r,{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)(wr,{open:!0,children:(0,$.jsxs)(yr,{children:[c,l,(0,$.jsx)(xr,{children:(0,$.jsx)(U,{onClick:a,children:`Retry`})})]})}),e[5]=u):u=e[5],u}function ms(){window.location.assign(window.location.href)}var hs=Gn,gs=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=G(`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)(Wn,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});gs.displayName=Wn.displayName;var _s=k(`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`}}),vs=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=G(_s({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)(En,{ref:t,className:o,...i}),n[7]=i,n[8]=t,n[9]=o,n[10]=s):s=n[10],s});vs.displayName=En.displayName;var ys=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=G(`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)(Hn,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});ys.displayName=Hn.displayName;var bs=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=G(`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)(St,{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)(Kn,{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});bs.displayName=Kn.displayName;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=G(`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)(mn,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});xs.displayName=mn.displayName;var Ss=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=G(`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)(An,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});Ss.displayName=An.displayName;function Cs(){let e=(0,Q.c)(5),{toasts:t}=hr(),n;e[0]===t?n=e[1]:(n=t.map(ws),e[0]=t,e[1]=n);let r;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(gs,{}),e[2]=r):r=e[2];let i;return e[3]===n?i=e[4]:(i=(0,$.jsxs)(hs,{children:[n,r]}),e[3]=n,e[4]=i),i}function ws(e){let{id:t,title:n,description:r,action:i,...a}=e;return(0,$.jsxs)(vs,{...a,children:[(0,$.jsxs)(`div`,{className:`grid gap-1`,children:[n&&(0,$.jsx)(xs,{children:n}),r&&(0,$.jsx)(Ss,{children:r})]}),i,(0,$.jsx)(bs,{})]},t)}function Ts(){let e=(0,Q.c)(4),{resolvedTheme:t,theme:n}=Tr(),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 Es(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)(Ts,{}),t[3]=i):i=t[3];let a;return t[4]!==n||t[5]!==r?(a=(0,$.jsxs)(Er,{...r,children:[i,n]}),t[4]=n,t[5]=r,t[6]=a):a=t[6],a}function Ds(){let{state:e,dispatch:t}=Yn(),{toast:n}=hr(),i=tr(`project-creation`).dispatch,[a,o]=(0,Z.useState)(null),s=(0,Z.useCallback)(async()=>{try{t({type:K.SetProjectsLoading,projectsLoading:!0});let e=await on();t({type:K.SetProjects,projects:e.projects})}catch(e){console.error(`Failed to refresh projects:`,e)}finally{t({type:K.SetProjectsLoading,projectsLoading:!1})}},[t]),c=(0,Z.useCallback)(async(n,r)=>{try{await Ge(n,r)}catch(e){console.error(`Failed to select thread:`,e)}(e.selectedThreadId!==r||e.selectedProjectId!==n)&&t({type:K.SelectThread,threadId:r,projectId:n})},[t,e.selectedThreadId,e.selectedProjectId]),l=(0,Z.useCallback)(async e=>{t({type:K.SetCreatingProject,isCreating:!0});try{let n=await e.apiCall();if(!n){t({type:K.SetCreatingProject,isCreating:!1}),await s();return}let r=e.useTerminalDispatch?i:t;r({type:K.ClearTerminalOutput}),r({type:K.SetTerminalOpen,open:!0}),r({type:K.AppendTerminalLine,line:{type:`system`,content:e.initialMessage}});let a=n.getReader(),c=new TextDecoder,l=``,u=null,d=!1,f=null,p=null;for(;;){let{done:n,value:i}=await a.read();if(n)break;l+=c.decode(i,{stream:!0});let s=l.split(`
48
+ `);l=s.pop()??``;for(let n of s){let i=n.trim();if(i)try{let n=JSON.parse(i);if(n.type===`progress`)!d&&n.threadId&&n.projectId&&(d=!0,f=n.projectId,p=n.threadId,t({type:K.AddCreatingProject,projectId:n.projectId,threadId:n.threadId,projectName:e.optimisticProjectName,gitUrl:e.gitUrl??``}),t({type:K.AddProcessingThread,threadId:n.threadId})),t({type:K.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 i=e.includeThreadPath&&n.project.threads?.length>0?`${n.project.path}/${n.project.threads[0]}`:n.project.path;r({type:K.AppendTerminalLine,line:{type:`system`,content:`Project created successfully at: ${i}`}}),t({type:K.SetTerminalOpen,open:!1}),e.handleSetupScript&&n.suggestedSetupScript&&o({projectId:n.project.id,command:n.suggestedSetupScript,remainingScripts:n.project.pendingSetupScripts??[]})}}else n.type===`error`&&(d&&f&&(t({type:K.RemoveCreatingProject,projectId:f}),p&&t({type:K.RemoveProcessingThread,threadId:p})),t({type:K.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:K.SetCreatingProject,isCreating:!1}),d&&p&&t({type:K.RemoveProcessingThread,threadId:p}),Oe();let m=await on();if(t({type:K.SetProjects,projects:m.projects}),t({type:K.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:K.SelectThread,threadId:n,projectId:u,focusInput:!0})}}}catch(n){console.error(`Failed to ${e.logTag}:`,n),t({type:K.SetCreatingProject,isCreating:!1}),(e.useTerminalDispatch?i:t)({type:K.AppendTerminalLine,line:{type:`error`,content:`${e.catchErrorPrefix}: ${n instanceof Error?n.message:`Unknown error`}`}})}},[t,s,i]),u=(0,Z.useCallback)(async(e,t)=>{let n=e.split(`/`).pop()?.replace(`.git`,``)??`project`;await l({apiCall:()=>yt(e,t),initialMessage:`Cloning repository: ${e}...`,optimisticProjectName:n,gitUrl:e,useTerminalDispatch:!0,includeThreadPath:!0,handleSetupScript:!0,logTag:`create project`,catchErrorPrefix:`Failed to create project`})},[l]),d=(0,Z.useCallback)(async(e,t,n)=>{await l({apiCall:()=>r(e,t,n),initialMessage:`Creating app "${e}"...`,optimisticProjectName:e,useTerminalDispatch:!0,handleSetupScript:!1,logTag:`create web app`,catchErrorPrefix:`Failed to create web app`})},[l]),f=(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}`})(),o=await V(r,i);if(!o){await s();return}let c=o.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(`
49
+ `);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:K.AddCreatingThread,projectId:r,threadId:e.threadId,title:a}),t({type:K.AddProcessingThread,threadId:e.threadId}),t({type:K.ClearTerminalOutput,threadId:f});for(let e of m)t({type:K.AppendTerminalLine,threadId:f,line:e});m.length=0}let n={type:`output`,content:e.message};f?t({type:K.AppendTerminalLine,threadId:f,line:n}):m.push(n)}else if(e.type===`error`){d&&f&&(t({type:K.RemoveCreatingThread,projectId:r,threadId:f}),t({type:K.RemoveProcessingThread,threadId:f}));let i={type:`error`,content:`Error: ${e.message}`};f?t({type:K.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:K.RemoveProcessingThread,threadId:f}),Oe(),await s(),f&&p&&t({type:K.SelectThread,threadId:f,projectId:r,focusInput:!0})}catch(e){throw d&&f&&(t({type:K.RemoveCreatingThread,projectId:r,threadId:f}),t({type:K.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:K.AppendTerminalLine,line:{type:`error`,content:r}}),n({variant:`destructive`,title:`Thread Creation Failed`,description:r}),e}},[s,t,e.projects,n]),p=(0,Z.useCallback)(async(n,r)=>{t({type:K.AddDeletingThread,threadId:r});try{await sn(n,r),Oe(),await s(),e.selectedThreadId===r&&t({type:K.SelectThread,threadId:``,projectId:``})}catch(e){console.error(`Failed to delete thread:`,e)}finally{t({type:K.RemoveDeletingThread,threadId:r})}},[s,e.selectedThreadId,t]),m=(0,Z.useCallback)(async n=>{t({type:K.AddDeletingProject,projectId:n});let r=e.projects.find(e=>e.projectId===n)?.threads.map(e=>e.threadId)??[];for(let e of r)t({type:K.AddDeletingThread,threadId:e});try{await B(n),await s(),e.selectedProjectId===n&&t({type:K.SelectThread,threadId:``,projectId:``})}catch(e){console.error(`Failed to delete project:`,e)}finally{t({type:K.RemoveDeletingProject,projectId:n});for(let e of r)t({type:K.RemoveDeletingThread,threadId:e})}},[s,e.selectedProjectId,e.projects,t]),h=(0,Z.useCallback)(async e=>{let n=a;if(o(null),!n||!e)return;let{projectId:r,command:i,remainingScripts:c}=n,l=[i,...c||[]];try{t({type:K.SetCreatingProject,isCreating:!0}),t({type:K.SetTerminalOpen,open:!0}),t({type:K.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:K.AppendTerminalLine,line:{type:`system`,content:`Installing package ${e+1}/${l.length} in ${a}...`}}),t({type:K.AppendTerminalLine,line:{type:`output`,content:`📦 Installing dependencies in ${a}: ${n}`}});let o=await en(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(`
50
+ `);r=o.pop()??``;for(let e of o)if(e.trim())try{let n=JSON.parse(e);typeof n==`string`?t({type:K.AppendTerminalLine,line:{type:`output`,content:n}}):n.type===`error`&&t({type:K.AppendTerminalLine,line:{type:`error`,content:n.message}})}catch{t({type:K.AppendTerminalLine,line:{type:`output`,content:e}})}}if(r.trim())try{let e=JSON.parse(r);typeof e==`string`?t({type:K.AppendTerminalLine,line:{type:`output`,content:e}}):e.type===`error`&&t({type:K.AppendTerminalLine,line:{type:`error`,content:e.message}})}catch{t({type:K.AppendTerminalLine,line:{type:`output`,content:r}})}}e<l.length-1&&(t({type:K.AppendTerminalLine,line:{type:`system`,content:``}}),t({type:K.AppendTerminalLine,line:{type:`system`,content:`---`}}),t({type:K.AppendTerminalLine,line:{type:`system`,content:``}}))}t({type:K.AppendTerminalLine,line:{type:`system`,content:`All dependencies installed successfully!`}}),t({type:K.SetCreatingProject,isCreating:!1}),await s()}catch(e){t({type:K.SetCreatingProject,isCreating:!1}),console.error(`Failed to run setup script:`,e),t({type:K.AppendTerminalLine,line:{type:`error`,content:`Failed to run setup script: ${e instanceof Error?e.message:`Unknown error`}`}})}},[a,t,s]);(0,Z.useEffect)(()=>{let n=!0;async function r(){try{t({type:K.SetProjectsLoading,projectsLoading:!0});let r=await on();if(!n)return;if(t({type:K.SetProjects,projects:r.projects}),!e.selectedThreadId)for(let e of r.projects){let n=e.threads.find(e=>e.isSelected);if(n){t({type:K.SelectThread,threadId:n.threadId,projectId:e.projectId});break}}}catch(e){console.error(`Failed to load projects:`,e)}finally{n&&t({type:K.SetProjectsLoading,projectsLoading:!1})}}return r(),()=>{n=!1}},[t,e.selectedThreadId,e.configUpdatedAt]);let g=(0,Z.useCallback)(async()=>{await l({apiCall:ee,initialMessage:`Opening folder...`,optimisticProjectName:`Opening folder...`,useTerminalDispatch:!0,handleSetupScript:!0,logTag:`open folder`,catchErrorPrefix:`Failed to open folder`})},[l]);return{projects:e.projects,selectedProjectId:e.selectedProjectId,selectedThreadId:e.selectedThreadId,refreshProjects:s,handleSelectThread:c,handleCreateProject:u,handleCreateWebApp:d,handleOpenFolder:g,handleCreateThread:f,handleDeleteThread:p,confirmDeleteProject:m,pendingSetupScriptConfirmation:a,resolveSetupScriptConfirmation:h}}function Os(){let e=(0,Q.c)(2),[t,n]=(0,Z.useState)(ks),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 ks(){return document.hasFocus()}var As=null;function js(){As??=new Audio(`/pop.wav`),As.currentTime=0,As.play().catch(e=>{console.debug(`Could not play completion sound:`,e)})}function Ms(){let{state:e,dispatch:t}=Yn(),n=Os(),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 tn(),n=a.current.filter(t=>!e.includes(t));for(let e of n)e!==o.current.selectedThreadId&&t({type:K.MarkThreadCompleted,threadId:e});return n.length>0&&!s.current&&js(),a.current=e,t({type:K.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:K.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 Ns=768;function Ps(){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: ${Ns-1}px)`),t=()=>{n(window.innerWidth<Ns)};return e.addEventListener(`change`,t),n(window.innerWidth<Ns),()=>e.removeEventListener(`change`,t)},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),Z.useEffect(r,i),!!t}var Fs=(0,Z.lazy)(()=>Un(()=>import(`./terminal-panel-4EVJwsCQ.js`).then(e=>({default:e.TerminalPanel})),__vite__mapDeps([21,1,2,14,15]))),Is=(0,Z.lazy)(()=>Un(()=>import(`./todos-view-D3JYa8fa.js`).then(e=>({default:e.TodosView})),[])),Ls=(0,Z.lazy)(()=>Un(()=>import(`./diff-view-v-bVp3Zf.js`),__vite__mapDeps([10,1,5,6,2,7,11,12,13,14,15,16,17,18,19,8,20]))),Rs=(0,Z.lazy)(()=>Un(()=>import(`./explorer-tab-view-CsPSJADk.js`),__vite__mapDeps([22,1,5,6,2,7,18,14,15]))),zs=(0,Z.lazy)(()=>Un(()=>import(`./browser-tab-CgLMsYM8.js`).then(e=>({default:e.BrowserTab})),__vite__mapDeps([23,1,2,24,6,3,14,15]))),Bs=(0,Z.lazy)(()=>Un(()=>import(`./dialogs-config-3Hr2GRdt.js`).then(e=>e.t),__vite__mapDeps([2,1]))),Vs=(0,Z.lazy)(()=>Un(()=>import(`./onboarding-dialog-lFFrB1GZ.js`),__vite__mapDeps([25,12,1,6,2]))),Hs=(0,Z.lazy)(()=>Un(()=>import(`./conversation-history-view-IVxKEbP_.js`),__vite__mapDeps([26,6,1,2]))),Us=(0,Z.lazy)(()=>Un(()=>import(`./settings-view-BWQrM94z.js`),__vite__mapDeps([27,1,5,6,2,7,28,18])));function Ws(){let{state:e,dispatch:t}=Yn();(0,Z.useEffect)(()=>{window.__electrobunWebviewId&&new Xr({})},[]);let n=Nn(),r=Pn(),i=Ps(),{projects:a,handleSelectThread:o,handleCreateProject:s,handleCreateWebApp:c,handleOpenFolder:l,handleCreateThread:u,handleDeleteThread:d,confirmDeleteProject:f,refreshProjects:p,pendingSetupScriptConfirmation:m,resolveSetupScriptConfirmation:h}=Ds(),{processingThreadIds:g,completedThreadIds:_,clearCompleted:v}=Ms(),[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}=tr(e.selectedThreadId),z=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{L.open&&e.selectedThreadId===z.current&&b(`terminal`),z.current=e.selectedThreadId},[L.open,e.selectedThreadId]);let[ee,B]=(0,Z.useState)(!1),[te,ne]=(0,Z.useState)(!1),[V,re]=(0,Z.useState)(!1),[H,ie]=(0,Z.useState)(null),[ae,oe]=(0,Z.useState)(!1),[se,ce]=(0,Z.useState)(!1),le=(0,Z.useRef)(null),ue=r.pathname.startsWith(`/settings`),de=r.pathname===`/review`,fe=r.pathname===`/todos`;(0,Z.useEffect)(()=>{r.pathname===`/`&&y===`tasks`&&b(`chat`)},[r.pathname]);let pe=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{let n=ue||de||fe;if(n&&pe.current===null)pe.current=e.sidebarOpen,e.sidebarOpen&&t({type:K.ToggleSidebar});else if(!n&&pe.current!==null){let n=pe.current;pe.current=null,n&&!e.sidebarOpen&&t({type:K.ToggleSidebar})}},[ue,de,fe]),(0,Z.useEffect)(()=>{(async()=>{try{(await W()).updateAvailable&&oe(!0)}catch{}})()},[]);let me=(0,Z.useCallback)(async()=>{ce(!0);try{await an()}catch{ce(!1)}},[]);(0,Z.useEffect)(()=>{V||(async()=>{try{(await Qe()).onboardingCompleted||ne(!0)}catch(e){console.error(`Failed to check onboarding status:`,e)}finally{re(!0)}})()},[V]),(0,Z.useEffect)(()=>{te||t({type:K.ConfigUpdated})},[te,t]);let U=(0,Z.useCallback)(e=>{let t=a.find(t=>t.projectId===e);t&&ie({id:t.projectId,name:R(t)})},[a]),he=(0,Z.useCallback)(e=>{u(e,void 0)},[u]),ge=(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:K.ToggleSidebar})},[o,i,e.sidebarOpen,e.selectedThreadId,t,v,r.pathname,n]);(0,Z.useEffect)(()=>{e.sidebarOpen?le.current?.expand():le.current?.collapse()},[e.sidebarOpen]);let _e={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)(kr.Provider,{value:_e,children:(0,$.jsxs)(ar,{delayDuration:200,children:[(0,$.jsxs)(Br,{direction:`horizontal`,className:`h-screen bg-background`,children:[(0,$.jsx)(zr,{ref:le,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)(ii,{projects:a,selectedThreadId:e.selectedThreadId,selectedProjectId:e.selectedProjectId,processingThreadIds:g,completedThreadIds:_,deletingThreadIds:e.deletingThreadIds,deletingProjectIds:e.deletingProjectIds,onSelectThread:ge,onCreateProject:()=>B(!0),onCreateThread:he,onDeleteThread:d,onDeleteProject:U,onNavigateToSettings:()=>void n(`/settings/providers`),onDeselect:()=>t({type:K.ClearSelection}),collapsed:!e.sidebarOpen,updateAvailable:ae,updatingApp:se,onUpdateApp:me,onRefreshProjects:p})})}),!i&&(0,$.jsx)(Vr,{withHandle:!0,className:e.sidebarOpen?`ml-[-40px]`:``}),(0,$.jsx)(zr,{minSize:40,className:`overflow-hidden ${i&&e.sidebarOpen?`hidden`:``}`,children:(0,$.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden`,children:[!de&&!ue&&!fe&&(0,$.jsx)(ls,{}),!de&&!ue&&!fe&&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${!de&&!ue&&!fe&&y!==`chat`?` hidden`:``}`,children:(0,$.jsxs)(Ln,{children:[(0,$.jsx)(zn,{path:`/settings/:tab?`,element:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Us,{})})}),(0,$.jsx)(zn,{path:`/settings/project/:projectId`,element:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Us,{})})}),(0,$.jsx)(zn,{path:`/settings/add-skill`,element:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Us,{})})}),(0,$.jsx)(zn,{path:`/settings/add-command`,element:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Us,{})})}),(0,$.jsx)(zn,{path:`/settings/mcp-server-edit`,element:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Us,{})})}),(0,$.jsx)(zn,{path:`*`,element:(0,$.jsx)(ro,{onCreateThread:he})})]})}),(0,$.jsx)(`div`,{className:`flex-1 overflow-hidden${y===`terminal`&&!de&&!ue&&!fe?``:` hidden`}`,children:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Fs,{})})}),(0,$.jsx)(`div`,{className:`flex-1 overflow-hidden${y===`browser`&&!de&&!ue&&!fe?``:` hidden`}`,children:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(zs,{})})}),!de&&!ue&&!fe&&y!==`chat`&&y!==`terminal`&&y!==`browser`&&(y===`explorer`?(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Rs,{})}):y===`tasks`&&e.selectedProjectId?(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Is,{projectId:e.selectedProjectId})}):y===`history`?(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Hs,{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)(Ls,{threadId:e.selectedThreadId,onExit:()=>b(`chat`)})}):(0,$.jsx)(`div`,{className:`flex-1 overflow-hidden`}))]})}),(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Bs,{open:ee,onOpenChange:B,onSubmitClone:s,onSubmitWebApp:c,onOpenFolder:l})}),(0,$.jsx)(us,{open:H!==null,projectName:H?.name,onOpenChange:e=>!e&&ie(null),onConfirm:()=>{H&&(f(H.id),ie(null))}}),(0,$.jsx)(ds,{open:m!==null,setupScripts:m?[m.command,...m.remainingScripts||[]]:[],onConfirm:h}),(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Vs,{open:te,onOpenChange:ne,onComplete:()=>{re(!0),p()}})}),(0,$.jsx)(ps,{})]}),(0,$.jsx)(Cs,{})]})})}function Gs(){let e=(0,Q.c)(5),[t,n]=(0,Z.useReducer)(rr,$n),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)(Ws,{}),e[2]=i):i=e[2];let a;return e[3]===r?a=e[4]:(a=(0,$.jsx)(Es,{attribute:`class`,defaultTheme:`system`,enableSystem:!0,storageKey:`tarsk-theme`,children:(0,$.jsx)(er.Provider,{value:r,children:i})}),e[3]=r,e[4]=a),a}var Ks=!1;window.addEventListener(`resize`,()=>{Ks||=(window.__electrobunWebviewId&&(document.body.style.height=`calc(100%)`),!0)}),(0,Hr.createRoot)(document.getElementById(`root`)).render((0,$.jsx)(Z.StrictMode,{children:(0,$.jsx)(Mn,{children:(0,$.jsx)(Gs,{})})}));export{eo as t};