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