tarsk 0.4.21 → 0.4.22

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 (47) hide show
  1. package/dist/index.js +52 -152
  2. package/dist/public/assets/{account-view-D1kGyryt.js → account-view-pOQZWJfl.js} +1 -1
  3. package/dist/public/assets/{alert-dialog-Bk7neo_n.js → alert-dialog-BeLER45U.js} +1 -1
  4. package/dist/public/assets/{api-DL5XaoTS.js → api-Bagaj1rQ.js} +1 -1
  5. package/dist/public/assets/{browser-tab-BUOT-D_w.js → browser-tab-DmootUHa.js} +1 -1
  6. package/dist/public/assets/chat-input-container-CfXgimBQ.js +1 -0
  7. package/dist/public/assets/context-menu-BlG_bTqN.js +1 -0
  8. package/dist/public/assets/conversation-history-view-DjO711iz.js +1 -0
  9. package/dist/public/assets/{dialogs-config-DmDjliuA.js → dialogs-config-Dwpv4SNp.js} +1 -1
  10. package/dist/public/assets/{diff-view-DXIv51Tn.js → diff-view-B8Grak1p.js} +2 -2
  11. package/dist/public/assets/{explorer-tab-view-tyn_6pBh.js → explorer-tab-view-lFzzjVe8.js} +2 -2
  12. package/dist/public/assets/explorer-tree-CyWyxQvY.js +1 -0
  13. package/dist/public/assets/{explorer-view-Bw3-gTSX.js → explorer-view-DjN4dtgh.js} +1 -1
  14. package/dist/public/assets/{history-view-BOjZoBCb.js → history-view-BvAOaO8q.js} +1 -1
  15. package/dist/public/assets/index-C7dA1l3u.js +50 -0
  16. package/dist/public/assets/onboarding-dialog-DSmKEXk4.js +1 -0
  17. package/dist/public/assets/onboarding-vGz3IczM.js +1 -0
  18. package/dist/public/assets/{page-toolbar-CvreDTwj.js → page-toolbar-CBE5_3E3.js} +1 -1
  19. package/dist/public/assets/{project-settings-view-BJYR_l3u.js → project-settings-view-B13GlkU6.js} +1 -1
  20. package/dist/public/assets/{provider-details-view-B1eTEo0M.js → provider-details-view-BQQKYvR8.js} +1 -1
  21. package/dist/public/assets/providers-sidebar-C2RknYQn.js +1 -0
  22. package/dist/public/assets/react-vendor-CYvpNUsM.js +17 -0
  23. package/dist/public/assets/{resizable-DJ5w1ZWX.js → resizable-C82J5y6K.js} +1 -1
  24. package/dist/public/assets/{run-stop-button-iZHomql0.js → run-stop-button-1ECLRujs.js} +2 -2
  25. package/dist/public/assets/{settings-view-C38jeeqJ.js → settings-view-CxiVTevy.js} +2 -2
  26. package/dist/public/assets/{side-panel-container-BqWSTCOr.js → side-panel-container-B9Dn9qD2.js} +2 -2
  27. package/dist/public/assets/{standard-list-item-CpBjveM0.js → standard-list-item-BJWg4I9s.js} +1 -1
  28. package/dist/public/assets/{store-CAPnOXso.js → store-Cn1lT5YJ.js} +1 -1
  29. package/dist/public/assets/{tab-context-Bmd79Rk0.js → tab-context-COCYkRNN.js} +1 -1
  30. package/dist/public/assets/{tabs-DEmnnGvq.js → tabs-M7nUZf6O.js} +1 -1
  31. package/dist/public/assets/{terminal-panel-r8cb3-tk.js → terminal-panel-Cea0pLdX.js} +2 -2
  32. package/dist/public/assets/{textarea-BjfyGfGR.js → textarea-C5IMo2ya.js} +1 -1
  33. package/dist/public/assets/todos-view-DDVfCfgF.js +1 -0
  34. package/dist/public/assets/{use-toast-C9B1H3P9.js → use-toast-rlEtMnzM.js} +1 -1
  35. package/dist/public/assets/{utils-BG_JNnOl.js → utils-C3gmypZX.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/index-DAw9BEzt.js +0 -50
  43. package/dist/public/assets/onboarding-BgEjTEKs.js +0 -1
  44. package/dist/public/assets/onboarding-dialog-EiVl-ynw.js +0 -1
  45. package/dist/public/assets/providers-sidebar-Df50eL_5.js +0 -1
  46. package/dist/public/assets/react-vendor-CaS5zjF7.js +0 -17
  47. 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-pOQZWJfl.js","assets/rolldown-runtime-B1FJdls4.js","assets/dialogs-config-Dwpv4SNp.js","assets/use-toast-rlEtMnzM.js","assets/project-settings-view-B13GlkU6.js","assets/react-vendor-CYvpNUsM.js","assets/history-view-BvAOaO8q.js","assets/monaco-c-HyCuEi.js","assets/textarea-C5IMo2ya.js","assets/dist-CIGnaqp2.js","assets/diff-view-B8Grak1p.js","assets/chat-input-container-CfXgimBQ.js","assets/onboarding-vGz3IczM.js","assets/alert-dialog-BeLER45U.js","assets/store-Cn1lT5YJ.js","assets/tab-context-COCYkRNN.js","assets/page-toolbar-CBE5_3E3.js","assets/context-menu-BlG_bTqN.js","assets/resizable-C82J5y6K.js","assets/standard-list-item-BJWg4I9s.js","assets/utils-C3gmypZX.js","assets/terminal-panel-Cea0pLdX.js","assets/explorer-tab-view-lFzzjVe8.js","assets/browser-tab-DmootUHa.js","assets/run-stop-button-1ECLRujs.js","assets/onboarding-dialog-DSmKEXk4.js","assets/conversation-history-view-DjO711iz.js","assets/settings-view-CxiVTevy.js","assets/side-panel-container-B9Dn9qD2.js"])))=>i.map(i=>d[i]);
2
+ import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{$i as t,$r as n,$t as r,A as i,Ai as a,Ar as o,At as s,B as c,Bn as l,Cn as u,Cr as d,Di as f,Dn as p,Dr as m,Dt as h,E as g,En as _,Et as v,F as y,Fi as b,Fr as x,Ft as S,Gi as C,Gr as w,Gt as T,Hn as E,Hr as D,Ht as O,I as k,In as A,Ir as j,It as M,J as N,Ji as P,Jn as F,Jr as I,Jt as L,Ki as R,Kn as z,Kr as ee,Kt as te,L as B,Li as ne,Lr as re,Lt as ie,M as ae,Mn as V,Mr as oe,Mt as se,N as ce,Nn as H,Nr as le,Nt as ue,O as de,Oi as fe,Or as pe,Ot as me,P as he,Pn as U,Pr as ge,Pt as _e,Qr as ve,R as ye,Ri as be,Rn as W,Rt as xe,S as Se,Sn as Ce,Ti as we,Tn as Te,Ui as Ee,Un as De,Ur as Oe,Ut as ke,Vi as Ae,Vn as je,Vt as Me,Wi as Ne,Wn as G,Wt as Pe,X as Fe,Xi as Ie,Yi as Le,Yr as Re,Zi as ze,Zr as Be,Zt as Ve,_ as He,_n as Ue,_t as We,ai as Ge,an as Ke,bn as qe,bt as Je,ca as Ye,ci as Xe,ct as Ze,dn as Qe,dt as $e,ea as et,ei as tt,en as nt,et as rt,f as it,fi as at,ft as ot,g as st,gi as ct,gt as lt,h as ut,hi as dt,hn as ft,ht as pt,ia as mt,ii as ht,in as gt,it as _t,j as vt,ji as yt,jr as bt,k as xt,kn as St,kr as Ct,la as wt,lt as Tt,mi as Et,mt as Dt,na as Ot,ni as kt,nn as At,o as jt,oa as Mt,oi as Nt,on as Pt,ot as Ft,p as It,pi as Lt,pt as Rt,qi as zt,qn as Bt,qr as Vt,qt as Ht,ra as Ut,ri as Wt,st as Gt,ta as Kt,ti as qt,tn as Jt,ua as Yt,un as Xt,ut as Zt,v as Qt,vn as $t,vt as en,wi as tn,wn as nn,wt as rn,x as an,xi as on,xt as sn,yi as cn,z as ln,zn as un,zr as dn,zt as fn}from"./dialogs-config-Dwpv4SNp.js";import{$ as pn,A as mn,C as hn,G as gn,H as _n,I as vn,K as yn,L as bn,M as xn,N as Sn,O as Cn,P as wn,Q as Tn,R as En,S as Dn,U as On,V as kn,W as An,b as jn,et as Mn,ft as Nn,gt as Pn,ht as Fn,j as In,k as Ln,mt as Rn,nt as zn,pt as Bn,q as Vn,tt as Hn,v as Un,vt as Wn,w as Gn,x as Kn,y as qn,yt as Jn,z as Yn}from"./react-vendor-CYvpNUsM.js";import{a as Xn,c as Zn,d as Qn,f as $n,i as er,n as tr,o as nr,p as rr,r as ir,t as K}from"./store-Cn1lT5YJ.js";import{t as ar}from"./textarea-C5IMo2ya.js";import{c as q,l as or,s as J,u as Y}from"./history-view-BvAOaO8q.js";import{a as sr,i as cr,n as lr,o as ur,r as dr,t as fr}from"./chat-input-container-CfXgimBQ.js";import{n as pr,t as X}from"./use-toast-rlEtMnzM.js";import{t as mr}from"./standard-list-item-BJWg4I9s.js";import{a as hr,c as gr,i as _r,n as vr,o as yr,r as br,s as xr,t as Sr}from"./alert-dialog-BeLER45U.js";import{n as Cr,t as wr}from"./utils-C3gmypZX.js";import{t as Tr}from"./side-panel-container-B9Dn9qD2.js";import{n as Er,t as Dr}from"./tab-context-COCYkRNN.js";import{n as Or,r as kr}from"./onboarding-vGz3IczM.js";import{n as Ar,t as jr}from"./run-stop-button-1ECLRujs.js";import{i as Mr,n as Nr,r as Pr,t as Fr}from"./tabs-M7nUZf6O.js";import{t as Ir}from"./page-toolbar-CBE5_3E3.js";import{n as Lr,r as Rr,t as zr}from"./resizable-C82J5y6K.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(Yt(),1),Br=Jn(),Q=Ye(),Vr=1e10,Hr=1e3;function Ur(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 Wr(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=Hr}=e;e.transport&&i(e.transport),e.requestHandler&&a(e.requestHandler),e._debugHooks&&(t=e._debugHooks);let s=0;function c(){return s<=Vr?++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 Ur([`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 Ur([`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 Ur([`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 Ur([`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 Gr(e,t){let n=Wr({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 Kr=window.__electrobunWebviewId,qr=window.__electrobunRpcSocketPort,Jr=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:${qr}/socket?webviewId=${Kr}`);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 Gr(`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))}})}})}},$=d();function Yr(e){let t=(0,Q.c)(47),{open:n,onOpenChange:r,feedbackName:i,onFeedbackNameChange:a,feedbackEmail:o,onFeedbackEmailChange:s,feedbackText:c,onFeedbackTextChange:u,loadingFeedbackUser:d,submittingFeedback:f,onSubmit:p}=e,m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsxs)(E,{children:[(0,$.jsx)(De,{children:`Send Feedback`}),(0,$.jsx)(l,{children:`Share feedback about Tarsk.`})]}),t[0]=m):m=t[0];let h;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(V,{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)(H,{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)(V,{htmlFor:`feedback-email`,children:`Email`}),t[8]=y):y=t[8];let b;t[9]===s?b=t[10]:(b=e=>s(e.target.value),t[9]=s,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)(H,{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)(V,{htmlFor:`feedback-text`,children:`Feedback`}),t[15]=C):C=t[15];let w;t[16]===u?w=t[17]:(w=e=>u(e.target.value),t[16]=u,t[17]=w);let T;t[18]!==c||t[19]!==f||t[20]!==w?(T=(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[C,(0,$.jsx)(ar,{id:`feedback-text`,value:c,onChange:w,placeholder:`Tell us what you think...`,className:`min-h-32`,disabled:f})]}),t[18]=c,t[19]=f,t[20]=w,t[21]=T):T=t[21];let D;t[22]!==T||t[23]!==v||t[24]!==S?(D=(0,$.jsxs)(`div`,{className:`grid gap-4 py-2`,children:[v,S,T]}),t[22]=T,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)(dt,{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)(je,{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)(un,{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)(W,{open:n,onOpenChange:r,children:N}),t[43]=r,t[44]=n,t[45]=N,t[46]=P):P=t[46],P}function Xr(){let[e,t]=(0,Z.useState)(!1),[n,r]=(0,Z.useState)(``),[i,a]=(0,Z.useState)(``),[o,s]=(0,Z.useState)(``),[c,l]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(!1);return(0,Z.useEffect)(()=>{if(!e)return;let t=!0;return l(!0),Gt().then(e=>{t&&(r(t=>t||e.name),a(t=>t||e.email))}).catch(()=>{t&&X({title:`Could not load git details`,description:`You can still submit feedback by entering your name and email manually.`,variant:`destructive`})}).finally(()=>{t&&l(!1)}),()=>{t=!1}},[e]),{showFeedback:e,feedbackName:n,setFeedbackName:r,feedbackEmail:i,setFeedbackEmail:a,feedbackText:o,setFeedbackText:s,loadingFeedbackUser:c,submittingFeedback:u,handleFeedbackDialogChange:e=>{t(e),e||s(``)},handleSubmitFeedback:async()=>{let e=o.trim();if(!e){X({title:`Feedback required`,description:`Please enter your feedback before submitting.`,variant:`destructive`});return}d(!0);try{await p(`api/feedback`,{name:n.trim(),email:i.trim(),feedback:e}),X({title:`Feedback sent`,description:`Thanks for sharing your feedback.`}),s(``),t(!1)}catch(e){X({title:`Failed to send feedback`,description:e instanceof Error?e.message:`Please try again.`,variant:`destructive`})}finally{d(!1)}}}}function Zr(e){let t=(0,Q.c)(8),{collapsed:n}=e,{theme:r,setTheme:i}=Cr();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)(dn,{className:`h-4 w-4 rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0`}),s=(0,$.jsx)(Nt,{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 Qr({threadId:e,currentConversationId:t,children:n}){let[r,i]=(0,Z.useState)(null),[a,o]=(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),[g,_]=(0,Z.useState)(!1);if((0,Z.useEffect)(()=>{if(!m||g||!e)return;async function n(){d(!0),p(null);try{let n=(await v(e)).currentConversationId??t,[r,a]=await Promise.allSettled([s(e).catch(e=>{throw console.error(`Thread usage summary failed:`,e),e}),n?_t(e,n).catch(e=>{throw console.error(`Conversation usage failed:`,e),e}):Promise.resolve(null)]);if(r.status===`fulfilled`)i(r.value);else throw console.error(`Failed to fetch thread usage summary:`,r.reason),r.reason;if(a?.status===`fulfilled`&&a.value){if(o(a.value),a.value.model?.model){let e=a.value.model.model,t=a.value.model.provider,n=t&&e?`${t}/${e}`:e;console.log(`Fetching model info for:`,n,`(provider:`,t,`model:`,e+`)`),Zt(n).then(l).catch(e=>{console.warn(`Failed to fetch model info:`,e)})}}else if(a?.status===`rejected`)throw console.error(`Failed to fetch conversation usage:`,a.reason),a.reason;_(!0)}catch(e){console.error(`[TokenUsageTooltip] Failed to load usage data:`,e),p(`Failed to load usage data`)}finally{d(!1)}}n()},[m,g,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&&g&&_(!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)(Kt,{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)(Kt,{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)(Kt,{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)(ge,{className:`h-3 w-3`}),(0,$.jsxs)(`span`,{children:[r.conversationCount,` chats`]})]})]}),a&&(0,$.jsxs)(`div`,{className:`border-t border-border pt-2 space-y-1`,children:[(0,$.jsx)(`div`,{className:`text-xs font-semibold text-foreground`,children:`Current Chat:`}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(pe,{className:`h-3 w-3`}),(0,$.jsxs)(`span`,{children:[((e,t)=>{let n=y(e);return t?`${n} (${Math.round(e/t*100)}%)`:n})(a.footprint?.totalTokens??a.usage.totalTokens,typeof c?.context_length==`number`?c.context_length:void 0),` `,`tokens`]})]}),a.model.model&&(0,$.jsxs)(`div`,{className:`text-muted-foreground`,children:[a.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 $r(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 v(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)(ge,{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)(Qr,{threadId:n,currentConversationId:r,children:s}),t[4]=r,t[5]=n,t[6]=c):c=t[6],c}var ei=(0,Z.lazy)(()=>Wn(()=>import(`./account-view-pOQZWJfl.js`),__vite__mapDeps([0,1,2,3]))),ti=(0,Z.lazy)(()=>Wn(()=>import(`./project-settings-view-B13GlkU6.js`),__vite__mapDeps([4,1,5,6,2,7,8,3])));function ni(e){let t=(0,Q.c)(101),{projects:n,selectedThreadId:r,selectedProjectId:i,processingThreadIds:a,completedThreadIds:o,deletingThreadIds:s,deletingProjectIds:c,onSelectThread:l,onCreateProject:u,onCreateThread:d,onDeleteThread:f,onDeleteProject:p,onNavigateToSettings:m,onDeselect:h,collapsed:g,updateAvailable:_,updatingApp:v,onUpdateApp:y,onRefreshProjects:b}=e,[x,S]=(0,Z.useState)(!1),[C,w]=(0,Z.useState)(null),{showFeedback:T,feedbackName:E,setFeedbackName:D,feedbackEmail:O,setFeedbackEmail:k,feedbackText:A,setFeedbackText:j,loadingFeedbackUser:M,submittingFeedback:N,handleFeedbackDialogChange:P,handleSubmitFeedback:F}=Xr(),I;t[0]===n?I=t[1]:(I=n.map(ri),t[0]=n,t[1]=I);let L=I,R;t[2]!==g||t[3]!==u?(R=!g&&(0,$.jsxs)(U,{variant:`outline`,size:`sm`,className:`gap-2`,onClick:u,children:[(0,$.jsx)(ve,{className:`h-4 w-4 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:`New Project`})]}),t[2]=g,t[3]=u,t[4]=R):R=t[4];let ee;t[5]!==g||t[6]!==y||t[7]!==_||t[8]!==v?(ee=_&&(0,$.jsxs)(U,{variant:`ghost`,size:`sm`,className:`w-full justify-start gap-2 text-emerald-600 dark:text-emerald-400`,onClick:y,disabled:v,children:[v?(0,$.jsx)(dt,{className:`h-4 w-4 animate-spin`}):(0,$.jsx)(be,{className:`h-4 w-4`}),!g&&(0,$.jsx)(`span`,{className:`truncate`,children:v?`Updating...`:`Update to Latest`})]}),t[5]=g,t[6]=y,t[7]=_,t[8]=v,t[9]=ee):ee=t[9];let te;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,$.jsx)(Kt,{className:`h-4 w-4`}),t[10]=te):te=t[10];let B;t[11]===g?B=t[12]:(B=!g&&(0,$.jsx)(`span`,{className:`truncate`,children:`Providers`}),t[11]=g,t[12]=B);let ne;t[13]!==m||t[14]!==B?(ne=(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:m,children:[te,B]})}),t[13]=m,t[14]=B,t[15]=ne):ne=t[15];let re,ie;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(re=()=>S(!0),ie=(0,$.jsx)(bt,{className:`h-4 w-4`}),t[16]=re,t[17]=ie):(re=t[16],ie=t[17]);let ae;t[18]===g?ae=t[19]:(ae=!g&&(0,$.jsx)(`span`,{className:`truncate`,children:`Account`}),t[18]=g,t[19]=ae);let V;t[20]===ae?V=t[21]:(V=(0,$.jsxs)(U,{variant:`ghost`,size:`sm`,className:`flex-1 justify-start gap-2 text-sidebar-foreground`,onClick:re,children:[ie,ae]}),t[20]=ae,t[21]=V);let oe;t[22]===P?oe=t[23]:(oe=()=>P(!0),t[22]=P,t[23]=oe);let se,ce;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(se=(0,$.jsx)(at,{className:`h-4 w-4`}),ce=(0,$.jsx)(`span`,{className:`sr-only`,children:`Feedback`}),t[24]=se,t[25]=ce):(se=t[24],ce=t[25]);let H;t[26]===oe?H=t[27]:(H=(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]})}),t[26]=oe,t[27]=H);let le;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(le=(0,$.jsx)(q,{children:`Send feedback to the Tarsk team`}),t[28]=le):le=t[28];let ue;t[29]===H?ue=t[30]:(ue=(0,$.jsx)(or,{children:(0,$.jsxs)(J,{children:[H,le]})}),t[29]=H,t[30]=ue);let de=r??void 0,fe;t[31]===de?fe=t[32]:(fe=(0,$.jsx)($r,{threadId:de}),t[31]=de,t[32]=fe);let pe;t[33]===g?pe=t[34]:(pe=(0,$.jsx)(Zr,{collapsed:g}),t[33]=g,t[34]=pe);let me;t[35]!==V||t[36]!==ue||t[37]!==fe||t[38]!==pe?(me=(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[V,ue,fe,pe]}),t[35]=V,t[36]=ue,t[37]=fe,t[38]=pe,t[39]=me):me=t[39];let he;t[40]!==me||t[41]!==ee||t[42]!==ne?(he=(0,$.jsxs)(`div`,{className:`px-3 py-2 flex flex-col gap-1`,children:[ee,ne,me]}),t[40]=me,t[41]=ee,t[42]=ne,t[43]=he):he=t[43];let ge;t[44]===n.length?ge=t[45]:(ge=n.length===0&&(0,$.jsx)(`p`,{className:`px-3 py-6 text-center text-xs text-muted-foreground`,children:`No projects yet. Clone a repository to get started.`}),t[44]=n.length,t[45]=ge);let _e;t[46]!==o||t[47]!==c||t[48]!==s||t[49]!==d||t[50]!==p||t[51]!==f||t[52]!==l||t[53]!==a||t[54]!==n||t[55]!==i||t[56]!==r?(_e=(e,t)=>{let{isOpen:u,toggle:m}=t;return e.kind===`project`?(0,$.jsx)(ii,{project:e.project,isOpen:u,onToggle:m,isDeletingProject:c.includes(e.project.projectId),isSelected:i?e.project.projectId===i:!1,onCreateThread:d,onDeleteProject:p,onProjectSettings:w,hasSelectedThread:e.project.threads.some(e=>e.threadId===r)}):(0,$.jsx)(ai,{thread:e.thread,projectId:e.projectId,selectedThreadId:r,isProcessing:a.includes(e.thread.threadId),isDeleting:s.includes(e.thread.threadId),isCompleted:o.includes(e.thread.threadId),projectTitlePrefix:`${z(n.find(t=>t.projectId===e.projectId))} - `,onSelectThread:l,onDeleteThread:f})},t[46]=o,t[47]=c,t[48]=s,t[49]=d,t[50]=p,t[51]=f,t[52]=l,t[53]=a,t[54]=n,t[55]=i,t[56]=r,t[57]=_e):_e=t[57];let ye;t[58]!==L||t[59]!==_e?(ye=(0,$.jsx)(ur,{nodes:L,defaultOpen:!0,childContainerClassName:`ml-4 border-l border-sidebar-border pl-2`,renderNode:_e}),t[58]=L,t[59]=_e,t[60]=ye):ye=t[60];let xe;t[61]!==ge||t[62]!==ye?(xe=(0,$.jsx)(St,{className:`flex-1 w-full`,children:(0,$.jsxs)(`div`,{className:`px-2 py-2 w-full max-w-full overflow-hidden`,children:[ge,ye]})}),t[61]=ge,t[62]=ye,t[63]=xe):xe=t[63];let Se;t[64]!==g||t[65]!==h||t[66]!==R||t[67]!==he||t[68]!==xe?(Se=(0,$.jsx)(Tr,{collapsed:g,onLogoClick:h,headerAction:R,footer:he,children:xe}),t[64]=g,t[65]=h,t[66]=R,t[67]=he,t[68]=xe,t[69]=Se):Se=t[69];let Ce=C!==null,we;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(we=e=>!e&&w(null),t[70]=we):we=t[70];let Te;t[71]===b?Te=t[72]:(Te=()=>{b?.(),w(null)},t[71]=b,t[72]=Te);let Ee;t[73]!==C||t[74]!==Te?(Ee=(0,$.jsx)(un,{className:`max-w-2xl p-0 overflow-auto max-h-[90vh]`,children:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(ti,{projectId:C,onProjectUpdated:Te})})}),t[73]=C,t[74]=Te,t[75]=Ee):Ee=t[75];let De;t[76]!==Ce||t[77]!==Ee?(De=(0,$.jsx)(W,{open:Ce,onOpenChange:we,children:Ee}),t[76]=Ce,t[77]=Ee,t[78]=De):De=t[78];let Oe;t[79]===F?Oe=t[80]:(Oe=()=>void F(),t[79]=F,t[80]=Oe);let ke;t[81]!==O||t[82]!==E||t[83]!==A||t[84]!==P||t[85]!==M||t[86]!==k||t[87]!==D||t[88]!==j||t[89]!==T||t[90]!==N||t[91]!==Oe?(ke=(0,$.jsx)(Yr,{open:T,onOpenChange:P,feedbackName:E,onFeedbackNameChange:D,feedbackEmail:O,onFeedbackEmailChange:k,feedbackText:A,onFeedbackTextChange:j,loadingFeedbackUser:M,submittingFeedback:N,onSubmit:Oe}),t[81]=O,t[82]=E,t[83]=A,t[84]=P,t[85]=M,t[86]=k,t[87]=D,t[88]=j,t[89]=T,t[90]=N,t[91]=Oe,t[92]=ke):ke=t[92];let Ae;t[93]===Symbol.for(`react.memo_cache_sentinel`)?(Ae=(0,$.jsx)(un,{className:`max-w-2xl p-0 overflow-auto max-h-[90vh]`,children:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(ei,{})})}),t[93]=Ae):Ae=t[93];let je;t[94]===x?je=t[95]:(je=(0,$.jsx)(W,{open:x,onOpenChange:S,children:Ae}),t[94]=x,t[95]=je);let Me;return t[96]!==Se||t[97]!==De||t[98]!==ke||t[99]!==je?(Me=(0,$.jsxs)($.Fragment,{children:[Se,De,ke,je]}),t[96]=Se,t[97]=De,t[98]=ke,t[99]=je,t[100]=Me):Me=t[100],Me}function ri(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 ii(e){let t=(0,Q.c)(26),{project:n,isOpen:r,onToggle:i,isDeletingProject:a,hasSelectedThread:o,isSelected:s,onCreateThread:c,onDeleteProject:l,onProjectSettings:u}=e,d;t[0]===n?d=t[1]:(d=z(n),t[0]=n,t[1]=d);let f=d,p=o||s,m=r&&`rotate-90`,h;t[2]===m?h=t[3]:(h=G(`h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform`,m),t[2]=m,t[3]=h);let g;t[4]===h?g=t[5]:(g=(0,$.jsx)(ze,{className:h}),t[4]=h,t[5]=g);let _;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(yt,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}),t[6]=_):_=t[6];let v=(o||s)&&`font-bold text-foreground`,y;t[7]===v?y=t[8]:(y=G(`min-w-0 truncate transition-all block`,v),t[7]=v,t[8]=y);let b;t[9]!==f||t[10]!==y?(b=(0,$.jsx)(`span`,{className:y,children:f}),t[9]=f,t[10]=y,t[11]=b):b=t[11];let S;t[12]!==g||t[13]!==b?(S=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1.5 w-0`,children:[g,_,b]}),t[12]=g,t[13]=b,t[14]=S):S=t[14];let C;t[15]!==a||t[16]!==c||t[17]!==l||t[18]!==u||t[19]!==n?(C=(0,$.jsx)(`div`,{className:`flex shrink-0 items-center ml-auto`,children:a?(0,$.jsx)(dt,{className:`h-3.5 w-3.5 shrink-0 animate-spin text-muted-foreground mr-1`}):(0,$.jsxs)(or,{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(),u(n.projectId)},children:[(0,$.jsx)(w,{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(),c(n.projectId)},children:[(0,$.jsx)(ve,{}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Add thread`})]})}),(0,$.jsx)(q,{side:`right`,children:`Add thread`})]}),n.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(),l(n.projectId)},children:[(0,$.jsx)(x,{}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Delete project`})]})}),(0,$.jsx)(q,{side:`right`,children:`Delete project`})]})]})}),t[15]=a,t[16]=c,t[17]=l,t[18]=u,t[19]=n,t[20]=C):C=t[20];let T;return t[21]!==i||t[22]!==S||t[23]!==C||t[24]!==p?(T=(0,$.jsxs)(mr,{selected:p,noBackground:!0,className:`mb-1 h-9`,onClick:i,children:[S,C]}),t[21]=i,t[22]=S,t[23]=C,t[24]=p,t[25]=T):T=t[25],T}function ai(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)(gr,{children:`Delete Thread`}),t[9]=_):_=t[9];let v;t[10]===g?v=t[11]:(v=(0,$.jsxs)(hr,{children:[`Are you sure you want to delete "`,g,`" and all its files? This action cannot be undone.`]}),t[10]=g,t[11]=v);let y;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(br,{children:`Cancel`}),t[12]=y):y=t[12];let b;t[13]!==u||t[14]!==r||t[15]!==n.threadId?(b=(0,$.jsxs)(`div`,{className:`flex gap-3 justify-end`,children:[y,(0,$.jsx)(vr,{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]=b):b=t[16];let S;t[17]!==v||t[18]!==b?(S=(0,$.jsxs)(_r,{children:[_,v,b]}),t[17]=v,t[18]=b,t[19]=S):S=t[19];let C;t[20]!==d||t[21]!==S?(C=(0,$.jsx)(Sr,{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)(dt,{className:`ml-auto h-3 w-3 shrink-0 animate-spin text-muted-foreground`}):s?(0,$.jsx)(et,{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)(x,{}),(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)(mr,{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 oi=e(wt(),1),si=.1,ci=10,li=1.25,ui=.001;function di(){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=fi,u;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>n(e=>l(e*li)),e[1]=u):u=e[1];let d=u,f;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=()=>n(e=>l(e/li)),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*ui;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 fi(e){return Math.min(Math.max(e,si),ci)}function pi(){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 mi(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 Wn(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 hi(e){let t=(0,Q.c)(69),{svgOutput:n,onClose:r}=e,{scale:i,offset:a,isDragging:o,containerRef:s,zoomIn:c,zoomOut:l,reset:u,onMouseDown:d,onMouseMove:f,onMouseUp:p}=di(),m,h;t[0]===r?(m=t[1],h=t[2]):(m=()=>{let e=function(e){e.key===`Escape`&&r()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},h=[r],t[0]=r,t[1]=m,t[2]=h),(0,Z.useEffect)(m,h);let g;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(g=[],t[3]=g):g=t[3],(0,Z.useEffect)(gi,g);let _;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(`span`,{className:`text-xs font-mono text-muted-foreground`,children:`mermaid diagram`}),t[4]=_):_=t[4];let v,y;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(Xe,{className:`h-3.5 w-3.5`}),y=(0,$.jsx)(`span`,{className:`sr-only`,children:`Zoom out`}),t[5]=v,t[6]=y):(v=t[5],y=t[6]);let b;t[7]===l?b=t[8]:(b=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(U,{variant:`ghost`,size:`icon-xs`,onClick:l,children:[v,y]})}),t[7]=l,t[8]=b);let x;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(q,{children:`Zoom out`}),t[9]=x):x=t[9];let S;t[10]===b?S=t[11]:(S=(0,$.jsxs)(J,{children:[b,x]}),t[10]=b,t[11]=S);let C;t[12]===i?C=t[13]:(C=Math.round(i*100),t[12]=i,t[13]=C);let w;t[14]!==u||t[15]!==C?(w=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,onClick:u,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:[C,`%`]})}),t[14]=u,t[15]=C,t[16]=w):w=t[16];let T;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(q,{children:`Reset zoom`}),t[17]=T):T=t[17];let E;t[18]===w?E=t[19]:(E=(0,$.jsxs)(J,{children:[w,T]}),t[18]=w,t[19]=E);let D,O;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,$.jsx)(ve,{className:`h-3.5 w-3.5`}),O=(0,$.jsx)(`span`,{className:`sr-only`,children:`Zoom in`}),t[20]=D,t[21]=O):(D=t[20],O=t[21]);let k;t[22]===c?k=t[23]:(k=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(U,{variant:`ghost`,size:`icon-xs`,onClick:c,children:[D,O]})}),t[22]=c,t[23]=k);let A;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,$.jsx)(q,{children:`Zoom in`}),t[24]=A):A=t[24];let j;t[25]===k?j=t[26]:(j=(0,$.jsxs)(J,{children:[k,A]}),t[25]=k,t[26]=j);let M,N;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,$.jsx)(Be,{className:`h-3.5 w-3.5`}),N=(0,$.jsx)(`span`,{className:`sr-only`,children:`Reset view`}),t[27]=M,t[28]=N):(M=t[27],N=t[28]);let P;t[29]===u?P=t[30]:(P=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(U,{variant:`ghost`,size:`icon-xs`,onClick:u,children:[M,N]})}),t[29]=u,t[30]=P);let F;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,$.jsx)(q,{children:`Reset view`}),t[31]=F):F=t[31];let I;t[32]===P?I=t[33]:(I=(0,$.jsxs)(J,{children:[P,F]}),t[32]=P,t[33]=I);let L;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,$.jsx)(`div`,{className:`w-px h-4 bg-border mx-1`}),t[34]=L):L=t[34];let R,z;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,$.jsx)(Ct,{className:`h-3.5 w-3.5`}),z=(0,$.jsx)(`span`,{className:`sr-only`,children:`Close`}),t[35]=R,t[36]=z):(R=t[35],z=t[36]);let ee;t[37]===r?ee=t[38]:(ee=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(U,{variant:`ghost`,size:`icon-xs`,onClick:r,children:[R,z]})}),t[37]=r,t[38]=ee);let te;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,$.jsx)(q,{children:`Close (Esc)`}),t[39]=te):te=t[39];let B;t[40]===ee?B=t[41]:(B=(0,$.jsxs)(J,{children:[ee,te]}),t[40]=ee,t[41]=B);let ne;t[42]!==E||t[43]!==j||t[44]!==I||t[45]!==B||t[46]!==S?(ne=(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 bg-background/90 border-b border-border shrink-0`,children:[_,(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[S,E,j,I,L,B]})]}),t[42]=E,t[43]=j,t[44]=I,t[45]=B,t[46]=S,t[47]=ne):ne=t[47];let re=o?`cursor-grabbing`:`cursor-grab`,ie;t[48]===re?ie=t[49]:(ie=G(`flex-1 overflow-hidden select-none`,re),t[48]=re,t[49]=ie);let ae=`translate(${a.x}px, ${a.y}px) scale(${i})`,V=o?`none`:`transform 0.1s ease-out`,oe;t[50]!==ae||t[51]!==V?(oe={transform:ae,transformOrigin:`center center`,transition:V},t[50]=ae,t[51]=V,t[52]=oe):oe=t[52];let se;t[53]===n?se=t[54]:(se={__html:n},t[53]=n,t[54]=se);let ce;t[55]!==oe||t[56]!==se?(ce=(0,$.jsx)(`div`,{className:`w-full h-full flex items-center justify-center`,style:oe,dangerouslySetInnerHTML:se}),t[55]=oe,t[56]=se,t[57]=ce):ce=t[57];let H;t[58]!==s||t[59]!==d||t[60]!==f||t[61]!==p||t[62]!==ie||t[63]!==ce?(H=(0,$.jsx)(`div`,{ref:s,className:ie,onMouseDown:d,onMouseMove:f,onMouseUp:p,onMouseLeave:p,children:ce}),t[58]=s,t[59]=d,t[60]=f,t[61]=p,t[62]=ie,t[63]=ce,t[64]=H):H=t[64];let le;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(le=(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`}),t[65]=le):le=t[65];let ue;return t[66]!==ne||t[67]!==H?(ue=(0,oi.createPortal)((0,$.jsx)(or,{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:[ne,H,le]})}),document.body),t[66]=ne,t[67]=H,t[68]=ue):ue=t[68],ue}function gi(){return document.body.style.overflow=`hidden`,_i}function _i(){document.body.style.overflow=``}function vi(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}=mi(n,pi()),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)(Lt,{}),(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)(et,{}):(0,$.jsx)(Ee,{}),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)(hi,{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)(or,{children:[E,D]}),t[48]=E,t[49]=D,t[50]=O):O=t[50],O}var yi=`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(`.`),bi=[/-->/,/--\./,/-\./,/==>/,/--\|/,/\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 xi(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(yi.some(e=>n===e.toLowerCase()||n.startsWith(e.toLowerCase()+` `)))return!0;let r=0;for(let t of bi)t.test(e)&&r++;return r>=2}function Si(e){if(!xi(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 yi.some(e=>n===e.toLowerCase()||n.startsWith(e.toLowerCase()+` `))?e.trim():null}var Ci=(0,Z.memo)(function({content:e,className:t,enableMermaid:n=!1}){let r=(0,Z.useMemo)(()=>!e||typeof e!=`string`?[]:wi(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)(Ti,{block:e,start:i[t]},t))})});function wi(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`||xi(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&&xi(e)){let t=Si(e);t?r.push({type:`mermaid`,code:t}):r.push({type:`paragraph`,text:e})}else r.push({type:`paragraph`,text:e})}}return r}var Ti=(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)(Ei,{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)(Oi,{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)(Ei,{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)(Ei,{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(ki),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)(Ei,{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(Ai),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(Mi),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)(vi,{content:n.code}),t[40]=n.code,t[41]=e),e}default:return null}}),Ei=(0,Z.memo)(function(e){let t=(0,Q.c)(6),{text:n}=e,r;t[0]===n?r=t[1]:(r=Di(n),t[0]=n,t[1]=r);let i=r,a;t[2]===i?a=t[3]:(a=i.map(Ni),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 Di(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 Oi(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)(et,{}):(0,$.jsx)(Ee,{}),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 ki(e,t){return(0,$.jsx)(`li`,{children:(0,$.jsx)(Ei,{text:e})},t)}function Ai(e,t){return(0,$.jsx)(`th`,{className:`px-3 py-2 text-left font-medium`,children:(0,$.jsx)(Ei,{text:e})},t)}function ji(e,t){return(0,$.jsx)(`td`,{className:`px-3 py-2`,children:(0,$.jsx)(Ei,{text:e})},t)}function Mi(e,t){return(0,$.jsx)(`tr`,{className:`border-b border-border last:border-0`,children:e.map(ji)},t)}function Ni(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 Pi(e){let t=e.toLowerCase();return t.includes(`read`)||t.includes(`file`)?Ut:t.includes(`create`)?ve:t.includes(`replace`)||t.includes(`edit`)?D:t.includes(`delete`)?Le:t.includes(`terminal`)||t.includes(`bash`)||t.includes(`shell`)?re:t.includes(`run`)?pe:t.includes(`git`)||t.includes(`branch`)?fe:t.includes(`search`)||t.includes(`grep`)||t.includes(`find`)?I:t.includes(`code`)||t.includes(`debug`)?Ne:t.includes(`test`)?P:t.includes(`agent`)||t.includes(`subagent`)?Ge:t.includes(`copy`)?Ee:t.includes(`dir`)||t.includes(`list`)||t.includes(`ls`)?Et:t.includes(`view`)||t.includes(`show`)?b:t.includes(`config`)||t.includes(`setting`)?w:t.includes(`image`)||t.includes(`generate_image`)?cn:t.includes(`chat`)||t.includes(`message`)||t.includes(`ask`)?at:o}function Fi(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 Ii(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 Li(e){return typeof e==`string`?e:typeof e==`object`&&e?JSON.stringify(e,null,2):String(e)}function Ri(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 zi(e){if(typeof e!=`object`||!e)return e;if(Array.isArray(e))return e.map(zi);let t={};for(let[n,r]of Object.entries(e))if(typeof r==`string`){let e=Ri(r);t[n]=typeof e==`object`?zi(e):r}else t[n]=zi(r);return t}function Bi(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 Vi(e){if(e==null)return``;let t=typeof e==`object`&&e?zi(e):e;return Bi(typeof t==`string`?t:t==null?``:JSON.stringify(t,null,2))}function Hi(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:Ii(Li(i),t),d=Ii(o?String(i.prompt):null,t),f=Ii(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=Ii(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=Pi(n),N=(n===`todo`?j===`done`?P:j===`working`?zt:R: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:N,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 Ui(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)(E,{children:(0,$.jsx)(De,{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)(un,{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)(W,{open:n,onOpenChange:r,children:c}),t[7]=r,t[8]=n,t[9]=c,t[10]=l):l=t[10],l}function Wi(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(Ki),o=s.map(Gi),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 Gi(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 Ki(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 qi(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 Ji(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 Yi(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 Xi(e){let n=(0,Q.c)(55),{data:r,inline:i,resultContent:a}=e,[o,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(!1);if(i){if(r.command!==null&&a){let e;n[0]===r.icon?e=n[1]:(e=(0,Z.createElement)(r.icon,{className:`h-3.5 w-3.5 shrink-0 text-brand`}),n[0]=r.icon,n[1]=e);let t;n[2]===r.displayName?t=n[3]:(t=(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:r.displayName}),n[2]=r.displayName,n[3]=t);let i;n[4]===Symbol.for(`react.memo_cache_sentinel`)?(i=()=>l(!0),n[4]=i):i=n[4];let o;n[5]===r.command?o=n[6]:(o=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:i,className:`text-xs font-mono text-muted-foreground hover:underline break-all cursor-pointer`,children:r.command})}),n[5]=r.command,n[6]=o);let s;n[7]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(q,{children:`View output`}),n[7]=s):s=n[7];let u;n[8]===o?u=n[9]:(u=(0,$.jsxs)(J,{children:[o,s]}),n[8]=o,n[9]=u);let d;n[10]!==e||n[11]!==t||n[12]!==u?(d=(0,$.jsxs)(`div`,{className:`py-0.5 flex items-center gap-2 flex-wrap`,children:[e,t,u]}),n[10]=e,n[11]=t,n[12]=u,n[13]=d):d=n[13];let f;n[14]!==r.command||n[15]!==c||n[16]!==a?(f=(0,$.jsx)(Ui,{open:c,onOpenChange:l,title:r.command,content:a}),n[14]=r.command,n[15]=c,n[16]=a,n[17]=f):f=n[17];let p;return n[18]!==d||n[19]!==f?(p=(0,$.jsxs)($.Fragment,{children:[d,f]}),n[18]=d,n[19]=f,n[20]=p):p=n[20],p}let e=r.toolName,t;n[21]===r.icon?t=n[22]:(t=(0,Z.createElement)(r.icon,{className:`h-3.5 w-3.5 shrink-0 text-brand`}),n[21]=r.icon,n[22]=t);let i;n[23]===r.displayName?i=n[24]:(i=(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:r.displayName}),n[23]=r.displayName,n[24]=i);let o;n[25]!==r.toolName||n[26]!==t||n[27]!==i?(o=(0,$.jsxs)(`span`,{title:e,className:`inline-flex items-center gap-1`,children:[t,i]}),n[25]=r.toolName,n[26]=t,n[27]=i,n[28]=o):o=n[28];let s;n[29]===r.command?s=n[30]:(s=r.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:r.command}),n[29]=r.command,n[30]=s);let u;return n[31]!==o||n[32]!==s?(u=(0,$.jsxs)(`div`,{className:`py-0.5 flex items-center gap-2 flex-wrap`,children:[o,s]}),n[31]=o,n[32]=s,n[33]=u):u=n[33],u}let u;n[34]===o?u=n[35]:(u=()=>s(!o),n[34]=o,n[35]=u);let d=r.toolName,f;n[36]===r.icon?f=n[37]:(f=(0,Z.createElement)(r.icon,{className:`h-4 w-4 text-brand`}),n[36]=r.icon,n[37]=f);let p;n[38]===r.displayName?p=n[39]:(p=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:r.displayName}),n[38]=r.displayName,n[39]=p);let m;n[40]===o?m=n[41]:(m=o?(0,$.jsx)(t,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(ze,{className:`h-4 w-4 shrink-0`}),n[40]=o,n[41]=m);let h;n[42]!==r.toolName||n[43]!==u||n[44]!==f||n[45]!==p||n[46]!==m?(h=(0,$.jsxs)(`button`,{onClick:u,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:d,children:[f,p,m]}),n[42]=r.toolName,n[43]=u,n[44]=f,n[45]=p,n[46]=m,n[47]=h):h=n[47];let g;n[48]!==r.toolId||n[49]!==r.toolInput||n[50]!==o?(g=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: `,r.toolId]}),r.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:r.toolInput}):null]}),n[48]=r.toolId,n[49]=r.toolInput,n[50]=o,n[51]=g):g=n[51];let _;return n[52]!==h||n[53]!==g?(_=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[h,g]}),n[52]=h,n[53]=g,n[54]=_):_=n[54],_}var Zi=Mn,Qi=Hn,$i=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)(pn,{children:(0,$.jsx)(Tn,{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});$i.displayName=Tn.displayName;function ea(e){let n=(0,Q.c)(45),{data:r,inline:i,rootPath:a,onOpenFile:o}=e,[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(!1),d;n[0]!==r.filePath||n[1]!==o||n[2]!==a?(d=function(){!r.filePath||!o||o(a&&r.filePath.startsWith(a)?r.filePath.slice(a.length+1):r.filePath)},n[0]=r.filePath,n[1]=o,n[2]=a,n[3]=d):d=n[3];let f=d;if(i){let e=!!(r.toolInput&&!r.command&&!r.path&&!r.pattern&&!r.fileDisplayName),t;n[4]!==r.displayName||n[5]!==r.icon||n[6]!==r.toolId||n[7]!==r.toolInput||n[8]!==r.toolName||n[9]!==e?(t=e?(0,$.jsxs)(Zi,{children:[(0,$.jsx)(Qi,{asChild:!0,children:(0,$.jsx)(`span`,{title:r.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)(r.icon,{className:`h-3.5 w-3.5 text-brand`}),(0,$.jsx)(`span`,{className:`text-xs`,children:r.displayName})]})})}),(0,$.jsx)($i,{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: `,r.toolId]}),(0,$.jsx)(`pre`,{className:`font-mono whitespace-pre-wrap overflow-auto max-h-48`,children:r.toolInput})]})})]}):(0,$.jsxs)(`span`,{title:r.toolName,className:`inline-flex items-center gap-1`,children:[(0,Z.createElement)(r.icon,{className:`h-3.5 w-3.5 shrink-0 text-brand`}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:r.displayName})]}),n[4]=r.displayName,n[5]=r.icon,n[6]=r.toolId,n[7]=r.toolInput,n[8]=r.toolName,n[9]=e,n[10]=t):t=n[10];let i;n[11]!==r.editNewText||n[12]!==r.editOldText||n[13]!==r.fileDisplayName||n[14]!==r.filePath||n[15]!==r.hasEditDiff||n[16]!==r.path||n[17]!==l||n[18]!==f||n[19]!==a?(i=r.fileDisplayName?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:r.hasEditDiff?()=>u(!0):f,className:G(`text-xs font-mono truncate max-w-[200px] sm:max-w-[320px] cursor-pointer`,`text-muted-foreground hover:underline`),children:r.fileDisplayName})}),(0,$.jsx)(q,{children:r.hasEditDiff?`View diff`:r.filePath?Ii(r.filePath,a)??r.filePath:r.fileDisplayName})]}),r.hasEditDiff&&(0,$.jsx)(W,{open:l,onOpenChange:u,children:(0,$.jsxs)(un,{className:`max-w-2xl h-[80vh] flex flex-col`,children:[(0,$.jsx)(E,{children:(0,$.jsx)(De,{children:(0,$.jsx)(`code`,{className:`text-sm font-mono`,children:Ii(r.filePath,a)??r.filePath})})}),(0,$.jsx)(`div`,{className:`overflow-auto flex-1 rounded border border-border bg-muted/30 p-3`,children:(0,$.jsx)(Wi,{oldText:r.editOldText,newText:r.editNewText})})]})})]}):r.path===null?null:(0,$.jsx)(`span`,{className:`text-xs font-mono text-muted-foreground truncate max-w-[200px] sm:max-w-[320px]`,title:r.path,children:r.path}),n[11]=r.editNewText,n[12]=r.editOldText,n[13]=r.fileDisplayName,n[14]=r.filePath,n[15]=r.hasEditDiff,n[16]=r.path,n[17]=l,n[18]=f,n[19]=a,n[20]=i):i=n[20];let o;return n[21]!==t||n[22]!==i?(o=(0,$.jsxs)(`div`,{className:`py-0.5 flex items-center gap-2 flex-wrap`,children:[t,i]}),n[21]=t,n[22]=i,n[23]=o):o=n[23],o}let p;n[24]===s?p=n[25]:(p=()=>c(!s),n[24]=s,n[25]=p);let m=r.toolName,h;n[26]===r.icon?h=n[27]:(h=(0,Z.createElement)(r.icon,{className:`h-4 w-4 text-brand`}),n[26]=r.icon,n[27]=h);let g;n[28]===r.displayName?g=n[29]:(g=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:r.displayName}),n[28]=r.displayName,n[29]=g);let _;n[30]===s?_=n[31]:(_=s?(0,$.jsx)(t,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(ze,{className:`h-4 w-4 shrink-0`}),n[30]=s,n[31]=_);let v;n[32]!==r.toolName||n[33]!==p||n[34]!==h||n[35]!==g||n[36]!==_?(v=(0,$.jsxs)(`button`,{onClick:p,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:m,children:[h,g,_]}),n[32]=r.toolName,n[33]=p,n[34]=h,n[35]=g,n[36]=_,n[37]=v):v=n[37];let y;n[38]!==r.toolId||n[39]!==r.toolInput||n[40]!==s?(y=s&&(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: `,r.toolId]}),r.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:r.toolInput}):null]}),n[38]=r.toolId,n[39]=r.toolInput,n[40]=s,n[41]=y):y=n[41];let b;return n[42]!==v||n[43]!==y?(b=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[v,y]}),n[42]=v,n[43]=y,n[44]=b):b=n[44],b}function ta(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)(Yi,{children:n.codeSearchQuery}),n.pattern!==null&&(0,$.jsxs)(Yi,{children:[`/`,n.pattern,`/`]}),n.codeSearchFilePath!==null&&(0,$.jsx)(Yi,{children:n.codeSearchFilePath}),n.codeSearchFileGlob!==null&&(0,$.jsx)(Yi,{children:n.codeSearchFileGlob})]}):n.pattern!==null&&(0,$.jsx)(Yi,{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 na(e){let n=(0,Q.c)(67),{data:r,inline:i,resultContent:a}=e,[o,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(!1),u=r.toolName===`code_search`,d=r.codeSearchQuery??r.pattern??r.codeSearchFilePath??r.codeSearchFileGlob??`search`;if(i){if(a&&(u||r.toolName===`find`||r.pattern!==null)){let e;n[0]===r.icon?e=n[1]:(e=(0,Z.createElement)(r.icon,{className:`h-3.5 w-3.5 shrink-0 text-brand`}),n[0]=r.icon,n[1]=e);let t;n[2]===r.displayName?t=n[3]:(t=(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:r.displayName}),n[2]=r.displayName,n[3]=t);let i;n[4]===Symbol.for(`react.memo_cache_sentinel`)?(i=()=>l(!0),n[4]=i):i=n[4];let o;n[5]===d?o=n[6]:(o=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:i,className:`text-xs font-mono text-muted-foreground hover:underline break-all cursor-pointer`,children:d})}),n[5]=d,n[6]=o);let s;n[7]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(q,{children:`View results`}),n[7]=s):s=n[7];let u;n[8]===o?u=n[9]:(u=(0,$.jsxs)(J,{children:[o,s]}),n[8]=o,n[9]=u);let f;n[10]!==e||n[11]!==t||n[12]!==u?(f=(0,$.jsxs)(`div`,{className:`py-0.5 flex items-center gap-2 flex-wrap`,children:[e,t,u]}),n[10]=e,n[11]=t,n[12]=u,n[13]=f):f=n[13];let p;n[14]!==c||n[15]!==a||n[16]!==d?(p=(0,$.jsx)(Ui,{open:c,onOpenChange:l,title:d,content:a}),n[14]=c,n[15]=a,n[16]=d,n[17]=p):p=n[17];let m;return n[18]!==f||n[19]!==p?(m=(0,$.jsxs)($.Fragment,{children:[f,p]}),n[18]=f,n[19]=p,n[20]=m):m=n[20],m}let e=r.toolName,t;n[21]===r.icon?t=n[22]:(t=(0,Z.createElement)(r.icon,{className:`h-3.5 w-3.5 shrink-0 text-brand`}),n[21]=r.icon,n[22]=t);let i;n[23]===r.displayName?i=n[24]:(i=(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:r.displayName}),n[23]=r.displayName,n[24]=i);let o;n[25]!==r.toolName||n[26]!==t||n[27]!==i?(o=(0,$.jsxs)(`span`,{title:e,className:`inline-flex items-center gap-1`,children:[t,i]}),n[25]=r.toolName,n[26]=t,n[27]=i,n[28]=o):o=n[28];let s;n[29]===r?s=n[30]:(s=(0,$.jsx)(ta,{data:r}),n[29]=r,n[30]=s);let f;n[31]===r.lang?f=n[32]:(f=r.lang!==null&&(0,$.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded bg-muted text-muted-foreground`,children:r.lang}),n[31]=r.lang,n[32]=f);let p;return n[33]!==o||n[34]!==s||n[35]!==f?(p=(0,$.jsxs)(`div`,{className:`py-0.5 flex items-center gap-2 flex-wrap`,children:[o,s,f]}),n[33]=o,n[34]=s,n[35]=f,n[36]=p):p=n[36],p}let f;n[37]===o?f=n[38]:(f=()=>s(!o),n[37]=o,n[38]=f);let p=r.toolName,m;n[39]===r.icon?m=n[40]:(m=(0,Z.createElement)(r.icon,{className:`h-4 w-4 text-brand`}),n[39]=r.icon,n[40]=m);let h;n[41]===r.displayName?h=n[42]:(h=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:r.displayName}),n[41]=r.displayName,n[42]=h);let g;n[43]!==r.codeSearchFileGlob||n[44]!==r.codeSearchFilePath||n[45]!==r.codeSearchQuery||n[46]!==r.pattern||n[47]!==u?(g=u&&(0,$.jsxs)($.Fragment,{children:[r.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:r.codeSearchQuery}),r.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:[`/`,r.pattern,`/`]}),r.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:r.codeSearchFilePath}),r.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:r.codeSearchFileGlob})]}),n[43]=r.codeSearchFileGlob,n[44]=r.codeSearchFilePath,n[45]=r.codeSearchQuery,n[46]=r.pattern,n[47]=u,n[48]=g):g=n[48];let _;n[49]===o?_=n[50]:(_=o?(0,$.jsx)(t,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(ze,{className:`h-4 w-4 shrink-0`}),n[49]=o,n[50]=_);let v;n[51]!==r.toolName||n[52]!==f||n[53]!==m||n[54]!==h||n[55]!==g||n[56]!==_?(v=(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,_]}),n[51]=r.toolName,n[52]=f,n[53]=m,n[54]=h,n[55]=g,n[56]=_,n[57]=v):v=n[57];let y;n[58]!==r.toolId||n[59]!==r.toolInput||n[60]!==o||n[61]!==u||n[62]!==a?(y=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: `,r.toolId]}),r.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:r.toolInput}):null,u&&a&&(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:a})]}),n[58]=r.toolId,n[59]=r.toolInput,n[60]=o,n[61]=u,n[62]=a,n[63]=y):y=n[63];let b;return n[64]!==v||n[65]!==y?(b=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[v,y]}),n[64]=v,n[65]=y,n[66]=b):b=n[66],b}function ra(e){let n=(0,Q.c)(57),{data:r,inline:i}=e,[a,o]=(0,Z.useState)(!1);if(i){let e=r.toolName,t;n[0]===r.icon?t=n[1]:(t=(0,Z.createElement)(r.icon,{className:`h-3.5 w-3.5 text-brand`}),n[0]=r.icon,n[1]=t);let i;n[2]===r.displayName?i=n[3]:(i=(0,$.jsx)(`span`,{className:`text-xs`,children:r.displayName}),n[2]=r.displayName,n[3]=i);let a;n[4]!==t||n[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:[t,i]}),n[4]=t,n[5]=i,n[6]=a):a=n[6];let o;n[7]!==r.toolName||n[8]!==a?(o=(0,$.jsx)(Qi,{asChild:!0,children:(0,$.jsx)(`span`,{title:e,className:`inline-flex`,children:a})}),n[7]=r.toolName,n[8]=a,n[9]=o):o=n[9];let s;n[10]===r.toolId?s=n[11]:(s=(0,$.jsxs)(`div`,{className:`font-mono`,children:[`ID: `,r.toolId]}),n[10]=r.toolId,n[11]=s);let c;n[12]!==r.prompt||n[13]!==r.toolInput?(c=r.prompt?(0,$.jsx)(`div`,{className:`whitespace-pre-wrap leading-relaxed`,children:r.prompt}):r.toolInput?(0,$.jsx)(`pre`,{className:`font-mono whitespace-pre-wrap overflow-auto max-h-48`,children:r.toolInput}):null,n[12]=r.prompt,n[13]=r.toolInput,n[14]=c):c=n[14];let l;n[15]!==s||n[16]!==c?(l=(0,$.jsx)($i,{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]})}),n[15]=s,n[16]=c,n[17]=l):l=n[17];let u;n[18]!==o||n[19]!==l?(u=(0,$.jsxs)(Zi,{children:[o,l]}),n[18]=o,n[19]=l,n[20]=u):u=n[20];let d;n[21]===r.agentName?d=n[22]:(d=r.agentName&&(0,$.jsx)(qi,{name:r.agentName}),n[21]=r.agentName,n[22]=d);let f;n[23]===r.subagentType?f=n[24]:(f=r.subagentType&&(0,$.jsx)(Ji,{type:r.subagentType}),n[23]=r.subagentType,n[24]=f);let p;return n[25]!==d||n[26]!==f||n[27]!==u?(p=(0,$.jsxs)(`div`,{className:`py-0.5 flex items-center gap-2 flex-wrap`,children:[u,d,f]}),n[25]=d,n[26]=f,n[27]=u,n[28]=p):p=n[28],p}let s;n[29]===a?s=n[30]:(s=()=>o(!a),n[29]=a,n[30]=s);let c=r.toolName,l;n[31]===r.icon?l=n[32]:(l=(0,Z.createElement)(r.icon,{className:`h-4 w-4 text-brand`}),n[31]=r.icon,n[32]=l);let u;n[33]===r.displayName?u=n[34]:(u=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:r.displayName}),n[33]=r.displayName,n[34]=u);let d;n[35]===r.agentName?d=n[36]:(d=r.agentName&&(0,$.jsx)(qi,{name:r.agentName}),n[35]=r.agentName,n[36]=d);let f;n[37]===r.subagentType?f=n[38]:(f=r.subagentType&&(0,$.jsx)(Ji,{type:r.subagentType}),n[37]=r.subagentType,n[38]=f);let p;n[39]===a?p=n[40]:(p=a?(0,$.jsx)(t,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(ze,{className:`h-4 w-4 shrink-0`}),n[39]=a,n[40]=p);let m;n[41]!==r.toolName||n[42]!==s||n[43]!==l||n[44]!==u||n[45]!==d||n[46]!==f||n[47]!==p?(m=(0,$.jsxs)(`button`,{onClick:s,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:c,children:[l,u,d,f,p]}),n[41]=r.toolName,n[42]=s,n[43]=l,n[44]=u,n[45]=d,n[46]=f,n[47]=p,n[48]=m):m=n[48];let h;n[49]!==r.prompt||n[50]!==r.toolId||n[51]!==r.toolInput||n[52]!==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: `,r.toolId]}),r.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:r.prompt}):r.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:r.toolInput}):null]}),n[49]=r.prompt,n[50]=r.toolId,n[51]=r.toolInput,n[52]=a,n[53]=h):h=n[53];let g;return n[54]!==m||n[55]!==h?(g=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[m,h]}),n[54]=m,n[55]=h,n[56]=g):g=n[56],g}function ia(e){let n=(0,Q.c)(21),{data:r,inline:i}=e,[a,o]=(0,Z.useState)(!1);if(i)return null;let s;n[0]===a?s=n[1]:(s=()=>o(!a),n[0]=a,n[1]=s);let c=r.toolName,l;n[2]===r.icon?l=n[3]:(l=(0,Z.createElement)(r.icon,{className:`h-4 w-4 text-brand`}),n[2]=r.icon,n[3]=l);let u;n[4]===r.displayName?u=n[5]:(u=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:r.displayName}),n[4]=r.displayName,n[5]=u);let d;n[6]===a?d=n[7]:(d=a?(0,$.jsx)(t,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(ze,{className:`h-4 w-4 shrink-0`}),n[6]=a,n[7]=d);let f;n[8]!==r.toolName||n[9]!==s||n[10]!==l||n[11]!==u||n[12]!==d?(f=(0,$.jsxs)(`button`,{onClick:s,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:c,children:[l,u,d]}),n[8]=r.toolName,n[9]=s,n[10]=l,n[11]=u,n[12]=d,n[13]=f):f=n[13];let p;n[14]!==r.toolId||n[15]!==r.toolInput||n[16]!==a?(p=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: `,r.toolId]}),r.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:r.toolInput}):null]}),n[14]=r.toolId,n[15]=r.toolInput,n[16]=a,n[17]=p):p=n[17];let m;return n[18]!==f||n[19]!==p?(m=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[f,p]}),n[18]=f,n[19]=p,n[20]=m):m=n[20],m}function aa(e){let n=(0,Q.c)(34),{data:r,inline:i}=e,[a,o]=(0,Z.useState)(!1);if(i){let e=r.toolName,t;n[0]===r.icon?t=n[1]:(t=(0,Z.createElement)(r.icon,{className:`h-3.5 w-3.5 shrink-0 text-brand`}),n[0]=r.icon,n[1]=t);let i;n[2]===r.displayName?i=n[3]:(i=(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:r.displayName}),n[2]=r.displayName,n[3]=i);let a;n[4]!==r.toolName||n[5]!==t||n[6]!==i?(a=(0,$.jsxs)(`span`,{title:e,className:`inline-flex items-center gap-1`,children:[t,i]}),n[4]=r.toolName,n[5]=t,n[6]=i,n[7]=a):a=n[7];let o;n[8]===r.imageGenPrompt?o=n[9]:(o=r.imageGenPrompt!==null&&(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground truncate max-w-[200px] sm:max-w-[320px]`,title:r.imageGenPrompt,children:r.imageGenPrompt}),n[8]=r.imageGenPrompt,n[9]=o);let s;return n[10]!==a||n[11]!==o?(s=(0,$.jsxs)(`div`,{className:`py-0.5 flex items-center gap-2 flex-wrap`,children:[a,o]}),n[10]=a,n[11]=o,n[12]=s):s=n[12],s}let s;n[13]===a?s=n[14]:(s=()=>o(!a),n[13]=a,n[14]=s);let c=r.toolName,l;n[15]===r.icon?l=n[16]:(l=(0,Z.createElement)(r.icon,{className:`h-4 w-4 text-brand`}),n[15]=r.icon,n[16]=l);let u;n[17]===r.displayName?u=n[18]:(u=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:r.displayName}),n[17]=r.displayName,n[18]=u);let d;n[19]===a?d=n[20]:(d=a?(0,$.jsx)(t,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(ze,{className:`h-4 w-4 shrink-0`}),n[19]=a,n[20]=d);let f;n[21]!==r.toolName||n[22]!==s||n[23]!==l||n[24]!==u||n[25]!==d?(f=(0,$.jsxs)(`button`,{onClick:s,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:c,children:[l,u,d]}),n[21]=r.toolName,n[22]=s,n[23]=l,n[24]=u,n[25]=d,n[26]=f):f=n[26];let p;n[27]!==r.toolId||n[28]!==r.toolInput||n[29]!==a?(p=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: `,r.toolId]}),r.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:r.toolInput}):null]}),n[27]=r.toolId,n[28]=r.toolInput,n[29]=a,n[30]=p):p=n[30];let m;return n[31]!==f||n[32]!==p?(m=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[f,p]}),n[31]=f,n[32]=p,n[33]=m):m=n[33],m}function oa(e){let n=(0,Q.c)(35),{data:r,inline:i}=e,[a,o]=(0,Z.useState)(!1);if(i){let e=!!(r.prompt??(r.toolInput&&!r.command&&!r.path&&!r.pattern&&!r.fileDisplayName)),t;n[0]!==r.displayName||n[1]!==r.icon||n[2]!==r.prompt||n[3]!==r.toolId||n[4]!==r.toolInput||n[5]!==r.toolName||n[6]!==e?(t=e?(0,$.jsxs)(Zi,{children:[(0,$.jsx)(Qi,{asChild:!0,children:(0,$.jsx)(`span`,{title:r.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)(r.icon,{className:`h-3.5 w-3.5 text-brand`}),(0,$.jsx)(`span`,{className:`text-xs`,children:r.displayName})]})})}),(0,$.jsx)($i,{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: `,r.toolId]}),r.prompt?(0,$.jsx)(`div`,{className:`whitespace-pre-wrap leading-relaxed`,children:r.prompt}):r.toolInput?(0,$.jsx)(`pre`,{className:`font-mono whitespace-pre-wrap overflow-auto max-h-48`,children:r.toolInput}):null]})})]}):(0,$.jsxs)(`span`,{title:r.toolName,className:`inline-flex items-center gap-1`,children:[(0,Z.createElement)(r.icon,{className:`h-3.5 w-3.5 shrink-0 text-brand`}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:r.displayName})]}),n[0]=r.displayName,n[1]=r.icon,n[2]=r.prompt,n[3]=r.toolId,n[4]=r.toolInput,n[5]=r.toolName,n[6]=e,n[7]=t):t=n[7];let i;n[8]===r.path?i=n[9]:(i=r.path!==null&&(0,$.jsx)(`span`,{className:`text-xs font-mono text-muted-foreground truncate max-w-[200px] sm:max-w-[320px]`,title:r.path,children:r.path}),n[8]=r.path,n[9]=i);let a;return n[10]!==t||n[11]!==i?(a=(0,$.jsxs)(`div`,{className:`py-0.5 flex items-center gap-2 flex-wrap`,children:[t,i]}),n[10]=t,n[11]=i,n[12]=a):a=n[12],a}let s;n[13]===a?s=n[14]:(s=()=>o(!a),n[13]=a,n[14]=s);let c=r.toolName,l;n[15]===r.icon?l=n[16]:(l=(0,Z.createElement)(r.icon,{className:`h-4 w-4 text-brand`}),n[15]=r.icon,n[16]=l);let u;n[17]===r.displayName?u=n[18]:(u=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:r.displayName}),n[17]=r.displayName,n[18]=u);let d;n[19]===a?d=n[20]:(d=a?(0,$.jsx)(t,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(ze,{className:`h-4 w-4 shrink-0`}),n[19]=a,n[20]=d);let f;n[21]!==r.toolName||n[22]!==s||n[23]!==l||n[24]!==u||n[25]!==d?(f=(0,$.jsxs)(`button`,{onClick:s,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:c,children:[l,u,d]}),n[21]=r.toolName,n[22]=s,n[23]=l,n[24]=u,n[25]=d,n[26]=f):f=n[26];let p;n[27]!==r.prompt||n[28]!==r.toolId||n[29]!==r.toolInput||n[30]!==a?(p=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: `,r.toolId]}),r.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:r.prompt}):r.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:r.toolInput}):null]}),n[27]=r.prompt,n[28]=r.toolId,n[29]=r.toolInput,n[30]=a,n[31]=p):p=n[31];let m;return n[32]!==f||n[33]!==p?(m=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[f,p]}),n[32]=f,n[33]=p,n[34]=m):m=n[34],m}function sa(e){let t=(0,Q.c)(34),{block:n,inline:r,resultContent:i}=e,{state:a}=Xn(),{setPendingExplorerPath:o,setActiveMainTab:s}=Er(),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=Hi(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)(Xi,{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)(ea,{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)(na,{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)(ra,{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)(ia,{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)(aa,{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)(oa,{data:u,inline:r}),t[31]=u,t[32]=r,t[33]=e):e=t[33],e}}}var ca=(0,Z.createContext)({todos:[],setTodos:()=>{}});function la(e){let t=(0,Q.c)(7),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=[],t[0]=r):r=t[0];let[i,a]=(0,Z.useState)(r),o;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(o=e=>{a(e)},t[1]=o):o=t[1];let s=o,c;t[2]===i?c=t[3]:(c={todos:i,setTodos:s},t[2]=i,t[3]=c);let l;return t[4]!==n||t[5]!==c?(l=(0,$.jsx)(ca.Provider,{value:c,children:n}),t[4]=n,t[5]=c,t[6]=l):l=t[6],l}function ua(e){let t=[e.result,e.content],n=[];for(let e of t)if(typeof e==`string`)n.push(e);else if(Array.isArray(e))for(let t of e)typeof t==`object`&&t&&`text`in t&&typeof t.text==`string`&&n.push(t.text);for(let e of n){let t=e.trim();if(t.startsWith(`{`))try{let e=JSON.parse(t);if(e&&Array.isArray(e.todos))return e.todos}catch(e){console.error(`Failed to parse todo JSON:`,e)}}return null}function da(e){let t=(0,Q.c)(17),{todos:n}=e,{todos:r,setTodos:i}=(0,Z.useContext)(ca),a,o;t[0]!==n||t[1]!==i?(a=()=>{i(n)},o=[n,i],t[0]=n,t[1]=i,t[2]=a,t[3]=o):(a=t[2],o=t[3]),(0,Z.useEffect)(a,o);let s=r.length>0?r:n,c;t[4]===s?c=t[5]:(c=s.filter(pa),t[4]=s,t[5]=c);let l=c.length,u;t[6]===s.length?u=t[7]:(u=s.length===0&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No todo items.`}),t[6]=s.length,t[7]=u);let d;t[8]===s?d=t[9]:(d=s.map(fa),t[8]=s,t[9]=d);let f;t[10]!==l||t[11]!==s.length?(f=s.length>0&&(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground pt-1`,children:[l,`/`,s.length,` completed`]}),t[10]=l,t[11]=s.length,t[12]=f):f=t[12];let p;return t[13]!==u||t[14]!==d||t[15]!==f?(p=(0,$.jsxs)(`div`,{className:`space-y-1`,children:[u,d,f]}),t[13]=u,t[14]=d,t[15]=f,t[16]=p):p=t[16],p}function fa(e){return(0,$.jsxs)(`div`,{className:`flex items-start gap-2 text-sm`,children:[e.status===`done`?(0,$.jsx)(P,{className:`h-4 w-4 shrink-0 mt-0.5 text-brand`}):e.status===`working`?(0,$.jsx)(C,{className:`h-4 w-4 shrink-0 mt-0.5 text-yellow-500`}):(0,$.jsx)(R,{className:`h-4 w-4 shrink-0 mt-0.5 text-muted-foreground`}),(0,$.jsx)(`span`,{className:e.status===`done`?`line-through text-muted-foreground`:`text-foreground`,children:e.description})]},e.id)}function pa(e){return e.status===`done`}function ma(e){let t=(0,Q.c)(4),{todos:n}=e,{setTodos:r}=(0,Z.useContext)(ca),i,a;return t[0]!==r||t[1]!==n?(i=()=>{r(n)},a=[n,r],t[0]=r,t[1]=n,t[2]=i,t[3]=a):(i=t[2],a=t[3]),(0,Z.useEffect)(i,a),null}function ha(e){let n=(0,Q.c)(21),{todos:r}=e,[i,a]=(0,Z.useState)(!0);if(r.length===0)return null;let o;n[0]===r?o=n[1]:(o=r.filter(ga),n[0]=r,n[1]=o);let s=o.length,c=s===r.length,l=r.length-s,u=c?`${r.length} Tasks Completed`:`${l} Tasks To Do`,d;n[2]===i?d=n[3]:(d=()=>a(!i),n[2]=i,n[3]=d);let f;n[4]===c?f=n[5]:(f=c?(0,$.jsx)(P,{className:`h-4 w-4 shrink-0 text-brand`}):(0,$.jsx)(ct,{className:`h-4 w-4 shrink-0`}),n[4]=c,n[5]=f);let p;n[6]===u?p=n[7]:(p=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:u}),n[6]=u,n[7]=p);let m;n[8]===i?m=n[9]:(m=i?(0,$.jsx)(t,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(ze,{className:`h-4 w-4 shrink-0`}),n[8]=i,n[9]=m);let h;n[10]!==d||n[11]!==f||n[12]!==p||n[13]!==m?(h=(0,$.jsxs)(`button`,{onClick:d,className:`w-full px-3 py-2 flex items-center gap-2 text-sm font-medium text-foreground hover:bg-muted transition-colors text-left`,title:`Todo list`,children:[f,p,m]}),n[10]=d,n[11]=f,n[12]=p,n[13]=m,n[14]=h):h=n[14];let g;n[15]!==i||n[16]!==r?(g=i&&(0,$.jsx)(`div`,{className:`px-3 py-3 bg-background border-t border-border`,children:(0,$.jsx)(da,{todos:r})}),n[15]=i,n[16]=r,n[17]=g):g=n[17];let _;return n[18]!==h||n[19]!==g?(_=(0,$.jsxs)(`div`,{className:`mb-3 rounded-lg border border-border bg-muted/50 overflow-hidden`,children:[h,g]}),n[18]=h,n[19]=g,n[20]=_):_=n[20],_}function ga(e){return e.status===`done`}function _a(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 va(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 Jt(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 g(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 p;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(be,{className:`h-3.5 w-3.5`}),t[7]=p):p=t[7];let m;t[8]===c?m=t[9]:(m=(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:p})}),t[8]=c,t[9]=m);let h;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(q,{children:`Save image`}),t[10]=h):h=t[10];let _;t[11]===m?_=t[12]:(_=(0,$.jsxs)(J,{children:[m,h]}),t[11]=m,t[12]=_);let v;t[13]===i?v=t[14]:(v=i?(0,$.jsx)(et,{className:`h-3.5 w-3.5 text-green-500`}):(0,$.jsx)(Ee,{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)(or,{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 ya(e){let n=(0,Q.c)(70),{block:r,inline:i}=e,[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(!1),{state:l}=Xn(),u=l.projects,d,f,p,m,h,g,_,v;if(n[0]!==r||n[1]!==i||n[2]!==l.projects||n[3]!==l.selectedProjectId||n[4]!==l.selectedThreadId){g=Symbol.for(`react.early_return_sentinel`);bb0:{let e;n[13]===l.selectedProjectId?e=n[14]:(e=e=>e.projectId===l.selectedProjectId,n[13]=l.selectedProjectId,n[14]=e);let t=u.find(e)?.threads.find(e=>e.threadId===l.selectedThreadId)?.path;v=r.toolName??`Unknown Tool`,_=r.toolCallId??`unknown`;let a=r,o=r.result??a.content,s;n[15]!==a||n[16]!==v?(s=v===`todo`?ua(a):null,n[15]=a,n[16]=v,n[17]=s):s=n[17];let c=s;if(p=Ii(Vi(o),t),!(p.length>0)&&c===null){g=null;break bb0}if(d=Fi(v),typeof o==`object`&&o){let e=o,t=e.returnDisplay??e.return_display;if(typeof t==`string`&&t.trim()){let e;n[18]===t?e=n[19]:(e=t.trim(),n[18]=t,n[19]=e),d=e}else if(v===`read`||v===`file_read`){let t=e.filePath??e.file_path??e.path??``;if(t){let e;n[20]===t?e=n[21]:(e=t.split(`/`).pop()??t,n[20]=t,n[21]=e),d=`Completed ${e}`}}}else if(o==null){let e;n[22]===v?e=n[23]:(e=Fi(v),n[22]=v,n[23]=e),d=`${e} (no result)`}if(d=Ii(d,t),c!==null){let e;n[24]===c?e=n[25]:(e=(0,$.jsx)(ma,{todos:c}),n[24]=c,n[25]=e),g=e;break bb0}if(v===`generate_image`){let e;n[26]===o?e=n[27]:(e=_a(o),n[26]=o,n[27]=e);let t=e;if(t&&(t.imageUrl||t.imageData)){let e;n[28]!==t.imageData||n[29]!==t.imageUrl?(e=(0,$.jsx)(va,{imageUrl:t.imageUrl,imageData:t.imageData}),n[28]=t.imageData,n[29]=t.imageUrl,n[30]=e):e=n[30],g=e;break bb0}}if(i){g=null;break bb0}let y;n[31]===v?y=n[32]:(y=v.toLowerCase().includes(`bash`),n[31]=v,n[32]=y),f=y,m=p?p.split(`
15
+ `):[],h=f?m.slice(0,3).join(`
16
+ `):p}n[0]=r,n[1]=i,n[2]=l.projects,n[3]=l.selectedProjectId,n[4]=l.selectedThreadId,n[5]=d,n[6]=f,n[7]=p,n[8]=m,n[9]=h,n[10]=g,n[11]=_,n[12]=v}else d=n[5],f=n[6],p=n[7],m=n[8],h=n[9],g=n[10],_=n[11],v=n[12];if(g!==Symbol.for(`react.early_return_sentinel`))return g;let y=h,b=f&&m.length>3;if(f){let e;n[33]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(P,{className:`h-4 w-4 shrink-0`}),n[33]=e):e=n[33];let t;n[34]===d?t=n[35]:(t=(0,$.jsxs)(`div`,{className:`px-3 py-2 flex items-center gap-2 text-sm font-medium text-foreground`,children:[e,(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:d})]}),n[34]=d,n[35]=t);let r;n[36]!==b||n[37]!==y||n[38]!==p||n[39]!==m?(r=p&&(0,$.jsxs)(`div`,{className:`px-3 pb-2 bg-background border-t border-border`,children:[(0,$.jsxs)(`pre`,{className:`text-xs bg-muted p-2 rounded font-mono whitespace-pre-wrap overflow-auto text-foreground text-left mt-2${b?` cursor-pointer hover:bg-muted/80`:``}`,onClick:b?()=>c(!0):void 0,title:b?`Click to see full output`:void 0,children:[y,b&&(0,$.jsxs)(`span`,{className:`text-muted-foreground`,children:[`
17
+ `,`...`]})]}),b&&(0,$.jsxs)(`button`,{type:`button`,onClick:()=>c(!0),className:`mt-1 text-xs text-brand hover:underline`,children:[`Show full output (`,m.length,` lines)`]})]}),n[36]=b,n[37]=y,n[38]=p,n[39]=m,n[40]=r):r=n[40];let i;n[41]!==t||n[42]!==r?(i=(0,$.jsxs)(`div`,{className:`mb-3 rounded-lg border border-border bg-muted/50 overflow-hidden`,children:[t,r]}),n[41]=t,n[42]=r,n[43]=i):i=n[43];let a;n[44]!==s||n[45]!==b||n[46]!==p?(a=b&&(0,$.jsx)(W,{open:s,onOpenChange:c,children:(0,$.jsxs)(un,{className:`max-w-3xl max-h-[80vh] flex flex-col`,children:[(0,$.jsx)(E,{children:(0,$.jsx)(De,{children:`Full Output`})}),(0,$.jsx)(`pre`,{className:`text-xs bg-muted p-3 rounded font-mono whitespace-pre-wrap overflow-auto flex-1 text-foreground`,children:p})]})}),n[44]=s,n[45]=b,n[46]=p,n[47]=a):a=n[47];let o;return n[48]!==i||n[49]!==a?(o=(0,$.jsxs)($.Fragment,{children:[i,a]}),n[48]=i,n[49]=a,n[50]=o):o=n[50],o}let x;n[51]===a?x=n[52]:(x=()=>o(!a),n[51]=a,n[52]=x);let S=`${v} result`,C;n[53]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,$.jsx)(P,{className:`h-4 w-4 shrink-0`}),n[53]=C):C=n[53];let w;n[54]===d?w=n[55]:(w=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:d}),n[54]=d,n[55]=w);let T;n[56]===a?T=n[57]:(T=a?(0,$.jsx)(t,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(ze,{className:`h-4 w-4 shrink-0`}),n[56]=a,n[57]=T);let D;n[58]!==x||n[59]!==S||n[60]!==w||n[61]!==T?(D=(0,$.jsxs)(`button`,{onClick:x,className:`w-full px-3 py-2 flex items-center gap-2 text-sm font-medium text-foreground hover:bg-muted transition-colors text-left`,title:S,children:[C,w,T]}),n[58]=x,n[59]=S,n[60]=w,n[61]=T,n[62]=D):D=n[62];let O;n[63]!==a||n[64]!==p||n[65]!==_?(O=a&&(0,$.jsxs)(`div`,{className:`px-3 py-2 bg-background border-t border-border`,children:[(0,$.jsxs)(`div`,{className:`text-xs text-muted-foreground mb-2 font-mono`,children:[`Call ID: `,_]}),p&&(0,$.jsx)(`pre`,{className:`text-xs bg-muted p-2 rounded font-mono whitespace-pre-wrap overflow-auto max-h-48 text-foreground text-left`,children:p})]}),n[63]=a,n[64]=p,n[65]=_,n[66]=O):O=n[66];let k;return n[67]!==O||n[68]!==D?(k=(0,$.jsxs)(`div`,{className:`mb-3 rounded-lg border border-border bg-muted/50 overflow-hidden`,children:[D,O]}),n[67]=O,n[68]=D,n[69]=k):k=n[69],k}function ba(e){let n=(0,Q.c)(22),{text:r,label:i,isStreaming:a,hasContentAfter:o}=e,s=a===void 0?!1:a,c=o===void 0?!1:o,[l,u]=(0,Z.useState)(null),d=(0,Z.useRef)(s),f=(0,Z.useRef)(c),p,m;if(n[0]!==c||n[1]!==s?(p=()=>{(d.current&&!s||!f.current&&c)&&(0,Z.startTransition)(()=>{u(!1)}),d.current=s,f.current=c},m=[s,c,u],n[0]=c,n[1]=s,n[2]=p,n[3]=m):(p=n[2],m=n[3]),(0,Z.useEffect)(p,m),!r?.trim())return null;let h=l??s,g;n[4]===h?g=n[5]:(g=()=>u(!h),n[4]=h,n[5]=g);let _=i??`Thinking`,v;n[6]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(Kt,{className:`h-4 w-4 shrink-0 text-brand`}),n[6]=v):v=n[6];let y=i??`Thinking`,b;n[7]===y?b=n[8]:(b=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:y}),n[7]=y,n[8]=b);let x;n[9]===h?x=n[10]:(x=h?(0,$.jsx)(t,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(ze,{className:`h-4 w-4 shrink-0`}),n[9]=h,n[10]=x);let S;n[11]!==x||n[12]!==g||n[13]!==_||n[14]!==b?(S=(0,$.jsxs)(`button`,{onClick:g,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:_,children:[v,b,x]}),n[11]=x,n[12]=g,n[13]=_,n[14]=b,n[15]=S):S=n[15];let C;n[16]!==h||n[17]!==r?(C=h&&(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:r})}),n[16]=h,n[17]=r,n[18]=C):C=n[18];let w;return n[19]!==S||n[20]!==C?(w=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[S,C]}),n[19]=S,n[20]=C,n[21]=w):w=n[21],w}function xa({toolCall:e,className:n}){let{state:r,dispatch:i}=Xn(),[a,o]=(0,Z.useState)(!1),s=r.toolCallProgress[e.id];return(0,Z.useMemo)(()=>{if(!r.isStreaming)return{isActive:!1,isCompleted:!0};let t=!1,n=!1;for(let i of r.streamingSegments)if(i.type===`thinking`){for(let r of i.chunks)if(r.includes(e.id))try{let i=JSON.parse(r);if(Array.isArray(i))for(let r of i)r.type===`tool_use`&&r.id===e.id&&(t=!0),r.type===`tool-result`&&r.toolCallId===e.id&&(n=!0,t=!1)}catch{}}return t&&!r.isStreaming&&(n=!0,t=!1),{isActive:t,isCompleted:n}},[r.isStreaming,r.streamingSegments,e.id]).isActive?(0,$.jsxs)(`div`,{className:G(`overflow-hidden mb-2`,n),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)(dt,{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:()=>{o(e=>!e)},className:`p-1 hover:bg-muted/50 rounded transition-colors`,title:a?`Collapse`:`Expand`,children:a?(0,$.jsx)(Ie,{className:`h-3.5 w-3.5`}):(0,$.jsx)(t,{className:`h-3.5 w-3.5`})}),(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(`button`,{onClick:()=>{i({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.`};i({type:K.AppendStreamChunk,chunkType:`content`,content:JSON.stringify([t]),segments:r.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)(Ct,{className:`h-3.5 w-3.5`})})}),(0,$.jsx)(q,{className:`bg-red-600 text-white border-red-600`,children:`Stop this process`})]})]})]}),a&&(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)})]}),s&&(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:s.delta}),s.partial?.content?.[0]?.arguments&&typeof s.partial.content[0].arguments==`object`&&`content`in s.partial.content[0].arguments&&typeof s.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: `,s.partial.content[0].arguments.content.slice(-50),s.partial.content[0].arguments.content.length>50&&`...`]})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,$.jsx)(dt,{className:`h-3 w-3 animate-spin`}),`Executing`,s&&` with progress`,`...`]})]})]}):null}function Sa(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 Qe(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)(et,{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)(zt,{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)(Ci,{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)(et,{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 N;t[37]!==s||t[38]!==p?(N=p||!s.trim(),t[37]=s,t[38]=p,t[39]=N):N=t[39];let P;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,$.jsx)(mt,{className:`h-3 w-3`}),t[40]=P):P=t[40];let F;t[41]!==S||t[42]!==N?(F=(0,$.jsx)(`button`,{type:`button`,onClick:S,disabled:N,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:P}),t[41]=S,t[42]=N,t[43]=F):F=t[43];let I;t[44]!==M||t[45]!==F?(I=(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[M,F]}),t[44]=M,t[45]=F,t[46]=I):I=t[46];let L;return t[47]!==I||t[48]!==O||t[49]!==k?(L=(0,$.jsxs)(`div`,{className:`rounded-lg border-t border-border p-4 my-2`,children:[O,k,I]}),t[47]=I,t[48]=O,t[49]=k,t[50]=L):L=t[50],L}function Ca(e){let n=(0,Q.c)(46),{toolCallId:r,intention:i,code:a}=e,{state:o}=Xn(),s=o.selectedThreadId,c;n[0]===r?c=n[1]:(c=cr(r),n[0]=r,n[1]=c);let l=c,[u,d]=(0,Z.useState)(l?.status??`running`),f;n[2]===l?f=n[3]:(f=()=>{if(!l||l.status!==`success`)return null;let e=l.result;return e==null?null:typeof e==`string`?e:JSON.stringify(e,null,2)},n[2]=l,n[3]=f);let[p,m]=(0,Z.useState)(f),[h,g]=(0,Z.useState)(l?.error??null),_,v;n[4]===r?(_=n[5],v=n[6]):(_=()=>sr(r,()=>{let e=cr(r);if(e)if(d(e.status),e.status===`success`){let t=e.result;m(t==null?null:typeof t==`string`?t:JSON.stringify(t,null,2))}else e.status===`error`&&g(e.error??null)}),v=[r],n[4]=r,n[5]=_,n[6]=v),(0,Z.useEffect)(_,v);let y,b;n[7]!==a||n[8]!==s||n[9]!==r?(y=()=>{s&&dr(r,a,s)},b=[r,a,s],n[7]=a,n[8]=s,n[9]=r,n[10]=y,n[11]=b):(y=n[10],b=n[11]),(0,Z.useEffect)(y,b);let[x,S]=(0,Z.useState)(!1),C;n[12]===Symbol.for(`react.memo_cache_sentinel`)?(C=()=>S(wa),n[12]=C):C=n[12];let w=C;if(u===`running`){let e;n[13]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Ae,{className:`h-4 w-4 shrink-0 text-brand animate-pulse`}),n[13]=e):e=n[13];let t=i||`Executing Browser JS...`,r;return n[14]===t?r=n[15]:(r=(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:t})]})}),n[14]=t,n[15]=r),r}if(u===`success`){let e;n[16]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Ae,{className:`h-4 w-4 shrink-0 text-brand`}),n[16]=e):e=n[16];let r=i||`Browser JS Executed Successfully`,o;n[17]===r?o=n[18]:(o=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:r}),n[17]=r,n[18]=o);let s;n[19]===x?s=n[20]:(s=x?(0,$.jsx)(t,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(ze,{className:`h-4 w-4 shrink-0`}),n[19]=x,n[20]=s);let c;n[21]!==o||n[22]!==s?(c=(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,o,s]}),n[21]=o,n[22]=s,n[23]=c):c=n[23];let l;n[24]!==a||n[25]!==x||n[26]!==p?(l=x&&(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:a}),p!=null&&(0,$.jsx)(`pre`,{className:`text-xs text-foreground leading-relaxed whitespace-pre-wrap border-t border-border pt-2`,children:p})]}),n[24]=a,n[25]=x,n[26]=p,n[27]=l):l=n[27];let u;return n[28]!==c||n[29]!==l?(u=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[c,l]}),n[28]=c,n[29]=l,n[30]=u):u=n[30],u}let T;n[31]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(Ae,{className:`h-4 w-4 shrink-0 text-destructive`}),n[31]=T):T=n[31];let E=i||`Browser JS Execution Failed`,D;n[32]===E?D=n[33]:(D=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:E}),n[32]=E,n[33]=D);let O;n[34]===x?O=n[35]:(O=x?(0,$.jsx)(t,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(ze,{className:`h-4 w-4 shrink-0`}),n[34]=x,n[35]=O);let k;n[36]!==D||n[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]}),n[36]=D,n[37]=O,n[38]=k):k=n[38];let A;n[39]!==a||n[40]!==h||n[41]!==x?(A=x&&(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:h}),(0,$.jsx)(`pre`,{className:`text-xs text-muted-foreground leading-relaxed whitespace-pre-wrap`,children:a})]}),n[39]=a,n[40]=h,n[41]=x,n[42]=A):A=n[42];let j;return n[43]!==k||n[44]!==A?(j=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[k,A]}),n[43]=k,n[44]=A,n[45]=j):j=n[45],j}function wa(e){return!e}function Ta(e){let t=[];for(let n of e){if(n.type!==`tool-result`||n.toolName!==`todo`)continue;let e=[n.result,n.content];for(let n of e){let e=[];if(typeof n==`string`)e.push(n);else if(Array.isArray(n))for(let t of n)typeof t==`object`&&t&&`text`in t&&typeof t.text==`string`&&e.push(t.text);for(let n of e)try{let e=JSON.parse(n.trim());e&&Array.isArray(e.todos)&&(t=e.todos)}catch{}}}return t}function Ea(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 Jt(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 g(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)(be,{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 p;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(q,{children:`Save image`}),t[10]=p):p=t[10];let m;t[11]===f?m=t[12]:(m=(0,$.jsxs)(J,{children:[f,p]}),t[11]=f,t[12]=m);let h;t[13]===r?h=t[14]:(h=r?(0,$.jsx)(et,{className:`h-3.5 w-3.5 text-green-500`}):(0,$.jsx)(Ee,{className:`h-3.5 w-3.5`}),t[13]=r,t[14]=h);let _;t[15]!==c||t[16]!==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:h})}),t[15]=c,t[16]=h,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]!==m?(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)(or,{children:[m,b]})}),t[23]=b,t[24]=m,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 Da(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 Oa(e,t,n,r){return e.name===`ask_user`?(0,$.jsx)(Sa,{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)(Ca,{toolCallId:e.id,intention:e.input?.intention??``,code:e.input?.code??``},t):n?(0,$.jsxs)(`span`,{children:[(0,$.jsx)(xa,{toolCall:e}),(0,$.jsx)(sa,{inline:!0,block:e,resultContent:r})]},t):(0,$.jsx)(sa,{inline:!0,block:e,resultContent:r},t)}function ka({message:e,threadId:t}){let n=e.sender===`user`,r=n?null:$n(e.content),[i,a]=(0,Z.useState)(!1),o=e.timestamp?new Date(e.timestamp).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}):``;async function s(){if(!(!e.checkpointRef||!t||i)){a(!0);try{let n=await Ve(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{a(!1)}}}return(0,$.jsxs)(`div`,{className:G(`group flex gap-3 px-4 py-4`,n?`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`,n?`bg-foreground`:`bg-muted`),children:n?(0,$.jsx)(bt,{className:`h-3.5 w-3.5 text-background`}):(0,$.jsx)(Ot,{className:`h-3.5 w-3.5 text-muted-foreground`})}),n&&e.checkpointRef&&(0,$.jsx)(or,{children:(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(`button`,{onClick:s,disabled:i,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)(Be,{className:G(`h-3 w-3`,i&&`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`,n&&`items-end`),children:[(0,$.jsxs)(`div`,{className:G(`flex items-center gap-2`,n&&`flex-row-reverse`),children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:n?`You`:`Agent`}),o&&(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`}),o]}),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)(Ae,{className:`h-2.5 w-2.5`}),kr(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)(j,{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`,n?`bg-foreground text-background`:`bg-muted text-foreground`),children:e.isThinking?(()=>{let t=rr(e.content);return t?.length?t.map((e,n)=>e.type===`tool_use`?Oa(e,n,!1,Da(t,e.id)):e.type===`tool-result`?(0,$.jsx)(ya,{inline:!0,block:e},n):e.type===`reasoning`&&`text`in e?(0,$.jsx)(ba,{text:Qn(e.text),label:e.label},n):null):(0,$.jsx)(`div`,{className:`text-xs text-muted-foreground leading-relaxed whitespace-pre-wrap`,children:(0,$.jsx)(Ci,{content:Qn(e.content),enableMermaid:!0})})})():r?(()=>{let e=Ta(r),t=r.filter(e=>e.type===`tool_use`&&e.name===`ask_user`);return(0,$.jsxs)($.Fragment,{children:[r.map((e,t)=>e.type===`tool_use`&&e.name===`todo`||e.type===`tool-result`&&e.toolName===`todo`?e.type===`tool-result`?(0,$.jsx)(ya,{inline:!0,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)(ba,{text:Qn(e.text),label:e.label}):e.type===`text`&&`text`in e?(0,$.jsx)(Ci,{content:Qn(e.text),enableMermaid:!0}):e.type===`tool_use`?Oa(e,void 0,!1,Da(r,e.id)):e.type===`tool-result`?(0,$.jsx)(ya,{inline:!0,block:e}):null},t)),e.length>0&&(0,$.jsx)(ha,{todos:e}),t.map((e,t)=>(0,$.jsx)(Sa,{toolCallId:e.id,question:JSON.stringify(e.input?.question??``),options:e.input?.options,context:e.input?.context,answeredText:Da(r,e.id)},`ask-${t}`))]})})():(0,$.jsx)(Ci,{content:Qn(e.content),enableMermaid:!0})}),(e.generatedImageUrl||e.generatedImageData)&&(0,$.jsx)(Ea,{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)(qt,{className:`h-2.5 w-2.5`}),e.fileName]},t))})]})]})}function Aa(e){let t=(0,Q.c)(23),{segments:n,model:r,isCreatingProject:i,isProcessingThread:a}=e,o,s,c,l,u;if(t[0]!==i||t[1]!==a||t[2]!==r||t[3]!==n){let e=Zn(n),d=t=>e[t].type===`reasoning`?e.slice(t+1).length>0:!1;l=`group flex gap-3 px-4 py-4`,t[9]===Symbol.for(`react.memo_cache_sentinel`)?(u=(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)(Ot,{className:`h-3.5 w-3.5 text-white`})}),t[9]=u):u=t[9],o=`flex flex-1 flex-col gap-1 min-w-0`;let f;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:`Agent`}),t[10]=f):f=t[10];let p;t[11]===r?p=t[12]:(p=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)(Ae,{className:`h-2.5 w-2.5`}),kr(r)]}),t[11]=r,t[12]=p),t[13]===p?s=t[14]:(s=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[f,p]}),t[13]=p,t[14]=s),c=e.length>0?(()=>{let t=Ta(e),n=e.filter(ja);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)(ya,{inline:!0,block:t},`b-${n}`):null:t.type===`tool_use`&&t.name===`ask_user`?null:(0,$.jsx)(`div`,{children:t.type===`reasoning`&&`text`in t?(0,$.jsx)(ba,{text:Qn(t.text),label:t.label,isStreaming:!0,hasContentAfter:d(n)}):t.type===`text`&&`text`in t?(0,$.jsx)(Ci,{content:Qn(t.text),enableMermaid:!0}):t.type===`tool_use`?Oa(t,void 0,!0,Da(e,t.id)):t.type===`tool-result`?(0,$.jsx)(ya,{inline:!0,block:t}):null},`b-${n}`)),t.length>0&&(0,$.jsx)(ha,{todos:t}),n.map((t,n)=>(0,$.jsx)(Sa,{toolCallId:t.id,question:JSON.stringify(t.input?.question??``),options:t.input?.options,context:t.input?.context,answeredText:Da(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)(ba,{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]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u}else o=t[4],s=t[5],c=t[6],l=t[7],u=t[8];let d;t[15]!==o||t[16]!==s||t[17]!==c?(d=(0,$.jsxs)(`div`,{className:o,children:[s,c]}),t[15]=o,t[16]=s,t[17]=c,t[18]=d):d=t[18];let f;return t[19]!==l||t[20]!==u||t[21]!==d?(f=(0,$.jsxs)(`div`,{className:l,children:[u,d]}),t[19]=l,t[20]=u,t[21]=d,t[22]=f):f=t[22],f}function ja(e){return e.type===`tool_use`&&e.name===`ask_user`}var Ma=(0,Z.memo)(Aa,(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 Na(e){let t=(0,Q.c)(34),{projects:n,onSelectProject:r,onCreateThread:i,onConnectRepo:o,onNewApp:s,onOpenFolder:c}=e,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(`img`,{src:`/tarsk-color.svg`,alt:`Tarsk`,className:`h-16 w-16 rounded-lg`}),t[0]=l):l=t[0];let u;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight text-foreground text-balance`,children:`Let's build it!`}),t[1]=u):u=t[1];let d=n.length===0?`Start or connect your first project`:`Select a project to start coding`,f;t[2]===d?f=t[3]:(f=(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3`,children:[l,(0,$.jsxs)(`div`,{className:`text-center`,children:[u,(0,$.jsx)(`p`,{className:`mt-1 text-base text-muted-foreground`,children:d})]})]}),t[2]=d,t[3]=f);let p;if(t[4]!==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)(yt,{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],p=n.map(e),t[4]=i,t[5]=r,t[6]=n,t[7]=p}else p=t[7];let m,h,g;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(fe,{className:`h-5 w-5 text-muted-foreground`}),h=(0,$.jsx)(`span`,{className:`text-sm text-foreground leading-snug font-medium`,children:`Connect a repo`}),g=(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Clone an existing repository`}),t[11]=m,t[12]=h,t[13]=g):(m=t[11],h=t[12],g=t[13]);let _;t[14]===o?_=t[15]:(_=(0,$.jsxs)(`button`,{type:`button`,className:`flex w-56 flex-col gap-2 rounded-xl border border-border bg-background p-4 text-left shadow-sm transition-colors hover:bg-muted`,onClick:o,children:[m,h,g]}),t[14]=o,t[15]=_);let v,y,b;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(tt,{className:`h-5 w-5 text-muted-foreground`}),y=(0,$.jsx)(`span`,{className:`text-sm text-foreground leading-snug font-medium`,children:`New App`}),b=(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Create a new project from template`}),t[16]=v,t[17]=y,t[18]=b):(v=t[16],y=t[17],b=t[18]);let x;t[19]===s?x=t[20]:(x=(0,$.jsxs)(`button`,{type:`button`,className:`flex w-56 flex-col gap-2 rounded-xl border border-border bg-background p-4 text-left shadow-sm transition-colors hover:bg-muted`,onClick:s,children:[v,y,b]}),t[19]=s,t[20]=x);let S,C,w;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,$.jsx)(a,{className:`h-5 w-5 text-muted-foreground`}),C=(0,$.jsx)(`span`,{className:`text-sm text-foreground leading-snug font-medium`,children:`Open Folder`}),w=(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Use an existing local folder`}),t[21]=S,t[22]=C,t[23]=w):(S=t[21],C=t[22],w=t[23]);let T;t[24]===c?T=t[25]:(T=(0,$.jsxs)(`button`,{type:`button`,className:`flex w-56 flex-col gap-2 rounded-xl border border-border bg-background p-4 text-left shadow-sm transition-colors hover:bg-muted`,onClick:c,children:[S,C,w]}),t[24]=c,t[25]=T);let E;t[26]!==x||t[27]!==T||t[28]!==p||t[29]!==_?(E=(0,$.jsxs)(`div`,{className:`flex flex-wrap justify-center gap-3`,children:[p,_,x,T]}),t[26]=x,t[27]=T,t[28]=p,t[29]=_,t[30]=E):E=t[30];let D;return t[31]!==E||t[32]!==f?(D=(0,$.jsxs)(`div`,{className:`mx-auto flex max-w-3xl flex-1 flex-col items-center justify-center gap-8 px-4`,children:[f,E]}),t[31]=E,t[32]=f,t[33]=D):D=t[33],D}function Pa(e){let t=(0,Q.c)(20),{project:n}=e,{setDevServerRunning:r}=Er(),[i,a]=(0,Z.useState)(!1),{startServer:o}=Ar(),s;t[0]!==n||t[1]!==r?(s=()=>{if(!n?.projectId)return;let e=async()=>{try{let e=await Pe(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 Fa=(0,Z.createContext)(null),Ia=(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});Ia.displayName=`MessageList`;function La(){let e=(0,Q.c)(12),t=(0,Z.useContext)(Fa);if(!t)return null;let{isStreaming:n,isCreatingProject:r,isProcessingThread:i,streamingSegments:a,streamingModel:o,error:s,onClearError:c}=t,l;e[0]!==r||e[1]!==i||e[2]!==n||e[3]!==o||e[4]!==a?(l=(n||r||i)&&(0,$.jsx)(Ma,{segments:a,model:o,isCreatingProject:r,isProcessingThread:i}),e[0]=r,e[1]=i,e[2]=n,e[3]=o,e[4]=a,e[5]=l):l=e[5];let u;e[6]!==s||e[7]!==c?(u=s&&(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:s}),(0,$.jsx)(`button`,{type:`button`,className:`mt-1 text-xs text-destructive underline underline-offset-2 hover:text-destructive/80`,onClick:c,children:`Dismiss`})]}),e[6]=s,e[7]=c,e[8]=u):u=e[8];let d;return e[9]!==l||e[10]!==u?(d=(0,$.jsxs)(`div`,{className:`mx-auto max-w-3xl w-full min-w-0 pb-4`,children:[l,u]}),e[9]=l,e[10]=u,e[11]=d):d=e[11],d}var Ra={List:Ia,Footer:La};function za(e){let t=(0,Q.c)(45),{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)(Na,{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)(Pa,{project:D}),t[22]=D,t[23]=e),e}let O;t[24]!==_||t[25]!==o||t[26]!==s||t[27]!==r||t[28]!==v||t[29]!==a||t[30]!==i?(O={isStreaming:r,isCreatingProject:o,isProcessingThread:s,streamingSegments:i,streamingModel:a,error:_,onClearError:v},t[24]=_,t[25]=o,t[26]=s,t[27]=r,t[28]=v,t[29]=a,t[30]=i,t[31]=O):O=t[31];let k=O,A;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(A=G(`flex-1 overflow-hidden`),t[32]=A):A=t[32];let j;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(j={height:`100%`},t[33]=j):j=t[33];let M;t[34]===c?M=t[35]:(M=(e,t)=>(0,$.jsx)(ka,{message:t,threadId:c}),t[34]=c,t[35]=M);let N;t[36]!==n||t[37]!==M?(N=(0,$.jsx)(zn,{ref:y,style:j,data:n,itemContent:M,overscan:500,components:Ra}),t[36]=n,t[37]=M,t[38]=N):N=t[38];let P;t[39]!==k||t[40]!==N?(P=(0,$.jsx)(Fa.Provider,{value:k,children:N}),t[39]=k,t[40]=N,t[41]=P):P=t[41];let F;return t[42]!==c||t[43]!==P?(F=(0,$.jsx)(`div`,{className:A,children:(0,$.jsx)(la,{children:P},c)}),t[42]=c,t[43]=P,t[44]=F):F=t[44],F}async function Ba(e){return nn(`api/projects/${u(e)}/todos`)}async function Va(e,t){return p(`api/projects/${u(e)}/todos`,{description:t})}async function Ha(e,t,n){return _(`api/projects/${u(e)}/todos/${u(t)}`,n)}async function Ua(e,t){await Ce(`api/projects/${u(e)}/todos/${u(t)}`)}var Wa={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 Ga({todo:e,projectId:t,onUpdate:n,onEdit:r,onAction:i,onThreadSelect:a}){let[o,s]=(0,Z.useState)(!1),c=Wa[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 Ha(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)(dt,{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)(ne,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Open thread`})]})}),(0,$.jsx)(q,{side:`right`,children:`Open thread`})]})]})]})}var Ka=`Please analyze this task and create a detailed implementation plan.
18
+
19
+ Task description:
20
+ {description}`,qa="\nWrite your complete plan to the file `{todoId}-plan.md` in the current directory.",Ja=`Act as a Quality Assurance Manager. Rephrase the task into a rigorous test case: {description}`,Ya=`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}`,Xa={plan:Ka,test:Ja,review:Ya},Za={plan:`planPrompt`,test:`testPrompt`,review:`reviewPrompt`};function Qa(e,t){let n=e?.[Za[t]];return n&&n.trim()?n:Xa[t]}function $a(e,t,n,r){let i=e.replace(/\{description\}/g,r);return t===`plan`&&(i+=qa.replace(/\{todoId\}/g,n)),i}var eo=[`Ready`,`Plan`,`Build`,`Test`,`Review`,`Done`],to={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 no(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 ro(e){let t=e.getReader();try{for(;;){let{done:e}=await t.read();if(e)break}}catch{}}async function io(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 ao({projectId:e,addOpen:t,onAddOpenChange:n,onThreadSelect:r}){let{state:i,dispatch:a}=Xn(),[o,s]=(0,Z.useState)([]),[c,l]=(0,Z.useState)(!0),[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)(``),[m,h]=(0,Z.useState)(!1),[g,_]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(null),[x,S]=(0,Z.useState)(``),[C,w]=(0,Z.useState)(!1),[T,D]=(0,Z.useState)(!1),O=(0,Z.useCallback)(async()=>{try{let t=await Ba(e),n=t.filter(e=>e.threadId&&e.status!==`Done`),r=[...t];await Promise.all(n.map(async t=>{try{await v(t.threadId)}catch(n){if(n instanceof Error&&n.message.includes(`not found`)){let n=await Ha(e,t.id,{status:`Done`}),i=r.findIndex(e=>e.id===t.id);i!==-1&&(r[i]=n);return}}})),s(r)}catch(e){console.error(`Failed to fetch project todos:`,e)}finally{l(!1)}},[e]);(0,Z.useEffect)(()=>{O()},[O]),(0,Z.useEffect)(()=>{if(!o.some(e=>e.working))return;let t=setInterval(async()=>{try{let n=await Ba(e);s(n),n.some(e=>e.working)||clearInterval(t)}catch(e){console.error(`Failed to poll project todos:`,e)}},2e3);return()=>clearInterval(t)},[o,e]),(0,Z.useEffect)(()=>{t&&p(``)},[t]);function k(e){p(e.description),d({todo:e})}function A(){d(null),p(``)}async function j(){if(f.trim()){h(!0);try{let t=await Va(e,f);s(e=>[...e,t]),n(!1),p(``)}finally{h(!1)}}}async function M(){if(!(!f.trim()||!u)){h(!0);try{let t=await Ha(e,u.todo.id,{description:f});s(e=>e.map(e=>e.id===t.id?t:e)),A()}finally{h(!1)}}}async function N(){if(u){h(!0);try{await Ua(e,u.todo.id),s(e=>e.filter(e=>e.id!==u.todo.id)),A()}finally{h(!1)}}}function P(e){s(t=>t.map(t=>t.id===e.id?e:t))}async function F(t){let n=i.selectedThreadId?i.projectModelSelections[i.selectedThreadId]:void 0,r=i.projects.find(t=>t.projectId===e),o=r?.threads.find(e=>e.threadId===i.selectedThreadId),s=n?.id??o?.model,c=n?.provider??o?.modelProvider;if(!s||!c)throw console.error(`No model or provider found for project`,e,o),Error(`No model configuration found. Please configure a model and provider for this project first.`);let l=await ae(e);if(!l)return;let u=null,d=await no(l,n=>{Ha(e,t.id,{status:`Plan`,working:!0,threadId:n}).then(e=>{u=e,P(e)})});if(!d)return;u||P(await Ha(e,t.id,{status:`Plan`,working:!0,threadId:d}));let f=n??{id:s,provider:c,name:s,description:``};a({type:K.SetProjectModel,threadId:d,model:f}),qe(d,{model:s,modelProvider:c});let p=await Pt(d,$a(Qa(r,`plan`),`plan`,t.id,t.description),s,[],void 0,c);p&&ro(p)}async function I(t){let n=await ae(e);if(!n)return;let r=null,i=await no(n,n=>{Ha(e,t.id,{status:`Build`,working:!0,threadId:n}).then(e=>{r=e,P(e)})});if(!i)return;r||P(await Ha(e,t.id,{status:`Build`,working:!0,threadId:i}));let o=await v(i),s=o.model,c=o.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.`);a({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 Pt(i,t.description,s,[],void 0,c);l&&ro(l)}async function L(t){try{let n=await ae(e);if(!n){_(!1),b(null);return}let r=null;if(r=await no(n,e=>{r=e}),!r){_(!1),b(null);return}let a=await v(r),o=a.model,s=a.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){ln(e,r),_(!1),b(null);return}let c=$a(Qa(i.projects.find(t=>t.projectId===e),`test`),`test`,t.id,t.description),l=await Pt(r,c,o,[],void 0,s);l&&S(await io(l)),ln(e,r)}catch(e){console.error(`Failed to generate test case:`,e),_(!1),b(null)}finally{w(!1)}}function R(e){b(e),S(``),w(!0),_(!0),L(e)}function z(){_(!1),b(null),S(``)}async function ee(){if(!y||!x.trim())return;let t=y,n=x;z(),D(!0);try{let r=await ae(e);if(!r)return;let i=null,o=await no(r,n=>{Ha(e,t.id,{status:`Test`,working:!0,threadId:n}).then(e=>{i=e,P(e)})});if(!o)return;i||P(await Ha(e,t.id,{status:`Test`,working:!0,threadId:o}));let s=await v(o),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.`);a({type:K.SetProjectModel,threadId:o,model:{id:c,provider:l,name:c,description:``}}),qe(o,{model:c,modelProvider:l});let u=await Pt(o,n,c,[],void 0,l);u&&ro(u)}finally{D(!1)}}async function te(t){let n=await ae(e);if(!n)return;let r=null,o=await no(n,n=>{Ha(e,t.id,{status:`Review`,working:!0,threadId:n}).then(e=>{r=e,P(e)})});if(!o)return;r||P(await Ha(e,t.id,{status:`Review`,working:!0,threadId:o}));let s=await v(o),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.`);a({type:K.SetProjectModel,threadId:o,model:{id:c,provider:l,name:c,description:``}}),qe(o,{model:c,modelProvider:l});let u=await Pt(o,$a(Qa(i.projects.find(t=>t.projectId===e),`review`),`review`,t.id,t.description),c,[],void 0,l);u&&ro(u)}async function B(t,n){n===`Plan`?await F(t):n===`Build`?await I(t):n===`Test`?R(t):n===`Review`?await te(t):P(await Ha(e,t.id,{status:n,working:n!==`Done`}))}return c?(0,$.jsx)(`div`,{className:`flex items-center justify-center h-64`,children:(0,$.jsx)(dt,{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:eo.map(t=>{let i=o.filter(e=>e.status===t),a=t===`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`,to[t]),children:[(0,$.jsxs)(`div`,{className:`px-3 py-2 flex items-center justify-between`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wide`,children:t}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground bg-muted rounded-full px-1.5 py-0.5`,children:i.length})]}),(0,$.jsx)(St,{className:`flex-1 px-2 pb-2`,children:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[a&&(0,$.jsxs)(U,{variant:`outline`,size:`sm`,className:`w-full h-8 border-dashed text-muted-foreground hover:text-foreground`,onClick:()=>n(!0),children:[(0,$.jsx)(ve,{className:`h-3 w-3 mr-1`}),`Add Task`]}),i.map(t=>(0,$.jsx)(Ga,{todo:t,projectId:e,onUpdate:P,onEdit:k,onAction:B,onThreadSelect:r},t.id))]})})]},t)})}),(0,$.jsx)(W,{open:t,onOpenChange:n,children:(0,$.jsxs)(un,{className:`sm:max-w-2xl`,children:[(0,$.jsx)(E,{children:(0,$.jsx)(De,{children:`Add Task`})}),(0,$.jsxs)(`div`,{className:`py-2`,children:[(0,$.jsx)(ar,{placeholder:`Describe what needs to be done...`,value:f,onChange:e=>p(e.target.value),rows:12,className:`resize-none text-sm`,autoFocus:!0,onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&j()}}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1.5`,children:`A title will be generated automatically from your description.`})]}),(0,$.jsx)(je,{children:(0,$.jsx)(U,{onClick:()=>void j(),disabled:m||!f.trim(),children:m?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(dt,{className:`h-3 w-3 animate-spin mr-1`}),`Generating title...`]}):`Add`})})]})}),(0,$.jsx)(W,{open:g,onOpenChange:e=>!e&&z(),children:(0,$.jsxs)(un,{className:`sm:max-w-2xl`,children:[(0,$.jsx)(E,{children:(0,$.jsx)(De,{children:`Test Case`})}),(0,$.jsx)(`div`,{className:`py-2`,children:C?(0,$.jsxs)(`div`,{className:`flex items-center justify-center h-32 gap-2 text-muted-foreground`,children:[(0,$.jsx)(dt,{className:`h-4 w-4 animate-spin`}),(0,$.jsx)(`span`,{className:`text-sm`,children:`Generating test case...`})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ar,{value:x,onChange:e=>S(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)(je,{children:[(0,$.jsx)(U,{variant:`outline`,onClick:z,disabled:C,children:`Cancel`}),(0,$.jsx)(U,{onClick:()=>void ee(),disabled:C||!x.trim()||T,children:T?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(dt,{className:`h-3 w-3 animate-spin mr-1`}),`Starting...`]}):`Confirm`})]})]})}),(0,$.jsx)(W,{open:u!==null,onOpenChange:e=>!e&&A(),children:(0,$.jsxs)(un,{className:`sm:max-w-2xl`,children:[(0,$.jsx)(E,{children:(0,$.jsx)(De,{children:`Edit Task`})}),(0,$.jsx)(`div`,{className:`py-2`,children:(0,$.jsx)(ar,{placeholder:`Describe what needs to be done...`,value:f,onChange:e=>p(e.target.value),rows:12,className:`resize-none text-sm`,autoFocus:!0,onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&M()}})}),(0,$.jsxs)(je,{className:`gap-2 sm:gap-0`,children:[(0,$.jsx)(U,{variant:`destructive`,onClick:()=>void N(),disabled:m,className:`mr-auto`,children:`Delete`}),(0,$.jsx)(U,{onClick:()=>void M(),disabled:m||!f.trim(),children:m?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(dt,{className:`h-3 w-3 animate-spin mr-1`}),`Saving...`]}):`Save`})]})]})})]})}var oo=[{value:`plan`,label:`Plan`,field:`planPrompt`,defaultPrompt:Ka},{value:`review`,label:`Code Review`,field:`reviewPrompt`,defaultPrompt:Ya},{value:`test`,label:`Test`,field:`testPrompt`,defaultPrompt:Ja}];function so({open:e,onOpenChange:t,projectId:n}){let{state:r}=Xn(),[i,a]=(0,Z.useState)({plan:``,review:``,test:``}),[o,s]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{if(!e)return;let t=r.projects.find(e=>e.projectId===n);a({plan:t?.planPrompt??``,review:t?.reviewPrompt??``,test:t?.testPrompt??``})},[e,n,r.projects]);async function c(){s(!0);try{await ft(n,{planPrompt:i.plan.trim()===Ka?null:i.plan.trim()||null,testPrompt:i.test.trim()===Ja?null:i.test.trim()||null,reviewPrompt:i.review.trim()===Ya?null:i.review.trim()||null}),ke(),X({title:`AI prompt settings saved`}),t(!1)}catch(e){X({title:`Error`,description:e instanceof Error?e.message:`Failed to save prompt settings`,variant:`destructive`})}finally{s(!1)}}function u(e,t){a(n=>({...n,[e]:t}))}return(0,$.jsx)(W,{open:e,onOpenChange:t,children:(0,$.jsxs)(un,{className:`max-w-2xl`,children:[(0,$.jsxs)(E,{children:[(0,$.jsx)(De,{children:`AI Prompt Settings`}),(0,$.jsx)(l,{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)(Fr,{defaultValue:`plan`,className:`w-full`,children:[(0,$.jsx)(Pr,{className:`w-full`,children:oo.map(e=>(0,$.jsx)(Mr,{value:e.value,className:`flex-1`,children:e.label},e.value))}),oo.map(e=>(0,$.jsxs)(Nr,{value:e.value,children:[(0,$.jsx)(ar,{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)(je,{children:(0,$.jsx)(U,{onClick:()=>void c(),disabled:o,children:o?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(dt,{className:`mr-2 h-4 w-4 animate-spin`}),`Saving...`]}):`Save`})})]})})}function co({projectId:e}){let{state:t,dispatch:n}=Xn(),{projects:r}=t,[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(!1),c=Pn(),{setActiveMainTab:l}=Er();async function u(i){if(r.find(t=>t.projectId===e)){c(`/`),l(`chat`);try{let{getProjects:r,invalidateProjectsCache:a}=await Wn(async()=>{let{getProjects:e,invalidateProjectsCache:t}=await import(`./dialogs-config-Dwpv4SNp.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 en();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 en();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)(ao,{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)(w,{className:`h-4 w-4`})}),(0,$.jsx)(so,{open:o,onOpenChange:s,projectId:e})]})}var lo=(0,Z.lazy)(()=>Wn(()=>import(`./diff-view-B8Grak1p.js`),__vite__mapDeps([10,1,5,6,2,7,11,12,13,14,15,16,17,18,19,8,20]))),uo=(0,Z.lazy)(()=>Wn(()=>import(`./dialogs-config-Dwpv4SNp.js`).then(e=>e.t),__vite__mapDeps([2,1])));function fo(e){let t=(0,Q.c)(49),{onCreateThread:n}=e,{state:r,dispatch:a}=Xn(),o=Pn(),s=Fn(),[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}=r,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]!==r.sidebarOpen?(C=()=>{r.sidebarOpen&&a({type:K.ToggleSidebar})},t[3]=a,t[4]=r.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 xt(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 i(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 te(),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}=r,ee;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?(ee=I&&z?(0,$.jsx)(co,{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)(lo,{threadId:f,onExit:R})}):(0,$.jsx)(za,{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:po}),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]=ee):ee=t[35];let B;t[36]!==p||t[37]!==F||t[38]!==f||t[39]!==I?(B=!F&&!I&&f&&(0,$.jsx)(fr,{messages:p}),t[36]=p,t[37]=F,t[38]=f,t[39]=I,t[40]=B):B=t[40];let ne=u??void 0,re;t[41]!==c||t[42]!==P||t[43]!==ne?(re=(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(uo,{open:c,onOpenChange:l,initialMode:ne,onSubmitClone:A,onSubmitWebApp:M,onOpenFolder:P})}),t[41]=c,t[42]=P,t[43]=ne,t[44]=re):re=t[44];let ie;return t[45]!==B||t[46]!==re||t[47]!==ee?(ie=(0,$.jsxs)(`div`,{className:`flex h-full flex-col`,children:[ee,B,re]}),t[45]=B,t[46]=re,t[47]=ee,t[48]=ie):ie=t[48],ie}function po(){}var mo=_n,ho=Vn,go=An,_o=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)(ze,{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)(yn,{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});_o.displayName=yn.displayName;var vo=Z.forwardRef((e,t)=>{let n=(0,Q.c)(9),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=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)(gn,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});vo.displayName=gn.displayName;var yo=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)(Yn,{children:(0,$.jsx)(wn,{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});yo.displayName=wn.displayName;var bo=Z.forwardRef((e,t)=>{let n=(0,Q.c)(11),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({className:r,inset:i,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o=i&&`pl-8`,s;n[4]!==r||n[5]!==o?(s=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)(vn,{ref:t,className:s,...a}),n[7]=a,n[8]=t,n[9]=s,n[10]=c):c=n[10],c});bo.displayName=vn.displayName;var xo=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)(bn,{children:(0,$.jsx)(et,{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)(Sn,{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});xo.displayName=Sn.displayName;var So=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)(bn,{children:(0,$.jsx)(R,{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)(kn,{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});So.displayName=kn.displayName;var Co=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)(En,{ref:t,className:s,...a}),n[7]=a,n[8]=t,n[9]=s,n[10]=c):c=n[10],c});Co.displayName=En.displayName;var wo=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)(On,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});wo.displayName=On.displayName;var To=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};To.displayName=`DropdownMenuShortcut`;var Eo=`VS Code`,Do={"VS Code":`vscode`,Cursor:`cursor`,Windsurf:`windsurf`,Xcode:`xcode`,"Android Studio":`android-studio`,Kiro:`kiro`,Terminal:`terminal`};function Oo({projectId:e,threadId:n,openWith:r}){let[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)([]),[c,l]=(0,Z.useState)(r??Eo),[u,d]=(0,Z.useState)(!0);(0,Z.useEffect)(()=>{(async()=>{try{let e=await rt();s(e),!c&&e.length>0&&l(e[0])}catch(e){console.error(`Failed to fetch available programs:`,e),s([Eo])}finally{d(!1)}})()},[]),(0,Z.useEffect)(()=>{r&&o.includes(r)&&l(r)},[r,o,l]);let f=async t=>{try{a(!0),l(t),await Ue(e,t),n?await L(n,t):await Ht(e,t),X({title:`Success`,description:`Opened project in ${t}`})}catch(e){console.error(`Failed to open project in ${t}:`,e);let n=`Failed to open project in ${t}`;if(e instanceof Error){let t=e;n=t.details?t.details:e.message}X({title:`Error`,description:n,variant:`destructive`})}finally{a(!1)}};return u?(0,$.jsx)(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:i,onClick:async()=>{await f(c)},title:`Open in ${c}`,children:(0,$.jsx)(`img`,{src:`/ide/${Do[c]||Do[Eo]}.svg`,alt:c,className:`h-4 w-4`})}),(0,$.jsxs)(mo,{children:[(0,$.jsx)(ho,{asChild:!0,children:(0,$.jsx)(U,{variant:`outline`,size:`sm`,className:`h-8 w-8 rounded-l-none px-1 border-transparent`,disabled:i,children:(0,$.jsx)(t,{className:`h-3.5 w-3.5`})})}),(0,$.jsx)(yo,{align:`end`,children:o.map(e=>(0,$.jsxs)(bo,{onClick:()=>f(e),disabled:i,className:`flex items-center gap-2`,children:[(0,$.jsx)(`img`,{src:`/ide/${Do[e]||Do[Eo]}.svg`,alt:e,className:`h-4 w-4`}),e]},e))})]})]})}function ko(e,t){return t?`Creating PR...`:e.status===`Behind`&&!e.hasChanges&&!e.hasUnpushedCommits?`Sync`:e.hasChanges?`Commit`:e.prExists&&e.prState===`OPEN`&&!e.hasChanges&&!e.hasUnpushedCommits?`Open PR`:e.commitsAheadOfDefault&&!e.prExists&&!e.hasChanges?`Create PR`:e.hasUnpushedCommits&&e.prExists?`Update PR`:`Commit`}function Ao(e,t){return t?(0,$.jsx)(dt,{className:`h-3.5 w-3.5 animate-spin`}):e.status===`Behind`&&!e.hasChanges&&!e.hasUnpushedCommits?(0,$.jsx)(Mt,{className:`h-3.5 w-3.5`}):e.hasChanges?(0,$.jsx)(f,{className:`h-3.5 w-3.5`}):e.prExists&&e.prState===`OPEN`&&!e.hasChanges&&!e.hasUnpushedCommits?(0,$.jsx)(ne,{className:`h-3.5 w-3.5`}):(0,$.jsx)(we,{className:`h-3.5 w-3.5`})}function jo(e){return e.status===`Behind`&&!e.hasChanges&&!e.hasUnpushedCommits?`Your branch "${e.currentBranch}" is behind "${e.defaultBranch??`main`}". This will rebase and sync with the latest changes`:e.hasChanges?e.changedFilesCount>0?`Commit ${e.changedFilesCount} changed file${e.changedFilesCount===1?``:`s`}`:`No changes to commit`:e.prExists&&e.prState===`OPEN`&&!e.hasChanges&&!e.hasUnpushedCommits?`View pull request in GitHub`:e.commitsAheadOfDefault&&!e.prExists&&!e.hasChanges?`Create pull request for committed changes`:e.hasUnpushedCommits&&e.prExists?`Update pull request with unpushed commits`:`No actions available`}function Mo(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 No(e){return e.hasChanges||e.status===`Behind`&&!e.hasChanges&&!e.hasUnpushedCommits||e.commitsAheadOfDefault&&!e.prExists&&!e.hasChanges}function Po(e){let n=(0,Q.c)(102),{branchStatus:r,currentBranch:i,remoteUrl:a,hasRemoteBranch:o,hasUnpushedCommits:s,canCreateRepo:c,repoUrl:l,isRefreshing:u,isBrandState:d,gitUser:f,availableBranches:p,isLoadingBranches:m,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${d?` bg-brand text-brand-foreground hover:bg-brand/90 hover:text-brand-foreground`:``}`,k;n[0]===u?k=n[1]:(k=u?(0,$.jsx)(dt,{className:`h-3.5 w-3.5 animate-spin`}):(0,$.jsx)(t,{className:`h-3.5 w-3.5`}),n[0]=u,n[1]=k);let A;n[2]!==v||n[3]!==O||n[4]!==k?(A=(0,$.jsx)(ho,{asChild:!0,children:(0,$.jsx)(U,{variant:`outline`,size:`sm`,className:O,disabled:v,children:k})}),n[2]=v,n[3]=O,n[4]=k,n[5]=A):A=n[5];let j;n[6]===h?j=n[7]:(j=async e=>{e&&await h()},n[6]=h,n[7]=j);let M;n[8]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,$.jsx)(fe,{className:`h-3 w-3 shrink-0`}),n[8]=M):M=n[8];let N=i||`Unknown`,P;n[9]===N?P=n[10]:(P=(0,$.jsxs)(_o,{className:`gap-2 text-xs`,children:[M,(0,$.jsx)(`span`,{className:`font-medium`,children:N})]}),n[9]=N,n[10]=P);let F;n[11]!==p||n[12]!==i||n[13]!==v||n[14]!==m||n[15]!==g?(F=m?(0,$.jsxs)(`div`,{className:`px-2 py-1.5 text-xs text-muted-foreground flex items-center gap-2`,children:[(0,$.jsx)(dt,{className:`h-3 w-3 animate-spin`}),`Loading branches…`]}):p.length===0?(0,$.jsx)(`div`,{className:`px-2 py-1.5 text-xs text-muted-foreground`,children:`No branches found`}):p.map(e=>(0,$.jsxs)(bo,{disabled:e===i||v,onClick:()=>void g(e),children:[(0,$.jsx)(fe,{className:`h-3.5 w-3.5 mr-2 shrink-0`}),(0,$.jsx)(`span`,{className:e===i?`font-semibold text-foreground`:``,children:e}),e===i&&(0,$.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:`current`})]},e)),n[11]=p,n[12]=i,n[13]=v,n[14]=m,n[15]=g,n[16]=F):F=n[16];let I;n[17]===F?I=n[18]:(I=(0,$.jsx)(vo,{children:F}),n[17]=F,n[18]=I);let L;n[19]!==j||n[20]!==P||n[21]!==I?(L=(0,$.jsxs)(go,{onOpenChange:j,children:[P,I]}),n[19]=j,n[20]=P,n[21]=I,n[22]=L):L=n[22];let R;n[23]!==r||n[24]!==a?(R=r===`Behind`&&(0,$.jsxs)(`div`,{className:`px-2 py-1 text-xs text-amber-600`,children:[`Branch is behind `,a?`origin`:`remote`]}),n[23]=r,n[24]=a,n[25]=R):R=n[25];let z;n[26]===f?z=n[27]:(z=f&&(0,$.jsxs)(`div`,{className:`px-2 py-1 text-xs text-muted-foreground`,children:[(0,$.jsx)(`span`,{className:`font-medium`,children:`User:`}),` `,f]}),n[26]=f,n[27]=z);let ee;n[28]===Symbol.for(`react.memo_cache_sentinel`)?(ee=(0,$.jsx)(wo,{}),n[28]=ee):ee=n[28];let te;n[29]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,$.jsx)(be,{className:`h-3.5 w-3.5 mr-2`}),n[29]=te):te=n[29];let B;n[30]!==v||n[31]!==b?(B=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(bo,{onClick:b,disabled:v,children:[te,`Fetch`]})}),n[30]=v,n[31]=b,n[32]=B):B=n[32];let re;n[33]===Symbol.for(`react.memo_cache_sentinel`)?(re=(0,$.jsx)(q,{side:`right`,children:`Download latest information from remote without merging changes`}),n[33]=re):re=n[33];let ie;n[34]===B?ie=n[35]:(ie=(0,$.jsx)(or,{children:(0,$.jsxs)(J,{children:[B,re]})}),n[34]=B,n[35]=ie);let ae;n[36]!==o||n[37]!==v||n[38]!==x?(ae=()=>{o&&!v&&x()},n[36]=o,n[37]=v,n[38]=x,n[39]=ae):ae=n[39];let V=!o||v?`opacity-50 cursor-not-allowed`:``,se;n[40]===Symbol.for(`react.memo_cache_sentinel`)?(se=(0,$.jsx)(Mt,{className:`h-3.5 w-3.5 mr-2`}),n[40]=se):se=n[40];let ce;n[41]!==ae||n[42]!==V?(ce=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(bo,{onClick:ae,className:V,children:[se,`Pull`]})}),n[41]=ae,n[42]=V,n[43]=ce):ce=n[43];let H=o?`Pull latest changes from remote`:`No remote branch to pull from`,le;n[44]===H?le=n[45]:(le=(0,$.jsx)(q,{side:`right`,children:H}),n[44]=H,n[45]=le);let ue;n[46]!==ce||n[47]!==le?(ue=(0,$.jsx)(or,{children:(0,$.jsxs)(J,{children:[ce,le]})}),n[46]=ce,n[47]=le,n[48]=ue):ue=n[48];let de;n[49]!==o||n[50]!==v||n[51]!==S?(de=!o&&(0,$.jsx)(or,{children:(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(bo,{onClick:S,disabled:v,children:[(0,$.jsx)(oe,{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`})]})}),n[49]=o,n[50]=v,n[51]=S,n[52]=de):de=n[52];let pe;n[53]!==s||n[54]!==v||n[55]!==S?(pe=()=>{s&&!v&&S()},n[53]=s,n[54]=v,n[55]=S,n[56]=pe):pe=n[56];let me=!s||v?`opacity-50 cursor-not-allowed`:``,he;n[57]===Symbol.for(`react.memo_cache_sentinel`)?(he=(0,$.jsx)(oe,{className:`h-3.5 w-3.5 mr-2`}),n[57]=he):he=n[57];let ge;n[58]!==pe||n[59]!==me?(ge=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(bo,{onClick:pe,className:me,children:[he,`Push Commits`]})}),n[58]=pe,n[59]=me,n[60]=ge):ge=n[60];let _e=s?v?`Push in progress...`:`Push your uncommitted commits to the remote branch`:`No commits to push - your branch is up to date with remote`,ve;n[61]===_e?ve=n[62]:(ve=(0,$.jsx)(q,{side:`right`,children:_e}),n[61]=_e,n[62]=ve);let ye;n[63]!==ge||n[64]!==ve?(ye=(0,$.jsx)(or,{children:(0,$.jsxs)(J,{children:[ge,ve]})}),n[63]=ge,n[64]=ve,n[65]=ye):ye=n[65];let W=v||y,xe;n[66]===Symbol.for(`react.memo_cache_sentinel`)?(xe=(0,$.jsx)(on,{className:`h-3.5 w-3.5 mr-2`}),n[66]=xe):xe=n[66];let Se;n[67]!==C||n[68]!==W?(Se=(0,$.jsxs)(bo,{onClick:C,disabled:W,children:[xe,`History`]}),n[67]=C,n[68]=W,n[69]=Se):Se=n[69];let Ce;n[70]===Symbol.for(`react.memo_cache_sentinel`)?(Ce=(0,$.jsx)(fe,{className:`h-3.5 w-3.5 mr-2`}),n[70]=Ce):Ce=n[70];let Te;n[71]!==v||n[72]!==w?(Te=(0,$.jsxs)(bo,{onClick:w,disabled:v,children:[Ce,`New Branch`]}),n[71]=v,n[72]=w,n[73]=Te):Te=n[73];let Ee;n[74]!==_||n[75]!==v||n[76]!==T?(Ee=!_&&(0,$.jsxs)(bo,{onClick:T,disabled:v,children:[(0,$.jsx)(we,{className:`h-3.5 w-3.5 mr-2`}),`Create Pull Request`]}),n[74]=_,n[75]=v,n[76]=T,n[77]=Ee):Ee=n[77];let De;n[78]!==c||n[79]!==v||n[80]!==E?(De=c&&(0,$.jsxs)(bo,{onClick:E,disabled:v,children:[(0,$.jsx)(tn,{className:`h-3.5 w-3.5 mr-2`}),`Create Repo`]}),n[78]=c,n[79]=v,n[80]=E,n[81]=De):De=n[81];let Oe;n[82]!==v||n[83]!==D||n[84]!==l?(Oe=l&&(0,$.jsxs)(bo,{onClick:D,disabled:v,children:[(0,$.jsx)(ne,{className:`h-3.5 w-3.5 mr-2`}),`View in GitHub`]}),n[82]=v,n[83]=D,n[84]=l,n[85]=Oe):Oe=n[85];let ke;n[86]!==L||n[87]!==R||n[88]!==z||n[89]!==ie||n[90]!==ue||n[91]!==de||n[92]!==ye||n[93]!==Se||n[94]!==Te||n[95]!==Ee||n[96]!==De||n[97]!==Oe?(ke=(0,$.jsxs)(yo,{align:`end`,children:[L,R,z,ee,ie,ue,de,ye,Se,Te,Ee,De,Oe]}),n[86]=L,n[87]=R,n[88]=z,n[89]=ie,n[90]=ue,n[91]=de,n[92]=ye,n[93]=Se,n[94]=Te,n[95]=Ee,n[96]=De,n[97]=Oe,n[98]=ke):ke=n[98];let Ae;return n[99]!==A||n[100]!==ke?(Ae=(0,$.jsxs)(mo,{children:[A,ke]}),n[99]=A,n[100]=ke,n[101]=Ae):Ae=n[101],Ae}function Fo(){return{autoGenerateCommitMessage:it(),autoGeneratePRInfo:It(),privateRepositoryDefault:ut()}}function Io(e){e.autoGenerateCommitMessage!==void 0&&st(e.autoGenerateCommitMessage),e.autoGeneratePRInfo!==void 0&&He(e.autoGeneratePRInfo),e.privateRepositoryDefault!==void 0&&Qt(e.privateRepositoryDefault)}function Lo(e){return e?!0:(X({title:`Error`,description:`No thread selected`,variant:`destructive`}),!1)}function Ro(e){let t=(0,Q.c)(57),{open:n,onOpenChange:r,commitMessage:i,onCommitMessageChange:a,autoGenerateCommitMessage:o,onAutoGenerateChange:s,isGeneratingMessage:c,isLoading:u,onGenerateMessage:d,onCommit:f,currentBranch:p}=e,m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(De,{children:`Commit Changes`}),t[0]=m):m=t[0];let h;t[1]===p?h=t[2]:(h=(0,$.jsxs)(E,{children:[m,(0,$.jsxs)(l,{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)(V,{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)(ar,{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=c||u,b;t[9]===c?b=t[10]:(b=c?(0,$.jsx)(dt,{className:`h-3.5 w-3.5 animate-spin`}):(0,$.jsx)(Oe,{className:`h-3.5 w-3.5`}),t[9]=c,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=c?`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 w;t[17]!==C||t[18]!==x?(w=(0,$.jsx)(or,{children:(0,$.jsxs)(J,{children:[x,C]})}),t[17]=C,t[18]=x,t[19]=w):w=t[19];let T;t[20]!==w||t[21]!==v?(T=(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[g,(0,$.jsxs)(`div`,{className:`relative`,children:[v,w]})]}),t[20]=w,t[21]=v,t[22]=T):T=t[22];let D;t[23]===s?D=t[24]:(D=e=>s(e===!0),t[23]=s,t[24]=D);let O;t[25]!==o||t[26]!==D?(O=(0,$.jsx)(Or,{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)(V,{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]!==T||t[32]!==A?(j=(0,$.jsxs)(`div`,{className:`grid gap-4 py-4`,children:[T,A]}),t[31]=T,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)(je,{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)(un,{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)(W,{open:n,onOpenChange:r,children:R}),t[53]=r,t[54]=n,t[55]=R,t[56]=z):z=t[56],z}function zo(e){let t=(0,Q.c)(62),{open:n,onOpenChange:r,prTitle:i,onPrTitleChange:a,prDescription:o,onPrDescriptionChange:s,isGeneratingPRInfo:c,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)(De,{children:`Create Pull Request`}),t[0]=g):g=t[0];let _;t[1]===p?_=t[2]:(_=(0,$.jsxs)(E,{children:[g,(0,$.jsxs)(l,{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)(V,{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)(H,{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)(V,{htmlFor:`pr-description`,children:`Description (optional)`}),t[10]=S):S=t[10];let C;t[11]===s?C=t[12]:(C=e=>s(e.target.value),t[11]=s,t[12]=C);let w;t[13]!==o||t[14]!==C?(w=(0,$.jsx)(ar,{id:`pr-description`,placeholder:`Enter PR description...`,value:o,onChange:C,rows:4,className:`pr-10`}),t[13]=o,t[14]=C,t[15]=w):w=t[15];let T=c||u,D;t[16]===c?D=t[17]:(D=c?(0,$.jsx)(dt,{className:`h-3.5 w-3.5 animate-spin`}):(0,$.jsx)(Oe,{className:`h-3.5 w-3.5`}),t[16]=c,t[17]=D);let O;t[18]!==d||t[19]!==T||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:T,children:D})}),t[18]=d,t[19]=T,t[20]=D,t[21]=O):O=t[21];let k=c?`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)(or,{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]!==w?(M=(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[S,(0,$.jsxs)(`div`,{className:`relative`,children:[w,j]})]}),t[27]=j,t[28]=w,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)(Or,{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)(V,{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`,te;t[47]!==u||t[48]!==f||t[49]!==ee?(te=(0,$.jsx)(U,{onClick:f,disabled:u,children:ee}),t[47]=u,t[48]=f,t[49]=ee,t[50]=te):te=t[50];let B;t[51]!==z||t[52]!==te?(B=(0,$.jsxs)(je,{children:[z,te]}),t[51]=z,t[52]=te,t[53]=B):B=t[53];let ne;t[54]!==_||t[55]!==L||t[56]!==B?(ne=(0,$.jsxs)(un,{children:[_,L,B]}),t[54]=_,t[55]=L,t[56]=B,t[57]=ne):ne=t[57];let re;return t[58]!==r||t[59]!==n||t[60]!==ne?(re=(0,$.jsx)(W,{open:n,onOpenChange:r,children:ne}),t[58]=r,t[59]=n,t[60]=ne,t[61]=re):re=t[61],re}function Bo(e){let t=(0,Q.c)(48),{open:n,onOpenChange:r,repoName:i,onRepoNameChange:a,repoDescription:o,onRepoDescriptionChange:s,isPrivateRepo:c,onPrivateRepoChange:u,isLoading:d,onCreateRepo:f}=e,p;t[0]!==r||t[1]!==s||t[2]!==a?(p=e=>{e||(a(``),s(``)),r(e)},t[0]=r,t[1]=s,t[2]=a,t[3]=p):p=t[3];let m;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsxs)(E,{children:[(0,$.jsx)(De,{children:`Create GitHub Repository`}),(0,$.jsx)(l,{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)(V,{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)(H,{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)(V,{htmlFor:`repo-description`,children:`Description (optional)`}),t[11]=v):v=t[11];let y;t[12]===s?y=t[13]:(y=e=>s(e.target.value),t[12]=s,t[13]=y);let b;t[14]!==o||t[15]!==y?(b=(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[v,(0,$.jsx)(ar,{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]!==c||t[20]!==x?(S=(0,$.jsx)(Or,{id:`repo-private`,checked:c,onCheckedChange:x}),t[19]=c,t[20]=x,t[21]=S):S=t[21];let C;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,$.jsx)(V,{htmlFor:`repo-private`,className:`text-sm font-normal`,children:`Private repository`}),t[22]=C):C=t[22];let w;t[23]===S?w=t[24]:(w=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[S,C]}),t[23]=S,t[24]=w);let T;t[25]!==w||t[26]!==_||t[27]!==b?(T=(0,$.jsxs)(`div`,{className:`grid gap-4 py-4`,children:[_,b,w]}),t[25]=w,t[26]=_,t[27]=b,t[28]=T):T=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)(je,{children:[O,A]}),t[38]=O,t[39]=A,t[40]=j):j=t[40];let M;t[41]!==T||t[42]!==j?(M=(0,$.jsxs)(un,{children:[m,T,j]}),t[41]=T,t[42]=j,t[43]=M):M=t[43];let N;return t[44]!==n||t[45]!==p||t[46]!==M?(N=(0,$.jsx)(W,{open:n,onOpenChange:p,children:M}),t[44]=n,t[45]=p,t[46]=M,t[47]=N):N=t[47],N}function Vo(e){let t=(0,Q.c)(28),{open:n,onOpenChange:r,commits:i,displayedCommits:a,isLoadingMore:o,onScroll:s,currentBranch:c}=e,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(De,{children:`Commit History`}),t[0]=u):u=t[0];let d;t[1]===c?d=t[2]:(d=(0,$.jsxs)(E,{children:[u,(0,$.jsxs)(l,{children:[`Recent commits on branch `,c]})]}),t[1]=c,t[2]=d);let f;t[3]===a?f=t[4]:(f=a.length>0?a.map(Ho):(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)(dt,{className:`h-4 w-4 animate-spin inline`})}),t[5]=o,t[6]=p);let m;t[7]!==i.length||t[8]!==a.length||t[9]!==o?(m=a.length<i.length&&!o&&(0,$.jsx)(`div`,{className:`p-3 text-center text-xs text-slate-500`,children:`Scroll to load more`}),t[7]=i.length,t[8]=a.length,t[9]=o,t[10]=m):m=t[10];let h;t[11]!==f||t[12]!==p||t[13]!==m?(h=(0,$.jsxs)(`div`,{className:`divide-y`,children:[f,p,m]}),t[11]=f,t[12]=p,t[13]=m,t[14]=h):h=t[14];let g;t[15]!==s||t[16]!==h?(g=(0,$.jsx)(`div`,{className:`flex-1 overflow-y-auto border rounded-lg`,onScroll:s,children:h}),t[15]=s,t[16]=h,t[17]=g):g=t[17];let _;t[18]===r?_=t[19]:(_=(0,$.jsx)(je,{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)(un,{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)(W,{open:n,onOpenChange:r,children:v}),t[24]=r,t[25]=n,t[26]=v,t[27]=y):y=t[27],y}function Ho(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 Uo(e){let t=(0,Q.c)(15),{open:n,onOpenChange:r,isLoading:i,onPushAndCreatePR:a,onCancel:o}=e,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsxs)(E,{children:[(0,$.jsx)(De,{children:`Push Branch First`}),(0,$.jsx)(l,{children:`Your branch needs to be pushed to the remote before creating a pull request. Would you like to push it now?`})]}),t[0]=s):s=t[0];let c;t[1]!==i||t[2]!==o?(c=(0,$.jsx)(U,{variant:`outline`,onClick:o,disabled:i,children:`Cancel`}),t[1]=i,t[2]=o,t[3]=c):c=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]!==c||t[9]!==d?(f=(0,$.jsxs)(un,{children:[s,(0,$.jsxs)(je,{children:[c,d]})]}),t[8]=c,t[9]=d,t[10]=f):f=t[10];let p;return t[11]!==r||t[12]!==n||t[13]!==f?(p=(0,$.jsx)(W,{open:n,onOpenChange:r,children:f}),t[11]=r,t[12]=n,t[13]=f,t[14]=p):p=t[14],p}function Wo(e){let t=(0,Q.c)(27),{open:n,onOpenChange:r,onCommitFirst:i,onStashAndPull:a,onCancel:o,isLoading:s}=e,c=s===void 0?!1:s,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsxs)(E,{children:[(0,$.jsxs)(De,{className:`flex items-center gap-2`,children:[(0,$.jsx)(le,{className:`h-5 w-5 text-amber-500`}),`Uncommitted Changes Detected`]}),(0,$.jsx)(l,{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 p;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(f,{className:`h-4 w-4 mr-2`}),t[2]=p):p=t[2];let m;t[3]!==c||t[4]!==i?(m=(0,$.jsxs)(U,{onClick:i,disabled:c,className:`w-full justify-start`,variant:`outline`,children:[p,`Commit changes first, then pull`]}),t[3]=c,t[4]=i,t[5]=m):m=t[5];let h;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(ht,{className:`h-4 w-4 mr-2`}),t[6]=h):h=t[6];let g;t[7]!==c||t[8]!==a?(g=(0,$.jsxs)(U,{onClick:a,disabled:c,className:`w-full justify-start`,variant:`outline`,children:[h,`Stash changes → Pull → Restore changes`]}),t[7]=c,t[8]=a,t[9]=g):g=t[9];let _;t[10]!==m||t[11]!==g?(_=(0,$.jsxs)(`div`,{className:`space-y-2`,children:[m,g]}),t[10]=m,t[11]=g,t[12]=_):_=t[12];let v;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(`strong`,{children:`Commit first:`}),t[13]=v):v=t[13];let y;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsxs)(`div`,{className:`text-xs text-muted-foreground mt-4`,children:[v,` 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]=y):y=t[14];let b;t[15]===_?b=t[16]:(b=(0,$.jsx)(`div`,{className:`py-4`,children:(0,$.jsxs)(`div`,{className:`space-y-3`,children:[d,_,y]})}),t[15]=_,t[16]=b);let x;t[17]!==c||t[18]!==o?(x=(0,$.jsx)(je,{children:(0,$.jsx)(U,{variant:`ghost`,onClick:o,disabled:c,children:`Cancel`})}),t[17]=c,t[18]=o,t[19]=x):x=t[19];let S;t[20]!==b||t[21]!==x?(S=(0,$.jsxs)(un,{className:`sm:max-w-[425px]`,children:[u,b,x]}),t[20]=b,t[21]=x,t[22]=S):S=t[22];let C;return t[23]!==r||t[24]!==n||t[25]!==S?(C=(0,$.jsx)(W,{open:n,onOpenChange:r,children:S}),t[23]=r,t[24]=n,t[25]=S,t[26]=C):C=t[26],C}function Go(e){let t=(0,Q.c)(19),{open:n,onOpenChange:r,onNewBranch:i,onJustOpen:a,isLoading:o,defaultBranch:s}=e,c=o===void 0?!1:o,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(De,{children:`Pull Request Merged`}),t[0]=u):u=t[0];let d=s?` from ${s}`:``,f;t[1]===d?f=t[2]:(f=(0,$.jsxs)(E,{children:[u,(0,$.jsxs)(l,{children:[`As the pull request has been merged a new branch will be created`,d,`.`]})]}),t[1]=d,t[2]=f);let p;t[3]!==c||t[4]!==a?(p=(0,$.jsx)(U,{variant:`ghost`,onClick:a,disabled:c,children:`Just Open`}),t[3]=c,t[4]=a,t[5]=p):p=t[5];let m;t[6]!==c||t[7]!==i?(m=(0,$.jsx)(U,{onClick:i,disabled:c,children:`New Branch`}),t[6]=c,t[7]=i,t[8]=m):m=t[8];let h;t[9]!==p||t[10]!==m?(h=(0,$.jsxs)(je,{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)(un,{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)(W,{open:n,onOpenChange:r,children:g}),t[15]=r,t[16]=n,t[17]=g,t[18]=_):_=t[18],_}function Ko(e){let t=(0,Q.c)(35),{open:n,onOpenChange:r,branchName:i,onBranchNameChange:a,isLoading:o,onCreateBranch:s}=e,c;t[0]!==i||t[1]!==o||t[2]!==s?(c=e=>{e.key===`Enter`&&i.trim()&&!o&&s()},t[0]=i,t[1]=o,t[2]=s,t[3]=c):c=t[3];let u=c,d;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsxs)(E,{children:[(0,$.jsx)(De,{children:`New Branch`}),(0,$.jsx)(l,{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)(V,{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)(H,{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]!==s||t[22]!==_||t[23]!==v?(y=(0,$.jsx)(U,{onClick:s,disabled:_,children:v}),t[21]=s,t[22]=_,t[23]=v,t[24]=y):y=t[24];let b;t[25]!==y||t[26]!==g?(b=(0,$.jsxs)(je,{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)(un,{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)(W,{open:n,onOpenChange:r,children:x}),t[31]=r,t[32]=n,t[33]=x,t[34]=S):S=t[34],S}function qo(e){let t=e.split(`/`);return t.length>=2?{provider:t[0],model:t.slice(1).join(`/`)}:{provider:void 0,model:e}}function Jo(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}:qo(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 N(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 Fe(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 Yo({projectId:e,threadId:t}){let{state:n,dispatch:r}=Xn(),[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,y]=(0,Z.useState)(!1),[b,x]=(0,Z.useState)(null),C=(0,Z.useRef)(!1),w=(0,Z.useRef)(!1),[E,D]=(0,Z.useState)(!1),[O,k]=(0,Z.useState)([]),[A,j]=(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)(``),[te,B]=(0,Z.useState)(``),[ne,re]=(0,Z.useState)(``),[ae,V]=(0,Z.useState)(!1),[oe,ce]=(0,Z.useState)(!1),[H,le]=(0,Z.useState)(!1),[fe,pe]=(0,Z.useState)(!1),[me,he]=(0,Z.useState)(``),[ge,ve]=(0,Z.useState)([]),[ye,be]=(0,Z.useState)(!1),W=lr(t),Se=Jo(t,e,n.projectModelSelections);async function Ce(){ke();let e=await sn();r({type:K.SetProjects,projects:e.projects})}let[we,Te]=(0,Z.useState)(()=>Fo()),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)(()=>{Io(we)},[we]),(0,Z.useEffect)(()=>{let e=!0;return Ze().then(t=>{e&&re(t)}).catch(()=>{}),()=>{e=!1}},[]),(0,Z.useEffect)(()=>{if(!c){w.current=!1;return}if(c&&we.autoGenerateCommitMessage&&!f.trim()&&t&&!w.current){w.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){C.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:C.current}),u&&we.autoGeneratePRInfo&&!m.trim()&&!g.trim()&&t&&!C.current){console.log(`[pr-auto-gen] Starting auto-generation...`),C.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`),le(!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 Oe(){if(f.trim()&&Lo(t))try{a(!0),await ue(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&&(ce(!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 Ae(){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 T(W.prUrl);return}if(W.commitsAheadOfDefault&&!W.prExists&&!W.hasChanges){d(!0);return}if(W.hasUnpushedCommits&&W.prExists){await G();return}}async function je(){let e=await Se.generateCommitMessageWithAI();e&&p(e)}async function Ne(){if(Lo(t))try{a(!0),await M(t),await W.fetchUnifiedStatus()}catch(e){console.error(`Failed to fetch:`,e)}finally{a(!1)}}async function G(){if(Lo(t))try{a(!0),await fn(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(Lo(t)){if(W.hasChanges){V(!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(){V(!1),ce(!0),l(!0)}async function Le(){V(!1),await Fe()}async function Re(){if(t)try{a(!0);let e=await _e(t,W.defaultBranch??void 0);ke();let n=await sn();r({type:K.SetProjects,projects:n.projects}),X({title:`New branch created`,description:`Created new branch "${e.branchName}" on current thread`}),le(!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 _e(t,W.defaultBranch??void 0,me.trim());ke();let n=await sn();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(!Lo(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 Me(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(Lo(t))try{a(!0),s(!0);let e=await S(t,m,g);e.prUrl&&await T(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(Lo(t))try{a(!0);let e=await de(t,z,te,we.privateRepositoryDefault);e.repoUrl&&setTimeout(()=>{T(e.repoUrl)},3e3),ee(``),B(``),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??b;if(!(!t||!n))try{a(!0),s(!0);try{await fn(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 Me(t),console.log(`[push-and-pr] ✓ Pull completed, retrying push...`),await fn(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 S(t,n.title,n.description);e.prUrl&&await T(e.prUrl),h(``),_(``),x(null),y(!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(Lo(t))try{j(!0);let e=await Ft(t,100);k(e),P(e.slice(0,10)),D(!0)}catch(e){console.error(`Failed to fetch git history:`,e)}finally{j(!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=No(W);async function Ye(){if(!ye){be(!0);try{ve((await ie(t)).branches)}catch{ve([])}finally{be(!1)}}}async function Xe(e){if(e!==W.currentBranch){a(!0);try{await se(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&&T(W.repoUrl)}function et(){y(!1),x(null)}function tt(){le(!1),W.fetchUnifiedStatus(!0)}return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-0`,children:[(0,$.jsx)(or,{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:Mo(W,i),onClick:Ae,children:[Ao(W,o),ko(W,o)]})}),(0,$.jsx)(q,{children:jo(W)})]})}),(0,$.jsx)(Po,{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:ne,availableBranches:ge,isLoadingBranches:ye,onBranchSubMenuOpen:Ye,onCheckoutBranch:Xe,isDirectCommitMode:De,isLoading:i,isLoadingHistory:A,onFetch:()=>void Ne(),onPull:()=>void Pe(),onPush:()=>void G(),onOpenHistory:()=>void Ge(),onNewBranch:Qe,onCreatePR:()=>d(!0),onCreateRepo:()=>R(!0),onViewInGitHub:$e})]}),(0,$.jsx)(Ro,{open:c,onOpenChange:l,commitMessage:f,onCommitMessageChange:p,autoGenerateCommitMessage:we.autoGenerateCommitMessage,onAutoGenerateChange:e=>Te(t=>({...t,autoGenerateCommitMessage:e})),isGeneratingMessage:Se.isGeneratingMessage,isLoading:i,onGenerateMessage:je,onCommit:Oe,currentBranch:W.currentBranch}),(0,$.jsx)(zo,{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)(Uo,{open:v,onOpenChange:y,isLoading:i,onPushAndCreatePR:We,onCancel:et}),(0,$.jsx)(Bo,{open:L,onOpenChange:R,repoName:z,onRepoNameChange:ee,repoDescription:te,onRepoDescriptionChange:B,isPrivateRepo:we.privateRepositoryDefault,onPrivateRepoChange:e=>Te(t=>({...t,privateRepositoryDefault:e})),isLoading:i,onCreateRepo:He}),(0,$.jsx)(Vo,{open:E,onOpenChange:D,commits:O,displayedCommits:N,isLoadingMore:F,onScroll:qe,currentBranch:W.currentBranch}),(0,$.jsx)(Wo,{open:ae,onOpenChange:V,onCommitFirst:Ie,onStashAndPull:Le,onCancel:()=>V(!1),isLoading:i}),(0,$.jsx)(Go,{open:H,onOpenChange:le,onNewBranch:Re,onJustOpen:tt,isLoading:i,defaultBranch:W.defaultBranch??void 0}),(0,$.jsx)(Ko,{open:fe,onOpenChange:pe,branchName:me,onBranchNameChange:he,isLoading:i,onCreateBranch:ze})]})}var Xo=`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 Zo({open:e,onOpenChange:r,projectId:i,commands:a,onRefresh:o}){let[s,c]=(0,Z.useState)(null),[u,d]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)([]),[_,v]=(0,Z.useState)(0),[b,S]=(0,Z.useState)(!1),C=(0,Z.useRef)(null),w=(0,Z.useRef)(null),T=()=>{c({id:crypto.randomUUID(),name:``,icon:`Play`,commandLine:``}),p(!1),g([])},D=e=>{c({...e}),p(!1),g([])},O=async()=>{try{S(!0);let e=await ot(i);g(e.scripts),v(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{S(!1)}},k=e=>{c(t=>t?{...t,name:e.name,commandLine:e.commandLine,relativeFolder:e.relativePath||``}:null),p(!1),g([]),C.current?.focus()},A=e=>{f&&(e.key===`ArrowDown`?(e.preventDefault(),v(e=>e<h.length-1?e+1:e)):e.key===`ArrowUp`?(e.preventDefault(),v(e=>e>0?e-1:0)):e.key===`Enter`?(e.preventDefault(),_<h.length&&k(h[_])):e.key===`Escape`&&(e.preventDefault(),p(!1),g([])))};(0,Z.useEffect)(()=>{let e=e=>{w.current&&!w.current.contains(e.target)&&(p(!1),g([]))};return f&&document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[f]);let j=async e=>{try{await y(i,e),X({title:`Success`,description:`Command deleted`}),o()}catch{X({title:`Error`,description:`Failed to delete command`,variant:`destructive`})}};return(0,$.jsx)(W,{open:e,onOpenChange:r,children:(0,$.jsxs)(un,{className:`sm:max-w-[500px]`,children:[(0,$.jsxs)(E,{children:[(0,$.jsx)(De,{children:`Project Commands`}),(0,$.jsx)(l,{children:`Manage custom commands for this project.`})]}),(0,$.jsx)(`div`,{className:`py-4 flex flex-col gap-4`,children:s?(0,$.jsxs)(`div`,{className:`p-4 border rounded-lg bg-muted/30 flex flex-col gap-4 animate-in slide-in-from-top-2`,children:[(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[(0,$.jsx)(V,{htmlFor:`name`,children:`Command Name`}),(0,$.jsx)(H,{id:`name`,value:s.name,onChange:e=>c({...s,name:e.target.value}),placeholder:`e.g. Run Tests`,autoComplete:`off`})]}),(0,$.jsxs)(`div`,{className:`grid gap-2 relative`,children:[(0,$.jsx)(V,{htmlFor:`commandLine`,children:`Command Line`}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(ar,{ref:C,id:`commandLine`,value:s.commandLine,onChange:e=>c({...s,commandLine:e.target.value}),onKeyDown:A,placeholder:`e.g. npm test`,className:`font-mono text-xs min-h-[100px] resize-none pr-10`}),(0,$.jsx)(or,{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 O(),disabled:b,children:(0,$.jsx)(t,{className:`h-4 w-4`})})}),(0,$.jsx)(q,{children:(0,$.jsx)(`p`,{children:`Discover package scripts`})})]})})]}),f&&(0,$.jsx)(`div`,{ref:w,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)(t,{className:`h-3 w-3`}),`Available Scripts `,b&&`(loading...)`]}),h.length>0?(()=>{let e={};h.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===_;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:()=>k(e),onMouseEnter:()=>v(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)(V,{htmlFor:`relativeFolder`,children:`Relative Folder`}),(0,$.jsx)(H,{id:`relativeFolder`,value:s.relativeFolder??``,onChange:e=>c({...s,relativeFolder:e.target.value}),placeholder:`e.g. frontend, packages/api (optional)`,autoComplete:`off`}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Folder path relative to project root where the command will be executed. Leave empty to run from project root.`})]}),(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[(0,$.jsx)(V,{children:`Icon`}),(0,$.jsx)(`div`,{className:`grid grid-cols-10 gap-1 p-2 bg-background rounded-md border border-border`,children:Xo.map(e=>{let t=m[e]||zt;return(0,$.jsx)(U,{variant:s.icon===e?`default`:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:()=>c({...s,icon:e}),title:e,children:(0,$.jsx)(t,{className:`h-4 w-4`})},e)})})]}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2 mt-2`,children:[(0,$.jsxs)(U,{variant:`ghost`,size:`sm`,onClick:()=>c(null),children:[(0,$.jsx)(Ct,{className:`h-4 w-4 mr-2`}),` Cancel`]}),(0,$.jsxs)(U,{size:`sm`,onClick:async()=>{if(!s?.name||!s?.commandLine){X({title:`Error`,description:`Name and Command Line are required`,variant:`destructive`});return}try{d(!0),await nt(i,s),X({title:`Success`,description:`Command saved`}),c(null),o()}catch{X({title:`Error`,description:`Failed to save command`,variant:`destructive`})}finally{d(!1)}},disabled:u,children:[(0,$.jsx)(et,{className:`h-4 w-4 mr-2`}),` `,u?`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:[a.length===0&&(0,$.jsx)(`div`,{className:`text-center py-8 text-muted-foreground border-2 border-dashed rounded-lg`,children:`No commands defined yet.`}),a.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:()=>D(e),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`div`,{className:`p-2 bg-muted rounded`,children:(0,$.jsx)(m[e.icon]||n,{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(),j(e.id)},children:(0,$.jsx)(x,{className:`h-4 w-4`})})})]},e.id))]}),(0,$.jsxs)(U,{variant:`outline`,className:`w-full border-dashed`,onClick:T,children:[(0,$.jsx)(ve,{className:`h-4 w-4 mr-2`}),` Add New Command`]})]})})]})})}function Qo(){let e=(0,Q.c)(27),{state:t}=Xn(),{selectedProjectId:r,selectedThreadId:i,projects:a}=t,{dispatch:o}=nr(i),[s,c]=(0,Z.useState)(!1),l,u,d,f,p;if(e[0]!==o||e[1]!==a||e[2]!==r||e[3]!==i||e[4]!==t.isRunningCommand){p=Symbol.for(`react.early_return_sentinel`);bb0:{let s;e[10]===r?s=e[11]:(s=e=>e.projectId===r,e[10]=r,e[11]=s),l=a.find(s)?.commands??[];let h;e[12]!==o||e[13]!==r||e[14]!==i?(h=e=>{!r||!i||o({type:K.QueueTerminalCommand,threadId:i,command:e.commandLine,relativeFolder:e.relativeFolder})},e[12]=o,e[13]=r,e[14]=i,e[15]=h):h=e[15];let g=h,_;if(e[16]===o?_=e[17]:(_=async()=>{o({type:K.ConfigUpdated})},e[16]=o,e[17]=_),u=_,!r){p=null;break bb0}d=`flex items-center gap-1`,f=l.length===0?(0,$.jsx)(or,{children:(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(U,{variant:`action`,size:`icon-md`,onClick:()=>c(!0),children:(0,$.jsx)(ee,{})})}),(0,$.jsx)(q,{children:`Manage commands`})]})}):(0,$.jsx)($.Fragment,{children:(0,$.jsxs)(or,{children:[l.map(e=>{let r=m[e.icon]||n;return(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(U,{variant:`action`,size:`icon-md`,onClick:()=>g({commandLine:e.commandLine,relativeFolder:e.relativeFolder}),disabled:t.isRunningCommand,children:(0,$.jsx)(r,{})})}),(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:()=>c(!0),children:(0,$.jsx)(ee,{})})}),(0,$.jsx)(q,{children:`Manage commands`})]})]})})}e[0]=o,e[1]=a,e[2]=r,e[3]=i,e[4]=t.isRunningCommand,e[5]=l,e[6]=u,e[7]=d,e[8]=f,e[9]=p}else l=e[5],u=e[6],d=e[7],f=e[8],p=e[9];if(p!==Symbol.for(`react.early_return_sentinel`))return p;let h;e[18]!==l||e[19]!==u||e[20]!==r||e[21]!==s?(h=(0,$.jsx)(Zo,{open:s,onOpenChange:c,projectId:r,commands:l,onRefresh:u}),e[18]=l,e[19]=u,e[20]=r,e[21]=s,e[22]=h):h=e[22];let g;return e[23]!==d||e[24]!==f||e[25]!==h?(g=(0,$.jsxs)(`div`,{className:d,children:[f,h]}),e[23]=d,e[24]=f,e[25]=h,e[26]=g):g=e[26],g}function $o(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 es({threadId:e}){let{dispatch:t}=Xn(),{setTerminalNotification:n}=Er(),[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 Xt(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])),n(!0),t({type:K.AppendTerminalLine,threadId:e,line:{type:`system`,content:`▶ ${i.friendlyName}`}});try{let n=await r(e,i.name,i.command,{signal:a.signal});if(n){let r=n.getReader(),i=new TextDecoder,a=``;try{for(;;){let{done:n,value:o}=await r.read();if(n)break;a+=i.decode(o,{stream:!0});let s=a.split(`
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{r.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)(mo,{children:[(0,$.jsx)(or,{children:(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(ho,{asChild:!0,children:(0,$.jsx)(U,{variant:`action`,size:`icon-md`,children:(0,$.jsx)(Re,{})})})}),(0,$.jsx)(q,{children:`Project Scripts`})]})}),(0,$.jsx)(yo,{align:`end`,className:`min-w-[180px]`,children:f?d.map(([e,t])=>(0,$.jsxs)(go,{children:[(0,$.jsx)(_o,{children:e}),(0,$.jsx)(vo,{className:`max-h-[min(400px,80vh)] overflow-y-auto`,children:t.map(e=>(0,$.jsxs)(bo,{onClick:()=>{l(e)},className:`gap-2`,children:[o.has(e.name)?(0,$.jsx)(dt,{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)(bo,{onClick:()=>{l(e)},className:`gap-2`,children:[o.has(e.name)?(0,$.jsx)(dt,{className:`h-3 w-3 animate-spin shrink-0`}):(0,$.jsx)(`div`,{className:`h-3 w-3 shrink-0`}),e.friendlyName]},e.name))})]})}var ts=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)(xn,{className:a,...i,ref:t}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});ts.displayName=xn.displayName;var ns=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)(mn,{className:`flex items-center justify-center`,children:(0,$.jsx)(R,{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)(In,{ref:t,className:a,...i,children:o}),n[6]=i,n[7]=t,n[8]=a,n[9]=s):s=n[9],s});ns.displayName=In.displayName;function rs({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)(V,{htmlFor:`skillName`,children:`Skill Name`}),(0,$.jsx)(H,{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)(V,{htmlFor:`skillDescription`,children:`Description`}),(0,$.jsx)(ar,{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)(V,{children:`Scope`}),(0,$.jsxs)(ts,{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)(ns,{value:`local`,id:`scope-local`}),(0,$.jsx)(V,{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)(ns,{value:`global`,id:`scope-global`,disabled:!0}),(0,$.jsx)(V,{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 he(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)(dt,{className:`mr-2 h-4 w-4 animate-spin`}),`Creating...`]}):(0,$.jsxs)($.Fragment,{children:[`Continue`,(0,$.jsx)(ze,{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 is=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)(Ln,{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)(Cn,{className:a,...i,ref:t,children:o}),n[6]=i,n[7]=t,n[8]=a,n[9]=s):s=n[9],s});is.displayName=Cn.displayName;function as({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)(V,{htmlFor:`ruleName`,children:`Rule Name`}),(0,$.jsx)(H,{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)(V,{htmlFor:`ruleDescription`,children:`Description`}),(0,$.jsx)(ar,{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)(V,{htmlFor:`alwaysApply`,children:`Always Apply`}),(0,$.jsx)(is,{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)(V,{children:`Scope`}),(0,$.jsxs)(ts,{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)(ns,{value:`local`,id:`scope-local`}),(0,$.jsx)(V,{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)(ns,{value:`global`,id:`scope-global`,disabled:!0}),(0,$.jsx)(V,{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 gt(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)(dt,{className:`mr-2 h-4 w-4 animate-spin`}),`Creating...`]}):(0,$.jsxs)($.Fragment,{children:[`Continue`,(0,$.jsx)(ze,{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 os({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)(V,{htmlFor:`agentName`,children:`Agent Name`}),(0,$.jsx)(H,{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)(V,{htmlFor:`agentDescription`,children:`Description`}),(0,$.jsx)(ar,{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)(V,{htmlFor:`agentTools`,children:`Allowed Tools (optional)`}),(0,$.jsx)(H,{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)(V,{children:`Scope`}),(0,$.jsxs)(ts,{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)(ns,{value:`local`,id:`scope-local`}),(0,$.jsx)(V,{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)(ns,{value:`global`,id:`scope-global`,disabled:!0}),(0,$.jsx)(V,{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 ce(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)(dt,{className:`mr-2 h-4 w-4 animate-spin`}),`Creating...`]}):(0,$.jsxs)($.Fragment,{children:[`Continue`,(0,$.jsx)(ze,{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 ss({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)(V,{htmlFor:`commandName`,children:`Command Name`}),(0,$.jsx)(H,{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)(V,{htmlFor:`commandDescription`,children:`Description`}),(0,$.jsx)(H,{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)(V,{htmlFor:`argumentHint`,children:`Argument Hint (optional)`}),(0,$.jsx)(H,{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)(V,{children:`Mode`}),(0,$.jsxs)(ts,{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)(ns,{value:`default`,id:`mode-default`}),(0,$.jsx)(V,{htmlFor:`mode-default`,className:`font-normal cursor-pointer`,children:`Default`})]}),(0,$.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,$.jsx)(ns,{value:`plan`,id:`mode-plan`}),(0,$.jsx)(V,{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)(V,{children:`Scope`}),(0,$.jsxs)(ts,{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)(ns,{value:`local`,id:`scope-local`}),(0,$.jsx)(V,{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)(ns,{value:`global`,id:`scope-global`,disabled:!0}),(0,$.jsx)(V,{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 vt(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)(dt,{className:`mr-2 h-4 w-4 animate-spin`}),`Creating...`]}):(0,$.jsxs)($.Fragment,{children:[`Continue`,(0,$.jsx)(ze,{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 cs(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 ls(){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 us(e,t,n){await At(e,t,n)}async function ds(e,t){await k(e,t)}function fs({projectPath:e,serverName:t,onBack:n}){let{installedServers:r}=cs(e),i=!!t,[a,o]=(0,Z.useState)(``),[s,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)(``),[d,f]=(0,Z.useState)([]),[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(!1),[_,v]=(0,Z.useState)(null),[y,b]=(0,Z.useState)(i),[x,S]=(0,Z.useState)(``),[C,w]=(0,Z.useState)(``),[T,E]=(0,Z.useState)(``),[D,O]=(0,Z.useState)([]);(0,Z.useEffect)(()=>{if(i&&t){let e=r.find(e=>e.name===t);if(e){o(e.name),c(e.config.command);let t=e.config.args.join(`
41
+ `);u(t);let n=Object.entries(e.config.env??{}).map(([e,t])=>({key:e,value:t}));f(n),S(e.name),w(e.config.command),E(t),O(n),b(!1)}}else b(!1)},[r,t,i]);let k=(0,Z.useCallback)(()=>{f(e=>[...e,{key:``,value:``}])},[]),A=(0,Z.useCallback)(e=>{f(t=>t.filter((t,n)=>n!==e))},[]),j=(0,Z.useCallback)((e,t)=>{f(n=>n.map((n,r)=>r===e?{...n,key:t}:n))},[]),M=(0,Z.useCallback)((e,t)=>{f(n=>n.map((n,r)=>r===e?{...n,value:t}:n))},[]),N=()=>{let e=l.split(`
42
+ `).map(e=>e.trim()).filter(Boolean),t={};for(let{key:e,value:n}of d)e.trim()&&(t[e.trim()]=n);return{command:s.trim(),args:e,...Object.keys(t).length>0?{env:t}:{}}},P=async()=>{v(null);let t=a.trim(),r=s.trim();if(!t){v(`Server name is required`);return}if(!r){v(`Command is required`);return}m(!0);try{if(!e)throw Error(`No project path`);await us(e,x||t,N()),X({title:`Success`,description:i?`MCP server configuration saved`:`MCP server added`}),n()}catch(e){v(e instanceof Error?e.message:`Failed to save server`)}finally{m(!1)}},F=async()=>{if(e){g(!0);try{await ds(e,x),X({title:`Success`,description:`MCP server removed`}),n()}catch(e){v(e instanceof Error?e.message:`Failed to delete server`)}finally{g(!1)}}},I=i?s!==C||l!==T||JSON.stringify(d)!==JSON.stringify(D):a.trim()!==``||s.trim()!==``||l.trim()!==``||d.length>0;return y?(0,$.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading server configuration...`})}):(0,$.jsxs)(`div`,{className:`max-w-2xl mx-auto p-6`,children:[(0,$.jsxs)(`div`,{className:`mb-6`,children:[(0,$.jsx)(`h1`,{className:`text-2xl font-bold`,children:i?a:`Add MCP Server`}),(0,$.jsx)(`p`,{className:`text-muted-foreground`,children:i?`Edit MCP Server configuration.`:`Configure a new MCP Server.`})]}),(0,$.jsxs)(`div`,{className:`space-y-6`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(V,{htmlFor:`server-name`,children:`Server name`}),(0,$.jsx)(H,{id:`server-name`,placeholder:`e.g. filesystem`,value:a,onChange:e=>o(e.target.value),disabled:i}),i&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Server name cannot be changed`})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(V,{htmlFor:`server-command`,children:`Command`}),(0,$.jsx)(H,{id:`server-command`,placeholder:`e.g. npx`,value:s,onChange:e=>c(e.target.value),className:`text-sm`})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(V,{htmlFor:`server-args`,children:[`Arguments `,(0,$.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:`(one per line)`})]}),(0,$.jsx)(ar,{id:`server-args`,placeholder:`-y
43
+ @modelcontextprotocol/server-filesystem
44
+ /path/to/dir`,value:l,onChange:e=>u(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)(V,{children:`Environment variables`}),(0,$.jsxs)(U,{variant:`ghost`,size:`sm`,onClick:k,className:`h-6 px-2 text-xs`,children:[(0,$.jsx)(ve,{className:`h-3 w-3 mr-1`}),`Add variable`]})]}),d.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:d.map((e,t)=>(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(H,{placeholder:`KEY`,value:e.key,onChange:e=>j(t,e.target.value),className:`font-mono text-xs w-[35%]`}),(0,$.jsx)(H,{placeholder:`value`,value:e.value,onChange:e=>M(t,e.target.value),className:`font-mono text-xs flex-1`}),(0,$.jsx)(U,{variant:`ghost`,size:`icon`,onClick:()=>A(t),className:`h-9 w-9 flex-shrink-0`,children:(0,$.jsx)(Ct,{className:`h-3.5 w-3.5`})})]},t))})]}),_&&(0,$.jsx)(`p`,{className:`text-sm text-destructive`,children:_}),(0,$.jsxs)(`div`,{className:`border-t pt-4 flex items-center justify-between`,children:[i&&(0,$.jsx)(U,{variant:`destructive`,onClick:F,disabled:h||p,children:h?`Removing...`:`Remove`}),!i&&(0,$.jsx)(`div`,{}),(0,$.jsx)(U,{onClick:P,disabled:p||h||!I,children:p?i?`Saving...`:`Adding...`:i?`Save`:`Add`})]})]})]})}function ps(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)(Vt,{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)(or,{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)(et,{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)(or,{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)(ne,{className:`h-3.5 w-3.5`})})}),(0,$.jsx)(q,{children:`Open in Explorer`})]})}),s&&(0,$.jsx)(or,{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)(x,{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 v;return t[17]!==c||t[18]!==_||t[19]!==l||t[20]!==u||t[21]!==g?(v=(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]=v):v=t[22],v}function ms(e){let t=[];for(let n of e)n.type===`file`&&t.push(n.path),n.children&&t.push(...ms(n.children));return t}function hs({projectPath:e,threadId:t,onClose:n}){let{installedServers:r,loadInstalledServers:i}=cs(e),{popularServers:a}=ls(),{setActiveMainTab:o,setPendingExplorerPath:s,triggerExplorerRefresh:u,setExplorerClearPath:d}=Er(),[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),[S,C]=(0,Z.useState)(new Map),[w,D]=(0,Z.useState)([]),[k,A]=(0,Z.useState)([]),[j,M]=(0,Z.useState)([]),[N,P]=(0,Z.useState)([]);(0,Z.useEffect)(()=>{lt().then(D).catch(()=>D([])),Rt().then(A).catch(()=>A([])),pt().then(M).catch(()=>M([])),We().then(P).catch(()=>P([]))},[]),(0,Z.useEffect)(()=>{t&&(me(t).then(e=>x(new Set(ms(e)))).catch(()=>{}),rn(t).then(e=>C(new Map(e.map(e=>[e.name,e.filePath])))).catch(()=>{}))},[t]);let F=(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(w),[w,L]),ee=(0,Z.useMemo)(()=>L(k),[k,L]),te=(0,Z.useMemo)(()=>L(j),[j,L]),B=(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 us(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]),re=(0,Z.useCallback)(async t=>{if(!e)return;let n=t.name.toLowerCase().replace(/\s+/g,`-`);try{await ds(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]),ie=(0,Z.useCallback)(()=>{s(`.agents/mcp.json`),o(`explorer`),n()},[s,o,n]),ae=(0,Z.useCallback)(e=>{s(`.agents/skills/${e.id}/SKILL.md`),o(`explorer`),n()},[s,o,n]),V=(0,Z.useCallback)(e=>{s(`.agents/agents/${e.id}/AGENT.md`),o(`explorer`),n()},[s,o,n]),oe=(0,Z.useCallback)(e=>{s(`.agents/rules/${e.name}.md`),o(`explorer`),n()},[s,o,n]),se=(0,Z.useCallback)(e=>{let t=S.get(e.name);t&&(s(t),o(`explorer`),n())},[S,s,o,n]),ce=(0,Z.useCallback)(async e=>{if(!t)return;let n=`.agents/skills/${e.id}/SKILL.md`;try{await c(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 c(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 c(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=S.get(e.name);if(t)try{await ye(t),C(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`})}},[S,u,d]),fe=(0,Z.useCallback)((e,t,n,r)=>{y({name:e,gitHubRepo:t,gitHubFolder:n,onConfirm:r})},[]),pe=(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 O(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 gt(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 O(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 gt(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 O(t,e.gitHubRepo,e.gitHubFolder,`.agents/rules`):await gt(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||S.has(e.name))return;let n=async()=>{_(e.id);try{if(e.gitHubRepo&&e.gitHubFolder){let n=`.agents/commands`;await O(t,e.gitHubRepo,e.gitHubFolder,n);let r=`${n}/${e.name}.md`;C(t=>new Map(t).set(e.name,r))}else{let n=await vt(e.name,e.content,{description:e.description,argumentHint:e.argumentHint},`project`,t);C(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,S,u,fe]);function ve({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)(dt,{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)(dt,{className:`h-4 w-4 animate-spin`})}),(0,$.jsx)(ps,{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)(W,{open:v!==null,onOpenChange:e=>{e||y(null)},children:(0,$.jsxs)(un,{children:[(0,$.jsxs)(E,{children:[(0,$.jsxs)(De,{children:[`Install `,v?.name]}),(0,$.jsxs)(l,{children:[`Install `,(0,$.jsx)(`strong`,{children:v?.name}),` from`,` `,(0,$.jsx)(`strong`,{children:v?.gitHubRepo}),` (`,v?.gitHubFolder,`)?`]})]}),(0,$.jsxs)(je,{className:`flex-row gap-2 sm:justify-between`,children:[(0,$.jsx)(U,{variant:`outline`,onClick:()=>{v&&T(`${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)(Fr,{value:f,onValueChange:F,children:(0,$.jsxs)(Pr,{className:`w-full`,children:[(0,$.jsx)(Mr,{value:`mcp`,className:`flex-1`,children:`MCP`}),(0,$.jsx)(Mr,{value:`skills`,className:`flex-1`,children:`Skills`}),(0,$.jsx)(Mr,{value:`agents`,className:`flex-1`,children:`Agents`}),(0,$.jsx)(Mr,{value:`rules`,className:`flex-1`,children:`Rules`}),(0,$.jsx)(Mr,{value:`commands`,className:`flex-1`,children:`Commands`})]})}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(I,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground pointer-events-none`}),(0,$.jsx)(H,{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)(dt,{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)(dt,{className:`h-4 w-4 animate-spin`})}),(0,$.jsx)(ps,{name:e.name,description:e.description,installed:n,onClick:()=>void ne(e),onOpen:n?ie:void 0,onUninstall:n?()=>void re(e):void 0})]},e.id)})})}),f===`skills`&&(0,$.jsx)(ve,{items:z,onInstall:e=>void pe(e),isInstalled:e=>b.has(`.agents/skills/${e.id}/SKILL.md`),noThreadWarning:!0,onOpen:ae,onUninstall:e=>void ce(e)}),f===`agents`&&(0,$.jsx)(ve,{items:ee,onInstall:e=>void he(e),isInstalled:e=>b.has(`.agents/agents/${e.id}/AGENT.md`),noThreadWarning:!0,onOpen:V,onUninstall:e=>void le(e)}),f===`rules`&&(0,$.jsx)(ve,{items:te,onInstall:e=>void ge(e),isInstalled:e=>b.has(`.agents/rules/${e.name}.md`),noThreadWarning:!0,onOpen:oe,onUninstall:e=>void ue(e)}),f===`commands`&&(0,$.jsx)(ve,{items:B,onInstall:e=>void _e(e),isInstalled:e=>S.has(e.name),noThreadWarning:!0,onOpen:se,onUninstall:e=>void de(e)})]})]})]})}function gs(){let e=Pn(),{state:t}=Xn(),{selectedProjectId:n,selectedThreadId:r,projects:i}=t,a=i.find(e=>e.projectId===n),[o,s]=(0,Z.useState)(null),[c,u]=(0,Z.useState)(``),[d,f]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{o!==`instructions`||!r||(f(!0),h(r,`AGENTS.md`).then(e=>u(e.content)).catch(()=>u(``)).finally(()=>f(!1)))},[o,r]);let g=async()=>{if(r){m(!0);try{await gt(r,`AGENTS.md`,c),X({title:`Instructions saved`}),s(null)}catch(e){X({title:`Error`,description:e instanceof Error?e.message:`Failed to save instructions`,variant:`destructive`})}finally{m(!1)}}};return n?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(or,{children:(0,$.jsxs)(mo,{children:[(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(ho,{asChild:!0,children:(0,$.jsx)(U,{variant:`action`,size:`icon-md`,children:(0,$.jsx)(Kt,{})})})}),(0,$.jsx)(q,{children:`AI`})]}),(0,$.jsxs)(yo,{align:`end`,children:[(0,$.jsx)(bo,{onSelect:()=>s(`mcp`),children:`Add MCP Server`}),(0,$.jsx)(bo,{onSelect:()=>s(`skill`),children:`Add Skill`}),(0,$.jsx)(bo,{onSelect:()=>s(`rule`),children:`Add Rule`}),(0,$.jsx)(bo,{onSelect:()=>s(`slash-command`),children:`Add Slash Command`}),(0,$.jsx)(bo,{onSelect:()=>s(`subagent`),children:`Add Subagent`}),(0,$.jsx)(wo,{}),(0,$.jsx)(bo,{onSelect:()=>s(`instructions`),disabled:!r,children:`Instructions`}),(0,$.jsx)(bo,{onSelect:()=>void e(`/settings?tab=providers`),children:`Model Providers`}),(0,$.jsx)(wo,{}),(0,$.jsx)(bo,{onSelect:()=>s(`marketplace`),children:`Marketplace`})]})]})}),(0,$.jsx)(W,{open:o===`mcp`,onOpenChange:e=>!e&&s(null),children:(0,$.jsx)(un,{className:`max-w-2xl max-h-[90vh] overflow-y-auto p-0`,children:(0,$.jsx)(`div`,{className:`w-full`,children:(0,$.jsx)(fs,{projectPath:a?.projectPath,onBack:()=>s(null)})})})}),(0,$.jsx)(W,{open:o===`marketplace`,onOpenChange:e=>!e&&s(null),children:(0,$.jsx)(un,{className:`max-w-3xl h-[80vh] overflow-y-auto p-0`,children:(0,$.jsx)(hs,{projectPath:a?.projectPath,threadId:r,onClose:()=>s(null)})})}),(0,$.jsx)(W,{open:o===`skill`,onOpenChange:e=>!e&&s(null),children:(0,$.jsx)(un,{className:`max-w-2xl max-h-[90vh] overflow-y-auto p-0`,children:(0,$.jsx)(rs,{threadId:r,onSkillCreated:()=>s(null)})})}),(0,$.jsx)(W,{open:o===`rule`,onOpenChange:e=>!e&&s(null),children:(0,$.jsx)(un,{className:`max-w-2xl max-h-[90vh] overflow-y-auto p-0`,children:(0,$.jsx)(as,{threadId:r,onRuleCreated:()=>s(null)})})}),(0,$.jsx)(W,{open:o===`slash-command`,onOpenChange:e=>!e&&s(null),children:(0,$.jsx)(un,{className:`max-w-2xl max-h-[90vh] overflow-y-auto p-0`,children:(0,$.jsx)(ss,{projectId:n,threadId:r,onCommandCreated:()=>s(null)})})}),(0,$.jsx)(W,{open:o===`subagent`,onOpenChange:e=>!e&&s(null),children:(0,$.jsx)(un,{className:`max-w-2xl max-h-[90vh] overflow-y-auto p-0`,children:(0,$.jsx)(os,{threadId:r,onAgentCreated:()=>s(null)})})}),(0,$.jsx)(W,{open:o===`instructions`,onOpenChange:e=>!e&&s(null),children:(0,$.jsxs)(un,{className:`max-w-2xl`,children:[(0,$.jsxs)(E,{children:[(0,$.jsx)(De,{children:`Instructions`}),(0,$.jsx)(l,{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)(dt,{className:`h-5 w-5 animate-spin text-muted-foreground`})}):(0,$.jsx)(ar,{value:c,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:p}),(0,$.jsxs)(je,{children:[(0,$.jsx)(U,{variant:`outline`,onClick:()=>s(null),children:`Cancel`}),(0,$.jsx)(U,{onClick:()=>void g(),disabled:d||p,children:p?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(dt,{className:`mr-2 h-4 w-4 animate-spin`}),`Saving...`]}):`Save`})]})]})})]}):null}function _s(){let e=(0,Q.c)(44),{state:t,dispatch:n}=Xn(),{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)(Wt,{className:`h-4 w-4`}):(0,$.jsx)(kt,{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:Bt(a,i)}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:F(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)($o,{className:`electrobun-webkit-app-region-no-drag`,children:[(0,$.jsx)(jr,{projectId:i,runCommand:c?.runCommand}),r&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(es,{threadId:r}),(0,$.jsx)(Qo,{}),(0,$.jsx)(gs,{})]})]}),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)($o,{className:`electrobun-webkit-app-region-no-drag`,children:(0,$.jsx)(Yo,{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)($o,{className:`electrobun-webkit-app-region-no-drag`,children:(0,$.jsx)(Oo,{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)(Ir,{className:d,children:[_,C]}),e[40]=C,e[41]=d,e[42]=_,e[43]=w):w=e[43],w}function vs(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)(gr,{children:`Delete Project`}),t[0]=o):o=t[0];let s;t[1]===r?s=t[2]:(s=(0,$.jsxs)(xr,{children:[o,(0,$.jsxs)(hr,{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)(br,{children:`Cancel`}),t[3]=c):c=t[3];let l;t[4]===a?l=t[5]:(l=(0,$.jsxs)(yr,{children:[c,(0,$.jsx)(vr,{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)(_r,{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)(Sr,{open:n,onOpenChange:i,children:u}),t[9]=i,t[10]=n,t[11]=u,t[12]=d):d=t[12],d}function ys(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)(gr,{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)(xr,{children:[o,(0,$.jsxs)(hr,{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(bs),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)(br,{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)(vr,{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)(yr,{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)(_r,{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)(Sr,{open:n,onOpenChange:a,children:h}),t[24]=n,t[25]=a,t[26]=h,t[27]=g):g=t[27],g}function bs(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 xs(){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=Ss;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)(xr,{children:[(0,$.jsx)(gr,{children:`Service unavailable`}),(0,$.jsx)(hr,{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)(Sr,{open:!0,children:(0,$.jsxs)(_r,{children:[c,l,(0,$.jsx)(yr,{children:(0,$.jsx)(U,{onClick:a,children:`Retry`})})]})}),e[5]=u):u=e[5],u}function Ss(){window.location.assign(window.location.href)}var Cs=Kn,ws=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)(Gn,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});ws.displayName=Gn.displayName;var Ts=A(`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`}}),Es=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(Ts({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)(Dn,{ref:t,className:o,...i}),n[7]=i,n[8]=t,n[9]=o,n[10]=s):s=n[10],s});Es.displayName=Dn.displayName;var Ds=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)(Un,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});Ds.displayName=Un.displayName;var Os=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)(Ct,{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)(qn,{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});Os.displayName=qn.displayName;var ks=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)(hn,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});ks.displayName=hn.displayName;var As=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)(jn,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});As.displayName=jn.displayName;function js(){let e=(0,Q.c)(5),{toasts:t}=pr(),n;e[0]===t?n=e[1]:(n=t.map(Ms),e[0]=t,e[1]=n);let r;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(ws,{}),e[2]=r):r=e[2];let i;return e[3]===n?i=e[4]:(i=(0,$.jsxs)(Cs,{children:[n,r]}),e[3]=n,e[4]=i),i}function Ms(e){let{id:t,title:n,description:r,action:i,...a}=e;return(0,$.jsxs)(Es,{...a,children:[(0,$.jsxs)(`div`,{className:`grid gap-1`,children:[n&&(0,$.jsx)(ks,{children:n}),r&&(0,$.jsx)(As,{children:r})]}),i,(0,$.jsx)(Os,{})]},t)}function Ns(){let e=(0,Q.c)(4),{resolvedTheme:t,theme:n}=Cr(),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 Ps(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)(Ns,{}),t[3]=i):i=t[3];let a;return t[4]!==n||t[5]!==r?(a=(0,$.jsxs)(wr,{...r,children:[i,n]}),t[4]=n,t[5]=r,t[6]=a):a=t[6],a}function Fs(){let{state:e,dispatch:t}=Xn(),{toast:n}=pr(),r=nr(`project-creation`).dispatch,[a,o]=(0,Z.useState)(null),s=(0,Z.useCallback)(async()=>{try{t({type:K.SetProjectsLoading,projectsLoading:!0});let e=await sn();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 Ke(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 i=e.useTerminalDispatch?r:t;i({type:K.ClearTerminalOutput}),i({type:K.SetTerminalOpen,open:!0}),i({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:r}=await a.read();if(n)break;l+=c.decode(r,{stream:!0});let s=l.split(`
48
+ `);l=s.pop()??``;for(let n of s){let r=n.trim();if(r)try{let n=JSON.parse(r);if(n.type===`progress`)!d&&n.threadId&&n.projectId&&(d=!0,f=n.projectId,p=n.threadId,t({type: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 r=e.includeThreadPath&&n.project.threads?.length>0?`${n.project.path}/${n.project.threads[0]}`:n.project.path;i({type:K.AppendTerminalLine,line:{type:`system`,content:`Project created successfully at: ${r}`}}),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}),ke();let m=await sn();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?r:t)({type:K.AppendTerminalLine,line:{type:`error`,content:`${e.catchErrorPrefix}: ${n instanceof Error?n.message:`Unknown error`}`}})}},[t,s,r]),u=(0,Z.useCallback)(async(e,t)=>{let n=e.split(`/`).pop()?.replace(`.git`,``)??`project`;await l({apiCall:()=>xt(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:()=>i(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 ae(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}),ke(),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 ln(n,r),ke(),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 $t(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 sn();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:te,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 Is(){let e=(0,Q.c)(2),[t,n]=(0,Z.useState)(Ls),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 Ls(){return document.hasFocus()}var Rs=null;function zs(){Rs??=new Audio(`/pop.wav`),Rs.currentTime=0,Rs.play().catch(e=>{console.debug(`Could not play completion sound:`,e)})}function Bs(){let{state:e,dispatch:t}=Xn(),n=Is(),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 en(),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&&zs(),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 Vs=768;function Hs(){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: ${Vs-1}px)`),t=()=>{n(window.innerWidth<Vs)};return e.addEventListener(`change`,t),n(window.innerWidth<Vs),()=>e.removeEventListener(`change`,t)},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),Z.useEffect(r,i),!!t}var Us=(0,Z.lazy)(()=>Wn(()=>import(`./terminal-panel-Cea0pLdX.js`).then(e=>({default:e.TerminalPanel})),__vite__mapDeps([21,1,2,14,15]))),Ws=(0,Z.lazy)(()=>Wn(()=>import(`./todos-view-DDVfCfgF.js`).then(e=>({default:e.TodosView})),[])),Gs=(0,Z.lazy)(()=>Wn(()=>import(`./diff-view-B8Grak1p.js`),__vite__mapDeps([10,1,5,6,2,7,11,12,13,14,15,16,17,18,19,8,20]))),Ks=(0,Z.lazy)(()=>Wn(()=>import(`./explorer-tab-view-lFzzjVe8.js`),__vite__mapDeps([22,1,5,6,2,7,18,14,15]))),qs=(0,Z.lazy)(()=>Wn(()=>import(`./browser-tab-DmootUHa.js`).then(e=>({default:e.BrowserTab})),__vite__mapDeps([23,1,2,24,6,3,14,15]))),Js=(0,Z.lazy)(()=>Wn(()=>import(`./dialogs-config-Dwpv4SNp.js`).then(e=>e.t),__vite__mapDeps([2,1]))),Ys=(0,Z.lazy)(()=>Wn(()=>import(`./onboarding-dialog-DSmKEXk4.js`),__vite__mapDeps([25,12,1,6,2]))),Xs=(0,Z.lazy)(()=>Wn(()=>import(`./conversation-history-view-DjO711iz.js`),__vite__mapDeps([26,6,1,2]))),Zs=(0,Z.lazy)(()=>Wn(()=>import(`./settings-view-CxiVTevy.js`),__vite__mapDeps([27,1,5,6,2,7,28,18])));function Qs(){let{state:e,dispatch:t}=Xn();(0,Z.useEffect)(()=>{window.__electrobunWebviewId&&new Jr({})},[]);let n=Pn(),r=Fn(),i=Hs(),{projects:a,handleSelectThread:o,handleCreateProject:s,handleCreateWebApp:c,handleOpenFolder:l,handleCreateThread:u,handleDeleteThread:d,confirmDeleteProject:f,refreshProjects:p,pendingSetupScriptConfirmation:m,resolveSetupScriptConfirmation:h}=Fs(),{processingThreadIds:g,completedThreadIds:_,clearCompleted:v}=Bs(),[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}=nr(e.selectedThreadId),R=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{L.open&&e.selectedThreadId===R.current&&b(`terminal`),R.current=e.selectedThreadId},[L.open,e.selectedThreadId]);let[ee,te]=(0,Z.useState)(!1),[B,ne]=(0,Z.useState)(!1),[re,ie]=(0,Z.useState)(!1),[ae,V]=(0,Z.useState)(null),[oe,se]=(0,Z.useState)(!1),[ce,H]=(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 Se()).updateAvailable&&se(!0)}catch{}})()},[]);let me=(0,Z.useCallback)(async()=>{H(!0);try{await an()}catch{H(!1)}},[]);(0,Z.useEffect)(()=>{re||(async()=>{try{(await $e()).onboardingCompleted||ne(!0)}catch(e){console.error(`Failed to check onboarding status:`,e)}finally{ie(!0)}})()},[re]),(0,Z.useEffect)(()=>{B||t({type:K.ConfigUpdated})},[B,t]);let he=(0,Z.useCallback)(e=>{let t=a.find(t=>t.projectId===e);t&&V({id:t.projectId,name:z(t)})},[a]),U=(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)(Dr.Provider,{value:_e,children:(0,$.jsxs)(or,{delayDuration:200,children:[(0,$.jsxs)(Rr,{direction:`horizontal`,className:`h-screen bg-background`,children:[(0,$.jsx)(Lr,{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)(ni,{projects:a,selectedThreadId:e.selectedThreadId,selectedProjectId:e.selectedProjectId,processingThreadIds:g,completedThreadIds:_,deletingThreadIds:e.deletingThreadIds,deletingProjectIds:e.deletingProjectIds,onSelectThread:ge,onCreateProject:()=>te(!0),onCreateThread:U,onDeleteThread:d,onDeleteProject:he,onNavigateToSettings:()=>void n(`/settings/providers`),onDeselect:()=>t({type:K.ClearSelection}),collapsed:!e.sidebarOpen,updateAvailable:oe,updatingApp:ce,onUpdateApp:me,onRefreshProjects:p})})}),!i&&(0,$.jsx)(zr,{withHandle:!0,className:e.sidebarOpen?`ml-[-40px]`:``}),(0,$.jsx)(Lr,{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)(_s,{}),!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)(Rn,{children:[(0,$.jsx)(Bn,{path:`/settings/:tab?`,element:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Zs,{})})}),(0,$.jsx)(Bn,{path:`/settings/project/:projectId`,element:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Zs,{})})}),(0,$.jsx)(Bn,{path:`/settings/add-skill`,element:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Zs,{})})}),(0,$.jsx)(Bn,{path:`/settings/add-command`,element:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Zs,{})})}),(0,$.jsx)(Bn,{path:`/settings/mcp-server-edit`,element:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Zs,{})})}),(0,$.jsx)(Bn,{path:`*`,element:(0,$.jsx)(fo,{onCreateThread:U})})]})}),(0,$.jsx)(`div`,{className:`flex-1 overflow-hidden${y===`terminal`&&!de&&!ue&&!fe?``:` hidden`}`,children:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Us,{})})}),(0,$.jsx)(`div`,{className:`flex-1 overflow-hidden${y===`browser`&&!de&&!ue&&!fe?``:` hidden`}`,children:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(qs,{})})}),!de&&!ue&&!fe&&y!==`chat`&&y!==`terminal`&&y!==`browser`&&(y===`explorer`?(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Ks,{})}):y===`tasks`&&e.selectedProjectId?(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Ws,{projectId:e.selectedProjectId})}):y===`history`?(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Xs,{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)(Gs,{threadId:e.selectedThreadId,onExit:()=>b(`chat`)})}):(0,$.jsx)(`div`,{className:`flex-1 overflow-hidden`}))]})}),(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Js,{open:ee,onOpenChange:te,onSubmitClone:s,onSubmitWebApp:c,onOpenFolder:l})}),(0,$.jsx)(vs,{open:ae!==null,projectName:ae?.name,onOpenChange:e=>!e&&V(null),onConfirm:()=>{ae&&(f(ae.id),V(null))}}),(0,$.jsx)(ys,{open:m!==null,setupScripts:m?[m.command,...m.remainingScripts||[]]:[],onConfirm:h}),(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Ys,{open:B,onOpenChange:ne,onComplete:()=>{ie(!0),p()}})}),(0,$.jsx)(xs,{})]}),(0,$.jsx)(js,{})]})})}function $s(){let e=(0,Q.c)(5),[t,n]=(0,Z.useReducer)(ir,er),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)(Qs,{}),e[2]=i):i=e[2];let a;return e[3]===r?a=e[4]:(a=(0,$.jsx)(Ps,{attribute:`class`,defaultTheme:`system`,enableSystem:!0,storageKey:`tarsk-theme`,children:(0,$.jsx)(tr.Provider,{value:r,children:i})}),e[3]=r,e[4]=a),a}var ec=!1;window.addEventListener(`resize`,()=>{ec||=(window.__electrobunWebviewId&&(document.body.style.height=`calc(100%)`),!0)}),(0,Br.createRoot)(document.getElementById(`root`)).render((0,$.jsx)(Z.StrictMode,{children:(0,$.jsx)(Nn,{children:(0,$.jsx)($s,{})})}));export{co as t};