tarsk 0.4.26 → 0.4.27
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.
- package/dist/index.js +197 -51
- package/dist/public/assets/account-view-BFhjAYmz.js +1 -0
- package/dist/public/assets/alert-dialog--tUzAWFm.js +1 -0
- package/dist/public/assets/api-BBbysRIh.js +1 -0
- package/dist/public/assets/{browser-tab-BNkQAd5u.js → browser-tab-DlzO5cMP.js} +1 -1
- package/dist/public/assets/chat-input-container-B_qVOGzW.js +21 -0
- package/dist/public/assets/context-menu-D5slxFcc.js +1 -0
- package/dist/public/assets/conversation-history-view-B4zHwyrw.js +1 -0
- package/dist/public/assets/{dialogs-config-BEsTbY1C.js → dialogs-config-DZFG2IQM.js} +3 -3
- package/dist/public/assets/diff-view-fOVqrHQW.js +3 -0
- package/dist/public/assets/explorer-tab-view-MLrWJ1Y0.js +2 -0
- package/dist/public/assets/{explorer-tree-KuYjR6r9.js → explorer-tree-8TyBYuC7.js} +1 -1
- package/dist/public/assets/{explorer-view-Cj6fyxMP.js → explorer-view-5U70mfAJ.js} +1 -1
- package/dist/public/assets/history-view-BR8scGnM.js +1 -0
- package/dist/public/assets/index-0BuHfewk.css +1 -0
- package/dist/public/assets/index-BTbiyooe.js +37 -0
- package/dist/public/assets/mcp-server-card-DupwHcKT.js +1 -0
- package/dist/public/assets/onboarding-Cn5RqOCa.js +1 -0
- package/dist/public/assets/onboarding-dialog-BXsvjU1t.js +1 -0
- package/dist/public/assets/{page-toolbar-DM-x5q1_.js → page-toolbar-TvYsDwUY.js} +1 -1
- package/dist/public/assets/{project-settings-view-wkrbmymL.js → project-settings-view-C7GW_R0m.js} +1 -1
- package/dist/public/assets/providers-list-view-AVt5I1WB.js +1 -0
- package/dist/public/assets/radio-group-Mifbn8sU.js +1 -0
- package/dist/public/assets/react-vendor-Bao-KYKs.js +22 -0
- package/dist/public/assets/resizable-DzrIos_Y.js +1 -0
- package/dist/public/assets/{run-stop-button-CZ62jJDn.js → run-stop-button-k1LeM0M-.js} +2 -2
- package/dist/public/assets/settings-instructions-view-CgfWSPmK.js +1 -0
- package/dist/public/assets/settings-mcp-servers-view-Becs_RxN.js +5 -0
- package/dist/public/assets/settings-models-view-BqdD_7GR.js +1 -0
- package/dist/public/assets/settings-rules-view-D7j5OHUi.js +8 -0
- package/dist/public/assets/settings-skills-view-aPv03-bO.js +2 -0
- package/dist/public/assets/settings-slash-commands-view-DLMWXQXA.js +1 -0
- package/dist/public/assets/settings-subagents-view-DBYzNE4W.js +2 -0
- package/dist/public/assets/settings-view-CccwUKkf.js +2 -0
- package/dist/public/assets/{side-panel-container-DVnN8vFb.js → side-panel-container-oMcXib2A.js} +2 -2
- package/dist/public/assets/skeleton-Bc0U0oGc.js +1 -0
- package/dist/public/assets/{standard-list-item-ByRgCvKd.js → standard-list-item-D2lbPXa1.js} +1 -1
- package/dist/public/assets/{store-Dyy2UFdD.js → store-CwvBC-YP.js} +1 -1
- package/dist/public/assets/{tab-context-DBrXMyNd.js → tab-context-CCvlrC0o.js} +1 -1
- package/dist/public/assets/{tabs-DxQZhlZp.js → tabs-Mb_cjIfE.js} +1 -1
- package/dist/public/assets/{terminal-panel-COYGYBV5.js → terminal-panel-GuO2XygM.js} +2 -2
- package/dist/public/assets/{textarea-CUYwgm5q.js → textarea-DpXOZLt8.js} +1 -1
- package/dist/public/assets/todos-view-C4GMi1Np.js +1 -0
- package/dist/public/assets/{use-toast-BqYP6xbg.js → use-toast-DqmC-mB5.js} +1 -1
- package/dist/public/assets/{utils-BavofGRh.js → utils-Cy2s2TEb.js} +1 -1
- package/dist/public/assets/whisper-wasm-Clnf-l-9.js +2 -0
- package/dist/public/index.html +21 -20
- package/dist/public/wasm/libmain-CWYJvMY5.js +3318 -0
- package/dist/public/wasm/libmain-D9-QM3iM.mjs +3301 -0
- package/package.json +4 -3
- package/dist/public/assets/account-view-g3bIVa-z.js +0 -1
- package/dist/public/assets/alert-dialog-DXEB8gMn.js +0 -1
- package/dist/public/assets/api-DQLZE-zX.js +0 -1
- package/dist/public/assets/chat-input-container-C8o4YcJZ.js +0 -1
- package/dist/public/assets/context-menu-CThafUml.js +0 -1
- package/dist/public/assets/conversation-history-view-64T6FDPb.js +0 -1
- package/dist/public/assets/diff-view-DgR-WEkB.js +0 -3
- package/dist/public/assets/explorer-tab-view-B53xe5xM.js +0 -2
- package/dist/public/assets/history-view-_L50vkTM.js +0 -1
- package/dist/public/assets/index-CAoVFXj2.css +0 -1
- package/dist/public/assets/index-Q5OqmtNF.js +0 -50
- package/dist/public/assets/onboarding-C_q_uRK0.js +0 -1
- package/dist/public/assets/onboarding-dialog-Cum5S2wE.js +0 -1
- package/dist/public/assets/provider-details-view-jc3yYdzr.js +0 -1
- package/dist/public/assets/providers-sidebar-B796hXzU.js +0 -1
- package/dist/public/assets/react-vendor-QkuITxN7.js +0 -17
- package/dist/public/assets/resizable-GT3fWOfA.js +0 -1
- package/dist/public/assets/settings-view-BbL7i34u.js +0 -2
- package/dist/public/assets/todos-view-DB99PEKH.js +0 -1
- /package/dist/public/assets/{dist-CIGnaqp2.js → dist-BI23Ei33.js} +0 -0
- /package/dist/public/assets/{monaco-c-HyCuEi.js → monaco-DDfTQM3i.js} +0 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/project-settings-view-C7GW_R0m.js","assets/rolldown-runtime-B1FJdls4.js","assets/react-vendor-Bao-KYKs.js","assets/history-view-BR8scGnM.js","assets/dialogs-config-DZFG2IQM.js","assets/monaco-DDfTQM3i.js","assets/textarea-DpXOZLt8.js","assets/use-toast-DqmC-mB5.js","assets/dist-BI23Ei33.js","assets/diff-view-fOVqrHQW.js","assets/chat-input-container-B_qVOGzW.js","assets/onboarding-Cn5RqOCa.js","assets/alert-dialog--tUzAWFm.js","assets/store-CwvBC-YP.js","assets/tab-context-CCvlrC0o.js","assets/whisper-wasm-Clnf-l-9.js","assets/utils-Cy2s2TEb.js","assets/page-toolbar-TvYsDwUY.js","assets/context-menu-D5slxFcc.js","assets/resizable-DzrIos_Y.js","assets/standard-list-item-D2lbPXa1.js","assets/terminal-panel-GuO2XygM.js","assets/explorer-tab-view-MLrWJ1Y0.js","assets/browser-tab-DlzO5cMP.js","assets/run-stop-button-k1LeM0M-.js","assets/onboarding-dialog-BXsvjU1t.js","assets/conversation-history-view-B4zHwyrw.js","assets/settings-view-CccwUKkf.js","assets/side-panel-container-oMcXib2A.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{$i as t,A as n,An as r,B as i,Bn as a,Cn as o,Ct as s,Dn as c,Dr as l,E as u,Ei as d,En as f,F as p,Fi as m,Fn as h,Gi as g,Gn as _,Hn as v,Hr as y,Ht as b,Ii as x,It as S,Jn as C,Jr as w,Jt as T,Ki as E,Kn as D,Kt as O,L as k,Li as A,Ln as j,Lr as M,Lt as N,M as P,Mi as F,Mn as I,Mr as L,Ni as R,Nr as ee,O as z,Oi as B,On as V,Pr as te,Qi as H,Qn as ne,Qr as re,Ri as ie,Rn as U,Rr as ae,Rt as oe,S as se,Si as ce,St as le,Tn as ue,Ui as de,Un as W,Ur as G,Vr as fe,Vt as pe,Wn as me,Wt as he,Xn as ge,Xt as _e,Y as ve,Yi as ye,Yr as be,Yt as xe,Z as Se,Zi as Ce,Zn as we,Zr as Te,Zt as Ee,_ as De,_a as Oe,aa as ke,ai as Ae,bi as je,bn as Me,ca as Ne,ci as Pe,cn as Fe,ct as Ie,da as Le,di as Re,ea as ze,ei as Be,en as Ve,f as He,fa as Ue,fi as We,ft as Ge,g as Ke,gi as qe,h as Je,ha as Ye,ia as Xe,in as Ze,jr as Qe,k as $e,kn as et,kt as tt,la as nt,li as rt,ln as it,lt as at,mn as ot,na as st,nn as ct,o as lt,oi as ut,p as dt,pa as ft,pi as pt,pn as mt,pt as ht,qn as gt,qt as _t,ra as vt,ri as yt,rn as bt,sa as xt,st as St,ta as Ct,ti as wt,tt as Tt,ui as Et,v as Dt,va as Ot,vn as kt,x as At,xi as jt,xn as Mt,ya as Nt,yi as Pt,yt as Ft,zi as It,zr as Lt,zt as Rt}from"./dialogs-config-DZFG2IQM.js";import{C as zt,D as Bt,E as Vt,O as Ht,T as Ut,_t as Wt,bt as Gt,et as Kt,gt as qt,ht as Jt,it as Yt,k as Xt,mt as Zt,nt as Qt,rt as $t,tt as en,vt as tn,w as nn,xt as rn}from"./react-vendor-Bao-KYKs.js";import{a as an,c as on,d as sn,f as cn,i as ln,n as un,o as dn,p as fn,r as pn,t as K}from"./store-CwvBC-YP.js";import{t as mn}from"./textarea-DpXOZLt8.js";import{c as q,l as hn,s as J,u as Y}from"./history-view-BR8scGnM.js";import{_ as gn,a as _n,c as vn,d as yn,f as bn,g as xn,h as Sn,i as Cn,l as wn,m as Tn,n as En,o as Dn,p as On,r as kn,s as An,t as jn,u as Mn}from"./chat-input-container-B_qVOGzW.js";import{n as Nn,t as X}from"./use-toast-DqmC-mB5.js";import{t as Pn}from"./standard-list-item-D2lbPXa1.js";import{a as Fn,c as In,i as Ln,n as Rn,o as zn,r as Bn,s as Vn,t as Hn}from"./alert-dialog--tUzAWFm.js";import{t as Un}from"./side-panel-container-oMcXib2A.js";import{n as Wn,t as Gn}from"./tab-context-CCvlrC0o.js";import{n as Kn,r as qn}from"./onboarding-Cn5RqOCa.js";import{n as Jn,t as Yn}from"./run-stop-button-k1LeM0M-.js";import{n as Xn,t as Zn}from"./utils-Cy2s2TEb.js";import{i as Qn,n as $n,r as er,t as tr}from"./tabs-Mb_cjIfE.js";import{t as nr}from"./page-toolbar-TvYsDwUY.js";import{n as rr,r as ir,t as ar}from"./resizable-DzrIos_Y.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(Nt(),1),or=rn(),Q=Oe(),sr=1e10,cr=1e3;function lr(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 ur(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=cr}=e;e.transport&&i(e.transport),e.requestHandler&&a(e.requestHandler),e._debugHooks&&(t=e._debugHooks);let s=0;function c(){return s<=sr?++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 lr([`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 lr([`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 lr([`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 lr([`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 dr(e,t){let n=ur({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 fr=window.__electrobunWebviewId,pr=window.__electrobunRpcSocketPort,mr=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:${pr}/socket?webviewId=${fr}`);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 dr(`webview`,{...e,extraRequestHandlers:{evaluateJavascriptWithResponse:({script:e})=>new Promise(t=>{try{let n=Function(e)();n instanceof Promise?n.then(e=>{t(e)}).catch(e=>{console.error(`bun: async script execution failed`,e),t(String(e))}):t(n)}catch(e){console.error(`bun: failed to eval script`,e),t(String(e))}})}})}},$=l();function hr(e){let t=(0,Q.c)(47),{open:n,onOpenChange:r,feedbackName:i,onFeedbackNameChange:a,feedbackEmail:o,onFeedbackEmailChange:s,feedbackText:c,onFeedbackTextChange:l,loadingFeedbackUser:u,submittingFeedback:d,onSubmit:f}=e,p;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsxs)(D,{children:[(0,$.jsx)(gt,{children:`Send Feedback`}),(0,$.jsx)(me,{children:`Share feedback about Tarsk.`})]}),t[0]=p):p=t[0];let m;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(h,{htmlFor:`feedback-name`,children:`Name`}),t[1]=m):m=t[1];let g;t[2]===a?g=t[3]:(g=e=>a(e.target.value),t[2]=a,t[3]=g);let y=d||u,b;t[4]!==i||t[5]!==g||t[6]!==y?(b=(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[m,(0,$.jsx)(j,{id:`feedback-name`,value:i,onChange:g,placeholder:`Your name`,disabled:y})]}),t[4]=i,t[5]=g,t[6]=y,t[7]=b):b=t[7];let x;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(h,{htmlFor:`feedback-email`,children:`Email`}),t[8]=x):x=t[8];let S;t[9]===s?S=t[10]:(S=e=>s(e.target.value),t[9]=s,t[10]=S);let C=d||u,w;t[11]!==o||t[12]!==S||t[13]!==C?(w=(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[x,(0,$.jsx)(j,{id:`feedback-email`,type:`email`,value:o,onChange:S,placeholder:`you@example.com`,disabled:C})]}),t[11]=o,t[12]=S,t[13]=C,t[14]=w):w=t[14];let T;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(h,{htmlFor:`feedback-text`,children:`Feedback`}),t[15]=T):T=t[15];let E;t[16]===l?E=t[17]:(E=e=>l(e.target.value),t[16]=l,t[17]=E);let O;t[18]!==c||t[19]!==d||t[20]!==E?(O=(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[T,(0,$.jsx)(mn,{id:`feedback-text`,value:c,onChange:E,placeholder:`Tell us what you think...`,className:`min-h-32`,disabled:d})]}),t[18]=c,t[19]=d,t[20]=E,t[21]=O):O=t[21];let k;t[22]!==O||t[23]!==b||t[24]!==w?(k=(0,$.jsxs)(`div`,{className:`grid gap-4 py-2`,children:[b,w,O]}),t[22]=O,t[23]=b,t[24]=w,t[25]=k):k=t[25];let A;t[26]===r?A=t[27]:(A=()=>r(!1),t[26]=r,t[27]=A);let M;t[28]!==d||t[29]!==A?(M=(0,$.jsx)(U,{variant:`outline`,onClick:A,disabled:d,children:`Cancel`}),t[28]=d,t[29]=A,t[30]=M):M=t[30];let N;t[31]===d?N=t[32]:(N=d?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ce,{className:`mr-2 h-4 w-4 animate-spin`}),`Sending...`]}):`Send Feedback`,t[31]=d,t[32]=N);let P;t[33]!==f||t[34]!==d||t[35]!==N?(P=(0,$.jsx)(U,{onClick:f,disabled:d,children:N}),t[33]=f,t[34]=d,t[35]=N,t[36]=P):P=t[36];let F;t[37]!==M||t[38]!==P?(F=(0,$.jsxs)(_,{children:[M,P]}),t[37]=M,t[38]=P,t[39]=F):F=t[39];let I;t[40]!==k||t[41]!==F?(I=(0,$.jsxs)(W,{className:`max-w-xl`,children:[p,k,F]}),t[40]=k,t[41]=F,t[42]=I):I=t[42];let L;return t[43]!==r||t[44]!==n||t[45]!==I?(L=(0,$.jsx)(v,{open:n,onOpenChange:r,children:I}),t[43]=r,t[44]=n,t[45]=I,t[46]=L):L=t[46],L}function gr(){let[e,t]=(0,Z.useState)(!1),[n,i]=(0,Z.useState)(``),[a,o]=(0,Z.useState)(``),[s,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(!1);return(0,Z.useEffect)(()=>{if(!e)return;let t=!0;return u(!0),Ie().then(e=>{t&&(i(t=>t||e.name),o(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&&u(!1)}),()=>{t=!1}},[e]),{showFeedback:e,feedbackName:n,setFeedbackName:i,feedbackEmail:a,setFeedbackEmail:o,feedbackText:s,setFeedbackText:c,loadingFeedbackUser:l,submittingFeedback:d,handleFeedbackDialogChange:e=>{t(e),e||c(``)},handleSubmitFeedback:async()=>{let e=s.trim();if(!e){X({title:`Feedback required`,description:`Please enter your feedback before submitting.`,variant:`destructive`});return}f(!0);try{await r(`api/feedback`,{name:n.trim(),email:a.trim(),feedback:e}),X({title:`Feedback sent`,description:`Thanks for sharing your feedback.`}),c(``),t(!1)}catch(e){X({title:`Failed to send feedback`,description:e instanceof Error?e.message:`Please try again.`,variant:`destructive`})}finally{f(!1)}}}}var _r=(0,Z.lazy)(()=>Gt(()=>import(`./project-settings-view-C7GW_R0m.js`),__vite__mapDeps([0,1,2,3,4,5,6,7])));function vr(e){let t=(0,Q.c)(89),{projects:n,selectedThreadId:r,selectedProjectId:i,processingThreadIds:a,completedThreadIds:o,deletingThreadIds:s,deletingProjectIds:c,onSelectThread:l,onCreateProject:u,onCreateThread:d,onDeleteThread:f,onDeleteProject:p,onDeselect:m,collapsed:h,updateAvailable:g,updatingApp:_,onUpdateApp:y,onRefreshProjects:b,expandProjectId:x}=e,S=tn(),[C,w]=(0,Z.useState)(null),{showFeedback:T,feedbackName:D,setFeedbackName:O,feedbackEmail:k,setFeedbackEmail:A,feedbackText:j,setFeedbackText:M,loadingFeedbackUser:N,submittingFeedback:P,handleFeedbackDialogChange:F,handleSubmitFeedback:L}=gr(),R;t[0]===n?R=t[1]:(R=n.map(yr),t[0]=n,t[1]=R);let ee=R,z;t[2]!==h||t[3]!==u?(z=!h&&(0,$.jsxs)(U,{variant:`outline`,size:`sm`,className:`gap-2`,onClick:u,children:[(0,$.jsx)(Ae,{className:`h-4 w-4 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:`New Project`})]}),t[2]=h,t[3]=u,t[4]=z):z=t[4];let B;t[5]!==h||t[6]!==y||t[7]!==g||t[8]!==_?(B=g&&(0,$.jsxs)(U,{variant:`ghost`,size:`sm`,className:`w-full justify-start gap-2 text-emerald-600 dark:text-emerald-400`,onClick:y,disabled:_,children:[_?(0,$.jsx)(ce,{className:`h-4 w-4 animate-spin`}):(0,$.jsx)(E,{className:`h-4 w-4`}),!h&&(0,$.jsx)(`span`,{className:`truncate`,children:_?`Updating...`:`Update to Latest`})]}),t[5]=h,t[6]=y,t[7]=g,t[8]=_,t[9]=B):B=t[9];let V;t[10]===S?V=t[11]:(V=()=>void S(`/settings`),t[10]=S,t[11]=V);let te;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,$.jsx)(Te,{className:`h-4 w-4`}),t[12]=te):te=t[12];let H;t[13]===h?H=t[14]:(H=!h&&(0,$.jsx)(`span`,{className:`truncate`,children:`Settings`}),t[13]=h,t[14]=H);let ne;t[15]!==V||t[16]!==H?(ne=(0,$.jsxs)(U,{variant:`ghost`,size:`sm`,className:`flex-1 justify-start gap-2 text-sidebar-foreground`,onClick:V,children:[te,H]}),t[15]=V,t[16]=H,t[17]=ne):ne=t[17];let re;t[18]===F?re=t[19]:(re=()=>F(!0),t[18]=F,t[19]=re);let ie,ae;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(ae=(0,$.jsx)(Pt,{className:`h-4 w-4`}),ie=(0,$.jsx)(`span`,{className:`sr-only`,children:`Feedback`}),t[20]=ie,t[21]=ae):(ie=t[20],ae=t[21]);let oe;t[22]===re?oe=t[23]:(oe=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(U,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground hover:text-background`,onClick:re,children:[ae,ie]})}),t[22]=re,t[23]=oe);let se;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(se=(0,$.jsx)(q,{children:`Send feedback to the Tarsk team`}),t[24]=se):se=t[24];let le;t[25]===oe?le=t[26]:(le=(0,$.jsx)(hn,{children:(0,$.jsxs)(J,{children:[oe,se]})}),t[25]=oe,t[26]=le);let ue;t[27]!==le||t[28]!==ne?(ue=(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[ne,le]}),t[27]=le,t[28]=ne,t[29]=ue):ue=t[29];let de;t[30]!==ue||t[31]!==B?(de=(0,$.jsxs)(`div`,{className:`px-3 py-2 flex flex-col gap-1`,children:[B,ue]}),t[30]=ue,t[31]=B,t[32]=de):de=t[32];let G;t[33]===n.length?G=t[34]:(G=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[33]=n.length,t[34]=G);let fe;t[35]===x?fe=t[36]:(fe=x?[x]:void 0,t[35]=x,t[36]=fe);let pe;t[37]!==o||t[38]!==c||t[39]!==s||t[40]!==d||t[41]!==p||t[42]!==f||t[43]!==l||t[44]!==a||t[45]!==n||t[46]!==i||t[47]!==r?(pe=(e,t)=>{let{isOpen:u,toggle:m}=t;return e.kind===`project`?(0,$.jsx)(br,{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)(xr,{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:`${ge(n.find(t=>t.projectId===e.projectId))} - `,onSelectThread:l,onDeleteThread:f})},t[37]=o,t[38]=c,t[39]=s,t[40]=d,t[41]=p,t[42]=f,t[43]=l,t[44]=a,t[45]=n,t[46]=i,t[47]=r,t[48]=pe):pe=t[48];let me;t[49]!==ee||t[50]!==fe||t[51]!==pe?(me=(0,$.jsx)(gn,{nodes:ee,defaultOpen:!0,forceOpenIds:fe,childContainerClassName:`ml-4 border-l border-sidebar-border pl-2`,renderNode:pe}),t[49]=ee,t[50]=fe,t[51]=pe,t[52]=me):me=t[52];let he;t[53]!==G||t[54]!==me?(he=(0,$.jsx)(I,{className:`flex-1 w-full`,children:(0,$.jsxs)(`div`,{className:`px-2 py-2 w-full max-w-full overflow-hidden`,children:[G,me]})}),t[53]=G,t[54]=me,t[55]=he):he=t[55];let _e;t[56]!==h||t[57]!==m||t[58]!==de||t[59]!==z||t[60]!==he?(_e=(0,$.jsx)(Un,{collapsed:h,onLogoClick:m,headerAction:z,footer:de,children:he}),t[56]=h,t[57]=m,t[58]=de,t[59]=z,t[60]=he,t[61]=_e):_e=t[61];let ve=C!==null,ye;t[62]===Symbol.for(`react.memo_cache_sentinel`)?(ye=e=>!e&&w(null),t[62]=ye):ye=t[62];let be;t[63]===b?be=t[64]:(be=()=>{b?.(),w(null)},t[63]=b,t[64]=be);let xe;t[65]!==C||t[66]!==be?(xe=(0,$.jsx)(W,{className:`max-w-2xl p-0 overflow-auto max-h-[90vh]`,children:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(_r,{projectId:C,onProjectUpdated:be})})}),t[65]=C,t[66]=be,t[67]=xe):xe=t[67];let Se;t[68]!==ve||t[69]!==xe?(Se=(0,$.jsx)(v,{open:ve,onOpenChange:ye,children:xe}),t[68]=ve,t[69]=xe,t[70]=Se):Se=t[70];let Ce;t[71]===L?Ce=t[72]:(Ce=()=>void L(),t[71]=L,t[72]=Ce);let we;t[73]!==k||t[74]!==D||t[75]!==j||t[76]!==F||t[77]!==N||t[78]!==A||t[79]!==O||t[80]!==M||t[81]!==T||t[82]!==P||t[83]!==Ce?(we=(0,$.jsx)(hr,{open:T,onOpenChange:F,feedbackName:D,onFeedbackNameChange:O,feedbackEmail:k,onFeedbackEmailChange:A,feedbackText:j,onFeedbackTextChange:M,loadingFeedbackUser:N,submittingFeedback:P,onSubmit:Ce}),t[73]=k,t[74]=D,t[75]=j,t[76]=F,t[77]=N,t[78]=A,t[79]=O,t[80]=M,t[81]=T,t[82]=P,t[83]=Ce,t[84]=we):we=t[84];let Ee;return t[85]!==_e||t[86]!==Se||t[87]!==we?(Ee=(0,$.jsxs)($.Fragment,{children:[_e,Se,we]}),t[85]=_e,t[86]=Se,t[87]=we,t[88]=Ee):Ee=t[88],Ee}function yr(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 br(e){let t=(0,Q.c)(29),{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=ge(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=C(`h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform`,m),t[2]=m,t[3]=h);let g;t[4]===h?g=t[5]:(g=(0,$.jsx)(ke,{className:h}),t[4]=h,t[5]=g);let _;t[6]===n.gitUrl?_=t[7]:(_=n.gitUrl?(0,$.jsx)(It,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}):(0,$.jsx)(A,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}),t[6]=n.gitUrl,t[7]=_);let v=(o||s)&&`font-bold text-foreground`,y;t[8]===v?y=t[9]:(y=C(`min-w-0 truncate transition-all block`,v),t[8]=v,t[9]=y);let b;t[10]!==f||t[11]!==y?(b=(0,$.jsx)(`span`,{className:y,children:f}),t[10]=f,t[11]=y,t[12]=b):b=t[12];let x;t[13]!==g||t[14]!==_||t[15]!==b?(x=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1.5 w-0`,children:[g,_,b]}),t[13]=g,t[14]=_,t[15]=b,t[16]=x):x=t[16];let S;t[17]!==a||t[18]!==c||t[19]!==l||t[20]!==u||t[21]!==n.projectId||t[22]!==n.threads?(S=(0,$.jsx)(`div`,{className:`flex shrink-0 items-center ml-auto`,children:a?(0,$.jsx)(ce,{className:`h-3.5 w-3.5 shrink-0 animate-spin text-muted-foreground mr-1`}):(0,$.jsxs)(hn,{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)(Te,{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)(Ae,{}),(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)(fe,{}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Delete project`})]})}),(0,$.jsx)(q,{side:`right`,children:`Delete project`})]})]})}),t[17]=a,t[18]=c,t[19]=l,t[20]=u,t[21]=n.projectId,t[22]=n.threads,t[23]=S):S=t[23];let w;return t[24]!==i||t[25]!==x||t[26]!==S||t[27]!==p?(w=(0,$.jsxs)(Pn,{selected:p,noBackground:!0,className:`mb-1 h-9`,onClick:i,children:[x,S]}),t[24]=i,t[25]=x,t[26]=S,t[27]=p,t[28]=w):w=t[28],w}function xr(e){let t=(0,Q.c)(50),{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=(0,Z.useRef)(null),m=n.threadId===i,h,g;t[0]===a?(h=t[1],g=t[2]):(h=()=>{a&&p.current&&p.current.scrollIntoView({behavior:`smooth`,block:`nearest`})},g=[a],t[0]=a,t[1]=h,t[2]=g),(0,Z.useEffect)(h,g);let _;t[3]!==u||t[4]!==r||t[5]!==n.gitStatusDot||t[6]!==n.threadId?(_=e=>{e.stopPropagation(),n.gitStatusDot?f(!0):u(r,n.threadId)},t[3]=u,t[4]=r,t[5]=n.gitStatusDot,t[6]=n.threadId,t[7]=_):_=t[7];let v=_,y;t[8]!==c||t[9]!==n.threadId||t[10]!==n.title?(y=n.title?.startsWith(c)?n.title.slice(c.length):n.title??n.threadId,t[8]=c,t[9]=n.threadId,t[10]=n.title,t[11]=y):y=t[11];let b=y,x;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(In,{children:`Delete Thread`}),t[12]=x):x=t[12];let S;t[13]===b?S=t[14]:(S=(0,$.jsxs)(Fn,{children:[`Are you sure you want to delete "`,b,`" and all its files? This action cannot be undone.`]}),t[13]=b,t[14]=S);let C;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,$.jsx)(Bn,{children:`Cancel`}),t[15]=C):C=t[15];let w;t[16]!==u||t[17]!==r||t[18]!==n.threadId?(w=(0,$.jsxs)(`div`,{className:`flex gap-3 justify-end`,children:[C,(0,$.jsx)(Rn,{onClick:()=>{f(!1),u(r,n.threadId)},className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:`Delete`})]}),t[16]=u,t[17]=r,t[18]=n.threadId,t[19]=w):w=t[19];let T;t[20]!==S||t[21]!==w?(T=(0,$.jsxs)(Ln,{children:[x,S,w]}),t[20]=S,t[21]=w,t[22]=T):T=t[22];let E;t[23]!==d||t[24]!==T?(E=(0,$.jsx)(Hn,{open:d,onOpenChange:f,children:T}),t[23]=d,t[24]=T,t[25]=E):E=t[25];let D,O;t[26]!==l||t[27]!==r||t[28]!==n.threadId?(D=()=>l(r,n.threadId),O=e=>{(e.key===`Enter`||e.key===` `)&&l(r,n.threadId)},t[26]=l,t[27]=r,t[28]=n.threadId,t[29]=D,t[30]=O):(D=t[29],O=t[30]);let k;t[31]===n.gitStatusDot?k=t[32]:(k=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[31]=n.gitStatusDot,t[32]=k);let A;t[33]===b?A=t[34]:(A=(0,$.jsx)(`div`,{className:`flex-1 min-w-0 w-0`,children:(0,$.jsx)(`span`,{className:`text-sm truncate block`,children:b})}),t[33]=b,t[34]=A);let j;t[35]!==v||t[36]!==s||t[37]!==o||t[38]!==a?(j=a||o?(0,$.jsx)(ce,{className:`ml-auto h-3 w-3 shrink-0 animate-spin text-muted-foreground`}):s?(0,$.jsx)(Ne,{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:v,children:[(0,$.jsx)(fe,{}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Delete thread`})]})}),(0,$.jsx)(q,{side:`right`,children:`Delete thread and files from the repo`})]})}),t[35]=v,t[36]=s,t[37]=o,t[38]=a,t[39]=j):j=t[39];let M;t[40]!==m||t[41]!==D||t[42]!==O||t[43]!==k||t[44]!==A||t[45]!==j?(M=(0,$.jsxs)(Pn,{ref:p,selected:m,onClick:D,onKeyDown:O,role:`button`,tabIndex:0,children:[k,A,j]}),t[40]=m,t[41]=D,t[42]=O,t[43]=k,t[44]=A,t[45]=j,t[46]=M):M=t[46];let N;return t[47]!==E||t[48]!==M?(N=(0,$.jsxs)($.Fragment,{children:[E,M]}),t[47]=E,t[48]=M,t[49]=N):N=t[49],N}var Sr=18,Cr=4,wr=(Sr+Cr/2+2)*2,Tr=2*Math.PI*Sr;function Er(e){let t=(0,Q.c)(8),{eventCount:n}=e,r=Tr*(1-(n===void 0?0:n)%360/360),i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i={width:wr,height:wr},t[0]=i):i=t[0];let a,o;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a={position:`absolute`,inset:0},o=(0,$.jsx)(`circle`,{cx:wr/2,cy:wr/2,r:Sr,fill:`none`,stroke:`hsl(var(--brand) / 0.2)`,strokeWidth:Cr}),t[1]=a,t[2]=o):(a=t[1],o=t[2]);let s;t[3]===r?s=t[4]:(s=(0,$.jsxs)(`svg`,{className:`animate-spin-slow animate-radial-pulse-brand rounded-full`,width:wr,height:wr,style:a,children:[o,(0,$.jsx)(`circle`,{cx:wr/2,cy:wr/2,r:Sr,fill:`none`,stroke:`hsl(var(--brand))`,strokeWidth:Cr,strokeDasharray:Tr,strokeDashoffset:r,strokeLinecap:`round`})]}),t[3]=r,t[4]=s);let c;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(`div`,{className:`absolute flex items-center justify-center rounded-full bg-brand`,style:{inset:Cr+2},children:(0,$.jsx)(Le,{className:`h-3.5 w-3.5 text-white`})}),t[5]=c):c=t[5];let l;return t[6]===s?l=t[7]:(l=(0,$.jsxs)(`div`,{className:`relative shrink-0 self-end`,style:i,children:[s,c]}),t[6]=s,t[7]=l),l}var Dr=e(Ot(),1),Or=.1,kr=10,Ar=1.25,jr=.001;function Mr(){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=Nr,u;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>n(e=>l(e*Ar)),e[1]=u):u=e[1];let d=u,f;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=()=>n(e=>l(e/Ar)),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*jr;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 Nr(e){return Math.min(Math.max(e,Or),kr)}function Pr(){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 Fr(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 Gt(async()=>{let{renderMermaidSVG:e}=await import(`./dist-BI23Ei33.js`);return{renderMermaidSVG:e}},__vite__mapDeps([8,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 Ir(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}=Mr(),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)(Lr,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)(qe,{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 w;t[12]===i?w=t[13]:(w=Math.round(i*100),t[12]=i,t[13]=w);let T;t[14]!==u||t[15]!==w?(T=(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:[w,`%`]})}),t[14]=u,t[15]=w,t[16]=T):T=t[16];let E;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,$.jsx)(q,{children:`Reset zoom`}),t[17]=E):E=t[17];let D;t[18]===T?D=t[19]:(D=(0,$.jsxs)(J,{children:[T,E]}),t[18]=T,t[19]=D);let O,k;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,$.jsx)(Ae,{className:`h-3.5 w-3.5`}),k=(0,$.jsx)(`span`,{className:`sr-only`,children:`Zoom in`}),t[20]=O,t[21]=k):(O=t[20],k=t[21]);let A;t[22]===c?A=t[23]:(A=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(U,{variant:`ghost`,size:`icon-xs`,onClick:c,children:[O,k]})}),t[22]=c,t[23]=A);let j;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,$.jsx)(q,{children:`Zoom in`}),t[24]=j):j=t[24];let M;t[25]===A?M=t[26]:(M=(0,$.jsxs)(J,{children:[A,j]}),t[25]=A,t[26]=M);let N,P;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,$.jsx)(yt,{className:`h-3.5 w-3.5`}),P=(0,$.jsx)(`span`,{className:`sr-only`,children:`Reset view`}),t[27]=N,t[28]=P):(N=t[27],P=t[28]);let F;t[29]===u?F=t[30]:(F=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(U,{variant:`ghost`,size:`icon-xs`,onClick:u,children:[N,P]})}),t[29]=u,t[30]=F);let I;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,$.jsx)(q,{children:`Reset view`}),t[31]=I):I=t[31];let L;t[32]===F?L=t[33]:(L=(0,$.jsxs)(J,{children:[F,I]}),t[32]=F,t[33]=L);let R;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,$.jsx)(`div`,{className:`w-px h-4 bg-border mx-1`}),t[34]=R):R=t[34];let z,B;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,$.jsx)(ee,{className:`h-3.5 w-3.5`}),B=(0,$.jsx)(`span`,{className:`sr-only`,children:`Close`}),t[35]=z,t[36]=B):(z=t[35],B=t[36]);let V;t[37]===r?V=t[38]:(V=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(U,{variant:`ghost`,size:`icon-xs`,onClick:r,children:[z,B]})}),t[37]=r,t[38]=V);let te;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,$.jsx)(q,{children:`Close (Esc)`}),t[39]=te):te=t[39];let H;t[40]===V?H=t[41]:(H=(0,$.jsxs)(J,{children:[V,te]}),t[40]=V,t[41]=H);let ne;t[42]!==D||t[43]!==M||t[44]!==L||t[45]!==H||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,D,M,L,R,H]})]}),t[42]=D,t[43]=M,t[44]=L,t[45]=H,t[46]=S,t[47]=ne):ne=t[47];let re=o?`cursor-grabbing`:`cursor-grab`,ie;t[48]===re?ie=t[49]:(ie=C(`flex-1 overflow-hidden select-none`,re),t[48]=re,t[49]=ie);let ae=`translate(${a.x}px, ${a.y}px) scale(${i})`,oe=o?`none`:`transform 0.1s ease-out`,se;t[50]!==ae||t[51]!==oe?(se={transform:ae,transformOrigin:`center center`,transition:oe},t[50]=ae,t[51]=oe,t[52]=se):se=t[52];let ce;t[53]===n?ce=t[54]:(ce={__html:n},t[53]=n,t[54]=ce);let le;t[55]!==se||t[56]!==ce?(le=(0,$.jsx)(`div`,{className:`w-full h-full flex items-center justify-center`,style:se,dangerouslySetInnerHTML:ce}),t[55]=se,t[56]=ce,t[57]=le):le=t[57];let ue;t[58]!==s||t[59]!==d||t[60]!==f||t[61]!==p||t[62]!==ie||t[63]!==le?(ue=(0,$.jsx)(`div`,{ref:s,className:ie,onMouseDown:d,onMouseMove:f,onMouseUp:p,onMouseLeave:p,children:le}),t[58]=s,t[59]=d,t[60]=f,t[61]=p,t[62]=ie,t[63]=le,t[64]=ue):ue=t[64];let de;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(de=(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]=de):de=t[65];let W;return t[66]!==ne||t[67]!==ue?(W=(0,Dr.createPortal)((0,$.jsx)(hn,{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,ue,de]})}),document.body),t[66]=ne,t[67]=ue,t[68]=W):W=t[68],W}function Lr(){return document.body.style.overflow=`hidden`,Rr}function Rr(){document.body.style.overflow=``}function zr(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}=Fr(n,Pr()),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)(je,{}),(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)(Ne,{}):(0,$.jsx)(Ce,{}),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=C(`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=C(`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=C(`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 w;t[36]===c?w=t[37]:(w=(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]=w);let T;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(q,{children:`Click to view fullscreen`}),t[38]=T):T=t[38];let E;t[39]===w?E=t[40]:(E=(0,$.jsxs)(J,{children:[w,T]}),t[39]=w,t[40]=E);let D;t[41]!==b||t[42]!==x||t[43]!==E?(D=(0,$.jsxs)(`div`,{className:x,children:[b,E]}),t[41]=b,t[42]=x,t[43]=E,t[44]=D):D=t[44];let O;t[45]!==o||t[46]!==c?(O=o&&(0,$.jsx)(Ir,{svgOutput:c,onClose:()=>s(!1)}),t[45]=o,t[46]=c,t[47]=O):O=t[47];let k;return t[48]!==D||t[49]!==O?(k=(0,$.jsxs)(hn,{children:[D,O]}),t[48]=D,t[49]=O,t[50]=k):k=t[50],k}var Br=`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(`.`),Vr=[/-->/,/--\./,/-\./,/==>/,/--\|/,/\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 Hr(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(Br.some(e=>n===e.toLowerCase()||n.startsWith(e.toLowerCase()+` `)))return!0;let r=0;for(let t of Vr)t.test(e)&&r++;return r>=2}function Ur(e){if(!Hr(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 Br.some(e=>n===e.toLowerCase()||n.startsWith(e.toLowerCase()+` `))?e.trim():null}var Wr=(0,Z.memo)(function({content:e,className:t,enableMermaid:n=!1}){let r=(0,Z.useMemo)(()=>!e||typeof e!=`string`?[]:Gr(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:C(`prose-custom space-y-3 min-w-0 break-words`,t),children:r.map((e,t)=>(0,$.jsx)(Kr,{block:e,start:i[t]},t))})});function Gr(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`||Hr(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&&Hr(e)){let t=Ur(e);t?r.push({type:`mermaid`,code:t}):r.push({type:`paragraph`,text:e})}else r.push({type:`paragraph`,text:e})}}return r}var Kr=(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=C({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)(qr,{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)(Yr,{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)(qr,{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)(qr,{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(Xr),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)(qr,{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(Zr),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($r),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)(zr,{content:n.code}),t[40]=n.code,t[41]=e),e}default:return null}}),qr=(0,Z.memo)(function(e){let t=(0,Q.c)(6),{text:n}=e,r;t[0]===n?r=t[1]:(r=Jr(n),t[0]=n,t[1]=r);let i=r,a;t[2]===i?a=t[3]:(a=i.map(ei),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 Jr(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 Yr(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)(Ne,{}):(0,$.jsx)(Ce,{}),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 Xr(e,t){return(0,$.jsx)(`li`,{children:(0,$.jsx)(qr,{text:e})},t)}function Zr(e,t){return(0,$.jsx)(`th`,{className:`px-3 py-2 text-left font-medium`,children:(0,$.jsx)(qr,{text:e})},t)}function Qr(e,t){return(0,$.jsx)(`td`,{className:`px-3 py-2`,children:(0,$.jsx)(qr,{text:e})},t)}function $r(e,t){return(0,$.jsx)(`tr`,{className:`border-b border-border last:border-0`,children:e.map(Qr)},t)}function ei(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 ti(e){let t=e.toLowerCase();return t.includes(`read`)||t.includes(`file`)?Ue:t.includes(`create`)?Ae:t.includes(`replace`)||t.includes(`edit`)?w:t.includes(`delete`)?vt:t.includes(`terminal`)||t.includes(`bash`)||t.includes(`shell`)?G:t.includes(`run`)?L:t.includes(`git`)||t.includes(`branch`)?x:t.includes(`search`)||t.includes(`grep`)||t.includes(`find`)?Be:t.includes(`code`)||t.includes(`debug`)?H:t.includes(`test`)?st:t.includes(`agent`)||t.includes(`subagent`)?pt:t.includes(`copy`)?Ce:t.includes(`dir`)||t.includes(`list`)||t.includes(`ls`)?jt:t.includes(`view`)||t.includes(`show`)?de:t.includes(`config`)||t.includes(`setting`)?Te:t.includes(`image`)||t.includes(`generate_image`)?d:t.includes(`chat`)||t.includes(`message`)||t.includes(`ask`)?Pt:te}function ni(e){let t=e.toLowerCase();return t.includes(`bash`)||t.includes(`terminal`)||t.includes(`shell`)?`Ran`:t.includes(`read`)||t.includes(`file`)?`Read`:t===`ast_grep`?`Code Search`:t===`agent`?`Subagent`:t===`generate_image`?`Make Image`:e}function ri(e,t){if(!t||!e||typeof e!=`string`)return e;try{let n=t.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);return e.replace(new RegExp(n,`g`),`.`)}catch{return e}}function ii(e){return typeof e==`string`?e:typeof e==`object`&&e?JSON.stringify(e,null,2):String(e)}function ai(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 oi(e){if(typeof e!=`object`||!e)return e;if(Array.isArray(e))return e.map(oi);let t={};for(let[n,r]of Object.entries(e))if(typeof r==`string`){let e=ai(r);t[n]=typeof e==`object`?oi(e):r}else t[n]=oi(r);return t}function si(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 ci(e){if(e==null)return``;let t=typeof e==`object`&&e?oi(e):e;return si(typeof t==`string`?t:t==null?``:JSON.stringify(t,null,2))}function li(e,t){let n=e.name??`Unknown Tool`,r=e.id??`unknown`,i=e.input,a=i&&typeof i==`object`?i:null,o=i&&typeof i==`object`&&`description`in i,s=o?i.subagent_type:void 0,c=s==null?null:JSON.stringify(s),l=n===`agent`&&a&&typeof a.agentName==`string`?a.agentName:null,u=o?null:ri(ii(i),t),d=ri(o?String(i.prompt):null,t),f=ri(a&&typeof a.command==`string`?a.command:null,t),p=a&&typeof a.pattern==`string`?a.pattern:null,m=a&&typeof a.lang==`string`?a.lang:null,h=n===`code_search`,g=h&&a&&typeof a.query==`string`?a.query:null,_=h&&a&&typeof a.filePath==`string`?a.filePath:null,v=h&&a&&typeof a.fileGlob==`string`?a.fileGlob:null,y=ri(a&&typeof a.path==`string`?a.path:null,t),b=a&&typeof a.offset==`number`?a.offset:null,x=a&&typeof a.limit==`number`?a.limit:null,S=n.toLowerCase(),C=S.includes(`read`)||S.includes(`write`)||S.includes(`edit`),w=S.includes(`edit`),T=C&&a&&typeof a.path==`string`?a.path:null,E=T?T.split(`/`).pop()??T:null,D=w&&a&&typeof a.oldText==`string`?a.oldText:null,O=w&&a&&typeof a.newText==`string`?a.newText:null,k=D!==null&&O!==null,A=n===`generate_image`&&a&&typeof a.prompt==`string`?a.prompt:null,j=n===`todo`&&a?a.status:void 0,M=ti(n),N=(n===`todo`?j===`done`?st:j===`working`?Ct:ze:null)??M,P=n.charAt(0).toUpperCase()+n.slice(1);S===`bash`&&(P=`Ran`),S===`code_search`&&(P=`Code Search`),S===`generate_image`&&(P=`Make Image`),S.includes(`read`)&&(b!==null||x!==null)&&(b!==null&&x!==null?P+=` (lines ${b} to ${b+x})`:b===null?P+=` (${x} lines)`:P+=` (from line ${b})`);let F=`default`;return S===`bash`||S.includes(`terminal`)||S.includes(`shell`)?F=`bash`:C?F=`file`:h||S===`find`||S.includes(`search`)||S.includes(`grep`)?F=`search`:S===`agent`||S.includes(`subagent`)||o?F=`agent`:S===`todo`?F=`todo`:S===`generate_image`&&(F=`imageGen`),{toolType:F,toolName:n,toolId:r,displayName:P,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)(D,{children:(0,$.jsx)(gt,{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)(W,{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)(v,{open:n,onOpenChange:r,children:c}),t[7]=r,t[8]=n,t[9]=c,t[10]=l):l=t[10],l}function di(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(pi),o=s.map(fi),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 fi(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 pi(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 mi(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 hi(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 gi(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 _i(e){let t=(0,Q.c)(55),{data:n,inline:r,resultContent:i}=e,[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(!1);if(r){if(n.command!==null&&i){let e;t[0]===n.icon?e=t[1]:(e=(0,Z.createElement)(n.icon,{className:`h-3.5 w-3.5 shrink-0 text-brand`}),t[0]=n.icon,t[1]=e);let r;t[2]===n.displayName?r=t[3]:(r=(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n.displayName}),t[2]=n.displayName,t[3]=r);let a;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(a=()=>c(!0),t[4]=a):a=t[4];let o;t[5]===n.command?o=t[6]:(o=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:a,className:`text-xs font-mono text-muted-foreground hover:underline break-all cursor-pointer`,children:n.command})}),t[5]=n.command,t[6]=o);let l;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(q,{children:`View output`}),t[7]=l):l=t[7];let u;t[8]===o?u=t[9]:(u=(0,$.jsxs)(J,{children:[o,l]}),t[8]=o,t[9]=u);let d;t[10]!==e||t[11]!==r||t[12]!==u?(d=(0,$.jsxs)(`div`,{className:`py-0.5 flex items-center gap-2 flex-wrap`,children:[e,r,u]}),t[10]=e,t[11]=r,t[12]=u,t[13]=d):d=t[13];let f;t[14]!==n.command||t[15]!==s||t[16]!==i?(f=(0,$.jsx)(ui,{open:s,onOpenChange:c,title:n.command,content:i}),t[14]=n.command,t[15]=s,t[16]=i,t[17]=f):f=t[17];let p;return t[18]!==d||t[19]!==f?(p=(0,$.jsxs)($.Fragment,{children:[d,f]}),t[18]=d,t[19]=f,t[20]=p):p=t[20],p}let e=n.toolName,r;t[21]===n.icon?r=t[22]:(r=(0,Z.createElement)(n.icon,{className:`h-3.5 w-3.5 shrink-0 text-brand`}),t[21]=n.icon,t[22]=r);let a;t[23]===n.displayName?a=t[24]:(a=(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n.displayName}),t[23]=n.displayName,t[24]=a);let o;t[25]!==n.toolName||t[26]!==r||t[27]!==a?(o=(0,$.jsxs)(`span`,{title:e,className:`inline-flex items-center gap-1`,children:[r,a]}),t[25]=n.toolName,t[26]=r,t[27]=a,t[28]=o):o=t[28];let l;t[29]===n.command?l=t[30]:(l=n.command!==null&&(0,$.jsx)(`code`,{className:`text-xs font-mono text-muted-foreground break-all rounded bg-muted/60 px-1 py-0.5`,children:n.command}),t[29]=n.command,t[30]=l);let u;return t[31]!==o||t[32]!==l?(u=(0,$.jsxs)(`div`,{className:`py-0.5 flex items-center gap-2 flex-wrap`,children:[o,l]}),t[31]=o,t[32]=l,t[33]=u):u=t[33],u}let l;t[34]===a?l=t[35]:(l=()=>o(!a),t[34]=a,t[35]=l);let u=n.toolName,d;t[36]===n.icon?d=t[37]:(d=(0,Z.createElement)(n.icon,{className:`h-4 w-4 text-brand`}),t[36]=n.icon,t[37]=d);let f;t[38]===n.displayName?f=t[39]:(f=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:n.displayName}),t[38]=n.displayName,t[39]=f);let p;t[40]===a?p=t[41]:(p=a?(0,$.jsx)(xt,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(ke,{className:`h-4 w-4 shrink-0`}),t[40]=a,t[41]=p);let m;t[42]!==n.toolName||t[43]!==l||t[44]!==d||t[45]!==f||t[46]!==p?(m=(0,$.jsxs)(`button`,{onClick:l,className:`w-full py-2 flex items-center gap-2 text-sm font-medium text-foreground hover:bg-muted/50 transition-colors text-left`,title:u,children:[d,f,p]}),t[42]=n.toolName,t[43]=l,t[44]=d,t[45]=f,t[46]=p,t[47]=m):m=t[47];let h;t[48]!==n.toolId||t[49]!==n.toolInput||t[50]!==a?(h=a&&(0,$.jsxs)(`div`,{className:`py-2 border-t border-border`,children:[(0,$.jsxs)(`div`,{className:`text-xs text-muted-foreground mb-2 font-mono`,children:[`ID: `,n.toolId]}),n.toolInput?(0,$.jsx)(`pre`,{className:`text-xs bg-slate-100 dark:bg-slate-900 p-2 rounded font-mono whitespace-pre-wrap overflow-auto max-h-48`,children:n.toolInput}):null]}),t[48]=n.toolId,t[49]=n.toolInput,t[50]=a,t[51]=h):h=t[51];let g;return t[52]!==m||t[53]!==h?(g=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[m,h]}),t[52]=m,t[53]=h,t[54]=g):g=t[54],g}var vi=Qt,yi=$t,bi=Z.forwardRef((e,t)=>{let n=(0,Q.c)(13),r,i,a,o;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4]):({className:r,align:a,sideOffset:o,...i}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let s=a===void 0?`center`:a,c=o===void 0?4:o,l;n[5]===r?l=n[6]:(l=C(`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)(en,{children:(0,$.jsx)(Kt,{ref:t,align:s,sideOffset:c,className:l,...i})}),n[7]=s,n[8]=i,n[9]=t,n[10]=c,n[11]=l,n[12]=u):u=n[12],u});bi.displayName=Kt.displayName;function xi(e){let t=(0,Q.c)(45),{data:n,inline:r,rootPath:i,onOpenFile:a}=e,[o,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(!1),u;t[0]!==n.filePath||t[1]!==a||t[2]!==i?(u=function(){!n.filePath||!a||a(i&&n.filePath.startsWith(i)?n.filePath.slice(i.length+1):n.filePath)},t[0]=n.filePath,t[1]=a,t[2]=i,t[3]=u):u=t[3];let d=u;if(r){let e=!!(n.toolInput&&!n.command&&!n.path&&!n.pattern&&!n.fileDisplayName),r;t[4]!==n.displayName||t[5]!==n.icon||t[6]!==n.toolId||t[7]!==n.toolInput||t[8]!==n.toolName||t[9]!==e?(r=e?(0,$.jsxs)(vi,{children:[(0,$.jsx)(yi,{asChild:!0,children:(0,$.jsx)(`span`,{title:n.toolName,className:`inline-flex`,children:(0,$.jsxs)(`button`,{type:`button`,className:`inline-flex shrink-0 items-center gap-1 rounded p-0.5 text-muted-foreground hover:text-foreground focus:outline-none focus-visible:ring-2 focus-visible:ring-ring`,"aria-label":`Show tool details`,children:[(0,Z.createElement)(n.icon,{className:`h-3.5 w-3.5 text-brand`}),(0,$.jsx)(`span`,{className:`text-xs`,children:n.displayName})]})})}),(0,$.jsx)(bi,{className:`w-80 max-h-80 overflow-auto`,align:`start`,children:(0,$.jsxs)(`div`,{className:`text-xs text-muted-foreground space-y-2`,children:[(0,$.jsxs)(`div`,{className:`font-mono`,children:[`ID: `,n.toolId]}),(0,$.jsx)(`pre`,{className:`font-mono whitespace-pre-wrap overflow-auto max-h-48`,children:n.toolInput})]})})]}):(0,$.jsxs)(`span`,{title:n.toolName,className:`inline-flex items-center gap-1`,children:[(0,Z.createElement)(n.icon,{className:`h-3.5 w-3.5 shrink-0 text-brand`}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n.displayName})]}),t[4]=n.displayName,t[5]=n.icon,t[6]=n.toolId,t[7]=n.toolInput,t[8]=n.toolName,t[9]=e,t[10]=r):r=t[10];let a;t[11]!==n.editNewText||t[12]!==n.editOldText||t[13]!==n.fileDisplayName||t[14]!==n.filePath||t[15]!==n.hasEditDiff||t[16]!==n.path||t[17]!==c||t[18]!==d||t[19]!==i?(a=n.fileDisplayName?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:n.hasEditDiff?()=>l(!0):d,className:C(`text-xs font-mono truncate max-w-[200px] sm:max-w-[320px] cursor-pointer`,`text-muted-foreground hover:underline`),children:n.fileDisplayName})}),(0,$.jsx)(q,{children:n.hasEditDiff?`View diff`:n.filePath?ri(n.filePath,i)??n.filePath:n.fileDisplayName})]}),n.hasEditDiff&&(0,$.jsx)(v,{open:c,onOpenChange:l,children:(0,$.jsxs)(W,{className:`max-w-2xl h-[80vh] flex flex-col`,children:[(0,$.jsx)(D,{children:(0,$.jsx)(gt,{children:(0,$.jsx)(`code`,{className:`text-sm font-mono`,children:ri(n.filePath,i)??n.filePath})})}),(0,$.jsx)(`div`,{className:`overflow-auto flex-1 rounded border border-border bg-muted/30 p-3`,children:(0,$.jsx)(di,{oldText:n.editOldText,newText:n.editNewText})})]})})]}):n.path===null?null:(0,$.jsx)(`span`,{className:`text-xs font-mono text-muted-foreground truncate max-w-[200px] sm:max-w-[320px]`,title:n.path,children:n.path}),t[11]=n.editNewText,t[12]=n.editOldText,t[13]=n.fileDisplayName,t[14]=n.filePath,t[15]=n.hasEditDiff,t[16]=n.path,t[17]=c,t[18]=d,t[19]=i,t[20]=a):a=t[20];let o;return t[21]!==r||t[22]!==a?(o=(0,$.jsxs)(`div`,{className:`py-0.5 flex items-center gap-2 flex-wrap`,children:[r,a]}),t[21]=r,t[22]=a,t[23]=o):o=t[23],o}let f;t[24]===o?f=t[25]:(f=()=>s(!o),t[24]=o,t[25]=f);let p=n.toolName,m;t[26]===n.icon?m=t[27]:(m=(0,Z.createElement)(n.icon,{className:`h-4 w-4 text-brand`}),t[26]=n.icon,t[27]=m);let h;t[28]===n.displayName?h=t[29]:(h=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:n.displayName}),t[28]=n.displayName,t[29]=h);let g;t[30]===o?g=t[31]:(g=o?(0,$.jsx)(xt,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(ke,{className:`h-4 w-4 shrink-0`}),t[30]=o,t[31]=g);let _;t[32]!==n.toolName||t[33]!==f||t[34]!==m||t[35]!==h||t[36]!==g?(_=(0,$.jsxs)(`button`,{onClick:f,className:`w-full py-2 flex items-center gap-2 text-sm font-medium text-foreground hover:bg-muted/50 transition-colors text-left`,title:p,children:[m,h,g]}),t[32]=n.toolName,t[33]=f,t[34]=m,t[35]=h,t[36]=g,t[37]=_):_=t[37];let y;t[38]!==n.toolId||t[39]!==n.toolInput||t[40]!==o?(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: `,n.toolId]}),n.toolInput?(0,$.jsx)(`pre`,{className:`text-xs bg-slate-100 dark:bg-slate-900 p-2 rounded font-mono whitespace-pre-wrap overflow-auto max-h-48`,children:n.toolInput}):null]}),t[38]=n.toolId,t[39]=n.toolInput,t[40]=o,t[41]=y):y=t[41];let b;return t[42]!==_||t[43]!==y?(b=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[_,y]}),t[42]=_,t[43]=y,t[44]=b):b=t[44],b}function Si(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)(gi,{children:n.codeSearchQuery}),n.pattern!==null&&(0,$.jsxs)(gi,{children:[`/`,n.pattern,`/`]}),n.codeSearchFilePath!==null&&(0,$.jsx)(gi,{children:n.codeSearchFilePath}),n.codeSearchFileGlob!==null&&(0,$.jsx)(gi,{children:n.codeSearchFileGlob})]}):n.pattern!==null&&(0,$.jsx)(gi,{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 Ci(e){let t=(0,Q.c)(67),{data:n,inline:r,resultContent:i}=e,[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(!1),l=n.toolName===`code_search`,u=n.codeSearchQuery??n.pattern??n.codeSearchFilePath??n.codeSearchFileGlob??`search`;if(r){if(i&&(l||n.toolName===`find`||n.pattern!==null)){let e;t[0]===n.icon?e=t[1]:(e=(0,Z.createElement)(n.icon,{className:`h-3.5 w-3.5 shrink-0 text-brand`}),t[0]=n.icon,t[1]=e);let r;t[2]===n.displayName?r=t[3]:(r=(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n.displayName}),t[2]=n.displayName,t[3]=r);let a;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(a=()=>c(!0),t[4]=a):a=t[4];let o;t[5]===u?o=t[6]:(o=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:a,className:`text-xs font-mono text-muted-foreground hover:underline break-all cursor-pointer`,children:u})}),t[5]=u,t[6]=o);let l;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(q,{children:`View results`}),t[7]=l):l=t[7];let d;t[8]===o?d=t[9]:(d=(0,$.jsxs)(J,{children:[o,l]}),t[8]=o,t[9]=d);let f;t[10]!==e||t[11]!==r||t[12]!==d?(f=(0,$.jsxs)(`div`,{className:`py-0.5 flex items-center gap-2 flex-wrap`,children:[e,r,d]}),t[10]=e,t[11]=r,t[12]=d,t[13]=f):f=t[13];let p;t[14]!==s||t[15]!==i||t[16]!==u?(p=(0,$.jsx)(ui,{open:s,onOpenChange:c,title:u,content:i}),t[14]=s,t[15]=i,t[16]=u,t[17]=p):p=t[17];let m;return t[18]!==f||t[19]!==p?(m=(0,$.jsxs)($.Fragment,{children:[f,p]}),t[18]=f,t[19]=p,t[20]=m):m=t[20],m}let e=n.toolName,r;t[21]===n.icon?r=t[22]:(r=(0,Z.createElement)(n.icon,{className:`h-3.5 w-3.5 shrink-0 text-brand`}),t[21]=n.icon,t[22]=r);let a;t[23]===n.displayName?a=t[24]:(a=(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n.displayName}),t[23]=n.displayName,t[24]=a);let o;t[25]!==n.toolName||t[26]!==r||t[27]!==a?(o=(0,$.jsxs)(`span`,{title:e,className:`inline-flex items-center gap-1`,children:[r,a]}),t[25]=n.toolName,t[26]=r,t[27]=a,t[28]=o):o=t[28];let d;t[29]===n?d=t[30]:(d=(0,$.jsx)(Si,{data:n}),t[29]=n,t[30]=d);let f;t[31]===n.lang?f=t[32]:(f=n.lang!==null&&(0,$.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded bg-muted text-muted-foreground`,children:n.lang}),t[31]=n.lang,t[32]=f);let p;return t[33]!==o||t[34]!==d||t[35]!==f?(p=(0,$.jsxs)(`div`,{className:`py-0.5 flex items-center gap-2 flex-wrap`,children:[o,d,f]}),t[33]=o,t[34]=d,t[35]=f,t[36]=p):p=t[36],p}let d;t[37]===a?d=t[38]:(d=()=>o(!a),t[37]=a,t[38]=d);let f=n.toolName,p;t[39]===n.icon?p=t[40]:(p=(0,Z.createElement)(n.icon,{className:`h-4 w-4 text-brand`}),t[39]=n.icon,t[40]=p);let m;t[41]===n.displayName?m=t[42]:(m=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:n.displayName}),t[41]=n.displayName,t[42]=m);let h;t[43]!==n.codeSearchFileGlob||t[44]!==n.codeSearchFilePath||t[45]!==n.codeSearchQuery||t[46]!==n.pattern||t[47]!==l?(h=l&&(0,$.jsxs)($.Fragment,{children:[n.codeSearchQuery!==null&&(0,$.jsx)(`code`,{className:`text-xs font-mono bg-muted text-muted-foreground rounded px-1 py-0.5 truncate max-w-[150px]`,children:n.codeSearchQuery}),n.pattern!==null&&(0,$.jsxs)(`code`,{className:`text-xs font-mono bg-muted text-muted-foreground rounded px-1 py-0.5 truncate max-w-[150px]`,children:[`/`,n.pattern,`/`]}),n.codeSearchFilePath!==null&&(0,$.jsx)(`code`,{className:`text-xs font-mono bg-muted text-muted-foreground rounded px-1 py-0.5 truncate max-w-[150px]`,children:n.codeSearchFilePath}),n.codeSearchFileGlob!==null&&(0,$.jsx)(`code`,{className:`text-xs font-mono bg-muted text-muted-foreground rounded px-1 py-0.5 truncate max-w-[150px]`,children:n.codeSearchFileGlob})]}),t[43]=n.codeSearchFileGlob,t[44]=n.codeSearchFilePath,t[45]=n.codeSearchQuery,t[46]=n.pattern,t[47]=l,t[48]=h):h=t[48];let g;t[49]===a?g=t[50]:(g=a?(0,$.jsx)(xt,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(ke,{className:`h-4 w-4 shrink-0`}),t[49]=a,t[50]=g);let _;t[51]!==n.toolName||t[52]!==d||t[53]!==p||t[54]!==m||t[55]!==h||t[56]!==g?(_=(0,$.jsxs)(`button`,{onClick:d,className:`w-full py-2 flex items-center gap-2 text-sm font-medium text-foreground hover:bg-muted/50 transition-colors text-left`,title:f,children:[p,m,h,g]}),t[51]=n.toolName,t[52]=d,t[53]=p,t[54]=m,t[55]=h,t[56]=g,t[57]=_):_=t[57];let v;t[58]!==n.toolId||t[59]!==n.toolInput||t[60]!==a||t[61]!==l||t[62]!==i?(v=a&&(0,$.jsxs)(`div`,{className:`py-2 border-t border-border`,children:[(0,$.jsxs)(`div`,{className:`text-xs text-muted-foreground mb-2 font-mono`,children:[`ID: `,n.toolId]}),n.toolInput?(0,$.jsx)(`pre`,{className:`text-xs bg-slate-100 dark:bg-slate-900 p-2 rounded font-mono whitespace-pre-wrap overflow-auto max-h-48`,children:n.toolInput}):null,l&&i&&(0,$.jsx)(`pre`,{className:`text-xs bg-slate-100 dark:bg-slate-900 p-2 rounded font-mono whitespace-pre-wrap overflow-auto max-h-64 mt-2`,children:i})]}),t[58]=n.toolId,t[59]=n.toolInput,t[60]=a,t[61]=l,t[62]=i,t[63]=v):v=t[63];let y;return t[64]!==_||t[65]!==v?(y=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[_,v]}),t[64]=_,t[65]=v,t[66]=y):y=t[66],y}function wi(e){let t=(0,Q.c)(57),{data:n,inline:r}=e,[i,a]=(0,Z.useState)(!1);if(r){let e=n.toolName,r;t[0]===n.icon?r=t[1]:(r=(0,Z.createElement)(n.icon,{className:`h-3.5 w-3.5 text-brand`}),t[0]=n.icon,t[1]=r);let i;t[2]===n.displayName?i=t[3]:(i=(0,$.jsx)(`span`,{className:`text-xs`,children:n.displayName}),t[2]=n.displayName,t[3]=i);let a;t[4]!==r||t[5]!==i?(a=(0,$.jsxs)(`button`,{type:`button`,className:`inline-flex shrink-0 items-center gap-1 rounded p-0.5 text-muted-foreground hover:text-foreground focus:outline-none focus-visible:ring-2 focus-visible:ring-ring`,"aria-label":`Show tool details`,children:[r,i]}),t[4]=r,t[5]=i,t[6]=a):a=t[6];let o;t[7]!==n.toolName||t[8]!==a?(o=(0,$.jsx)(yi,{asChild:!0,children:(0,$.jsx)(`span`,{title:e,className:`inline-flex`,children:a})}),t[7]=n.toolName,t[8]=a,t[9]=o):o=t[9];let s;t[10]===n.toolId?s=t[11]:(s=(0,$.jsxs)(`div`,{className:`font-mono`,children:[`ID: `,n.toolId]}),t[10]=n.toolId,t[11]=s);let c;t[12]!==n.prompt||t[13]!==n.toolInput?(c=n.prompt?(0,$.jsx)(`div`,{className:`whitespace-pre-wrap leading-relaxed`,children:n.prompt}):n.toolInput?(0,$.jsx)(`pre`,{className:`font-mono whitespace-pre-wrap overflow-auto max-h-48`,children:n.toolInput}):null,t[12]=n.prompt,t[13]=n.toolInput,t[14]=c):c=t[14];let l;t[15]!==s||t[16]!==c?(l=(0,$.jsx)(bi,{className:`w-80 max-h-80 overflow-auto`,align:`start`,children:(0,$.jsxs)(`div`,{className:`text-xs text-muted-foreground space-y-2`,children:[s,c]})}),t[15]=s,t[16]=c,t[17]=l):l=t[17];let u;t[18]!==o||t[19]!==l?(u=(0,$.jsxs)(vi,{children:[o,l]}),t[18]=o,t[19]=l,t[20]=u):u=t[20];let d;t[21]===n.agentName?d=t[22]:(d=n.agentName&&(0,$.jsx)(mi,{name:n.agentName}),t[21]=n.agentName,t[22]=d);let f;t[23]===n.subagentType?f=t[24]:(f=n.subagentType&&(0,$.jsx)(hi,{type:n.subagentType}),t[23]=n.subagentType,t[24]=f);let p;return t[25]!==d||t[26]!==f||t[27]!==u?(p=(0,$.jsxs)(`div`,{className:`py-0.5 flex items-center gap-2 flex-wrap`,children:[u,d,f]}),t[25]=d,t[26]=f,t[27]=u,t[28]=p):p=t[28],p}let o;t[29]===i?o=t[30]:(o=()=>a(!i),t[29]=i,t[30]=o);let s=n.toolName,c;t[31]===n.icon?c=t[32]:(c=(0,Z.createElement)(n.icon,{className:`h-4 w-4 text-brand`}),t[31]=n.icon,t[32]=c);let l;t[33]===n.displayName?l=t[34]:(l=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:n.displayName}),t[33]=n.displayName,t[34]=l);let u;t[35]===n.agentName?u=t[36]:(u=n.agentName&&(0,$.jsx)(mi,{name:n.agentName}),t[35]=n.agentName,t[36]=u);let d;t[37]===n.subagentType?d=t[38]:(d=n.subagentType&&(0,$.jsx)(hi,{type:n.subagentType}),t[37]=n.subagentType,t[38]=d);let f;t[39]===i?f=t[40]:(f=i?(0,$.jsx)(xt,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(ke,{className:`h-4 w-4 shrink-0`}),t[39]=i,t[40]=f);let p;t[41]!==n.toolName||t[42]!==o||t[43]!==c||t[44]!==l||t[45]!==u||t[46]!==d||t[47]!==f?(p=(0,$.jsxs)(`button`,{onClick:o,className:`w-full py-2 flex items-center gap-2 text-sm font-medium text-foreground hover:bg-muted/50 transition-colors text-left`,title:s,children:[c,l,u,d,f]}),t[41]=n.toolName,t[42]=o,t[43]=c,t[44]=l,t[45]=u,t[46]=d,t[47]=f,t[48]=p):p=t[48];let m;t[49]!==n.prompt||t[50]!==n.toolId||t[51]!==n.toolInput||t[52]!==i?(m=i&&(0,$.jsxs)(`div`,{className:`py-2 border-t border-border`,children:[(0,$.jsxs)(`div`,{className:`text-xs text-muted-foreground mb-2 font-mono`,children:[`ID: `,n.toolId]}),n.prompt?(0,$.jsx)(`div`,{className:`text-xs bg-slate-100 dark:bg-slate-900 p-3 rounded whitespace-pre-wrap overflow-auto max-h-64 leading-relaxed`,children:n.prompt}):n.toolInput?(0,$.jsx)(`pre`,{className:`text-xs bg-slate-100 dark:bg-slate-900 p-2 rounded font-mono whitespace-pre-wrap overflow-auto max-h-48`,children:n.toolInput}):null]}),t[49]=n.prompt,t[50]=n.toolId,t[51]=n.toolInput,t[52]=i,t[53]=m):m=t[53];let h;return t[54]!==p||t[55]!==m?(h=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[p,m]}),t[54]=p,t[55]=m,t[56]=h):h=t[56],h}function Ti(e){let t=(0,Q.c)(21),{data:n,inline:r}=e,[i,a]=(0,Z.useState)(!1);if(r)return null;let o;t[0]===i?o=t[1]:(o=()=>a(!i),t[0]=i,t[1]=o);let s=n.toolName,c;t[2]===n.icon?c=t[3]:(c=(0,Z.createElement)(n.icon,{className:`h-4 w-4 text-brand`}),t[2]=n.icon,t[3]=c);let l;t[4]===n.displayName?l=t[5]:(l=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:n.displayName}),t[4]=n.displayName,t[5]=l);let u;t[6]===i?u=t[7]:(u=i?(0,$.jsx)(xt,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(ke,{className:`h-4 w-4 shrink-0`}),t[6]=i,t[7]=u);let d;t[8]!==n.toolName||t[9]!==o||t[10]!==c||t[11]!==l||t[12]!==u?(d=(0,$.jsxs)(`button`,{onClick:o,className:`w-full py-2 flex items-center gap-2 text-sm font-medium text-foreground hover:bg-muted/50 transition-colors text-left`,title:s,children:[c,l,u]}),t[8]=n.toolName,t[9]=o,t[10]=c,t[11]=l,t[12]=u,t[13]=d):d=t[13];let f;t[14]!==n.toolId||t[15]!==n.toolInput||t[16]!==i?(f=i&&(0,$.jsxs)(`div`,{className:`py-2 border-t border-border`,children:[(0,$.jsxs)(`div`,{className:`text-xs text-muted-foreground mb-2 font-mono`,children:[`ID: `,n.toolId]}),n.toolInput?(0,$.jsx)(`pre`,{className:`text-xs bg-slate-100 dark:bg-slate-900 p-2 rounded font-mono whitespace-pre-wrap overflow-auto max-h-48`,children:n.toolInput}):null]}),t[14]=n.toolId,t[15]=n.toolInput,t[16]=i,t[17]=f):f=t[17];let p;return t[18]!==d||t[19]!==f?(p=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[d,f]}),t[18]=d,t[19]=f,t[20]=p):p=t[20],p}function Ei(e){let t=(0,Q.c)(34),{data:n,inline:r}=e,[i,a]=(0,Z.useState)(!1);if(r){let e=n.toolName,r;t[0]===n.icon?r=t[1]:(r=(0,Z.createElement)(n.icon,{className:`h-3.5 w-3.5 shrink-0 text-brand`}),t[0]=n.icon,t[1]=r);let i;t[2]===n.displayName?i=t[3]:(i=(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n.displayName}),t[2]=n.displayName,t[3]=i);let a;t[4]!==n.toolName||t[5]!==r||t[6]!==i?(a=(0,$.jsxs)(`span`,{title:e,className:`inline-flex items-center gap-1`,children:[r,i]}),t[4]=n.toolName,t[5]=r,t[6]=i,t[7]=a):a=t[7];let o;t[8]===n.imageGenPrompt?o=t[9]:(o=n.imageGenPrompt!==null&&(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground truncate max-w-[200px] sm:max-w-[320px]`,title:n.imageGenPrompt,children:n.imageGenPrompt}),t[8]=n.imageGenPrompt,t[9]=o);let s;return t[10]!==a||t[11]!==o?(s=(0,$.jsxs)(`div`,{className:`py-0.5 flex items-center gap-2 flex-wrap`,children:[a,o]}),t[10]=a,t[11]=o,t[12]=s):s=t[12],s}let o;t[13]===i?o=t[14]:(o=()=>a(!i),t[13]=i,t[14]=o);let s=n.toolName,c;t[15]===n.icon?c=t[16]:(c=(0,Z.createElement)(n.icon,{className:`h-4 w-4 text-brand`}),t[15]=n.icon,t[16]=c);let l;t[17]===n.displayName?l=t[18]:(l=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:n.displayName}),t[17]=n.displayName,t[18]=l);let u;t[19]===i?u=t[20]:(u=i?(0,$.jsx)(xt,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(ke,{className:`h-4 w-4 shrink-0`}),t[19]=i,t[20]=u);let d;t[21]!==n.toolName||t[22]!==o||t[23]!==c||t[24]!==l||t[25]!==u?(d=(0,$.jsxs)(`button`,{onClick:o,className:`w-full py-2 flex items-center gap-2 text-sm font-medium text-foreground hover:bg-muted/50 transition-colors text-left`,title:s,children:[c,l,u]}),t[21]=n.toolName,t[22]=o,t[23]=c,t[24]=l,t[25]=u,t[26]=d):d=t[26];let f;t[27]!==n.toolId||t[28]!==n.toolInput||t[29]!==i?(f=i&&(0,$.jsxs)(`div`,{className:`py-2 border-t border-border`,children:[(0,$.jsxs)(`div`,{className:`text-xs text-muted-foreground mb-2 font-mono`,children:[`ID: `,n.toolId]}),n.toolInput?(0,$.jsx)(`pre`,{className:`text-xs bg-slate-100 dark:bg-slate-900 p-2 rounded font-mono whitespace-pre-wrap overflow-auto max-h-48`,children:n.toolInput}):null]}),t[27]=n.toolId,t[28]=n.toolInput,t[29]=i,t[30]=f):f=t[30];let p;return t[31]!==d||t[32]!==f?(p=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[d,f]}),t[31]=d,t[32]=f,t[33]=p):p=t[33],p}function Di(e){let t=(0,Q.c)(35),{data:n,inline:r}=e,[i,a]=(0,Z.useState)(!1);if(r){let e=!!(n.prompt??(n.toolInput&&!n.command&&!n.path&&!n.pattern&&!n.fileDisplayName)),r;t[0]!==n.displayName||t[1]!==n.icon||t[2]!==n.prompt||t[3]!==n.toolId||t[4]!==n.toolInput||t[5]!==n.toolName||t[6]!==e?(r=e?(0,$.jsxs)(vi,{children:[(0,$.jsx)(yi,{asChild:!0,children:(0,$.jsx)(`span`,{title:n.toolName,className:`inline-flex`,children:(0,$.jsxs)(`button`,{type:`button`,className:`inline-flex shrink-0 items-center gap-1 rounded p-0.5 text-muted-foreground hover:text-foreground focus:outline-none focus-visible:ring-2 focus-visible:ring-ring`,"aria-label":`Show tool details`,children:[(0,Z.createElement)(n.icon,{className:`h-3.5 w-3.5 text-brand`}),(0,$.jsx)(`span`,{className:`text-xs`,children:n.displayName})]})})}),(0,$.jsx)(bi,{className:`w-80 max-h-80 overflow-auto`,align:`start`,children:(0,$.jsxs)(`div`,{className:`text-xs text-muted-foreground space-y-2`,children:[(0,$.jsxs)(`div`,{className:`font-mono`,children:[`ID: `,n.toolId]}),n.prompt?(0,$.jsx)(`div`,{className:`whitespace-pre-wrap leading-relaxed`,children:n.prompt}):n.toolInput?(0,$.jsx)(`pre`,{className:`font-mono whitespace-pre-wrap overflow-auto max-h-48`,children:n.toolInput}):null]})})]}):(0,$.jsxs)(`span`,{title:n.toolName,className:`inline-flex items-center gap-1`,children:[(0,Z.createElement)(n.icon,{className:`h-3.5 w-3.5 shrink-0 text-brand`}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n.displayName})]}),t[0]=n.displayName,t[1]=n.icon,t[2]=n.prompt,t[3]=n.toolId,t[4]=n.toolInput,t[5]=n.toolName,t[6]=e,t[7]=r):r=t[7];let i;t[8]===n.path?i=t[9]:(i=n.path!==null&&(0,$.jsx)(`span`,{className:`text-xs font-mono text-muted-foreground truncate max-w-[200px] sm:max-w-[320px]`,title:n.path,children:n.path}),t[8]=n.path,t[9]=i);let a;return t[10]!==r||t[11]!==i?(a=(0,$.jsxs)(`div`,{className:`py-0.5 flex items-center gap-2 flex-wrap`,children:[r,i]}),t[10]=r,t[11]=i,t[12]=a):a=t[12],a}let o;t[13]===i?o=t[14]:(o=()=>a(!i),t[13]=i,t[14]=o);let s=n.toolName,c;t[15]===n.icon?c=t[16]:(c=(0,Z.createElement)(n.icon,{className:`h-4 w-4 text-brand`}),t[15]=n.icon,t[16]=c);let l;t[17]===n.displayName?l=t[18]:(l=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:n.displayName}),t[17]=n.displayName,t[18]=l);let u;t[19]===i?u=t[20]:(u=i?(0,$.jsx)(xt,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(ke,{className:`h-4 w-4 shrink-0`}),t[19]=i,t[20]=u);let d;t[21]!==n.toolName||t[22]!==o||t[23]!==c||t[24]!==l||t[25]!==u?(d=(0,$.jsxs)(`button`,{onClick:o,className:`w-full py-2 flex items-center gap-2 text-sm font-medium text-foreground hover:bg-muted/50 transition-colors text-left`,title:s,children:[c,l,u]}),t[21]=n.toolName,t[22]=o,t[23]=c,t[24]=l,t[25]=u,t[26]=d):d=t[26];let f;t[27]!==n.prompt||t[28]!==n.toolId||t[29]!==n.toolInput||t[30]!==i?(f=i&&(0,$.jsxs)(`div`,{className:`py-2 border-t border-border`,children:[(0,$.jsxs)(`div`,{className:`text-xs text-muted-foreground mb-2 font-mono`,children:[`ID: `,n.toolId]}),n.prompt?(0,$.jsx)(`div`,{className:`text-xs bg-slate-100 dark:bg-slate-900 p-3 rounded whitespace-pre-wrap overflow-auto max-h-64 leading-relaxed`,children:n.prompt}):n.toolInput?(0,$.jsx)(`pre`,{className:`text-xs bg-slate-100 dark:bg-slate-900 p-2 rounded font-mono whitespace-pre-wrap overflow-auto max-h-48`,children:n.toolInput}):null]}),t[27]=n.prompt,t[28]=n.toolId,t[29]=n.toolInput,t[30]=i,t[31]=f):f=t[31];let p;return t[32]!==d||t[33]!==f?(p=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[d,f]}),t[32]=d,t[33]=f,t[34]=p):p=t[34],p}function Oi(e){let t=(0,Q.c)(34),{block:n,inline:r,resultContent:i}=e,{state:a}=an(),{setPendingExplorerPath:o,setActiveMainTab:s}=Wn(),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=li(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)(_i,{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)(xi,{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)(Ci,{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)(wi,{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)(Ti,{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)(Ei,{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)(Di,{data:u,inline:r}),t[31]=u,t[32]=r,t[33]=e):e=t[33],e}}}function ki(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 Ai(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 Ze(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 u(o.startsWith(`data:`)?{imageData:o.replace(/^data:[^;]+;base64,/,``)}:{imageUrl:o}),a(!0),setTimeout(()=>a(!1),2e3)},t[2]=o,t[3]=l);let d=l,f;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(f={maxHeight:`512px`},t[4]=f):f=t[4];let p;t[5]===o?p=t[6]:(p=(0,$.jsx)(`img`,{src:o,alt:`Generated image`,className:`max-w-full rounded-lg block`,style:f}),t[5]=o,t[6]=p);let m;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(E,{className:`h-3.5 w-3.5`}),t[7]=m):m=t[7];let h;t[8]===c?h=t[9]:(h=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(`button`,{onClick:c,className:`flex items-center justify-center h-7 w-7 rounded-md bg-background/80 backdrop-blur-sm border border-border text-foreground hover:bg-background transition-colors`,children:m})}),t[8]=c,t[9]=h);let g;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(q,{children:`Save image`}),t[10]=g):g=t[10];let _;t[11]===h?_=t[12]:(_=(0,$.jsxs)(J,{children:[h,g]}),t[11]=h,t[12]=_);let v;t[13]===i?v=t[14]:(v=i?(0,$.jsx)(Ne,{className:`h-3.5 w-3.5 text-green-500`}):(0,$.jsx)(Ce,{className:`h-3.5 w-3.5`}),t[13]=i,t[14]=v);let y;t[15]!==d||t[16]!==v?(y=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(`button`,{onClick:d,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]=d,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)(hn,{children:[_,S]})}),t[23]=S,t[24]=_,t[25]=C):C=t[25];let w;return t[26]!==C||t[27]!==p?(w=(0,$.jsxs)(`div`,{className:`mb-3 relative group/img inline-block max-w-full`,children:[p,C]}),t[26]=C,t[27]=p,t[28]=w):w=t[28],w}function ji(e){let t=(0,Q.c)(72),{block:n,inline:r,sequence:i}=e,a=i===void 0?0:i,[o,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(!1),{state:u}=an(),d=u.projects,f,p,m,h,g,_,y,b;if(t[0]!==n||t[1]!==r||t[2]!==a||t[3]!==u.projects||t[4]!==u.selectedProjectId||t[5]!==u.selectedThreadId){_=Symbol.for(`react.early_return_sentinel`);bb0:{let e;t[14]===u.selectedProjectId?e=t[15]:(e=e=>e.projectId===u.selectedProjectId,t[14]=u.selectedProjectId,t[15]=e);let i=d.find(e)?.threads.find(e=>e.threadId===u.selectedThreadId)?.path;b=n.toolName??`Unknown Tool`,y=n.toolCallId??`unknown`;let o=n,s=n.result??o.content,c;t[16]!==o||t[17]!==b?(c=b===`todo`?xn(o):null,t[16]=o,t[17]=b,t[18]=c):c=t[18];let l=c;if(m=ri(ci(s),i),!(m.length>0)&&l===null){_=null;break bb0}if(f=ni(b),typeof s==`object`&&s){let e=s,n=e.returnDisplay??e.return_display;if(typeof n==`string`&&n.trim()){let e;t[19]===n?e=t[20]:(e=n.trim(),t[19]=n,t[20]=e),f=e}else if(b===`read`||b===`file_read`){let n=e.filePath??e.file_path??e.path??``;if(n){let e;t[21]===n?e=t[22]:(e=n.split(`/`).pop()??n,t[21]=n,t[22]=e),f=`Completed ${e}`}}}else if(s==null){let e;t[23]===b?e=t[24]:(e=ni(b),t[23]=b,t[24]=e),f=`${e} (no result)`}if(f=ri(f,i),l!==null){let e;t[25]!==a||t[26]!==l?(e=(0,$.jsx)(Tn,{todos:l,sequence:a}),t[25]=a,t[26]=l,t[27]=e):e=t[27],_=e;break bb0}if(b===`generate_image`){let e;t[28]===s?e=t[29]:(e=ki(s),t[28]=s,t[29]=e);let n=e;if(n&&(n.imageUrl||n.imageData)){let e;t[30]!==n.imageData||t[31]!==n.imageUrl?(e=(0,$.jsx)(Ai,{imageUrl:n.imageUrl,imageData:n.imageData}),t[30]=n.imageData,t[31]=n.imageUrl,t[32]=e):e=t[32],_=e;break bb0}}if(r){_=null;break bb0}let v;t[33]===b?v=t[34]:(v=b.toLowerCase().includes(`bash`),t[33]=b,t[34]=v),p=v,h=m?m.split(`
|
|
15
|
+
`):[],g=p?h.slice(0,3).join(`
|
|
16
|
+
`):m}t[0]=n,t[1]=r,t[2]=a,t[3]=u.projects,t[4]=u.selectedProjectId,t[5]=u.selectedThreadId,t[6]=f,t[7]=p,t[8]=m,t[9]=h,t[10]=g,t[11]=_,t[12]=y,t[13]=b}else f=t[6],p=t[7],m=t[8],h=t[9],g=t[10],_=t[11],y=t[12],b=t[13];if(_!==Symbol.for(`react.early_return_sentinel`))return _;let x=g,S=p&&h.length>3;if(p){let e;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(st,{className:`h-4 w-4 shrink-0`}),t[35]=e):e=t[35];let n;t[36]===f?n=t[37]:(n=(0,$.jsxs)(`div`,{className:`px-3 py-2 flex items-center gap-2 text-sm font-medium text-foreground`,children:[e,(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:f})]}),t[36]=f,t[37]=n);let r;t[38]!==S||t[39]!==x||t[40]!==m||t[41]!==h?(r=m&&(0,$.jsxs)(`div`,{className:`px-3 pb-2 bg-background border-t border-border`,children:[(0,$.jsxs)(`pre`,{className:`text-xs bg-muted p-2 rounded font-mono whitespace-pre-wrap overflow-auto text-foreground text-left mt-2${S?` cursor-pointer hover:bg-muted/80`:``}`,onClick:S?()=>l(!0):void 0,title:S?`Click to see full output`:void 0,children:[x,S&&(0,$.jsxs)(`span`,{className:`text-muted-foreground`,children:[`
|
|
17
|
+
`,`...`]})]}),S&&(0,$.jsxs)(`button`,{type:`button`,onClick:()=>l(!0),className:`mt-1 text-xs text-brand hover:underline`,children:[`Show full output (`,h.length,` lines)`]})]}),t[38]=S,t[39]=x,t[40]=m,t[41]=h,t[42]=r):r=t[42];let i;t[43]!==n||t[44]!==r?(i=(0,$.jsxs)(`div`,{className:`mb-3 rounded-lg border border-border bg-muted/50 overflow-hidden`,children:[n,r]}),t[43]=n,t[44]=r,t[45]=i):i=t[45];let a;t[46]!==c||t[47]!==S||t[48]!==m?(a=S&&(0,$.jsx)(v,{open:c,onOpenChange:l,children:(0,$.jsxs)(W,{className:`max-w-3xl max-h-[80vh] flex flex-col`,children:[(0,$.jsx)(D,{children:(0,$.jsx)(gt,{children:`Full Output`})}),(0,$.jsx)(`pre`,{className:`text-xs bg-muted p-3 rounded font-mono whitespace-pre-wrap overflow-auto flex-1 text-foreground`,children:m})]})}),t[46]=c,t[47]=S,t[48]=m,t[49]=a):a=t[49];let o;return t[50]!==i||t[51]!==a?(o=(0,$.jsxs)($.Fragment,{children:[i,a]}),t[50]=i,t[51]=a,t[52]=o):o=t[52],o}let C;t[53]===o?C=t[54]:(C=()=>s(!o),t[53]=o,t[54]=C);let w=`${b} result`,T;t[55]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(st,{className:`h-4 w-4 shrink-0`}),t[55]=T):T=t[55];let E;t[56]===f?E=t[57]:(E=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:f}),t[56]=f,t[57]=E);let O;t[58]===o?O=t[59]:(O=o?(0,$.jsx)(xt,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(ke,{className:`h-4 w-4 shrink-0`}),t[58]=o,t[59]=O);let k;t[60]!==C||t[61]!==w||t[62]!==E||t[63]!==O?(k=(0,$.jsxs)(`button`,{onClick:C,className:`w-full px-3 py-2 flex items-center gap-2 text-sm font-medium text-foreground hover:bg-muted transition-colors text-left`,title:w,children:[T,E,O]}),t[60]=C,t[61]=w,t[62]=E,t[63]=O,t[64]=k):k=t[64];let A;t[65]!==o||t[66]!==m||t[67]!==y?(A=o&&(0,$.jsxs)(`div`,{className:`px-3 py-2 bg-background border-t border-border`,children:[(0,$.jsxs)(`div`,{className:`text-xs text-muted-foreground mb-2 font-mono`,children:[`Call ID: `,y]}),m&&(0,$.jsx)(`pre`,{className:`text-xs bg-muted p-2 rounded font-mono whitespace-pre-wrap overflow-auto max-h-48 text-foreground text-left`,children:m})]}),t[65]=o,t[66]=m,t[67]=y,t[68]=A):A=t[68];let j;return t[69]!==k||t[70]!==A?(j=(0,$.jsxs)(`div`,{className:`mb-3 rounded-lg border border-border bg-muted/50 overflow-hidden`,children:[k,A]}),t[69]=k,t[70]=A,t[71]=j):j=t[71],j}function Mi(e){let t=(0,Q.c)(1),{isStreaming:n}=e;if(!(n!==void 0&&n))return null;let r;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsxs)(`div`,{className:`py-0.5 flex items-center gap-2`,children:[(0,$.jsx)(nt,{className:`h-3.5 w-3.5 shrink-0 animate-pulse text-brand`}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Thinking...`})]}),t[0]=r):r=t[0],r}function Ni({toolCall:e,className:t}){let{state:n,dispatch:r}=an(),[i,a]=(0,Z.useState)(!1),o=n.toolCallProgress[e.id];return(0,Z.useMemo)(()=>{if(!n.isStreaming)return{isActive:!1,isCompleted:!0};let t=!1,r=!1;for(let i of n.streamingSegments)if(i.type===`thinking`){for(let n of i.chunks)if(n.includes(e.id))try{let i=JSON.parse(n);if(Array.isArray(i))for(let n of i)n.type===`tool_use`&&n.id===e.id&&(t=!0),n.type===`tool-result`&&n.toolCallId===e.id&&(r=!0,t=!1)}catch{}}return t&&!n.isStreaming&&(r=!0,t=!1),{isActive:t,isCompleted:r}},[n.isStreaming,n.streamingSegments,e.id]).isActive?(0,$.jsxs)(`div`,{className:C(`overflow-hidden mb-2`,t),children:[(0,$.jsxs)(`div`,{className:`px-3 py-2 flex items-center gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 flex-1`,children:[(0,$.jsx)(ce,{className:`h-3.5 w-3.5 animate-spin`}),(0,$.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:e.name===`bash`?`Run`:e.name.charAt(0).toUpperCase()+e.name.slice(1)}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.name===`bash`&&typeof e.input?.command==`string`?`run "${e.input.command}"`:typeof e.input?.description==`string`?e.input.description:`running`})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(`button`,{onClick:()=>{a(e=>!e)},className:`p-1 hover:bg-muted/50 rounded transition-colors`,title:i?`Collapse`:`Expand`,children:i?(0,$.jsx)(Xe,{className:`h-3.5 w-3.5`}):(0,$.jsx)(xt,{className:`h-3.5 w-3.5`})}),(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(`button`,{onClick:()=>{r({type:K.StopStream});let t={type:`tool-result`,toolCallId:e.id,toolName:e.name,result:`Tool execution was cancelled by the user. The command was taking too long or required user approval.`,isError:!0,content:`Tool execution was cancelled by the user. The command was taking too long or required user approval.`};r({type:K.AppendStreamChunk,chunkType:`content`,content:JSON.stringify([t]),segments:n.streamingSegments})},className:`p-1 hover:bg-red-200 dark:hover:bg-red-800 rounded transition-colors text-red-600 dark:text-red-400`,children:(0,$.jsx)(ee,{className:`h-3.5 w-3.5`})})}),(0,$.jsx)(q,{className:`bg-red-600 text-white border-red-600`,children:`Stop this process`})]})]})]}),i&&(0,$.jsxs)(`div`,{className:`py-2 border-t border-border min-h-[8rem] overflow-auto`,children:[(0,$.jsxs)(`div`,{className:`text-xs text-muted-foreground mb-2 font-mono`,children:[`ID: `,e.id]}),(0,$.jsxs)(`div`,{className:`mb-2`,children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground mb-1`,children:`Input:`}),(0,$.jsx)(`pre`,{className:`text-xs bg-slate-100 dark:bg-slate-900 p-2 rounded font-mono whitespace-pre-wrap overflow-auto max-h-48 border border-slate-200 dark:border-slate-700`,children:(e=>JSON.stringify(e,null,2))(e.input)})]}),o&&(0,$.jsxs)(`div`,{className:`mb-2`,children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground mb-1`,children:`Progress:`}),(0,$.jsxs)(`div`,{className:`text-xs bg-green-50 dark:bg-green-900/20 p-2 rounded border border-green-200 dark:border-green-800`,children:[(0,$.jsx)(`div`,{className:`text-green-700 dark:text-green-300 font-mono`,children:o.delta}),o.partial?.content?.[0]?.arguments&&typeof o.partial.content[0].arguments==`object`&&`content`in o.partial.content[0].arguments&&typeof o.partial.content[0].arguments.content==`string`&&(0,$.jsxs)(`div`,{className:`mt-1 text-green-600 dark:text-green-400 font-mono text-xs`,children:[`Building: `,o.partial.content[0].arguments.content.slice(-50),o.partial.content[0].arguments.content.length>50&&`...`]})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,$.jsx)(ce,{className:`h-3 w-3 animate-spin`}),`Executing`,o&&` with progress`,`...`]})]})]}):null}function Pi(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 ot(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,w;t[12]===S?w=t[13]:(w=e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),S())},t[12]=S,t[13]=w);let T=w;if(l){let e,n;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Ne,{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 E;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,$.jsx)(Ct,{className:`h-5 w-5 text-brand shrink-0 mt-0.5`}),t[18]=E):E=t[18];let D;t[19]===r?D=t[20]:(D=(0,$.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:(0,$.jsx)(Wr,{content:r})}),t[19]=r,t[20]=D);let O;t[21]===a?O=t[22]:(O=a&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:a}),t[21]=a,t[22]=O);let k;t[23]!==D||t[24]!==O?(k=(0,$.jsxs)(`div`,{className:`flex items-start gap-2 mb-3`,children:[E,(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[D,O]})]}),t[23]=D,t[24]=O,t[25]=k):k=t[25];let A;t[26]!==b||t[27]!==p||t[28]!==i||t[29]!==h?(A=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:C(`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)(Ne,{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]=A):A=t[30];let j;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(j=e=>c(e.target.value),t[31]=j):j=t[31];let M=i?.length?`Or type a custom answer...`:`Type your answer...`,N;t[32]!==s||t[33]!==T||t[34]!==p||t[35]!==M?(N=(0,$.jsx)(`input`,{type:`text`,value:s,onChange:j,onKeyDown:T,placeholder:M,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]=T,t[34]=p,t[35]=M,t[36]=N):N=t[36];let P;t[37]!==s||t[38]!==p?(P=p||!s.trim(),t[37]=s,t[38]=p,t[39]=P):P=t[39];let F;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,$.jsx)(ft,{className:`h-3 w-3`}),t[40]=F):F=t[40];let I;t[41]!==S||t[42]!==P?(I=(0,$.jsx)(`button`,{type:`button`,onClick:S,disabled:P,className:`h-7 w-7 rounded-full bg-primary text-primary-foreground hover:bg-primary/90 transition-colors disabled:opacity-50 flex items-center justify-center shrink-0`,children:F}),t[41]=S,t[42]=P,t[43]=I):I=t[43];let L;t[44]!==N||t[45]!==I?(L=(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[N,I]}),t[44]=N,t[45]=I,t[46]=L):L=t[46];let R;return t[47]!==L||t[48]!==k||t[49]!==A?(R=(0,$.jsxs)(`div`,{className:`rounded-lg border-t border-border p-4 my-2`,children:[k,A,L]}),t[47]=L,t[48]=k,t[49]=A,t[50]=R):R=t[50],R}function Fi(e){let t=(0,Q.c)(46),{toolCallId:n,intention:r,code:i}=e,{state:a}=an(),o=a.selectedThreadId,s;t[0]===n?s=t[1]:(s=bn(n),t[0]=n,t[1]=s);let c=s,[l,u]=(0,Z.useState)(c?.status??`running`),d;t[2]===c?d=t[3]:(d=()=>{if(!c||c.status!==`success`)return null;let e=c.result;return e==null?null:typeof e==`string`?e:JSON.stringify(e,null,2)},t[2]=c,t[3]=d);let[f,p]=(0,Z.useState)(d),[m,h]=(0,Z.useState)(c?.error??null),g,_;t[4]===n?(g=t[5],_=t[6]):(g=()=>On(n,()=>{let e=bn(n);if(e)if(u(e.status),e.status===`success`){let t=e.result;p(t==null?null:typeof t==`string`?t:JSON.stringify(t,null,2))}else e.status===`error`&&h(e.error??null)}),_=[n],t[4]=n,t[5]=g,t[6]=_),(0,Z.useEffect)(g,_);let v,y;t[7]!==i||t[8]!==o||t[9]!==n?(v=()=>{o&&yn(n,i,o)},y=[n,i,o],t[7]=i,t[8]=o,t[9]=n,t[10]=v,t[11]=y):(v=t[10],y=t[11]),(0,Z.useEffect)(v,y);let[b,x]=(0,Z.useState)(!1),S;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(S=()=>x(Ii),t[12]=S):S=t[12];let C=S;if(l===`running`){let e;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(ye,{className:`h-4 w-4 shrink-0 text-brand animate-pulse`}),t[13]=e):e=t[13];let n=r||`Executing Browser JS...`,i;return t[14]===n?i=t[15]:(i=(0,$.jsx)(`div`,{className:`overflow-hidden`,children:(0,$.jsxs)(`div`,{className:`w-full py-2 flex items-center gap-2 text-sm font-medium text-foreground`,children:[e,(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:n})]})}),t[14]=n,t[15]=i),i}if(l===`success`){let e;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(ye,{className:`h-4 w-4 shrink-0 text-brand`}),t[16]=e):e=t[16];let n=r||`Browser JS Executed Successfully`,a;t[17]===n?a=t[18]:(a=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:n}),t[17]=n,t[18]=a);let o;t[19]===b?o=t[20]:(o=b?(0,$.jsx)(xt,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(ke,{className:`h-4 w-4 shrink-0`}),t[19]=b,t[20]=o);let s;t[21]!==a||t[22]!==o?(s=(0,$.jsxs)(`button`,{onClick:C,className:`w-full py-2 flex items-center gap-2 text-sm font-medium text-foreground hover:bg-muted/50 transition-colors text-left`,children:[e,a,o]}),t[21]=a,t[22]=o,t[23]=s):s=t[23];let c;t[24]!==i||t[25]!==b||t[26]!==f?(c=b&&(0,$.jsxs)(`div`,{className:`py-2 border-t border-border flex flex-col gap-2`,children:[(0,$.jsx)(`pre`,{className:`text-xs text-muted-foreground leading-relaxed whitespace-pre-wrap`,children:i}),f!=null&&(0,$.jsx)(`pre`,{className:`text-xs text-foreground leading-relaxed whitespace-pre-wrap border-t border-border pt-2`,children:f})]}),t[24]=i,t[25]=b,t[26]=f,t[27]=c):c=t[27];let l;return t[28]!==s||t[29]!==c?(l=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[s,c]}),t[28]=s,t[29]=c,t[30]=l):l=t[30],l}let w;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(ye,{className:`h-4 w-4 shrink-0 text-destructive`}),t[31]=w):w=t[31];let T=r||`Browser JS Execution Failed`,E;t[32]===T?E=t[33]:(E=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:T}),t[32]=T,t[33]=E);let D;t[34]===b?D=t[35]:(D=b?(0,$.jsx)(xt,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(ke,{className:`h-4 w-4 shrink-0`}),t[34]=b,t[35]=D);let O;t[36]!==E||t[37]!==D?(O=(0,$.jsxs)(`button`,{onClick:C,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:[w,E,D]}),t[36]=E,t[37]=D,t[38]=O):O=t[38];let k;t[39]!==i||t[40]!==m||t[41]!==b?(k=b&&(0,$.jsxs)(`div`,{className:`py-2 border-t border-border flex flex-col gap-2`,children:[(0,$.jsx)(`pre`,{className:`text-xs text-muted-foreground leading-relaxed whitespace-pre-wrap`,children:m}),(0,$.jsx)(`pre`,{className:`text-xs text-muted-foreground leading-relaxed whitespace-pre-wrap`,children:i})]}),t[39]=i,t[40]=m,t[41]=b,t[42]=k):k=t[42];let A;return t[43]!==O||t[44]!==k?(A=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[O,k]}),t[43]=O,t[44]=k,t[45]=A):A=t[45],A}function Ii(e){return!e}function Li(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 Ze(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 u(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 d;t[5]===n?d=t[6]:(d=(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]=d);let f;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(E,{className:`h-3.5 w-3.5`}),t[7]=f):f=t[7];let p;t[8]===o?p=t[9]:(p=(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:f})}),t[8]=o,t[9]=p);let m;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(q,{children:`Save image`}),t[10]=m):m=t[10];let h;t[11]===p?h=t[12]:(h=(0,$.jsxs)(J,{children:[p,m]}),t[11]=p,t[12]=h);let g;t[13]===r?g=t[14]:(g=r?(0,$.jsx)(Ne,{className:`h-3.5 w-3.5 text-green-500`}):(0,$.jsx)(Ce,{className:`h-3.5 w-3.5`}),t[13]=r,t[14]=g);let _;t[15]!==c||t[16]!==g?(_=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(`button`,{onClick:c,className:`flex items-center justify-center h-7 w-7 rounded-md bg-background/80 backdrop-blur-sm border border-border text-foreground hover:bg-background transition-colors`,children:g})}),t[15]=c,t[16]=g,t[17]=_):_=t[17];let v=r?`Copied!`:`Copy to clipboard`,y;t[18]===v?y=t[19]:(y=(0,$.jsx)(q,{children:v}),t[18]=v,t[19]=y);let b;t[20]!==_||t[21]!==y?(b=(0,$.jsxs)(J,{children:[_,y]}),t[20]=_,t[21]=y,t[22]=b):b=t[22];let x;t[23]!==b||t[24]!==h?(x=(0,$.jsx)(`div`,{className:`absolute top-2 right-2 flex gap-1 opacity-0 group-hover/img:opacity-100 transition-opacity`,children:(0,$.jsxs)(hn,{children:[h,b]})}),t[23]=b,t[24]=h,t[25]=x):x=t[25];let S;return t[26]!==x||t[27]!==d?(S=(0,$.jsxs)(`div`,{className:`mt-2 relative group/img inline-block max-w-full`,children:[d,x]}),t[26]=x,t[27]=d,t[28]=S):S=t[28],S}function Ri(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 zi(e,t,n,r){return e.name===`ask_user`?(0,$.jsx)(Pi,{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)(Fi,{toolCallId:e.id,intention:e.input?.intention??``,code:e.input?.code??``},t):n?(0,$.jsxs)(`span`,{children:[(0,$.jsx)(Ni,{toolCall:e}),(0,$.jsx)(Oi,{inline:!0,block:e,resultContent:r})]},t):(0,$.jsx)(Oi,{inline:!0,block:e,resultContent:r},t)}function Bi({message:e,threadId:n,messageIndex:r=0}){let i=e.sender===`user`,a=i?null:cn(e.content),[o,s]=(0,Z.useState)(!1),c=e.timestamp?new Date(e.timestamp).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}):``;async function l(){if(!(!e.checkpointRef||!n||o)){s(!0);try{let t=await Ve(n,e.checkpointRef);t.success?X({title:`Checkpoint restored`,description:`Working tree restored to before this agent run.`}):X({title:`Restore failed`,description:t.error??`Could not restore checkpoint.`,variant:`destructive`})}catch(e){X({title:`Restore failed`,description:e instanceof Error?e.message:`Unknown error`,variant:`destructive`})}finally{s(!1)}}}return(0,$.jsxs)(`div`,{className:C(`group flex gap-3 px-4 py-4`,i?`flex-row-reverse`:`flex-row`),children:[(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-1 shrink-0`,children:[(0,$.jsx)(`div`,{className:C(`flex h-7 w-7 items-center justify-center rounded-full`,i?`bg-foreground`:`bg-muted`),children:i?(0,$.jsx)(M,{className:`h-3.5 w-3.5 text-background`}):(0,$.jsx)(Le,{className:`h-3.5 w-3.5 text-muted-foreground`})}),i&&e.checkpointRef&&(0,$.jsx)(hn,{children:(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(`button`,{onClick:l,disabled:o,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)(yt,{className:C(`h-3 w-3`,o&&`animate-spin`)})})}),(0,$.jsx)(q,{side:`left`,children:`Restore checkpoint`})]})})]}),(0,$.jsxs)(`div`,{className:C(`flex flex-1 flex-col gap-1 min-w-0`,i&&`items-end`),children:[(0,$.jsxs)(`div`,{className:C(`flex items-center gap-2`,i&&`flex-row-reverse`),children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:i?`You`:`Agent`}),c&&(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)(t,{className:`h-2.5 w-2.5`}),c]}),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)(ye,{className:`h-2.5 w-2.5`}),qn(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)(y,{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:C(`rounded-xl px-4 py-3 flex flex-col gap-0.5 min-w-0`,i?`bg-foreground text-background`:`bg-muted text-foreground`),children:e.isThinking?(()=>{let t=fn(e.content);return t?.length?t.map((e,n)=>e.type===`tool_use`?zi(e,n,!1,Ri(t,e.id)):e.type===`tool-result`?(0,$.jsx)(ji,{inline:!0,block:e},n):e.type===`reasoning`&&`text`in e?(0,$.jsx)(Mi,{},n):null):(0,$.jsx)(`div`,{className:`text-xs text-muted-foreground leading-relaxed whitespace-pre-wrap`,children:(0,$.jsx)(Wr,{content:sn(e.content),enableMermaid:!0})})})():a?(()=>{let e=a.filter(e=>e.type===`tool_use`&&e.name===`ask_user`);return(0,$.jsxs)($.Fragment,{children:[a.map((e,t)=>e.type===`tool_use`&&e.name===`todo`||e.type===`tool-result`&&e.toolName===`todo`?e.type===`tool-result`?(0,$.jsx)(ji,{inline:!0,sequence:r,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)(Mi,{}):e.type===`text`&&`text`in e?(0,$.jsx)(Wr,{content:sn(e.text),enableMermaid:!0}):e.type===`tool_use`?zi(e,void 0,!1,Ri(a,e.id)):e.type===`tool-result`?(0,$.jsx)(ji,{inline:!0,block:e}):null},t)),e.map((e,t)=>(0,$.jsx)(Pi,{toolCallId:e.id,question:JSON.stringify(e.input?.question??``),options:e.input?.options,context:e.input?.context,answeredText:Ri(a,e.id)},`ask-${t}`))]})})():(0,$.jsx)(Wr,{content:sn(e.content),enableMermaid:!0})}),(e.generatedImageUrl||e.generatedImageData)&&(0,$.jsx)(Li,{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)(rt,{className:`h-2.5 w-2.5`}),e.fileName]},t))})]})]})}function Vi(e){let t=(0,Q.c)(26),{segments:n,model:r,isCreatingProject:i,isProcessingThread:a,totalMessages:o,eventCount:s}=e,c=o===void 0?0:o,l=s===void 0?0:s,u,d,f,p,m;if(t[0]!==l||t[1]!==i||t[2]!==a||t[3]!==r||t[4]!==n||t[5]!==c){let e=on(n);p=`group flex gap-3 px-4 py-4`,t[11]===l?m=t[12]:(m=(0,$.jsx)(Er,{eventCount:l}),t[11]=l,t[12]=m),u=`flex flex-1 flex-col gap-1 min-w-0`;let o;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:`Agent`}),t[13]=o):o=t[13];let s;t[14]===r?s=t[15]:(s=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)(ye,{className:`h-2.5 w-2.5`}),qn(r)]}),t[14]=r,t[15]=s),t[16]===s?d=t[17]:(d=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[o,s]}),t[16]=s,t[17]=d),f=e.length>0?(()=>{let t=e.filter(Ui);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)(ji,{inline:!0,sequence:c,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)(Mi,{isStreaming:e.slice(n+1).every(Hi)}):t.type===`text`&&`text`in t?(0,$.jsx)(Wr,{content:sn(t.text),enableMermaid:!0}):t.type===`tool_use`?zi(t,void 0,!0,Ri(e,t.id)):t.type===`tool-result`?(0,$.jsx)(ji,{inline:!0,block:t}):null},`b-${n}`)),t.map((t,n)=>(0,$.jsx)(Pi,{toolCallId:t.id,question:JSON.stringify(t.input?.question??``),options:t.input?.options,context:t.input?.context,answeredText:Ri(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)(Mi,{isStreaming:!0})}):(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]=l,t[1]=i,t[2]=a,t[3]=r,t[4]=n,t[5]=c,t[6]=u,t[7]=d,t[8]=f,t[9]=p,t[10]=m}else u=t[6],d=t[7],f=t[8],p=t[9],m=t[10];let h;t[18]!==u||t[19]!==d||t[20]!==f?(h=(0,$.jsxs)(`div`,{className:u,children:[d,f]}),t[18]=u,t[19]=d,t[20]=f,t[21]=h):h=t[21];let g;return t[22]!==p||t[23]!==m||t[24]!==h?(g=(0,$.jsxs)(`div`,{className:p,children:[m,h]}),t[22]=p,t[23]=m,t[24]=h,t[25]=g):g=t[25],g}function Hi(e){return e.type===`reasoning`}function Ui(e){return e.type===`tool_use`&&e.name===`ask_user`}var Wi=(0,Z.memo)(Vi,(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 Gi(e){let t=(0,Q.c)(34),{projects:n,onSelectProject:r,onCreateThread:i,onConnectRepo:a,onNewApp:o,onOpenFolder:s}=e,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(`img`,{src:`/tarsk-color.svg`,alt:`Tarsk`,className:`h-16 w-16 rounded-lg`}),t[0]=c):c=t[0];let l;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight text-foreground text-balance`,children:`Let's build it!`}),t[1]=l):l=t[1];let u=n.length===0?`Start or connect your first project`:`Select a project to start coding`,d;t[2]===u?d=t[3]:(d=(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3`,children:[c,(0,$.jsxs)(`div`,{className:`text-center`,children:[l,(0,$.jsx)(`p`,{className:`mt-1 text-base text-muted-foreground`,children:u})]})]}),t[2]=u,t[3]=d);let f;if(t[4]!==i||t[5]!==r||t[6]!==n){let e;t[8]!==i||t[9]!==r?(e=e=>(0,$.jsxs)(`button`,{type:`button`,className:`flex w-56 flex-col gap-2 rounded-xl border border-border bg-background p-4 text-left shadow-sm transition-colors hover:bg-muted`,onClick:()=>{e.threads.length===0?i(e.projectId):r(e.projectId,e.threads[0].threadId)},children:[(0,$.jsx)(It,{className:`h-5 w-5 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`text-sm text-foreground leading-snug font-medium`,children:e.name}),(0,$.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[e.threads.length,` thread`,e.threads.length===1?``:`s`]})]},e.projectId),t[8]=i,t[9]=r,t[10]=e):e=t[10],f=n.map(e),t[4]=i,t[5]=r,t[6]=n,t[7]=f}else f=t[7];let p,m,h;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(x,{className:`h-5 w-5 text-muted-foreground`}),m=(0,$.jsx)(`span`,{className:`text-sm text-foreground leading-snug font-medium`,children:`Connect a repo`}),h=(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Clone an existing repository`}),t[11]=p,t[12]=m,t[13]=h):(p=t[11],m=t[12],h=t[13]);let g;t[14]===a?g=t[15]:(g=(0,$.jsxs)(`button`,{type:`button`,className:`flex w-56 flex-col gap-2 rounded-xl border border-border bg-background p-4 text-left shadow-sm transition-colors hover:bg-muted`,onClick:a,children:[p,m,h]}),t[14]=a,t[15]=g);let _,v,y;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(Pe,{className:`h-5 w-5 text-muted-foreground`}),v=(0,$.jsx)(`span`,{className:`text-sm text-foreground leading-snug font-medium`,children:`New App`}),y=(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Create a new project from template`}),t[16]=_,t[17]=v,t[18]=y):(_=t[16],v=t[17],y=t[18]);let b;t[19]===o?b=t[20]:(b=(0,$.jsxs)(`button`,{type:`button`,className:`flex w-56 flex-col gap-2 rounded-xl border border-border bg-background p-4 text-left shadow-sm transition-colors hover:bg-muted`,onClick:o,children:[_,v,y]}),t[19]=o,t[20]=b);let S,C,w;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,$.jsx)(ie,{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]===s?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:s,children:[S,C,w]}),t[24]=s,t[25]=T);let E;t[26]!==b||t[27]!==T||t[28]!==f||t[29]!==g?(E=(0,$.jsxs)(`div`,{className:`flex flex-wrap justify-center gap-3`,children:[f,g,b,T]}),t[26]=b,t[27]=T,t[28]=f,t[29]=g,t[30]=E):E=t[30];let D;return t[31]!==E||t[32]!==d?(D=(0,$.jsxs)(`div`,{className:`mx-auto flex max-w-3xl flex-1 flex-col items-center justify-center gap-8 px-4`,children:[d,E]}),t[31]=E,t[32]=d,t[33]=D):D=t[33],D}function Ki(e){let t=(0,Q.c)(20),{project:n}=e,{setDevServerRunning:r}=Wn(),[i,a]=(0,Z.useState)(!1),{startServer:o}=Jn(),s;t[0]!==n||t[1]!==r?(s=()=>{if(!n?.projectId)return;let e=async()=>{try{let e=await _t(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 qi=(0,Z.createContext)(null),Ji=(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});Ji.displayName=`MessageList`;function Yi(){let e=(0,Q.c)(14),t=(0,Z.useContext)(qi);if(!t)return null;let{isStreaming:n,isCreatingProject:r,isProcessingThread:i,streamingSegments:a,streamingModel:o,streamingEventCount:s,totalMessages:c,error:l,onClearError:u}=t,d;e[0]!==r||e[1]!==i||e[2]!==n||e[3]!==s||e[4]!==o||e[5]!==a||e[6]!==c?(d=(n||r||i)&&(0,$.jsx)(Wi,{segments:a,model:o,isCreatingProject:r,isProcessingThread:i,totalMessages:c,eventCount:s}),e[0]=r,e[1]=i,e[2]=n,e[3]=s,e[4]=o,e[5]=a,e[6]=c,e[7]=d):d=e[7];let f;e[8]!==l||e[9]!==u?(f=l&&(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:l}),(0,$.jsx)(`button`,{type:`button`,className:`mt-1 text-xs text-destructive underline underline-offset-2 hover:text-destructive/80`,onClick:u,children:`Dismiss`})]}),e[8]=l,e[9]=u,e[10]=f):f=e[10];let p;return e[11]!==d||e[12]!==f?(p=(0,$.jsxs)(`div`,{className:`mx-auto max-w-3xl w-full min-w-0 pb-48`,children:[d,f]}),e[11]=d,e[12]=f,e[13]=p):p=e[13],p}var Xi={List:Ji,Footer:Yi};function Zi(e){let t=(0,Q.c)(44),{messages:n,isStreaming:r,streamingSegments:i,streamingModel:a,streamingEventCount:o,isCreatingProject:s,isProcessingThread:c,selectedThreadId:l,selectedProjectId:u,projects:d,projectsLoading:f,messagesLoaded:p,onSelectThread:m,onCreateThread:h,onConnectRepo:g,onNewApp:_,onOpenFolder:v,error:y,onClearError:b}=e,x=(0,Z.useRef)(null),S=(0,Z.useRef)(0),w=(0,Z.useRef)(!1),T;t[0]!==r||t[1]!==n.length?(T=()=>{let e=n.length>S.current,t=w.current&&!r;(r||e||t)&&requestAnimationFrame(()=>{x.current?.scrollTo({top:2**53-1,behavior:`smooth`})}),S.current=n.length,w.current=r},t[0]=r,t[1]=n.length,t[2]=T):T=t[2];let E;t[3]!==r||t[4]!==n||t[5]!==i.length?(E=[r,n,i.length],t[3]=r,t[4]=n,t[5]=i.length,t[6]=E):E=t[6],(0,Z.useEffect)(T,E);let D=n.length===0&&!r&&!s&&!l,O=p&&n.length===0&&!r&&!s&&l,k;if(t[7]!==d||t[8]!==u){let e;t[10]===u?e=t[11]:(e=e=>e.projectId===u,t[10]=u,t[11]=e),k=d.find(e),t[7]=d,t[8]=u,t[9]=k}else k=t[9];let A=k;if(D){let e=`transition-opacity duration-500 ease-in-out ${f?`opacity-0`:`opacity-100`}`,n;t[12]!==g||t[13]!==h||t[14]!==_||t[15]!==v||t[16]!==m||t[17]!==d?(n=(0,$.jsx)(Gi,{projects:d,onSelectProject:m,onCreateThread:h,onConnectRepo:g,onNewApp:_,onOpenFolder:v}),t[12]=g,t[13]=h,t[14]=_,t[15]=v,t[16]=m,t[17]=d,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(O){let e;return t[22]===A?e=t[23]:(e=(0,$.jsx)(Ki,{project:A}),t[22]=A,t[23]=e),e}let j;t[24]!==y||t[25]!==s||t[26]!==c||t[27]!==r||t[28]!==n.length||t[29]!==b||t[30]!==o||t[31]!==a||t[32]!==i?(j={isStreaming:r,isCreatingProject:s,isProcessingThread:c,streamingSegments:i,streamingModel:a,streamingEventCount:o,totalMessages:n.length,error:y,onClearError:b},t[24]=y,t[25]=s,t[26]=c,t[27]=r,t[28]=n.length,t[29]=b,t[30]=o,t[31]=a,t[32]=i,t[33]=j):j=t[33];let M=j,N;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(N=C(`h-full overflow-hidden`),t[34]=N):N=t[34];let P;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(P={height:`100%`},t[35]=P):P=t[35];let F;t[36]===l?F=t[37]:(F=(e,t)=>(0,$.jsx)(Bi,{message:t,threadId:l,messageIndex:e}),t[36]=l,t[37]=F);let I;t[38]!==n||t[39]!==F?(I=(0,$.jsx)(Yt,{ref:x,style:P,data:n,itemContent:F,overscan:500,components:Xi}),t[38]=n,t[39]=F,t[40]=I):I=t[40];let L;return t[41]!==M||t[42]!==I?(L=(0,$.jsx)(`div`,{className:N,children:(0,$.jsx)(qi.Provider,{value:M,children:I})}),t[41]=M,t[42]=I,t[43]=L):L=t[43],L}async function Qi(e){return c(`api/projects/${f(e)}/todos`)}async function $i(e,t){return r(`api/projects/${f(e)}/todos`,{description:t})}async function ea(e,t,n){return et(`api/projects/${f(e)}/todos/${f(t)}`,n)}async function ta(e,t){await ue(`api/projects/${f(e)}/todos/${f(t)}`)}var na={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 ra({todo:e,projectId:t,onUpdate:n,onEdit:r,onAction:i,onThreadSelect:a}){let[o,s]=(0,Z.useState)(!1),c=na[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 ea(t,e.id,{status:a,working:a!==`Done`}))}finally{s(!1)}}return(0,$.jsxs)(`div`,{className:C(`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)(ce,{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)(g,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Open thread`})]})}),(0,$.jsx)(q,{side:`right`,children:`Open thread`})]})]})]})}var ia=`Please analyze this task and create a detailed implementation plan.
|
|
18
|
+
|
|
19
|
+
Task description:
|
|
20
|
+
{description}`,aa="\nWrite your complete plan to the file `{todoId}-plan.md` in the current directory.",oa=`Act as a Quality Assurance Manager. Rephrase the task into a rigorous test case: {description}`,sa=`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}`,ca={plan:ia,test:oa,review:sa},la={plan:`planPrompt`,test:`testPrompt`,review:`reviewPrompt`};function ua(e,t){let n=e?.[la[t]];return n&&n.trim()?n:ca[t]}function da(e,t,n,r){let i=e.replace(/\{description\}/g,r);return t===`plan`&&(i+=aa.replace(/\{todoId\}/g,n)),i}var fa=[`Ready`,`Plan`,`Build`,`Test`,`Review`,`Done`],pa={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 ma(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 ha(e){let t=e.getReader();try{for(;;){let{done:e}=await t.read();if(e)break}}catch{}}async function ga(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 _a({projectId:e,addOpen:t,onAddOpenChange:n,onThreadSelect:r}){let{state:a,dispatch:s}=an(),[l,u]=(0,Z.useState)([]),[d,f]=(0,Z.useState)(!0),[p,m]=(0,Z.useState)(null),[h,g]=(0,Z.useState)(``),[y,b]=(0,Z.useState)(!1),[x,S]=(0,Z.useState)(!1),[w,T]=(0,Z.useState)(null),[E,O]=(0,Z.useState)(``),[k,A]=(0,Z.useState)(!1),[j,M]=(0,Z.useState)(!1),N=(0,Z.useCallback)(async()=>{try{let t=await Qi(e),n=t.filter(e=>e.threadId&&e.status!==`Done`),r=[...t];await Promise.all(n.map(async t=>{try{await tt(t.threadId)}catch(n){if(n instanceof Error&&n.message.includes(`not found`)){let n=await ea(e,t.id,{status:`Done`}),i=r.findIndex(e=>e.id===t.id);i!==-1&&(r[i]=n);return}}})),u(r)}catch(e){console.error(`Failed to fetch project todos:`,e)}finally{f(!1)}},[e]);(0,Z.useEffect)(()=>{N()},[N]),(0,Z.useEffect)(()=>{if(!l.some(e=>e.working))return;let t=setInterval(async()=>{try{let n=await Qi(e);u(n),n.some(e=>e.working)||clearInterval(t)}catch(e){console.error(`Failed to poll project todos:`,e)}},2e3);return()=>clearInterval(t)},[l,e]),(0,Z.useEffect)(()=>{t&&g(``)},[t]);function F(e){g(e.description),m({todo:e})}function L(){m(null),g(``)}async function R(){if(h.trim()){b(!0);try{let t=await $i(e,h);u(e=>[...e,t]),n(!1),g(``)}finally{b(!1)}}}async function ee(){if(!(!h.trim()||!p)){b(!0);try{let t=await ea(e,p.todo.id,{description:h});u(e=>e.map(e=>e.id===t.id?t:e)),L()}finally{b(!1)}}}async function z(){if(p){b(!0);try{await ta(e,p.todo.id),u(e=>e.filter(e=>e.id!==p.todo.id)),L()}finally{b(!1)}}}function B(e){u(t=>t.map(t=>t.id===e.id?e:t))}async function V(t){let n=a.selectedThreadId?a.projectModelSelections[a.selectedThreadId]:void 0,r=a.projects.find(t=>t.projectId===e),i=r?.threads.find(e=>e.threadId===a.selectedThreadId),c=n?.id??i?.model,l=n?.provider??i?.modelProvider;if(!c||!l)throw console.error(`No model or provider found for project`,e,i),Error(`No model configuration found. Please configure a model and provider for this project first.`);let u=await P(e);if(!u)return;let d=null,f=await ma(u,n=>{ea(e,t.id,{status:`Plan`,working:!0,threadId:n}).then(e=>{d=e,B(e)})});if(!f)return;d||B(await ea(e,t.id,{status:`Plan`,working:!0,threadId:f}));let p=n??{id:c,provider:l,name:c,description:``};s({type:K.SetProjectModel,threadId:f,model:p}),o(f,{model:c,modelProvider:l});let m=await it(f,da(ua(r,`plan`),`plan`,t.id,t.description),c,[],void 0,l);m&&ha(m)}async function te(t){let n=await P(e);if(!n)return;let r=null,i=await ma(n,n=>{ea(e,t.id,{status:`Build`,working:!0,threadId:n}).then(e=>{r=e,B(e)})});if(!i)return;r||B(await ea(e,t.id,{status:`Build`,working:!0,threadId:i}));let a=await tt(i),l=a.model,u=a.modelProvider;if(!l||!u)try{let t=(await c(`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&&(l=t.model,u=t.modelProvider)}catch(e){console.error(`Failed to get project threads:`,e)}if(!l||!u)throw Error(`No model configuration found. Please configure a model and provider for this project first.`);s({type:K.SetProjectModel,threadId:i,model:{id:l,provider:u,name:l,description:``}}),o(i,{model:l,modelProvider:u}),console.log(`Sending chat message with provider:`,i,t.description,u);let d=await it(i,t.description,l,[],void 0,u);d&&ha(d)}async function H(t){try{let n=await P(e);if(!n){S(!1),T(null);return}let r=null;if(r=await ma(n,e=>{r=e}),!r){S(!1),T(null);return}let o=await tt(r),s=o.model,l=o.modelProvider;if(!s||!l)try{let t=(await c(`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&&(s=t.model,l=t.modelProvider)}catch(e){console.error(`Failed to get project threads:`,e)}if(!s||!l){i(e,r),S(!1),T(null);return}let u=da(ua(a.projects.find(t=>t.projectId===e),`test`),`test`,t.id,t.description),d=await it(r,u,s,[],void 0,l);d&&O(await ga(d)),i(e,r)}catch(e){console.error(`Failed to generate test case:`,e),S(!1),T(null)}finally{A(!1)}}function ne(e){T(e),O(``),A(!0),S(!0),H(e)}function re(){S(!1),T(null),O(``)}async function ie(){if(!w||!E.trim())return;let t=w,n=E;re(),M(!0);try{let r=await P(e);if(!r)return;let i=null,a=await ma(r,n=>{ea(e,t.id,{status:`Test`,working:!0,threadId:n}).then(e=>{i=e,B(e)})});if(!a)return;i||B(await ea(e,t.id,{status:`Test`,working:!0,threadId:a}));let l=await tt(a),u=l.model,d=l.modelProvider;if(!u||!d)try{let t=(await c(`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&&(u=t.model,d=t.modelProvider)}catch(e){console.error(`Failed to get project threads:`,e)}if(!u||!d)throw Error(`No model configuration found. Please configure a model and provider for this project first.`);s({type:K.SetProjectModel,threadId:a,model:{id:u,provider:d,name:u,description:``}}),o(a,{model:u,modelProvider:d});let f=await it(a,n,u,[],void 0,d);f&&ha(f)}finally{M(!1)}}async function ae(t){let n=await P(e);if(!n)return;let r=null,i=await ma(n,n=>{ea(e,t.id,{status:`Review`,working:!0,threadId:n}).then(e=>{r=e,B(e)})});if(!i)return;r||B(await ea(e,t.id,{status:`Review`,working:!0,threadId:i}));let l=await tt(i),u=l.model,d=l.modelProvider;if(!u||!d)try{let t=(await c(`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&&(u=t.model,d=t.modelProvider)}catch(e){console.error(`Failed to get project threads:`,e)}if(!u||!d)throw Error(`No model configuration found. Please configure a model and provider for this project first.`);s({type:K.SetProjectModel,threadId:i,model:{id:u,provider:d,name:u,description:``}}),o(i,{model:u,modelProvider:d});let f=await it(i,da(ua(a.projects.find(t=>t.projectId===e),`review`),`review`,t.id,t.description),u,[],void 0,d);f&&ha(f)}async function oe(t,n){n===`Plan`?await V(t):n===`Build`?await te(t):n===`Test`?ne(t):n===`Review`?await ae(t):B(await ea(e,t.id,{status:n,working:n!==`Done`}))}return d?(0,$.jsx)(`div`,{className:`flex items-center justify-center h-64`,children:(0,$.jsx)(ce,{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:fa.map(t=>{let i=l.filter(e=>e.status===t),a=t===`Ready`;return(0,$.jsxs)(`div`,{className:C(`flex flex-col rounded-lg border border-t-4 bg-muted/30 min-w-[200px] w-[200px] shrink-0`,pa[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)(I,{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)(Ae,{className:`h-3 w-3 mr-1`}),`Add Task`]}),i.map(t=>(0,$.jsx)(ra,{todo:t,projectId:e,onUpdate:B,onEdit:F,onAction:oe,onThreadSelect:r},t.id))]})})]},t)})}),(0,$.jsx)(v,{open:t,onOpenChange:n,children:(0,$.jsxs)(W,{className:`sm:max-w-2xl`,children:[(0,$.jsx)(D,{children:(0,$.jsx)(gt,{children:`Add Task`})}),(0,$.jsxs)(`div`,{className:`py-2`,children:[(0,$.jsx)(mn,{placeholder:`Describe what needs to be done...`,value:h,onChange:e=>g(e.target.value),rows:12,className:`resize-none text-sm`,autoFocus:!0,onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&R()}}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1.5`,children:`A title will be generated automatically from your description.`})]}),(0,$.jsx)(_,{children:(0,$.jsx)(U,{onClick:()=>void R(),disabled:y||!h.trim(),children:y?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ce,{className:`h-3 w-3 animate-spin mr-1`}),`Generating title...`]}):`Add`})})]})}),(0,$.jsx)(v,{open:x,onOpenChange:e=>!e&&re(),children:(0,$.jsxs)(W,{className:`sm:max-w-2xl`,children:[(0,$.jsx)(D,{children:(0,$.jsx)(gt,{children:`Test Case`})}),(0,$.jsx)(`div`,{className:`py-2`,children:k?(0,$.jsxs)(`div`,{className:`flex items-center justify-center h-32 gap-2 text-muted-foreground`,children:[(0,$.jsx)(ce,{className:`h-4 w-4 animate-spin`}),(0,$.jsx)(`span`,{className:`text-sm`,children:`Generating test case...`})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(mn,{value:E,onChange:e=>O(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)(_,{children:[(0,$.jsx)(U,{variant:`outline`,onClick:re,disabled:k,children:`Cancel`}),(0,$.jsx)(U,{onClick:()=>void ie(),disabled:k||!E.trim()||j,children:j?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ce,{className:`h-3 w-3 animate-spin mr-1`}),`Starting...`]}):`Confirm`})]})]})}),(0,$.jsx)(v,{open:p!==null,onOpenChange:e=>!e&&L(),children:(0,$.jsxs)(W,{className:`sm:max-w-2xl`,children:[(0,$.jsx)(D,{children:(0,$.jsx)(gt,{children:`Edit Task`})}),(0,$.jsx)(`div`,{className:`py-2`,children:(0,$.jsx)(mn,{placeholder:`Describe what needs to be done...`,value:h,onChange:e=>g(e.target.value),rows:12,className:`resize-none text-sm`,autoFocus:!0,onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&ee()}})}),(0,$.jsxs)(_,{className:`gap-2 sm:gap-0`,children:[(0,$.jsx)(U,{variant:`destructive`,onClick:()=>void z(),disabled:y,className:`mr-auto`,children:`Delete`}),(0,$.jsx)(U,{onClick:()=>void ee(),disabled:y||!h.trim(),children:y?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ce,{className:`h-3 w-3 animate-spin mr-1`}),`Saving...`]}):`Save`})]})]})})]})}var va=[{value:`plan`,label:`Plan`,field:`planPrompt`,defaultPrompt:ia},{value:`review`,label:`Code Review`,field:`reviewPrompt`,defaultPrompt:sa},{value:`test`,label:`Test`,field:`testPrompt`,defaultPrompt:oa}];function ya({open:e,onOpenChange:t,projectId:n}){let{state:r}=an(),[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 kt(n,{planPrompt:i.plan.trim()===ia?null:i.plan.trim()||null,testPrompt:i.test.trim()===oa?null:i.test.trim()||null,reviewPrompt:i.review.trim()===sa?null:i.review.trim()||null}),O(),X({title:`AI prompt settings saved`}),t(!1)}catch(e){X({title:`Error`,description:e instanceof Error?e.message:`Failed to save prompt settings`,variant:`destructive`})}finally{s(!1)}}function l(e,t){a(n=>({...n,[e]:t}))}return(0,$.jsx)(v,{open:e,onOpenChange:t,children:(0,$.jsxs)(W,{className:`max-w-2xl`,children:[(0,$.jsxs)(D,{children:[(0,$.jsx)(gt,{children:`AI Prompt Settings`}),(0,$.jsx)(me,{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)(tr,{defaultValue:`plan`,className:`w-full`,children:[(0,$.jsx)(er,{className:`w-full`,children:va.map(e=>(0,$.jsx)(Qn,{value:e.value,className:`flex-1`,children:e.label},e.value))}),va.map(e=>(0,$.jsxs)($n,{value:e.value,children:[(0,$.jsx)(mn,{value:i[e.value]||e.defaultPrompt,onChange:t=>l(e.value,t.target.value),className:`min-h-[250px] font-mono text-sm resize-none`,placeholder:e.defaultPrompt,disabled:o}),(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground mt-1.5`,children:[`Use `,(0,$.jsx)(`code`,{className:`text-xs`,children:`{description}`}),` for the task description. Leave empty to use the default.`]})]},e.value))]}),(0,$.jsx)(_,{children:(0,$.jsx)(U,{onClick:()=>void c(),disabled:o,children:o?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ce,{className:`mr-2 h-4 w-4 animate-spin`}),`Saving...`]}):`Save`})})]})})}function ba({projectId:e}){let{state:t,dispatch:n}=an(),{projects:r}=t,[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(!1),c=tn(),{setActiveMainTab:l}=Wn();async function u(i){if(r.find(t=>t.projectId===e)){c(`/`),l(`chat`);try{let{getProjects:r,invalidateProjectsCache:a}=await Gt(async()=>{let{getProjects:e,invalidateProjectsCache:t}=await import(`./dialogs-config-DZFG2IQM.js`).then(e=>e.b);return{getProjects:e,invalidateProjectsCache:t}},__vite__mapDeps([4,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 Ft();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 Ft();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)(_a,{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)(Te,{className:`h-4 w-4`})}),(0,$.jsx)(ya,{open:o,onOpenChange:s,projectId:e})]})}var xa=(0,Z.lazy)(()=>Gt(()=>import(`./diff-view-fOVqrHQW.js`),__vite__mapDeps([9,1,2,3,4,5,10,11,12,7,13,14,15,16,17,18,19,20,6]))),Sa=(0,Z.lazy)(()=>Gt(()=>import(`./dialogs-config-DZFG2IQM.js`).then(e=>e.t),__vite__mapDeps([4,1])));function Ca(e){let t=(0,Q.c)(54),{onCreateThread:r}=e,{state:i,dispatch:a}=an(),o=tn(),s=Wt(),[c,l]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(null),{selectedThreadId:f,messages:p,isCreatingProject:m,processingThreadIds:h,projects:g,projectsLoading:_,messagesLoaded:v,isStreaming:y,streamingSegments:b,streamingModel:x,streamingEventCount:S}=i,C;t[0]!==h||t[1]!==f?(C=f&&h.includes(f),t[0]=h,t[1]=f,t[2]=C):C=t[2];let w=!!C,T;t[3]!==a||t[4]!==i.sidebarOpen?(T=()=>{i.sidebarOpen&&a({type:K.ToggleSidebar})},t[3]=a,t[4]=i.sidebarOpen,t[5]=T):T=t[5];let E=T,D;t[6]===E?D=t[7]:(D=()=>{E(),d(`clone`),l(!0)},t[6]=E,t[7]=D);let O=D,k;t[8]===E?k=t[9]:(k=()=>{E(),d(`webapp`),l(!0)},t[8]=E,t[9]=k);let A=k,j;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(j=async(e,t)=>{try{await $e(e,t),l(!1),d(null)}catch(e){console.error(`Failed to clone repository:`,e)}},t[10]=j):j=t[10];let M=j,N;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(N=async(e,t,r)=>{try{await n(e,t,r),l(!1),d(null)}catch(e){console.error(`Failed to create project:`,e)}},t[11]=N):N=t[11];let P=N,F;t[12]===E?F=t[13]:(F=async()=>{E();try{await xe(),l(!1),d(null)}catch(e){console.error(`Failed to open folder:`,e)}},t[12]=E,t[13]=F);let I=F,L=s.pathname===`/review`,R=s.pathname===`/todos`,ee;t[14]===o?ee=t[15]:(ee=()=>{o(`/`)},t[14]=o,t[15]=ee);let z=ee,{selectedProjectId:B}=i,V;t[16]!==E||t[17]!==a||t[18]!==O||t[19]!==z||t[20]!==A||t[21]!==I||t[22]!==m||t[23]!==w||t[24]!==y||t[25]!==p||t[26]!==v||t[27]!==r||t[28]!==g||t[29]!==_||t[30]!==L||t[31]!==B||t[32]!==f||t[33]!==S||t[34]!==x||t[35]!==b||t[36]!==R?(V=R&&B?(0,$.jsx)(ba,{projectId:B}):L&&f?(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:`Loading diff view...`}),children:(0,$.jsx)(xa,{threadId:f,onExit:z})}):(0,$.jsx)(Zi,{messages:p,isStreaming:y,streamingSegments:b,streamingModel:x,streamingEventCount:S,isCreatingProject:m,isProcessingThread:w,selectedThreadId:f,selectedProjectId:B,projects:g,projectsLoading:_,messagesLoaded:v,onSelectThread:(e,t)=>{E(),a({type:K.SelectThread,projectId:e,threadId:t})},onCreateThread:r,onConnectRepo:O,onNewApp:A,onOpenFolder:I,error:null,onClearError:wa}),t[16]=E,t[17]=a,t[18]=O,t[19]=z,t[20]=A,t[21]=I,t[22]=m,t[23]=w,t[24]=y,t[25]=p,t[26]=v,t[27]=r,t[28]=g,t[29]=_,t[30]=L,t[31]=B,t[32]=f,t[33]=S,t[34]=x,t[35]=b,t[36]=R,t[37]=V):V=t[37];let te;t[38]!==p||t[39]!==L||t[40]!==f||t[41]!==R?(te=!L&&!R&&f&&(0,$.jsxs)(`div`,{className:`absolute bottom-0 left-0 right-0 z-10 pr-4`,children:[(0,$.jsx)(`div`,{className:`h-6 bg-gradient-to-t from-background to-transparent`}),(0,$.jsx)(`div`,{className:`h-8 bg-background`}),(0,$.jsx)(`div`,{className:`bg-background`,children:(0,$.jsx)(jn,{messages:p})})]}),t[38]=p,t[39]=L,t[40]=f,t[41]=R,t[42]=te):te=t[42];let H=u??void 0,ne;t[43]!==c||t[44]!==I||t[45]!==H?(ne=(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Sa,{open:c,onOpenChange:l,initialMode:H,onSubmitClone:M,onSubmitWebApp:P,onOpenFolder:I})}),t[43]=c,t[44]=I,t[45]=H,t[46]=ne):ne=t[46];let re;t[47]!==te||t[48]!==ne||t[49]!==V?(re=(0,$.jsxs)(`div`,{className:`relative flex h-full flex-col`,children:[V,te,ne]}),t[47]=te,t[48]=ne,t[49]=V,t[50]=re):re=t[50];let ie;return t[51]!==f||t[52]!==re?(ie=(0,$.jsx)(Sn,{threadId:f,children:re}),t[51]=f,t[52]=re,t[53]=ie):ie=t[53],ie}function wa(){}var Ta=`VS Code`,Ea={"VS Code":`vscode`,Cursor:`cursor`,Windsurf:`windsurf`,Xcode:`xcode`,"Android Studio":`android-studio`,Kiro:`kiro`,Terminal:`terminal`};function Da({projectId:e,threadId:t,openWith:n}){let[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)([]),[s,c]=(0,Z.useState)(n??Ta),[l,u]=(0,Z.useState)(!0);(0,Z.useEffect)(()=>{(async()=>{try{let e=await Tt();o(e),!s&&e.length>0&&c(e[0])}catch(e){console.error(`Failed to fetch available programs:`,e),o([Ta])}finally{u(!1)}})()},[]),(0,Z.useEffect)(()=>{n&&a.includes(n)&&c(n)},[n,a,c]);let d=async n=>{try{i(!0),c(n),await Me(e,n),t?await Ee(t,n):await _e(e,n),X({title:`Success`,description:`Opened project in ${n}`})}catch(e){console.error(`Failed to open project in ${n}:`,e);let t=`Failed to open project in ${n}`;if(e instanceof Error){let n=e;t=n.details?n.details:e.message}X({title:`Error`,description:t,variant:`destructive`})}finally{i(!1)}};return l?(0,$.jsx)(U,{variant:`outline`,size:`sm`,className:`h-8`,disabled:!0,children:(0,$.jsx)(`div`,{className:`h-4 w-4 animate-pulse bg-muted rounded`})}):(0,$.jsxs)(`div`,{className:`flex items-center gap-0`,children:[(0,$.jsx)(U,{variant:`outline`,size:`sm`,className:`h-8 rounded-r-none border-r-0 border-transparent`,disabled:r,onClick:async()=>{await d(s)},title:`Open in ${s}`,children:(0,$.jsx)(`img`,{src:`/ide/${Ea[s]||Ea[Ta]}.svg`,alt:s,className:`h-4 w-4`})}),(0,$.jsxs)(kn,{children:[(0,$.jsx)(Mn,{asChild:!0,children:(0,$.jsx)(U,{variant:`outline`,size:`sm`,className:`h-8 w-8 rounded-l-none px-1 border-transparent`,disabled:r,children:(0,$.jsx)(xt,{className:`h-3.5 w-3.5`})})}),(0,$.jsx)(Cn,{align:`end`,children:a.map(e=>(0,$.jsxs)(_n,{onClick:()=>d(e),disabled:r,className:`flex items-center gap-2`,children:[(0,$.jsx)(`img`,{src:`/ide/${Ea[e]||Ea[Ta]}.svg`,alt:e,className:`h-4 w-4`}),e]},e))})]})]})}function Oa(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 ka(e,t){return t?(0,$.jsx)(ce,{className:`h-3.5 w-3.5 animate-spin`}):e.status===`Behind`&&!e.hasChanges&&!e.hasUnpushedCommits?(0,$.jsx)(Ye,{className:`h-3.5 w-3.5`}):e.hasChanges?(0,$.jsx)(m,{className:`h-3.5 w-3.5`}):e.prExists&&e.prState===`OPEN`&&!e.hasChanges&&!e.hasUnpushedCommits?(0,$.jsx)(g,{className:`h-3.5 w-3.5`}):(0,$.jsx)(R,{className:`h-3.5 w-3.5`})}function Aa(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 ja(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 Ma(e){return e.hasChanges||e.status===`Behind`&&!e.hasChanges&&!e.hasUnpushedCommits||e.commitsAheadOfDefault&&!e.prExists&&!e.hasChanges}function Na(e){let t=(0,Q.c)(79),{branchStatus:n,remoteUrl:r,hasRemoteBranch:i,hasUnpushedCommits:a,canCreateRepo:o,repoUrl:s,isRefreshing:c,isBrandState:l,gitUser:u,isDirectCommitMode:d,isLoading:f,isLoadingHistory:p,onFetch:m,onPull:h,onPush:_,onOpenHistory:v,onCreatePR:y,onCreateRepo:b,onViewInGitHub:x}=e,S=`h-8 w-8 rounded-l-none px-1 border-transparent${l?` bg-brand text-brand-foreground hover:bg-brand/90 hover:text-brand-foreground`:``}`,C;t[0]===c?C=t[1]:(C=c?(0,$.jsx)(ce,{className:`h-3.5 w-3.5 animate-spin`}):(0,$.jsx)(xt,{className:`h-3.5 w-3.5`}),t[0]=c,t[1]=C);let w;t[2]!==f||t[3]!==S||t[4]!==C?(w=(0,$.jsx)(Mn,{asChild:!0,children:(0,$.jsx)(U,{variant:`outline`,size:`sm`,className:S,disabled:f,children:C})}),t[2]=f,t[3]=S,t[4]=C,t[5]=w):w=t[5];let T;t[6]!==n||t[7]!==r?(T=n===`Behind`&&(0,$.jsxs)(`div`,{className:`px-2 py-1 text-xs text-amber-600`,children:[`Branch is behind `,r?`origin`:`remote`]}),t[6]=n,t[7]=r,t[8]=T):T=t[8];let D;t[9]===u?D=t[10]:(D=u&&(0,$.jsxs)(`div`,{className:`px-2 py-1 text-xs text-muted-foreground`,children:[(0,$.jsx)(`span`,{className:`font-medium`,children:`User:`}),` `,u]}),t[9]=u,t[10]=D);let O;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,$.jsx)(Dn,{}),t[11]=O):O=t[11];let k;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,$.jsx)(E,{className:`h-3.5 w-3.5 mr-2`}),t[12]=k):k=t[12];let A;t[13]!==f||t[14]!==m?(A=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(_n,{onClick:m,disabled:f,children:[k,`Fetch`]})}),t[13]=f,t[14]=m,t[15]=A):A=t[15];let j;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,$.jsx)(q,{side:`right`,children:`Download latest information from remote without merging changes`}),t[16]=j):j=t[16];let M;t[17]===A?M=t[18]:(M=(0,$.jsx)(hn,{children:(0,$.jsxs)(J,{children:[A,j]})}),t[17]=A,t[18]=M);let N;t[19]!==i||t[20]!==f||t[21]!==h?(N=()=>{i&&!f&&h()},t[19]=i,t[20]=f,t[21]=h,t[22]=N):N=t[22];let P=!i||f?`opacity-50 cursor-not-allowed`:``,I;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,$.jsx)(Ye,{className:`h-3.5 w-3.5 mr-2`}),t[23]=I):I=t[23];let L;t[24]!==N||t[25]!==P?(L=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(_n,{onClick:N,className:P,children:[I,`Pull`]})}),t[24]=N,t[25]=P,t[26]=L):L=t[26];let ee=i?`Pull latest changes from remote`:`No remote branch to pull from`,z;t[27]===ee?z=t[28]:(z=(0,$.jsx)(q,{side:`right`,children:ee}),t[27]=ee,t[28]=z);let V;t[29]!==L||t[30]!==z?(V=(0,$.jsx)(hn,{children:(0,$.jsxs)(J,{children:[L,z]})}),t[29]=L,t[30]=z,t[31]=V):V=t[31];let te;t[32]!==i||t[33]!==f||t[34]!==_?(te=!i&&(0,$.jsx)(hn,{children:(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(_n,{onClick:_,disabled:f,children:[(0,$.jsx)(ae,{className:`h-3.5 w-3.5 mr-2`}),`Push Branch to Remote`]})}),(0,$.jsx)(q,{side:`right`,children:`Create remote branch and push local commits`})]})}),t[32]=i,t[33]=f,t[34]=_,t[35]=te):te=t[35];let H;t[36]!==a||t[37]!==f||t[38]!==_?(H=()=>{a&&!f&&_()},t[36]=a,t[37]=f,t[38]=_,t[39]=H):H=t[39];let ne=!a||f?`opacity-50 cursor-not-allowed`:``,re;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(re=(0,$.jsx)(ae,{className:`h-3.5 w-3.5 mr-2`}),t[40]=re):re=t[40];let ie;t[41]!==H||t[42]!==ne?(ie=(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(_n,{onClick:H,className:ne,children:[re,`Push Commits`]})}),t[41]=H,t[42]=ne,t[43]=ie):ie=t[43];let oe=a?f?`Push in progress...`:`Push your uncommitted commits to the remote branch`:`No commits to push - your branch is up to date with remote`,se;t[44]===oe?se=t[45]:(se=(0,$.jsx)(q,{side:`right`,children:oe}),t[44]=oe,t[45]=se);let le;t[46]!==ie||t[47]!==se?(le=(0,$.jsx)(hn,{children:(0,$.jsxs)(J,{children:[ie,se]})}),t[46]=ie,t[47]=se,t[48]=le):le=t[48];let ue=f||p,de;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(de=(0,$.jsx)(B,{className:`h-3.5 w-3.5 mr-2`}),t[49]=de):de=t[49];let W;t[50]!==v||t[51]!==ue?(W=(0,$.jsxs)(_n,{onClick:v,disabled:ue,children:[de,`History`]}),t[50]=v,t[51]=ue,t[52]=W):W=t[52];let G;t[53]!==d||t[54]!==f||t[55]!==y?(G=!d&&(0,$.jsxs)(_n,{onClick:y,disabled:f,children:[(0,$.jsx)(R,{className:`h-3.5 w-3.5 mr-2`}),`Create Pull Request`]}),t[53]=d,t[54]=f,t[55]=y,t[56]=G):G=t[56];let fe;t[57]!==o||t[58]!==f||t[59]!==b?(fe=o&&(0,$.jsxs)(_n,{onClick:b,disabled:f,children:[(0,$.jsx)(F,{className:`h-3.5 w-3.5 mr-2`}),`Create Repo`]}),t[57]=o,t[58]=f,t[59]=b,t[60]=fe):fe=t[60];let pe;t[61]!==f||t[62]!==x||t[63]!==s?(pe=s&&(0,$.jsxs)(_n,{onClick:x,disabled:f,children:[(0,$.jsx)(g,{className:`h-3.5 w-3.5 mr-2`}),`View in GitHub`]}),t[61]=f,t[62]=x,t[63]=s,t[64]=pe):pe=t[64];let me;t[65]!==M||t[66]!==V||t[67]!==te||t[68]!==le||t[69]!==W||t[70]!==G||t[71]!==fe||t[72]!==pe||t[73]!==T||t[74]!==D?(me=(0,$.jsxs)(Cn,{align:`end`,children:[T,D,O,M,V,te,le,W,G,fe,pe]}),t[65]=M,t[66]=V,t[67]=te,t[68]=le,t[69]=W,t[70]=G,t[71]=fe,t[72]=pe,t[73]=T,t[74]=D,t[75]=me):me=t[75];let he;return t[76]!==w||t[77]!==me?(he=(0,$.jsxs)(kn,{children:[w,me]}),t[76]=w,t[77]=me,t[78]=he):he=t[78],he}function Pa(){return{autoGenerateCommitMessage:He(),autoGeneratePRInfo:dt(),privateRepositoryDefault:Je()}}function Fa(e){e.autoGenerateCommitMessage!==void 0&&Ke(e.autoGenerateCommitMessage),e.autoGeneratePRInfo!==void 0&&De(e.autoGeneratePRInfo),e.privateRepositoryDefault!==void 0&&Dt(e.privateRepositoryDefault)}function Ia(e){return e?!0:(X({title:`Error`,description:`No thread selected`,variant:`destructive`}),!1)}function La(e){let t=(0,Q.c)(57),{open:n,onOpenChange:r,commitMessage:i,onCommitMessageChange:a,autoGenerateCommitMessage:o,onAutoGenerateChange:s,isGeneratingMessage:c,isLoading:l,onGenerateMessage:u,onCommit:d,currentBranch:f}=e,p;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(gt,{children:`Commit Changes`}),t[0]=p):p=t[0];let m;t[1]===f?m=t[2]:(m=(0,$.jsxs)(D,{children:[p,(0,$.jsxs)(me,{children:[`Enter a commit message for your changes on branch `,f]})]}),t[1]=f,t[2]=m);let g;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(h,{htmlFor:`commit-message`,children:`Commit Message`}),t[3]=g):g=t[3];let y;t[4]===a?y=t[5]:(y=e=>a(e.target.value),t[4]=a,t[5]=y);let b;t[6]!==i||t[7]!==y?(b=(0,$.jsx)(mn,{id:`commit-message`,placeholder:`Enter commit message...`,value:i,onChange:y,rows:4,className:`pr-10`}),t[6]=i,t[7]=y,t[8]=b):b=t[8];let x=c||l,S;t[9]===c?S=t[10]:(S=c?(0,$.jsx)(ce,{className:`h-3.5 w-3.5 animate-spin`}):(0,$.jsx)(be,{className:`h-3.5 w-3.5`}),t[9]=c,t[10]=S);let C;t[11]!==u||t[12]!==x||t[13]!==S?(C=(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:u,disabled:x,children:S})}),t[11]=u,t[12]=x,t[13]=S,t[14]=C):C=t[14];let w=c?`Generating commit message...`:`Generate commit message with AI`,T;t[15]===w?T=t[16]:(T=(0,$.jsx)(q,{children:w}),t[15]=w,t[16]=T);let E;t[17]!==T||t[18]!==C?(E=(0,$.jsx)(hn,{children:(0,$.jsxs)(J,{children:[C,T]})}),t[17]=T,t[18]=C,t[19]=E):E=t[19];let O;t[20]!==E||t[21]!==b?(O=(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[g,(0,$.jsxs)(`div`,{className:`relative`,children:[b,E]})]}),t[20]=E,t[21]=b,t[22]=O):O=t[22];let k;t[23]===s?k=t[24]:(k=e=>s(e===!0),t[23]=s,t[24]=k);let A;t[25]!==o||t[26]!==k?(A=(0,$.jsx)(Kn,{id:`auto-generate`,checked:o,onCheckedChange:k}),t[25]=o,t[26]=k,t[27]=A):A=t[27];let j;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,$.jsx)(h,{htmlFor:`auto-generate`,className:`text-sm font-normal`,children:`Auto generate commit messages`}),t[28]=j):j=t[28];let M;t[29]===A?M=t[30]:(M=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[A,j]}),t[29]=A,t[30]=M);let N;t[31]!==O||t[32]!==M?(N=(0,$.jsxs)(`div`,{className:`grid gap-4 py-4`,children:[O,M]}),t[31]=O,t[32]=M,t[33]=N):N=t[33];let P;t[34]===r?P=t[35]:(P=()=>r(!1),t[34]=r,t[35]=P);let F;t[36]!==l||t[37]!==P?(F=(0,$.jsx)(U,{variant:`outline`,onClick:P,disabled:l,children:`Cancel`}),t[36]=l,t[37]=P,t[38]=F):F=t[38];let I;t[39]!==i||t[40]!==l?(I=l||!i.trim(),t[39]=i,t[40]=l,t[41]=I):I=t[41];let L=l?`Committing...`:`Commit`,R;t[42]!==d||t[43]!==I||t[44]!==L?(R=(0,$.jsx)(U,{onClick:d,disabled:I,children:L}),t[42]=d,t[43]=I,t[44]=L,t[45]=R):R=t[45];let ee;t[46]!==F||t[47]!==R?(ee=(0,$.jsxs)(_,{children:[F,R]}),t[46]=F,t[47]=R,t[48]=ee):ee=t[48];let z;t[49]!==N||t[50]!==m||t[51]!==ee?(z=(0,$.jsxs)(W,{children:[m,N,ee]}),t[49]=N,t[50]=m,t[51]=ee,t[52]=z):z=t[52];let B;return t[53]!==r||t[54]!==n||t[55]!==z?(B=(0,$.jsx)(v,{open:n,onOpenChange:r,children:z}),t[53]=r,t[54]=n,t[55]=z,t[56]=B):B=t[56],B}function Ra(e){let t=(0,Q.c)(62),{open:n,onOpenChange:r,prTitle:i,onPrTitleChange:a,prDescription:o,onPrDescriptionChange:s,isGeneratingPRInfo:c,isLoading:l,onGeneratePRInfo:u,onCreatePR:d,currentBranch:f,autoGeneratePRInfo:p,onAutoGeneratePRInfoChange:m}=e,g;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(gt,{children:`Create Pull Request`}),t[0]=g):g=t[0];let y;t[1]===f?y=t[2]:(y=(0,$.jsxs)(D,{children:[g,(0,$.jsxs)(me,{children:[`Create a pull request for branch `,f]})]}),t[1]=f,t[2]=y);let b;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(h,{htmlFor:`pr-title`,children:`Title (optional)`}),t[3]=b):b=t[3];let x=f||`Enter PR title...`,S;t[4]===a?S=t[5]:(S=e=>a(e.target.value),t[4]=a,t[5]=S);let C;t[6]!==i||t[7]!==x||t[8]!==S?(C=(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[b,(0,$.jsx)(j,{id:`pr-title`,placeholder:x,value:i,onChange:S})]}),t[6]=i,t[7]=x,t[8]=S,t[9]=C):C=t[9];let w;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(h,{htmlFor:`pr-description`,children:`Description (optional)`}),t[10]=w):w=t[10];let T;t[11]===s?T=t[12]:(T=e=>s(e.target.value),t[11]=s,t[12]=T);let E;t[13]!==o||t[14]!==T?(E=(0,$.jsx)(mn,{id:`pr-description`,placeholder:`Enter PR description...`,value:o,onChange:T,rows:4,className:`pr-10`}),t[13]=o,t[14]=T,t[15]=E):E=t[15];let O=c||l,k;t[16]===c?k=t[17]:(k=c?(0,$.jsx)(ce,{className:`h-3.5 w-3.5 animate-spin`}):(0,$.jsx)(be,{className:`h-3.5 w-3.5`}),t[16]=c,t[17]=k);let A;t[18]!==u||t[19]!==O||t[20]!==k?(A=(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:u,disabled:O,children:k})}),t[18]=u,t[19]=O,t[20]=k,t[21]=A):A=t[21];let M=c?`Generating PR description...`:`Generate PR title and description with AI`,N;t[22]===M?N=t[23]:(N=(0,$.jsx)(q,{children:M}),t[22]=M,t[23]=N);let P;t[24]!==A||t[25]!==N?(P=(0,$.jsx)(hn,{children:(0,$.jsxs)(J,{children:[A,N]})}),t[24]=A,t[25]=N,t[26]=P):P=t[26];let F;t[27]!==P||t[28]!==E?(F=(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[w,(0,$.jsxs)(`div`,{className:`relative`,children:[E,P]})]}),t[27]=P,t[28]=E,t[29]=F):F=t[29];let I;t[30]===m?I=t[31]:(I=e=>m(e===!0),t[30]=m,t[31]=I);let L;t[32]!==p||t[33]!==I?(L=(0,$.jsx)(Kn,{id:`auto-generate-pr`,checked:p,onCheckedChange:I}),t[32]=p,t[33]=I,t[34]=L):L=t[34];let R;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,$.jsx)(h,{htmlFor:`auto-generate-pr`,className:`text-sm font-normal`,children:`Auto generate PR title and description`}),t[35]=R):R=t[35];let ee;t[36]===L?ee=t[37]:(ee=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[L,R]}),t[36]=L,t[37]=ee);let z;t[38]!==F||t[39]!==ee||t[40]!==C?(z=(0,$.jsxs)(`div`,{className:`grid gap-4 py-4`,children:[C,F,ee]}),t[38]=F,t[39]=ee,t[40]=C,t[41]=z):z=t[41];let B;t[42]===r?B=t[43]:(B=()=>r(!1),t[42]=r,t[43]=B);let V;t[44]!==l||t[45]!==B?(V=(0,$.jsx)(U,{variant:`outline`,onClick:B,disabled:l,children:`Cancel`}),t[44]=l,t[45]=B,t[46]=V):V=t[46];let te=l?`Creating...`:`Create PR`,H;t[47]!==l||t[48]!==d||t[49]!==te?(H=(0,$.jsx)(U,{onClick:d,disabled:l,children:te}),t[47]=l,t[48]=d,t[49]=te,t[50]=H):H=t[50];let ne;t[51]!==V||t[52]!==H?(ne=(0,$.jsxs)(_,{children:[V,H]}),t[51]=V,t[52]=H,t[53]=ne):ne=t[53];let re;t[54]!==y||t[55]!==z||t[56]!==ne?(re=(0,$.jsxs)(W,{children:[y,z,ne]}),t[54]=y,t[55]=z,t[56]=ne,t[57]=re):re=t[57];let ie;return t[58]!==r||t[59]!==n||t[60]!==re?(ie=(0,$.jsx)(v,{open:n,onOpenChange:r,children:re}),t[58]=r,t[59]=n,t[60]=re,t[61]=ie):ie=t[61],ie}function za(e){let t=(0,Q.c)(48),{open:n,onOpenChange:r,repoName:i,onRepoNameChange:a,repoDescription:o,onRepoDescriptionChange:s,isPrivateRepo:c,onPrivateRepoChange:l,isLoading:u,onCreateRepo:d}=e,f;t[0]!==r||t[1]!==s||t[2]!==a?(f=e=>{e||(a(``),s(``)),r(e)},t[0]=r,t[1]=s,t[2]=a,t[3]=f):f=t[3];let p;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsxs)(D,{children:[(0,$.jsx)(gt,{children:`Create GitHub Repository`}),(0,$.jsx)(me,{children:`Create a new GitHub repository and push your local repository`})]}),t[4]=p):p=t[4];let m;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(h,{htmlFor:`repo-name`,children:`Repository Name (optional)`}),t[5]=m):m=t[5];let g;t[6]===a?g=t[7]:(g=e=>a(e.target.value),t[6]=a,t[7]=g);let y;t[8]!==i||t[9]!==g?(y=(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[m,(0,$.jsx)(j,{id:`repo-name`,placeholder:`Leave empty to use current folder name`,value:i,onChange:g})]}),t[8]=i,t[9]=g,t[10]=y):y=t[10];let b;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(h,{htmlFor:`repo-description`,children:`Description (optional)`}),t[11]=b):b=t[11];let x;t[12]===s?x=t[13]:(x=e=>s(e.target.value),t[12]=s,t[13]=x);let S;t[14]!==o||t[15]!==x?(S=(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[b,(0,$.jsx)(mn,{id:`repo-description`,placeholder:`Enter repository description...`,value:o,onChange:x,rows:3})]}),t[14]=o,t[15]=x,t[16]=S):S=t[16];let C;t[17]===l?C=t[18]:(C=e=>l(e===!0),t[17]=l,t[18]=C);let w;t[19]!==c||t[20]!==C?(w=(0,$.jsx)(Kn,{id:`repo-private`,checked:c,onCheckedChange:C}),t[19]=c,t[20]=C,t[21]=w):w=t[21];let T;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(h,{htmlFor:`repo-private`,className:`text-sm font-normal`,children:`Private repository`}),t[22]=T):T=t[22];let E;t[23]===w?E=t[24]:(E=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[w,T]}),t[23]=w,t[24]=E);let O;t[25]!==E||t[26]!==y||t[27]!==S?(O=(0,$.jsxs)(`div`,{className:`grid gap-4 py-4`,children:[y,S,E]}),t[25]=E,t[26]=y,t[27]=S,t[28]=O):O=t[28];let k;t[29]===r?k=t[30]:(k=()=>r(!1),t[29]=r,t[30]=k);let A;t[31]!==u||t[32]!==k?(A=(0,$.jsx)(U,{variant:`outline`,onClick:k,disabled:u,children:`Cancel`}),t[31]=u,t[32]=k,t[33]=A):A=t[33];let M=u?`Creating...`:`Create & Push`,N;t[34]!==u||t[35]!==d||t[36]!==M?(N=(0,$.jsx)(U,{onClick:d,disabled:u,children:M}),t[34]=u,t[35]=d,t[36]=M,t[37]=N):N=t[37];let P;t[38]!==A||t[39]!==N?(P=(0,$.jsxs)(_,{children:[A,N]}),t[38]=A,t[39]=N,t[40]=P):P=t[40];let F;t[41]!==O||t[42]!==P?(F=(0,$.jsxs)(W,{children:[p,O,P]}),t[41]=O,t[42]=P,t[43]=F):F=t[43];let I;return t[44]!==n||t[45]!==f||t[46]!==F?(I=(0,$.jsx)(v,{open:n,onOpenChange:f,children:F}),t[44]=n,t[45]=f,t[46]=F,t[47]=I):I=t[47],I}function Ba(e){let t=(0,Q.c)(28),{open:n,onOpenChange:r,commits:i,displayedCommits:a,isLoadingMore:o,onScroll:s,currentBranch:c}=e,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(gt,{children:`Commit History`}),t[0]=l):l=t[0];let u;t[1]===c?u=t[2]:(u=(0,$.jsxs)(D,{children:[l,(0,$.jsxs)(me,{children:[`Recent commits on branch `,c]})]}),t[1]=c,t[2]=u);let d;t[3]===a?d=t[4]:(d=a.length>0?a.map(Va):(0,$.jsx)(`p`,{className:`text-sm text-slate-500 text-center py-8`,children:`No commits found`}),t[3]=a,t[4]=d);let f;t[5]===o?f=t[6]:(f=o&&(0,$.jsx)(`div`,{className:`p-3 text-center`,children:(0,$.jsx)(ce,{className:`h-4 w-4 animate-spin inline`})}),t[5]=o,t[6]=f);let p;t[7]!==i.length||t[8]!==a.length||t[9]!==o?(p=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]=p):p=t[10];let m;t[11]!==d||t[12]!==f||t[13]!==p?(m=(0,$.jsxs)(`div`,{className:`divide-y`,children:[d,f,p]}),t[11]=d,t[12]=f,t[13]=p,t[14]=m):m=t[14];let h;t[15]!==s||t[16]!==m?(h=(0,$.jsx)(`div`,{className:`flex-1 overflow-y-auto border rounded-lg`,onScroll:s,children:m}),t[15]=s,t[16]=m,t[17]=h):h=t[17];let g;t[18]===r?g=t[19]:(g=(0,$.jsx)(_,{children:(0,$.jsx)(U,{onClick:()=>r(!1),children:`Close`})}),t[18]=r,t[19]=g);let y;t[20]!==u||t[21]!==h||t[22]!==g?(y=(0,$.jsxs)(W,{className:`max-w-2xl max-h-[80vh] flex flex-col`,children:[u,h,g]}),t[20]=u,t[21]=h,t[22]=g,t[23]=y):y=t[23];let b;return t[24]!==r||t[25]!==n||t[26]!==y?(b=(0,$.jsx)(v,{open:n,onOpenChange:r,children:y}),t[24]=r,t[25]=n,t[26]=y,t[27]=b):b=t[27],b}function Va(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 Ha(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)(D,{children:[(0,$.jsx)(gt,{children:`Push Branch First`}),(0,$.jsx)(me,{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 l=i?`Pushing...`:`Push & Create PR`,u;t[4]!==i||t[5]!==a||t[6]!==l?(u=(0,$.jsx)(U,{onClick:a,disabled:i,children:l}),t[4]=i,t[5]=a,t[6]=l,t[7]=u):u=t[7];let d;t[8]!==c||t[9]!==u?(d=(0,$.jsxs)(W,{children:[s,(0,$.jsxs)(_,{children:[c,u]})]}),t[8]=c,t[9]=u,t[10]=d):d=t[10];let f;return t[11]!==r||t[12]!==n||t[13]!==d?(f=(0,$.jsx)(v,{open:n,onOpenChange:r,children:d}),t[11]=r,t[12]=n,t[13]=d,t[14]=f):f=t[14],f}function Ua(e){let t=(0,Q.c)(27),{open:n,onOpenChange:r,onCommitFirst:i,onStashAndPull:a,onCancel:o,isLoading:s}=e,c=s===void 0?!1:s,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsxs)(D,{children:[(0,$.jsxs)(gt,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Lt,{className:`h-5 w-5 text-amber-500`}),`Uncommitted Changes Detected`]}),(0,$.jsx)(me,{children:`You have uncommitted changes. You need to handle them before pulling from the remote branch.`})]}),t[0]=l):l=t[0];let u;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`Choose how you want to proceed:`}),t[1]=u):u=t[1];let d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(m,{className:`h-4 w-4 mr-2`}),t[2]=d):d=t[2];let f;t[3]!==c||t[4]!==i?(f=(0,$.jsxs)(U,{onClick:i,disabled:c,className:`w-full justify-start`,variant:`outline`,children:[d,`Commit changes first, then pull`]}),t[3]=c,t[4]=i,t[5]=f):f=t[5];let p;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(We,{className:`h-4 w-4 mr-2`}),t[6]=p):p=t[6];let h;t[7]!==c||t[8]!==a?(h=(0,$.jsxs)(U,{onClick:a,disabled:c,className:`w-full justify-start`,variant:`outline`,children:[p,`Stash changes → Pull → Restore changes`]}),t[7]=c,t[8]=a,t[9]=h):h=t[9];let g;t[10]!==f||t[11]!==h?(g=(0,$.jsxs)(`div`,{className:`space-y-2`,children:[f,h]}),t[10]=f,t[11]=h,t[12]=g):g=t[12];let y;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(`strong`,{children:`Commit first:`}),t[13]=y):y=t[13];let b;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsxs)(`div`,{className:`text-xs text-muted-foreground mt-4`,children:[y,` 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]=b):b=t[14];let x;t[15]===g?x=t[16]:(x=(0,$.jsx)(`div`,{className:`py-4`,children:(0,$.jsxs)(`div`,{className:`space-y-3`,children:[u,g,b]})}),t[15]=g,t[16]=x);let S;t[17]!==c||t[18]!==o?(S=(0,$.jsx)(_,{children:(0,$.jsx)(U,{variant:`ghost`,onClick:o,disabled:c,children:`Cancel`})}),t[17]=c,t[18]=o,t[19]=S):S=t[19];let C;t[20]!==x||t[21]!==S?(C=(0,$.jsxs)(W,{className:`sm:max-w-[425px]`,children:[l,x,S]}),t[20]=x,t[21]=S,t[22]=C):C=t[22];let w;return t[23]!==r||t[24]!==n||t[25]!==C?(w=(0,$.jsx)(v,{open:n,onOpenChange:r,children:C}),t[23]=r,t[24]=n,t[25]=C,t[26]=w):w=t[26],w}function Wa(e){let t=(0,Q.c)(19),{open:n,onOpenChange:r,onNewBranch:i,onJustOpen:a,isLoading:o,defaultBranch:s}=e,c=o===void 0?!1:o,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(gt,{children:`Pull Request Merged`}),t[0]=l):l=t[0];let u=s?` from ${s}`:``,d;t[1]===u?d=t[2]:(d=(0,$.jsxs)(D,{children:[l,(0,$.jsxs)(me,{children:[`As the pull request has been merged a new branch will be created`,u,`.`]})]}),t[1]=u,t[2]=d);let f;t[3]!==c||t[4]!==a?(f=(0,$.jsx)(U,{variant:`ghost`,onClick:a,disabled:c,children:`Just Open`}),t[3]=c,t[4]=a,t[5]=f):f=t[5];let p;t[6]!==c||t[7]!==i?(p=(0,$.jsx)(U,{onClick:i,disabled:c,children:`New Branch`}),t[6]=c,t[7]=i,t[8]=p):p=t[8];let m;t[9]!==f||t[10]!==p?(m=(0,$.jsxs)(_,{children:[f,p]}),t[9]=f,t[10]=p,t[11]=m):m=t[11];let h;t[12]!==d||t[13]!==m?(h=(0,$.jsxs)(W,{children:[d,m]}),t[12]=d,t[13]=m,t[14]=h):h=t[14];let g;return t[15]!==r||t[16]!==n||t[17]!==h?(g=(0,$.jsx)(v,{open:n,onOpenChange:r,children:h}),t[15]=r,t[16]=n,t[17]=h,t[18]=g):g=t[18],g}function Ga(e){let t=e.split(`/`);return t.length>=2?{provider:t[0],model:t.slice(1).join(`/`)}:{provider:void 0,model:e}}function Ka(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}:Ga(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 ve(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 Se(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 qa({projectId:e,threadId:t}){let{state:n,dispatch:r}=an(),[i,a]=(0,Z.useState)(!1),[o,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(``),[h,g]=(0,Z.useState)(``),[_,v]=(0,Z.useState)(``),[y,x]=(0,Z.useState)(!1),[C,w]=(0,Z.useState)(null),E=(0,Z.useRef)(!1),D=(0,Z.useRef)(!1),[k,A]=(0,Z.useState)(!1),[j,M]=(0,Z.useState)([]),[P,F]=(0,Z.useState)(!1),[I,L]=(0,Z.useState)([]),[R,ee]=(0,Z.useState)(!1),[B,V]=(0,Z.useState)(!1),[te,H]=(0,Z.useState)(``),[ne,re]=(0,Z.useState)(``),[ie,ae]=(0,Z.useState)(``),[se,ce]=(0,Z.useState)(!1),[le,ue]=(0,Z.useState)(!1),[de,W]=(0,Z.useState)(!1),G=En(t),fe=Ka(t,e,n.projectModelSelections);async function me(){O();let e=await s();r({type:K.SetProjects,projects:e.projects})}let[ge,_e]=(0,Z.useState)(()=>Pa()),ve=n.projects.find(t=>t.projectId===e),ye=ve?.commitMethod===lt.Direct;(0,Z.useEffect)(()=>{function e(){document.visibilityState===`visible`&&G.fetchUnifiedStatus(!0)}return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[G.fetchUnifiedStatus]),(0,Z.useEffect)(()=>{B&&ve?.name&&!te&&H(ve.name)},[B,ve?.name,te]),(0,Z.useEffect)(()=>{Fa(ge)},[ge]),(0,Z.useEffect)(()=>{let e=!0;return at().then(t=>{e&&ae(t)}).catch(()=>{}),()=>{e=!1}},[]),(0,Z.useEffect)(()=>{if(!l){D.current=!1;return}if(l&&ge.autoGenerateCommitMessage&&!p.trim()&&t&&!D.current){D.current=!0;async function e(){let e=await fe.generateCommitMessageWithAI();e&&m(e)}e()}},[l,ge.autoGenerateCommitMessage,t,fe,p]),(0,Z.useEffect)(()=>{if(!d){E.current=!1;return}if(console.log(`[pr-auto-gen] useEffect triggered`,{isPRDialogOpen:d,autoGeneratePRInfo:ge.autoGeneratePRInfo,prTitleEmpty:!h.trim(),prDescriptionEmpty:!_.trim(),threadId:t,hasThreadId:!!t,generationAlreadyStarted:E.current}),d&&ge.autoGeneratePRInfo&&!h.trim()&&!_.trim()&&t&&!E.current){console.log(`[pr-auto-gen] Starting auto-generation...`),E.current=!0;async function e(){let e=await fe.generatePRInfoWithAI();e&&(console.log(`[pr-auto-gen] Setting PR info:`,e.title.substring(0,50)),g(e.title),v(e.description))}e()}else console.log(`[pr-auto-gen] Skipping auto-generation - conditions not met`)},[d,ge.autoGeneratePRInfo,t,fe,h,_]),(0,Z.useEffect)(()=>{console.log(`Unified status changed:`,{prExists:G.prExists,prState:G.prState,threadId:t}),G.prExists&&G.prState===`MERGED`&&(console.log(`Merged PR detected, opening dialog`),W(!0))},[G.prExists,G.prState,t]),(0,Z.useEffect)(()=>{!n.isStreaming&&n.completedThreadIds.includes(n.selectedThreadId??``)&&(G.fetchUnifiedStatus(!0),r({type:K.ClearThreadCompleted,threadId:n.selectedThreadId??``}))},[n.isStreaming,n.completedThreadIds,n.selectedThreadId,G,r]);async function be(){if(p.trim()&&Ia(t))try{a(!0),await S(t,p),m(``),u(!1),await G.fetchUnifiedStatus(!0),me(),X({title:`Changes committed successfully`,description:`Your changes have been committed to '${G.currentBranch}'.`}),le&&(ue(!1),await Ee())}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 xe(){if(G.status===`Behind`&&!G.hasChanges&&!G.hasUnpushedCommits){await Ae();return}if(G.hasChanges){u(!0);return}if(G.prExists&&G.prState===`OPEN`&&!G.hasChanges&&!G.hasUnpushedCommits){G.prUrl&&await T(G.prUrl);return}if(G.commitsAheadOfDefault&&!G.prExists&&!G.hasChanges){f(!0);return}if(G.hasUnpushedCommits&&G.prExists){await we();return}}async function Se(){let e=await fe.generateCommitMessageWithAI();e&&m(e)}async function Ce(){if(Ia(t))try{a(!0),await Rt(t),await G.fetchUnifiedStatus()}catch(e){console.error(`Failed to fetch:`,e)}finally{a(!1)}}async function we(){if(Ia(t))try{a(!0),await b(t),await G.fetchUnifiedStatus(!0),me(),G.hasRemoteBranch?X({title:`Branch pushed successfully`,description:`Your branch '${G.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 Te(){if(Ia(t)){if(G.hasChanges){ce(!0);return}await Ee()}}async function Ee(){try{a(!0),await pe(t),await G.fetchUnifiedStatus(!0),me(),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 De(){ce(!1),ue(!0),u(!0)}async function Oe(){ce(!1),await Ee()}async function ke(){if(t)try{a(!0);let e=await N(t,G.defaultBranch??void 0);O();let n=await s();r({type:K.SetProjects,projects:n.projects}),X({title:`New branch created`,description:`Created new branch "${e.branchName}" on current thread`}),W(!1),await G.fetchUnifiedStatus(!0),setTimeout(()=>void G.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 Ae(){if(!Ia(t)){console.log(`[sync] Thread operation validation failed`);return}try{console.log(`[sync] Starting branch sync for thread: ${t}`),console.log(`[sync] Current branch: ${G.currentBranch}, Default branch: ${G.defaultBranch}`),a(!0),console.log(`[sync] Calling gitSyncBranch API...`);let e=await he(t);console.log(`[sync] ✓ gitSyncBranch API call successful`),console.log(`[sync] Result:`,e),console.log(`[sync] Refreshing git status...`),await G.fetchUnifiedStatus(!0),me(),console.log(`[sync] ✓ Git status refreshed`),X({title:`Branch synced successfully`,description:`Your branch '${G.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 je(){if(Ia(t))try{a(!0),c(!0);let e=await oe(t,h,_);e.prUrl&&await T(e.prUrl),g(``),v(``),f(!1),await G.fetchUnifiedStatus(),me()}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`)?(f(!1),Pe({title:h,description:_})):X({title:`Create PR Failed`,description:t,variant:`destructive`})}finally{a(!1),c(!1)}}async function Me(){if(Ia(t))try{a(!0);let e=await z(t,te,ne,ge.privateRepositoryDefault);e.repoUrl&&setTimeout(()=>{T(e.repoUrl)},3e3),H(``),re(``),V(!1),await G.fetchUnifiedStatus(),me()}catch(e){console.error(`Failed to create repo:`,e)}finally{a(!1)}}async function Ne(){let e=await fe.generatePRInfoWithAI();e&&(g(e.title),v(e.description))}async function Pe(e){let n=e??C;if(!(!t||!n))try{a(!0),c(!0);try{await b(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 he(t),console.log(`[push-and-pr] ✓ Pull completed, retrying push...`),await b(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 oe(t,n.title,n.description);e.prUrl&&await T(e.prUrl),g(``),v(``),w(null),x(!1),await G.fetchUnifiedStatus(),me()}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),c(!1)}}async function Fe(){if(Ia(t))try{F(!0);let e=await St(t,100);M(e),L(e.slice(0,10)),A(!0)}catch(e){console.error(`Failed to fetch git history:`,e)}finally{F(!1)}}function Ie(){R||(ee(!0),setTimeout(()=>{let e=I.length+10;L(j.slice(0,e)),ee(!1)},300))}function Le(e){let t=e.currentTarget;t.scrollHeight-t.scrollTop-t.clientHeight<100&&I.length<j.length&&!R&&Ie()}let Re=Ma(G);function ze(){G.repoUrl&&T(G.repoUrl)}function Be(){x(!1),w(null)}function Ve(){W(!1),G.fetchUnifiedStatus(!0)}return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-0`,children:[(0,$.jsx)(hn,{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${Re?` bg-brand text-brand-foreground hover:bg-brand/90 hover:text-brand-foreground`:``}`,disabled:ja(G,i),onClick:xe,children:[ka(G,o),Oa(G,o)]})}),(0,$.jsx)(q,{children:Aa(G)})]})}),(0,$.jsx)(Na,{branchStatus:G.status,remoteUrl:G.remoteUrl,hasRemoteBranch:G.hasRemoteBranch,hasUnpushedCommits:G.hasUnpushedCommits,canCreateRepo:G.canCreateRepo,repoUrl:G.repoUrl,isRefreshing:G.isRefreshing,isBrandState:Re,gitUser:ie,isDirectCommitMode:ye,isLoading:i,isLoadingHistory:P,onFetch:()=>void Ce(),onPull:()=>void Te(),onPush:()=>void we(),onOpenHistory:()=>void Fe(),onCreatePR:()=>f(!0),onCreateRepo:()=>V(!0),onViewInGitHub:ze})]}),(0,$.jsx)(La,{open:l,onOpenChange:u,commitMessage:p,onCommitMessageChange:m,autoGenerateCommitMessage:ge.autoGenerateCommitMessage,onAutoGenerateChange:e=>_e(t=>({...t,autoGenerateCommitMessage:e})),isGeneratingMessage:fe.isGeneratingMessage,isLoading:i,onGenerateMessage:Se,onCommit:be,currentBranch:G.currentBranch}),(0,$.jsx)(Ra,{open:d,onOpenChange:f,prTitle:h,onPrTitleChange:g,prDescription:_,onPrDescriptionChange:v,isGeneratingPRInfo:fe.isGeneratingPRInfo,isLoading:i,onGeneratePRInfo:Ne,onCreatePR:je,currentBranch:G.currentBranch,autoGeneratePRInfo:ge.autoGeneratePRInfo,onAutoGeneratePRInfoChange:e=>_e(t=>({...t,autoGeneratePRInfo:e}))}),(0,$.jsx)(Ha,{open:y,onOpenChange:x,isLoading:i,onPushAndCreatePR:Pe,onCancel:Be}),(0,$.jsx)(za,{open:B,onOpenChange:V,repoName:te,onRepoNameChange:H,repoDescription:ne,onRepoDescriptionChange:re,isPrivateRepo:ge.privateRepositoryDefault,onPrivateRepoChange:e=>_e(t=>({...t,privateRepositoryDefault:e})),isLoading:i,onCreateRepo:Me}),(0,$.jsx)(Ba,{open:k,onOpenChange:A,commits:j,displayedCommits:I,isLoadingMore:R,onScroll:Le,currentBranch:G.currentBranch}),(0,$.jsx)(Ua,{open:se,onOpenChange:ce,onCommitFirst:De,onStashAndPull:Oe,onCancel:()=>ce(!1),isLoading:i}),(0,$.jsx)(Wa,{open:de,onOpenChange:W,onNewBranch:ke,onJustOpen:Ve,isLoading:i,defaultBranch:G.defaultBranch??void 0})]})}var Ja=`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 Ya({open:e,onOpenChange:t,projectId:n,commands:r,onRefresh:i}){let[a,o]=(0,Z.useState)(null),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)([]),[m,g]=(0,Z.useState)(0),[_,y]=(0,Z.useState)(!1),b=(0,Z.useRef)(null),x=(0,Z.useRef)(null),S=()=>{o({id:crypto.randomUUID(),name:``,icon:`Play`,commandLine:``}),u(!1),f([])},w=e=>{o({...e}),u(!1),f([])},T=async()=>{try{y(!0);let e=await ht(n);f(e.scripts),g(0),u(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{y(!1)}},E=e=>{o(t=>t?{...t,name:e.name,commandLine:e.commandLine,relativeFolder:e.relativePath||``}:null),u(!1),f([]),b.current?.focus()},O=e=>{l&&(e.key===`ArrowDown`?(e.preventDefault(),g(e=>e<d.length-1?e+1:e)):e.key===`ArrowUp`?(e.preventDefault(),g(e=>e>0?e-1:0)):e.key===`Enter`?(e.preventDefault(),m<d.length&&E(d[m])):e.key===`Escape`&&(e.preventDefault(),u(!1),f([])))};(0,Z.useEffect)(()=>{let e=e=>{x.current&&!x.current.contains(e.target)&&(u(!1),f([]))};return l&&document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[l]);let k=async e=>{try{await p(n,e),X({title:`Success`,description:`Command deleted`}),i()}catch{X({title:`Error`,description:`Failed to delete command`,variant:`destructive`})}};return(0,$.jsx)(v,{open:e,onOpenChange:t,children:(0,$.jsxs)(W,{className:`sm:max-w-[500px]`,children:[(0,$.jsxs)(D,{children:[(0,$.jsx)(gt,{children:`Project Commands`}),(0,$.jsx)(me,{children:`Manage custom commands for this project.`})]}),(0,$.jsx)(`div`,{className:`py-4 flex flex-col gap-4`,children:a?(0,$.jsxs)(`div`,{className:`p-4 border rounded-lg bg-muted/30 flex flex-col gap-4 animate-in slide-in-from-top-2`,children:[(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[(0,$.jsx)(h,{htmlFor:`name`,children:`Command Name`}),(0,$.jsx)(j,{id:`name`,value:a.name,onChange:e=>o({...a,name:e.target.value}),placeholder:`e.g. Run Tests`,autoComplete:`off`})]}),(0,$.jsxs)(`div`,{className:`grid gap-2 relative`,children:[(0,$.jsx)(h,{htmlFor:`commandLine`,children:`Command Line`}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(mn,{ref:b,id:`commandLine`,value:a.commandLine,onChange:e=>o({...a,commandLine:e.target.value}),onKeyDown:O,placeholder:`e.g. npm test`,className:`font-mono text-xs min-h-[100px] resize-none pr-10`}),(0,$.jsx)(hn,{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 T(),disabled:_,children:(0,$.jsx)(xt,{className:`h-4 w-4`})})}),(0,$.jsx)(q,{children:(0,$.jsx)(`p`,{children:`Discover package scripts`})})]})})]}),l&&(0,$.jsx)(`div`,{ref:x,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)(xt,{className:`h-3 w-3`}),`Available Scripts `,_&&`(loading...)`]}),d.length>0?(()=>{let e={};d.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===m;return n++,(0,$.jsxs)(`button`,{type:`button`,className:C(`flex w-full flex-col gap-1 rounded-lg mx-1 px-3 py-2 text-left transition-colors`,t?`bg-accent text-accent-foreground`:`text-popover-foreground hover:bg-accent/50`),onClick:()=>E(e),onMouseEnter:()=>g(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:_?`Loading scripts...`:`No package scripts found`})]})})]}),(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[(0,$.jsx)(h,{htmlFor:`relativeFolder`,children:`Relative Folder`}),(0,$.jsx)(j,{id:`relativeFolder`,value:a.relativeFolder??``,onChange:e=>o({...a,relativeFolder:e.target.value}),placeholder:`e.g. frontend, packages/api (optional)`,autoComplete:`off`}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Folder path relative to project root where the command will be executed. Leave empty to run from project root.`})]}),(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[(0,$.jsx)(h,{children:`Icon`}),(0,$.jsx)(`div`,{className:`grid grid-cols-10 gap-1 p-2 bg-background rounded-md border border-border`,children:Ja.map(e=>{let t=Qe[e]||Ct;return(0,$.jsx)(U,{variant:a.icon===e?`default`:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:()=>o({...a,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:()=>o(null),children:[(0,$.jsx)(ee,{className:`h-4 w-4 mr-2`}),` Cancel`]}),(0,$.jsxs)(U,{size:`sm`,onClick:async()=>{if(!a?.name||!a?.commandLine){X({title:`Error`,description:`Name and Command Line are required`,variant:`destructive`});return}try{c(!0),await bt(n,a),X({title:`Success`,description:`Command saved`}),o(null),i()}catch{X({title:`Error`,description:`Failed to save command`,variant:`destructive`})}finally{c(!1)}},disabled:s,children:[(0,$.jsx)(Ne,{className:`h-4 w-4 mr-2`}),` `,s?`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:[r.length===0&&(0,$.jsx)(`div`,{className:`text-center py-8 text-muted-foreground border-2 border-dashed rounded-lg`,children:`No commands defined yet.`}),r.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between p-3 rounded-md border border-border bg-card hover:bg-muted/50 cursor-pointer group transition-colors`,onClick:()=>w(e),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`div`,{className:`p-2 bg-muted rounded`,children:(0,$.jsx)(Qe[e.icon]||ut,{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(),k(e.id)},children:(0,$.jsx)(fe,{className:`h-4 w-4`})})})]},e.id))]}),(0,$.jsxs)(U,{variant:`outline`,className:`w-full border-dashed`,onClick:S,children:[(0,$.jsx)(Ae,{className:`h-4 w-4 mr-2`}),` Add New Command`]})]})})]})})}function Xa(){let e=(0,Q.c)(27),{state:t}=an(),{selectedProjectId:n,selectedThreadId:r,projects:i}=t,{dispatch:a}=dn(r),[o,s]=(0,Z.useState)(!1),c,l,u,d,f;if(e[0]!==a||e[1]!==i||e[2]!==n||e[3]!==r||e[4]!==t.isRunningCommand){f=Symbol.for(`react.early_return_sentinel`);bb0:{let o;e[10]===n?o=e[11]:(o=e=>e.projectId===n,e[10]=n,e[11]=o),c=i.find(o)?.commands??[];let p;e[12]!==a||e[13]!==n||e[14]!==r?(p=e=>{!n||!r||a({type:K.QueueTerminalCommand,threadId:r,command:e.commandLine,relativeFolder:e.relativeFolder})},e[12]=a,e[13]=n,e[14]=r,e[15]=p):p=e[15];let m=p,h;if(e[16]===a?h=e[17]:(h=async()=>{a({type:K.ConfigUpdated})},e[16]=a,e[17]=h),l=h,!n){f=null;break bb0}u=`flex items-center gap-1`,d=c.length===0?(0,$.jsx)(hn,{children:(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(U,{variant:`action`,size:`icon-md`,onClick:()=>s(!0),children:(0,$.jsx)(re,{})})}),(0,$.jsx)(q,{children:`Manage commands`})]})}):(0,$.jsx)($.Fragment,{children:(0,$.jsxs)(hn,{children:[c.map(e=>{let n=Qe[e.icon]||ut;return(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(U,{variant:`action`,size:`icon-md`,onClick:()=>m({commandLine:e.commandLine,relativeFolder:e.relativeFolder}),disabled:t.isRunningCommand,children:(0,$.jsx)(n,{})})}),(0,$.jsx)(q,{children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,$.jsx)(`span`,{className:`font-medium`,children:e.name}),(0,$.jsx)(`span`,{className:`text-[10px] opacity-70 font-mono whitespace-pre-wrap max-w-[300px] max-h-[100px] overflow-y-auto`,children:e.commandLine})]})})]},e.id)}),(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(U,{variant:`action`,size:`icon-md`,className:`ml-1`,onClick:()=>s(!0),children:(0,$.jsx)(re,{})})}),(0,$.jsx)(q,{children:`Manage commands`})]})]})})}e[0]=a,e[1]=i,e[2]=n,e[3]=r,e[4]=t.isRunningCommand,e[5]=c,e[6]=l,e[7]=u,e[8]=d,e[9]=f}else c=e[5],l=e[6],u=e[7],d=e[8],f=e[9];if(f!==Symbol.for(`react.early_return_sentinel`))return f;let p;e[18]!==c||e[19]!==l||e[20]!==n||e[21]!==o?(p=(0,$.jsx)(Ya,{open:o,onOpenChange:s,projectId:n,commands:c,onRefresh:l}),e[18]=c,e[19]=l,e[20]=n,e[21]=o,e[22]=p):p=e[22];let m;return e[23]!==u||e[24]!==d||e[25]!==p?(m=(0,$.jsxs)(`div`,{className:u,children:[d,p]}),e[23]=u,e[24]=d,e[25]=p,e[26]=m):m=e[26],m}function Za(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 Qa({threadId:e}){let{dispatch:t}=an(),{setTerminalNotification:n}=Wn(),[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)(new Set),s=(0,Z.useRef)(new Map);(0,Z.useEffect)(()=>((async()=>{try{let t=await le(e);if(t.length===0){i(null);return}i(t),o(new Set(t.filter(e=>e.isRunning).map(e=>e.name)))}catch{i(null)}})(),()=>{for(let e of s.current.values())e.abort();s.current.clear()}),[e]);let c=async r=>{if(a.has(r.name)){let n=s.current.get(r.name);n&&(n.abort(),s.current.delete(r.name));try{await mt(e,r.name)}catch{}t({type:K.AppendTerminalLine,threadId:e,line:{type:`system`,content:`■ ${r.friendlyName} stopped`}}),o(e=>{let t=new Set(e);return t.delete(r.name),t})}else{let i=new AbortController;s.current.set(r.name,i),o(e=>new Set([...e,r.name])),n(!0),t({type:K.AppendTerminalLine,threadId:e,line:{type:`system`,content:`▶ ${r.friendlyName}`}});try{let n=await ct(e,r.name,r.command,{signal:i.signal});if(n){let r=n.getReader(),i=new TextDecoder,a=``;try{for(;;){let{done:n,value:o}=await r.read();if(n)break;a+=i.decode(o,{stream:!0});let s=a.split(`
|
|
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:`✓ ${r.friendlyName} done`}})}catch{}finally{s.current.delete(r.name),o(e=>{let t=new Set(e);return t.delete(r.name),t})}}};if(!r)return null;let l=r.reduce((e,t)=>(e[t.workspace]||(e[t.workspace]=[]),e[t.workspace].push(t),e),{}),u=Object.entries(l).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>[e,[...t].sort((e,t)=>e.friendlyName.localeCompare(t.friendlyName))]),d=u.length>1;return(0,$.jsxs)(kn,{children:[(0,$.jsx)(hn,{children:(0,$.jsxs)(J,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(Mn,{asChild:!0,children:(0,$.jsx)(U,{variant:`action`,size:`icon-md`,children:(0,$.jsx)(wt,{})})})}),(0,$.jsx)(q,{children:`Project Scripts`})]})}),(0,$.jsx)(Cn,{align:`end`,className:`min-w-[180px]`,children:d?u.map(([e,t])=>(0,$.jsxs)(An,{children:[(0,$.jsx)(wn,{children:e}),(0,$.jsx)(vn,{className:`max-h-[min(400px,80vh)] overflow-y-auto`,children:t.map(e=>(0,$.jsxs)(_n,{onClick:()=>{c(e)},className:`gap-2`,children:[a.has(e.name)?(0,$.jsx)(ce,{className:`h-3 w-3 animate-spin shrink-0`}):(0,$.jsx)(`div`,{className:`h-3 w-3 shrink-0`}),e.friendlyName]},e.name))})]},e)):u[0]?.[1].map(e=>(0,$.jsxs)(_n,{onClick:()=>{c(e)},className:`gap-2`,children:[a.has(e.name)?(0,$.jsx)(ce,{className:`h-3 w-3 animate-spin shrink-0`}):(0,$.jsx)(`div`,{className:`h-3 w-3 shrink-0`}),e.friendlyName]},e.name))})]})}function $a(){let e=(0,Q.c)(44),{state:t,dispatch:n}=an(),{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=C(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)(Re,{className:`h-4 w-4`}):(0,$.jsx)(Et,{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:we(a,i)}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:ne(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=C(`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)(Za,{className:`electrobun-webkit-app-region-no-drag`,children:[(0,$.jsx)(Yn,{projectId:i,runCommand:c?.runCommand}),r&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Qa,{threadId:r}),(0,$.jsx)(Xa,{})]})]}),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)(Za,{className:`electrobun-webkit-app-region-no-drag`,children:(0,$.jsx)(qa,{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)(Za,{className:`electrobun-webkit-app-region-no-drag`,children:(0,$.jsx)(Da,{projectId:i,threadId:r,openWith:c?.openWith})}),e[31]=c?.openWith,e[32]=i,e[33]=r,e[34]=S):S=e[34];let w;e[35]!==y||e[36]!==b||e[37]!==x||e[38]!==S?(w=(0,$.jsxs)(`div`,{className:y,children:[b,x,S]}),e[35]=y,e[36]=b,e[37]=x,e[38]=S,e[39]=w):w=e[39];let T;return e[40]!==w||e[41]!==d||e[42]!==_?(T=(0,$.jsxs)(nr,{className:d,children:[_,w]}),e[40]=w,e[41]=d,e[42]=_,e[43]=T):T=e[43],T}function eo(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)(In,{children:`Delete Project`}),t[0]=o):o=t[0];let s;t[1]===r?s=t[2]:(s=(0,$.jsxs)(Vn,{children:[o,(0,$.jsxs)(Fn,{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)(Bn,{children:`Cancel`}),t[3]=c):c=t[3];let l;t[4]===a?l=t[5]:(l=(0,$.jsxs)(zn,{children:[c,(0,$.jsx)(Rn,{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)(Ln,{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)(Hn,{open:n,onOpenChange:i,children:u}),t[9]=i,t[10]=n,t[11]=u,t[12]=d):d=t[12],d}function to(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)(In,{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)(Vn,{children:[o,(0,$.jsxs)(Fn,{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(no),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)(Bn,{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)(Rn,{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)(zn,{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)(Ln,{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)(Hn,{open:n,onOpenChange:a,children:h}),t[24]=n,t[25]=a,t[26]=h,t[27]=g):g=t[27],g}function no(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 ro(){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(`${V()}/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=io;if(t)return null;let o;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=V(),e[2]=o):o=e[2];let s=o,c,l;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsxs)(Vn,{children:[(0,$.jsx)(In,{children:`Service unavailable`}),(0,$.jsx)(Fn,{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)(Hn,{open:!0,children:(0,$.jsxs)(Ln,{children:[c,l,(0,$.jsx)(zn,{children:(0,$.jsx)(U,{onClick:a,children:`Retry`})})]})}),e[5]=u):u=e[5],u}function io(){window.location.assign(window.location.href)}var ao=Vt,oo=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=C(`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)(Xt,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});oo.displayName=Xt.displayName;var so=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`}}),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,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=C(so({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)(Bt,{ref:t,className:o,...i}),n[7]=i,n[8]=t,n[9]=o,n[10]=s):s=n[10],s});co.displayName=Bt.displayName;var lo=Z.forwardRef((e,t)=>{let n=(0,Q.c)(9),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=C(`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)(zt,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});lo.displayName=zt.displayName;var uo=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=C(`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)(ee,{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)(nn,{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});uo.displayName=nn.displayName;var fo=Z.forwardRef((e,t)=>{let n=(0,Q.c)(9),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=C(`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)(Ht,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});fo.displayName=Ht.displayName;var po=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=C(`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)(Ut,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});po.displayName=Ut.displayName;function mo(){let e=(0,Q.c)(5),{toasts:t}=Nn(),n;e[0]===t?n=e[1]:(n=t.map(ho),e[0]=t,e[1]=n);let r;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(oo,{}),e[2]=r):r=e[2];let i;return e[3]===n?i=e[4]:(i=(0,$.jsxs)(ao,{children:[n,r]}),e[3]=n,e[4]=i),i}function ho(e){let{id:t,title:n,description:r,action:i,...a}=e;return(0,$.jsxs)(co,{...a,children:[(0,$.jsxs)(`div`,{className:`grid gap-1`,children:[n&&(0,$.jsx)(fo,{children:n}),r&&(0,$.jsx)(po,{children:r})]}),i,(0,$.jsx)(uo,{})]},t)}function go(){let e=(0,Q.c)(4),{resolvedTheme:t,theme:n}=Xn(),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 _o(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)(go,{}),t[3]=i):i=t[3];let a;return t[4]!==n||t[5]!==r?(a=(0,$.jsxs)(Zn,{...r,children:[i,n]}),t[4]=n,t[5]=r,t[6]=a):a=t[6],a}function vo(e){let{state:t,dispatch:r}=an(),{toast:a}=Nn(),o=dn(`project-creation`).dispatch,[c,l]=(0,Z.useState)(null),u=(0,Z.useCallback)(async()=>{try{r({type:K.SetProjectsLoading,projectsLoading:!0});let e=await s();r({type:K.SetProjects,projects:e.projects})}catch(e){console.error(`Failed to refresh projects:`,e)}finally{r({type:K.SetProjectsLoading,projectsLoading:!1})}},[r]),d=(0,Z.useCallback)(async(e,n)=>{try{await Fe(e,n)}catch(e){console.error(`Failed to select thread:`,e)}(t.selectedThreadId!==n||t.selectedProjectId!==e)&&r({type:K.SelectThread,threadId:n,projectId:e})},[r,t.selectedThreadId,t.selectedProjectId]),f=(0,Z.useCallback)(async t=>{r({type:K.SetCreatingProject,isCreating:!0});try{let n=await t.apiCall();if(!n){r({type:K.SetCreatingProject,isCreating:!1}),await u();return}let i=t.useTerminalDispatch?o:r;i({type:K.ClearTerminalOutput}),i({type:K.SetTerminalOpen,open:!0}),i({type:K.AppendTerminalLine,line:{type:`system`,content:t.initialMessage}});let a=n.getReader(),c=new TextDecoder,d=``,f=null,p=!1,m=null,h=null;for(;;){let{done:e,value:n}=await a.read();if(e)break;d+=c.decode(n,{stream:!0});let o=d.split(`
|
|
35
|
+
`);d=o.pop()??``;for(let e of o){let n=e.trim();if(n)try{let e=JSON.parse(n);if(e.type===`progress`)!p&&e.threadId&&e.projectId&&(p=!0,m=e.projectId,h=e.threadId,r({type:K.AddCreatingProject,projectId:e.projectId,threadId:e.threadId,projectName:t.optimisticProjectName,gitUrl:t.gitUrl??``}),r({type:K.AddProcessingThread,threadId:e.threadId})),r({type:K.AppendTerminalLine,...t.useTerminalDispatch?{threadId:h??`project-creation`}:{},line:{type:`output`,content:e.message}});else if(e.type===`complete`){if(e.project){f=e.project.id;let n=t.includeThreadPath&&e.project.threads?.length>0?`${e.project.path}/${e.project.threads[0]}`:e.project.path;i({type:K.AppendTerminalLine,line:{type:`system`,content:`Project created successfully at: ${n}`}}),r({type:K.SetTerminalOpen,open:!1}),t.handleSetupScript&&e.suggestedSetupScript&&l({projectId:e.project.id,command:e.suggestedSetupScript,remainingScripts:e.project.pendingSetupScripts??[]})}}else e.type===`error`&&(p&&m&&(r({type:K.RemoveCreatingProject,projectId:m}),h&&r({type:K.RemoveProcessingThread,threadId:h})),r({type:K.AppendTerminalLine,...t.useTerminalDispatch?{threadId:h??`project-creation`}:{},line:{type:`error`,content:`Error: ${e.message}`}}))}catch(e){console.error(`Failed to parse ${t.logTag} event`,e)}}}r({type:K.SetCreatingProject,isCreating:!1}),p&&h&&r({type:K.RemoveProcessingThread,threadId:h}),O();let g=await s();if(r({type:K.SetProjects,projects:g.projects}),r({type:K.SetProjectsLoading,projectsLoading:!1}),f){let t=g.projects.find(e=>e.projectId===f);if(t&&t.threads.length>0){let e=t.threads[0].threadId;r({type:K.SelectThread,threadId:e,projectId:f,focusInput:!0})}e?.onProjectCreated?.(f)}}catch(e){console.error(`Failed to ${t.logTag}:`,e),r({type:K.SetCreatingProject,isCreating:!1}),(t.useTerminalDispatch?o:r)({type:K.AppendTerminalLine,line:{type:`error`,content:`${t.catchErrorPrefix}: ${e instanceof Error?e.message:`Unknown error`}`}})}},[r,u,o,e?.onProjectCreated]),p=(0,Z.useCallback)(async(e,t)=>{let n=e.split(`/`).pop()?.replace(`.git`,``)??`project`;await f({apiCall:()=>$e(e,t),initialMessage:`Cloning repository: ${e}...`,optimisticProjectName:n,gitUrl:e,useTerminalDispatch:!0,includeThreadPath:!0,handleSetupScript:!0,logTag:`create project`,catchErrorPrefix:`Failed to create project`})},[f]),m=(0,Z.useCallback)(async(e,t,r)=>{await f({apiCall:()=>n(e,t,r),initialMessage:`Creating app "${e}"...`,optimisticProjectName:e,useTerminalDispatch:!0,handleSetupScript:!1,logTag:`create web app`,catchErrorPrefix:`Failed to create web app`})},[f]),h=(0,Z.useCallback)(async(e,n)=>{try{let i=n??(()=>{let n=t.projects.find(t=>t.projectId===e)?.threads.map(e=>e.title)??[],r=/^thread-(\d+)$/i,i=0;for(let e of n){let t=e.match(r);t&&(i=Math.max(i,parseInt(t[1],10)))}return`thread-${i+1}`})(),o=await P(e,n);if(!o){await u();return}let s=o.getReader(),c=new TextDecoder,l=``,d=!1,f=null,p=!0,m=[{type:`system`,content:`Creating thread "${i}"...`}];try{for(;;){let{done:t,value:n}=await s.read();if(t)break;l+=c.decode(n,{stream:!0});let o=l.split(`
|
|
36
|
+
`);l=o.pop()??``;for(let t of o){let n=t.trim();if(n)try{let t=JSON.parse(n);if(t.type===`progress`){if(!d&&t.threadId){d=!0,f=t.threadId,r({type:K.AddCreatingThread,projectId:e,threadId:t.threadId,title:i}),r({type:K.AddProcessingThread,threadId:t.threadId}),r({type:K.ClearTerminalOutput,threadId:f});for(let e of m)r({type:K.AppendTerminalLine,threadId:f,line:e});m.length=0}let n={type:`output`,content:t.message};f?r({type:K.AppendTerminalLine,threadId:f,line:n}):m.push(n)}else if(t.type===`error`){d&&f&&(r({type:K.RemoveCreatingThread,projectId:e,threadId:f}),r({type:K.RemoveProcessingThread,threadId:f}));let n={type:`error`,content:`Error: ${t.message}`};f?r({type:K.AppendTerminalLine,threadId:f,line:n}):m.push(n),console.error(`Thread creation error:`,t.message),a({title:`Thread Creation Failed`,description:t.message,variant:`destructive`}),p=!1}}catch(e){console.error(`Failed to parse thread event`,e)}}}d&&f&&r({type:K.RemoveProcessingThread,threadId:f}),O(),await u(),f&&p&&r({type:K.SelectThread,threadId:f,projectId:e,focusInput:!0})}catch(t){throw d&&f&&(r({type:K.RemoveCreatingThread,projectId:e,threadId:f}),r({type:K.RemoveProcessingThread,threadId:f})),a({title:`Thread Creation Failed`,description:t instanceof Error?t.message:String(t),variant:`destructive`}),t}}catch(e){console.error(`Failed to create thread:`,e);let t=`Failed to create thread: ${e instanceof Error?e.message:`Unknown error`}`;throw r({type:K.AppendTerminalLine,line:{type:`error`,content:t}}),a({variant:`destructive`,title:`Thread Creation Failed`,description:t}),e}},[u,r,t.projects,a]),g=(0,Z.useCallback)(async(e,n)=>{r({type:K.AddDeletingThread,threadId:n});try{await i(e,n),O(),await u(),t.selectedThreadId===n&&r({type:K.SelectThread,threadId:``,projectId:``})}catch(e){console.error(`Failed to delete thread:`,e)}finally{r({type:K.RemoveDeletingThread,threadId:n})}},[u,t.selectedThreadId,r]),_=(0,Z.useCallback)(async e=>{r({type:K.AddDeletingProject,projectId:e});let n=t.projects.find(t=>t.projectId===e)?.threads.map(e=>e.threadId)??[];for(let e of n)r({type:K.AddDeletingThread,threadId:e});try{await k(e),await u(),t.selectedProjectId===e&&r({type:K.SelectThread,threadId:``,projectId:``})}catch(e){console.error(`Failed to delete project:`,e)}finally{r({type:K.RemoveDeletingProject,projectId:e});for(let e of n)r({type:K.RemoveDeletingThread,threadId:e})}},[u,t.selectedProjectId,t.projects,r]),v=(0,Z.useCallback)(async e=>{let t=c;if(l(null),!t||!e)return;let{projectId:n,command:i,remainingScripts:a}=t,o=[i,...a||[]];try{r({type:K.SetCreatingProject,isCreating:!0}),r({type:K.SetTerminalOpen,open:!0}),r({type:K.AppendTerminalLine,line:{type:`system`,content:`Installing dependencies for ${o.length} package${o.length===1?``:`s`}...`}});for(let e=0;e<o.length;e++){let t=o[e],i=t.match(/^cd "([^"]+)" && (.+)$/),a=i?i[1]:`root`;r({type:K.AppendTerminalLine,line:{type:`system`,content:`Installing package ${e+1}/${o.length} in ${a}...`}}),r({type:K.AppendTerminalLine,line:{type:`output`,content:`📦 Installing dependencies in ${a}: ${t}`}});let s=await Mt(n,t,!0);if(s){let e=s.getReader(),t=new TextDecoder,n=``;for(;;){let{done:i,value:a}=await e.read();if(i)break;n+=t.decode(a,{stream:!0});let o=n.split(`
|
|
37
|
+
`);n=o.pop()??``;for(let e of o)if(e.trim())try{let t=JSON.parse(e);typeof t==`string`?r({type:K.AppendTerminalLine,line:{type:`output`,content:t}}):t.type===`error`&&r({type:K.AppendTerminalLine,line:{type:`error`,content:t.message}})}catch{r({type:K.AppendTerminalLine,line:{type:`output`,content:e}})}}if(n.trim())try{let e=JSON.parse(n);typeof e==`string`?r({type:K.AppendTerminalLine,line:{type:`output`,content:e}}):e.type===`error`&&r({type:K.AppendTerminalLine,line:{type:`error`,content:e.message}})}catch{r({type:K.AppendTerminalLine,line:{type:`output`,content:n}})}}e<o.length-1&&(r({type:K.AppendTerminalLine,line:{type:`system`,content:``}}),r({type:K.AppendTerminalLine,line:{type:`system`,content:`---`}}),r({type:K.AppendTerminalLine,line:{type:`system`,content:``}}))}r({type:K.AppendTerminalLine,line:{type:`system`,content:`All dependencies installed successfully!`}}),r({type:K.SetCreatingProject,isCreating:!1}),await u()}catch(e){r({type:K.SetCreatingProject,isCreating:!1}),console.error(`Failed to run setup script:`,e),r({type:K.AppendTerminalLine,line:{type:`error`,content:`Failed to run setup script: ${e instanceof Error?e.message:`Unknown error`}`}})}},[c,r,u]);(0,Z.useEffect)(()=>{let e=!0;async function n(){try{r({type:K.SetProjectsLoading,projectsLoading:!0});let n=await s();if(!e)return;if(r({type:K.SetProjects,projects:n.projects}),!t.selectedThreadId)for(let e of n.projects){let t=e.threads.find(e=>e.isSelected);if(t){r({type:K.SelectThread,threadId:t.threadId,projectId:e.projectId});break}}}catch(e){console.error(`Failed to load projects:`,e)}finally{e&&r({type:K.SetProjectsLoading,projectsLoading:!1})}}return n(),()=>{e=!1}},[r,t.selectedThreadId,t.configUpdatedAt]);let y=(0,Z.useCallback)(async()=>{await f({apiCall:xe,initialMessage:`Opening folder...`,optimisticProjectName:`Opening folder...`,useTerminalDispatch:!0,handleSetupScript:!0,logTag:`open folder`,catchErrorPrefix:`Failed to open folder`})},[f]);return{projects:t.projects,selectedProjectId:t.selectedProjectId,selectedThreadId:t.selectedThreadId,refreshProjects:u,handleSelectThread:d,handleCreateProject:p,handleCreateWebApp:m,handleOpenFolder:y,handleCreateThread:h,handleDeleteThread:g,confirmDeleteProject:_,pendingSetupScriptConfirmation:c,resolveSetupScriptConfirmation:v}}function yo(){let e=(0,Q.c)(2),[t,n]=(0,Z.useState)(bo),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 bo(){return document.hasFocus()}var xo=null;function So(){xo??=new Audio(`/pop.wav`),xo.currentTime=0,xo.play().catch(e=>{console.debug(`Could not play completion sound:`,e)})}function Co(){let{state:e,dispatch:t}=an(),n=yo(),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 Ft(),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&&So(),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 wo=768;function To(){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: ${wo-1}px)`),t=()=>{n(window.innerWidth<wo)};return e.addEventListener(`change`,t),n(window.innerWidth<wo),()=>e.removeEventListener(`change`,t)},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),Z.useEffect(r,i),!!t}var Eo=(0,Z.lazy)(()=>Gt(()=>import(`./terminal-panel-GuO2XygM.js`).then(e=>({default:e.TerminalPanel})),__vite__mapDeps([21,1,4,13,14]))),Do=(0,Z.lazy)(()=>Gt(()=>import(`./todos-view-C4GMi1Np.js`).then(e=>({default:e.TodosView})),[])),Oo=(0,Z.lazy)(()=>Gt(()=>import(`./diff-view-fOVqrHQW.js`),__vite__mapDeps([9,1,2,3,4,5,10,11,12,7,13,14,15,16,17,18,19,20,6]))),ko=(0,Z.lazy)(()=>Gt(()=>import(`./explorer-tab-view-MLrWJ1Y0.js`),__vite__mapDeps([22,1,2,3,4,5,19,13,14]))),Ao=(0,Z.lazy)(()=>Gt(()=>import(`./browser-tab-DlzO5cMP.js`).then(e=>({default:e.BrowserTab})),__vite__mapDeps([23,1,4,24,3,7,13,14]))),jo=(0,Z.lazy)(()=>Gt(()=>import(`./dialogs-config-DZFG2IQM.js`).then(e=>e.t),__vite__mapDeps([4,1]))),Mo=(0,Z.lazy)(()=>Gt(()=>import(`./onboarding-dialog-BXsvjU1t.js`),__vite__mapDeps([25,11,1,3,4]))),No=(0,Z.lazy)(()=>Gt(()=>import(`./conversation-history-view-B4zHwyrw.js`),__vite__mapDeps([26,3,1,4]))),Po=(0,Z.lazy)(()=>Gt(()=>import(`./settings-view-CccwUKkf.js`),__vite__mapDeps([27,1,2,3,4,5,28,19,20])));function Fo(){let{state:e,dispatch:t}=an();(0,Z.useEffect)(()=>{window.__electrobunWebviewId&&new mr({})},[]);let n=tn(),r=Wt(),i=To(),[a,o]=(0,Z.useState)(null),{projects:s,handleSelectThread:c,handleCreateProject:l,handleCreateWebApp:u,handleOpenFolder:d,handleCreateThread:f,handleDeleteThread:p,confirmDeleteProject:m,refreshProjects:h,pendingSetupScriptConfirmation:g,resolveSetupScriptConfirmation:_}=vo({onProjectCreated:o}),{processingThreadIds:v,completedThreadIds:y,clearCompleted:b}=Co(),[x,S]=(0,Z.useState)(`chat`),[C,w]=(0,Z.useState)(null),[T,E]=(0,Z.useState)(!1),[D,O]=(0,Z.useState)(!1),[k,A]=(0,Z.useState)(!1),[j,M]=(0,Z.useState)(null),[N,P]=(0,Z.useState)(0),[F,I]=(0,Z.useState)(null),[L,R]=(0,Z.useState)(0),{terminalState:ee}=dn(e.selectedThreadId),z=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{ee.open&&e.selectedThreadId===z.current&&S(`terminal`),z.current=e.selectedThreadId},[ee.open,e.selectedThreadId]);let[B,V]=(0,Z.useState)(!1),[te,H]=(0,Z.useState)(!1),[ne,re]=(0,Z.useState)(!1),[ie,U]=(0,Z.useState)(null),[ae,oe]=(0,Z.useState)(!1),[ce,le]=(0,Z.useState)(!1),ue=(0,Z.useRef)(null),de=r.pathname.startsWith(`/settings`),W=r.pathname===`/review`,G=r.pathname===`/todos`;(0,Z.useEffect)(()=>{r.pathname===`/`&&x===`tasks`&&S(`chat`)},[r.pathname]);let fe=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{let n=de||W||G;if(n&&fe.current===null)fe.current=e.sidebarOpen,e.sidebarOpen&&t({type:K.ToggleSidebar});else if(!n&&fe.current!==null){let n=fe.current;fe.current=null,n&&!e.sidebarOpen&&t({type:K.ToggleSidebar})}},[de,W,G]),(0,Z.useEffect)(()=>{(async()=>{try{(await se()).updateAvailable&&oe(!0)}catch{}})()},[]);let pe=(0,Z.useCallback)(async()=>{le(!0);try{await At()}catch{le(!1)}},[]);(0,Z.useEffect)(()=>{ne||(async()=>{try{(await Ge()).onboardingCompleted||H(!0)}catch(e){console.error(`Failed to check onboarding status:`,e)}finally{re(!0)}})()},[ne]),(0,Z.useEffect)(()=>{te||t({type:K.ConfigUpdated})},[te,t]);let me=(0,Z.useCallback)(e=>{let t=s.find(t=>t.projectId===e);t&&U({id:t.projectId,name:ge(t)})},[s]),he=(0,Z.useCallback)(e=>{o(e),f(e,void 0)},[f]);(0,Z.useEffect)(()=>{a&&e.selectedProjectId===a&&e.selectedThreadId&&o(null)},[a,e.selectedProjectId,e.selectedThreadId]);let _e=(0,Z.useCallback)(async(a,s)=>{o(null),b(s),r.pathname!==`/`&&n(`/`),S(`chat`),e.selectedThreadId!==s&&R(e=>e+1),await c(a,s),i&&e.sidebarOpen&&t({type:K.ToggleSidebar})},[c,i,e.sidebarOpen,e.selectedThreadId,t,b,r.pathname,n]);(0,Z.useEffect)(()=>{e.sidebarOpen?ue.current?.expand():ue.current?.collapse()},[e.sidebarOpen]);let ve={activeMainTab:x,setActiveMainTab:S,devServerUrl:C,setDevServerUrl:w,devServerRunning:T,setDevServerRunning:E,devServerLoading:D,setDevServerLoading:O,terminalNotification:k,setTerminalNotification:A,pendingExplorerPath:j,setPendingExplorerPath:M,explorerRefreshTick:N,triggerExplorerRefresh:()=>P(e=>e+1),explorerClearPath:F,setExplorerClearPath:I,browserResetTrigger:L,triggerBrowserReset:()=>R(e=>e+1)};return(0,$.jsx)(Gn.Provider,{value:ve,children:(0,$.jsxs)(hn,{delayDuration:200,children:[(0,$.jsxs)(ir,{direction:`horizontal`,className:`h-screen bg-background`,children:[(0,$.jsx)(rr,{ref:ue,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)(vr,{projects:s,selectedThreadId:e.selectedThreadId,selectedProjectId:e.selectedProjectId,processingThreadIds:v,completedThreadIds:y,deletingThreadIds:e.deletingThreadIds,deletingProjectIds:e.deletingProjectIds,onSelectThread:_e,onCreateProject:()=>V(!0),onCreateThread:he,onDeleteThread:p,onDeleteProject:me,onDeselect:()=>t({type:K.ClearSelection}),collapsed:!e.sidebarOpen,updateAvailable:ae,updatingApp:ce,onUpdateApp:pe,onRefreshProjects:h,expandProjectId:a})})}),!i&&(0,$.jsx)(ar,{withHandle:!0,className:e.sidebarOpen?`ml-[-40px]`:``}),(0,$.jsx)(rr,{minSize:40,className:`overflow-hidden ${i&&e.sidebarOpen?`hidden`:``}`,children:(0,$.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden`,children:[!W&&!de&&!G&&(0,$.jsx)($a,{}),!W&&!de&&!G&&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:()=>{S(t),t===`terminal`&&A(!1)},className:`relative px-4 py-2 text-sm font-medium transition-colors ${x===t?`border-b-2 border-primary text-foreground -mb-px`:`text-muted-foreground hover:text-foreground`}`,children:[e,t===`terminal`&&k&&x!==`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${!W&&!de&&!G&&x!==`chat`?` hidden`:``}`,children:(0,$.jsxs)(qt,{children:[(0,$.jsx)(Jt,{path:`/settings/:tab?`,element:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Po,{})})}),(0,$.jsx)(Jt,{path:`/settings/project/:projectId`,element:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Po,{})})}),(0,$.jsx)(Jt,{path:`*`,element:(0,$.jsx)(Ca,{onCreateThread:he})})]})}),(0,$.jsx)(`div`,{className:`flex-1 overflow-hidden${x===`terminal`&&!W&&!de&&!G?``:` hidden`}`,children:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Eo,{})})}),(0,$.jsx)(`div`,{className:`flex-1 overflow-hidden${x===`browser`&&!W&&!de&&!G?``:` hidden`}`,children:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Ao,{})})}),!W&&!de&&!G&&x!==`chat`&&x!==`terminal`&&x!==`browser`&&(x===`explorer`?(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(ko,{})}):x===`tasks`&&e.selectedProjectId?(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Do,{projectId:e.selectedProjectId})}):x===`history`?(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(No,{isOpen:!0,onClose:()=>S(`chat`),initialFilter:e.selectedProjectId?{type:`project`,id:e.selectedProjectId}:void 0,projects:s,inline:!0})}):x===`review`&&e.selectedThreadId?(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Oo,{threadId:e.selectedThreadId,onExit:()=>S(`chat`)})}):(0,$.jsx)(`div`,{className:`flex-1 overflow-hidden`}))]})}),(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(jo,{open:B,onOpenChange:V,onSubmitClone:l,onSubmitWebApp:u,onOpenFolder:d})}),(0,$.jsx)(eo,{open:ie!==null,projectName:ie?.name,onOpenChange:e=>!e&&U(null),onConfirm:()=>{ie&&(m(ie.id),U(null))}}),(0,$.jsx)(to,{open:g!==null,setupScripts:g?[g.command,...g.remainingScripts||[]]:[],onConfirm:_}),(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Mo,{open:te,onOpenChange:H,onComplete:()=>{re(!0),h()}})}),(0,$.jsx)(ro,{})]}),(0,$.jsx)(mo,{})]})})}function Io(){let e=(0,Q.c)(5),[t,n]=(0,Z.useReducer)(pn,ln),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)(Fo,{}),e[2]=i):i=e[2];let a;return e[3]===r?a=e[4]:(a=(0,$.jsx)(_o,{attribute:`class`,defaultTheme:`system`,enableSystem:!0,storageKey:`tarsk-theme`,children:(0,$.jsx)(un.Provider,{value:r,children:i})}),e[3]=r,e[4]=a),a}var Lo=!1;window.addEventListener(`resize`,()=>{Lo||=(window.__electrobunWebviewId&&(document.body.style.height=`calc(100%)`),!0)}),(0,or.createRoot)(document.getElementById(`root`)).render((0,$.jsx)(Z.StrictMode,{children:(0,$.jsx)(Zt,{children:(0,$.jsx)(Io,{})})}));export{ba as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{$r as e,Dr as t,Gi as n,Rn as r,Vr as i,_a as a,ca as o}from"./dialogs-config-DZFG2IQM.js";import{c as s,l as c,s as l,u}from"./history-view-BR8scGnM.js";var d=a(),f=t();function p(t){let a=(0,d.c)(25),{name:p,description:m,installed:h,onClick:g,onOpen:_,onUninstall:v,showInstalledControls:y}=t,b=y===void 0?!0:y,x=`flex flex-col gap-2 p-2.5 rounded-lg border border-border bg-card text-left transition-colors w-full ${h?``:`hover:bg-accent/50 cursor-pointer`}`,S=h?void 0:g,C=h?void 0:`button`,w;a[0]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,f.jsx)(`div`,{className:`flex-shrink-0 h-6 w-6 rounded-md bg-muted flex items-center justify-center`,children:(0,f.jsx)(e,{className:`h-3 w-3 text-muted-foreground`})}),a[0]=w):w=a[0];let T;a[1]===p?T=a[2]:(T=(0,f.jsx)(`span`,{className:`font-medium text-sm truncate`,children:p}),a[1]=p,a[2]=T);let E;a[3]!==h||a[4]!==b?(E=h&&b&&(0,f.jsx)(c,{delayDuration:300,children:(0,f.jsxs)(l,{children:[(0,f.jsx)(u,{asChild:!0,children:(0,f.jsx)(`span`,{className:`flex-shrink-0 h-4 w-4 rounded-full bg-green-500/15 flex items-center justify-center`,children:(0,f.jsx)(o,{className:`h-2.5 w-2.5 text-green-600 dark:text-green-400`})})}),(0,f.jsx)(s,{children:`Installed`})]})}),a[3]=h,a[4]=b,a[5]=E):E=a[5];let D;a[6]!==T||a[7]!==E?(D=(0,f.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[w,T,E]}),a[6]=T,a[7]=E,a[8]=D):D=a[8];let O;a[9]!==h||a[10]!==_||a[11]!==v||a[12]!==b?(O=h&&b&&(0,f.jsxs)(`div`,{className:`flex items-center gap-1 flex-shrink-0`,children:[_&&(0,f.jsx)(c,{delayDuration:300,children:(0,f.jsxs)(l,{children:[(0,f.jsx)(u,{asChild:!0,children:(0,f.jsx)(r,{variant:`ghost`,size:`icon-sm`,onClick:e=>{e.stopPropagation(),_()},children:(0,f.jsx)(n,{className:`h-3.5 w-3.5`})})}),(0,f.jsx)(s,{children:`Open in Explorer`})]})}),v&&(0,f.jsx)(c,{delayDuration:300,children:(0,f.jsxs)(l,{children:[(0,f.jsx)(u,{asChild:!0,children:(0,f.jsx)(r,{variant:`ghost`,size:`icon-sm`,onClick:e=>{e.stopPropagation(),v()},className:`text-destructive hover:text-destructive`,children:(0,f.jsx)(i,{className:`h-3.5 w-3.5`})})}),(0,f.jsx)(s,{children:`Remove`})]})})]}),a[9]=h,a[10]=_,a[11]=v,a[12]=b,a[13]=O):O=a[13];let k;a[14]!==D||a[15]!==O?(k=(0,f.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[D,O]}),a[14]=D,a[15]=O,a[16]=k):k=a[16];let A;a[17]===m?A=a[18]:(A=(0,f.jsx)(`p`,{className:`text-xs text-muted-foreground line-clamp-3`,children:m}),a[17]=m,a[18]=A);let j;return a[19]!==k||a[20]!==A||a[21]!==x||a[22]!==S||a[23]!==C?(j=(0,f.jsxs)(`div`,{className:x,onClick:S,role:C,children:[k,A]}),a[19]=k,a[20]=A,a[21]=x,a[22]=S,a[23]=C,a[24]=j):j=a[24],j}export{p as t};
|