tarsk 0.4.29 → 0.4.31
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 +746 -349
- package/dist/public/assets/{account-view-YvC0mymF.js → account-view-Cdp8xegU.js} +1 -1
- package/dist/public/assets/alert-dialog-DAJFcjdR.js +1 -0
- package/dist/public/assets/api-BYFUablr.js +1 -0
- package/dist/public/assets/{browser-tab-CCXMlmPO.js → browser-tab-Ban23pgA.js} +1 -1
- package/dist/public/assets/chat-input-container-Bc7nCdKX.js +21 -0
- package/dist/public/assets/context-menu-D93N09Jw.js +1 -0
- package/dist/public/assets/conversation-history-view-qm_qW0aD.js +1 -0
- package/dist/public/assets/{dialogs-config-B91VQpxo.js → dialogs-config-VlhyoYms.js} +14 -14
- package/dist/public/assets/diff-view-DUmzPmed.js +3 -0
- package/dist/public/assets/explorer-tab-view-Bbboiq-d.js +2 -0
- package/dist/public/assets/explorer-tree-CX03Vh31.js +1 -0
- package/dist/public/assets/{explorer-view-BCJqE1-z.js → explorer-view-CMcJFEtT.js} +1 -1
- package/dist/public/assets/history-view-Cub-F9g6.js +1 -0
- package/dist/public/assets/index-C-dv630o.css +1 -0
- package/dist/public/assets/index-DaJT5K7g.js +29 -0
- package/dist/public/assets/{markdown-renderer-9nzN0Pk3.js → markdown-renderer-BPXg5AUu.js} +4 -4
- package/dist/public/assets/{mcp-server-card-BSw_FlEC.js → mcp-server-card-BCZmpcVY.js} +1 -1
- package/dist/public/assets/onboarding-BPUo1aJX.js +1 -0
- package/dist/public/assets/onboarding-dialog-vqz8baom.js +1 -0
- package/dist/public/assets/page-toolbar-CU9dGLvm.js +1 -0
- package/dist/public/assets/project-settings-view-BAs5RYWR.js +1 -0
- package/dist/public/assets/providers-list-view-67A5O5vd.js +1 -0
- package/dist/public/assets/radio-group-CRwVSJCp.js +1 -0
- package/dist/public/assets/react-vendor-CtZx3FWA.js +22 -0
- package/dist/public/assets/{resizable-CEv7JjTI.js → resizable-AKojmHeo.js} +1 -1
- package/dist/public/assets/{run-stop-button-CrjPMC0m.js → run-stop-button-DYoC8i6e.js} +2 -2
- package/dist/public/assets/settings-general-view-mu1Qq8cl.js +1 -0
- package/dist/public/assets/{settings-instructions-view-C23spY9Y.js → settings-instructions-view-DQRSZId7.js} +1 -1
- package/dist/public/assets/{settings-mcp-servers-view-ZHar6YbE.js → settings-mcp-servers-view-BqJMRVZJ.js} +4 -4
- package/dist/public/assets/settings-models-skeleton-qdDMv5hS.js +1 -0
- package/dist/public/assets/settings-models-view-DSrdZZfF.js +1 -0
- package/dist/public/assets/settings-rules-view-Dt_lfKVv.js +8 -0
- package/dist/public/assets/{settings-skills-view-D60tD-OE.js → settings-skills-view-Djrk38ol.js} +2 -2
- package/dist/public/assets/{settings-slash-commands-view-DR-pzulT.js → settings-slash-commands-view-Cm5cy2My.js} +1 -1
- package/dist/public/assets/{settings-subagents-view-InXmwmw9.js → settings-subagents-view-CsGwbSvQ.js} +2 -2
- package/dist/public/assets/settings-view-DuTfugUO.js +2 -0
- package/dist/public/assets/{side-panel-container-CO3qgRvc.js → side-panel-container-Cg99BH1l.js} +2 -2
- package/dist/public/assets/skeleton-B1fuNMHm.js +1 -0
- package/dist/public/assets/{standard-list-item-DyALhVYe.js → standard-list-item-0m99qNoa.js} +1 -1
- package/dist/public/assets/{store-D28g9VUj.js → store-DUqJt-K-.js} +1 -1
- package/dist/public/assets/{tab-context-C3z7YU59.js → tab-context-BYpxvaoz.js} +1 -1
- package/dist/public/assets/tabs-ywSKq3qp.js +1 -0
- package/dist/public/assets/{terminal-panel-EifoA6G0.js → terminal-panel-C9XWZHaD.js} +2 -2
- package/dist/public/assets/textarea-DuuNwegn.js +1 -0
- package/dist/public/assets/todos-view-CRzNrsfP.js +1 -0
- package/dist/public/assets/{use-font-size-BCtvz0bm.js → use-font-size-D2A0_bAi.js} +1 -1
- package/dist/public/assets/{use-toast-BZ79E_dX.js → use-toast-BF5WtiOJ.js} +1 -1
- package/dist/public/assets/{utils-Bhu11Tpg.js → utils-CheqpoJ4.js} +1 -1
- package/dist/public/index.html +21 -21
- package/package.json +2 -2
- package/dist/public/assets/alert-dialog-BFhUZsPe.js +0 -1
- package/dist/public/assets/api-DSvSyBH5.js +0 -1
- package/dist/public/assets/chat-input-container-VwmGKJFJ.js +0 -21
- package/dist/public/assets/context-menu-B6K8j1ha.js +0 -1
- package/dist/public/assets/conversation-history-view-DrrLyMbg.js +0 -1
- package/dist/public/assets/diff-view-C09yOc5d.js +0 -3
- package/dist/public/assets/explorer-tab-view-B1DukGdo.js +0 -2
- package/dist/public/assets/explorer-tree-DCeud6YI.js +0 -1
- package/dist/public/assets/history-view-Dj4NiScy.js +0 -1
- package/dist/public/assets/index-7TFkb0ll.css +0 -1
- package/dist/public/assets/index-BLCecayZ.js +0 -29
- package/dist/public/assets/onboarding-ClUE_I5q.js +0 -1
- package/dist/public/assets/onboarding-dialog-C2jig8mT.js +0 -1
- package/dist/public/assets/page-toolbar-DnVFnCgq.js +0 -1
- package/dist/public/assets/project-settings-view-DWn0ty7b.js +0 -1
- package/dist/public/assets/providers-list-view-B0DqNJYK.js +0 -1
- package/dist/public/assets/radio-group-CM_Wwam0.js +0 -1
- package/dist/public/assets/react-vendor-nPkCWaAR.js +0 -22
- package/dist/public/assets/settings-general-view-CwQYmnI2.js +0 -1
- package/dist/public/assets/settings-models-view-Cg6WQ4cy.js +0 -1
- package/dist/public/assets/settings-rules-view-zAx5JL4w.js +0 -8
- package/dist/public/assets/settings-view-DLRDBuwH.js +0 -2
- package/dist/public/assets/skeleton-CXoVAzC1.js +0 -1
- package/dist/public/assets/tabs-sXgL2DZz.js +0 -1
- package/dist/public/assets/textarea-Bp3p1-25.js +0 -1
- package/dist/public/assets/todos-view-DRL4px6A.js +0 -1
- /package/dist/public/assets/{dist-D5DgwfYL.js → dist-CAVGqbBm.js} +0 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dialogs-config-VlhyoYms.js","assets/rolldown-runtime-B1FJdls4.js","assets/diff-view-DUmzPmed.js","assets/monaco-BGyhgQtx.js","assets/monaco-Br_kD0ds.css","assets/chat-input-container-Bc7nCdKX.js","assets/history-view-Cub-F9g6.js","assets/onboarding-BPUo1aJX.js","assets/alert-dialog-DAJFcjdR.js","assets/react-vendor-CtZx3FWA.js","assets/use-toast-BF5WtiOJ.js","assets/store-DUqJt-K-.js","assets/tab-context-BYpxvaoz.js","assets/whisper-wasm-C_Ot631g.js","assets/utils-CheqpoJ4.js","assets/page-toolbar-CU9dGLvm.js","assets/context-menu-D93N09Jw.js","assets/resizable-AKojmHeo.js","assets/standard-list-item-0m99qNoa.js","assets/textarea-DuuNwegn.js","assets/terminal-panel-C9XWZHaD.js","assets/explorer-tab-view-Bbboiq-d.js","assets/browser-tab-Ban23pgA.js","assets/run-stop-button-DYoC8i6e.js","assets/onboarding-dialog-vqz8baom.js","assets/settings-view-DuTfugUO.js","assets/settings-models-skeleton-qdDMv5hS.js","assets/skeleton-B1fuNMHm.js","assets/side-panel-container-Cg99BH1l.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{$i as t,$t as n,A as r,Ai as i,An as a,Ar as o,At as s,B as c,Bi as l,Br as u,C as d,Ci as f,Dn as p,E as m,Er as h,Et as g,Fi as _,Fn as v,Fr as y,G as b,Gn as x,Gr as S,Gt as C,Hn as w,Ht as T,I as E,In as D,It as O,J as k,Ji as A,Jn as j,Jr as M,Jt as N,Kn as P,L as F,Li as I,Ln as L,Mn as ee,Mr as R,Nn as z,Nr as B,On as V,Or as H,P as U,Pi as te,Pn as W,Qt as G,R as ne,Ri as re,Rr as ie,S as ae,T as oe,Ti as se,Tn as ce,U as le,Ut as ue,Vi as K,Wn as q,Wr as de,Wt as fe,Xn as J,Xt as pe,Yn as me,Zi as he,_ as ge,_a as _e,_i as ve,_t as ye,aa as be,at as xe,bn as Se,bt as Ce,ca as we,ci as Te,cn as Ee,d as De,di as Oe,ea as ke,ei as Ae,en as je,f as Me,g as Ne,gi as Pe,gn as Fe,gt as Ie,h as Le,ha as Re,hi as ze,hn as Be,ht as Ve,jr as He,k as Ue,kt as We,la as Ge,ln as Ke,lt as qe,mi as Je,na as Ye,ni as Xe,nn as Ze,oa as Qe,oi as $e,on as et,pa as tt,pi as nt,qi as rt,qn as it,qr as at,qt as ot,ra as st,ri as ct,rn as lt,rt as ut,tn as dt,ua as ft,ui as pt,un as mt,v as ht,w as gt,x as _t,xn as vt,y as yt,ya as bt,yt as xt,zi as St,zn as Ct}from"./dialogs-config-VlhyoYms.js";import{A as wt,Ct as Tt,M as Et,N as Dt,O as Ot,P as kt,St as At,Tt as jt,bt as Mt,j as Nt,k as Pt,lt as Ft,xt as It,yt as Lt}from"./react-vendor-CtZx3FWA.js";import{Pt as Rt}from"./monaco-BGyhgQtx.js";import{a as zt,c as Bt,d as Vt,f as Ht,i as Ut,m as Wt,n as Gt,o as Kt,p as qt,r as Jt,t as Y}from"./store-DUqJt-K-.js";import{t as Yt}from"./textarea-DuuNwegn.js";import{c as Xt,l as Zt,s as Qt,u as $t}from"./history-view-Cub-F9g6.js";import{_ as en,a as tn,b as nn,c as rn,d as an,f as on,g as sn,h as cn,i as ln,l as un,m as dn,n as fn,o as pn,p as mn,r as hn,s as gn,t as _n,u as vn,v as yn,y as bn}from"./chat-input-container-Bc7nCdKX.js";import{n as xn,t as X}from"./use-toast-BF5WtiOJ.js";import{t as Sn}from"./standard-list-item-0m99qNoa.js";import{a as Cn,c as wn,i as Tn,n as En,o as Dn,r as On,s as kn,t as An}from"./alert-dialog-DAJFcjdR.js";import{t as jn}from"./side-panel-container-Cg99BH1l.js";import{t as Mn}from"./markdown-renderer-BPXg5AUu.js";import{n as Nn,t as Pn}from"./tab-context-BYpxvaoz.js";import{o as Fn,s as In}from"./onboarding-BPUo1aJX.js";import{n as Ln,t as Rn}from"./run-stop-button-DYoC8i6e.js";import{n as zn,t as Bn}from"./utils-CheqpoJ4.js";import{i as Vn,n as Hn,r as Un,t as Wn}from"./tabs-ywSKq3qp.js";import{t as Gn}from"./page-toolbar-CU9dGLvm.js";import{n as Kn,r as qn,t as Jn}from"./resizable-AKojmHeo.js";import{t as Yn}from"./use-font-size-D2A0_bAi.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(bt(),1),Xn=jt(),Q=_e(),Zn=1e10,Qn=1e3;function $n(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 er(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=Qn}=e;e.transport&&i(e.transport),e.requestHandler&&a(e.requestHandler),e._debugHooks&&(t=e._debugHooks);let s=0;function c(){return s<=Zn?++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 $n([`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 $n([`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 $n([`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 $n([`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 tr(e,t){let n=er({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 nr=window.__electrobunWebviewId,rr=window.__electrobunRpcSocketPort,ir=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:${rr}/socket?webviewId=${nr}`);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 tr(`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))}})}})}},$=y();function ar(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)(me,{children:[(0,$.jsx)(J,{children:`Send Feedback`}),(0,$.jsx)(it,{children:`Share feedback about Tarsk.`})]}),t[0]=p):p=t[0];let m;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(w,{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 _=d||u,v;t[4]!==i||t[5]!==g||t[6]!==_?(v=(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[m,(0,$.jsx)(q,{id:`feedback-name`,value:i,onChange:g,placeholder:`Your name`,disabled:_})]}),t[4]=i,t[5]=g,t[6]=_,t[7]=v):v=t[7];let y;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(w,{htmlFor:`feedback-email`,children:`Email`}),t[8]=y):y=t[8];let b;t[9]===s?b=t[10]:(b=e=>s(e.target.value),t[9]=s,t[10]=b);let S=d||u,C;t[11]!==o||t[12]!==b||t[13]!==S?(C=(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[y,(0,$.jsx)(q,{id:`feedback-email`,type:`email`,value:o,onChange:b,placeholder:`you@example.com`,disabled:S})]}),t[11]=o,t[12]=b,t[13]=S,t[14]=C):C=t[14];let T;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(w,{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 D;t[18]!==c||t[19]!==d||t[20]!==E?(D=(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[T,(0,$.jsx)(Yt,{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]=D):D=t[21];let O;t[22]!==D||t[23]!==v||t[24]!==C?(O=(0,$.jsxs)(`div`,{className:`grid gap-4 py-2`,children:[v,C,D]}),t[22]=D,t[23]=v,t[24]=C,t[25]=O):O=t[25];let k;t[26]===r?k=t[27]:(k=()=>r(!1),t[26]=r,t[27]=k);let A;t[28]!==d||t[29]!==k?(A=(0,$.jsx)(h,{variant:`outline`,onClick:k,disabled:d,children:`Cancel`}),t[28]=d,t[29]=k,t[30]=A):A=t[30];let M;t[31]===d?M=t[32]:(M=d?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(se,{className:`mr-2 h-4 w-4 animate-spin`}),`Sending...`]}):`Send Feedback`,t[31]=d,t[32]=M);let N;t[33]!==f||t[34]!==d||t[35]!==M?(N=(0,$.jsx)(h,{onClick:f,disabled:d,children:M}),t[33]=f,t[34]=d,t[35]=M,t[36]=N):N=t[36];let F;t[37]!==A||t[38]!==N?(F=(0,$.jsxs)(j,{children:[A,N]}),t[37]=A,t[38]=N,t[39]=F):F=t[39];let I;t[40]!==O||t[41]!==F?(I=(0,$.jsxs)(P,{className:`max-w-xl`,children:[p,O,F]}),t[40]=O,t[41]=F,t[42]=I):I=t[42];let L;return t[43]!==r||t[44]!==n||t[45]!==I?(L=(0,$.jsx)(x,{open:n,onOpenChange:r,children:I}),t[43]=r,t[44]=n,t[45]=I,t[46]=L):L=t[46],L}function or(){let[e,t]=(0,Z.useState)(!1),[n,r]=(0,Z.useState)(``),[i,a]=(0,Z.useState)(``),[o,s]=(0,Z.useState)(``),[c,l]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(!1);return(0,Z.useEffect)(()=>{if(!e)return;let t=!0;return l(!0),Ie().then(e=>{t&&(r(t=>t||e.name),a(t=>t||e.email))}).catch(()=>{t&&X({title:`Could not load git details`,description:`You can still submit feedback by entering your name and email manually.`,variant:`destructive`})}).finally(()=>{t&&l(!1)}),()=>{t=!1}},[e]),{showFeedback:e,feedbackName:n,setFeedbackName:r,feedbackEmail:i,setFeedbackEmail:a,feedbackText:o,setFeedbackText:s,loadingFeedbackUser:c,submittingFeedback:u,handleFeedbackDialogChange:e=>{t(e),e||s(``)},handleSubmitFeedback:async()=>{let e=o.trim();if(!e){X({title:`Feedback required`,description:`Please enter your feedback before submitting.`,variant:`destructive`});return}d(!0);try{await L(`api/feedback`,{name:n.trim(),email:i.trim(),feedback:e}),X({title:`Feedback sent`,description:`Thanks for sharing your feedback.`}),s(``),t(!1)}catch(e){X({title:`Failed to send feedback`,description:e instanceof Error?e.message:`Please try again.`,variant:`destructive`})}finally{d(!1)}}}}function sr(e){let t=(0,Q.c)(80),{projects:n,selectedThreadId:r,selectedProjectId:i,processingThreadIds:a,completedThreadIds:s,deletingThreadIds:c,deletingProjectIds:l,onSelectThread:u,onCreateProject:d,onCreateThread:p,onDeleteThread:m,onDeleteProject:g,onDeselect:_,collapsed:v,updateAvailable:y,updatingApp:b,onUpdateApp:x,expandProjectId:S}=e,C=Tt(),{showFeedback:w,feedbackName:T,setFeedbackName:E,feedbackEmail:D,setFeedbackEmail:O,feedbackText:k,setFeedbackText:j,loadingFeedbackUser:M,submittingFeedback:N,handleFeedbackDialogChange:P,handleSubmitFeedback:F}=or(),I;t[0]===n?I=t[1]:(I=n.map(cr),t[0]=n,t[1]=I);let L=I,ee;t[2]!==v||t[3]!==d?(ee=!v&&(0,$.jsxs)(h,{variant:`outline`,size:`sm`,className:`gap-2`,onClick:d,children:[(0,$.jsx)(pt,{className:`h-4 w-4 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:`New Project`})]}),t[2]=v,t[3]=d,t[4]=ee):ee=t[4];let R;t[5]!==v||t[6]!==x||t[7]!==y||t[8]!==b?(R=y&&(0,$.jsxs)(h,{variant:`ghost`,size:`sm`,className:`w-full justify-start gap-2 text-emerald-600 dark:text-emerald-400`,onClick:x,disabled:b,children:[b?(0,$.jsx)(se,{className:`h-4 w-4 animate-spin`}):(0,$.jsx)(A,{className:`h-4 w-4`}),!v&&(0,$.jsx)(`span`,{className:`truncate`,children:b?`Updating...`:`Update to Latest`})]}),t[5]=v,t[6]=x,t[7]=y,t[8]=b,t[9]=R):R=t[9];let z;t[10]===C?z=t[11]:(z=()=>void C(`/settings/general`),t[10]=C,t[11]=z);let B;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,$.jsx)(Xe,{className:`h-4 w-4`}),t[12]=B):B=t[12];let V;t[13]===v?V=t[14]:(V=!v&&(0,$.jsx)(`span`,{className:`truncate`,children:`Settings`}),t[13]=v,t[14]=V);let H;t[15]!==z||t[16]!==V?(H=(0,$.jsxs)(h,{variant:`ghost`,size:`sm`,className:`flex-1 justify-start gap-2 text-sidebar-foreground`,onClick:z,children:[B,V]}),t[15]=z,t[16]=V,t[17]=H):H=t[17];let U;t[18]===P?U=t[19]:(U=()=>P(!0),t[18]=P,t[19]=U);let te,W;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(W=(0,$.jsx)(f,{className:`h-4 w-4`}),te=(0,$.jsx)(`span`,{className:`sr-only`,children:`Feedback`}),t[20]=te,t[21]=W):(te=t[20],W=t[21]);let G;t[22]===U?G=t[23]:(G=(0,$.jsx)($t,{asChild:!0,children:(0,$.jsxs)(h,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground hover:text-background`,onClick:U,children:[W,te]})}),t[22]=U,t[23]=G);let ne;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(ne=(0,$.jsx)(Xt,{children:`Send feedback to the Tarsk team`}),t[24]=ne):ne=t[24];let re;t[25]===G?re=t[26]:(re=(0,$.jsx)(Zt,{children:(0,$.jsxs)(Qt,{children:[G,ne]})}),t[25]=G,t[26]=re);let ie;t[27]!==re||t[28]!==H?(ie=(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[H,re]}),t[27]=re,t[28]=H,t[29]=ie):ie=t[29];let ae;t[30]!==ie||t[31]!==R?(ae=(0,$.jsxs)(`div`,{className:`px-3 py-2 flex flex-col gap-1`,children:[R,ie]}),t[30]=ie,t[31]=R,t[32]=ae):ae=t[32];let oe;t[33]===n.length?oe=t[34]:(oe=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]=oe);let ce;t[35]===S?ce=t[36]:(ce=S?[S]:void 0,t[35]=S,t[36]=ce);let le;t[37]!==s||t[38]!==l||t[39]!==c||t[40]!==C||t[41]!==p||t[42]!==g||t[43]!==m||t[44]!==u||t[45]!==a||t[46]!==n||t[47]!==i||t[48]!==r?(le=(e,t)=>{let{isOpen:d,toggle:f}=t;return e.kind===`project`?(0,$.jsx)(lr,{project:e.project,isOpen:d,onToggle:f,isDeletingProject:l.includes(e.project.projectId),isSelected:i?e.project.projectId===i:!1,onCreateThread:p,onDeleteProject:g,onProjectSettings:e=>void C(`/settings/project/${e}`),hasSelectedThread:e.project.threads.some(e=>e.threadId===r)}):(0,$.jsx)(ur,{thread:e.thread,projectId:e.projectId,selectedThreadId:r,isProcessing:a.includes(e.thread.threadId),isDeleting:c.includes(e.thread.threadId),isCompleted:s.includes(e.thread.threadId),projectTitlePrefix:`${o(n.find(t=>t.projectId===e.projectId))} - `,onSelectThread:u,onDeleteThread:m})},t[37]=s,t[38]=l,t[39]=c,t[40]=C,t[41]=p,t[42]=g,t[43]=m,t[44]=u,t[45]=a,t[46]=n,t[47]=i,t[48]=r,t[49]=le):le=t[49];let ue;t[50]!==L||t[51]!==ce||t[52]!==le?(ue=(0,$.jsx)(nn,{nodes:L,defaultOpen:!0,forceOpenIds:ce,childContainerClassName:`ml-4 border-l border-sidebar-border pl-2`,renderNode:le}),t[50]=L,t[51]=ce,t[52]=le,t[53]=ue):ue=t[53];let K;t[54]!==oe||t[55]!==ue?(K=(0,$.jsx)(Ct,{className:`flex-1 w-full`,children:(0,$.jsxs)(`div`,{className:`px-2 py-2 w-full max-w-full overflow-hidden`,children:[oe,ue]})}),t[54]=oe,t[55]=ue,t[56]=K):K=t[56];let q;t[57]!==v||t[58]!==_||t[59]!==ae||t[60]!==ee||t[61]!==K?(q=(0,$.jsx)(jn,{collapsed:v,onLogoClick:_,headerAction:ee,footer:ae,children:K}),t[57]=v,t[58]=_,t[59]=ae,t[60]=ee,t[61]=K,t[62]=q):q=t[62];let de;t[63]===F?de=t[64]:(de=()=>void F(),t[63]=F,t[64]=de);let fe;t[65]!==D||t[66]!==T||t[67]!==k||t[68]!==P||t[69]!==M||t[70]!==O||t[71]!==E||t[72]!==j||t[73]!==w||t[74]!==N||t[75]!==de?(fe=(0,$.jsx)(ar,{open:w,onOpenChange:P,feedbackName:T,onFeedbackNameChange:E,feedbackEmail:D,onFeedbackEmailChange:O,feedbackText:k,onFeedbackTextChange:j,loadingFeedbackUser:M,submittingFeedback:N,onSubmit:de}),t[65]=D,t[66]=T,t[67]=k,t[68]=P,t[69]=M,t[70]=O,t[71]=E,t[72]=j,t[73]=w,t[74]=N,t[75]=de,t[76]=fe):fe=t[76];let J;return t[77]!==q||t[78]!==fe?(J=(0,$.jsxs)($.Fragment,{children:[q,fe]}),t[77]=q,t[78]=fe,t[79]=J):J=t[79],J}function cr(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 lr(e){let t=(0,Q.c)(29),{project:n,isOpen:r,onToggle:i,isDeletingProject:a,hasSelectedThread:s,isSelected:c,onCreateThread:l,onDeleteProject:u,onProjectSettings:d}=e,f;t[0]===n?f=t[1]:(f=o(n),t[0]=n,t[1]=f);let p=f,m=s||c,g=r&&`rotate-90`,_;t[2]===g?_=t[3]:(_=H(`h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform`,g),t[2]=g,t[3]=_);let v;t[4]===_?v=t[5]:(v=(0,$.jsx)(Qe,{className:_}),t[4]=_,t[5]=v);let y;t[6]===n.gitUrl?y=t[7]:(y=n.gitUrl?(0,$.jsx)(K,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}):(0,$.jsx)(St,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}),t[6]=n.gitUrl,t[7]=y);let b=(s||c)&&`font-bold text-foreground`,x;t[8]===b?x=t[9]:(x=H(`min-w-0 truncate transition-all block`,b),t[8]=b,t[9]=x);let S;t[10]!==p||t[11]!==x?(S=(0,$.jsx)(`span`,{className:x,children:p}),t[10]=p,t[11]=x,t[12]=S):S=t[12];let C;t[13]!==v||t[14]!==y||t[15]!==S?(C=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1.5 w-0`,children:[v,y,S]}),t[13]=v,t[14]=y,t[15]=S,t[16]=C):C=t[16];let w;t[17]!==a||t[18]!==l||t[19]!==u||t[20]!==d||t[21]!==n.projectId||t[22]!==n.threads?(w=(0,$.jsx)(`div`,{className:`flex shrink-0 items-center ml-auto`,children:a?(0,$.jsx)(se,{className:`h-3.5 w-3.5 shrink-0 animate-spin text-muted-foreground mr-1`}):(0,$.jsxs)(Zt,{children:[(0,$.jsxs)(Qt,{children:[(0,$.jsx)($t,{asChild:!0,children:(0,$.jsxs)(h,{variant:`ghost`,size:`icon`,className:`h-7 w-7 shrink-0 hidden group-hover:flex items-center justify-center`,onClick:e=>{e.stopPropagation(),d(n.projectId)},children:[(0,$.jsx)(Xe,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Project settings`})]})}),(0,$.jsx)(Xt,{side:`right`,children:`Project settings`})]}),(0,$.jsxs)(Qt,{children:[(0,$.jsx)($t,{asChild:!0,children:(0,$.jsxs)(h,{variant:`action`,size:`icon-sm`,className:`shrink-0 hidden group-hover:flex items-center justify-center`,onClick:e=>{e.stopPropagation(),l(n.projectId)},children:[(0,$.jsx)(pt,{}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Add thread`})]})}),(0,$.jsx)(Xt,{side:`right`,children:`Add thread`})]}),n.threads.length===0&&(0,$.jsxs)(Qt,{children:[(0,$.jsx)($t,{asChild:!0,children:(0,$.jsxs)(h,{variant:`ghost`,size:`icon-sm`,className:`shrink-0 hidden group-hover:flex items-center justify-center text-muted-foreground hover:bg-destructive hover:text-destructive-foreground transition-colors`,onClick:e=>{e.stopPropagation(),u(n.projectId)},children:[(0,$.jsx)(at,{}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Delete project`})]})}),(0,$.jsx)(Xt,{side:`right`,children:`Delete project`})]})]})}),t[17]=a,t[18]=l,t[19]=u,t[20]=d,t[21]=n.projectId,t[22]=n.threads,t[23]=w):w=t[23];let T;return t[24]!==i||t[25]!==C||t[26]!==w||t[27]!==m?(T=(0,$.jsxs)(Sn,{selected:m,noBackground:!0,className:`mb-1 h-9`,onClick:i,children:[C,w]}),t[24]=i,t[25]=C,t[26]=w,t[27]=m,t[28]=T):T=t[28],T}function ur(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,g,_;t[0]===a?(g=t[1],_=t[2]):(g=()=>{a&&p.current&&p.current.scrollIntoView({behavior:`smooth`,block:`nearest`})},_=[a],t[0]=a,t[1]=g,t[2]=_),(0,Z.useEffect)(g,_);let v;t[3]!==u||t[4]!==r||t[5]!==n.gitStatusDot||t[6]!==n.threadId?(v=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]=v):v=t[7];let y=v,b;t[8]!==c||t[9]!==n.threadId||t[10]!==n.title?(b=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]=b):b=t[11];let x=b,S;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,$.jsx)(wn,{children:`Delete Thread`}),t[12]=S):S=t[12];let C;t[13]===x?C=t[14]:(C=(0,$.jsxs)(Cn,{children:[`Are you sure you want to delete "`,x,`" and all its files? This action cannot be undone.`]}),t[13]=x,t[14]=C);let w;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(On,{children:`Cancel`}),t[15]=w):w=t[15];let T;t[16]!==u||t[17]!==r||t[18]!==n.threadId?(T=(0,$.jsxs)(`div`,{className:`flex gap-3 justify-end`,children:[w,(0,$.jsx)(En,{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]=T):T=t[19];let E;t[20]!==C||t[21]!==T?(E=(0,$.jsxs)(Tn,{children:[S,C,T]}),t[20]=C,t[21]=T,t[22]=E):E=t[22];let D;t[23]!==d||t[24]!==E?(D=(0,$.jsx)(An,{open:d,onOpenChange:f,children:E}),t[23]=d,t[24]=E,t[25]=D):D=t[25];let O,k;t[26]!==l||t[27]!==r||t[28]!==n.threadId?(O=()=>l(r,n.threadId),k=e=>{(e.key===`Enter`||e.key===` `)&&l(r,n.threadId)},t[26]=l,t[27]=r,t[28]=n.threadId,t[29]=O,t[30]=k):(O=t[29],k=t[30]);let A;t[31]===n.gitStatusDot?A=t[32]:(A=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]=A);let j;t[33]===x?j=t[34]:(j=(0,$.jsx)(`div`,{className:`flex-1 min-w-0 w-0`,children:(0,$.jsx)(`span`,{className:`text-sm truncate block`,children:x})}),t[33]=x,t[34]=j);let M;t[35]!==y||t[36]!==s||t[37]!==o||t[38]!==a?(M=a||o?(0,$.jsx)(se,{className:`ml-auto h-3 w-3 shrink-0 animate-spin text-muted-foreground`}):s?(0,$.jsx)(Ge,{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)(Qt,{children:[(0,$.jsx)($t,{asChild:!0,children:(0,$.jsxs)(h,{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:y,children:[(0,$.jsx)(at,{}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Delete thread`})]})}),(0,$.jsx)(Xt,{side:`right`,children:`Delete thread and files from the repo`})]})}),t[35]=y,t[36]=s,t[37]=o,t[38]=a,t[39]=M):M=t[39];let N;t[40]!==m||t[41]!==O||t[42]!==k||t[43]!==A||t[44]!==j||t[45]!==M?(N=(0,$.jsxs)(Sn,{ref:p,selected:m,onClick:O,onKeyDown:k,role:`button`,tabIndex:0,children:[A,j,M]}),t[40]=m,t[41]=O,t[42]=k,t[43]=A,t[44]=j,t[45]=M,t[46]=N):N=t[46];let P;return t[47]!==D||t[48]!==N?(P=(0,$.jsxs)($.Fragment,{children:[D,N]}),t[47]=D,t[48]=N,t[49]=P):P=t[49],P}function dr(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 fr(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 pr(e){return typeof e==`string`?e:typeof e==`object`&&e?JSON.stringify(e,null,2):String(e)}function mr(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 hr(e){if(typeof e!=`object`||!e)return e;if(Array.isArray(e))return e.map(hr);let t={};for(let[n,r]of Object.entries(e))if(typeof r==`string`){let e=mr(r);t[n]=typeof e==`object`?hr(e):r}else t[n]=hr(r);return t}function gr(e){if(e==null||typeof e!=`string`)return``;let t=e;return t=t.replace(/\\\\n/g,`
|
|
3
|
+
`),t=t.replace(/\\\\"/g,`"`),t=t.replace(/\\n/g,`
|
|
4
|
+
`),t=t.replace(/\\"/g,`"`),t}function _r(e){if(e==null)return``;let t=typeof e==`object`&&e?hr(e):e;return gr(typeof t==`string`?t:t==null?``:JSON.stringify(t,null,2))}function vr(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:fr(pr(i),t),d=fr(o?String(i.prompt):null,t),f=fr(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=fr(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=n.charAt(0).toUpperCase()+n.slice(1);S===`bash`&&(M=`Ran`),S===`code_search`&&(M=`Code Search`),S===`generate_image`&&(M=`Make Image`),S.includes(`read`)&&(b!==null||x!==null)&&(b!==null&&x!==null?M+=` (lines ${b} to ${b+x})`:b===null?M+=` (${x} lines)`:M+=` (from line ${b})`);let N=`default`;return S===`bash`||S.includes(`terminal`)||S.includes(`shell`)?N=`bash`:C?N=`file`:h||S===`find`||S.includes(`search`)||S.includes(`grep`)?N=`search`:S===`agent`||S.includes(`subagent`)||o?N=`agent`:S===`todo`?N=`todo`:S===`generate_image`&&(N=`imageGen`),{toolType:N,toolName:n,toolId:r,displayName:M,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 yr(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)(me,{children:(0,$.jsx)(J,{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-sm 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)(P,{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)(x,{open:n,onOpenChange:r,children:c}),t[7]=r,t[8]=n,t[9]=c,t[10]=l):l=t[10],l}function br(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(`
|
|
5
|
+
`),s=r.split(`
|
|
6
|
+
`);i=`text-sm font-mono whitespace-pre-wrap overflow-auto`,a=e.map(Sr),o=s.map(xr),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 xr(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 Sr(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 Cr(e){let t=(0,Q.c)(2),{name:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(`span`,{className:`text-sm px-1.5 py-0.5 rounded bg-muted text-muted-foreground font-mono`,children:n}),t[0]=n,t[1]=r),r}function wr(e){let t=(0,Q.c)(2),{type:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(`span`,{className:`text-sm px-2 py-0.5 rounded bg-muted text-muted-foreground`,children:n}),t[0]=n,t[1]=r),r}function Tr(e){let t=(0,Q.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(`code`,{className:`text-sm 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}var Er=9,Dr=100;function Or(e){let t=(0,Q.c)(6),{className:n,size:r}=e,i=(r===void 0?`sm`:r)===`sm`?`h-3.5 w-3.5`:`h-4 w-4`,a;t[0]!==n||t[1]!==i?(a=H(`grid shrink-0 grid-cols-3 gap-px`,i,n),t[0]=n,t[1]=i,t[2]=a):a=t[2];let o;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=Array.from({length:Er},kr),t[3]=o):o=t[3];let s;return t[4]===a?s=t[5]:(s=(0,$.jsx)(`div`,{className:a,"aria-hidden":!0,children:o}),t[4]=a,t[5]=s),s}function kr(e,t){return(0,$.jsx)(`div`,{className:`rounded-[0.5px] bg-brand animate-tool-grid-pulse`,style:{animationDelay:`${t*Dr}ms`}},t)}function Ar(e){let t=(0,Q.c)(15),{toolName:n,displayName:r,isActive:i,muted:a,size:o,className:s}=e,c=a===void 0?!0:a,l=o===void 0?`sm`:o,u;t[0]===s?u=t[1]:(u=H(`inline-flex items-center gap-1`,s),t[0]=s,t[1]=u);let d;t[2]!==i||t[3]!==l?(d=i&&(0,$.jsx)(Or,{size:l}),t[2]=i,t[3]=l,t[4]=d):d=t[4];let f=c?`text-muted-foreground`:void 0,p;t[5]===f?p=t[6]:(p=H(`text-sm`,f),t[5]=f,t[6]=p);let m;t[7]!==r||t[8]!==p?(m=(0,$.jsx)(`span`,{className:p,children:r}),t[7]=r,t[8]=p,t[9]=m):m=t[9];let h;return t[10]!==u||t[11]!==d||t[12]!==m||t[13]!==n?(h=(0,$.jsxs)(`span`,{title:n,className:u,children:[d,m]}),t[10]=u,t[11]=d,t[12]=m,t[13]=n,t[14]=h):h=t[14],h}function jr(e){let t=(0,Q.c)(50),{data:n,inline:r,resultContent:i,isActive:a}=e,[o,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(!1);if(r){if(n.command!==null&&i){let e;t[0]!==n.displayName||t[1]!==n.toolName||t[2]!==a?(e=(0,$.jsx)(Ar,{toolName:n.toolName,displayName:n.displayName,isActive:a}),t[0]=n.displayName,t[1]=n.toolName,t[2]=a,t[3]=e):e=t[3];let r;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>l(!0),t[4]=r):r=t[4];let o;t[5]===n.command?o=t[6]:(o=(0,$.jsx)($t,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:r,className:`text-sm font-mono text-muted-foreground hover:underline break-all cursor-pointer`,children:n.command})}),t[5]=n.command,t[6]=o);let s;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(Xt,{children:`View output`}),t[7]=s):s=t[7];let u;t[8]===o?u=t[9]:(u=(0,$.jsxs)(Qt,{children:[o,s]}),t[8]=o,t[9]=u);let d;t[10]!==e||t[11]!==u?(d=(0,$.jsxs)(`div`,{className:`py-0.5 flex items-center gap-2 flex-wrap`,children:[e,u]}),t[10]=e,t[11]=u,t[12]=d):d=t[12];let f;t[13]!==n.command||t[14]!==c||t[15]!==i?(f=(0,$.jsx)(yr,{open:c,onOpenChange:l,title:n.command,content:i}),t[13]=n.command,t[14]=c,t[15]=i,t[16]=f):f=t[16];let p;return t[17]!==d||t[18]!==f?(p=(0,$.jsxs)($.Fragment,{children:[d,f]}),t[17]=d,t[18]=f,t[19]=p):p=t[19],p}let e;t[20]!==n.displayName||t[21]!==n.toolName||t[22]!==a?(e=(0,$.jsx)(Ar,{toolName:n.toolName,displayName:n.displayName,isActive:a}),t[20]=n.displayName,t[21]=n.toolName,t[22]=a,t[23]=e):e=t[23];let r;t[24]===n.command?r=t[25]:(r=n.command!==null&&(0,$.jsx)(`code`,{className:`text-sm font-mono text-muted-foreground break-all rounded bg-muted/60 px-1 py-0.5`,children:n.command}),t[24]=n.command,t[25]=r);let o;return t[26]!==e||t[27]!==r?(o=(0,$.jsxs)(`div`,{className:`py-0.5 flex items-center gap-2 flex-wrap`,children:[e,r]}),t[26]=e,t[27]=r,t[28]=o):o=t[28],o}let u;t[29]===o?u=t[30]:(u=()=>s(!o),t[29]=o,t[30]=u);let d;t[31]===a?d=t[32]:(d=a&&(0,$.jsx)(Or,{size:`md`}),t[31]=a,t[32]=d);let f;t[33]===n.displayName?f=t[34]:(f=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:n.displayName}),t[33]=n.displayName,t[34]=f);let p;t[35]===o?p=t[36]:(p=o?(0,$.jsx)(we,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(Qe,{className:`h-4 w-4 shrink-0`}),t[35]=o,t[36]=p);let m;t[37]!==n.toolName||t[38]!==u||t[39]!==d||t[40]!==f||t[41]!==p?(m=(0,$.jsxs)(`button`,{onClick:u,className:`w-full py-2 flex items-center gap-2 text-sm font-medium text-foreground hover:bg-muted/50 transition-colors text-left`,title:n.toolName,children:[d,f,p]}),t[37]=n.toolName,t[38]=u,t[39]=d,t[40]=f,t[41]=p,t[42]=m):m=t[42];let h;t[43]!==n.toolId||t[44]!==n.toolInput||t[45]!==o?(h=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-sm 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[43]=n.toolId,t[44]=n.toolInput,t[45]=o,t[46]=h):h=t[46];let g;return t[47]!==m||t[48]!==h?(g=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[m,h]}),t[47]=m,t[48]=h,t[49]=g):g=t[49],g}function Mr(e){let t=(0,Q.c)(45),{data:n,inline:r,rootPath:i,onOpenFile:a,isActive:o}=e,[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(!1),d;t[0]!==n.filePath||t[1]!==a||t[2]!==i?(d=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]=d):d=t[3];let f=d;if(r){let e=!!(n.toolInput&&!n.command&&!n.path&&!n.pattern&&!n.fileDisplayName),r;t[4]!==n.displayName||t[5]!==n.toolId||t[6]!==n.toolInput||t[7]!==n.toolName||t[8]!==e||t[9]!==o?(r=e?(0,$.jsxs)(en,{children:[(0,$.jsx)(bn,{asChild:!0,children:(0,$.jsx)(`span`,{title:n.toolName,className:`inline-flex`,children:(0,$.jsx)(`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,$.jsx)(Ar,{toolName:n.toolName,displayName:n.displayName,isActive:o,muted:!1})})})}),(0,$.jsx)(yn,{className:`w-80 max-h-80 overflow-auto`,align:`start`,children:(0,$.jsxs)(`div`,{className:`text-sm 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,$.jsx)(Ar,{toolName:n.toolName,displayName:n.displayName,isActive:o}),t[4]=n.displayName,t[5]=n.toolId,t[6]=n.toolInput,t[7]=n.toolName,t[8]=e,t[9]=o,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]!==l||t[18]!==f||t[19]!==i?(a=n.fileDisplayName?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(Qt,{children:[(0,$.jsx)($t,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:n.hasEditDiff?()=>u(!0):f,className:H(`text-sm font-mono truncate max-w-[200px] sm:max-w-[320px] cursor-pointer`,`text-muted-foreground hover:underline`),children:n.fileDisplayName})}),(0,$.jsx)(Xt,{children:n.hasEditDiff?`View diff`:n.filePath?fr(n.filePath,i)??n.filePath:n.fileDisplayName})]}),n.hasEditDiff&&(0,$.jsx)(x,{open:l,onOpenChange:u,children:(0,$.jsxs)(P,{className:`max-w-2xl h-[80vh] flex flex-col`,children:[(0,$.jsx)(me,{children:(0,$.jsx)(J,{children:(0,$.jsx)(`code`,{className:`text-sm font-mono`,children:fr(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)(br,{oldText:n.editOldText,newText:n.editNewText})})]})})]}):n.path===null?null:(0,$.jsx)(`span`,{className:`text-sm 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]=l,t[18]=f,t[19]=i,t[20]=a):a=t[20];let s;return t[21]!==r||t[22]!==a?(s=(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]=s):s=t[23],s}let p;t[24]===s?p=t[25]:(p=()=>c(!s),t[24]=s,t[25]=p);let m;t[26]===o?m=t[27]:(m=o&&(0,$.jsx)(Or,{size:`md`}),t[26]=o,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]===s?g=t[31]:(g=s?(0,$.jsx)(we,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(Qe,{className:`h-4 w-4 shrink-0`}),t[30]=s,t[31]=g);let _;t[32]!==n.toolName||t[33]!==p||t[34]!==m||t[35]!==h||t[36]!==g?(_=(0,$.jsxs)(`button`,{onClick:p,className:`w-full py-2 flex items-center gap-2 text-sm font-medium text-foreground hover:bg-muted/50 transition-colors text-left`,title:n.toolName,children:[m,h,g]}),t[32]=n.toolName,t[33]=p,t[34]=m,t[35]=h,t[36]=g,t[37]=_):_=t[37];let v;t[38]!==n.toolId||t[39]!==n.toolInput||t[40]!==s?(v=s&&(0,$.jsxs)(`div`,{className:`py-2 border-t border-border`,children:[(0,$.jsxs)(`div`,{className:`text-xs text-muted-foreground mb-2 font-mono`,children:[`ID: `,n.toolId]}),n.toolInput?(0,$.jsx)(`pre`,{className:`text-sm 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]=s,t[41]=v):v=t[41];let y;return t[42]!==_||t[43]!==v?(y=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[_,v]}),t[42]=_,t[43]=v,t[44]=y):y=t[44],y}function Nr(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)(Tr,{children:n.codeSearchQuery}),n.pattern!==null&&(0,$.jsxs)(Tr,{children:[`/`,n.pattern,`/`]}),n.codeSearchFilePath!==null&&(0,$.jsx)(Tr,{children:n.codeSearchFilePath}),n.codeSearchFileGlob!==null&&(0,$.jsx)(Tr,{children:n.codeSearchFileGlob})]}):n.pattern!==null&&(0,$.jsx)(Tr,{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 Pr(e){let t=(0,Q.c)(62),{data:n,inline:r,resultContent:i,isActive:a}=e,[o,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(!1),u=n.toolName===`code_search`,d=n.codeSearchQuery??n.pattern??n.codeSearchFilePath??n.codeSearchFileGlob??`search`;if(r){if(i&&(u||n.toolName===`find`||n.pattern!==null)){let e;t[0]!==n.displayName||t[1]!==n.toolName||t[2]!==a?(e=(0,$.jsx)(Ar,{toolName:n.toolName,displayName:n.displayName,isActive:a}),t[0]=n.displayName,t[1]=n.toolName,t[2]=a,t[3]=e):e=t[3];let r;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>l(!0),t[4]=r):r=t[4];let o;t[5]===d?o=t[6]:(o=(0,$.jsx)($t,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:r,className:`text-sm font-mono text-muted-foreground hover:underline break-all cursor-pointer`,children:d})}),t[5]=d,t[6]=o);let s;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(Xt,{children:`View results`}),t[7]=s):s=t[7];let u;t[8]===o?u=t[9]:(u=(0,$.jsxs)(Qt,{children:[o,s]}),t[8]=o,t[9]=u);let f;t[10]!==e||t[11]!==u?(f=(0,$.jsxs)(`div`,{className:`py-0.5 flex items-center gap-2 flex-wrap`,children:[e,u]}),t[10]=e,t[11]=u,t[12]=f):f=t[12];let p;t[13]!==c||t[14]!==i||t[15]!==d?(p=(0,$.jsx)(yr,{open:c,onOpenChange:l,title:d,content:i}),t[13]=c,t[14]=i,t[15]=d,t[16]=p):p=t[16];let m;return t[17]!==f||t[18]!==p?(m=(0,$.jsxs)($.Fragment,{children:[f,p]}),t[17]=f,t[18]=p,t[19]=m):m=t[19],m}let e;t[20]!==n.displayName||t[21]!==n.toolName||t[22]!==a?(e=(0,$.jsx)(Ar,{toolName:n.toolName,displayName:n.displayName,isActive:a}),t[20]=n.displayName,t[21]=n.toolName,t[22]=a,t[23]=e):e=t[23];let r;t[24]===n?r=t[25]:(r=(0,$.jsx)(Nr,{data:n}),t[24]=n,t[25]=r);let o;t[26]===n.lang?o=t[27]:(o=n.lang!==null&&(0,$.jsx)(`span`,{className:`text-sm px-1.5 py-0.5 rounded bg-muted text-muted-foreground`,children:n.lang}),t[26]=n.lang,t[27]=o);let s;return t[28]!==e||t[29]!==r||t[30]!==o?(s=(0,$.jsxs)(`div`,{className:`py-0.5 flex items-center gap-2 flex-wrap`,children:[e,r,o]}),t[28]=e,t[29]=r,t[30]=o,t[31]=s):s=t[31],s}let f;t[32]===o?f=t[33]:(f=()=>s(!o),t[32]=o,t[33]=f);let p;t[34]===a?p=t[35]:(p=a&&(0,$.jsx)(Or,{size:`md`}),t[34]=a,t[35]=p);let m;t[36]===n.displayName?m=t[37]:(m=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:n.displayName}),t[36]=n.displayName,t[37]=m);let h;t[38]!==n.codeSearchFileGlob||t[39]!==n.codeSearchFilePath||t[40]!==n.codeSearchQuery||t[41]!==n.pattern||t[42]!==u?(h=u&&(0,$.jsxs)($.Fragment,{children:[n.codeSearchQuery!==null&&(0,$.jsx)(`code`,{className:`text-sm 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-sm 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-sm 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-sm font-mono bg-muted text-muted-foreground rounded px-1 py-0.5 truncate max-w-[150px]`,children:n.codeSearchFileGlob})]}),t[38]=n.codeSearchFileGlob,t[39]=n.codeSearchFilePath,t[40]=n.codeSearchQuery,t[41]=n.pattern,t[42]=u,t[43]=h):h=t[43];let g;t[44]===o?g=t[45]:(g=o?(0,$.jsx)(we,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(Qe,{className:`h-4 w-4 shrink-0`}),t[44]=o,t[45]=g);let _;t[46]!==n.toolName||t[47]!==f||t[48]!==p||t[49]!==m||t[50]!==h||t[51]!==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:n.toolName,children:[p,m,h,g]}),t[46]=n.toolName,t[47]=f,t[48]=p,t[49]=m,t[50]=h,t[51]=g,t[52]=_):_=t[52];let v;t[53]!==n.toolId||t[54]!==n.toolInput||t[55]!==o||t[56]!==u||t[57]!==i?(v=o&&(0,$.jsxs)(`div`,{className:`py-2 border-t border-border`,children:[(0,$.jsxs)(`div`,{className:`text-xs text-muted-foreground mb-2 font-mono`,children:[`ID: `,n.toolId]}),n.toolInput?(0,$.jsx)(`pre`,{className:`text-sm bg-slate-100 dark:bg-slate-900 p-2 rounded font-mono whitespace-pre-wrap overflow-auto max-h-48`,children:n.toolInput}):null,u&&i&&(0,$.jsx)(`pre`,{className:`text-sm 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[53]=n.toolId,t[54]=n.toolInput,t[55]=o,t[56]=u,t[57]=i,t[58]=v):v=t[58];let y;return t[59]!==_||t[60]!==v?(y=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[_,v]}),t[59]=_,t[60]=v,t[61]=y):y=t[61],y}function Fr(e){let t=(0,Q.c)(54),{data:n,inline:r,isActive:i}=e,[a,o]=(0,Z.useState)(!1);if(r){let e;t[0]!==n.displayName||t[1]!==n.toolName||t[2]!==i?(e=(0,$.jsx)(`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,$.jsx)(Ar,{toolName:n.toolName,displayName:n.displayName,isActive:i,muted:!1})}),t[0]=n.displayName,t[1]=n.toolName,t[2]=i,t[3]=e):e=t[3];let r;t[4]!==n.toolName||t[5]!==e?(r=(0,$.jsx)(bn,{asChild:!0,children:(0,$.jsx)(`span`,{title:n.toolName,className:`inline-flex`,children:e})}),t[4]=n.toolName,t[5]=e,t[6]=r):r=t[6];let a;t[7]===n.toolId?a=t[8]:(a=(0,$.jsxs)(`div`,{className:`font-mono`,children:[`ID: `,n.toolId]}),t[7]=n.toolId,t[8]=a);let o;t[9]!==n.prompt||t[10]!==n.toolInput?(o=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[9]=n.prompt,t[10]=n.toolInput,t[11]=o):o=t[11];let s;t[12]!==a||t[13]!==o?(s=(0,$.jsx)(yn,{className:`w-80 max-h-80 overflow-auto`,align:`start`,children:(0,$.jsxs)(`div`,{className:`text-sm text-muted-foreground space-y-2`,children:[a,o]})}),t[12]=a,t[13]=o,t[14]=s):s=t[14];let c;t[15]!==r||t[16]!==s?(c=(0,$.jsxs)(en,{children:[r,s]}),t[15]=r,t[16]=s,t[17]=c):c=t[17];let l;t[18]===n.agentName?l=t[19]:(l=n.agentName&&(0,$.jsx)(Cr,{name:n.agentName}),t[18]=n.agentName,t[19]=l);let u;t[20]===n.subagentType?u=t[21]:(u=n.subagentType&&(0,$.jsx)(wr,{type:n.subagentType}),t[20]=n.subagentType,t[21]=u);let d;return t[22]!==c||t[23]!==l||t[24]!==u?(d=(0,$.jsxs)(`div`,{className:`py-0.5 flex items-center gap-2 flex-wrap`,children:[c,l,u]}),t[22]=c,t[23]=l,t[24]=u,t[25]=d):d=t[25],d}let s;t[26]===a?s=t[27]:(s=()=>o(!a),t[26]=a,t[27]=s);let c;t[28]===i?c=t[29]:(c=i&&(0,$.jsx)(Or,{size:`md`}),t[28]=i,t[29]=c);let l;t[30]===n.displayName?l=t[31]:(l=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:n.displayName}),t[30]=n.displayName,t[31]=l);let u;t[32]===n.agentName?u=t[33]:(u=n.agentName&&(0,$.jsx)(Cr,{name:n.agentName}),t[32]=n.agentName,t[33]=u);let d;t[34]===n.subagentType?d=t[35]:(d=n.subagentType&&(0,$.jsx)(wr,{type:n.subagentType}),t[34]=n.subagentType,t[35]=d);let f;t[36]===a?f=t[37]:(f=a?(0,$.jsx)(we,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(Qe,{className:`h-4 w-4 shrink-0`}),t[36]=a,t[37]=f);let p;t[38]!==n.toolName||t[39]!==s||t[40]!==c||t[41]!==l||t[42]!==u||t[43]!==d||t[44]!==f?(p=(0,$.jsxs)(`button`,{onClick:s,className:`w-full py-2 flex items-center gap-2 text-sm font-medium text-foreground hover:bg-muted/50 transition-colors text-left`,title:n.toolName,children:[c,l,u,d,f]}),t[38]=n.toolName,t[39]=s,t[40]=c,t[41]=l,t[42]=u,t[43]=d,t[44]=f,t[45]=p):p=t[45];let m;t[46]!==n.prompt||t[47]!==n.toolId||t[48]!==n.toolInput||t[49]!==a?(m=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.prompt?(0,$.jsx)(`div`,{className:`text-sm 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-sm 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[46]=n.prompt,t[47]=n.toolId,t[48]=n.toolInput,t[49]=a,t[50]=m):m=t[50];let h;return t[51]!==p||t[52]!==m?(h=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[p,m]}),t[51]=p,t[52]=m,t[53]=h):h=t[53],h}function Ir(e){let t=(0,Q.c)(21),{data:n,inline:r,isActive:i}=e,[a,o]=(0,Z.useState)(!1);if(r)return null;let s;t[0]===a?s=t[1]:(s=()=>o(!a),t[0]=a,t[1]=s);let c;t[2]===i?c=t[3]:(c=i&&(0,$.jsx)(Or,{size:`md`}),t[2]=i,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]===a?u=t[7]:(u=a?(0,$.jsx)(we,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(Qe,{className:`h-4 w-4 shrink-0`}),t[6]=a,t[7]=u);let d;t[8]!==n.toolName||t[9]!==s||t[10]!==c||t[11]!==l||t[12]!==u?(d=(0,$.jsxs)(`button`,{onClick:s,className:`w-full py-2 flex items-center gap-2 text-sm font-medium text-foreground hover:bg-muted/50 transition-colors text-left`,title:n.toolName,children:[c,l,u]}),t[8]=n.toolName,t[9]=s,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]!==a?(f=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-sm 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]=a,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 Lr(e){let t=(0,Q.c)(30),{data:n,inline:r,isActive:i}=e,[a,o]=(0,Z.useState)(!1);if(r){let e;t[0]!==n.displayName||t[1]!==n.toolName||t[2]!==i?(e=(0,$.jsx)(Ar,{toolName:n.toolName,displayName:n.displayName,isActive:i}),t[0]=n.displayName,t[1]=n.toolName,t[2]=i,t[3]=e):e=t[3];let r;t[4]===n.imageGenPrompt?r=t[5]:(r=n.imageGenPrompt!==null&&(0,$.jsx)(`span`,{className:`text-sm text-muted-foreground truncate max-w-[200px] sm:max-w-[320px]`,title:n.imageGenPrompt,children:n.imageGenPrompt}),t[4]=n.imageGenPrompt,t[5]=r);let a;return t[6]!==e||t[7]!==r?(a=(0,$.jsxs)(`div`,{className:`py-0.5 flex items-center gap-2 flex-wrap`,children:[e,r]}),t[6]=e,t[7]=r,t[8]=a):a=t[8],a}let s;t[9]===a?s=t[10]:(s=()=>o(!a),t[9]=a,t[10]=s);let c;t[11]===i?c=t[12]:(c=i&&(0,$.jsx)(Or,{size:`md`}),t[11]=i,t[12]=c);let l;t[13]===n.displayName?l=t[14]:(l=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:n.displayName}),t[13]=n.displayName,t[14]=l);let u;t[15]===a?u=t[16]:(u=a?(0,$.jsx)(we,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(Qe,{className:`h-4 w-4 shrink-0`}),t[15]=a,t[16]=u);let d;t[17]!==n.toolName||t[18]!==s||t[19]!==c||t[20]!==l||t[21]!==u?(d=(0,$.jsxs)(`button`,{onClick:s,className:`w-full py-2 flex items-center gap-2 text-sm font-medium text-foreground hover:bg-muted/50 transition-colors text-left`,title:n.toolName,children:[c,l,u]}),t[17]=n.toolName,t[18]=s,t[19]=c,t[20]=l,t[21]=u,t[22]=d):d=t[22];let f;t[23]!==n.toolId||t[24]!==n.toolInput||t[25]!==a?(f=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-sm 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[23]=n.toolId,t[24]=n.toolInput,t[25]=a,t[26]=f):f=t[26];let p;return t[27]!==d||t[28]!==f?(p=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[d,f]}),t[27]=d,t[28]=f,t[29]=p):p=t[29],p}function Rr(e){let t=(0,Q.c)(35),{data:n,inline:r,isActive:i}=e,[a,o]=(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.prompt||t[2]!==n.toolId||t[3]!==n.toolInput||t[4]!==n.toolName||t[5]!==e||t[6]!==i?(r=e?(0,$.jsxs)(en,{children:[(0,$.jsx)(bn,{asChild:!0,children:(0,$.jsx)(`span`,{title:n.toolName,className:`inline-flex`,children:(0,$.jsx)(`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,$.jsx)(Ar,{toolName:n.toolName,displayName:n.displayName,isActive:i,muted:!1})})})}),(0,$.jsx)(yn,{className:`w-80 max-h-80 overflow-auto`,align:`start`,children:(0,$.jsxs)(`div`,{className:`text-sm 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,$.jsx)(Ar,{toolName:n.toolName,displayName:n.displayName,isActive:i}),t[0]=n.displayName,t[1]=n.prompt,t[2]=n.toolId,t[3]=n.toolInput,t[4]=n.toolName,t[5]=e,t[6]=i,t[7]=r):r=t[7];let a;t[8]===n.path?a=t[9]:(a=n.path!==null&&(0,$.jsx)(`span`,{className:`text-sm 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]=a);let o;return t[10]!==r||t[11]!==a?(o=(0,$.jsxs)(`div`,{className:`py-0.5 flex items-center gap-2 flex-wrap`,children:[r,a]}),t[10]=r,t[11]=a,t[12]=o):o=t[12],o}let s;t[13]===a?s=t[14]:(s=()=>o(!a),t[13]=a,t[14]=s);let c;t[15]===i?c=t[16]:(c=i&&(0,$.jsx)(Or,{size:`md`}),t[15]=i,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]===a?u=t[20]:(u=a?(0,$.jsx)(we,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(Qe,{className:`h-4 w-4 shrink-0`}),t[19]=a,t[20]=u);let d;t[21]!==n.toolName||t[22]!==s||t[23]!==c||t[24]!==l||t[25]!==u?(d=(0,$.jsxs)(`button`,{onClick:s,className:`w-full py-2 flex items-center gap-2 text-sm font-medium text-foreground hover:bg-muted/50 transition-colors text-left`,title:n.toolName,children:[c,l,u]}),t[21]=n.toolName,t[22]=s,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]!==a?(f=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.prompt?(0,$.jsx)(`div`,{className:`text-sm 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-sm 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]=a,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 zr(e){let t=(0,Q.c)(41),{block:n,inline:r,resultContent:i,isActive:a}=e,{state:o}=zt(),{setPendingExplorerPath:s,setActiveMainTab:c}=Nn(),l;if(t[0]!==o.projects||t[1]!==o.selectedProjectId||t[2]!==o.selectedThreadId){let e;t[4]===o.selectedProjectId?e=t[5]:(e=e=>e.projectId===o.selectedProjectId,t[4]=o.selectedProjectId,t[5]=e),l=o.projects.find(e)?.threads.find(e=>e.threadId===o.selectedThreadId),t[0]=o.projects,t[1]=o.selectedProjectId,t[2]=o.selectedThreadId,t[3]=l}else l=t[3];let u=l?.path,d=vr(n,u),f=!!(a&&i===void 0),p;t[6]!==c||t[7]!==s?(p=function(e){s(e),c(`explorer`)},t[6]=c,t[7]=s,t[8]=p):p=t[8];let m=p;switch(d.toolType){case`bash`:{let e;return t[9]!==d||t[10]!==r||t[11]!==f||t[12]!==i?(e=(0,$.jsx)(jr,{data:d,inline:r,resultContent:i,isActive:f}),t[9]=d,t[10]=r,t[11]=f,t[12]=i,t[13]=e):e=t[13],e}case`file`:{let e;return t[14]!==d||t[15]!==m||t[16]!==r||t[17]!==f||t[18]!==u?(e=(0,$.jsx)(Mr,{data:d,inline:r,rootPath:u,onOpenFile:m,isActive:f}),t[14]=d,t[15]=m,t[16]=r,t[17]=f,t[18]=u,t[19]=e):e=t[19],e}case`search`:{let e;return t[20]!==d||t[21]!==r||t[22]!==f||t[23]!==i?(e=(0,$.jsx)(Pr,{data:d,inline:r,resultContent:i,isActive:f}),t[20]=d,t[21]=r,t[22]=f,t[23]=i,t[24]=e):e=t[24],e}case`agent`:{let e;return t[25]!==d||t[26]!==r||t[27]!==f?(e=(0,$.jsx)(Fr,{data:d,inline:r,isActive:f}),t[25]=d,t[26]=r,t[27]=f,t[28]=e):e=t[28],e}case`todo`:{let e;return t[29]!==d||t[30]!==r||t[31]!==f?(e=(0,$.jsx)(Ir,{data:d,inline:r,isActive:f}),t[29]=d,t[30]=r,t[31]=f,t[32]=e):e=t[32],e}case`imageGen`:{let e;return t[33]!==d||t[34]!==r||t[35]!==f?(e=(0,$.jsx)(Lr,{data:d,inline:r,isActive:f}),t[33]=d,t[34]=r,t[35]=f,t[36]=e):e=t[36],e}default:{let e;return t[37]!==d||t[38]!==r||t[39]!==f?(e=(0,$.jsx)(Rr,{data:d,inline:r,isActive:f}),t[37]=d,t[38]=r,t[39]=f,t[40]=e):e=t[40],e}}}function Br(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 Vr(e){let n=(0,Q.c)(29),{imageUrl:r,imageData:i}=e,[a,o]=(0,Z.useState)(!1),s=i?`data:image/png;base64,${i}`:r??``,c;n[0]===s?c=n[1]:(c=async()=>{let e=`generated-image-${Date.now()}.png`,{path:t}=await mt(s.startsWith(`data:`)?{imageData:s.replace(/^data:[^;]+;base64,/,``),filename:e}:{imageUrl:s,filename:e});X({title:`Saved to downloads: ${t.split(`/`).pop()}`})},n[0]=s,n[1]=c);let l=c,u;n[2]===s?u=n[3]:(u=async()=>{await U(s.startsWith(`data:`)?{imageData:s.replace(/^data:[^;]+;base64,/,``)}:{imageUrl:s}),o(!0),setTimeout(()=>o(!1),2e3)},n[2]=s,n[3]=u);let d=u,f;n[4]===Symbol.for(`react.memo_cache_sentinel`)?(f={maxHeight:`512px`},n[4]=f):f=n[4];let p;n[5]===s?p=n[6]:(p=(0,$.jsx)(`img`,{src:s,alt:`Generated image`,className:`max-w-full rounded-lg block`,style:f}),n[5]=s,n[6]=p);let m;n[7]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(A,{className:`h-3.5 w-3.5`}),n[7]=m):m=n[7];let h;n[8]===l?h=n[9]:(h=(0,$.jsx)($t,{asChild:!0,children:(0,$.jsx)(`button`,{onClick:l,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})}),n[8]=l,n[9]=h);let g;n[10]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(Xt,{children:`Save image`}),n[10]=g):g=n[10];let _;n[11]===h?_=n[12]:(_=(0,$.jsxs)(Qt,{children:[h,g]}),n[11]=h,n[12]=_);let v;n[13]===a?v=n[14]:(v=a?(0,$.jsx)(Ge,{className:`h-3.5 w-3.5 text-green-500`}):(0,$.jsx)(t,{className:`h-3.5 w-3.5`}),n[13]=a,n[14]=v);let y;n[15]!==d||n[16]!==v?(y=(0,$.jsx)($t,{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})}),n[15]=d,n[16]=v,n[17]=y):y=n[17];let b=a?`Copied!`:`Copy to clipboard`,x;n[18]===b?x=n[19]:(x=(0,$.jsx)(Xt,{children:b}),n[18]=b,n[19]=x);let S;n[20]!==y||n[21]!==x?(S=(0,$.jsxs)(Qt,{children:[y,x]}),n[20]=y,n[21]=x,n[22]=S):S=n[22];let C;n[23]!==S||n[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)(Zt,{children:[_,S]})}),n[23]=S,n[24]=_,n[25]=C):C=n[25];let w;return n[26]!==C||n[27]!==p?(w=(0,$.jsxs)(`div`,{className:`mb-3 relative group/img inline-block max-w-full`,children:[p,C]}),n[26]=C,n[27]=p,n[28]=w):w=n[28],w}function Hr(e){let t=(0,Q.c)(70),{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}=zt(),d=u.projects,f,p,m,h,g,_,v,y;if(t[0]!==n||t[1]!==r||t[2]!==a||t[3]!==u.projects||t[4]!==u.selectedProjectId||t[5]!==u.selectedThreadId){_=Symbol.for(`react.early_return_sentinel`);bb0:{let e;t[14]===u.selectedProjectId?e=t[15]:(e=e=>e.projectId===u.selectedProjectId,t[14]=u.selectedProjectId,t[15]=e);let i=d.find(e)?.threads.find(e=>e.threadId===u.selectedThreadId)?.path;y=n.toolName??`Unknown Tool`,v=n.toolCallId??`unknown`;let o=n,s=n.result??o.content,c;t[16]!==o||t[17]!==y?(c=y===`todo`?sn(o):null,t[16]=o,t[17]=y,t[18]=c):c=t[18];let l=c;if(m=fr(_r(s),i),!(m.length>0)&&l===null){_=null;break bb0}if(f=dr(y),typeof s==`object`&&s){let e=s,n=e.returnDisplay??e.return_display;if(typeof n==`string`&&n.trim()){let e;t[19]===n?e=t[20]:(e=n.trim(),t[19]=n,t[20]=e),f=e}else if(y===`read`||y===`file_read`){let n=e.filePath??e.file_path??e.path??``;if(n){let e;t[21]===n?e=t[22]:(e=n.split(`/`).pop()??n,t[21]=n,t[22]=e),f=`Completed ${e}`}}}else if(s==null){let e;t[23]===y?e=t[24]:(e=dr(y),t[23]=y,t[24]=e),f=`${e} (no result)`}if(f=fr(f,i),l!==null){let e;t[25]!==a||t[26]!==l?(e=(0,$.jsx)(dn,{todos:l,sequence:a}),t[25]=a,t[26]=l,t[27]=e):e=t[27],_=e;break bb0}if(y===`generate_image`){let e;t[28]===s?e=t[29]:(e=Br(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)(Vr,{imageUrl:n.imageUrl,imageData:n.imageData}),t[30]=n.imageData,t[31]=n.imageUrl,t[32]=e):e=t[32],_=e;break bb0}}if(r){_=null;break bb0}let b;t[33]===y?b=t[34]:(b=y.toLowerCase().includes(`bash`),t[33]=y,t[34]=b),p=b,h=m?m.split(`
|
|
7
|
+
`):[],g=p?h.slice(0,3).join(`
|
|
8
|
+
`):m}t[0]=n,t[1]=r,t[2]=a,t[3]=u.projects,t[4]=u.selectedProjectId,t[5]=u.selectedThreadId,t[6]=f,t[7]=p,t[8]=m,t[9]=h,t[10]=g,t[11]=_,t[12]=v,t[13]=y}else f=t[6],p=t[7],m=t[8],h=t[9],g=t[10],_=t[11],v=t[12],y=t[13];if(_!==Symbol.for(`react.early_return_sentinel`))return _;let b=g,S=p&&h.length>3;if(p){let e;t[35]===f?e=t[36]:(e=(0,$.jsx)(`div`,{className:`px-3 py-2 flex items-center gap-2 text-sm font-medium text-foreground`,children:(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:f})}),t[35]=f,t[36]=e);let n;t[37]!==S||t[38]!==b||t[39]!==m||t[40]!==h?(n=m&&(0,$.jsxs)(`div`,{className:`px-3 pb-2 bg-background border-t border-border`,children:[(0,$.jsxs)(`pre`,{className:`text-sm 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:[b,S&&(0,$.jsxs)(`span`,{className:`text-muted-foreground`,children:[`
|
|
9
|
+
`,`...`]})]}),S&&(0,$.jsxs)(`button`,{type:`button`,onClick:()=>l(!0),className:`mt-1 text-sm text-brand hover:underline`,children:[`Show full output (`,h.length,` lines)`]})]}),t[37]=S,t[38]=b,t[39]=m,t[40]=h,t[41]=n):n=t[41];let r;t[42]!==e||t[43]!==n?(r=(0,$.jsxs)(`div`,{className:`mb-3 rounded-lg border border-border bg-muted/50 overflow-hidden`,children:[e,n]}),t[42]=e,t[43]=n,t[44]=r):r=t[44];let i;t[45]!==c||t[46]!==S||t[47]!==m?(i=S&&(0,$.jsx)(x,{open:c,onOpenChange:l,children:(0,$.jsxs)(P,{className:`max-w-3xl max-h-[80vh] flex flex-col`,children:[(0,$.jsx)(me,{children:(0,$.jsx)(J,{children:`Full Output`})}),(0,$.jsx)(`pre`,{className:`text-sm bg-muted p-3 rounded font-mono whitespace-pre-wrap overflow-auto flex-1 text-foreground`,children:m})]})}),t[45]=c,t[46]=S,t[47]=m,t[48]=i):i=t[48];let a;return t[49]!==r||t[50]!==i?(a=(0,$.jsxs)($.Fragment,{children:[r,i]}),t[49]=r,t[50]=i,t[51]=a):a=t[51],a}let C;t[52]===o?C=t[53]:(C=()=>s(!o),t[52]=o,t[53]=C);let w=`${y} result`,T;t[54]===f?T=t[55]:(T=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:f}),t[54]=f,t[55]=T);let E;t[56]===o?E=t[57]:(E=o?(0,$.jsx)(we,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(Qe,{className:`h-4 w-4 shrink-0`}),t[56]=o,t[57]=E);let D;t[58]!==C||t[59]!==w||t[60]!==T||t[61]!==E?(D=(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]}),t[58]=C,t[59]=w,t[60]=T,t[61]=E,t[62]=D):D=t[62];let O;t[63]!==o||t[64]!==m||t[65]!==v?(O=o&&(0,$.jsxs)(`div`,{className:`px-3 py-2 bg-background border-t border-border`,children:[(0,$.jsxs)(`div`,{className:`text-xs text-muted-foreground mb-2 font-mono`,children:[`Call ID: `,v]}),m&&(0,$.jsx)(`pre`,{className:`text-sm bg-muted p-2 rounded font-mono whitespace-pre-wrap overflow-auto max-h-48 text-foreground text-left`,children:m})]}),t[63]=o,t[64]=m,t[65]=v,t[66]=O):O=t[66];let k;return t[67]!==O||t[68]!==D?(k=(0,$.jsxs)(`div`,{className:`mb-3 rounded-lg border border-border bg-muted/50 overflow-hidden`,children:[D,O]}),t[67]=O,t[68]=D,t[69]=k):k=t[69],k}function Ur(e){let t=(0,Q.c)(39),{text:n,isStreaming:r}=e,i=n===void 0?``:n,a=r===void 0?!1:r,o=(0,Z.useRef)(null),[s,c]=(0,Z.useState)(a),l=(0,Z.useRef)(a),u,d;t[0]===a?(u=t[1],d=t[2]):(u=()=>{a?c(!0):l.current&&!a&&c(!1),l.current=a},d=[a],t[0]=a,t[1]=u,t[2]=d),(0,Z.useEffect)(u,d);let f;t[3]!==s||t[4]!==a?(f=()=>{s&&a&&o.current&&(o.current.scrollTop=o.current.scrollHeight)},t[3]=s,t[4]=a,t[5]=f):f=t[5];let p;if(t[6]!==s||t[7]!==a||t[8]!==i?(p=[i,s,a],t[6]=s,t[7]=a,t[8]=i,t[9]=p):p=t[9],(0,Z.useEffect)(f,p),!i&&!a)return null;let m;t[10]!==a||t[11]!==i?(m=!a&&i.trim().startsWith(`Validated`),t[10]=a,t[11]=i,t[12]=m):m=t[12];let h=m,g=a?`Validating...`:h?`Validated`:`Thinking`,_;t[13]===s?_=t[14]:(_=()=>c(!s),t[13]=s,t[14]=_);let v;t[15]!==a||t[16]!==h?(v=h?(0,$.jsx)(st,{className:`h-3.5 w-3.5 shrink-0 text-green-600`}):(0,$.jsx)(ft,{className:H(`h-3.5 w-3.5 shrink-0`,a?`text-brand animate-pulse`:`text-muted-foreground`)}),t[15]=a,t[16]=h,t[17]=v):v=t[17];let y;t[18]===g?y=t[19]:(y=(0,$.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:g}),t[18]=g,t[19]=y);let b;t[20]===s?b=t[21]:(b=s?(0,$.jsx)(we,{className:`h-3 w-3 text-muted-foreground shrink-0`}):(0,$.jsx)(Qe,{className:`h-3 w-3 text-muted-foreground shrink-0`}),t[20]=s,t[21]=b);let x;t[22]!==s||t[23]!==y||t[24]!==b||t[25]!==_||t[26]!==v?(x=(0,$.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1.5 cursor-pointer select-none text-left w-full`,onClick:_,"aria-expanded":s,children:[v,y,b]}),t[22]=s,t[23]=y,t[24]=b,t[25]=_,t[26]=v,t[27]=x):x=t[27];let S=s?`grid-rows-[1fr]`:`grid-rows-[0fr]`,C;t[28]===S?C=t[29]:(C=H(`grid transition-[grid-template-rows] duration-200 ease-in-out`,S),t[28]=S,t[29]=C);let w;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(w={maxHeight:`7.5em`},t[30]=w):w=t[30];let T;t[31]===i?T=t[32]:(T=(0,$.jsx)(`div`,{className:`overflow-hidden`,children:(0,$.jsx)(`div`,{ref:o,className:`ml-5 text-sm text-muted-foreground/60 whitespace-pre-wrap overflow-y-auto`,style:w,children:i})}),t[31]=i,t[32]=T);let E;t[33]!==C||t[34]!==T?(E=(0,$.jsx)(`div`,{className:C,children:T}),t[33]=C,t[34]=T,t[35]=E):E=t[35];let D;return t[36]!==x||t[37]!==E?(D=(0,$.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[x,E]}),t[36]=x,t[37]=E,t[38]=D):D=t[38],D}function Wr(e){let t=(0,Q.c)(52),{toolCall:n,className:r}=e,{state:i,dispatch:a}=zt(),[o,s]=(0,Z.useState)(!1),c=i.toolCallProgress[n.id],l;t[0]===n.name?l=t[1]:(l=n.name===`bash`?`Ran`:n.name.charAt(0).toUpperCase()+n.name.slice(1),t[0]=n.name,t[1]=l);let d=l;if(!i.isStreaming)return null;let f;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=()=>{s(Kr)},t[2]=f):f=t[2];let p=f,m;t[3]!==a||t[4]!==i.streamingSegments||t[5]!==n.id||t[6]!==n.name?(m=()=>{a({type:Y.StopStream});let e={type:`tool-result`,toolCallId:n.id,toolName:n.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.`};a({type:Y.AppendStreamChunk,chunkType:`content`,content:JSON.stringify([e]),segments:i.streamingSegments})},t[3]=a,t[4]=i.streamingSegments,t[5]=n.id,t[6]=n.name,t[7]=m):m=t[7];let h=m,g=Gr,_=n.name===`bash`&&typeof n.input?.command==`string`?n.input.command:null,v=!_&&typeof n.input?.description==`string`?n.input.description:null,y;t[8]===r?y=t[9]:(y=H(`overflow-hidden mb-2`,r),t[8]=r,t[9]=y);let b;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(Or,{}),t[10]=b):b=t[10];let x;t[11]===d?x=t[12]:(x=(0,$.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:d}),t[11]=d,t[12]=x);let S;t[13]!==x||t[14]!==n.name?(S=(0,$.jsxs)(`span`,{title:n.name,className:`inline-flex items-center gap-1`,children:[b,x]}),t[13]=x,t[14]=n.name,t[15]=S):S=t[15];let C;t[16]===_?C=t[17]:(C=_!==null&&(0,$.jsx)(`code`,{className:`text-sm font-mono text-muted-foreground break-all rounded bg-muted/60 px-1 py-0.5`,children:_}),t[16]=_,t[17]=C);let w;t[18]===v?w=t[19]:(w=v!==null&&(0,$.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:v}),t[18]=v,t[19]=w);let T;t[20]!==_||t[21]!==v?(T=!_&&!v&&(0,$.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`running`}),t[20]=_,t[21]=v,t[22]=T):T=t[22];let E=o?`Collapse`:`Expand`,D;t[23]===o?D=t[24]:(D=o?(0,$.jsx)(be,{className:`h-3 w-3`}):(0,$.jsx)(we,{className:`h-3 w-3`}),t[23]=o,t[24]=D);let O;t[25]!==E||t[26]!==D?(O=(0,$.jsx)(`button`,{onClick:p,className:`p-1 hover:bg-muted/50 rounded transition-colors`,title:E,children:D}),t[25]=E,t[26]=D,t[27]=O):O=t[27];let k;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,$.jsx)(u,{className:`h-3 w-3`}),t[28]=k):k=t[28];let A;t[29]===h?A=t[30]:(A=(0,$.jsx)($t,{asChild:!0,children:(0,$.jsx)(`button`,{onClick:h,className:`p-1 hover:bg-red-200 dark:hover:bg-red-800 rounded transition-colors text-red-600 dark:text-red-400`,children:k})}),t[29]=h,t[30]=A);let j;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,$.jsx)(Xt,{className:`bg-red-600 text-white border-red-600`,children:`Stop this process`}),t[31]=j):j=t[31];let M;t[32]===A?M=t[33]:(M=(0,$.jsxs)(Qt,{children:[A,j]}),t[32]=A,t[33]=M);let N;t[34]!==O||t[35]!==M?(N=(0,$.jsxs)(`div`,{className:`flex items-center gap-1 ml-auto shrink-0`,children:[O,M]}),t[34]=O,t[35]=M,t[36]=N):N=t[36];let P;t[37]!==T||t[38]!==N||t[39]!==S||t[40]!==C||t[41]!==w?(P=(0,$.jsxs)(`div`,{className:`py-0.5 flex items-center gap-2 flex-wrap`,children:[S,C,w,T,N]}),t[37]=T,t[38]=N,t[39]=S,t[40]=C,t[41]=w,t[42]=P):P=t[42];let F;t[43]!==o||t[44]!==n.id||t[45]!==n.input||t[46]!==c?(F=o&&(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: `,n.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-sm 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:g(n.input)})]}),c&&(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-sm 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:c.delta}),c.partial?.content?.[0]?.arguments&&typeof c.partial.content[0].arguments==`object`&&`content`in c.partial.content[0].arguments&&typeof c.partial.content[0].arguments.content==`string`&&(0,$.jsxs)(`div`,{className:`mt-1 text-green-600 dark:text-green-400 font-mono text-sm`,children:[`Building: `,c.partial.content[0].arguments.content.slice(-50),c.partial.content[0].arguments.content.length>50&&`...`]})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,$.jsx)(Or,{}),`Executing`,c&&` with progress`,`...`]})]}),t[43]=o,t[44]=n.id,t[45]=n.input,t[46]=c,t[47]=F):F=t[47];let I;return t[48]!==P||t[49]!==F||t[50]!==y?(I=(0,$.jsxs)(`div`,{className:y,children:[P,F]}),t[48]=P,t[49]=F,t[50]=y,t[51]=I):I=t[51],I}function Gr(e){return JSON.stringify(e,null,2)}function Kr(e){return!e}function qr(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 vt(n,e.trim()),f(e.trim()),u(!0)}catch(e){console.error(`Failed to submit answer:`,e),m(!1),g(null)}}},t[0]=p,t[1]=n,t[2]=_):_=t[2];let v=_,y;t[3]!==v||t[4]!==p||t[5]!==l?(y=e=>{l||p||(g(e),v(e))},t[3]=v,t[4]=p,t[5]=l,t[6]=y):y=t[6];let b=y,x;t[7]!==s||t[8]!==v||t[9]!==p||t[10]!==l?(x=()=>{if(l||p)return;let e=s.trim();e&&v(e)},t[7]=s,t[8]=v,t[9]=p,t[10]=l,t[11]=x):x=t[11];let S=x,C;t[12]===S?C=t[13]:(C=e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),S())},t[12]=S,t[13]=C);let w=C;if(l){let e,n;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Ge,{className:`h-4 w-4`}),n=(0,$.jsx)(`span`,{className:`font-medium`,children:`Answered:`}),t[14]=e,t[15]=n):(e=t[14],n=t[15]);let r;return t[16]===d?r=t[17]:(r=(0,$.jsx)(`div`,{className:`rounded-lg p-3 my-2`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[e,n,(0,$.jsx)(`span`,{children:d})]})}),t[16]=d,t[17]=r),r}let T;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(Ye,{className:`h-5 w-5 text-brand shrink-0 mt-0.5`}),t[18]=T):T=t[18];let E;t[19]===r?E=t[20]:(E=(0,$.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:(0,$.jsx)(Mn,{content:r})}),t[19]=r,t[20]=E);let D;t[21]===a?D=t[22]:(D=a&&(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:a}),t[21]=a,t[22]=D);let O;t[23]!==E||t[24]!==D?(O=(0,$.jsxs)(`div`,{className:`flex items-start gap-2 mb-3`,children:[T,(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[E,D]})]}),t[23]=E,t[24]=D,t[25]=O):O=t[25];let k;t[26]!==b||t[27]!==p||t[28]!==i||t[29]!==h?(k=i&&i.length>0&&(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2 mb-3`,children:i.map(e=>{let t=h===e;return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>b(e),disabled:p,className:H(`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)(Ge,{className:`h-3.5 w-3.5 text-foreground`}),e]},e)})}),t[26]=b,t[27]=p,t[28]=i,t[29]=h,t[30]=k):k=t[30];let A;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(A=e=>c(e.target.value),t[31]=A):A=t[31];let j=i?.length?`Or type a custom answer...`:`Type your answer...`,M;t[32]!==s||t[33]!==w||t[34]!==p||t[35]!==j?(M=(0,$.jsx)(`input`,{type:`text`,value:s,onChange:A,onKeyDown:w,placeholder:j,disabled:p,className:`flex-1 rounded-md border border-border bg-background px-3 py-1.5 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring disabled:opacity-50`}),t[32]=s,t[33]=w,t[34]=p,t[35]=j,t[36]=M):M=t[36];let N;t[37]!==s||t[38]!==p?(N=p||!s.trim(),t[37]=s,t[38]=p,t[39]=N):N=t[39];let P;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,$.jsx)(tt,{className:`h-3 w-3`}),t[40]=P):P=t[40];let F;t[41]!==S||t[42]!==N?(F=(0,$.jsx)(`button`,{type:`button`,onClick:S,disabled:N,className:`h-7 w-7 rounded-full bg-primary text-primary-foreground hover:bg-primary/90 transition-colors disabled:opacity-50 flex items-center justify-center shrink-0`,children:P}),t[41]=S,t[42]=N,t[43]=F):F=t[43];let I;t[44]!==M||t[45]!==F?(I=(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[M,F]}),t[44]=M,t[45]=F,t[46]=I):I=t[46];let L;return t[47]!==I||t[48]!==O||t[49]!==k?(L=(0,$.jsxs)(`div`,{className:`rounded-lg border-t border-border p-4 my-2`,children:[O,k,I]}),t[47]=I,t[48]=O,t[49]=k,t[50]=L):L=t[50],L}function Jr(e){let t=(0,Q.c)(46),{toolCallId:n,intention:r,code:i}=e,{state:a}=zt(),o=a.selectedThreadId,s;t[0]===n?s=t[1]:(s=on(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=()=>mn(n,()=>{let e=on(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&&an(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(Yr),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)(he,{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)(he,{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)(we,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(Qe,{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-sm text-muted-foreground leading-relaxed whitespace-pre-wrap`,children:i}),f!=null&&(0,$.jsx)(`pre`,{className:`text-sm 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)(he,{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)(we,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(Qe,{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-sm text-muted-foreground leading-relaxed whitespace-pre-wrap`,children:m}),(0,$.jsx)(`pre`,{className:`text-sm 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 Yr(e){return!e}function Xr(e){let n=(0,Q.c)(29),{src:r}=e,[i,a]=(0,Z.useState)(!1),o;n[0]===r?o=n[1]:(o=async()=>{let e=`generated-image-${Date.now()}.png`,{path:t}=await mt(r.startsWith(`data:`)?{imageData:r.replace(/^data:[^;]+;base64,/,``),filename:e}:{imageUrl:r,filename:e});X({title:`Saved to downloads: ${t.split(`/`).pop()}`})},n[0]=r,n[1]=o);let s=o,c;n[2]===r?c=n[3]:(c=async()=>{await U(r.startsWith(`data:`)?{imageData:r.replace(/^data:[^;]+;base64,/,``)}:{imageUrl:r}),a(!0),setTimeout(()=>a(!1),2e3)},n[2]=r,n[3]=c);let l=c,u;n[4]===Symbol.for(`react.memo_cache_sentinel`)?(u={maxHeight:`512px`},n[4]=u):u=n[4];let d;n[5]===r?d=n[6]:(d=(0,$.jsx)(`img`,{src:r,alt:`Generated image`,className:`max-w-full rounded-lg border border-border block`,style:u}),n[5]=r,n[6]=d);let f;n[7]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(A,{className:`h-3.5 w-3.5`}),n[7]=f):f=n[7];let p;n[8]===s?p=n[9]:(p=(0,$.jsx)($t,{asChild:!0,children:(0,$.jsx)(`button`,{onClick:s,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})}),n[8]=s,n[9]=p);let m;n[10]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(Xt,{children:`Save image`}),n[10]=m):m=n[10];let h;n[11]===p?h=n[12]:(h=(0,$.jsxs)(Qt,{children:[p,m]}),n[11]=p,n[12]=h);let g;n[13]===i?g=n[14]:(g=i?(0,$.jsx)(Ge,{className:`h-3.5 w-3.5 text-green-500`}):(0,$.jsx)(t,{className:`h-3.5 w-3.5`}),n[13]=i,n[14]=g);let _;n[15]!==l||n[16]!==g?(_=(0,$.jsx)($t,{asChild:!0,children:(0,$.jsx)(`button`,{onClick:l,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})}),n[15]=l,n[16]=g,n[17]=_):_=n[17];let v=i?`Copied!`:`Copy to clipboard`,y;n[18]===v?y=n[19]:(y=(0,$.jsx)(Xt,{children:v}),n[18]=v,n[19]=y);let b;n[20]!==_||n[21]!==y?(b=(0,$.jsxs)(Qt,{children:[_,y]}),n[20]=_,n[21]=y,n[22]=b):b=n[22];let x;n[23]!==b||n[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)(Zt,{children:[h,b]})}),n[23]=b,n[24]=h,n[25]=x):x=n[25];let S;return n[26]!==x||n[27]!==d?(S=(0,$.jsxs)(`div`,{className:`mt-2 relative group/img inline-block max-w-full`,children:[d,x]}),n[26]=x,n[27]=d,n[28]=S):S=n[28],S}function Zr(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 Qr(e,t,n,r){return e.name===`ask_user`?(0,$.jsx)(qr,{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)(Jr,{toolCallId:e.id,intention:e.input?.intention??``,code:e.input?.code??``},t):n===!0&&r===void 0?(0,$.jsx)(Wr,{toolCall:e},t):(0,$.jsx)(zr,{inline:!0,block:e,resultContent:r,isActive:!1},t)}function $r({message:e,threadId:t,messageIndex:n=0}){let r=e.sender===`user`,i=r?null:qt(e.content),[a,o]=(0,Z.useState)(!1),s=e.timestamp?new Date(e.timestamp).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}):``;async function c(){if(!(!e.checkpointRef||!t||a)){o(!0);try{let n=await et(t,e.checkpointRef);n.success?X({title:`Checkpoint restored`,description:`Working tree restored to before this agent run.`}):X({title:`Restore failed`,description:n.error??`Could not restore checkpoint.`,variant:`destructive`})}catch(e){X({title:`Restore failed`,description:e instanceof Error?e.message:`Unknown error`,variant:`destructive`})}finally{o(!1)}}}return(0,$.jsx)(`div`,{className:H(`group px-4 py-4`,r&&`flex justify-end`),children:(0,$.jsxs)(`div`,{className:H(`flex flex-col gap-1 min-w-0 max-w-full`,r&&`items-end`),children:[(0,$.jsxs)(`div`,{className:H(`flex items-center gap-2`,r&&`flex-row-reverse`),children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:r?`You`:`Agent`}),r&&e.checkpointRef&&(0,$.jsx)(Zt,{children:(0,$.jsxs)(Qt,{children:[(0,$.jsx)($t,{asChild:!0,children:(0,$.jsx)(`button`,{onClick:c,disabled:a,className:`flex items-center justify-center h-5 w-5 rounded-md text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity hover:text-foreground hover:bg-muted disabled:opacity-50`,children:(0,$.jsx)(Te,{className:H(`h-3 w-3`,a&&`animate-spin`)})})}),(0,$.jsx)(Xt,{side:`left`,children:`Restore checkpoint`})]})}),s&&(0,$.jsxs)(`span`,{className:`flex items-center gap-1 text-[10px] text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity`,children:[(0,$.jsx)(ke,{className:`h-2.5 w-2.5`}),s]}),e.model&&(0,$.jsxs)(`span`,{className:`flex items-center gap-1 text-[10px] text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity`,children:[(0,$.jsx)(he,{className:`h-2.5 w-2.5`}),In(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)(M,{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:H(`flex flex-col gap-0.5 min-w-0 text-sm`,r&&`rounded-xl px-4 py-3 bg-foreground text-background`),children:e.isThinking?(()=>{let t=Wt(e.content);return t?.length?(0,$.jsx)($.Fragment,{children:Vt(t,!1).map((e,n)=>{if(e.type===`thinking-group`)return(0,$.jsx)(Ur,{text:e.text,isStreaming:!1},`tg-${n}`);let r=e;return r.type===`tool_use`?Qr(r,n,!1,Zr(t,r.id)):r.type===`tool-result`?(0,$.jsx)(Hr,{inline:!0,block:r},n):null})}):(0,$.jsx)(`div`,{className:`text-sm text-muted-foreground leading-relaxed whitespace-pre-wrap`,children:(0,$.jsx)(Mn,{content:Ht(e.content),enableMermaid:!0})})})():i?(()=>{let e=Vt(i,!1),t=i.filter(e=>e.type===`tool_use`&&e.name===`ask_user`);return(0,$.jsxs)($.Fragment,{children:[e.map((e,t)=>{if(e.type===`thinking-group`)return(0,$.jsx)(Ur,{text:e.text,isStreaming:!1},`tg-${t}`);let r=e;return r.type===`tool_use`&&r.name===`todo`||r.type===`tool-result`&&r.toolName===`todo`?r.type===`tool-result`?(0,$.jsx)(Hr,{inline:!0,sequence:n,block:r},t):null:r.type===`tool_use`&&r.name===`ask_user`||r.type===`tool-result`&&r.toolName===`ask_user`?null:(0,$.jsx)(`div`,{children:r.type===`text`&&`text`in r?(0,$.jsx)(Mn,{content:Ht(r.text),enableMermaid:!0}):r.type===`tool_use`?Qr(r,void 0,!1,Zr(i,r.id)):r.type===`tool-result`?(0,$.jsx)(Hr,{inline:!0,block:r}):null},t)}),t.map((e,t)=>(0,$.jsx)(qr,{toolCallId:e.id,question:JSON.stringify(e.input?.question??``),options:e.input?.options,context:e.input?.context,answeredText:Zr(i,e.id)},`ask-${t}`))]})})():(0,$.jsx)(Mn,{content:Ht(e.content),enableMermaid:!0})}),(e.generatedImageUrl||e.generatedImageData)&&(0,$.jsx)(Xr,{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)(Je,{className:`h-2.5 w-2.5`}),e.fileName]},t))})]})})}function ei(e){let t=(0,Q.c)(24),{segments:n,model:r,isCreatingProject:i,isProcessingThread:a,totalMessages:o,showProcessingLine:s}=e,c=o===void 0?0:o,l=s===void 0?!1:s,u,d,f,p;if(t[0]!==i||t[1]!==a||t[2]!==r||t[3]!==n||t[4]!==l||t[5]!==c){let e=Bt(n),o=l?`pb-0`:`pb-4`;t[10]===o?p=t[11]:(p=H(`group px-4 pt-4`,o),t[10]=o,t[11]=p),u=`flex flex-col gap-1 min-w-0`;let s;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:`Agent`}),t[12]=s):s=t[12];let m;t[13]===r?m=t[14]:(m=r&&(0,$.jsxs)(`span`,{className:`flex items-center gap-1 text-[10px] text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity`,children:[(0,$.jsx)(he,{className:`h-2.5 w-2.5`}),In(r)]}),t[13]=r,t[14]=m),t[15]===m?d=t[16]:(d=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[s,m]}),t[15]=m,t[16]=d),f=e.length>0?(()=>{let t=Vt(e,!0),n=e.filter(ti);return(0,$.jsxs)(`div`,{className:`flex flex-col gap-0.5 min-w-0 text-sm`,children:[t.map((t,n)=>{if(t.type===`thinking-group`){let e=t;return(0,$.jsx)(Ur,{text:e.text,isStreaming:e.isCurrentlyStreaming},`tg-${n}`)}let r=t;return r.type===`tool_use`&&r.name===`todo`||r.type===`tool-result`&&r.toolName===`todo`?r.type===`tool-result`?(0,$.jsx)(Hr,{inline:!0,sequence:c,block:r},`b-${n}`):null:r.type===`tool_use`&&r.name===`ask_user`?null:(0,$.jsx)(`div`,{children:r.type===`text`&&`text`in r?(0,$.jsx)(Mn,{content:Ht(r.text),enableMermaid:!0}):r.type===`tool_use`?(()=>{let t=Zr(e,r.id);return Qr(r,void 0,t===void 0,t)})():r.type===`tool-result`?(0,$.jsx)(Hr,{inline:!0,block:r}):null},`b-${n}`)}),n.map((t,n)=>(0,$.jsx)(qr,{toolCallId:t.id,question:JSON.stringify(t.input?.question??``),options:t.input?.options,context:t.input?.context,answeredText:Zr(e,t.id)},`ask-${n}`))]})})():i||a?(0,$.jsx)(`div`,{className:`min-w-0`,children:(0,$.jsx)(Ur,{isStreaming:!0})}):null,t[0]=i,t[1]=a,t[2]=r,t[3]=n,t[4]=l,t[5]=c,t[6]=u,t[7]=d,t[8]=f,t[9]=p}else u=t[6],d=t[7],f=t[8],p=t[9];let m;t[17]!==u||t[18]!==d||t[19]!==f?(m=(0,$.jsxs)(`div`,{className:u,children:[d,f]}),t[17]=u,t[18]=d,t[19]=f,t[20]=m):m=t[20];let h;return t[21]!==p||t[22]!==m?(h=(0,$.jsx)(`div`,{className:p,children:m}),t[21]=p,t[22]=m,t[23]=h):h=t[23],h}function ti(e){return e.type===`tool_use`&&e.name===`ask_user`}var ni=(0,Z.memo)(ei,(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}),ri=3e3;function ii(e){let t=[...oe],n=e?t.filter(t=>t!==e):t;return n[Math.floor(Math.random()*n.length)]}function ai(e){let t=(0,Q.c)(3),[n,r]=(0,Z.useState)(gt),i=(0,Z.useRef)(gt),a,o;return t[0]===e?(a=t[1],o=t[2]):(a=()=>{if(!e){r(gt),i.current=gt;return}let t=setInterval(()=>{let e=i.current===`Processing...`?ii():ii(i.current);i.current=e,r(e)},ri);return()=>clearInterval(t)},o=[e],t[0]=e,t[1]=a,t[2]=o),(0,Z.useEffect)(a,o),n}function oi(e){let t=(0,Q.c)(8),{active:n,className:r}=e,i=ai(n===void 0?!0:n),a;t[0]===r?a=t[1]:(a=H(`flex items-center gap-2`,r),t[0]=r,t[1]=a);let o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(Or,{}),t[2]=o):o=t[2];let s;t[3]===i?s=t[4]:(s=(0,$.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:i}),t[3]=i,t[4]=s);let c;return t[5]!==a||t[6]!==s?(c=(0,$.jsxs)(`div`,{className:a,"aria-live":`polite`,"aria-busy":`true`,children:[o,s]}),t[5]=a,t[6]=s,t[7]=c):c=t[7],c}function si(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 u;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight text-foreground text-balance`,children:`Let's build it!`}),t[1]=u):u=t[1];let d=n.length===0?`Start or connect your first project`:`Select a project to start coding`,f;t[2]===d?f=t[3]:(f=(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3`,children:[c,(0,$.jsxs)(`div`,{className:`text-center`,children:[u,(0,$.jsx)(`p`,{className:`mt-1 text-base text-muted-foreground`,children:d})]})]}),t[2]=d,t[3]=f);let p;if(t[4]!==i||t[5]!==r||t[6]!==n){let e;t[8]!==i||t[9]!==r?(e=e=>(0,$.jsxs)(`button`,{type:`button`,className:`flex w-56 flex-col gap-2 rounded-xl border border-border bg-background p-4 text-left shadow-sm transition-colors hover:bg-muted`,onClick:()=>{e.threads.length===0?i(e.projectId):r(e.projectId,e.threads[0].threadId)},children:[(0,$.jsx)(K,{className:`h-5 w-5 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`text-sm text-foreground leading-snug font-medium`,children:e.name}),(0,$.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[e.threads.length,` thread`,e.threads.length===1?``:`s`]})]},e.projectId),t[8]=i,t[9]=r,t[10]=e):e=t[10],p=n.map(e),t[4]=i,t[5]=r,t[6]=n,t[7]=p}else p=t[7];let m,h,g;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(re,{className:`h-5 w-5 text-muted-foreground`}),h=(0,$.jsx)(`span`,{className:`text-sm text-foreground leading-snug font-medium`,children:`Connect a repo`}),g=(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Clone an existing repository`}),t[11]=m,t[12]=h,t[13]=g):(m=t[11],h=t[12],g=t[13]);let _;t[14]===a?_=t[15]:(_=(0,$.jsxs)(`button`,{type:`button`,className:`flex w-56 flex-col gap-2 rounded-xl border border-border bg-background p-4 text-left shadow-sm transition-colors hover:bg-muted`,onClick:a,children:[m,h,g]}),t[14]=a,t[15]=_);let v,y,b;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(nt,{className:`h-5 w-5 text-muted-foreground`}),y=(0,$.jsx)(`span`,{className:`text-sm text-foreground leading-snug font-medium`,children:`New App`}),b=(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Create a new project from template`}),t[16]=v,t[17]=y,t[18]=b):(v=t[16],y=t[17],b=t[18]);let x;t[19]===o?x=t[20]:(x=(0,$.jsxs)(`button`,{type:`button`,className:`flex w-56 flex-col gap-2 rounded-xl border border-border bg-background p-4 text-left shadow-sm transition-colors hover:bg-muted`,onClick:o,children:[v,y,b]}),t[19]=o,t[20]=x);let S,C,w;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,$.jsx)(l,{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]!==x||t[27]!==T||t[28]!==p||t[29]!==_?(E=(0,$.jsxs)(`div`,{className:`flex flex-wrap justify-center gap-3`,children:[p,_,x,T]}),t[26]=x,t[27]=T,t[28]=p,t[29]=_,t[30]=E):E=t[30];let D;return t[31]!==E||t[32]!==f?(D=(0,$.jsxs)(`div`,{className:`mx-auto flex max-w-3xl flex-1 flex-col items-center justify-center gap-8 px-4`,children:[f,E]}),t[31]=E,t[32]=f,t[33]=D):D=t[33],D}function ci(e){let t=[`What would you like to add to ${e}?`,`What should we build in ${e}?`,`What changes do you want to make to ${e}?`,`What feature should we add to ${e}?`,`What would you like to fix in ${e}?`,`What are we working on in ${e}?`,`What's next for ${e}?`,`What should we improve in ${e}?`,`How can we make ${e} better?`,`What would you like to change in ${e}?`,`What should we ship in ${e} next?`];return t[Math.floor(Math.random()*t.length)]}function li(e){let t=(0,Q.c)(24),{project:r}=e,{setDevServerRunning:i}=Nn(),[a,o]=(0,Z.useState)(!1),{startServer:s}=Ln(),c;t[0]!==r||t[1]!==i?(c=()=>{if(!r?.projectId)return;let e=async()=>{try{let e=await n(r.projectId);o(e.isRunning),i(e.isRunning)}catch{o(!1),i(!1)}};e();let t=setInterval(e,2e3);return()=>clearInterval(t)},t[0]=r,t[1]=i,t[2]=c):c=t[2];let l=r?.projectId,u;t[3]===l?u=t[4]:(u=[l],t[3]=l,t[4]=u),(0,Z.useEffect)(c,u),r?.name;let d=r?.name??`your project`,f;t[5]===d?f=t[6]:(f=ci(d),t[5]=d,t[6]=f);let p=f,m=!a&&r?.runCommand,h;t[7]!==r||t[8]!==s?(h=()=>{r&&s(r)},t[7]=r,t[8]=s,t[9]=h):h=t[9];let g=h,_;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(`img`,{src:`/tarsk-color.svg`,alt:`Tarsk`,className:`h-16 w-16 rounded-lg`}),t[10]=_):_=t[10];let v=r?.name??`Project`,y;t[11]===v?y=t[12]:(y=(0,$.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight text-foreground text-balance`,children:v}),t[11]=v,t[12]=y);let b;t[13]===p?b=t[14]:(b=(0,$.jsx)(`p`,{className:`mt-2 text-base text-muted-foreground`,children:p}),t[13]=p,t[14]=b);let x;t[15]!==b||t[16]!==y?(x=(0,$.jsxs)(`div`,{className:`text-center`,children:[y,b]}),t[15]=b,t[16]=y,t[17]=x):x=t[17];let S;t[18]!==g||t[19]!==m?(S=m&&(0,$.jsx)(`button`,{type:`button`,onClick:g,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[18]=g,t[19]=m,t[20]=S):S=t[20];let C;return t[21]!==x||t[22]!==S?(C=(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:[_,x,S]})}),t[21]=x,t[22]=S,t[23]=C):C=t[23],C}var ui=(0,Z.createContext)(null),di=(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});di.displayName=`MessageList`;function fi(){let e=(0,Q.c)(19),t=(0,Z.useContext)(ui);if(!t)return null;let{isStreaming:n,isCreatingProject:r,isProcessingThread:i,hasPendingMessage:a,streamingSegments:o,streamingModel:s,totalMessages:c,error:l,onClearError:u}=t,d=o.length>0||r||i,f=n||a,p;e[0]!==d||e[1]!==r||e[2]!==i||e[3]!==n||e[4]!==f||e[5]!==s||e[6]!==o||e[7]!==c?(p=d&&(n||r||i)&&(0,$.jsx)(ni,{segments:o,model:s,isCreatingProject:r,isProcessingThread:i,totalMessages:c,showProcessingLine:f}),e[0]=d,e[1]=r,e[2]=i,e[3]=n,e[4]=f,e[5]=s,e[6]=o,e[7]=c,e[8]=p):p=e[8];let m;e[9]!==d||e[10]!==f?(m=f&&(0,$.jsx)(`div`,{className:H(`px-4 pb-4`,d?`pt-0`:`pt-2`),children:(0,$.jsx)(oi,{active:f})}),e[9]=d,e[10]=f,e[11]=m):m=e[11];let h;e[12]!==l||e[13]!==u?(h=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[12]=l,e[13]=u,e[14]=h):h=e[14];let g;return e[15]!==p||e[16]!==m||e[17]!==h?(g=(0,$.jsxs)(`div`,{className:`mx-auto max-w-3xl w-full min-w-0 pb-48`,children:[p,m,h]}),e[15]=p,e[16]=m,e[17]=h,e[18]=g):g=e[18],g}var pi={List:di,Footer:fi};function mi(e){let t=(0,Q.c)(62),{messages:n,isStreaming:r,streamingSegments:i,streamingModel:a,isCreatingProject:o,isProcessingThread:s,hasPendingMessage:c,selectedThreadId:l,selectedProjectId:u,projects:f,projectsLoading:p,messagesLoaded:m,onSelectThread:h,onCreateThread:g,onConnectRepo:_,onNewApp:v,onOpenFolder:y,error:b,onClearError:x}=e,S=(0,Z.useRef)(null),C=(0,Z.useRef)(0),w=(0,Z.useRef)(!1),T=(0,Z.useRef)(!1),E;t[0]===l?E=t[1]:(E=()=>{l&&S.current?.getState(e=>{d(l,e.scrollTop)})},t[0]=l,t[1]=E);let D=E,O,k;t[2]===D?(O=t[3],k=t[4]):(O=()=>{let e=()=>{D()};return window.addEventListener(`beforeunload`,e),()=>{window.removeEventListener(`beforeunload`,e),D()}},k=[D],t[2]=D,t[3]=O,t[4]=k),(0,Z.useEffect)(O,k);let A,j;t[5]===D?(A=t[6],j=t[7]):(A=()=>{let e=setInterval(()=>{D()},5e3);return()=>clearInterval(e)},j=[D],t[5]=D,t[6]=A,t[7]=j),(0,Z.useEffect)(A,j);let M,N;t[8]!==n.length||t[9]!==m||t[10]!==l?(M=()=>{if(!l||!m||T.current||(T.current=!0,n.length===0))return;let e=ge(l);e!==null&&e>0&&requestAnimationFrame(()=>{S.current?.scrollTo({top:e})})},N=[l,m,n.length],t[8]=n.length,t[9]=m,t[10]=l,t[11]=M,t[12]=N):(M=t[11],N=t[12]),(0,Z.useEffect)(M,N);let P;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(P=()=>{T.current=!1,C.current=0},t[13]=P):P=t[13];let F;t[14]===l?F=t[15]:(F=[l],t[14]=l,t[15]=F),(0,Z.useEffect)(P,F);let I;t[16]!==c||t[17]!==r||t[18]!==n.length?(I=()=>{if(!T.current)return;let e=n.length>C.current,t=w.current&&!r;(r||c||e||t)&&requestAnimationFrame(()=>{S.current?.scrollTo({top:2**53-1,behavior:`smooth`})}),C.current=n.length,w.current=r},t[16]=c,t[17]=r,t[18]=n.length,t[19]=I):I=t[19];let L;t[20]!==c||t[21]!==r||t[22]!==n||t[23]!==i.length?(L=[r,c,n,i.length],t[20]=c,t[21]=r,t[22]=n,t[23]=i.length,t[24]=L):L=t[24],(0,Z.useEffect)(I,L);let ee=n.length===0&&!r&&!o&&!l,R=m&&n.length===0&&!r&&!o&&!s&&!c&&l,z;if(t[25]!==f||t[26]!==u){let e;t[28]===u?e=t[29]:(e=e=>e.projectId===u,t[28]=u,t[29]=e),z=f.find(e),t[25]=f,t[26]=u,t[27]=z}else z=t[27];let B=z;if(ee){let e=`transition-opacity duration-500 ease-in-out ${p?`opacity-0`:`opacity-100`}`,n;t[30]!==_||t[31]!==g||t[32]!==v||t[33]!==y||t[34]!==h||t[35]!==f?(n=(0,$.jsx)(si,{projects:f,onSelectProject:h,onCreateThread:g,onConnectRepo:_,onNewApp:v,onOpenFolder:y}),t[30]=_,t[31]=g,t[32]=v,t[33]=y,t[34]=h,t[35]=f,t[36]=n):n=t[36];let r;return t[37]!==e||t[38]!==n?(r=(0,$.jsx)(`div`,{className:`flex-1 flex flex-col items-center justify-center`,children:(0,$.jsx)(`div`,{className:e,children:n})}),t[37]=e,t[38]=n,t[39]=r):r=t[39],r}if(R){let e;return t[40]===B?e=t[41]:(e=(0,$.jsx)(li,{project:B}),t[40]=B,t[41]=e),e}let V;t[42]!==b||t[43]!==c||t[44]!==o||t[45]!==s||t[46]!==r||t[47]!==n.length||t[48]!==x||t[49]!==a||t[50]!==i?(V={isStreaming:r,isCreatingProject:o,isProcessingThread:s,hasPendingMessage:c,streamingSegments:i,streamingModel:a,totalMessages:n.length,error:b,onClearError:x},t[42]=b,t[43]=c,t[44]=o,t[45]=s,t[46]=r,t[47]=n.length,t[48]=x,t[49]=a,t[50]=i,t[51]=V):V=t[51];let U=V,te;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(te=H(`h-full overflow-hidden`),t[52]=te):te=t[52];let W;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(W={height:`100%`},t[53]=W):W=t[53];let G;t[54]===l?G=t[55]:(G=(e,t)=>(0,$.jsx)($r,{message:t,threadId:l,messageIndex:e}),t[54]=l,t[55]=G);let ne;t[56]!==n||t[57]!==G?(ne=(0,$.jsx)(Ft,{ref:S,style:W,data:n,itemContent:G,overscan:500,components:pi}),t[56]=n,t[57]=G,t[58]=ne):ne=t[58];let re;return t[59]!==U||t[60]!==ne?(re=(0,$.jsx)(`div`,{className:te,children:(0,$.jsx)(ui.Provider,{value:U,children:ne})}),t[59]=U,t[60]=ne,t[61]=re):re=t[61],re}async function hi(e){return W(`api/projects/${z(e)}/todos`)}async function gi(e,t){return L(`api/projects/${z(e)}/todos`,{description:t})}async function _i(e,t,n){return D(`api/projects/${z(e)}/todos/${z(t)}`,n)}async function vi(e,t){await ee(`api/projects/${z(e)}/todos/${z(t)}`)}var yi={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 bi({todo:e,projectId:t,onUpdate:n,onEdit:r,onAction:i,onThreadSelect:a}){let[o,s]=(0,Z.useState)(!1),c=yi[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 _i(t,e.id,{status:a,working:a!==`Done`}))}finally{s(!1)}}return(0,$.jsxs)(`div`,{className:H(`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)(se,{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)(Qt,{children:[(0,$.jsx)($t,{asChild:!0,children:(0,$.jsx)(h,{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)(Xt,{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)(Qt,{children:[(0,$.jsx)($t,{asChild:!0,children:(0,$.jsxs)(h,{size:`icon`,variant:`ghost`,className:`h-7 w-7 shrink-0 group-hover:flex items-center justify-center`,onClick:l,children:[(0,$.jsx)(rt,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Open thread`})]})}),(0,$.jsx)(Xt,{side:`right`,children:`Open thread`})]})]})]})}var xi=`Please analyze this task and create a detailed implementation plan.
|
|
10
|
+
|
|
11
|
+
Task description:
|
|
12
|
+
{description}`,Si="\nWrite your complete plan to the file `{todoId}-plan.md` in the current directory.",Ci=`Act as a Quality Assurance Manager. Rephrase the task into a rigorous test case: {description}`,wi=`Code review: The systematic examination of code to find mistakes, ensure it follows best practices, and identify areas for improvement
|
|
13
|
+
Directions:
|
|
14
|
+
Carefully read through the list of code changes creating a todo list of code to review.
|
|
15
|
+
Analyze the code structure, variable names, functions, and logic flow
|
|
16
|
+
Look for any syntax errors, bugs, or inefficiencies
|
|
17
|
+
Consider best practices for the specific programming language used
|
|
18
|
+
Provide clear and constructive feedback on areas that could be improved
|
|
19
|
+
If applicable, include examples of how to refactor problematic code
|
|
20
|
+
Offer praise for portions of the code that are well-written and follow best practices
|
|
21
|
+
|
|
22
|
+
Task description:
|
|
23
|
+
{description}`,Ti={plan:xi,test:Ci,review:wi},Ei={plan:`planPrompt`,test:`testPrompt`,review:`reviewPrompt`};function Di(e,t){let n=e?.[Ei[t]];return n&&n.trim()?n:Ti[t]}function Oi(e,t,n,r){let i=e.replace(/\{description\}/g,r);return t===`plan`&&(i+=Si.replace(/\{todoId\}/g,n)),i}var ki=[`Ready`,`Plan`,`Build`,`Test`,`Review`,`Done`],Ai={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 ji(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(`
|
|
24
|
+
`);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 Mi(e){let t=e.getReader();try{for(;;){let{done:e}=await t.read();if(e)break}}catch{}}async function Ni(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(`
|
|
25
|
+
`);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 Pi({projectId:e,addOpen:t,onAddOpenChange:n,onThreadSelect:r}){let{state:i,dispatch:o}=zt(),[s,l]=(0,Z.useState)([]),[u,d]=(0,Z.useState)(!0),[f,p]=(0,Z.useState)(null),[m,g]=(0,Z.useState)(``),[_,v]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(!1),[S,C]=(0,Z.useState)(null),[w,T]=(0,Z.useState)(``),[E,D]=(0,Z.useState)(!1),[A,M]=(0,Z.useState)(!1),N=(0,Z.useCallback)(async()=>{try{let t=await hi(e),n=t.filter(e=>e.threadId&&e.status!==`Done`),r=[...t];await Promise.all(n.map(async t=>{try{await O(t.threadId)}catch(n){if(n instanceof Error&&n.message.includes(`not found`)){let n=await _i(e,t.id,{status:`Done`}),i=r.findIndex(e=>e.id===t.id);i!==-1&&(r[i]=n);return}}})),l(r)}catch(e){console.error(`Failed to fetch project todos:`,e)}finally{d(!1)}},[e]);(0,Z.useEffect)(()=>{N()},[N]),(0,Z.useEffect)(()=>{if(!s.some(e=>e.working))return;let t=setInterval(async()=>{try{let n=await hi(e);l(n),n.some(e=>e.working)||clearInterval(t)}catch(e){console.error(`Failed to poll project todos:`,e)}},2e3);return()=>clearInterval(t)},[s,e]),(0,Z.useEffect)(()=>{t&&g(``)},[t]);function F(e){g(e.description),p({todo:e})}function I(){p(null),g(``)}async function L(){if(m.trim()){v(!0);try{let t=await gi(e,m);l(e=>[...e,t]),n(!1),g(``)}finally{v(!1)}}}async function ee(){if(!(!m.trim()||!f)){v(!0);try{let t=await _i(e,f.todo.id,{description:m});l(e=>e.map(e=>e.id===t.id?t:e)),I()}finally{v(!1)}}}async function R(){if(f){v(!0);try{await vi(e,f.todo.id),l(e=>e.filter(e=>e.id!==f.todo.id)),I()}finally{v(!1)}}}function z(e){l(t=>t.map(t=>t.id===e.id?e:t))}async function B(t){let n=i.selectedThreadId?i.projectModelSelections[i.selectedThreadId]:void 0,r=i.projects.find(t=>t.projectId===e),s=r?.threads.find(e=>e.threadId===i.selectedThreadId),l=n?.id??s?.model,u=n?.provider??s?.modelProvider;if(!l||!u)throw console.error(`No model or provider found for project`,e,s),Error(`No model configuration found. Please configure a model and provider for this project first.`);let d=await c(e);if(!d)return;let f=null,p=await ji(d,n=>{_i(e,t.id,{status:`Plan`,working:!0,threadId:n}).then(e=>{f=e,z(e)})});if(!p)return;f||z(await _i(e,t.id,{status:`Plan`,working:!0,threadId:p}));let m=n??{id:l,provider:u,name:l,description:``};o({type:Y.SetProjectModel,threadId:p,model:m}),a(p,{model:l,modelProvider:u});let h=await Fe(p,Oi(Di(r,`plan`),`plan`,t.id,t.description),l,[],void 0,u);h&&Mi(h)}async function V(t){let n=await c(e);if(!n)return;let r=null,i=await ji(n,n=>{_i(e,t.id,{status:`Build`,working:!0,threadId:n}).then(e=>{r=e,z(e)})});if(!i)return;r||z(await _i(e,t.id,{status:`Build`,working:!0,threadId:i}));let s=await O(i),l=s.model,u=s.modelProvider;if(!l||!u)try{let t=(await W(`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.`);o({type:Y.SetProjectModel,threadId:i,model:{id:l,provider:u,name:l,description:``}}),a(i,{model:l,modelProvider:u}),console.log(`Sending chat message with provider:`,i,t.description,u);let d=await Fe(i,t.description,l,[],void 0,u);d&&Mi(d)}async function U(t){try{let n=await c(e);if(!n){b(!1),C(null);return}let r=null;if(r=await ji(n,e=>{r=e}),!r){b(!1),C(null);return}let a=await O(r),o=a.model,s=a.modelProvider;if(!o||!s)try{let t=(await W(`api/threads?projectId=${encodeURIComponent(e)}`)||[]).map(e=>{let t=e;return{model:t.model??void 0,modelProvider:t.modelProvider??void 0}}).find(e=>e.model&&e.modelProvider);t&&(o=t.model,s=t.modelProvider)}catch(e){console.error(`Failed to get project threads:`,e)}if(!o||!s){k(e,r),b(!1),C(null);return}let l=Oi(Di(i.projects.find(t=>t.projectId===e),`test`),`test`,t.id,t.description),u=await Fe(r,l,o,[],void 0,s);u&&T(await Ni(u)),k(e,r)}catch(e){console.error(`Failed to generate test case:`,e),b(!1),C(null)}finally{D(!1)}}function te(e){C(e),T(``),D(!0),b(!0),U(e)}function G(){b(!1),C(null),T(``)}async function ne(){if(!S||!w.trim())return;let t=S,n=w;G(),M(!0);try{let r=await c(e);if(!r)return;let i=null,s=await ji(r,n=>{_i(e,t.id,{status:`Test`,working:!0,threadId:n}).then(e=>{i=e,z(e)})});if(!s)return;i||z(await _i(e,t.id,{status:`Test`,working:!0,threadId:s}));let l=await O(s),u=l.model,d=l.modelProvider;if(!u||!d)try{let t=(await W(`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.`);o({type:Y.SetProjectModel,threadId:s,model:{id:u,provider:d,name:u,description:``}}),a(s,{model:u,modelProvider:d});let f=await Fe(s,n,u,[],void 0,d);f&&Mi(f)}finally{M(!1)}}async function re(t){let n=await c(e);if(!n)return;let r=null,s=await ji(n,n=>{_i(e,t.id,{status:`Review`,working:!0,threadId:n}).then(e=>{r=e,z(e)})});if(!s)return;r||z(await _i(e,t.id,{status:`Review`,working:!0,threadId:s}));let l=await O(s),u=l.model,d=l.modelProvider;if(!u||!d)try{let t=(await W(`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.`);o({type:Y.SetProjectModel,threadId:s,model:{id:u,provider:d,name:u,description:``}}),a(s,{model:u,modelProvider:d});let f=await Fe(s,Oi(Di(i.projects.find(t=>t.projectId===e),`review`),`review`,t.id,t.description),u,[],void 0,d);f&&Mi(f)}async function ie(t,n){n===`Plan`?await B(t):n===`Build`?await V(t):n===`Test`?te(t):n===`Review`?await re(t):z(await _i(e,t.id,{status:n,working:n!==`Done`}))}return u?(0,$.jsx)(`div`,{className:`flex items-center justify-center h-64`,children:(0,$.jsx)(se,{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:ki.map(t=>{let i=s.filter(e=>e.status===t),a=t===`Ready`;return(0,$.jsxs)(`div`,{className:H(`flex flex-col rounded-lg border border-t-4 bg-muted/30 min-w-[200px] w-[200px] shrink-0`,Ai[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)(Ct,{className:`flex-1 px-2 pb-2`,children:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[a&&(0,$.jsxs)(h,{variant:`outline`,size:`sm`,className:`w-full h-8 border-dashed text-muted-foreground hover:text-foreground`,onClick:()=>n(!0),children:[(0,$.jsx)(pt,{className:`h-3 w-3 mr-1`}),`Add Task`]}),i.map(t=>(0,$.jsx)(bi,{todo:t,projectId:e,onUpdate:z,onEdit:F,onAction:ie,onThreadSelect:r},t.id))]})})]},t)})}),(0,$.jsx)(x,{open:t,onOpenChange:n,children:(0,$.jsxs)(P,{className:`sm:max-w-2xl`,children:[(0,$.jsx)(me,{children:(0,$.jsx)(J,{children:`Add Task`})}),(0,$.jsxs)(`div`,{className:`py-2`,children:[(0,$.jsx)(Yt,{placeholder:`Describe what needs to be done...`,value:m,onChange:e=>g(e.target.value),rows:12,className:`resize-none text-sm`,autoFocus:!0,onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&L()}}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1.5`,children:`A title will be generated automatically from your description.`})]}),(0,$.jsx)(j,{children:(0,$.jsx)(h,{onClick:()=>void L(),disabled:_||!m.trim(),children:_?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(se,{className:`h-3 w-3 animate-spin mr-1`}),`Generating title...`]}):`Add`})})]})}),(0,$.jsx)(x,{open:y,onOpenChange:e=>!e&&G(),children:(0,$.jsxs)(P,{className:`sm:max-w-2xl`,children:[(0,$.jsx)(me,{children:(0,$.jsx)(J,{children:`Test Case`})}),(0,$.jsx)(`div`,{className:`py-2`,children:E?(0,$.jsxs)(`div`,{className:`flex items-center justify-center h-32 gap-2 text-muted-foreground`,children:[(0,$.jsx)(se,{className:`h-4 w-4 animate-spin`}),(0,$.jsx)(`span`,{className:`text-sm`,children:`Generating test case...`})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Yt,{value:w,onChange:e=>T(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)(j,{children:[(0,$.jsx)(h,{variant:`outline`,onClick:G,disabled:E,children:`Cancel`}),(0,$.jsx)(h,{onClick:()=>void ne(),disabled:E||!w.trim()||A,children:A?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(se,{className:`h-3 w-3 animate-spin mr-1`}),`Starting...`]}):`Confirm`})]})]})}),(0,$.jsx)(x,{open:f!==null,onOpenChange:e=>!e&&I(),children:(0,$.jsxs)(P,{className:`sm:max-w-2xl`,children:[(0,$.jsx)(me,{children:(0,$.jsx)(J,{children:`Edit Task`})}),(0,$.jsx)(`div`,{className:`py-2`,children:(0,$.jsx)(Yt,{placeholder:`Describe what needs to be done...`,value:m,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)(j,{className:`gap-2 sm:gap-0`,children:[(0,$.jsx)(h,{variant:`destructive`,onClick:()=>void R(),disabled:_,className:`mr-auto`,children:`Delete`}),(0,$.jsx)(h,{onClick:()=>void ee(),disabled:_||!m.trim(),children:_?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(se,{className:`h-3 w-3 animate-spin mr-1`}),`Saving...`]}):`Save`})]})]})})]})}var Fi=[{value:`plan`,label:`Plan`,field:`planPrompt`,defaultPrompt:xi},{value:`review`,label:`Code Review`,field:`reviewPrompt`,defaultPrompt:wi},{value:`test`,label:`Test`,field:`testPrompt`,defaultPrompt:Ci}];function Ii({open:e,onOpenChange:t,projectId:n}){let{state:r}=zt(),[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 ce(n,{planPrompt:i.plan.trim()===xi?null:i.plan.trim()||null,testPrompt:i.test.trim()===Ci?null:i.test.trim()||null,reviewPrompt:i.review.trim()===wi?null:i.review.trim()||null}),G(),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)(x,{open:e,onOpenChange:t,children:(0,$.jsxs)(P,{className:`max-w-2xl`,children:[(0,$.jsxs)(me,{children:[(0,$.jsx)(J,{children:`AI Prompt Settings`}),(0,$.jsx)(it,{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)(Wn,{defaultValue:`plan`,className:`w-full`,children:[(0,$.jsx)(Un,{className:`w-full`,children:Fi.map(e=>(0,$.jsx)(Vn,{value:e.value,className:`flex-1`,children:e.label},e.value))}),Fi.map(e=>(0,$.jsxs)(Hn,{value:e.value,children:[(0,$.jsx)(Yt,{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)(j,{children:(0,$.jsx)(h,{onClick:()=>void c(),disabled:o,children:o?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(se,{className:`mr-2 h-4 w-4 animate-spin`}),`Saving...`]}):`Save`})})]})})}function Li({projectId:e}){let{state:t,dispatch:n}=zt(),{projects:r}=t,[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(!1),c=Tt(),{setActiveMainTab:l}=Nn();async function u(i){if(r.find(t=>t.projectId===e)){c(`/`),l(`chat`);try{let{getProjects:r,invalidateProjectsCache:a}=await Rt(async()=>{let{getProjects:e,invalidateProjectsCache:t}=await import(`./dialogs-config-VlhyoYms.js`).then(e=>e.O);return{getProjects:e,invalidateProjectsCache:t}},__vite__mapDeps([0,1]));a();let o=await r();n({type:Y.SetProjects,projects:o.projects});let s=o.projects.find(t=>t.projectId===e);if(s&&s.threads.find(e=>e.threadId===i)){(t.selectedThreadId!==i||t.selectedProjectId!==e)&&n({type:Y.SelectThread,threadId:i,projectId:e});try{let e=await g();n({type:Y.SetProcessingThreads,threadIds:e})}catch(e){console.error(`Failed to fetch processing threads after thread selection:`,e)}}}catch(r){console.error(`Failed to refresh projects for thread selection:`,r),(t.selectedThreadId!==i||t.selectedProjectId!==e)&&n({type:Y.SelectThread,threadId:i,projectId:e});try{let e=await g();n({type:Y.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)(Pi,{projectId:e,addOpen:i,onAddOpenChange:a,onThreadSelect:u})}),(0,$.jsx)(h,{variant:`outline`,size:`icon`,className:`absolute bottom-8 right-4`,onClick:()=>s(!0),children:(0,$.jsx)(Xe,{className:`h-4 w-4`})}),(0,$.jsx)(Ii,{open:o,onOpenChange:s,projectId:e})]})}var Ri=(0,Z.lazy)(()=>Rt(()=>import(`./diff-view-DUmzPmed.js`),__vite__mapDeps([2,1,3,4,5,6,0,7,8,9,10,11,12,13,14,15,16,17,18,19]))),zi=(0,Z.lazy)(()=>Rt(()=>import(`./dialogs-config-VlhyoYms.js`).then(e=>e.t),__vite__mapDeps([0,1])));function Bi(e){let t=(0,Q.c)(54),{onCreateThread:n}=e,{state:r,dispatch:i}=zt(),a=Tt(),o=At(),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(null),{selectedThreadId:d,messages:f,isCreatingProject:p,processingThreadIds:m,projects:h,projectsLoading:g,messagesLoaded:_,isStreaming:v,streamingSegments:y,streamingModel:b,pendingChatMessage:x}=r,S;t[0]!==m||t[1]!==d?(S=d&&m.includes(d),t[0]=m,t[1]=d,t[2]=S):S=t[2];let C=!!S,w=x?.threadId===d,T;t[3]!==i||t[4]!==r.sidebarOpen?(T=()=>{r.sidebarOpen&&i({type:Y.ToggleSidebar})},t[3]=i,t[4]=r.sidebarOpen,t[5]=T):T=t[5];let E=T,D;t[6]===E?D=t[7]:(D=()=>{E(),u(`clone`),c(!0)},t[6]=E,t[7]=D);let O=D,k;t[8]===E?k=t[9]:(k=()=>{E(),u(`webapp`),c(!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 F(e,t),c(!1),u(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,n)=>{try{await ne(e,t,n),c(!1),u(null)}catch(e){console.error(`Failed to create project:`,e)}},t[11]=N):N=t[11];let P=N,I;t[12]===E?I=t[13]:(I=async()=>{E();try{await dt(),c(!1),u(null)}catch(e){console.error(`Failed to open folder:`,e)}},t[12]=E,t[13]=I);let L=I,ee=o.pathname===`/review`,R=o.pathname===`/todos`,z;t[14]===a?z=t[15]:(z=()=>{a(`/`)},t[14]=a,t[15]=z);let B=z,{selectedProjectId:V}=r,H;t[16]!==E||t[17]!==i||t[18]!==O||t[19]!==B||t[20]!==A||t[21]!==L||t[22]!==w||t[23]!==p||t[24]!==C||t[25]!==v||t[26]!==f||t[27]!==_||t[28]!==n||t[29]!==h||t[30]!==g||t[31]!==ee||t[32]!==V||t[33]!==d||t[34]!==b||t[35]!==y||t[36]!==R?(H=R&&V?(0,$.jsx)(Li,{projectId:V}):ee&&d?(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:`Loading diff view...`}),children:(0,$.jsx)(Ri,{threadId:d,onExit:B})}):(0,$.jsx)(mi,{messages:f,isStreaming:v,streamingSegments:y,streamingModel:b,isCreatingProject:p,isProcessingThread:C,hasPendingMessage:w,selectedThreadId:d,selectedProjectId:V,projects:h,projectsLoading:g,messagesLoaded:_,onSelectThread:(e,t)=>{E(),i({type:Y.SelectThread,projectId:e,threadId:t})},onCreateThread:n,onConnectRepo:O,onNewApp:A,onOpenFolder:L,error:null,onClearError:Vi}),t[16]=E,t[17]=i,t[18]=O,t[19]=B,t[20]=A,t[21]=L,t[22]=w,t[23]=p,t[24]=C,t[25]=v,t[26]=f,t[27]=_,t[28]=n,t[29]=h,t[30]=g,t[31]=ee,t[32]=V,t[33]=d,t[34]=b,t[35]=y,t[36]=R,t[37]=H):H=t[37];let U;t[38]!==f||t[39]!==ee||t[40]!==d||t[41]!==R?(U=!ee&&!R&&d&&(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)(_n,{messages:f})})]}),t[38]=f,t[39]=ee,t[40]=d,t[41]=R,t[42]=U):U=t[42];let te=l??void 0,W;t[43]!==s||t[44]!==L||t[45]!==te?(W=(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(zi,{open:s,onOpenChange:c,initialMode:te,onSubmitClone:M,onSubmitWebApp:P,onOpenFolder:L})}),t[43]=s,t[44]=L,t[45]=te,t[46]=W):W=t[46];let G;t[47]!==U||t[48]!==W||t[49]!==H?(G=(0,$.jsxs)(`div`,{className:`relative flex h-full flex-col`,children:[H,U,W]}),t[47]=U,t[48]=W,t[49]=H,t[50]=G):G=t[50];let re;return t[51]!==d||t[52]!==G?(re=(0,$.jsx)(cn,{threadId:d,children:G}),t[51]=d,t[52]=G,t[53]=re):re=t[53],re}function Vi(){}var Hi=`VS Code`;function Ui(e){return e||Le(Hi)}var Wi={"VS Code":`vscode`,Antigravity:`antigravity`,Cursor:`cursor`,"Devin Desktop":`devin`,Windsurf:`windsurf`,Xcode:`xcode`,"Android Studio":`android-studio`,Kiro:`kiro`,Terminal:`terminal`};function Gi({projectId:e,threadId:t,openWith:n}){let[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)([]),[s,c]=(0,Z.useState)(()=>Ui(n)),[l,u]=(0,Z.useState)(!0);(0,Z.useEffect)(()=>{(async()=>{try{let e=await qe();o(e);let t=Ui(n);e.includes(t)?c(t):e.length>0&&c(e[0])}catch(e){console.error(`Failed to fetch available programs:`,e),o([Hi])}finally{u(!1)}})()},[]),(0,Z.useEffect)(()=>{if(n&&a.includes(n)){c(n);return}let e=Le(Hi);!n&&a.includes(e)&&c(e)},[n,a]);async function d(t){c(t),_t(t),await p(e,t)}let f=async n=>{try{i(!0),await d(n),t?await lt(t,n):await Ze(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)}};async function m(e){try{await d(e)}catch(t){console.error(`Failed to save preferred IDE (${e}):`,t),X({title:`Error`,description:`Failed to save IDE preference`,variant:`destructive`})}}return l?(0,$.jsx)(h,{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)(h,{variant:`outline`,size:`sm`,className:`h-8 rounded-r-none border-r-0 border-transparent`,disabled:r,onClick:async()=>{await f(s)},title:`Open in ${s}`,children:(0,$.jsx)(`img`,{src:`/ide/${Wi[s]||Wi[Hi]}.svg`,alt:s,className:`h-4 w-4`})}),(0,$.jsxs)(hn,{children:[(0,$.jsx)(vn,{asChild:!0,children:(0,$.jsx)(h,{variant:`outline`,size:`sm`,className:`h-8 w-8 rounded-l-none px-1 border-transparent`,disabled:r,children:(0,$.jsx)(we,{className:`h-3.5 w-3.5`})})}),(0,$.jsx)(ln,{align:`end`,children:a.map(e=>(0,$.jsxs)(tn,{onClick:()=>void m(e),disabled:r,className:`flex items-center gap-2`,children:[(0,$.jsx)(`img`,{src:`/ide/${Wi[e]||Wi[Hi]}.svg`,alt:e,className:`h-4 w-4`}),e]},e))})]})]})}function Ki(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 qi(e,t){return t?(0,$.jsx)(se,{className:`h-3.5 w-3.5 animate-spin`}):e.status===`Behind`&&!e.hasChanges&&!e.hasUnpushedCommits?(0,$.jsx)(Re,{className:`h-3.5 w-3.5`}):e.hasChanges?(0,$.jsx)(I,{className:`h-3.5 w-3.5`}):e.prExists&&e.prState===`OPEN`&&!e.hasChanges&&!e.hasUnpushedCommits?(0,$.jsx)(rt,{className:`h-3.5 w-3.5`}):(0,$.jsx)(_,{className:`h-3.5 w-3.5`})}function Ji(e){if(e.status===`Behind`&&!e.hasChanges&&!e.hasUnpushedCommits){let t=e.defaultBranch??`main`;return e.currentBranch===e.defaultBranch?`Your branch is behind the remote. This will pull the latest changes from origin/${t}`:`Your branch "${e.currentBranch}" is behind "${t}". This will rebase and sync with the latest changes`}return 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 Yi(e,t,n=!1){return t||n?!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 Xi(e){return e.hasChanges||e.status===`Behind`&&!e.hasChanges&&!e.hasUnpushedCommits||e.commitsAheadOfDefault&&!e.prExists&&!e.hasChanges}function Zi(e){let t=(0,Q.c)(79),{branchStatus:n,remoteUrl:r,hasRemoteBranch:a,hasUnpushedCommits:o,canCreateRepo:s,repoUrl:c,isRefreshing:l,isBrandState:u,gitUser:d,isDirectCommitMode:f,isLoading:p,isLoadingHistory:m,onFetch:g,onPull:v,onPush:y,onOpenHistory:b,onCreatePR:x,onCreateRepo:S,onViewInGitHub:C}=e,w=`h-8 w-8 rounded-l-none px-1 border-transparent${u?` bg-brand text-brand-foreground hover:bg-brand/90 hover:text-brand-foreground`:``}`,T;t[0]===l?T=t[1]:(T=l?(0,$.jsx)(se,{className:`h-3.5 w-3.5 animate-spin`}):(0,$.jsx)(we,{className:`h-3.5 w-3.5`}),t[0]=l,t[1]=T);let E;t[2]!==p||t[3]!==w||t[4]!==T?(E=(0,$.jsx)(vn,{asChild:!0,children:(0,$.jsx)(h,{variant:`outline`,size:`sm`,className:w,disabled:p,children:T})}),t[2]=p,t[3]=w,t[4]=T,t[5]=E):E=t[5];let D;t[6]!==n||t[7]!==r?(D=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]=D):D=t[8];let O;t[9]===d?O=t[10]:(O=d&&(0,$.jsxs)(`div`,{className:`px-2 py-1 text-xs text-muted-foreground`,children:[(0,$.jsx)(`span`,{className:`font-medium`,children:`User:`}),` `,d]}),t[9]=d,t[10]=O);let k;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,$.jsx)(pn,{}),t[11]=k):k=t[11];let j;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,$.jsx)(A,{className:`h-3.5 w-3.5 mr-2`}),t[12]=j):j=t[12];let M;t[13]!==p||t[14]!==g?(M=(0,$.jsx)($t,{asChild:!0,children:(0,$.jsxs)(tn,{onClick:g,disabled:p,children:[j,`Fetch`]})}),t[13]=p,t[14]=g,t[15]=M):M=t[15];let N;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,$.jsx)(Xt,{side:`right`,children:`Download latest information from remote without merging changes`}),t[16]=N):N=t[16];let P;t[17]===M?P=t[18]:(P=(0,$.jsx)(Zt,{children:(0,$.jsxs)(Qt,{children:[M,N]})}),t[17]=M,t[18]=P);let F;t[19]!==a||t[20]!==p||t[21]!==v?(F=()=>{a&&!p&&v()},t[19]=a,t[20]=p,t[21]=v,t[22]=F):F=t[22];let I=!a||p?`opacity-50 cursor-not-allowed`:``,L;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,$.jsx)(Re,{className:`h-3.5 w-3.5 mr-2`}),t[23]=L):L=t[23];let ee;t[24]!==F||t[25]!==I?(ee=(0,$.jsx)($t,{asChild:!0,children:(0,$.jsxs)(tn,{onClick:F,className:I,children:[L,`Pull`]})}),t[24]=F,t[25]=I,t[26]=ee):ee=t[26];let R=a?`Pull latest changes from remote`:`No remote branch to pull from`,z;t[27]===R?z=t[28]:(z=(0,$.jsx)(Xt,{side:`right`,children:R}),t[27]=R,t[28]=z);let B;t[29]!==ee||t[30]!==z?(B=(0,$.jsx)(Zt,{children:(0,$.jsxs)(Qt,{children:[ee,z]})}),t[29]=ee,t[30]=z,t[31]=B):B=t[31];let V;t[32]!==a||t[33]!==p||t[34]!==y?(V=!a&&(0,$.jsx)(Zt,{children:(0,$.jsxs)(Qt,{children:[(0,$.jsx)($t,{asChild:!0,children:(0,$.jsxs)(tn,{onClick:y,disabled:p,children:[(0,$.jsx)(de,{className:`h-3.5 w-3.5 mr-2`}),`Push Branch to Remote`]})}),(0,$.jsx)(Xt,{side:`right`,children:`Create remote branch and push local commits`})]})}),t[32]=a,t[33]=p,t[34]=y,t[35]=V):V=t[35];let H;t[36]!==o||t[37]!==p||t[38]!==y?(H=()=>{o&&!p&&y()},t[36]=o,t[37]=p,t[38]=y,t[39]=H):H=t[39];let U=!o||p?`opacity-50 cursor-not-allowed`:``,W;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(W=(0,$.jsx)(de,{className:`h-3.5 w-3.5 mr-2`}),t[40]=W):W=t[40];let G;t[41]!==H||t[42]!==U?(G=(0,$.jsx)($t,{asChild:!0,children:(0,$.jsxs)(tn,{onClick:H,className:U,children:[W,`Push Commits`]})}),t[41]=H,t[42]=U,t[43]=G):G=t[43];let ne=o?p?`Push in progress...`:`Push your uncommitted commits to the remote branch`:`No commits to push - your branch is up to date with remote`,re;t[44]===ne?re=t[45]:(re=(0,$.jsx)(Xt,{side:`right`,children:ne}),t[44]=ne,t[45]=re);let ie;t[46]!==G||t[47]!==re?(ie=(0,$.jsx)(Zt,{children:(0,$.jsxs)(Qt,{children:[G,re]})}),t[46]=G,t[47]=re,t[48]=ie):ie=t[48];let ae=p||m,oe;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(oe=(0,$.jsx)(i,{className:`h-3.5 w-3.5 mr-2`}),t[49]=oe):oe=t[49];let ce;t[50]!==b||t[51]!==ae?(ce=(0,$.jsxs)(tn,{onClick:b,disabled:ae,children:[oe,`History`]}),t[50]=b,t[51]=ae,t[52]=ce):ce=t[52];let le;t[53]!==f||t[54]!==p||t[55]!==x?(le=!f&&(0,$.jsxs)(tn,{onClick:x,disabled:p,children:[(0,$.jsx)(_,{className:`h-3.5 w-3.5 mr-2`}),`Create Pull Request`]}),t[53]=f,t[54]=p,t[55]=x,t[56]=le):le=t[56];let ue;t[57]!==s||t[58]!==p||t[59]!==S?(ue=s&&(0,$.jsxs)(tn,{onClick:S,disabled:p,children:[(0,$.jsx)(te,{className:`h-3.5 w-3.5 mr-2`}),`Create Repo`]}),t[57]=s,t[58]=p,t[59]=S,t[60]=ue):ue=t[60];let K;t[61]!==p||t[62]!==C||t[63]!==c?(K=c&&(0,$.jsxs)(tn,{onClick:C,disabled:p,children:[(0,$.jsx)(rt,{className:`h-3.5 w-3.5 mr-2`}),`View in GitHub`]}),t[61]=p,t[62]=C,t[63]=c,t[64]=K):K=t[64];let q;t[65]!==P||t[66]!==B||t[67]!==V||t[68]!==ie||t[69]!==ce||t[70]!==le||t[71]!==ue||t[72]!==K||t[73]!==D||t[74]!==O?(q=(0,$.jsxs)(ln,{align:`end`,children:[D,O,k,P,B,V,ie,ce,le,ue,K]}),t[65]=P,t[66]=B,t[67]=V,t[68]=ie,t[69]=ce,t[70]=le,t[71]=ue,t[72]=K,t[73]=D,t[74]=O,t[75]=q):q=t[75];let fe;return t[76]!==E||t[77]!==q?(fe=(0,$.jsxs)(hn,{children:[E,q]}),t[76]=E,t[77]=q,t[78]=fe):fe=t[78],fe}function Qi(){return{autoGenerateCommitMessage:De(),autoGeneratePRInfo:Me(),privateRepositoryDefault:Ne()}}function $i(e){e.autoGenerateCommitMessage!==void 0&&ht(e.autoGenerateCommitMessage),e.autoGeneratePRInfo!==void 0&&yt(e.autoGeneratePRInfo),e.privateRepositoryDefault!==void 0&&ae(e.privateRepositoryDefault)}function ea(e){return e?!0:(X({title:`Error`,description:`No thread selected`,variant:`destructive`}),!1)}function ta(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)(J,{children:`Commit Changes`}),t[0]=p):p=t[0];let m;t[1]===f?m=t[2]:(m=(0,$.jsxs)(me,{children:[p,(0,$.jsxs)(it,{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)(w,{htmlFor:`commit-message`,children:`Commit Message`}),t[3]=g):g=t[3];let _;t[4]===a?_=t[5]:(_=e=>a(e.target.value),t[4]=a,t[5]=_);let v;t[6]!==i||t[7]!==_?(v=(0,$.jsx)(Yt,{id:`commit-message`,placeholder:`Enter commit message...`,value:i,onChange:_,rows:4,className:`pr-10`}),t[6]=i,t[7]=_,t[8]=v):v=t[8];let y=c||l,b;t[9]===c?b=t[10]:(b=c?(0,$.jsx)(se,{className:`h-3.5 w-3.5 animate-spin`}):(0,$.jsx)(Ae,{className:`h-3.5 w-3.5`}),t[9]=c,t[10]=b);let S;t[11]!==u||t[12]!==y||t[13]!==b?(S=(0,$.jsx)($t,{asChild:!0,children:(0,$.jsx)(h,{type:`button`,variant:`ghost`,size:`icon`,className:`absolute top-2 right-2 h-6 w-6`,onClick:u,disabled:y,children:b})}),t[11]=u,t[12]=y,t[13]=b,t[14]=S):S=t[14];let C=c?`Generating commit message...`:`Generate commit message with AI`,T;t[15]===C?T=t[16]:(T=(0,$.jsx)(Xt,{children:C}),t[15]=C,t[16]=T);let E;t[17]!==T||t[18]!==S?(E=(0,$.jsx)(Zt,{children:(0,$.jsxs)(Qt,{children:[S,T]})}),t[17]=T,t[18]=S,t[19]=E):E=t[19];let D;t[20]!==E||t[21]!==v?(D=(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[g,(0,$.jsxs)(`div`,{className:`relative`,children:[v,E]})]}),t[20]=E,t[21]=v,t[22]=D):D=t[22];let O;t[23]===s?O=t[24]:(O=e=>s(e===!0),t[23]=s,t[24]=O);let k;t[25]!==o||t[26]!==O?(k=(0,$.jsx)(Fn,{id:`auto-generate`,checked:o,onCheckedChange:O}),t[25]=o,t[26]=O,t[27]=k):k=t[27];let A;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,$.jsx)(w,{htmlFor:`auto-generate`,className:`text-sm font-normal`,children:`Auto generate commit messages`}),t[28]=A):A=t[28];let M;t[29]===k?M=t[30]:(M=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[k,A]}),t[29]=k,t[30]=M);let N;t[31]!==D||t[32]!==M?(N=(0,$.jsxs)(`div`,{className:`grid gap-4 py-4`,children:[D,M]}),t[31]=D,t[32]=M,t[33]=N):N=t[33];let F;t[34]===r?F=t[35]:(F=()=>r(!1),t[34]=r,t[35]=F);let I;t[36]!==l||t[37]!==F?(I=(0,$.jsx)(h,{variant:`outline`,onClick:F,disabled:l,children:`Cancel`}),t[36]=l,t[37]=F,t[38]=I):I=t[38];let L;t[39]!==i||t[40]!==l?(L=l||!i.trim(),t[39]=i,t[40]=l,t[41]=L):L=t[41];let ee=l?`Committing...`:`Commit`,R;t[42]!==d||t[43]!==L||t[44]!==ee?(R=(0,$.jsx)(h,{onClick:d,disabled:L,children:ee}),t[42]=d,t[43]=L,t[44]=ee,t[45]=R):R=t[45];let z;t[46]!==I||t[47]!==R?(z=(0,$.jsxs)(j,{children:[I,R]}),t[46]=I,t[47]=R,t[48]=z):z=t[48];let B;t[49]!==N||t[50]!==m||t[51]!==z?(B=(0,$.jsxs)(P,{children:[m,N,z]}),t[49]=N,t[50]=m,t[51]=z,t[52]=B):B=t[52];let V;return t[53]!==r||t[54]!==n||t[55]!==B?(V=(0,$.jsx)(x,{open:n,onOpenChange:r,children:B}),t[53]=r,t[54]=n,t[55]=B,t[56]=V):V=t[56],V}function na(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)(J,{children:`Create Pull Request`}),t[0]=g):g=t[0];let _;t[1]===f?_=t[2]:(_=(0,$.jsxs)(me,{children:[g,(0,$.jsxs)(it,{children:[`Create a pull request for branch `,f]})]}),t[1]=f,t[2]=_);let v;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(w,{htmlFor:`pr-title`,children:`Title (optional)`}),t[3]=v):v=t[3];let y=f||`Enter PR title...`,b;t[4]===a?b=t[5]:(b=e=>a(e.target.value),t[4]=a,t[5]=b);let S;t[6]!==i||t[7]!==y||t[8]!==b?(S=(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[v,(0,$.jsx)(q,{id:`pr-title`,placeholder:y,value:i,onChange:b})]}),t[6]=i,t[7]=y,t[8]=b,t[9]=S):S=t[9];let C;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,$.jsx)(w,{htmlFor:`pr-description`,children:`Description (optional)`}),t[10]=C):C=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)(Yt,{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 D=c||l,O;t[16]===c?O=t[17]:(O=c?(0,$.jsx)(se,{className:`h-3.5 w-3.5 animate-spin`}):(0,$.jsx)(Ae,{className:`h-3.5 w-3.5`}),t[16]=c,t[17]=O);let k;t[18]!==u||t[19]!==D||t[20]!==O?(k=(0,$.jsx)($t,{asChild:!0,children:(0,$.jsx)(h,{type:`button`,variant:`ghost`,size:`icon`,className:`absolute top-2 right-2 h-6 w-6`,onClick:u,disabled:D,children:O})}),t[18]=u,t[19]=D,t[20]=O,t[21]=k):k=t[21];let A=c?`Generating PR description...`:`Generate PR title and description with AI`,M;t[22]===A?M=t[23]:(M=(0,$.jsx)(Xt,{children:A}),t[22]=A,t[23]=M);let N;t[24]!==k||t[25]!==M?(N=(0,$.jsx)(Zt,{children:(0,$.jsxs)(Qt,{children:[k,M]})}),t[24]=k,t[25]=M,t[26]=N):N=t[26];let F;t[27]!==N||t[28]!==E?(F=(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[C,(0,$.jsxs)(`div`,{className:`relative`,children:[E,N]})]}),t[27]=N,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)(Fn,{id:`auto-generate-pr`,checked:p,onCheckedChange:I}),t[32]=p,t[33]=I,t[34]=L):L=t[34];let ee;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(ee=(0,$.jsx)(w,{htmlFor:`auto-generate-pr`,className:`text-sm font-normal`,children:`Auto generate PR title and description`}),t[35]=ee):ee=t[35];let R;t[36]===L?R=t[37]:(R=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[L,ee]}),t[36]=L,t[37]=R);let z;t[38]!==F||t[39]!==R||t[40]!==S?(z=(0,$.jsxs)(`div`,{className:`grid gap-4 py-4`,children:[S,F,R]}),t[38]=F,t[39]=R,t[40]=S,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)(h,{variant:`outline`,onClick:B,disabled:l,children:`Cancel`}),t[44]=l,t[45]=B,t[46]=V):V=t[46];let H=l?`Creating...`:`Create PR`,U;t[47]!==l||t[48]!==d||t[49]!==H?(U=(0,$.jsx)(h,{onClick:d,disabled:l,children:H}),t[47]=l,t[48]=d,t[49]=H,t[50]=U):U=t[50];let te;t[51]!==V||t[52]!==U?(te=(0,$.jsxs)(j,{children:[V,U]}),t[51]=V,t[52]=U,t[53]=te):te=t[53];let W;t[54]!==_||t[55]!==z||t[56]!==te?(W=(0,$.jsxs)(P,{children:[_,z,te]}),t[54]=_,t[55]=z,t[56]=te,t[57]=W):W=t[57];let G;return t[58]!==r||t[59]!==n||t[60]!==W?(G=(0,$.jsx)(x,{open:n,onOpenChange:r,children:W}),t[58]=r,t[59]=n,t[60]=W,t[61]=G):G=t[61],G}function ra(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)(me,{children:[(0,$.jsx)(J,{children:`Create GitHub Repository`}),(0,$.jsx)(it,{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)(w,{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 _;t[8]!==i||t[9]!==g?(_=(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[m,(0,$.jsx)(q,{id:`repo-name`,placeholder:`Leave empty to use current folder name`,value:i,onChange:g})]}),t[8]=i,t[9]=g,t[10]=_):_=t[10];let v;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(w,{htmlFor:`repo-description`,children:`Description (optional)`}),t[11]=v):v=t[11];let y;t[12]===s?y=t[13]:(y=e=>s(e.target.value),t[12]=s,t[13]=y);let b;t[14]!==o||t[15]!==y?(b=(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[v,(0,$.jsx)(Yt,{id:`repo-description`,placeholder:`Enter repository description...`,value:o,onChange:y,rows:3})]}),t[14]=o,t[15]=y,t[16]=b):b=t[16];let S;t[17]===l?S=t[18]:(S=e=>l(e===!0),t[17]=l,t[18]=S);let C;t[19]!==c||t[20]!==S?(C=(0,$.jsx)(Fn,{id:`repo-private`,checked:c,onCheckedChange:S}),t[19]=c,t[20]=S,t[21]=C):C=t[21];let T;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(w,{htmlFor:`repo-private`,className:`text-sm font-normal`,children:`Private repository`}),t[22]=T):T=t[22];let E;t[23]===C?E=t[24]:(E=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[C,T]}),t[23]=C,t[24]=E);let D;t[25]!==E||t[26]!==_||t[27]!==b?(D=(0,$.jsxs)(`div`,{className:`grid gap-4 py-4`,children:[_,b,E]}),t[25]=E,t[26]=_,t[27]=b,t[28]=D):D=t[28];let O;t[29]===r?O=t[30]:(O=()=>r(!1),t[29]=r,t[30]=O);let k;t[31]!==u||t[32]!==O?(k=(0,$.jsx)(h,{variant:`outline`,onClick:O,disabled:u,children:`Cancel`}),t[31]=u,t[32]=O,t[33]=k):k=t[33];let A=u?`Creating...`:`Create & Push`,M;t[34]!==u||t[35]!==d||t[36]!==A?(M=(0,$.jsx)(h,{onClick:d,disabled:u,children:A}),t[34]=u,t[35]=d,t[36]=A,t[37]=M):M=t[37];let N;t[38]!==k||t[39]!==M?(N=(0,$.jsxs)(j,{children:[k,M]}),t[38]=k,t[39]=M,t[40]=N):N=t[40];let F;t[41]!==D||t[42]!==N?(F=(0,$.jsxs)(P,{children:[p,D,N]}),t[41]=D,t[42]=N,t[43]=F):F=t[43];let I;return t[44]!==n||t[45]!==f||t[46]!==F?(I=(0,$.jsx)(x,{open:n,onOpenChange:f,children:F}),t[44]=n,t[45]=f,t[46]=F,t[47]=I):I=t[47],I}function ia(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)(J,{children:`Commit History`}),t[0]=l):l=t[0];let u;t[1]===c?u=t[2]:(u=(0,$.jsxs)(me,{children:[l,(0,$.jsxs)(it,{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(aa):(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)(se,{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 g;t[15]!==s||t[16]!==m?(g=(0,$.jsx)(`div`,{className:`flex-1 overflow-y-auto border rounded-lg`,onScroll:s,children:m}),t[15]=s,t[16]=m,t[17]=g):g=t[17];let _;t[18]===r?_=t[19]:(_=(0,$.jsx)(j,{children:(0,$.jsx)(h,{onClick:()=>r(!1),children:`Close`})}),t[18]=r,t[19]=_);let v;t[20]!==u||t[21]!==g||t[22]!==_?(v=(0,$.jsxs)(P,{className:`max-w-2xl max-h-[80vh] flex flex-col`,children:[u,g,_]}),t[20]=u,t[21]=g,t[22]=_,t[23]=v):v=t[23];let y;return t[24]!==r||t[25]!==n||t[26]!==v?(y=(0,$.jsx)(x,{open:n,onOpenChange:r,children:v}),t[24]=r,t[25]=n,t[26]=v,t[27]=y):y=t[27],y}function aa(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 oa(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)(me,{children:[(0,$.jsx)(J,{children:`Push Branch First`}),(0,$.jsx)(it,{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)(h,{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)(h,{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)(P,{children:[s,(0,$.jsxs)(j,{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)(x,{open:n,onOpenChange:r,children:d}),t[11]=r,t[12]=n,t[13]=d,t[14]=f):f=t[14],f}function sa(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)(me,{children:[(0,$.jsxs)(J,{className:`flex items-center gap-2`,children:[(0,$.jsx)(S,{className:`h-5 w-5 text-amber-500`}),`Uncommitted Changes Detected`]}),(0,$.jsx)(it,{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)(I,{className:`h-4 w-4 mr-2`}),t[2]=d):d=t[2];let f;t[3]!==c||t[4]!==i?(f=(0,$.jsxs)(h,{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)(ve,{className:`h-4 w-4 mr-2`}),t[6]=p):p=t[6];let m;t[7]!==c||t[8]!==a?(m=(0,$.jsxs)(h,{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]=m):m=t[9];let g;t[10]!==f||t[11]!==m?(g=(0,$.jsxs)(`div`,{className:`space-y-2`,children:[f,m]}),t[10]=f,t[11]=m,t[12]=g):g=t[12];let _;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(`strong`,{children:`Commit first:`}),t[13]=_):_=t[13];let v;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsxs)(`div`,{className:`text-xs text-muted-foreground mt-4`,children:[_,` Safe option, preserves changes in your commit history`,(0,$.jsx)(`br`,{}),(0,$.jsx)(`strong`,{children:`Stash and pull:`}),` Temporary option, changes will be restored after pulling`]}),t[14]=v):v=t[14];let y;t[15]===g?y=t[16]:(y=(0,$.jsx)(`div`,{className:`py-4`,children:(0,$.jsxs)(`div`,{className:`space-y-3`,children:[u,g,v]})}),t[15]=g,t[16]=y);let b;t[17]!==c||t[18]!==o?(b=(0,$.jsx)(j,{children:(0,$.jsx)(h,{variant:`ghost`,onClick:o,disabled:c,children:`Cancel`})}),t[17]=c,t[18]=o,t[19]=b):b=t[19];let C;t[20]!==y||t[21]!==b?(C=(0,$.jsxs)(P,{className:`sm:max-w-[425px]`,children:[l,y,b]}),t[20]=y,t[21]=b,t[22]=C):C=t[22];let w;return t[23]!==r||t[24]!==n||t[25]!==C?(w=(0,$.jsx)(x,{open:n,onOpenChange:r,children:C}),t[23]=r,t[24]=n,t[25]=C,t[26]=w):w=t[26],w}function ca(e){let t=(0,Q.c)(14),{open:n,onOpenChange:r,onNewBranch:i,onJustOpen:a,isLoading:o}=e,s=o===void 0?!1:o,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsxs)(me,{children:[(0,$.jsx)(J,{children:`Pull Request Merged`}),(0,$.jsx)(it,{children:`As the pull request has been merged, a new branch will be created from the current checkout.`})]}),t[0]=c):c=t[0];let l;t[1]!==s||t[2]!==a?(l=(0,$.jsx)(h,{variant:`ghost`,onClick:a,disabled:s,children:`Just Open`}),t[1]=s,t[2]=a,t[3]=l):l=t[3];let u;t[4]!==s||t[5]!==i?(u=(0,$.jsx)(h,{onClick:i,disabled:s,children:`New Branch`}),t[4]=s,t[5]=i,t[6]=u):u=t[6];let d;t[7]!==l||t[8]!==u?(d=(0,$.jsxs)(P,{children:[c,(0,$.jsxs)(j,{children:[l,u]})]}),t[7]=l,t[8]=u,t[9]=d):d=t[9];let f;return t[10]!==r||t[11]!==n||t[12]!==d?(f=(0,$.jsx)(x,{open:n,onOpenChange:r,children:d}),t[10]=r,t[11]=n,t[12]=d,t[13]=f):f=t[13],f}function la(e){let t=e.split(`/`);return t.length>=2?{provider:t[0],model:t.slice(1).join(`/`)}:{provider:void 0,model:e}}function ua(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}:la(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 ut(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 xe(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 da({projectId:e,threadId:t}){let{state:n,dispatch:r}=zt(),[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,g]=(0,Z.useState)(``),[_,v]=(0,Z.useState)(``),[y,b]=(0,Z.useState)(``),[x,S]=(0,Z.useState)(!1),[w,D]=(0,Z.useState)(null),O=(0,Z.useRef)(!1),k=(0,Z.useRef)(!1),[A,j]=(0,Z.useState)(!1),[M,P]=(0,Z.useState)([]),[F,I]=(0,Z.useState)(!1),[L,ee]=(0,Z.useState)([]),[R,z]=(0,Z.useState)(!1),[B,V]=(0,Z.useState)(!1),[H,U]=(0,Z.useState)(``),[te,W]=(0,Z.useState)(``),[ne,re]=(0,Z.useState)(``),[ie,ae]=(0,Z.useState)(!1),[oe,se]=(0,Z.useState)(!1),[ce,le]=(0,Z.useState)(!1),K=fn(t),q=ua(t,e,n.projectModelSelections);async function de(){G();let e=await s();r({type:Y.SetProjects,projects:e.projects})}let[J,me]=(0,Z.useState)(()=>Qi()),he=n.projects.find(t=>t.projectId===e),ge=he?.commitMethod===m.Direct;(0,Z.useEffect)(()=>{function e(){document.visibilityState===`visible`&&K.fetchUnifiedStatus(!0)}return document.addEventListener(`visibilitychange`,e),window.addEventListener(`focus`,e),()=>{document.removeEventListener(`visibilitychange`,e),window.removeEventListener(`focus`,e)}},[K.fetchUnifiedStatus]),(0,Z.useEffect)(()=>{B&&he?.name&&!H&&U(he.name)},[B,he?.name,H]),(0,Z.useEffect)(()=>{$i(J)},[J]),(0,Z.useEffect)(()=>{let e=!0;return ye().then(t=>{e&&re(t)}).catch(()=>{}),()=>{e=!1}},[]),(0,Z.useEffect)(()=>{if(!l){k.current=!1;return}if(l&&J.autoGenerateCommitMessage&&!p.trim()&&t&&!k.current){k.current=!0;async function e(){let e=await q.generateCommitMessageWithAI();e&&g(e)}e()}},[l,J.autoGenerateCommitMessage,t,q,p]),(0,Z.useEffect)(()=>{if(!d){O.current=!1;return}if(console.log(`[pr-auto-gen] useEffect triggered`,{isPRDialogOpen:d,autoGeneratePRInfo:J.autoGeneratePRInfo,prTitleEmpty:!_.trim(),prDescriptionEmpty:!y.trim(),threadId:t,hasThreadId:!!t,generationAlreadyStarted:O.current}),d&&J.autoGeneratePRInfo&&!_.trim()&&!y.trim()&&t&&!O.current){console.log(`[pr-auto-gen] Starting auto-generation...`),O.current=!0;async function e(){let e=await q.generatePRInfoWithAI();e&&(console.log(`[pr-auto-gen] Setting PR info:`,e.title.substring(0,50)),v(e.title),b(e.description))}e()}else console.log(`[pr-auto-gen] Skipping auto-generation - conditions not met`)},[d,J.autoGeneratePRInfo,t,q,_,y]),(0,Z.useEffect)(()=>{console.log(`Unified status changed:`,{prExists:K.prExists,prState:K.prState,threadId:t}),K.prExists&&K.prState===`MERGED`&&(console.log(`Merged PR detected, opening dialog`),le(!0)),o&&K.prExists&&K.prState===`OPEN`&&(console.log(`[pr-creation] PR confirmed in status, clearing isCreatingPR`),c(!1))},[K.prExists,K.prState,t,o]),(0,Z.useEffect)(()=>{if(!o)return;let e=setTimeout(()=>{console.log(`[pr-creation] Safety timeout reached, clearing isCreatingPR`),c(!1)},15e3);return()=>clearTimeout(e)},[o]),(0,Z.useEffect)(()=>{!n.isStreaming&&n.completedThreadIds.includes(n.selectedThreadId??``)&&(K.fetchUnifiedStatus(!0),r({type:Y.ClearThreadCompleted,threadId:n.selectedThreadId??``}))},[n.isStreaming,n.completedThreadIds,n.selectedThreadId,K,r]);async function _e(){if(p.trim()&&ea(t))try{a(!0),await T(t,p),g(``),u(!1),await K.fetchUnifiedStatus(!0),de(),X({title:`Changes committed successfully`,description:`Your changes have been committed to '${K.currentBranch}'.`}),oe&&(se(!1),await we())}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 ve(){if(K.status===`Behind`&&!K.hasChanges&&!K.hasUnpushedCommits){await Oe();return}if(K.hasChanges){u(!0);return}if(K.prExists&&K.prState===`OPEN`&&!K.hasChanges&&!K.hasUnpushedCommits){K.prUrl&&await je(K.prUrl);return}if(K.commitsAheadOfDefault&&!K.prExists&&!K.hasChanges){f(!0);return}if(K.hasUnpushedCommits&&K.prExists){await Se();return}}async function be(){let e=await q.generateCommitMessageWithAI();e&&g(e)}async function xe(){if(ea(t))try{a(!0),await C(t),await K.fetchUnifiedStatus()}catch(e){console.error(`Failed to fetch:`,e)}finally{a(!1)}}async function Se(){if(ea(t))try{a(!0),await N(t),await K.fetchUnifiedStatus(!0),de(),K.hasRemoteBranch?X({title:`Branch pushed successfully`,description:`Your branch '${K.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 Ce(){if(ea(t)){if(K.hasChanges){ae(!0);return}await we()}}async function we(){try{a(!0),await ot(t),await K.fetchUnifiedStatus(!0),de(),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 Te(){ae(!1),se(!0),u(!0)}async function Ee(){ae(!1),await we()}async function De(){if(t)try{a(!0);let e=await ue(t);G();let n=await s();r({type:Y.SetProjects,projects:n.projects}),X({title:`New branch created`,description:`Created new branch "${e.branchName}" on current thread`}),le(!1),await K.fetchUnifiedStatus(!0),setTimeout(()=>void K.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 Oe(){if(!ea(t)){console.log(`[sync] Thread operation validation failed`);return}try{console.log(`[sync] Starting branch sync for thread: ${t}`),console.log(`[sync] Current branch: ${K.currentBranch}, Default branch: ${K.defaultBranch}`),a(!0),console.log(`[sync] Calling gitSyncBranch API...`);let e=await pe(t);console.log(`[sync] ✓ gitSyncBranch API call successful`),console.log(`[sync] Result:`,e),console.log(`[sync] Refreshing git status...`),await K.fetchUnifiedStatus(!0),de(),console.log(`[sync] ✓ Git status refreshed`),X({title:`Branch synced successfully`,description:`Your branch '${K.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 ke(){if(ea(t))try{a(!0),c(!0);let e=await fe(t,_,y);e.prUrl&&await je(e.prUrl),v(``),b(``),f(!1),await K.fetchUnifiedStatus(!0),de();let n=0,r=setInterval(async()=>{if(n++,n>=6){clearInterval(r);return}await K.fetchUnifiedStatus(!0)},2e3)}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),Ne({title:_,description:y})):(c(!1),X({title:`Create PR Failed`,description:t,variant:`destructive`}))}finally{a(!1)}}async function Ae(){if(ea(t))try{a(!0);let e=await E(t,H,te,J.privateRepositoryDefault);e.repoUrl&&setTimeout(()=>{je(e.repoUrl)},3e3),U(``),W(``),V(!1),await K.fetchUnifiedStatus(),de()}catch(e){console.error(`Failed to create repo:`,e)}finally{a(!1)}}async function Me(){let e=await q.generatePRInfoWithAI();e&&(v(e.title),b(e.description))}async function Ne(e){let n=e??w;if(!(!t||!n))try{a(!0),c(!0);try{await N(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 pe(t),console.log(`[push-and-pr] ✓ Pull completed, retrying push...`),await N(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 fe(t,n.title,n.description);e.prUrl&&await je(e.prUrl),v(``),b(``),D(null),S(!1),await K.fetchUnifiedStatus(!0),de();let r=0,i=setInterval(async()=>{if(r++,r>=6){clearInterval(i);return}await K.fetchUnifiedStatus(!0)},2e3)}catch(e){console.error(`Failed to push and create PR:`,e);let t=e instanceof Error?e.message:`Failed to push and create PR`;c(!1),X({title:`Push & Create PR Failed`,description:t,variant:`destructive`})}finally{a(!1)}}async function Pe(){if(ea(t))try{I(!0);let e=await Ve(t,100);P(e),ee(e.slice(0,10)),j(!0)}catch(e){console.error(`Failed to fetch git history:`,e)}finally{I(!1)}}function Fe(){R||(z(!0),setTimeout(()=>{let e=L.length+10;ee(M.slice(0,e)),z(!1)},300))}function Ie(e){let t=e.currentTarget;t.scrollHeight-t.scrollTop-t.clientHeight<100&&L.length<M.length&&!R&&Fe()}let Le=Xi(K);function Re(){K.repoUrl&&je(K.repoUrl)}function ze(){S(!1),D(null)}function Be(){le(!1),K.fetchUnifiedStatus(!0)}return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-0`,children:[(0,$.jsx)(Zt,{children:(0,$.jsxs)(Qt,{children:[(0,$.jsx)($t,{asChild:!0,children:(0,$.jsxs)(h,{variant:`outline`,size:`sm`,className:`h-8 rounded-r-none border-r-0 gap-1.5 border-transparent${Le?` bg-brand text-brand-foreground hover:bg-brand/90 hover:text-brand-foreground`:``}`,disabled:Yi(K,i,o),onClick:ve,children:[qi(K,o),Ki(K,o)]})}),(0,$.jsx)(Xt,{children:Ji(K)})]})}),(0,$.jsx)(Zi,{branchStatus:K.status,remoteUrl:K.remoteUrl,hasRemoteBranch:K.hasRemoteBranch,hasUnpushedCommits:K.hasUnpushedCommits,canCreateRepo:K.canCreateRepo,repoUrl:K.repoUrl,isRefreshing:K.isRefreshing,isBrandState:Le,gitUser:ne,isDirectCommitMode:ge,isLoading:i||o,isLoadingHistory:F,onFetch:()=>void xe(),onPull:()=>void Ce(),onPush:()=>void Se(),onOpenHistory:()=>void Pe(),onCreatePR:()=>f(!0),onCreateRepo:()=>V(!0),onViewInGitHub:Re})]}),(0,$.jsx)(ta,{open:l,onOpenChange:u,commitMessage:p,onCommitMessageChange:g,autoGenerateCommitMessage:J.autoGenerateCommitMessage,onAutoGenerateChange:e=>me(t=>({...t,autoGenerateCommitMessage:e})),isGeneratingMessage:q.isGeneratingMessage,isLoading:i,onGenerateMessage:be,onCommit:_e,currentBranch:K.currentBranch}),(0,$.jsx)(na,{open:d,onOpenChange:f,prTitle:_,onPrTitleChange:v,prDescription:y,onPrDescriptionChange:b,isGeneratingPRInfo:q.isGeneratingPRInfo,isLoading:i,onGeneratePRInfo:Me,onCreatePR:ke,currentBranch:K.currentBranch,autoGeneratePRInfo:J.autoGeneratePRInfo,onAutoGeneratePRInfoChange:e=>me(t=>({...t,autoGeneratePRInfo:e}))}),(0,$.jsx)(oa,{open:x,onOpenChange:S,isLoading:i,onPushAndCreatePR:Ne,onCancel:ze}),(0,$.jsx)(ra,{open:B,onOpenChange:V,repoName:H,onRepoNameChange:U,repoDescription:te,onRepoDescriptionChange:W,isPrivateRepo:J.privateRepositoryDefault,onPrivateRepoChange:e=>me(t=>({...t,privateRepositoryDefault:e})),isLoading:i,onCreateRepo:Ae}),(0,$.jsx)(ia,{open:A,onOpenChange:j,commits:M,displayedCommits:L,isLoadingMore:R,onScroll:Ie,currentBranch:K.currentBranch}),(0,$.jsx)(sa,{open:ie,onOpenChange:ae,onCommitFirst:Te,onStashAndPull:Ee,onCancel:()=>ae(!1),isLoading:i}),(0,$.jsx)(ca,{open:ce,onOpenChange:le,onNewBranch:De,onJustOpen:Be,isLoading:i})]})}var fa=`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 pa({open:e,onOpenChange:t,projectId:n,commands:r,onRefresh:i}){let[a,o]=(0,Z.useState)(null),[s,c]=(0,Z.useState)(!1),[l,d]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)([]),[m,g]=(0,Z.useState)(0),[_,v]=(0,Z.useState)(!1),y=(0,Z.useRef)(null),b=(0,Z.useRef)(null),S=()=>{o({id:crypto.randomUUID(),name:``,icon:`Play`,commandLine:``}),d(!1),p([])},C=e=>{o({...e}),d(!1),p([])},T=async()=>{try{v(!0);let e=await Ce(n);p(e.scripts),g(0),d(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{v(!1)}},E=e=>{o(t=>t?{...t,name:e.name,commandLine:e.commandLine,relativeFolder:e.relativePath||``}:null),d(!1),p([]),y.current?.focus()},D=e=>{l&&(e.key===`ArrowDown`?(e.preventDefault(),g(e=>e<f.length-1?e+1:e)):e.key===`ArrowUp`?(e.preventDefault(),g(e=>e>0?e-1:0)):e.key===`Enter`?(e.preventDefault(),m<f.length&&E(f[m])):e.key===`Escape`&&(e.preventDefault(),d(!1),p([])))};(0,Z.useEffect)(()=>{let e=e=>{b.current&&!b.current.contains(e.target)&&(d(!1),p([]))};return l&&document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[l]);let O=async e=>{try{await le(n,e),X({title:`Success`,description:`Command deleted`}),i()}catch{X({title:`Error`,description:`Failed to delete command`,variant:`destructive`})}};return(0,$.jsx)(x,{open:e,onOpenChange:t,children:(0,$.jsxs)(P,{className:`sm:max-w-[500px]`,children:[(0,$.jsxs)(me,{children:[(0,$.jsx)(J,{children:`Project Commands`}),(0,$.jsx)(it,{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)(w,{htmlFor:`name`,children:`Command Name`}),(0,$.jsx)(q,{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)(w,{htmlFor:`commandLine`,children:`Command Line`}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(Yt,{ref:y,id:`commandLine`,value:a.commandLine,onChange:e=>o({...a,commandLine:e.target.value}),onKeyDown:D,placeholder:`e.g. npm test`,className:`font-mono text-xs min-h-[100px] resize-none pr-10`}),(0,$.jsx)(Zt,{children:(0,$.jsxs)(Qt,{children:[(0,$.jsx)($t,{asChild:!0,children:(0,$.jsx)(h,{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)(we,{className:`h-4 w-4`})})}),(0,$.jsx)(Xt,{children:(0,$.jsx)(`p`,{children:`Discover package scripts`})})]})})]}),l&&(0,$.jsx)(`div`,{ref:b,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)(we,{className:`h-3 w-3`}),`Available Scripts `,_&&`(loading...)`]}),f.length>0?(()=>{let e={};f.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:H(`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)(w,{htmlFor:`relativeFolder`,children:`Relative Folder`}),(0,$.jsx)(q,{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)(w,{children:`Icon`}),(0,$.jsx)(`div`,{className:`grid grid-cols-10 gap-1 p-2 bg-background rounded-md border border-border`,children:fa.map(e=>{let t=ie[e]||Ye;return(0,$.jsx)(h,{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)(h,{variant:`ghost`,size:`sm`,onClick:()=>o(null),children:[(0,$.jsx)(u,{className:`h-4 w-4 mr-2`}),` Cancel`]}),(0,$.jsxs)(h,{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 Ke(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)(Ge,{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:()=>C(e),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`div`,{className:`p-2 bg-muted rounded`,children:(0,$.jsx)(ie[e.icon]||Oe,{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)(h,{variant:`ghost`,size:`icon`,className:`h-8 w-8 text-muted-foreground hover:bg-destructive hover:text-destructive-foreground transition-colors`,onClick:t=>{t.stopPropagation(),O(e.id)},children:(0,$.jsx)(at,{className:`h-4 w-4`})})})]},e.id))]}),(0,$.jsxs)(h,{variant:`outline`,className:`w-full border-dashed`,onClick:S,children:[(0,$.jsx)(pt,{className:`h-4 w-4 mr-2`}),` Add New Command`]})]})})]})})}function ma(){let e=(0,Q.c)(27),{state:t}=zt(),{selectedProjectId:n,selectedThreadId:r,projects:i}=t,{dispatch:a}=Kt(r),[o,s]=(0,Z.useState)(!1),c,l,u,d,f;if(e[0]!==a||e[1]!==i||e[2]!==n||e[3]!==r||e[4]!==t.isRunningCommand){f=Symbol.for(`react.early_return_sentinel`);bb0:{let o;e[10]===n?o=e[11]:(o=e=>e.projectId===n,e[10]=n,e[11]=o),c=i.find(o)?.commands??[];let p;e[12]!==a||e[13]!==n||e[14]!==r?(p=e=>{!n||!r||a({type:Y.QueueTerminalCommand,threadId:r,command:e.commandLine,relativeFolder:e.relativeFolder})},e[12]=a,e[13]=n,e[14]=r,e[15]=p):p=e[15];let m=p,g;if(e[16]===a?g=e[17]:(g=async()=>{a({type:Y.ConfigUpdated})},e[16]=a,e[17]=g),l=g,!n){f=null;break bb0}u=`flex items-center gap-1`,d=c.length===0?(0,$.jsx)(Zt,{children:(0,$.jsxs)(Qt,{children:[(0,$.jsx)($t,{asChild:!0,children:(0,$.jsx)(h,{variant:`action`,size:`icon-md`,onClick:()=>s(!0),children:(0,$.jsx)(ct,{})})}),(0,$.jsx)(Xt,{children:`Manage commands`})]})}):(0,$.jsx)($.Fragment,{children:(0,$.jsxs)(Zt,{children:[c.map(e=>{let n=ie[e.icon]||Oe;return(0,$.jsxs)(Qt,{children:[(0,$.jsx)($t,{asChild:!0,children:(0,$.jsx)(h,{variant:`action`,size:`icon-md`,onClick:()=>m({commandLine:e.commandLine,relativeFolder:e.relativeFolder}),disabled:t.isRunningCommand,children:(0,$.jsx)(n,{})})}),(0,$.jsx)(Xt,{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)(Qt,{children:[(0,$.jsx)($t,{asChild:!0,children:(0,$.jsx)(h,{variant:`action`,size:`icon-md`,className:`ml-1`,onClick:()=>s(!0),children:(0,$.jsx)(ct,{})})}),(0,$.jsx)(Xt,{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)(pa,{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 ha(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 ga({threadId:e}){let{dispatch:t}=zt(),{setTerminalNotification:n}=Nn(),[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 We(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 Se(e,r.name)}catch{}t({type:Y.AppendTerminalLine,threadId:e,line:{type:`system`,content:`■ ${r.friendlyName} stopped`}}),o(e=>{let t=new Set(e);return t.delete(r.name),t})}else{let i=new AbortController;s.current.set(r.name,i),o(e=>new Set([...e,r.name])),n(!0),t({type:Y.AppendTerminalLine,threadId:e,line:{type:`system`,content:`▶ ${r.friendlyName}`}});try{let n=await Ee(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(`
|
|
26
|
+
`);a=s.pop()??``;for(let n of s)if(n.trim())try{let r=JSON.parse(n);typeof r==`string`?t({type:Y.AppendTerminalLine,threadId:e,line:{type:`output`,content:r}}):r.type===`error`&&t({type:Y.AppendTerminalLine,threadId:e,line:{type:`error`,content:r.message}})}catch{t({type:Y.AppendTerminalLine,threadId:e,line:{type:`output`,content:n}})}}if(a.trim())try{let n=JSON.parse(a);typeof n==`string`?t({type:Y.AppendTerminalLine,threadId:e,line:{type:`output`,content:n}}):n.type===`error`&&t({type:Y.AppendTerminalLine,threadId:e,line:{type:`error`,content:n.message}})}catch{t({type:Y.AppendTerminalLine,threadId:e,line:{type:`output`,content:a}})}}finally{r.releaseLock()}}t({type:Y.AppendTerminalLine,threadId:e,line:{type:`system`,content:`✓ ${r.friendlyName} done`}})}catch{}finally{s.current.delete(r.name),o(e=>{let t=new Set(e);return t.delete(r.name),t})}}};if(!r)return null;let l=r.reduce((e,t)=>(e[t.workspace]||(e[t.workspace]=[]),e[t.workspace].push(t),e),{}),u=Object.entries(l).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>[e,[...t].sort((e,t)=>e.friendlyName.localeCompare(t.friendlyName))]),d=u.length>1;return(0,$.jsxs)(hn,{children:[(0,$.jsx)(Zt,{children:(0,$.jsxs)(Qt,{children:[(0,$.jsx)($t,{asChild:!0,children:(0,$.jsx)(vn,{asChild:!0,children:(0,$.jsx)(h,{variant:`action`,size:`icon-md`,children:(0,$.jsx)($e,{})})})}),(0,$.jsx)(Xt,{children:`Project Scripts`})]})}),(0,$.jsx)(ln,{align:`end`,className:`min-w-[180px]`,children:d?u.map(([e,t])=>(0,$.jsxs)(gn,{children:[(0,$.jsx)(un,{children:e}),(0,$.jsx)(rn,{className:`max-h-[min(400px,80vh)] overflow-y-auto`,children:t.map(e=>(0,$.jsxs)(tn,{onClick:()=>{c(e)},className:`gap-2`,children:[a.has(e.name)?(0,$.jsx)(se,{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)(tn,{onClick:()=>{c(e)},className:`gap-2`,children:[a.has(e.name)?(0,$.jsx)(se,{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}=zt(),{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=H(u),e[5]=u,e[6]=d);let f;e[7]===n?f=e[8]:(f=()=>n({type:Y.ToggleSidebar}),e[7]=n,e[8]=f);let p;e[9]===o?p=e[10]:(p=o?(0,$.jsx)(Pe,{className:`h-4 w-4`}):(0,$.jsx)(ze,{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 g;e[12]!==f||e[13]!==p?(g=(0,$.jsxs)(h,{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]=g):g=e[14];let _;e[15]!==a||e[16]!==i||e[17]!==r?(_=r&&(0,$.jsxs)(`div`,{className:`flex flex-col`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:He(a,i)}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:R(a,r)})]}),e[15]=a,e[16]=i,e[17]=r,e[18]=_):_=e[18];let v;e[19]!==g||e[20]!==_?(v=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[g,_]}),e[19]=g,e[20]=_,e[21]=v):v=e[21];let y=l?`ml-0`:`ml-auto`,b;e[22]===y?b=e[23]:(b=H(`flex flex-wrap items-center justify-end gap-2`,y,`md:ml-auto`),e[22]=y,e[23]=b);let x;e[24]!==c?.runCommand||e[25]!==i||e[26]!==r?(x=i&&(0,$.jsxs)(ha,{className:`electrobun-webkit-app-region-no-drag`,children:[(0,$.jsx)(Rn,{projectId:i,runCommand:c?.runCommand}),r&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ga,{threadId:r}),(0,$.jsx)(ma,{})]})]}),e[24]=c?.runCommand,e[25]=i,e[26]=r,e[27]=x):x=e[27];let S;e[28]!==i||e[29]!==r?(S=r&&i&&(0,$.jsx)(ha,{className:`electrobun-webkit-app-region-no-drag`,children:(0,$.jsx)(da,{projectId:i,threadId:r})}),e[28]=i,e[29]=r,e[30]=S):S=e[30];let C;e[31]!==c?.openWith||e[32]!==i||e[33]!==r?(C=r&&i&&(0,$.jsx)(ha,{className:`electrobun-webkit-app-region-no-drag`,children:(0,$.jsx)(Gi,{projectId:i,threadId:r,openWith:c?.openWith})}),e[31]=c?.openWith,e[32]=i,e[33]=r,e[34]=C):C=e[34];let w;e[35]!==b||e[36]!==x||e[37]!==S||e[38]!==C?(w=(0,$.jsxs)(`div`,{className:b,children:[x,S,C]}),e[35]=b,e[36]=x,e[37]=S,e[38]=C,e[39]=w):w=e[39];let T;return e[40]!==w||e[41]!==d||e[42]!==v?(T=(0,$.jsxs)(Gn,{className:d,children:[v,w]}),e[40]=w,e[41]=d,e[42]=v,e[43]=T):T=e[43],T}function va(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)(wn,{children:`Delete Project`}),t[0]=o):o=t[0];let s;t[1]===r?s=t[2]:(s=(0,$.jsxs)(kn,{children:[o,(0,$.jsxs)(Cn,{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)(On,{children:`Cancel`}),t[3]=c):c=t[3];let l;t[4]===a?l=t[5]:(l=(0,$.jsxs)(Dn,{children:[c,(0,$.jsx)(En,{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)(Tn,{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)(An,{open:n,onOpenChange:i,children:u}),t[9]=i,t[10]=n,t[11]=u,t[12]=d):d=t[12],d}function ya(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)(wn,{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)(kn,{children:[o,(0,$.jsxs)(Cn,{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(ba),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)(On,{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)(En,{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)(Dn,{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)(Tn,{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)(An,{open:n,onOpenChange:a,children:h}),t[24]=n,t[25]=a,t[26]=h,t[27]=g):g=t[27],g}function ba(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 xa(){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=Sa;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)(kn,{children:[(0,$.jsx)(wn,{children:`Service unavailable`}),(0,$.jsx)(Cn,{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)(An,{open:!0,children:(0,$.jsxs)(Tn,{children:[c,l,(0,$.jsx)(Dn,{children:(0,$.jsx)(h,{onClick:a,children:`Retry`})})]})}),e[5]=u):u=e[5],u}function Sa(){window.location.assign(window.location.href)}var Ca=Nt,wa=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=H(`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)(kt,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});wa.displayName=kt.displayName;var Ta=B(`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`}}),Ea=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=H(Ta({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)(Et,{ref:t,className:o,...i}),n[7]=i,n[8]=t,n[9]=o,n[10]=s):s=n[10],s});Ea.displayName=Et.displayName;var Da=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=H(`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)(Ot,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});Da.displayName=Ot.displayName;var Oa=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=H(`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)(u,{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)(Pt,{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});Oa.displayName=Pt.displayName;var ka=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=H(`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)(Dt,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});ka.displayName=Dt.displayName;var Aa=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=H(`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)(wt,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});Aa.displayName=wt.displayName;function ja(){let e=(0,Q.c)(5),{toasts:t}=xn(),n;e[0]===t?n=e[1]:(n=t.map(Ma),e[0]=t,e[1]=n);let r;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(wa,{}),e[2]=r):r=e[2];let i;return e[3]===n?i=e[4]:(i=(0,$.jsxs)(Ca,{children:[n,r]}),e[3]=n,e[4]=i),i}function Ma(e){let{id:t,title:n,description:r,action:i,...a}=e;return(0,$.jsxs)(Ea,{...a,children:[(0,$.jsxs)(`div`,{className:`grid gap-1`,children:[n&&(0,$.jsx)(ka,{children:n}),r&&(0,$.jsx)(Aa,{children:r})]}),i,(0,$.jsx)(Oa,{})]},t)}function Na(){let e=(0,Q.c)(4),{resolvedTheme:t,theme:n}=zn(),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 Pa(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)(Na,{}),t[3]=i):i=t[3];let a;return t[4]!==n||t[5]!==r?(a=(0,$.jsxs)(Bn,{...r,children:[i,n]}),t[4]=n,t[5]=r,t[6]=a):a=t[6],a}function Fa(e){let{state:t,dispatch:n}=zt(),{toast:r}=xn(),i=Kt(`project-creation`).dispatch,[a,o]=(0,Z.useState)(null),l=(0,Z.useCallback)(async()=>{try{n({type:Y.SetProjectsLoading,projectsLoading:!0});let e=await s();n({type:Y.SetProjects,projects:e.projects})}catch(e){console.error(`Failed to refresh projects:`,e)}finally{n({type:Y.SetProjectsLoading,projectsLoading:!1})}},[n]),u=(0,Z.useCallback)(async(e,r)=>{try{await Be(e,r)}catch(e){console.error(`Failed to select thread:`,e)}(t.selectedThreadId!==r||t.selectedProjectId!==e)&&n({type:Y.SelectThread,threadId:r,projectId:e})},[n,t.selectedThreadId,t.selectedProjectId]),d=(0,Z.useCallback)(async t=>{n({type:Y.SetCreatingProject,isCreating:!0});try{let r=await t.apiCall();if(!r){n({type:Y.SetCreatingProject,isCreating:!1}),await l();return}let a=t.useTerminalDispatch?i:n;a({type:Y.ClearTerminalOutput}),a({type:Y.SetTerminalOpen,open:!0}),a({type:Y.AppendTerminalLine,line:{type:`system`,content:t.initialMessage}});let c=r.getReader(),u=new TextDecoder,d=``,f=null,p=!1,m=null,h=null;for(;;){let{done:e,value:r}=await c.read();if(e)break;d+=u.decode(r,{stream:!0});let i=d.split(`
|
|
27
|
+
`);d=i.pop()??``;for(let e of i){let r=e.trim();if(r)try{let e=JSON.parse(r);if(e.type===`progress`)!p&&e.threadId&&e.projectId&&(p=!0,m=e.projectId,h=e.threadId,n({type:Y.AddCreatingProject,projectId:e.projectId,threadId:e.threadId,projectName:t.optimisticProjectName,gitUrl:t.gitUrl??``}),n({type:Y.AddProcessingThread,threadId:e.threadId})),n({type:Y.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 r=t.includeThreadPath&&e.project.threads?.length>0?`${e.project.path}/${e.project.threads[0]}`:e.project.path;a({type:Y.AppendTerminalLine,line:{type:`system`,content:`Project created successfully at: ${r}`}}),n({type:Y.SetTerminalOpen,open:!1}),t.handleSetupScript&&e.suggestedSetupScript&&o({projectId:e.project.id,command:e.suggestedSetupScript,remainingScripts:e.project.pendingSetupScripts??[]})}}else e.type===`error`&&(p&&m&&(n({type:Y.RemoveCreatingProject,projectId:m}),h&&n({type:Y.RemoveProcessingThread,threadId:h})),n({type:Y.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)}}}n({type:Y.SetCreatingProject,isCreating:!1}),p&&h&&n({type:Y.RemoveProcessingThread,threadId:h}),G();let g=await s();if(n({type:Y.SetProjects,projects:g.projects}),n({type:Y.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;n({type:Y.SelectThread,threadId:e,projectId:f,focusInput:!0})}e?.onProjectCreated?.(f)}}catch(e){console.error(`Failed to ${t.logTag}:`,e),n({type:Y.SetCreatingProject,isCreating:!1}),(t.useTerminalDispatch?i:n)({type:Y.AppendTerminalLine,line:{type:`error`,content:`${t.catchErrorPrefix}: ${e instanceof Error?e.message:`Unknown error`}`}})}},[n,l,i,e?.onProjectCreated]),f=(0,Z.useCallback)(async(e,t)=>{let n=e.split(`/`).pop()?.replace(`.git`,``)??`project`;await d({apiCall:()=>F(e,t),initialMessage:`Cloning repository: ${e}...`,optimisticProjectName:n,gitUrl:e,useTerminalDispatch:!0,includeThreadPath:!0,handleSetupScript:!0,logTag:`create project`,catchErrorPrefix:`Failed to create project`})},[d]),p=(0,Z.useCallback)(async(e,t,n)=>{await d({apiCall:()=>ne(e,t,n),initialMessage:`Creating app "${e}"...`,optimisticProjectName:e,useTerminalDispatch:!0,handleSetupScript:!1,logTag:`create web app`,catchErrorPrefix:`Failed to create web app`})},[d]),m=(0,Z.useCallback)(async(e,i)=>{try{let a=i??(()=>{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 c(e,i);if(!o){await l();return}let s=o.getReader(),u=new TextDecoder,d=``,f=!1,p=null,m=!0,h=[{type:`system`,content:`Creating thread "${a}"...`}];try{for(;;){let{done:t,value:i}=await s.read();if(t)break;d+=u.decode(i,{stream:!0});let o=d.split(`
|
|
28
|
+
`);d=o.pop()??``;for(let t of o){let i=t.trim();if(i)try{let t=JSON.parse(i);if(t.type===`progress`){if(!f&&t.threadId){f=!0,p=t.threadId,n({type:Y.AddCreatingThread,projectId:e,threadId:t.threadId,title:a}),n({type:Y.AddProcessingThread,threadId:t.threadId}),n({type:Y.ClearTerminalOutput,threadId:p});for(let e of h)n({type:Y.AppendTerminalLine,threadId:p,line:e});h.length=0}let r={type:`output`,content:t.message};p?n({type:Y.AppendTerminalLine,threadId:p,line:r}):h.push(r)}else if(t.type===`error`){f&&p&&(n({type:Y.RemoveCreatingThread,projectId:e,threadId:p}),n({type:Y.RemoveProcessingThread,threadId:p}));let i={type:`error`,content:`Error: ${t.message}`};p?n({type:Y.AppendTerminalLine,threadId:p,line:i}):h.push(i),console.error(`Thread creation error:`,t.message),r({title:`Thread Creation Failed`,description:t.message,variant:`destructive`}),m=!1}}catch(e){console.error(`Failed to parse thread event`,e)}}}f&&p&&n({type:Y.RemoveProcessingThread,threadId:p}),G(),await l(),p&&m&&n({type:Y.SelectThread,threadId:p,projectId:e,focusInput:!0})}catch(t){throw f&&p&&(n({type:Y.RemoveCreatingThread,projectId:e,threadId:p}),n({type:Y.RemoveProcessingThread,threadId:p})),r({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 n({type:Y.AppendTerminalLine,line:{type:`error`,content:t}}),r({variant:`destructive`,title:`Thread Creation Failed`,description:t}),e}},[l,n,t.projects,r]),h=(0,Z.useCallback)(async(e,r)=>{n({type:Y.AddDeletingThread,threadId:r}),n({type:Y.ClearChatInputDraft,threadId:r});try{await k(e,r),G(),await l(),t.selectedThreadId===r&&n({type:Y.SelectThread,threadId:``,projectId:``})}catch(e){console.error(`Failed to delete thread:`,e)}finally{n({type:Y.RemoveDeletingThread,threadId:r})}},[l,t.selectedThreadId,n]),g=(0,Z.useCallback)(async e=>{n({type:Y.AddDeletingProject,projectId:e});let r=t.projects.find(t=>t.projectId===e)?.threads.map(e=>e.threadId)??[];for(let e of r)n({type:Y.AddDeletingThread,threadId:e}),n({type:Y.ClearChatInputDraft,threadId:e});try{await b(e),await l(),t.selectedProjectId===e&&n({type:Y.SelectThread,threadId:``,projectId:``})}catch(e){console.error(`Failed to delete project:`,e)}finally{n({type:Y.RemoveDeletingProject,projectId:e});for(let e of r)n({type:Y.RemoveDeletingThread,threadId:e})}},[l,t.selectedProjectId,t.projects,n]),_=(0,Z.useCallback)(async e=>{let t=a;if(o(null),!t||!e)return;let{projectId:r,command:i,remainingScripts:s}=t,c=[i,...s||[]];try{n({type:Y.SetCreatingProject,isCreating:!0}),n({type:Y.SetTerminalOpen,open:!0}),n({type:Y.AppendTerminalLine,line:{type:`system`,content:`Installing dependencies for ${c.length} package${c.length===1?``:`s`}...`}});for(let e=0;e<c.length;e++){let t=c[e],i=t.match(/^cd "([^"]+)" && (.+)$/),a=i?i[1]:`root`;n({type:Y.AppendTerminalLine,line:{type:`system`,content:`Installing package ${e+1}/${c.length} in ${a}...`}}),n({type:Y.AppendTerminalLine,line:{type:`output`,content:`📦 Installing dependencies in ${a}: ${t}`}});let o=await V(r,t,!0);if(o){let e=o.getReader(),t=new TextDecoder,r=``;for(;;){let{done:i,value:a}=await e.read();if(i)break;r+=t.decode(a,{stream:!0});let o=r.split(`
|
|
29
|
+
`);r=o.pop()??``;for(let e of o)if(e.trim())try{let t=JSON.parse(e);typeof t==`string`?n({type:Y.AppendTerminalLine,line:{type:`output`,content:t}}):t.type===`error`&&n({type:Y.AppendTerminalLine,line:{type:`error`,content:t.message}})}catch{n({type:Y.AppendTerminalLine,line:{type:`output`,content:e}})}}if(r.trim())try{let e=JSON.parse(r);typeof e==`string`?n({type:Y.AppendTerminalLine,line:{type:`output`,content:e}}):e.type===`error`&&n({type:Y.AppendTerminalLine,line:{type:`error`,content:e.message}})}catch{n({type:Y.AppendTerminalLine,line:{type:`output`,content:r}})}}e<c.length-1&&(n({type:Y.AppendTerminalLine,line:{type:`system`,content:``}}),n({type:Y.AppendTerminalLine,line:{type:`system`,content:`---`}}),n({type:Y.AppendTerminalLine,line:{type:`system`,content:``}}))}n({type:Y.AppendTerminalLine,line:{type:`system`,content:`All dependencies installed successfully!`}}),n({type:Y.SetCreatingProject,isCreating:!1}),await l()}catch(e){n({type:Y.SetCreatingProject,isCreating:!1}),console.error(`Failed to run setup script:`,e),n({type:Y.AppendTerminalLine,line:{type:`error`,content:`Failed to run setup script: ${e instanceof Error?e.message:`Unknown error`}`}})}},[a,n,l]);(0,Z.useEffect)(()=>{let e=!0;async function r(){try{n({type:Y.SetProjectsLoading,projectsLoading:!0});let r=await s();if(!e)return;if(n({type:Y.SetProjects,projects:r.projects}),!t.selectedThreadId)for(let e of r.projects){let t=e.threads.find(e=>e.isSelected);if(t){n({type:Y.SelectThread,threadId:t.threadId,projectId:e.projectId});break}}}catch(e){console.error(`Failed to load projects:`,e)}finally{e&&n({type:Y.SetProjectsLoading,projectsLoading:!1})}}return r(),()=>{e=!1}},[n,t.selectedThreadId,t.configUpdatedAt]);let v=(0,Z.useCallback)(async()=>{await d({apiCall:dt,initialMessage:`Opening folder...`,optimisticProjectName:`Opening folder...`,useTerminalDispatch:!0,handleSetupScript:!0,logTag:`open folder`,catchErrorPrefix:`Failed to open folder`})},[d]);return{projects:t.projects,selectedProjectId:t.selectedProjectId,selectedThreadId:t.selectedThreadId,refreshProjects:l,handleSelectThread:u,handleCreateProject:f,handleCreateWebApp:p,handleOpenFolder:v,handleCreateThread:m,handleDeleteThread:h,confirmDeleteProject:g,pendingSetupScriptConfirmation:a,resolveSetupScriptConfirmation:_}}function Ia(){let e=(0,Q.c)(2),[t,n]=(0,Z.useState)(La),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 La(){return document.hasFocus()}var Ra=null;function za(){Ra??=new Audio(`/pop.wav`),Ra.currentTime=0,Ra.play().catch(e=>{console.debug(`Could not play completion sound:`,e)})}function Ba(){let{state:e,dispatch:t}=zt(),n=Ia(),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 g(),n=a.current.filter(t=>!e.includes(t));for(let e of n)e!==o.current.selectedThreadId&&t({type:Y.MarkThreadCompleted,threadId:e});return n.length>0&&!s.current&&za(),a.current=e,t({type:Y.SetProcessingThreads,threadIds:e}),e}catch(e){return console.error(`Failed to fetch processing threads:`,e),[]}},[t]);(0,Z.useEffect)(()=>{let e=()=>{if(r.current||i.current)return;i.current=!0;let e=async()=>{let t=await c(),n=Object.values(o.current.threadStreamingStates).some(e=>e.isStreaming);t.length>0||n||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.processingThreadIds.length,Object.values(e.threadStreamingStates).some(e=>e.isStreaming),e.isCreatingProject,c]);let l=(0,Z.useCallback)(e=>{t({type:Y.ClearThreadCompleted,threadId:e})},[t]);return{processingThreadIds:e.processingThreadIds,completedThreadIds:e.completedThreadIds,isThreadProcessing:t=>e.processingThreadIds.includes(t),isThreadCompleted:t=>e.completedThreadIds.includes(t),clearCompleted:l}}var Va=768;function Ha(){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: ${Va-1}px)`),t=()=>{n(window.innerWidth<Va)};return e.addEventListener(`change`,t),n(window.innerWidth<Va),()=>e.removeEventListener(`change`,t)},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),Z.useEffect(r,i),!!t}var Ua=(0,Z.lazy)(()=>Rt(()=>import(`./terminal-panel-C9XWZHaD.js`).then(e=>({default:e.TerminalPanel})),__vite__mapDeps([20,1,0,11,12]))),Wa=(0,Z.lazy)(()=>Rt(()=>import(`./todos-view-CRzNrsfP.js`).then(e=>({default:e.TodosView})),[])),Ga=(0,Z.lazy)(()=>Rt(()=>import(`./diff-view-DUmzPmed.js`),__vite__mapDeps([2,1,3,4,5,6,0,7,8,9,10,11,12,13,14,15,16,17,18,19]))),Ka=(0,Z.lazy)(()=>Rt(()=>import(`./explorer-tab-view-Bbboiq-d.js`),__vite__mapDeps([21,1,3,4,0,17,9,6,11,12]))),qa=(0,Z.lazy)(()=>Rt(()=>import(`./browser-tab-Ban23pgA.js`).then(e=>({default:e.BrowserTab})),__vite__mapDeps([22,1,0,23,6,10,11,12]))),Ja=(0,Z.lazy)(()=>Rt(()=>import(`./dialogs-config-VlhyoYms.js`).then(e=>e.t),__vite__mapDeps([0,1]))),Ya=(0,Z.lazy)(()=>Rt(()=>import(`./onboarding-dialog-vqz8baom.js`),__vite__mapDeps([24,7,1,6,0]))),Xa=(0,Z.lazy)(()=>Rt(()=>import(`./settings-view-DuTfugUO.js`),__vite__mapDeps([25,1,3,4,0,26,27,28,17,9,6,18,11])));function Za(e){return e.startsWith(`/settings`)||e===`/review`||e===`/todos`}function Qa(){let e=(0,Q.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center bg-background`,children:(0,$.jsx)(`div`,{className:`h-8 w-8 animate-spin rounded-full border-2 border-muted border-t-primary`})}),e[0]=t):t=e[0],t}function $a(){let{state:e,dispatch:t}=zt();(0,Z.useEffect)(()=>{window.__electrobunWebviewId&&new ir({})},[]);let n=Tt(),i=At(),a=Ha(),[s,c]=(0,Z.useState)(null),{projects:l,handleSelectThread:u,handleCreateProject:d,handleCreateWebApp:f,handleOpenFolder:p,handleCreateThread:m,handleDeleteThread:h,confirmDeleteProject:g,refreshProjects:_,pendingSetupScriptConfirmation:v,resolveSetupScriptConfirmation:y}=Fa({onProjectCreated:c}),{processingThreadIds:b,completedThreadIds:x,clearCompleted:S}=Ba(),[C,w]=(0,Z.useState)(`chat`),[T,E]=(0,Z.useState)(null),[D,O]=(0,Z.useState)(!1),[k,A]=(0,Z.useState)(!1),[j,M]=(0,Z.useState)(!1),[N,P]=(0,Z.useState)(null),[F,I]=(0,Z.useState)(0),[L,ee]=(0,Z.useState)(null),[R,z]=(0,Z.useState)(0),{terminalState:B}=Kt(e.selectedThreadId),V=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{B.open&&e.selectedThreadId===V.current&&!Za(i.pathname)&&w(`terminal`),V.current=e.selectedThreadId},[B.open,e.selectedThreadId,i.pathname]);let[H,U]=(0,Z.useState)(!1),[te,W]=(0,Z.useState)(!1),[G,ne]=(0,Z.useState)(!1),[re,ie]=(0,Z.useState)(null),[ae,oe]=(0,Z.useState)(!1),[se,ce]=(0,Z.useState)(!1),le=(0,Z.useRef)(null),ue=i.pathname.startsWith(`/settings`),K=i.pathname===`/review`,q=i.pathname===`/todos`;(0,Z.useEffect)(()=>{i.pathname===`/`&&C===`tasks`&&w(`chat`)},[i.pathname]);let de=(0,Z.useRef)(C),fe=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{if(ue){if(fe.current===null){fe.current=Date.now(),de.current=C;return}de.current!==C&&n(`/`)}else fe.current=null;de.current=C},[C,ue,n]);let J=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{let n=ue||K||q;if(n&&J.current===null)J.current=e.sidebarOpen,e.sidebarOpen&&t({type:Y.ToggleSidebar});else if(!n&&J.current!==null){let n=J.current;J.current=null,n&&!e.sidebarOpen&&t({type:Y.ToggleSidebar})}},[ue,K,q]),(0,Z.useEffect)(()=>{(async()=>{try{(await r()).updateAvailable&&oe(!0)}catch{}})()},[]);let pe=(0,Z.useCallback)(async()=>{ce(!0);try{await Ue()}catch{ce(!1)}},[]);(0,Z.useEffect)(()=>{G||(async()=>{try{(await xt()).onboardingCompleted||W(!0)}catch(e){console.error(`Failed to check onboarding status:`,e)}finally{ne(!0)}})()},[G]),(0,Z.useEffect)(()=>{te||t({type:Y.ConfigUpdated})},[te,t]);let me=(0,Z.useCallback)(e=>{let t=l.find(t=>t.projectId===e);t&&ie({id:t.projectId,name:o(t)})},[l]),he=(0,Z.useCallback)(e=>{c(e),m(e,void 0)},[m]);(0,Z.useEffect)(()=>{s&&e.selectedProjectId===s&&e.selectedThreadId&&c(null)},[s,e.selectedProjectId,e.selectedThreadId]);let ge=(0,Z.useCallback)(async(r,o)=>{c(null),S(o),i.pathname!==`/`&&n(`/`),w(`chat`),e.selectedThreadId!==o&&z(e=>e+1),await u(r,o),a&&e.sidebarOpen&&t({type:Y.ToggleSidebar})},[u,a,e.sidebarOpen,e.selectedThreadId,t,S,i.pathname,n]);(0,Z.useEffect)(()=>{e.sidebarOpen?le.current?.expand():le.current?.collapse()},[e.sidebarOpen]);let _e={activeMainTab:C,setActiveMainTab:w,devServerUrl:T,setDevServerUrl:E,devServerRunning:D,setDevServerRunning:O,devServerLoading:k,setDevServerLoading:A,terminalNotification:j,setTerminalNotification:M,pendingExplorerPath:N,setPendingExplorerPath:P,explorerRefreshTick:F,triggerExplorerRefresh:()=>I(e=>e+1),explorerClearPath:L,setExplorerClearPath:ee,browserResetTrigger:R,triggerBrowserReset:()=>z(e=>e+1)};return(0,$.jsx)(Pn.Provider,{value:_e,children:(0,$.jsxs)(Zt,{delayDuration:200,children:[(0,$.jsxs)(qn,{direction:`horizontal`,className:`h-screen bg-background`,children:[(0,$.jsx)(Kn,{ref:le,defaultSize:a?100:25,minSize:a?50:12,maxSize:a?100:32,collapsible:!0,collapsedSize:0,className:`border-r border-transparent`,children:(0,$.jsx)(`div`,{className:`h-full overflow-hidden`,children:(0,$.jsx)(sr,{projects:l,selectedThreadId:e.selectedThreadId,selectedProjectId:e.selectedProjectId,processingThreadIds:b,completedThreadIds:x,deletingThreadIds:e.deletingThreadIds,deletingProjectIds:e.deletingProjectIds,onSelectThread:ge,onCreateProject:()=>U(!0),onCreateThread:he,onDeleteThread:h,onDeleteProject:me,onDeselect:()=>t({type:Y.ClearSelection}),collapsed:!e.sidebarOpen,updateAvailable:ae,updatingApp:se,onUpdateApp:pe,expandProjectId:s})})}),!a&&(0,$.jsx)(Jn,{withHandle:!0,className:e.sidebarOpen?`ml-[-40px]`:``}),(0,$.jsx)(Kn,{minSize:40,className:`overflow-hidden ${a&&e.sidebarOpen?`hidden`:``}`,children:(0,$.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden`,children:[!K&&!ue&&!q&&(0,$.jsx)(_a,{}),!K&&!ue&&!q&&e.selectedThreadId&&(0,$.jsx)(`div`,{className:`flex border-b border-border shrink-0`,children:[`Chat`,`Explorer`,`Review`,`Browser`,`Terminal`,`Tasks`].map(e=>{let t=e.toLowerCase();return(0,$.jsxs)(`button`,{onClick:()=>{w(t),t===`terminal`&&M(!1)},className:`relative px-4 py-2 text-sm font-medium transition-colors ${C===t?`border-b-2 border-primary text-foreground -mb-px`:`text-muted-foreground hover:text-foreground`}`,children:[e,t===`terminal`&&j&&C!==`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${!K&&!ue&&!q&&C!==`chat`?` hidden`:``}`,children:(0,$.jsxs)(It,{children:[(0,$.jsx)(Mt,{path:`/settings/project/:projectId`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(Qa,{}),children:(0,$.jsx)(Xa,{})})}),(0,$.jsx)(Mt,{path:`/settings/:tab?`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(Qa,{}),children:(0,$.jsx)(Xa,{})})}),(0,$.jsx)(Mt,{path:`*`,element:(0,$.jsx)(Bi,{onCreateThread:he})})]})}),(0,$.jsx)(`div`,{className:`flex-1 overflow-hidden${C===`terminal`&&!K&&!ue&&!q?``:` hidden`}`,children:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Ua,{})})}),(0,$.jsx)(`div`,{className:`flex-1 overflow-hidden${C===`browser`&&!K&&!ue&&!q?``:` hidden`}`,children:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(qa,{})})}),!K&&!ue&&!q&&C!==`chat`&&C!==`terminal`&&C!==`browser`&&(C===`explorer`?(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Ka,{})}):C===`tasks`&&e.selectedProjectId?(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Wa,{projectId:e.selectedProjectId})}):C===`review`&&e.selectedThreadId?(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Ga,{threadId:e.selectedThreadId,onExit:()=>w(`chat`)})}):(0,$.jsx)(`div`,{className:`flex-1 overflow-hidden`}))]})}),(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Ja,{open:H,onOpenChange:U,onSubmitClone:d,onSubmitWebApp:f,onOpenFolder:p})}),(0,$.jsx)(va,{open:re!==null,projectName:re?.name,onOpenChange:e=>!e&&ie(null),onConfirm:()=>{re&&(g(re.id),ie(null))}}),(0,$.jsx)(ya,{open:v!==null,setupScripts:v?[v.command,...v.remainingScripts||[]]:[],onConfirm:y}),(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Ya,{open:te,onOpenChange:W,onComplete:()=>{ne(!0),_()}})}),(0,$.jsx)(xa,{})]}),(0,$.jsx)(ja,{})]})})}function eo(){let e=(0,Q.c)(5),[t,n]=(0,Z.useReducer)(Jt,Ut),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)($a,{}),e[2]=i):i=e[2];let a;return e[3]===r?a=e[4]:(a=(0,$.jsx)(Pa,{attribute:`class`,defaultTheme:`system`,enableSystem:!0,storageKey:`tarsk-theme`,children:(0,$.jsx)(Gt.Provider,{value:r,children:i})}),e[3]=r,e[4]=a),a}Yn();var to=!1;window.addEventListener(`resize`,()=>{to||=(window.__electrobunWebviewId&&(document.body.style.height=`calc(100%)`),!0)}),(0,Xn.createRoot)(document.getElementById(`root`)).render((0,$.jsx)(Z.StrictMode,{children:(0,$.jsx)(Lt,{children:(0,$.jsx)(eo,{})})}));export{Li as t};
|