tarsk 0.5.35 → 0.5.37
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 +28 -15
- package/dist/public/assets/{account-view-k5jIArY-.js → account-view-Cn4P1srV.js} +1 -1
- package/dist/public/assets/api-DWU0D34A.js +1 -0
- package/dist/public/assets/{browser-tab-C9kJT-C5.js → browser-tab-DeoHDVON.js} +1 -1
- package/dist/public/assets/commit-dialog-CWb_KVrD.js +1 -0
- package/dist/public/assets/context-menu-C7FTMa2c.js +1 -0
- package/dist/public/assets/create-repo-dialog-BCPrWkIv.js +1 -0
- package/dist/public/assets/{dialogs-config-B4TDFSrS.js → dialogs-config-DZKtVbNK.js} +14 -14
- package/dist/public/assets/diff-view-DL3hFREY.js +3 -0
- package/dist/public/assets/explorer-tab-view-DAs4rpHu.js +2 -0
- package/dist/public/assets/{explorer-tree-uXbr6cCI.js → explorer-tree-BV1LcznV.js} +1 -1
- package/dist/public/assets/explorer-view-BGSxs_-F.js +1 -0
- package/dist/public/assets/git-history-dialog-Bqv0bD41.js +1 -0
- package/dist/public/assets/git-ops-button-DZzOCOr8.js +2 -0
- package/dist/public/assets/history-view-jX3PPID6.js +9 -0
- package/dist/public/assets/index-CbJ3v0Sr.js +65 -0
- package/dist/public/assets/index-jIBJk8xl.css +1 -0
- package/dist/public/assets/mcp-server-card-CTCrhFIS.js +1 -0
- package/dist/public/assets/merged-pr-dialog-B2qqrQ1g.js +1 -0
- package/dist/public/assets/onboarding-CxtzQldG.js +1 -0
- package/dist/public/assets/project-settings-view-B7RBOfiB.js +1 -0
- package/dist/public/assets/providers-list-view-BQFttbEU.js +1 -0
- package/dist/public/assets/pull-request-dialog-BIRSLJAA.js +1 -0
- package/dist/public/assets/pull-with-changes-dialog-LUgd2a4S.js +1 -0
- package/dist/public/assets/push-before-pr-dialog-CFmgu9H_.js +1 -0
- package/dist/public/assets/radio-group-Bd8YbtFD.js +1 -0
- package/dist/public/assets/{react-vendor-unlDVFpU.js → react-vendor-Ba8DSNiO.js} +5 -5
- package/dist/public/assets/settings-general-view-CH-51vI0.js +1 -0
- package/dist/public/assets/settings-instructions-view-D9HZldUk.js +1 -0
- package/dist/public/assets/settings-list-CKPEGohm.js +1 -0
- package/dist/public/assets/settings-mcp-servers-view-o2gqb0qo.js +5 -0
- package/dist/public/assets/{settings-models-skeleton-B_56ozbA.js → settings-models-skeleton-l966LEN8.js} +1 -1
- package/dist/public/assets/{settings-models-view-ms828HDa.js → settings-models-view-m-MDG6JH.js} +1 -1
- package/dist/public/assets/settings-rules-view-tG9JJQzK.js +8 -0
- package/dist/public/assets/settings-skills-view-DLyWp1pq.js +2 -0
- package/dist/public/assets/settings-slash-commands-view-B7OCA_J1.js +1 -0
- package/dist/public/assets/settings-subagents-view-CSkVwd-J.js +2 -0
- package/dist/public/assets/settings-system-prompt-view-Br6r4RXb.js +1 -0
- package/dist/public/assets/settings-view-rUCFRiPR.js +2 -0
- package/dist/public/assets/skeleton-qzmFgKhS.js +1 -0
- package/dist/public/assets/{terminal-panel-Bm5ECpK_.js → terminal-panel-D3Ru16FT.js} +2 -2
- package/dist/public/assets/{ui-components-BZYnvMGc.js → ui-components-f8jJJzEo.js} +1 -1
- package/dist/public/assets/{utils-umVhs9to.js → utils-BlXPFbY9.js} +1 -1
- package/dist/public/assets/{whisper-wasm-Cq5Ofwpd.js → whisper-wasm-EGutPGND.js} +2 -2
- package/dist/public/index.html +12 -9
- package/package.json +1 -1
- package/dist/public/assets/api-OCjPhv01.js +0 -1
- package/dist/public/assets/commit-dialog-8Ce6d3H8.js +0 -1
- package/dist/public/assets/context-menu-CMsWrzLD.js +0 -1
- package/dist/public/assets/create-repo-dialog-CVUtteNS.js +0 -1
- package/dist/public/assets/diff-view-DGfmGlB_.js +0 -3
- package/dist/public/assets/explorer-tab-view-CCXVTkVu.js +0 -2
- package/dist/public/assets/explorer-view-CupxzDId.js +0 -1
- package/dist/public/assets/git-history-dialog-BCGOZ6ua.js +0 -1
- package/dist/public/assets/git-ops-button-BV9X3fo-.js +0 -2
- package/dist/public/assets/history-view-Ds_0e_bx.js +0 -7
- package/dist/public/assets/index-C0lTt0ZK.css +0 -1
- package/dist/public/assets/index-DOsSr4dl.js +0 -65
- package/dist/public/assets/mcp-server-card-DrUUKNXv.js +0 -1
- package/dist/public/assets/merged-pr-dialog-DqWSFdCH.js +0 -1
- package/dist/public/assets/onboarding-DfL8a0LZ.js +0 -1
- package/dist/public/assets/project-settings-view-Cd_l3Lfy.js +0 -1
- package/dist/public/assets/providers-list-view-VXhgM3vp.js +0 -1
- package/dist/public/assets/pull-request-dialog-DZXTHHuh.js +0 -1
- package/dist/public/assets/pull-with-changes-dialog-CYQrwzcw.js +0 -1
- package/dist/public/assets/push-before-pr-dialog-D-ZnRpJi.js +0 -1
- package/dist/public/assets/radio-group-c0sU992r.js +0 -1
- package/dist/public/assets/settings-general-view-DI-lvP0L.js +0 -1
- package/dist/public/assets/settings-instructions-view-kUG32_dT.js +0 -1
- package/dist/public/assets/settings-list-CUbZrggr.js +0 -1
- package/dist/public/assets/settings-mcp-servers-view-DmxUO42I.js +0 -5
- package/dist/public/assets/settings-rules-view-Xx0ymfnQ.js +0 -8
- package/dist/public/assets/settings-skills-view-DvPPdsi_.js +0 -2
- package/dist/public/assets/settings-slash-commands-view-BULIAW2o.js +0 -1
- package/dist/public/assets/settings-subagents-view-B7FcLaZT.js +0 -2
- package/dist/public/assets/settings-system-prompt-view-66zf0gRc.js +0 -1
- package/dist/public/assets/settings-view-B4CMq7it.js +0 -2
- package/dist/public/assets/skeleton-BvSNJL9q.js +0 -1
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dist-oojFghRi.js","assets/rolldown-runtime-aKtaBQYM.js","assets/git-ops-button-DZzOCOr8.js","assets/monaco-CZnIWXyV.js","assets/monaco-Br_kD0ds.css","assets/dialogs-config-DZKtVbNK.js","assets/diff-view-DL3hFREY.js","assets/history-view-jX3PPID6.js","assets/onboarding-CxtzQldG.js","assets/context-menu-C7FTMa2c.js","assets/react-vendor-Ba8DSNiO.js","assets/utils-BlXPFbY9.js","assets/terminal-panel-D3Ru16FT.js","assets/explorer-tab-view-DAs4rpHu.js","assets/browser-tab-DeoHDVON.js","assets/settings-view-rUCFRiPR.js","assets/settings-models-skeleton-l966LEN8.js","assets/skeleton-qzmFgKhS.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{$ as t,$i as n,$n as r,A as i,Aa as a,Ar as o,Ba as s,Bn as c,Bt as l,Ca as u,D as d,Da as f,Di as p,Dn as m,Dr as h,Ea as g,Ei as _,En as v,Er as y,Fi as b,Fn as x,Ft as S,Ga as C,Gi as w,Gn as T,Ha as E,Hi as D,Hn as O,I as k,Ii as A,Ja as j,Jn as M,Kn as N,Kt as P,La as F,Ln as I,Lt as L,Ma as R,Mn as ee,Mr as z,Mt as te,N as ne,Na as re,Nn as B,Nt as ie,Oa as V,Oi as ae,Or as H,Ot as oe,Pa as se,Pi as ce,Pn as le,Pt as ue,Q as de,Qa as fe,Qi as pe,Qn as me,Qt as he,R as ge,Rn as _e,S as ve,Sa as ye,Si as be,St as xe,T as Se,Ta as Ce,Ti as we,Tt as Te,Ui as Ee,Un as De,Va as Oe,Vi as ke,Vn as Ae,Wa as je,Wi as Me,Wn as Ne,Xt as Pe,Ya as Fe,Yi as Ie,Yt as Le,Z as Re,Zn as ze,Zt as Be,_n as Ve,an as He,b as Ue,ba as We,bi as Ge,bn as Ke,bo as qe,bt as Je,c as Ye,ca as Xe,ci as U,d as Ze,da as Qe,di as $e,dn as et,do as tt,ea as nt,eo as rt,et as it,fi as at,fn as ot,fr as W,g as st,ga as ct,gn as lt,gt as ut,ha as dt,hn as ft,ho as pt,hr as G,ia as mt,in as ht,io as gt,j as _t,ji as vt,jn as yt,jr as bt,kn as xt,kr as St,kt as Ct,lo as wt,lr as Tt,lt as Et,m as Dt,ma as Ot,mi as kt,mn as At,mo as jt,mr as Mt,na as Nt,no as Pt,nr as Ft,nt as It,oo as Lt,or as Rt,ot as zt,p as Bt,pa as Vt,pi as Ht,pn as Ut,pr as K,q as Wt,qi as Gt,qn as Kt,qt,ra as Jt,rn as Yt,ro as Xt,rr as Zt,sa as Qt,so as $t,sr as en,tn,to as nn,tr as rn,tt as an,ua as on,ui as q,un as sn,uo as cn,ur as ln,ut as un,v as dn,va as fn,vn as pn,vo as mn,w as hn,wa as gn,wi as J,wn as _n,wr as vn,wt as yn,x as bn,xi as xn,xo as Sn,yn as Cn,yo as wn,za as Tn}from"./dialogs-config-DZKtVbNK.js";import{$ as En,A as Dn,B as On,D as kn,E as An,F as jn,G as Mn,H as Nn,I as Pn,J as Fn,K as In,L as Ln,M as Rn,N as zn,O as Bn,P as Vn,Q as Hn,R as Un,T as Wn,U as Gn,V as Kn,W as qn,X as Jn,Y as Yn,Z as Xn,at as Zn,ct as Qn,et as $n,it as er,j as tr,k as nr,nt as rr,ot as ir,q as ar,rt as or,st as sr,tt as cr,ut as lr,w as ur,z as dr}from"./react-vendor-Ba8DSNiO.js";import{r as fr}from"./monaco-CZnIWXyV.js";import{c as pr,o as mr,r as hr,s as gr}from"./onboarding-CxtzQldG.js";import{A as _r,F as vr,I as yr,M as br,N as xr,O as Sr,P as Cr,a as wr,j as Tr,k as Er,l as Dr,n as Or,o as kr,s as Ar,x as jr}from"./history-view-jX3PPID6.js";import{a as Mr,i as Nr,n as Pr,o as Fr,r as Ir,t as Lr}from"./whisper-wasm-EGutPGND.js";import{n as Rr,t as zr}from"./utils-BlXPFbY9.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 Y=e(Sn(),1),Br=lr(),X=wn(),Vr=1e10,Hr=1e3;function Ur(e,t){let n=e.map(e=>`"${e}"`).join(`, `);return Error(`This RPC instance cannot ${t} because the transport did not provide one or more of these methods: ${n}`)}function Wr(e={}){let t={},n={},r;function i(e){n.unregisterHandler&&n.unregisterHandler(),n=e,n.registerHandler?.(x)}function a(e){if(typeof e==`function`){r=e;return}r=(t,n)=>{let r=e[t];if(r)return r(n);let i=e._;if(!i)throw Error(`The requested method has no handler: ${String(t)}`);return i(t,n)}}let{maxRequestTime:o=Hr}=e;e.transport&&i(e.transport),e.requestHandler&&a(e.requestHandler),e._debugHooks&&(t=e._debugHooks);let s=0;function c(){return s<=Vr?++s:s=0}let l=new Map,u=new Map;function d(e,...r){let i=r[0];return new Promise((r,a)=>{if(!n.send)throw Ur([`send`],`make requests`);let s=c(),d={type:`request`,id:s,method:e,params:i};l.set(s,{resolve:r,reject:a}),o!==1/0&&u.set(s,setTimeout(()=>{u.delete(s),l.delete(s),a(Error(`RPC request timed out.`))},o)),t.onSend?.(d),n.send(d)})}let f=new Proxy(d,{get:(e,t,n)=>t in e?Reflect.get(e,t,n):e=>d(t,e)}),p=f;function m(e,...r){let i=r[0];if(!n.send)throw Ur([`send`],`send messages`);let a={type:`message`,id:e,payload:i};t.onSend?.(a),n.send(a)}let h=new Proxy(m,{get:(e,t,n)=>t in e?Reflect.get(e,t,n):e=>m(t,e)}),g=h,_=new Map,v=new Set;function y(e,t){if(!n.registerHandler)throw Ur([`registerHandler`],`register message listeners`);if(e===`*`){v.add(t);return}_.has(e)||_.set(e,new Set),_.get(e).add(t)}function b(e,t){if(e===`*`){v.delete(t);return}_.get(e)?.delete(t),_.get(e)?.size===0&&_.delete(e)}async function x(e){if(t.onReceive?.(e),!(`type`in e))throw Error(`Message does not contain a type.`);if(e.type===`request`){if(!n.send||!r)throw Ur([`send`,`requestHandler`],`handle requests`);let{id:i,method:a,params:o}=e,s;try{s={type:`response`,id:i,success:!0,payload:await r(a,o)}}catch(e){if(!(e instanceof Error))throw e;s={type:`response`,id:i,success:!1,error:e.message}}t.onSend?.(s),n.send(s);return}if(e.type===`response`){let t=u.get(e.id);t!=null&&clearTimeout(t),u.delete(e.id);let{resolve:n,reject:r}=l.get(e.id)??{};l.delete(e.id),e.success?n?.(e.payload):r?.(Error(e.error));return}if(e.type===`message`){for(let t of v)t(e.id,e.payload);let t=_.get(e.id);if(!t)return;for(let n of t)n(e.payload);return}throw Error(`Unexpected RPC message type: ${e.type}`)}return{setTransport:i,setRequestHandler:a,request:f,requestProxy:p,send:h,sendProxy:g,addMessageListener:y,removeMessageListener:b,proxy:{send:g,request:p}}}function Gr(e,t){let n=Wr({maxRequestTime:t.maxRequestTime,requestHandler:{...t.handlers.requests,...t.extraRequestHandlers},transport:{registerHandler:()=>{}}}),r=t.handlers.messages;return r&&n.addMessageListener(`*`,((e,t)=>{let n=r[`*`];n&&n(e,t);let i=r[e];i&&i(t)})),n}var Kr=window.__electrobunWebviewId,qr=window.__electrobunRpcSocketPort,Jr=class{bunSocket;rpc;rpcHandler;constructor(e){this.rpc=e.rpc,this.init()}init(){this.initSocketToBun(),window.__electrobun.receiveMessageFromBun=this.receiveMessageFromBun.bind(this),this.rpc&&this.rpc.setTransport(this.createTransport())}initSocketToBun(){let e=new WebSocket(`ws://localhost:${qr}/socket?webviewId=${Kr}`);this.bunSocket=e,e.addEventListener(`open`,()=>{}),e.addEventListener(`message`,async e=>{let t=e.data;if(typeof t==`string`)try{let e=JSON.parse(t),n=await window.__electrobun_decrypt(e.encryptedData,e.iv,e.tag);this.rpcHandler?.(JSON.parse(n))}catch(e){console.error(`Error parsing bun message:`,e)}else t instanceof Blob||console.error(`UNKNOWN DATA TYPE RECEIVED:`,e.data)}),e.addEventListener(`error`,e=>{console.error(`Socket error:`,e)}),e.addEventListener(`close`,e=>{})}createTransport(){let e=this;return{send(t){try{let n=JSON.stringify(t);e.bunBridge(n)}catch(e){console.error(`bun: failed to serialize message to webview`,e)}},registerHandler(t){e.rpcHandler=t}}}async bunBridge(e){if(this.bunSocket?.readyState===WebSocket.OPEN)try{let{encryptedData:t,iv:n,tag:r}=await window.__electrobun_encrypt(e),i=JSON.stringify({encryptedData:t,iv:n,tag:r});this.bunSocket.send(i);return}catch(e){console.error(`Error sending message to bun via socket:`,e)}window.__electrobunBunBridge?.postMessage(e)}receiveMessageFromBun(e){this.rpcHandler&&this.rpcHandler(e)}static defineRPC(e){return Gr(`webview`,{...e,extraRequestHandlers:{evaluateJavascriptWithResponse:({script:e})=>new Promise(t=>{try{let n=Function(e)();n instanceof Promise?n.then(e=>{t(e)}).catch(e=>{console.error(`bun: async script execution failed`,e),t(String(e))}):t(n)}catch(e){console.error(`bun: failed to eval script`,e),t(String(e))}})}})}};function Yr(e){return typeof e==`string`?e.replace(/\\n/g,`
|
|
3
|
+
`).replace(/✅/g,`✓`):``}function Xr(e){if(!e||typeof e!=`string`)return null;let t=e.trim();if(!t)return null;let n=/\[([A-Za-z]+)\]\s*/g,r,i=0;for(let e of t.matchAll(n))r=e[1],i=e.index+e[0].length;let a=r,o=a?t.slice(i):t;if(a&&o)return[{type:`reasoning`,text:o,label:a}];let s=[],c=0;for(;c<t.length;){let e=t.indexOf(`[`,c);if(e===-1){let e=t.slice(c).trim();e&&s.push({type:`reasoning`,text:e});break}let n=t.slice(c,e).trim();n&&s.push({type:`reasoning`,text:n});let r=0,i=-1;for(let n=e;n<t.length;n++)if(t[n]===`[`)r++;else if(t[n]===`]`&&(r--,r===0)){i=n;break}if(i===-1){let n=t.slice(e).trim();n&&s.push({type:`reasoning`,text:n});break}try{let n=JSON.parse(t.slice(e,i+1));if(Array.isArray(n)){for(let e of n)if(e&&typeof e==`object`&&`type`in e){let t=e.type;(t===`tool-result`||t===`tool_use`)&&s.push(e)}}}catch{let n=t.slice(e,i+1).trim();n&&s.push({type:`reasoning`,text:n})}c=i+1}return s.length>0?s:null}function Zr(e){return e.map(e=>{if(typeof e==`object`&&e&&!(`type`in e)){let t=e;if(t.reasoning)return{type:`reasoning`,text:typeof t.reasoning==`string`?t.reasoning:JSON.stringify(t.reasoning)};let n=t.text??t.content??t.answer;if(n)return{type:`text`,text:typeof n==`string`?n:JSON.stringify(n)}}return e})}function Qr(e){let t=[];if(e.type===`long_running_confirmation`&&typeof e.prompt==`object`&&e.prompt!==null&&typeof e.prompt.question==`string`&&Array.isArray(e.prompt.options)){let n=e.prompt;return t.push({type:`long_running_confirmation`,prompt:{toolCallId:typeof n.toolCallId==`string`?n.toolCallId:void 0,question:n.question,options:n.options.filter(e=>typeof e==`string`),context:typeof n.context==`string`?n.context:void 0}}),t}if(e.type===`shell_permission`&&typeof e.shellPermission==`object`&&e.shellPermission!==null&&typeof e.shellPermission.command==`string`){let n=e.shellPermission;return t.push({type:`shell_permission`,prompt:{toolCallId:typeof n.toolCallId==`string`?n.toolCallId:`shell-permission`,command:n.command,source:n.source===`bash`||n.source===`skill_script`||n.source===`browser_js`?n.source:`bash`,wildcardOptions:Array.isArray(n.wildcardOptions)?n.wildcardOptions.filter(e=>typeof e==`object`&&!!e&&typeof e.label==`string`&&typeof e.pattern==`string`&&(e.scope===`session`||e.scope===`project`)):[]}}),t}if(e.type===`web_fetch_permission`&&typeof e.webFetchPermission==`object`&&e.webFetchPermission!==null&&typeof e.webFetchPermission.hostname==`string`){let n=e.webFetchPermission;return t.push({type:`web_fetch_permission`,prompt:{toolCallId:typeof n.toolCallId==`string`?n.toolCallId:`web-fetch-permission`,hostname:n.hostname,url:typeof n.url==`string`?n.url:``,wildcardOptions:Array.isArray(n.wildcardOptions)?n.wildcardOptions.filter(e=>typeof e==`object`&&!!e&&typeof e.label==`string`&&typeof e.pattern==`string`&&(e.scope===`session`||e.scope===`project`)):[]}}),t}e.reasoning&&typeof e.reasoning==`string`&&t.push({type:`reasoning`,text:e.reasoning});let n=(typeof e.text==`string`?e.text:null)??(typeof e.content==`string`?e.content:null)??(typeof e.answer==`string`?e.answer:null);return n&&t.push({type:`text`,text:n}),t.length===0&&Object.keys(e).length>0&&t.push({type:`text`,text:JSON.stringify(e,null,2)}),t}function $r(e){if(!e)return null;let t=e.trim();if(t.startsWith(`{`)||t.startsWith(`[`))try{let e=JSON.parse(t);if(Array.isArray(e))return Zr(e);if(typeof e==`object`&&e)return Qr(e)}catch{}let n=[],r=e.indexOf(`{`),i=e.indexOf(`[`),a=r===-1?i:i===-1?r:Math.min(r,i);if(a!==-1){let t=e.slice(a),r=Math.max(t.lastIndexOf(`]`),t.lastIndexOf(`}`));if(r!==-1){let e=t.substring(0,r+1);try{let i=JSON.parse(e);Array.isArray(i)?n.push(...Zr(i)):n.push(...Qr(i));let a=t.substring(r+1).trim();return a&&n.push({type:`text`,text:a}),n}catch{}}}return null}function ei(e,t,n){let r=e[e.length-1];return r?.type===t?[...e.slice(0,-1),{type:t,chunks:[...r.chunks,n]}]:[...e,{type:t,chunks:[n]}]}function ti(e,t){return e[e.length-1]?.type===`content`?[...e.slice(0,-1),{type:`content`,chunks:[t]}]:[...e,{type:`content`,chunks:[t]}]}function ni(e,t){return[...e,{type:`long_running_confirmation`,prompt:t}]}function ri(e,t){return[...e,{type:`shell_permission`,prompt:t}]}function ii(e,t){return[...e,{type:`web_fetch_permission`,prompt:t}]}function ai(e){let t=[];for(let n of e){if(n.type===`long_running_confirmation`){t.push({type:`long_running_confirmation`,prompt:n.prompt});continue}if(n.type===`shell_permission`){t.push({type:`shell_permission`,prompt:n.prompt});continue}if(n.type===`web_fetch_permission`){t.push({type:`web_fetch_permission`,prompt:n.prompt});continue}let e=n.chunks.join(``);if(n.type===`thinking`){let n=Xr(e)??[];t.push(...n)}else{let n=$r(e)??(e.trim()?[{type:`text`,text:e}]:[]);t.push(...n)}}return t}function oi(e,t=!1){let n=[],r=[],i,a=()=>{r.length>0&&(n.push({type:`thinking-group`,text:r.join(`
|
|
4
|
+
|
|
5
|
+
`),label:i,isCurrentlyStreaming:!1}),r=[],i=void 0)};for(let t of e)if(t.type===`reasoning`&&`text`in t){let e=t;r.push(e.text),e.label&&(i=e.label)}else a(),n.push(t);if(a(),t&&n.length>0){let e=n[n.length-1];if(e.type===`thinking-group`){let t=e;t.label!==`Validated`&&(t.isCurrentlyStreaming=!0)}}return n}function si(e){let t=ai(e);return t.length===0?`...`:t.length===1&&t[0]?.type===`text`&&`text`in t[0]?t[0].text:JSON.stringify(t)}var Z=function(e){return e.SetProjects=`SET_PROJECTS`,e.SetProjectsLoading=`SET_PROJECTS_LOADING`,e.SelectThread=`SELECT_THREAD`,e.SetMessages=`SET_MESSAGES`,e.AddMessage=`ADD_MESSAGE`,e.EnqueueChatMessage=`ENQUEUE_CHAT_MESSAGE`,e.RemoveQueuedChatMessage=`REMOVE_QUEUED_CHAT_MESSAGE`,e.SetStreaming=`SET_STREAMING`,e.AppendStreamContent=`APPEND_STREAM_CONTENT`,e.SetStreamContent=`SET_STREAM_CONTENT`,e.AppendStreamThinking=`APPEND_STREAM_THINKING`,e.AppendStreamChunk=`APPEND_STREAM_CHUNK`,e.SetStreamModel=`SET_STREAM_MODEL`,e.SetProjectModel=`SET_PROJECT_MODEL`,e.ResetStream=`RESET_STREAM`,e.StopStream=`STOP_STREAM`,e.ToggleSidebar=`TOGGLE_SIDEBAR`,e.CloseSidebar=`CLOSE_SIDEBAR`,e.SetCreatingProject=`SET_CREATING_PROJECT`,e.ConfigUpdated=`CONFIG_UPDATED`,e.SetProcessingThreads=`SET_PROCESSING_THREADS`,e.AddProcessingThread=`ADD_PROCESSING_THREAD`,e.RemoveProcessingThread=`REMOVE_PROCESSING_THREAD`,e.AddCreatingProject=`ADD_CREATING_PROJECT`,e.AddCreatingThread=`ADD_CREATING_THREAD`,e.RemoveCreatingProject=`REMOVE_CREATING_PROJECT`,e.RemoveCreatingThread=`REMOVE_CREATING_THREAD`,e.MarkThreadCompleted=`MARK_THREAD_COMPLETED`,e.ClearThreadCompleted=`CLEAR_THREAD_COMPLETED`,e.AddDeletingThread=`ADD_DELETING_THREAD`,e.RemoveDeletingThread=`REMOVE_DELETING_THREAD`,e.AddDeletingProject=`ADD_DELETING_PROJECT`,e.RemoveDeletingProject=`REMOVE_DELETING_PROJECT`,e.AppendCommandOutput=`APPEND_COMMAND_OUTPUT`,e.SetRunningCommand=`SET_RUNNING_COMMAND`,e.ClearCommandOutput=`CLEAR_COMMAND_OUTPUT`,e.ToggleTerminal=`TOGGLE_TERMINAL`,e.SetTerminalOpen=`SET_TERMINAL_OPEN`,e.QueueTerminalCommand=`QUEUE_TERMINAL_COMMAND`,e.ClearQueuedTerminalCommand=`CLEAR_QUEUED_TERMINAL_COMMAND`,e.AppendTerminalLine=`APPEND_TERMINAL_LINE`,e.ClearTerminalOutput=`CLEAR_TERMINAL_OUTPUT`,e.SetTerminalHeight=`SET_TERMINAL_HEIGHT`,e.SetTerminalCwd=`SET_TERMINAL_CWD`,e.SetTerminalRunning=`SET_TERMINAL_RUNNING`,e.SetTerminalHistory=`SET_TERMINAL_HISTORY`,e.SetTerminalHistoryIndex=`SET_TERMINAL_HISTORY_INDEX`,e.UpdateThreadTitle=`UPDATE_THREAD_TITLE`,e.ClearFocusChatInput=`CLEAR_FOCUS_CHAT_INPUT`,e.ClearMessages=`CLEAR_MESSAGES`,e.UpdateToolCallProgress=`UPDATE_TOOL_CALL_PROGRESS`,e.UpdateToolExecutionOutput=`UPDATE_TOOL_EXECUTION_OUTPUT`,e.ClearToolCallProgress=`CLEAR_TOOL_CALL_PROGRESS`,e.SetPendingChatMessage=`SET_PENDING_CHAT_MESSAGE`,e.ClearPendingChatMessage=`CLEAR_PENDING_CHAT_MESSAGE`,e.IncrementStreamEventCount=`INCREMENT_STREAM_EVENT_COUNT`,e.SetDiffComments=`SET_DIFF_COMMENTS`,e.ClearSelection=`CLEAR_SELECTION`,e.SetChatInputDraft=`SET_CHAT_INPUT_DRAFT`,e.ClearChatInputDraft=`CLEAR_CHAT_INPUT_DRAFT`,e}({}),ci={isStreaming:!1,streamingContent:``,streamingThinking:``,streamingSegments:[],streamingModel:``,streamingEventCount:0};function li(){return{...ci,streamingSegments:[]}}function ui(e,t){return t?e[t]??li():li()}function di(e,t){return t.threadId??e.selectedThreadId}function fi(e,t,n,r=!1){if(!t)return{...e,...n,toolCallProgress:r?{}:e.toolCallProgress};let i={...e.threadStreamingStates,[t]:n};return t===e.selectedThreadId?{...e,...n,threadStreamingStates:i,toolCallProgress:r?{}:e.toolCallProgress}:{...e,threadStreamingStates:i}}var pi={projects:[],projectsLoading:!0,selectedThreadId:null,selectedProjectId:null,messages:[],messagesLoaded:!1,queuedChatMessages:[],isStreaming:!1,streamingContent:``,streamingThinking:``,streamingSegments:[],streamingModel:``,streamingEventCount:0,threadStreamingStates:{},projectModelSelections:{},sidebarOpen:!0,isCreatingProject:!1,configUpdatedAt:0,processingThreadIds:[],completedThreadIds:[],deletingThreadIds:[],deletingProjectIds:[],commandOutput:``,isRunningCommand:!1,terminalStates:{},focusChatInput:!1,toolCallProgress:{},pendingChatMessage:null,diffComments:{},chatInputDrafts:{}};function mi(e,t){switch(t.type){case`SET_PROJECTS`:{let n={...e.projectModelSelections};for(let e of t.projects)for(let t of e.threads){if(!t.model)continue;let e=n[t.threadId];n[t.threadId]={id:t.model,provider:t.modelProvider,name:e?.name??t.model,description:e?.description??``,context_length:e?.context_length,contextWindow:e?.contextWindow,features:e?.features,input_modalities:e?.input_modalities,max_output:e?.max_output,pricing:e?.pricing,tarsk_use:e?.tarsk_use,coding_index:e?.coding_index,supportsImages:e?.supportsImages}}return{...e,projects:t.projects,projectModelSelections:n}}case`SET_PROJECTS_LOADING`:return{...e,projectsLoading:t.projectsLoading};case`SELECT_THREAD`:{let n=ui(e.threadStreamingStates,t.threadId);return{...e,...n,selectedThreadId:t.threadId,selectedProjectId:t.projectId,messages:t.initialMessages??[],messagesLoaded:!1,focusChatInput:t.focusInput??!1}}case`CLEAR_SELECTION`:return{...e,...li(),selectedThreadId:null,selectedProjectId:null,messages:[],messagesLoaded:!1};case`SET_MESSAGES`:return{...e,messages:t.messages,messagesLoaded:!0};case`ADD_MESSAGE`:return t.threadId&&t.threadId!==e.selectedThreadId?e:{...e,messages:[...e.messages,t.message]};case`ENQUEUE_CHAT_MESSAGE`:return{...e,queuedChatMessages:[...e.queuedChatMessages,t.message]};case`REMOVE_QUEUED_CHAT_MESSAGE`:return{...e,queuedChatMessages:e.queuedChatMessages.filter(e=>e.id!==t.queuedMessageId)};case`SET_STREAMING`:{let n=di(e,t);return fi(e,n,{...ui(e.threadStreamingStates,n),isStreaming:t.isStreaming})}case`APPEND_STREAM_CONTENT`:{let n=di(e,t),r=ui(e.threadStreamingStates,n);return fi(e,n,{...r,streamingContent:r.streamingContent+t.content})}case`SET_STREAM_CONTENT`:{let n=di(e,t),r=ui(e.threadStreamingStates,n),i=ti(r.streamingSegments,t.content);return fi(e,n,{...r,streamingContent:t.content,streamingSegments:i})}case`APPEND_STREAM_THINKING`:{let n=di(e,t),r=ui(e.threadStreamingStates,n);return fi(e,n,{...r,streamingThinking:r.streamingThinking+t.content})}case`INCREMENT_STREAM_EVENT_COUNT`:{let n=di(e,t),r=ui(e.threadStreamingStates,n);return fi(e,n,{...r,streamingEventCount:r.streamingEventCount+1})}case`APPEND_STREAM_CHUNK`:{let n=di(e,t),r=ui(e.threadStreamingStates,n);return fi(e,n,{...r,streamingSegments:t.segments,streamingContent:t.chunkType===`content`?r.streamingContent+t.content:r.streamingContent,streamingThinking:t.chunkType===`thinking`?r.streamingThinking+t.content:r.streamingThinking})}case`SET_STREAM_MODEL`:{let n=di(e,t);return fi(e,n,{...ui(e.threadStreamingStates,n),streamingModel:t.model})}case`SET_PROJECT_MODEL`:return console.log(`[Store] SetProjectModel action:`,{threadId:t.threadId,model:{id:t.model.id,provider:t.model.provider}}),{...e,projects:e.projects.map(e=>({...e,threads:e.threads.map(e=>e.threadId===t.threadId?{...e,model:t.model.id,modelProvider:t.model.provider}:e)})),projectModelSelections:{...e.projectModelSelections,[t.threadId]:t.model}};case`RESET_STREAM`:return fi(e,di(e,t),li(),!0);case`STOP_STREAM`:{let n=di(e,t);return fi(e,n,{...ui(e.threadStreamingStates,n),isStreaming:!1})}case`TOGGLE_SIDEBAR`:return{...e,sidebarOpen:!e.sidebarOpen};case`CLOSE_SIDEBAR`:return e.sidebarOpen?{...e,sidebarOpen:!1}:e;case`SET_CREATING_PROJECT`:return{...e,isCreatingProject:t.isCreating};case`CONFIG_UPDATED`:return{...e,configUpdatedAt:Date.now()};case`SET_PROCESSING_THREADS`:return{...e,processingThreadIds:t.threadIds};case`ADD_PROCESSING_THREAD`:return{...e,processingThreadIds:e.processingThreadIds.includes(t.threadId)?e.processingThreadIds:[...e.processingThreadIds,t.threadId]};case`REMOVE_PROCESSING_THREAD`:return{...e,processingThreadIds:e.processingThreadIds.filter(e=>e!==t.threadId)};case`ADD_CREATING_PROJECT`:return{...e,projects:[...e.projects,{projectId:t.projectId,name:t.projectName,gitUrl:t.gitUrl,threads:[{threadId:t.threadId,title:`thread-1`,path:``,currentBranch:``}]}]};case`ADD_CREATING_THREAD`:return{...e,projects:e.projects.map(e=>e.projectId===t.projectId?{...e,threads:[...e.threads,{threadId:t.threadId,title:t.title,path:``,currentBranch:``}]}:e)};case`REMOVE_CREATING_PROJECT`:return{...e,projects:e.projects.filter(e=>e.projectId!==t.projectId)};case`REMOVE_CREATING_THREAD`:return{...e,projects:e.projects.map(e=>e.projectId===t.projectId?{...e,threads:e.threads.filter(e=>e.threadId!==t.threadId)}:e)};case`MARK_THREAD_COMPLETED`:return{...e,completedThreadIds:e.completedThreadIds.includes(t.threadId)?e.completedThreadIds:[...e.completedThreadIds,t.threadId]};case`CLEAR_THREAD_COMPLETED`:return{...e,completedThreadIds:e.completedThreadIds.filter(e=>e!==t.threadId)};case`ADD_DELETING_THREAD`:return{...e,deletingThreadIds:e.deletingThreadIds.includes(t.threadId)?e.deletingThreadIds:[...e.deletingThreadIds,t.threadId]};case`REMOVE_DELETING_THREAD`:return{...e,deletingThreadIds:e.deletingThreadIds.filter(e=>e!==t.threadId)};case`ADD_DELETING_PROJECT`:return{...e,deletingProjectIds:e.deletingProjectIds.includes(t.projectId)?e.deletingProjectIds:[...e.deletingProjectIds,t.projectId]};case`REMOVE_DELETING_PROJECT`:return{...e,deletingProjectIds:e.deletingProjectIds.filter(e=>e!==t.projectId)};case`APPEND_COMMAND_OUTPUT`:return{...e,commandOutput:e.commandOutput+t.content};case`SET_RUNNING_COMMAND`:return{...e,isRunningCommand:t.isRunning};case`CLEAR_COMMAND_OUTPUT`:return{...e,commandOutput:``};case`TOGGLE_TERMINAL`:{let n=t.threadId,r=e.terminalStates[n]??{open:!1,queuedCommand:null,outputLines:[],height:300,history:[],historyIndex:-1,cwd:`.`,isRunning:!1};return{...e,terminalStates:{...e.terminalStates,[n]:{...r,open:!r.open}}}}case`SET_TERMINAL_OPEN`:{let n=t.threadId??`default`,r=e.terminalStates[n]??{open:!1,queuedCommand:null,outputLines:[],height:300,history:[],historyIndex:-1,cwd:`.`,isRunning:!1};return{...e,terminalStates:{...e.terminalStates,[n]:{...r,open:t.open}}}}case`QUEUE_TERMINAL_COMMAND`:{let n=t.threadId,r=e.terminalStates[n]??{open:!1,queuedCommand:null,queuedRelativeFolder:null,outputLines:[],height:300,history:[],historyIndex:-1,cwd:`.`,isRunning:!1};return{...e,terminalStates:{...e.terminalStates,[n]:{...r,queuedCommand:t.command,queuedRelativeFolder:t.relativeFolder??null,open:!0}}}}case`CLEAR_QUEUED_TERMINAL_COMMAND`:{let n=t.threadId,r=e.terminalStates[n]??{open:!1,queuedCommand:null,outputLines:[],height:300,history:[],historyIndex:-1,cwd:`.`,isRunning:!1};return{...e,terminalStates:{...e.terminalStates,[n]:{...r,queuedCommand:null}}}}case`APPEND_TERMINAL_LINE`:{let n=t.threadId??`default`,r=e.terminalStates[n]??{open:!1,queuedCommand:null,outputLines:[],height:300,history:[],historyIndex:-1,cwd:`.`,isRunning:!1};return{...e,terminalStates:{...e.terminalStates,[n]:{...r,outputLines:[...r.outputLines,t.line]}}}}case`CLEAR_TERMINAL_OUTPUT`:{let n=t.threadId??`default`,r=e.terminalStates[n]??{open:!1,queuedCommand:null,outputLines:[],height:300,history:[],historyIndex:-1,cwd:`.`,isRunning:!1};return{...e,terminalStates:{...e.terminalStates,[n]:{...r,outputLines:[]}}}}case`SET_TERMINAL_HEIGHT`:{let n=t.threadId,r=e.terminalStates[n]??{open:!1,queuedCommand:null,outputLines:[],height:300,history:[],historyIndex:-1,cwd:`.`,isRunning:!1};return{...e,terminalStates:{...e.terminalStates,[n]:{...r,height:t.height}}}}case`SET_TERMINAL_CWD`:{let n=t.threadId,r=e.terminalStates[n]??{open:!1,queuedCommand:null,outputLines:[],height:300,history:[],historyIndex:-1,cwd:`.`,isRunning:!1};return{...e,terminalStates:{...e.terminalStates,[n]:{...r,cwd:t.cwd}}}}case`SET_TERMINAL_RUNNING`:{let n=t.threadId,r=e.terminalStates[n]??{open:!1,queuedCommand:null,outputLines:[],height:300,history:[],historyIndex:-1,cwd:`.`,isRunning:!1};return{...e,terminalStates:{...e.terminalStates,[n]:{...r,isRunning:t.isRunning}}}}case`SET_TERMINAL_HISTORY`:{let n=t.threadId,r=e.terminalStates[n]??{open:!1,queuedCommand:null,outputLines:[],height:300,history:[],historyIndex:-1,cwd:`.`,isRunning:!1};return{...e,terminalStates:{...e.terminalStates,[n]:{...r,history:t.history}}}}case`SET_TERMINAL_HISTORY_INDEX`:{let n=t.threadId,r=e.terminalStates[n]??{open:!1,queuedCommand:null,outputLines:[],height:300,history:[],historyIndex:-1,cwd:`.`,isRunning:!1};return{...e,terminalStates:{...e.terminalStates,[n]:{...r,historyIndex:t.index}}}}case`UPDATE_THREAD_TITLE`:return{...e,projects:e.projects.map(e=>e.projectId===t.projectId?{...e,threads:e.threads.map(e=>e.threadId===t.threadId?{...e,title:t.title}:e)}:e)};case`CLEAR_FOCUS_CHAT_INPUT`:return{...e,focusChatInput:!1};case`CLEAR_MESSAGES`:return{...e,messages:[]};case`UPDATE_TOOL_CALL_PROGRESS`:{let n=e.toolCallProgress[t.toolCallId];return{...e,toolCallProgress:{...e.toolCallProgress,[t.toolCallId]:{...n,...t.progress}}}}case`UPDATE_TOOL_EXECUTION_OUTPUT`:{let n=e.toolCallProgress[t.toolCallId];return{...e,toolCallProgress:{...e.toolCallProgress,[t.toolCallId]:{toolCallId:t.toolCallId,toolName:t.toolName??n?.toolName??``,delta:n?.delta??``,partial:n?.partial??{role:`tool`,content:[]},executionOutput:t.executionOutput}}}}case`CLEAR_TOOL_CALL_PROGRESS`:{if(!t.toolCallId)return{...e,toolCallProgress:{}};let{[t.toolCallId]:n,...r}=e.toolCallProgress;return{...e,toolCallProgress:r}}case`SET_PENDING_CHAT_MESSAGE`:return{...e,pendingChatMessage:t.message};case`CLEAR_PENDING_CHAT_MESSAGE`:return{...e,pendingChatMessage:null};case`SET_DIFF_COMMENTS`:return{...e,diffComments:{...e.diffComments,[t.threadId]:t.comments}};case`SET_CHAT_INPUT_DRAFT`:return{...e,chatInputDrafts:{...e.chatInputDrafts,[t.threadId]:t.draft}};case`CLEAR_CHAT_INPUT_DRAFT`:{let{[t.threadId]:n,...r}=e.chatInputDrafts;return{...e,chatInputDrafts:r}}default:return e}}function hi(e=pi){let t=e,n=new Set;function r(){return t}function i(e){let r=mi(t,e);if(r!==t){t=r;for(let e of n)e()}}function a(e){return n.add(e),function(){n.delete(e)}}return{getState:r,dispatch:i,subscribe:a}}var gi=(0,Y.createContext)(null);function _i(){let e=(0,Y.useContext)(gi);if(!e)throw Error(`useAppStore must be used within an AppStoreContext.Provider`);return e}function Q(e){let t=(0,X.c)(3),n=_i(),r;t[0]!==e||t[1]!==n?(r=function(){return e(n.getState())},t[0]=e,t[1]=n,t[2]=r):r=t[2];let i=r;return(0,Y.useSyncExternalStore)(n.subscribe,i,i)}function vi(){return _i().dispatch}var yi={open:!1,queuedCommand:null,queuedRelativeFolder:null,outputLines:[],height:300,history:[],historyIndex:-1,cwd:`.`,isRunning:!1};function bi(e){let t=(0,X.c)(8),n=vi(),r;t[0]===e?r=t[1]:(r=t=>(e?t.terminalStates[e]:void 0)??yi,t[0]=e,t[1]=r);let i=Q(r),a;t[2]!==n||t[3]!==e?(a=t=>{e&&n({...t,threadId:e})},t[2]=n,t[3]=e,t[4]=a):a=t[4];let o=a,s;return t[5]!==o||t[6]!==i?(s={terminalState:i,dispatch:o},t[5]=o,t[6]=i,t[7]=s):s=t[7],s}var $=vt(),xi=Y.forwardRef((e,t)=>{let n=(0,X.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=q(`flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,$.jsx)(`textarea`,{className:a,ref:t,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});xi.displayName=`Textarea`;function Si(e){let t=(0,X.c)(47),{open:n,onOpenChange:r,feedbackName:i,onFeedbackNameChange:a,feedbackEmail:s,onFeedbackEmailChange:c,feedbackText:l,onFeedbackTextChange:u,loadingFeedbackUser:d,submittingFeedback:f,onSubmit:p}=e,m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsxs)(bt,{children:[(0,$.jsx)(z,{children:`Send Feedback`}),(0,$.jsx)(St,{children:`Share feedback about Tarsk.`})]}),t[0]=m):m=t[0];let _;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(vn,{htmlFor:`feedback-name`,children:`Name`}),t[1]=_):_=t[1];let v;t[2]===a?v=t[3]:(v=e=>a(e.target.value),t[2]=a,t[3]=v);let b=f||d,x;t[4]!==i||t[5]!==v||t[6]!==b?(x=(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[_,(0,$.jsx)(y,{id:`feedback-name`,value:i,onChange:v,placeholder:`Your name`,disabled:b})]}),t[4]=i,t[5]=v,t[6]=b,t[7]=x):x=t[7];let S;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,$.jsx)(vn,{htmlFor:`feedback-email`,children:`Email`}),t[8]=S):S=t[8];let C;t[9]===c?C=t[10]:(C=e=>c(e.target.value),t[9]=c,t[10]=C);let w=f||d,T;t[11]!==s||t[12]!==C||t[13]!==w?(T=(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[S,(0,$.jsx)(y,{id:`feedback-email`,type:`email`,value:s,onChange:C,placeholder:`you@example.com`,disabled:w})]}),t[11]=s,t[12]=C,t[13]=w,t[14]=T):T=t[14];let E;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,$.jsx)(vn,{htmlFor:`feedback-text`,children:`Feedback`}),t[15]=E):E=t[15];let D;t[16]===u?D=t[17]:(D=e=>u(e.target.value),t[16]=u,t[17]=D);let O;t[18]!==l||t[19]!==f||t[20]!==D?(O=(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[E,(0,$.jsx)(xi,{id:`feedback-text`,value:l,onChange:D,placeholder:`Tell us what you think...`,className:`min-h-32`,disabled:f})]}),t[18]=l,t[19]=f,t[20]=D,t[21]=O):O=t[21];let k;t[22]!==O||t[23]!==x||t[24]!==T?(k=(0,$.jsxs)(`div`,{className:`grid gap-4 py-2`,children:[x,T,O]}),t[22]=O,t[23]=x,t[24]=T,t[25]=k):k=t[25];let A;t[26]===r?A=t[27]:(A=()=>r(!1),t[26]=r,t[27]=A);let j;t[28]!==f||t[29]!==A?(j=(0,$.jsx)(U,{variant:`outline`,onClick:A,disabled:f,children:`Cancel`}),t[28]=f,t[29]=A,t[30]=j):j=t[30];let M;t[31]===f?M=t[32]:(M=f?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(g,{className:`mr-2 h-4 w-4 animate-spin`}),`Sending...`]}):`Send`,t[31]=f,t[32]=M);let N;t[33]!==p||t[34]!==f||t[35]!==M?(N=(0,$.jsx)(U,{onClick:p,disabled:f,children:M}),t[33]=p,t[34]=f,t[35]=M,t[36]=N):N=t[36];let P;t[37]!==j||t[38]!==N?(P=(0,$.jsxs)(o,{children:[j,N]}),t[37]=j,t[38]=N,t[39]=P):P=t[39];let F;t[40]!==k||t[41]!==P?(F=(0,$.jsxs)(H,{className:`max-w-xl`,children:[m,k,P]}),t[40]=k,t[41]=P,t[42]=F):F=t[42];let I;return t[43]!==r||t[44]!==n||t[45]!==F?(I=(0,$.jsx)(h,{open:n,onOpenChange:r,children:F}),t[43]=r,t[44]=n,t[45]=F,t[46]=I):I=t[46],I}function Ci(e){let t=(0,X.c)(30),{node:n,level:r,renderNode:i,defaultOpen:a,indent:o,childContainerClassName:s,openState:c,onToggle:l,forceOpenIds:u}=e,d=!!(n.children&&n.children.length>0),f,p,m;if(t[0]!==a||t[1]!==u||t[2]!==d||t[3]!==r||t[4]!==n||t[5]!==l||t[6]!==c||t[7]!==i){f=u?.has(n.id)||(c[n.id]??a);let e;t[11]!==n.id||t[12]!==l?(e=()=>l(n.id),t[11]=n.id,t[12]=l,t[13]=e):e=t[13];let o=e;p=`min-w-0`,m=i(n,{isOpen:f,level:r,toggle:o,hasChildren:d}),t[0]=a,t[1]=u,t[2]=d,t[3]=r,t[4]=n,t[5]=l,t[6]=c,t[7]=i,t[8]=f,t[9]=p,t[10]=m}else f=t[8],p=t[9],m=t[10];let h;t[14]!==s||t[15]!==a||t[16]!==u||t[17]!==d||t[18]!==o||t[19]!==f||t[20]!==r||t[21]!==n.children||t[22]!==l||t[23]!==c||t[24]!==i?(h=d&&f&&(0,$.jsx)(`div`,{style:{paddingLeft:o},className:s,children:n.children.map(e=>(0,$.jsx)(Ci,{node:e,level:r+1,renderNode:i,defaultOpen:a,indent:o,childContainerClassName:s,openState:c,onToggle:l,forceOpenIds:u},e.id))}),t[14]=s,t[15]=a,t[16]=u,t[17]=d,t[18]=o,t[19]=f,t[20]=r,t[21]=n.children,t[22]=l,t[23]=c,t[24]=i,t[25]=h):h=t[25];let g;return t[26]!==p||t[27]!==m||t[28]!==h?(g=(0,$.jsxs)(`div`,{className:p,children:[m,h]}),t[26]=p,t[27]=m,t[28]=h,t[29]=g):g=t[29],g}function wi(e){let t=(0,X.c)(27),{nodes:n,renderNode:r,resetKey:i,defaultOpen:a,forceOpenIds:o,indent:s,childContainerClassName:c,className:l}=e,u=a===void 0?!1:a,d=s===void 0?16:s,f;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(f={},t[0]=f):f=t[0];let[p,m]=(0,Y.useState)(f),[h,g]=(0,Y.useState)(i);i!==h&&(g(i),m({}));let _;t[1]===o?_=t[2]:(_=o?new Set(o):void 0,t[1]=o,t[2]=_);let v=_,y;t[3]===u?y=t[4]:(y=e=>{m(t=>({...t,[e]:!(t[e]??u)}))},t[3]=u,t[4]=y);let b=y,x;t[5]===l?x=t[6]:(x=q(`min-w-0`,l),t[5]=l,t[6]=x);let S;if(t[7]!==c||t[8]!==u||t[9]!==v||t[10]!==b||t[11]!==d||t[12]!==n||t[13]!==p||t[14]!==r){let e;t[16]!==c||t[17]!==u||t[18]!==v||t[19]!==b||t[20]!==d||t[21]!==p||t[22]!==r?(e=e=>(0,$.jsx)(Ci,{node:e,level:0,renderNode:r,defaultOpen:u,indent:d,childContainerClassName:c,openState:p,onToggle:b,forceOpenIds:v},e.id),t[16]=c,t[17]=u,t[18]=v,t[19]=b,t[20]=d,t[21]=p,t[22]=r,t[23]=e):e=t[23],S=n.map(e),t[7]=c,t[8]=u,t[9]=v,t[10]=b,t[11]=d,t[12]=n,t[13]=p,t[14]=r,t[15]=S}else S=t[15];let C;return t[24]!==x||t[25]!==S?(C=(0,$.jsx)(`div`,{className:x,children:S}),t[24]=x,t[25]=S,t[26]=C):C=t[26],C}var Ti=1,Ei=1e6,Di=0;function Oi(){return Di=(Di+1)%(2**53-1),Di.toString()}var ki=new Map,Ai=e=>{if(ki.has(e))return;let t=setTimeout(()=>{ki.delete(e),Pi({type:`REMOVE_TOAST`,toastId:e})},Ei);ki.set(e,t)},ji=(e,t)=>{switch(t.type){case`ADD_TOAST`:return{...e,toasts:[t.toast,...e.toasts].slice(0,Ti)};case`UPDATE_TOAST`:return{...e,toasts:e.toasts.map(e=>e.id===t.toast.id?{...e,...t.toast}:e)};case`DISMISS_TOAST`:{let{toastId:n}=t;return n?Ai(n):e.toasts.forEach(e=>{Ai(e.id)}),{...e,toasts:e.toasts.map(e=>e.id===n||n===void 0?{...e,open:!1}:e)}}case`REMOVE_TOAST`:return t.toastId===void 0?{...e,toasts:[]}:{...e,toasts:e.toasts.filter(e=>e.id!==t.toastId)}}},Mi=[],Ni={toasts:[]};function Pi(e){Ni=ji(Ni,e),Mi.forEach(e=>{e(Ni)})}function Fi({...e}){let t=Oi(),n=e=>Pi({type:`UPDATE_TOAST`,toast:{...e,id:t}}),r=()=>Pi({type:`DISMISS_TOAST`,toastId:t});return Pi({type:`ADD_TOAST`,toast:{...e,id:t,open:!0,onOpenChange:e=>{e||r()}}}),{id:t,dismiss:r,update:n}}function Ii(){let e=(0,X.c)(4),[t,n]=Y.useState(Ni),r,i;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>(Mi.push(n),()=>{let e=Mi.indexOf(n);e>-1&&Mi.splice(e,1)}),i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),Y.useEffect(r,i);let a;return e[2]===t?a=e[3]:(a={...t,toast:Fi,dismiss:Li},e[2]=t,e[3]=a),a}function Li(e){return Pi({type:`DISMISS_TOAST`,toastId:e})}function Ri(){let[e,t]=(0,Y.useState)(!1),[n,r]=(0,Y.useState)(``),[i,a]=(0,Y.useState)(``),[o,s]=(0,Y.useState)(``),[c,l]=(0,Y.useState)(!1),[u,d]=(0,Y.useState)(!1);return(0,Y.useEffect)(()=>{if(!e)return;let t=!0;return l(!0),zt().then(e=>{t&&(r(t=>t||e.name),a(t=>t||e.email))}).catch(()=>{t&&Fi({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){Fi({title:`Feedback required`,description:`Please enter your feedback before submitting.`,variant:`destructive`});return}d(!0);try{await _e(`api/feedback`,{name:n.trim(),email:i.trim(),feedback:e}),Fi({title:`Feedback sent`,description:`Thanks for sharing your feedback.`}),s(``),t(!1)}catch(e){Fi({title:`Failed to send feedback`,description:e instanceof Error?e.message:`Please try again.`,variant:`destructive`})}finally{d(!1)}}}}var zi=Sr(e=>(0,$.jsxs)(`div`,{className:`flex flex-col select-none bg-sidebar text-sidebar-foreground mx-2.5 mt-8 md:mr-10 rounded-3xl shadow-2xl overflow-hidden`,style:e.v0,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b border-sidebar-border px-4 py-3 h-[61px]`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`div`,{className:`flex h-7 w-7 items-center justify-center overflow-hidden rounded-md border border-sidebar-border shadow-sm`,children:(0,$.jsx)(`img`,{src:`/tarsk.svg`,alt:`Tarsk`,className:e.v1,onClick:e.v2})}),e.v3]}),e.v4]}),e.v5,e.v6]}),{name:`SidePanelContainer_1`,portals:[`v3`,`v4`,`v5`,`v6`]}),Bi=function(e){let t=(0,X.c)(22),{children:n,collapsed:r,title:i,onTitleClose:a,subtitle:o,headerAction:s,footer:c,onLogoClick:l}=e,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u={containerType:`inline-size`,height:`calc(100% - 42px)`},t[0]=u):u=t[0];let d=l&&`cursor-pointer`,f;t[1]===d?f=t[2]:(f=q(`h-full w-full`,d),t[1]=d,t[2]=f);let p;t[3]!==r||t[4]!==o?(p=!r&&(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(`span`,{className:J.sectionTitle,children:`Tarsk`}),o&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)($t,{className:`h-3 w-3 text-sidebar-foreground/60`}),(0,$.jsx)(`span`,{className:q(J.label,`text-sidebar-foreground/80`),children:o})]})]}),t[3]=r,t[4]=o,t[5]=p):p=t[5];let m;t[6]!==r||t[7]!==s||t[8]!==a||t[9]!==i?(m=(i??a??s)&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 ml-auto`,children:[s&&!r&&s,i&&(0,$.jsx)(`span`,{className:q(J.compact,`font-medium text-sidebar-foreground/80`),children:i}),a&&(0,$.jsxs)(U,{variant:`ghost`,size:`icon`,className:`h-7 w-7 text-sidebar-foreground`,onClick:a,children:[(0,$.jsx)(A,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]}),t[6]=r,t[7]=s,t[8]=a,t[9]=i,t[10]=m):m=t[10];let h;t[11]===n?h=t[12]:(h=(0,$.jsx)(Ye,{className:`flex-1`,children:n}),t[11]=n,t[12]=h);let g;t[13]===c?g=t[14]:(g=c&&(0,$.jsx)(`div`,{className:`border-t border-sidebar-border`,children:c}),t[13]=c,t[14]=g);let _;return t[15]!==l||t[16]!==f||t[17]!==p||t[18]!==m||t[19]!==h||t[20]!==g?(_=(0,$.jsx)(zi,{v0:u,v1:f,v2:l,v3:p,v4:m,v5:h,v6:g}),t[15]=l,t[16]=f,t[17]=p,t[18]=m,t[19]=h,t[20]=g,t[21]=_):_=t[21],_};function Vi(e){let t=(0,X.c)(80),{projects:r,selectedThreadId:i,selectedProjectId:a,processingThreadIds:o,completedThreadIds:s,deletingThreadIds:c,deletingProjectIds:l,onSelectThread:d,onCreateProject:f,onCreateThread:p,onDeleteThread:m,onDeleteProject:h,onDeselect:_,collapsed:v,updateAvailable:y,updatingApp:b,onUpdateApp:x,expandProjectId:S}=e,C=Qn(),{showFeedback:w,feedbackName:T,setFeedbackName:E,feedbackEmail:D,setFeedbackEmail:O,feedbackText:k,setFeedbackText:A,loadingFeedbackUser:j,submittingFeedback:M,handleFeedbackDialogChange:N,handleSubmitFeedback:P}=Ri(),F;t[0]===r?F=t[1]:(F=r.map(Hi),t[0]=r,t[1]=F);let I=F,L;t[2]!==v||t[3]!==f?(L=!v&&(0,$.jsxs)(U,{variant:`outline`,size:`sm`,className:`gap-2`,onClick:f,children:[(0,$.jsx)(on,{className:`h-4 w-4 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:`New Project`})]}),t[2]=v,t[3]=f,t[4]=L):L=t[4];let R;t[5]!==v||t[6]!==x||t[7]!==y||t[8]!==b?(R=y&&(0,$.jsxs)(U,{variant:`ghost`,size:`sm`,className:`w-full justify-start gap-2 text-emerald-600 dark:text-emerald-400`,onClick:x,disabled:b,children:[b?(0,$.jsx)(g,{className:`h-4 w-4 animate-spin`}):(0,$.jsx)(Fe,{className:`h-4 w-4`}),!v&&(0,$.jsx)(`span`,{className:`truncate`,children:b?`Updating...`:`Update to Latest`})]}),t[5]=v,t[6]=x,t[7]=y,t[8]=b,t[9]=R):R=t[9];let ee;t[10]===C?ee=t[11]:(ee=()=>void C(`/settings/general`),t[10]=C,t[11]=ee);let z;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,$.jsx)(n,{className:`h-4 w-4`}),t[12]=z):z=t[12];let te;t[13]===v?te=t[14]:(te=!v&&(0,$.jsx)(`span`,{className:`truncate`,children:`Settings`}),t[13]=v,t[14]=te);let ne;t[15]!==ee||t[16]!==te?(ne=(0,$.jsxs)(U,{variant:`ghost`,size:`sm`,className:`flex-1 justify-start gap-2 text-sidebar-foreground`,onClick:ee,children:[z,te]}),t[15]=ee,t[16]=te,t[17]=ne):ne=t[17];let re;t[18]===N?re=t[19]:(re=()=>N(!0),t[18]=N,t[19]=re);let B,ie;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(ie=(0,$.jsx)(u,{className:`h-4 w-4`}),B=(0,$.jsx)(`span`,{className:`sr-only`,children:`Feedback`}),t[20]=B,t[21]=ie):(B=t[20],ie=t[21]);let V;t[22]===re?V=t[23]:(V=(0,$.jsx)(G,{asChild:!0,children:(0,$.jsxs)(U,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground hover:text-background`,onClick:re,children:[ie,B]})}),t[22]=re,t[23]=V);let ae;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(ae=(0,$.jsx)(K,{children:`Send feedback to the Tarsk team`}),t[24]=ae):ae=t[24];let H;t[25]===V?H=t[26]:(H=(0,$.jsx)(Mt,{children:(0,$.jsxs)(W,{children:[V,ae]})}),t[25]=V,t[26]=H);let oe;t[27]!==H||t[28]!==ne?(oe=(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[ne,H]}),t[27]=H,t[28]=ne,t[29]=oe):oe=t[29];let se;t[30]!==oe||t[31]!==R?(se=(0,$.jsxs)(`div`,{className:`px-3 py-2 flex flex-col gap-1`,children:[R,oe]}),t[30]=oe,t[31]=R,t[32]=se):se=t[32];let ce;t[33]===r.length?ce=t[34]:(ce=r.length===0&&(0,$.jsx)(`p`,{className:q(J.compact,`px-3 py-6 text-center text-muted-foreground`),children:`No projects yet. Clone a repository to get started.`}),t[33]=r.length,t[34]=ce);let le;t[35]===S?le=t[36]:(le=S?[S]:void 0,t[35]=S,t[36]=le);let ue;t[37]!==s||t[38]!==l||t[39]!==c||t[40]!==C||t[41]!==p||t[42]!==h||t[43]!==m||t[44]!==d||t[45]!==o||t[46]!==r||t[47]!==a||t[48]!==i?(ue=(e,t)=>{let{isOpen:n,toggle:u}=t;return e.kind===`project`?(0,$.jsx)(Ui,{project:e.project,isOpen:n,onToggle:u,isDeletingProject:l.includes(e.project.projectId),isSelected:a?e.project.projectId===a:!1,onCreateThread:p,onDeleteProject:h,onProjectSettings:e=>void C(`/settings/project/${e}`),hasSelectedThread:e.project.threads.some(e=>e.threadId===i)}):(0,$.jsx)(Wi,{thread:e.thread,projectId:e.projectId,selectedThreadId:i,isProcessing:o.includes(e.thread.threadId),isDeleting:c.includes(e.thread.threadId),isCompleted:s.includes(e.thread.threadId),projectTitlePrefix:`${at(r.find(t=>t.projectId===e.projectId))} - `,onSelectThread:d,onDeleteThread:m})},t[37]=s,t[38]=l,t[39]=c,t[40]=C,t[41]=p,t[42]=h,t[43]=m,t[44]=d,t[45]=o,t[46]=r,t[47]=a,t[48]=i,t[49]=ue):ue=t[49];let de;t[50]!==I||t[51]!==le||t[52]!==ue?(de=(0,$.jsx)(wi,{nodes:I,defaultOpen:!0,forceOpenIds:le,childContainerClassName:`ml-4 border-l border-sidebar-border pl-2`,renderNode:ue}),t[50]=I,t[51]=le,t[52]=ue,t[53]=de):de=t[53];let fe;t[54]!==ce||t[55]!==de?(fe=(0,$.jsx)(`div`,{className:`flex-1 w-full`,children:(0,$.jsxs)(`div`,{className:`px-2 py-2 w-full max-w-full overflow-hidden`,children:[ce,de]})}),t[54]=ce,t[55]=de,t[56]=fe):fe=t[56];let pe;t[57]!==v||t[58]!==_||t[59]!==se||t[60]!==L||t[61]!==fe?(pe=(0,$.jsx)(Bi,{collapsed:v,onLogoClick:_,headerAction:L,footer:se,children:fe}),t[57]=v,t[58]=_,t[59]=se,t[60]=L,t[61]=fe,t[62]=pe):pe=t[62];let me;t[63]===P?me=t[64]:(me=()=>void P(),t[63]=P,t[64]=me);let he;t[65]!==D||t[66]!==T||t[67]!==k||t[68]!==N||t[69]!==j||t[70]!==O||t[71]!==E||t[72]!==A||t[73]!==w||t[74]!==M||t[75]!==me?(he=(0,$.jsx)(Si,{open:w,onOpenChange:N,feedbackName:T,onFeedbackNameChange:E,feedbackEmail:D,onFeedbackEmailChange:O,feedbackText:k,onFeedbackTextChange:A,loadingFeedbackUser:j,submittingFeedback:M,onSubmit:me}),t[65]=D,t[66]=T,t[67]=k,t[68]=N,t[69]=j,t[70]=O,t[71]=E,t[72]=A,t[73]=w,t[74]=M,t[75]=me,t[76]=he):he=t[76];let ge;return t[77]!==pe||t[78]!==he?(ge=(0,$.jsxs)($.Fragment,{children:[pe,he]}),t[77]=pe,t[78]=he,t[79]=ge):ge=t[79],ge}function Hi(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 Ui(e){let t=(0,X.c)(33),{project:r,isOpen:i,onToggle:a,isDeletingProject:o,hasSelectedThread:c,isSelected:l,onCreateThread:u,onDeleteProject:d,onProjectSettings:f}=e,p;t[0]===r?p=t[1]:(p=at(r),t[0]=r,t[1]=p);let m=p,h=c||l,_=i&&`rotate-90`,v;t[2]===_?v=t[3]:(v=q(`h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform`,_),t[2]=_,t[3]=v);let y;t[4]===v?y=t[5]:(y=(0,$.jsx)($t,{className:v}),t[4]=v,t[5]=y);let b;t[6]===r.gitUrl?b=t[7]:(b=r.gitUrl?(0,$.jsx)(E,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}):(0,$.jsx)(s,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}),t[6]=r.gitUrl,t[7]=b);let x=(c||l)&&`font-bold text-foreground`,S;t[8]===x?S=t[9]:(S=q(`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]!==w?(T=(0,$.jsx)(`button`,{type:`button`,className:`min-w-0`,onClick:a,children:w}),t[17]=a,t[18]=w,t[19]=T):T=t[19];let D;t[20]!==T||t[21]!==h?(D=(0,$.jsx)(pr,{selected:h,noBackground:!0,className:`h-9 min-w-0 flex-1`,asChild:!0,children:T}),t[20]=T,t[21]=h,t[22]=D):D=t[22];let O;t[23]!==o||t[24]!==u||t[25]!==d||t[26]!==f||t[27]!==r.projectId||t[28]!==r.threads?(O=(0,$.jsx)(`div`,{className:`flex shrink-0 items-center`,children:o?(0,$.jsx)(g,{className:`h-3.5 w-3.5 shrink-0 animate-spin text-muted-foreground mr-1`}):(0,$.jsxs)(Mt,{children:[(0,$.jsxs)(W,{children:[(0,$.jsx)(G,{asChild:!0,children:(0,$.jsxs)(U,{variant:`ghost`,size:`icon`,className:`h-7 w-7 shrink-0 hidden can-hover:group-hover:flex items-center justify-center`,onClick:()=>f(r.projectId),children:[(0,$.jsx)(n,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Project settings`})]})}),(0,$.jsx)(K,{side:`right`,children:`Project settings`})]}),(0,$.jsxs)(W,{children:[(0,$.jsx)(G,{asChild:!0,children:(0,$.jsxs)(U,{variant:`action`,size:`icon-sm`,className:`shrink-0 hidden can-hover:group-hover:flex items-center justify-center`,onClick:()=>u(r.projectId),children:[(0,$.jsx)(on,{}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Add thread`})]})}),(0,$.jsx)(K,{side:`right`,children:`Add thread`})]}),r.threads.length===0&&(0,$.jsxs)(W,{children:[(0,$.jsx)(G,{asChild:!0,children:(0,$.jsxs)(U,{variant:`ghost`,size:`icon-sm`,className:`shrink-0 hidden can-hover:group-hover:flex items-center justify-center text-muted-foreground can-hover:hover:bg-destructive can-hover:hover:text-destructive-foreground transition-colors`,onClick:()=>d(r.projectId),children:[(0,$.jsx)(Ee,{}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Delete project`})]})}),(0,$.jsx)(K,{side:`right`,children:`Delete project`})]})]})}),t[23]=o,t[24]=u,t[25]=d,t[26]=f,t[27]=r.projectId,t[28]=r.threads,t[29]=O):O=t[29];let k;return t[30]!==D||t[31]!==O?(k=(0,$.jsxs)(`div`,{className:`group mb-1 flex min-w-0 items-center`,children:[D,O]}),t[30]=D,t[31]=O,t[32]=k):k=t[32],k}function Wi(e){let t=(0,X.c)(58),{thread:n,projectId:r,selectedThreadId:i,isProcessing:a,isDeleting:o,isCompleted:s,projectTitlePrefix:c,onSelectThread:l,onDeleteThread:u}=e,[d,f]=(0,Y.useState)(!1),p=(0,Y.useRef)(null),m=n.threadId===i,h,_;t[0]===a?(h=t[1],_=t[2]):(h=()=>{a&&p.current&&p.current.scrollIntoView({behavior:`smooth`,block:`nearest`})},_=[a],t[0]=a,t[1]=h,t[2]=_),(0,Y.useEffect)(h,_);let v;t[3]!==u||t[4]!==r||t[5]!==n.gitStatusDot||t[6]!==n.threadId?(v=e=>{e.stopPropagation(),n.gitStatusDot?f(!0):u(r,n.threadId)},t[3]=u,t[4]=r,t[5]=n.gitStatusDot,t[6]=n.threadId,t[7]=v):v=t[7];let y=v,b;t[8]!==c||t[9]!==n.threadId||t[10]!==n.title?(b=n.title?.startsWith(c)?n.title.slice(c.length):n.title??n.threadId,t[8]=c,t[9]=n.threadId,t[10]=n.title,t[11]=b):b=t[11];let x=b,S;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,$.jsx)(yr,{children:`Delete Thread`}),t[12]=S):S=t[12];let C;t[13]===x?C=t[14]:(C=(0,$.jsxs)(xr,{children:[`Are you sure you want to delete "`,x,`" and all its files? This action cannot be undone.`]}),t[13]=x,t[14]=C);let w;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(Tr,{children:`Cancel`}),t[15]=w):w=t[15];let T;t[16]!==u||t[17]!==r||t[18]!==n.threadId?(T=(0,$.jsxs)(`div`,{className:`flex gap-3 justify-end`,children:[w,(0,$.jsx)(_r,{onClick:()=>{f(!1),u(r,n.threadId)},className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:`Delete`})]}),t[16]=u,t[17]=r,t[18]=n.threadId,t[19]=T):T=t[19];let E;t[20]!==C||t[21]!==T?(E=(0,$.jsxs)(br,{children:[S,C,T]}),t[20]=C,t[21]=T,t[22]=E):E=t[22];let D;t[23]!==d||t[24]!==E?(D=(0,$.jsx)(Er,{open:d,onOpenChange:f,children:E}),t[23]=d,t[24]=E,t[25]=D):D=t[25];let O;t[26]!==l||t[27]!==r||t[28]!==n.threadId?(O=()=>l(r,n.threadId),t[26]=l,t[27]=r,t[28]=n.threadId,t[29]=O):O=t[29];let k;t[30]===n.gitStatusDot?k=t[31]:(k=n.gitStatusDot?(0,$.jsx)(`svg`,{className:`h-3 w-3 shrink-0`,viewBox:`0 0 12 12`,fill:`hsl(var(--brand))`,xmlns:`http://www.w3.org/2000/svg`,children:(0,$.jsx)(`circle`,{cx:`6`,cy:`6`,r:`5`})}):(0,$.jsx)(`svg`,{className:`h-3 w-3 shrink-0 text-muted-foreground`,viewBox:`0 0 12 12`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.0`,xmlns:`http://www.w3.org/2000/svg`,children:(0,$.jsx)(`circle`,{cx:`6`,cy:`6`,r:`4.5`})}),t[30]=n.gitStatusDot,t[31]=k);let A;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(A=q(J.body,`truncate block`),t[32]=A):A=t[32];let j;t[33]===x?j=t[34]:(j=(0,$.jsx)(`div`,{className:`flex-1 min-w-0 w-0`,children:(0,$.jsx)(`span`,{className:A,children:x})}),t[33]=x,t[34]=j);let M;t[35]!==s||t[36]!==o||t[37]!==a?(M=a||o?(0,$.jsx)(g,{className:`ml-auto h-3 w-3 shrink-0 animate-spin text-muted-foreground`}):s?(0,$.jsx)(cn,{className:`ml-auto h-3 w-3 shrink-0 text-green-500`}):null,t[35]=s,t[36]=o,t[37]=a,t[38]=M):M=t[38];let N;t[39]!==O||t[40]!==k||t[41]!==j||t[42]!==M?(N=(0,$.jsxs)(`button`,{type:`button`,className:`min-w-0 w-full`,onClick:O,children:[k,j,M]}),t[39]=O,t[40]=k,t[41]=j,t[42]=M,t[43]=N):N=t[43];let P;t[44]!==m||t[45]!==N?(P=(0,$.jsx)(pr,{selected:m,className:`min-w-0 flex-1`,asChild:!0,children:N}),t[44]=m,t[45]=N,t[46]=P):P=t[46];let F;t[47]!==y||t[48]!==s||t[49]!==o||t[50]!==a?(F=!a&&!o&&!s&&(0,$.jsxs)(W,{children:[(0,$.jsx)(G,{asChild:!0,children:(0,$.jsxs)(U,{variant:`ghost`,size:`icon-sm`,className:`hidden can-hover:group-hover:flex shrink-0 items-center justify-center text-muted-foreground can-hover:hover:bg-destructive can-hover:hover:text-destructive-foreground transition-colors`,onClick:y,children:[(0,$.jsx)(Ee,{}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Delete thread`})]})}),(0,$.jsx)(K,{side:`right`,children:`Delete thread and files from the repo`})]}),t[47]=y,t[48]=s,t[49]=o,t[50]=a,t[51]=F):F=t[51];let I;t[52]!==P||t[53]!==F?(I=(0,$.jsxs)(`div`,{ref:p,className:`group flex min-w-0 items-center`,children:[P,F]}),t[52]=P,t[53]=F,t[54]=I):I=t[54];let L;return t[55]!==D||t[56]!==I?(L=(0,$.jsxs)($.Fragment,{children:[D,I]}),t[55]=D,t[56]=I,t[57]=L):L=t[57],L}var Gi=e(qe(),1),Ki=.1,qi=10,Ji=1.25,Yi=.001;function Xi(){let e=(0,X.c)(15),[t,n]=(0,Y.useState)(1),r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r={x:0,y:0},e[0]=r):r=e[0];let[i,a]=(0,Y.useState)(r),[o,s]=(0,Y.useState)(!1),c=(0,Y.useRef)(null),l=Zi,u;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>n(e=>l(e*Ji)),e[1]=u):u=e[1];let d=u,f;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=()=>n(e=>l(e/Ji)),e[2]=f):f=e[2];let p=f,m;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>{n(1),a({x:0,y:0})},e[3]=m):m=e[3];let h=m,g;e[4]===i?g=e[5]:(g=e=>{e.preventDefault(),s(!0),c.current={x:e.clientX,y:e.clientY,ox:i.x,oy:i.y}},e[4]=i,e[5]=g);let _=g,v;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(v=e=>{c.current&&a({x:c.current.ox+(e.clientX-c.current.x),y:c.current.oy+(e.clientY-c.current.y)})},e[6]=v):v=e[6];let y=v,b;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(b=()=>{s(!1),c.current=null},e[7]=b):b=e[7];let x=b,S=(0,Y.useRef)(null),C,w;e[8]===Symbol.for(`react.memo_cache_sentinel`)?(C=()=>{let e=S.current;if(!e)return;let t=function(e){e.preventDefault();let t=-e.deltaY*Yi;n(e=>l(e*(1+t)))};return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},w=[],e[8]=C,e[9]=w):(C=e[8],w=e[9]),(0,Y.useEffect)(C,w);let T;return e[10]!==o||e[11]!==i||e[12]!==_||e[13]!==t?(T={scale:t,offset:i,isDragging:o,containerRef:S,zoomIn:d,zoomOut:p,reset:h,onMouseDown:_,onMouseMove:y,onMouseUp:x},e[10]=o,e[11]=i,e[12]=_,e[13]=t,e[14]=T):T=e[14],T}function Zi(e){return Math.min(Math.max(e,Ki),qi)}var Qi=Sr(e=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border bg-muted/80 px-4 py-2`,children:[(0,$.jsx)(`span`,{className:e.v0,children:e.v1}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[e.v2,e.v3]})]}),{name:`JSX_header_1`,portals:[`v1`,`v2`,`v3`]}),$i=Sr(e=>(0,$.jsxs)(`div`,{className:e.v0,children:[e.v1,(0,$.jsx)(`pre`,{className:`overflow-x-auto p-4 max-w-full`,children:(0,$.jsx)(`code`,{className:e.v2,children:e.v3})})]}),{name:`MermaidRenderer_1`,portals:[`v1`,`v3`]}),ea=Sr(e=>(0,$.jsxs)(`div`,{className:e.v0,children:[e.v1,(0,$.jsx)(`div`,{className:e.v2,children:`Rendering diagram…`})]}),{name:`MermaidRenderer_2`,portals:[`v1`]}),ta=Sr(e=>e.v0,{name:`MermaidRenderer_3`,portals:[`v0`]}),na=function(e){let t=(0,X.c)(47),{content:n,className:r}=e,[i,a]=(0,Y.useState)(!1),[o,s]=(0,Y.useState)(!1),{svgOutput:c,renderError:l}=ia(n,ra()),u;t[0]===n?u=t[1]:(u=async function(){await navigator.clipboard.writeText(n),a(!0),setTimeout(()=>a(!1),2e3)},t[0]=n,t[1]=u);let d=u,f;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=q(J.compact,`font-mono text-muted-foreground`),t[2]=f):f=t[2];let p=l?`mermaid (render error)`:`mermaid diagram`,m;t[3]!==l||t[4]!==c?(m=c&&!l&&(0,$.jsxs)(W,{children:[(0,$.jsx)(G,{asChild:!0,children:(0,$.jsxs)(U,{variant:`action`,size:`icon-xs`,onClick:()=>s(!0),children:[(0,$.jsx)(Ce,{}),(0,$.jsx)(`span`,{className:`sr-only`,children:`View fullscreen`})]})}),(0,$.jsx)(K,{children:`View fullscreen`})]}),t[3]=l,t[4]=c,t[5]=m):m=t[5];let h;t[6]===i?h=t[7]:(h=i?(0,$.jsx)(cn,{}):(0,$.jsx)(rt,{}),t[6]=i,t[7]=h);let g;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(`span`,{className:`sr-only`,children:`Copy mermaid code`}),t[8]=g):g=t[8];let _;t[9]!==d||t[10]!==h?(_=(0,$.jsxs)(U,{variant:`action`,size:`icon-xs`,onClick:d,children:[h,g]}),t[9]=d,t[10]=h,t[11]=_):_=t[11];let v;t[12]!==p||t[13]!==m||t[14]!==_?(v=(0,$.jsx)(Qi,{v0:f,v1:p,v2:m,v3:_}),t[12]=p,t[13]=m,t[14]=_,t[15]=v):v=t[15];let y=v;if(l){let e;t[16]===r?e=t[17]:(e=q(`group relative overflow-hidden rounded-lg border border-border bg-muted`,r),t[16]=r,t[17]=e);let i;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(i=q(J.compact,`font-mono text-foreground leading-relaxed`),t[18]=i):i=t[18];let a;return t[19]!==n||t[20]!==y||t[21]!==e?(a=(0,$.jsx)($i,{v0:e,v1:y,v2:i,v3:n}),t[19]=n,t[20]=y,t[21]=e,t[22]=a):a=t[22],a}if(!c){let e;t[23]===r?e=t[24]:(e=q(`group relative overflow-hidden rounded-lg border border-border bg-muted`,r),t[23]=r,t[24]=e);let n;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(n=q(J.compact,`p-4 text-muted-foreground`),t[25]=n):n=t[25];let i;return t[26]!==y||t[27]!==e?(i=(0,$.jsx)(ea,{v0:e,v1:y,v2:n}),t[26]=y,t[27]=e,t[28]=i):i=t[28],i}let b;t[29]===r?b=t[30]:(b=q(`group relative overflow-hidden rounded-lg border border-border bg-muted`,r),t[29]=r,t[30]=b);let x;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(x=()=>s(!0),t[31]=x):x=t[31];let S;t[32]===c?S=t[33]:(S=(0,$.jsx)(G,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`block w-full text-left cursor-zoom-in p-4 max-w-full overflow-hidden [&_svg]:max-w-full [&_svg]:h-auto hover:bg-muted/70 transition-colors`,onClick:x,dangerouslySetInnerHTML:{__html:c}})}),t[32]=c,t[33]=S);let C;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,$.jsx)(K,{children:`Click to view fullscreen`}),t[34]=C):C=t[34];let w;t[35]===S?w=t[36]:(w=(0,$.jsxs)(W,{children:[S,C]}),t[35]=S,t[36]=w);let T;t[37]!==y||t[38]!==w||t[39]!==b?(T=(0,$.jsxs)(`div`,{className:b,children:[y,w]}),t[37]=y,t[38]=w,t[39]=b,t[40]=T):T=t[40];let E;t[41]!==o||t[42]!==c?(E=o&&(0,$.jsx)(aa,{svgOutput:c,onClose:()=>s(!1)}),t[41]=o,t[42]=c,t[43]=E):E=t[43];let D;return t[44]!==T||t[45]!==E?(D=(0,$.jsx)(ta,{v0:(0,$.jsxs)(Mt,{children:[T,E]})}),t[44]=T,t[45]=E,t[46]=D):D=t[46],D};function ra(){let e=(0,X.c)(2),[t,n]=(0,Y.useState)(!1),r,i;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{let e=function(){n(document.documentElement.classList.contains(`dark`))};e();let t=new MutationObserver(e);return t.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`]}),()=>t.disconnect()},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),(0,Y.useEffect)(r,i),t}function ia(e,t){let[n,r]=(0,Y.useState)(null),[i,a]=(0,Y.useState)(!1);return(0,Y.useEffect)(()=>{let n=!1;async function i(){try{let{renderMermaidSVG:i}=await fr(async()=>{let{renderMermaidSVG:e}=await import(`./dist-oojFghRi.js`);return{renderMermaidSVG:e}},__vite__mapDeps([0,1])),o=i(e,{bg:t?`#18181B`:`#FFFFFF`,fg:t?`#FAFAFA`:`#27272A`,transparent:!1,padding:32});n||(r(o),a(!1))}catch(e){console.error(`Mermaid render error:`,e),n||a(!0)}}return i(),()=>{n=!0}},[e,t]),{svgOutput:n,renderError:i}}function aa(e){let t=(0,X.c)(70),{svgOutput:n,onClose:r}=e,{scale:i,offset:a,isDragging:o,containerRef:s,zoomIn:c,zoomOut:l,reset:u,onMouseDown:d,onMouseMove:f,onMouseUp:p}=Xi(),m,h;t[0]===r?(m=t[1],h=t[2]):(m=()=>{let e=function(e){e.key===`Escape`&&r()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},h=[r],t[0]=r,t[1]=m,t[2]=h),(0,Y.useEffect)(m,h);let g;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(g=[],t[3]=g):g=t[3],(0,Y.useEffect)(oa,g);let _;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(`span`,{className:q(J.compact,`font-mono text-muted-foreground`),children:`mermaid diagram`}),t[4]=_):_=t[4];let v,y;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(We,{className:`h-3.5 w-3.5`}),y=(0,$.jsx)(`span`,{className:`sr-only`,children:`Zoom out`}),t[5]=v,t[6]=y):(v=t[5],y=t[6]);let b;t[7]===l?b=t[8]:(b=(0,$.jsx)(G,{asChild:!0,children:(0,$.jsxs)(U,{variant:`ghost`,size:`icon-xs`,onClick:l,children:[v,y]})}),t[7]=l,t[8]=b);let x;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(K,{children:`Zoom out`}),t[9]=x):x=t[9];let S;t[10]===b?S=t[11]:(S=(0,$.jsxs)(W,{children:[b,x]}),t[10]=b,t[11]=S);let C;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(C=q(J.compact,`min-w-[3rem] px-2 py-1 font-mono text-muted-foreground hover:text-foreground hover:bg-muted rounded transition-colors`),t[12]=C):C=t[12];let w;t[13]===i?w=t[14]:(w=Math.round(i*100),t[13]=i,t[14]=w);let T;t[15]!==u||t[16]!==w?(T=(0,$.jsx)(G,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,onClick:u,className:C,children:[w,`%`]})}),t[15]=u,t[16]=w,t[17]=T):T=t[17];let E;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,$.jsx)(K,{children:`Reset zoom`}),t[18]=E):E=t[18];let D;t[19]===T?D=t[20]:(D=(0,$.jsxs)(W,{children:[T,E]}),t[19]=T,t[20]=D);let O,k;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,$.jsx)(on,{className:`h-3.5 w-3.5`}),k=(0,$.jsx)(`span`,{className:`sr-only`,children:`Zoom in`}),t[21]=O,t[22]=k):(O=t[21],k=t[22]);let j;t[23]===c?j=t[24]:(j=(0,$.jsx)(G,{asChild:!0,children:(0,$.jsxs)(U,{variant:`ghost`,size:`icon-xs`,onClick:c,children:[O,k]})}),t[23]=c,t[24]=j);let M;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,$.jsx)(K,{children:`Zoom in`}),t[25]=M):M=t[25];let N;t[26]===j?N=t[27]:(N=(0,$.jsxs)(W,{children:[j,M]}),t[26]=j,t[27]=N);let P,F;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,$.jsx)(Qt,{className:`h-3.5 w-3.5`}),F=(0,$.jsx)(`span`,{className:`sr-only`,children:`Reset view`}),t[28]=P,t[29]=F):(P=t[28],F=t[29]);let I;t[30]===u?I=t[31]:(I=(0,$.jsx)(G,{asChild:!0,children:(0,$.jsxs)(U,{variant:`ghost`,size:`icon-xs`,onClick:u,children:[P,F]})}),t[30]=u,t[31]=I);let L;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,$.jsx)(K,{children:`Reset view`}),t[32]=L):L=t[32];let R;t[33]===I?R=t[34]:(R=(0,$.jsxs)(W,{children:[I,L]}),t[33]=I,t[34]=R);let ee;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(ee=(0,$.jsx)(`div`,{className:`w-px h-4 bg-border mx-1`}),t[35]=ee):ee=t[35];let z,te;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,$.jsx)(A,{className:`h-3.5 w-3.5`}),te=(0,$.jsx)(`span`,{className:`sr-only`,children:`Close`}),t[36]=z,t[37]=te):(z=t[36],te=t[37]);let ne;t[38]===r?ne=t[39]:(ne=(0,$.jsx)(G,{asChild:!0,children:(0,$.jsxs)(U,{variant:`ghost`,size:`icon-xs`,onClick:r,children:[z,te]})}),t[38]=r,t[39]=ne);let re;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(re=(0,$.jsx)(K,{children:`Close (Esc)`}),t[40]=re):re=t[40];let B;t[41]===ne?B=t[42]:(B=(0,$.jsxs)(W,{children:[ne,re]}),t[41]=ne,t[42]=B);let ie;t[43]!==D||t[44]!==N||t[45]!==R||t[46]!==B||t[47]!==S?(ie=(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 bg-background/90 border-b border-border shrink-0`,children:[_,(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[S,D,N,R,ee,B]})]}),t[43]=D,t[44]=N,t[45]=R,t[46]=B,t[47]=S,t[48]=ie):ie=t[48];let V=o?`cursor-grabbing`:`cursor-grab`,ae;t[49]===V?ae=t[50]:(ae=q(`flex-1 overflow-hidden select-none`,V),t[49]=V,t[50]=ae);let H=`translate(${a.x}px, ${a.y}px) scale(${i})`,oe=o?`none`:`transform 0.1s ease-out`,se;t[51]!==H||t[52]!==oe?(se={transform:H,transformOrigin:`center center`,transition:oe},t[51]=H,t[52]=oe,t[53]=se):se=t[53];let ce;t[54]===n?ce=t[55]:(ce={__html:n},t[54]=n,t[55]=ce);let le;t[56]!==se||t[57]!==ce?(le=(0,$.jsx)(`div`,{className:`w-full h-full flex items-center justify-center`,style:se,dangerouslySetInnerHTML:ce}),t[56]=se,t[57]=ce,t[58]=le):le=t[58];let ue;t[59]!==s||t[60]!==d||t[61]!==f||t[62]!==p||t[63]!==ae||t[64]!==le?(ue=(0,$.jsx)(`div`,{ref:s,className:ae,onMouseDown:d,onMouseMove:f,onMouseUp:p,onMouseLeave:p,children:le}),t[59]=s,t[60]=d,t[61]=f,t[62]=p,t[63]=ae,t[64]=le,t[65]=ue):ue=t[65];let de;t[66]===Symbol.for(`react.memo_cache_sentinel`)?(de=(0,$.jsx)(`div`,{className:q(J.compact,`shrink-0 px-4 py-2 text-center text-muted-foreground/60 bg-background/60 border-t border-border`),children:`Scroll to zoom · Drag to pan · Esc to close`}),t[66]=de):de=t[66];let fe;return t[67]!==ie||t[68]!==ue?(fe=(0,Gi.createPortal)((0,$.jsx)(Mt,{children:(0,$.jsxs)(`div`,{className:`fixed inset-0 z-50 flex flex-col bg-black/85 backdrop-blur-sm`,role:`dialog`,"aria-modal":`true`,"aria-label":`Diagram fullscreen view`,children:[ie,ue,de]})}),document.body),t[67]=ie,t[68]=ue,t[69]=fe):fe=t[69],fe}function oa(){return document.body.style.overflow=`hidden`,sa}function sa(){document.body.style.overflow=``}var ca=`graph.flowchart.sequenceDiagram.classDiagram.stateDiagram.erDiagram.journey.gantt.pie.quadrantChart.requirementDiagram.gitgraph.mindmap.timeline.zenuml.sankey.block.architecture.c4.packet.circuit.flowchart LR.flowchart TD.flowchart BT.flowchart RL.graph LR.graph TD.graph BT.graph RL`.split(`.`),la=[/-->/,/--\./,/-\./,/==>/,/--\|/,/\w+\[\w+\]/,/\w+\(\w+\)/,/\w+\{\w+\}/,/\w+>\w+\]/,/\w+\(\w+\)/,/\w+\[\(\w+\)\]/,/participant\s+\w+/,/actor\s+\w+/,/Note over \w+/,/loop\s+/,/alt\s+/,/opt\s+/,/class\s+\w+/,/interface\s+\w+/,/enum\s+\w+/,/\[\*\]/,/\[\*\]/,/title\s+/,/direction\s+/,/subgraph\s+/];function ua(e){if(!e||typeof e!=`string`)return!1;let t=e.split(`
|
|
6
|
+
`).map(e=>e.trim()).filter(e=>e.length>0);if(t.length===0)return!1;if(/```mermaid\s*\n([\s\S]*?)\n```/.test(e))return!0;let n=t[0].toLowerCase();if(ca.some(e=>n===e.toLowerCase()||n.startsWith(e.toLowerCase()+` `)))return!0;let r=0;for(let t of la)t.test(e)&&r++;return r>=2}function da(e){if(!ua(e))return null;let t=/```mermaid\s*\n([\s\S]*?)\n```/.exec(e);if(t)return t[1].trim();let n=e.split(`
|
|
7
|
+
`).map(e=>e.trim()).filter(e=>e.length>0)[0].toLowerCase();return ca.some(e=>n===e.toLowerCase()||n.startsWith(e.toLowerCase()+` `))?e.trim():null}var fa=Sr(e=>(0,$.jsxs)(`div`,{className:`group relative overflow-hidden rounded-lg border border-border bg-muted`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border bg-muted/80 px-4 py-2`,children:[(0,$.jsx)(`span`,{className:e.v0,children:e.v1}),e.v2]}),(0,$.jsx)(`pre`,{className:`overflow-x-auto p-4 max-w-full`,children:(0,$.jsx)(`code`,{className:e.v3,children:e.v4})})]}),{name:`CodeBlock_1`,portals:[`v1`,`v2`,`v4`]}),pa=function(e){let t=(0,X.c)(14),{language:n,code:r}=e,[i,a]=(0,Y.useState)(!1),o;t[0]===r?o=t[1]:(o=async()=>{await navigator.clipboard.writeText(r),a(!0),setTimeout(()=>a(!1),2e3)},t[0]=r,t[1]=o);let s=o,c;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=q(J.compact,`text-muted-foreground font-mono`),t[2]=c):c=t[2];let l=n||`text`,u;t[3]===i?u=t[4]:(u=i?(0,$.jsx)(cn,{}):(0,$.jsx)(rt,{}),t[3]=i,t[4]=u);let d;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(`span`,{className:`sr-only`,children:`Copy code`}),t[5]=d):d=t[5];let f;t[6]!==s||t[7]!==u?(f=(0,$.jsxs)(U,{variant:`action`,size:`icon-xs`,onClick:s,children:[u,d]}),t[6]=s,t[7]=u,t[8]=f):f=t[8];let p;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(p=q(J.mono,`text-foreground leading-relaxed`),t[9]=p):p=t[9];let m;return t[10]!==r||t[11]!==l||t[12]!==f?(m=(0,$.jsx)(fa,{v0:c,v1:l,v2:f,v3:p,v4:r}),t[10]=r,t[11]=l,t[12]=f,t[13]=m):m=t[13],m},ma=(0,Y.memo)(function({content:e,className:t,enableMermaid:n=!1}){let r=(0,Y.useMemo)(()=>!e||typeof e!=`string`?[]:ha(e,n),[e,n]),i=(0,Y.useMemo)(()=>{let e=0;return r.map(t=>{if(t.type===`list`&&t.ordered){let n=e+1;return e+=t.items.length,n}else if(t.type===`list`&&!t.ordered)return 1;else return e=0,1})},[r]);return r.length===0?null:(0,$.jsx)(`div`,{className:q(`prose-custom space-y-3 min-w-0 break-words`,t),children:r.map((e,t)=>(0,$.jsx)(Ta,{block:e,start:i[t]},t))})});function ha(e,t=!1){let n=e.split(`
|
|
8
|
+
`),r=[],i=0;for(;i<n.length;){let e=n[i];if(e.trimStart().startsWith("```")){let a=e.trimStart().slice(3).trim(),o=[];for(i++;i<n.length&&!n[i].trimStart().startsWith("```");)o.push(n[i]),i++;t&&(a===`mermaid`||ua(o.join(`
|
|
9
|
+
`)))?r.push({type:`mermaid`,code:o.join(`
|
|
10
|
+
`)}):r.push({type:`code`,language:a,code:o.join(`
|
|
11
|
+
`)}),i++;continue}let a=e.match(/^(#{1,6})(\s.*)?$/);if(a){r.push({type:`heading`,level:a[1].length,text:a[2]?a[2].trim():``}),i++;continue}if(/^(---|\*\*\*|___)/.test(e.trim())){r.push({type:`hr`}),i++;continue}if(e.includes(`|`)&&i+1<n.length&&n[i+1].match(/^\|?\s*[-:]+/)){let t=e.split(`|`).map(e=>e.trim()).filter(Boolean);i+=2;let a=[];for(;i<n.length&&n[i].includes(`|`);)a.push(n[i].split(`|`).map(e=>e.trim()).filter(Boolean)),i++;r.push({type:`table`,headers:t,rows:a});continue}if(e.startsWith(`> `)){let e=[];for(;i<n.length&&n[i].startsWith(`> `);)e.push(n[i].slice(2)),i++;r.push({type:`blockquote`,text:e.join(`
|
|
12
|
+
`)});continue}if(/^\s*[-*+]\s/.test(e)){let e=[];for(;i<n.length&&/^\s*[-*+]\s/.test(n[i]);)e.push(n[i].replace(/^\s*[-*+]\s/,``)),i++;r.push({type:`list`,ordered:!1,items:e});continue}if(/^\s*\d+\.\s/.test(e)){let e=[];for(;i<n.length&&/^\s*\d+\.\s/.test(n[i]);)e.push(n[i].replace(/^\s*\d+\.\s/,``)),i++;r.push({type:`list`,ordered:!0,items:e});continue}if(e.trim()===``){i++;continue}let o=[];for(;i<n.length&&n[i].trim()!==``&&!n[i].startsWith(`#`)&&!n[i].startsWith("```")&&!n[i].startsWith(`> `)&&!/^\s*[-*+]\s/.test(n[i])&&!/^\s*\d+\.\s/.test(n[i]);)o.push(n[i]),i++;if(o.length>0){let e=o.join(`
|
|
13
|
+
`);if(t&&ua(e)){let t=da(e);t?r.push({type:`mermaid`,code:t}):r.push({type:`paragraph`,text:e})}else r.push({type:`paragraph`,text:e})}}return r}var ga=Sr(e=>e.v0,{name:`MarkdownBlock_2`,portals:[`v0`]}),_a=Sr(e=>e.v0,{name:`MarkdownBlock_3`,portals:[`v0`]}),va=Sr(e=>(0,$.jsx)(`blockquote`,{className:`border-l-2 border-border pl-4 text-muted-foreground italic`,children:e.v0}),{name:`MarkdownBlock_4`,portals:[`v0`]}),ya=Sr(e=>(0,$.jsx)(`ol`,{className:e.v0,children:e.v1}),{name:`MarkdownBlock_5`,portals:[`v1`]}),ba=Sr(e=>(0,$.jsx)(`ul`,{className:e.v0,children:e.v1}),{name:`MarkdownBlock_6`,portals:[`v1`]}),xa=Sr(e=>(0,$.jsx)(`p`,{className:e.v0,children:e.v1}),{name:`MarkdownBlock_7`,portals:[`v1`]}),Sa=Sr(()=>(0,$.jsx)(`hr`,{className:`border-border`}),{name:`MarkdownBlock_8`}),Ca=Sr(e=>(0,$.jsx)(`div`,{className:`overflow-x-auto rounded-md border border-border max-w-full`,children:(0,$.jsxs)(`table`,{className:e.v0,children:[(0,$.jsx)(`thead`,{children:(0,$.jsx)(`tr`,{className:`border-b border-border bg-muted/50`,children:e.v1})}),(0,$.jsx)(`tbody`,{children:e.v2})]})}),{name:`MarkdownBlock_9`,portals:[`v1`,`v2`]}),wa=Sr(e=>e.v0,{name:`MarkdownBlock_10`,portals:[`v0`]}),Ta=(0,Y.memo)(function(e){let t=(0,X.c)(46),{block:n,start:r}=e,i=r===void 0?1:r;switch(n.type){case`heading`:{let e=`h${n.level}`,r,i,a;if(t[0]!==e||t[1]!==n.level){let o={1:J.sectionTitle,2:q(J.body,`font-semibold`),3:q(J.body,`font-semibold`),4:J.sectionSubtitle,5:J.sectionSubtitle,6:J.sectionSubtitle};i=ga,r=e,a=q(o[n.level]),t[0]=e,t[1]=n.level,t[2]=r,t[3]=i,t[4]=a}else r=t[2],i=t[3],a=t[4];let o;t[5]===n.text?o=t[6]:(o=(0,$.jsx)(Ea,{text:n.text}),t[5]=n.text,t[6]=o);let s;t[7]!==r||t[8]!==a||t[9]!==o?(s=(0,$.jsx)(r,{className:a,children:o}),t[7]=r,t[8]=a,t[9]=o,t[10]=s):s=t[10];let c;return t[11]!==i||t[12]!==s?(c=(0,$.jsx)(i,{v0:s}),t[11]=i,t[12]=s,t[13]=c):c=t[13],c}case`code`:{let e;return t[14]!==n.code||t[15]!==n.language?(e=(0,$.jsx)(_a,{v0:(0,$.jsx)(pa,{language:n.language,code:n.code})}),t[14]=n.code,t[15]=n.language,t[16]=e):e=t[16],e}case`blockquote`:{let e;return t[17]===n.text?e=t[18]:(e=(0,$.jsx)(va,{v0:(0,$.jsx)(Ea,{text:n.text})}),t[17]=n.text,t[18]=e),e}case`list`:{if(n.ordered){let e;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(e=q(J.body,`space-y-1`),t[19]=e):e=t[19];let r;if(t[20]!==n.items||t[21]!==i){let e;t[23]===i?e=t[24]:(e=(e,t)=>(0,$.jsxs)(`li`,{className:`flex gap-1.5`,children:[(0,$.jsxs)(`span`,{className:`shrink-0 select-none tabular-nums`,children:[i+t,`.`]}),(0,$.jsx)(`span`,{children:(0,$.jsx)(Ea,{text:e})})]},t),t[23]=i,t[24]=e),r=n.items.map(e),t[20]=n.items,t[21]=i,t[22]=r}else r=t[22];let a;return t[25]===r?a=t[26]:(a=(0,$.jsx)(ya,{v0:e,v1:r}),t[25]=r,t[26]=a),a}let e;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(e=q(J.body,`space-y-1 pl-5 list-outside overflow-visible list-disc`),t[27]=e):e=t[27];let r;t[28]===n.items?r=t[29]:(r=n.items.map(Oa),t[28]=n.items,t[29]=r);let a;return t[30]===r?a=t[31]:(a=(0,$.jsx)(ba,{v0:e,v1:r}),t[30]=r,t[31]=a),a}case`paragraph`:{let e;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(e=q(J.body,`leading-relaxed whitespace-pre-wrap break-words`),t[32]=e):e=t[32];let r;return t[33]===n.text?r=t[34]:(r=(0,$.jsx)(xa,{v0:e,v1:(0,$.jsx)(Ea,{text:n.text})}),t[33]=n.text,t[34]=r),r}case`hr`:{let e;return t[35]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Sa,{}),t[35]=e):e=t[35],e}case`table`:{let e;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(e=q(J.body,`w-full`),t[36]=e):e=t[36];let r;t[37]===n.headers?r=t[38]:(r=n.headers.map(ka),t[37]=n.headers,t[38]=r);let i;t[39]===n.rows?i=t[40]:(i=n.rows.map(ja),t[39]=n.rows,t[40]=i);let a;return t[41]!==r||t[42]!==i?(a=(0,$.jsx)(Ca,{v0:e,v1:r,v2:i}),t[41]=r,t[42]=i,t[43]=a):a=t[43],a}case`mermaid`:{let e;return t[44]===n.code?e=t[45]:(e=(0,$.jsx)(wa,{v0:(0,$.jsx)(na,{content:n.code})}),t[44]=n.code,t[45]=e),e}default:return null}}),Ea=(0,Y.memo)(function(e){let t=(0,X.c)(6),{text:n}=e,r;t[0]===n?r=t[1]:(r=Da(n),t[0]=n,t[1]=r);let i=r,a;t[2]===i?a=t[3]:(a=i.map(Ma),t[2]=i,t[3]=a);let o;return t[4]===a?o=t[5]:(o=(0,$.jsx)($.Fragment,{children:a}),t[4]=a,t[5]=o),o});function Da(e){let t=[],n=/(`[^`]+`)|(\*\*[^*]+\*\*)|(\*[^*]+\*)|(__[^_]+__)|(_[^_]+_)|(~~[^~]+~~)|(\[[^\]]+\]\([^)]+\))/g,r=0,i;for(;(i=n.exec(e))!==null;){i.index>r&&t.push({type:`text`,text:e.slice(r,i.index)});let n=i[0];if(n.startsWith("`"))t.push({type:`code`,text:n.slice(1,-1)});else if(n.startsWith(`**`))t.push({type:`bold`,text:n.slice(2,-2)});else if(n.startsWith(`__`))t.push({type:`bold`,text:n.slice(2,-2)});else if(n.startsWith(`~~`))t.push({type:`strikethrough`,text:n.slice(2,-2)});else if(n.startsWith(`*`)||n.startsWith(`_`))t.push({type:`italic`,text:n.slice(1,-1)});else if(n.startsWith(`[`)){let e=n.match(/\[([^\]]+)\]\(([^)]+)\)/);e&&t.push({type:`link`,text:e[1],href:e[2]})}r=i.index+n.length}return r<e.length&&t.push({type:`text`,text:e.slice(r)}),t.length>0?t:[{type:`text`,text:e}]}function Oa(e,t){return(0,$.jsx)(`li`,{children:(0,$.jsx)(Ea,{text:e})},t)}function ka(e,t){return(0,$.jsx)(`th`,{className:`px-3 py-2 text-left font-medium`,children:(0,$.jsx)(Ea,{text:e})},t)}function Aa(e,t){return(0,$.jsx)(`td`,{className:`px-3 py-2`,children:(0,$.jsx)(Ea,{text:e})},t)}function ja(e,t){return(0,$.jsx)(`tr`,{className:`border-b border-border last:border-0`,children:e.map(Aa)},t)}function Ma(e,t){switch(e.type){case`bold`:return(0,$.jsx)(`strong`,{className:`font-semibold`,children:e.text},t);case`italic`:return(0,$.jsx)(`em`,{children:e.text},t);case`strikethrough`:return(0,$.jsx)(`del`,{className:`text-muted-foreground`,children:e.text},t);case`code`:return(0,$.jsx)(`code`,{className:q(J.mono,`rounded bg-muted/20 px-1.5 py-0.5`),children:e.text},t);case`link`:return(0,$.jsx)(`a`,{href:e.href,className:`text-primary underline underline-offset-2 hover:text-primary/80`,target:`_blank`,rel:`noopener noreferrer`,children:e.text},t);default:return(0,$.jsx)(`span`,{children:e.text},t)}}var Na=(0,Y.createContext)({activeMainTab:`chat`,setActiveMainTab:()=>{},devServerUrl:null,setDevServerUrl:()=>{},devServerRunning:!1,setDevServerRunning:()=>{},devServerLoading:!1,setDevServerLoading:()=>{},terminalNotification:!1,setTerminalNotification:()=>{},pendingExplorerPath:null,setPendingExplorerPath:()=>{},explorerRefreshTick:0,triggerExplorerRefresh:()=>{},explorerClearPath:null,setExplorerClearPath:()=>{},browserResetTrigger:0,triggerBrowserReset:()=>{}});function Pa(){return(0,Y.useContext)(Na)}var Fa=new RegExp(String.raw`\x1B\[[0-?]*[ -/]*[@-~]`,`g`),Ia=new RegExp(String.raw`\x1B\].*?(?:\x07|\x1B\\)`,`g`),La=new RegExp(String.raw`\x1B[@-_]`,`g`),Ra=/\r(?!\n)/g,za=/\\n/g;function Ba(e){return e.replace(Ia,``).replace(Fa,``).replace(La,``)}function Va(e){return Ba(e).replace(za,`
|
|
14
|
+
`).replace(Ra,`
|
|
15
|
+
`)}function Ha(e){return xn(e)}function Ua(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 Wa(e){return typeof e==`string`?e:typeof e==`object`&&e?JSON.stringify(e,null,2):String(e)}function Ga(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 Ka(e){if(typeof e!=`object`||!e)return e;if(Array.isArray(e))return e.map(Ka);let t={};for(let[n,r]of Object.entries(e))if(typeof r==`string`){let e=Ga(r);t[n]=typeof e==`object`?Ka(e):r}else t[n]=Ka(r);return t}function qa(e){if(e==null||typeof e!=`string`)return``;let t=e;return t=t.replace(/\\\\n/g,`
|
|
16
|
+
`),t=t.replace(/\\\\"/g,`"`),t=t.replace(/\\n/g,`
|
|
17
|
+
`),t=t.replace(/\\"/g,`"`),t}function Ja(e){if(e==null)return``;let t=typeof e==`object`&&e?Ka(e):e;return Va(qa(typeof t==`string`?t:t==null?``:JSON.stringify(t,null,2)))}function Ya(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:Ua(Wa(i),t),d=Ua(o?String(i.prompt):null,t),f=Ua(a&&typeof a.command==`string`?a.command:null,t),p=n===`fetch`&&a&&typeof a.url==`string`?a.url:null,m=a&&typeof a.pattern==`string`?a.pattern:null,h=a&&typeof a.lang==`string`?a.lang:null,g=n===`code_search`,_=g&&a&&typeof a.query==`string`?a.query:null,v=g&&a&&typeof a.filePath==`string`?a.filePath:null,y=g&&a&&typeof a.fileGlob==`string`?a.fileGlob:null,b=Ua(a&&typeof a.path==`string`?a.path:null,t),x=a&&typeof a.offset==`number`?a.offset:null,S=a&&typeof a.limit==`number`?a.limit:null,C=n.toLowerCase(),w=C.includes(`read`)||C.includes(`write`)||C.includes(`edit`),T=C.includes(`edit`),E=w&&a&&typeof a.path==`string`?a.path:null,D=E?E.split(`/`).pop()??E:null,O=T&&a&&typeof a.oldText==`string`?a.oldText:null,k=T&&a&&typeof a.newText==`string`?a.newText:null,A=O===null?null:O.split(`
|
|
18
|
+
`).length,j=k===null?null:k.split(`
|
|
19
|
+
`).length,M=O!==null&&k!==null,N=n===`generate_image`&&a&&typeof a.prompt==`string`?a.prompt:null,P=n===`todo`&&a?a.status:void 0,F=e.displayName??xn(n),I=e.activeDisplayName??Ge(n),L=`default`;return C===`bash`||C.includes(`terminal`)||C.includes(`shell`)?L=`bash`:C===`fetch`?L=`fetch`:w?L=`file`:g||C===`find`||C.includes(`search`)||C.includes(`grep`)?L=`search`:C===`agent`||C.includes(`subagent`)||o?L=`agent`:C===`todo`?L=`todo`:C===`generate_image`&&(L=`imageGen`),{toolType:L,toolName:n,toolId:r,displayName:F,activeDisplayName:I,inputObj:a,toolInput:u,command:f,fetchUrl:p,pattern:m,codeSearchQuery:_,codeSearchFilePath:v,codeSearchFileGlob:y,isFileTool:w,isEditTool:T,filePath:E,fileDisplayName:D,editOldText:O,editNewText:k,editDeletedLineCount:A,editAddedLineCount:j,hasEditDiff:M,path:b,offset:x,limit:S,prompt:d,agentName:l,subagentType:c,lang:h,imageGenPrompt:N,todoStatus:P}}var Xa=new Map;function Za(e){return e.trim()}function Qa(){let e=Ft(Kt.BASH_COMMAND_DURATIONS);if(!e)return{};try{let t=JSON.parse(e);if(typeof t!=`object`||!t||Array.isArray(t))return{};let n={};for(let[e,r]of Object.entries(t))typeof r==`number`&&Number.isFinite(r)&&r>0&&(n[Za(e)]=r);return n}catch{return{}}}function $a(e){ln(Kt.BASH_COMMAND_DURATIONS,JSON.stringify(e))}function eo(e){return Qa()[Za(e)]??null}function to(e,t){let n=Za(e);if(!n||!Number.isFinite(t)||t<=0)return;let r=Qa();r[n]=Math.round(t),$a(r)}function no(e,t){!t?.trim()||Xa.has(e)||Xa.set(e,{command:Za(t),startedAt:Date.now()})}function ro(e){let t=Xa.get(e);if(!t)return;let n=Date.now()-t.startedAt;to(t.command,n),Xa.delete(e)}function io(e){let t=Math.max(0,Math.floor(e/1e3)),n=Math.floor(t/60),r=t%60;return`${n}:${String(r).padStart(2,`0`)}`}function ao(e,t){return t!==null&&t>0?`${Math.min(99,Math.round(e/t*100))}% complete`:io(e)}var oo=1e3;function so(e,t,n){let[r,i]=(0,Y.useState)(0),[a,o]=(0,Y.useState)(null),s=(0,Y.useRef)(null),c=(0,Y.useRef)(!1),l=(0,Y.useRef)(n);return l.current=n,(0,Y.useEffect)(()=>{if(n&&!c.current){let n=e?.trim()??``;o(n?eo(n):null),no(t,e),s.current=Date.now(),i(0)}else !n&&c.current&&(ro(t),s.current=null,i(0),o(null));c.current=n},[n,e,t]),(0,Y.useEffect)(()=>()=>{l.current&&ro(t)},[t]),(0,Y.useEffect)(()=>{if(!n)return;let e=()=>{s.current===null&&(s.current=Date.now()),i(Date.now()-s.current)};e();let t=setInterval(e,oo);return()=>clearInterval(t)},[n]),n?ao(r,a):null}function co(e){let{maxHeight:t=`48`,padding:n=`2`,leading:r=!1,className:i}=e??{};return q(J.mono,n===`3`?`p-3`:`p-2`,`bg-muted rounded whitespace-pre-wrap overflow-auto text-foreground`,t===`64`?`max-h-64`:`max-h-48`,r&&`leading-relaxed`,i)}function lo(e){let t=(0,X.c)(12),{open:n,onOpenChange:r,title:i,content:a}=e,o;t[0]===i?o=t[1]:(o=(0,$.jsx)(bt,{children:(0,$.jsx)(z,{children:(0,$.jsx)(`code`,{className:J.mono,children:i})})}),t[0]=i,t[1]=o);let s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=co({padding:`3`,className:`flex-1 max-h-none`}),t[2]=s):s=t[2];let c;t[3]===a?c=t[4]:(c=(0,$.jsx)(`pre`,{className:s,children:a}),t[3]=a,t[4]=c);let l;t[5]!==o||t[6]!==c?(l=(0,$.jsxs)(H,{className:`max-w-3xl h-[80vh] flex flex-col`,children:[o,c]}),t[5]=o,t[6]=c,t[7]=l):l=t[7];let u;return t[8]!==r||t[9]!==n||t[10]!==l?(u=(0,$.jsx)(h,{open:n,onOpenChange:r,children:l}),t[8]=r,t[9]=n,t[10]=l,t[11]=u):u=t[11],u}function uo(e){let t=(0,X.c)(10),{oldText:n,newText:r}=e,i,a,o;if(t[0]!==r||t[1]!==n){let e=n.split(`
|
|
20
|
+
`),s=r.split(`
|
|
21
|
+
`);t[5]===Symbol.for(`react.memo_cache_sentinel`)?(i=q(J.caption,`font-mono whitespace-pre-wrap overflow-auto`),t[5]=i):i=t[5],a=e.map(po),o=s.map(fo),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[6]!==i||t[7]!==a||t[8]!==o?(s=(0,$.jsxs)(`pre`,{className:i,children:[a,o]}),t[6]=i,t[7]=a,t[8]=o,t[9]=s):s=t[9],s}function fo(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 po(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 mo(e){let t=(0,X.c)(3),{name:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=q(J.caption,`px-1.5 py-0.5 rounded bg-muted font-mono`),t[0]=r):r=t[0];let i;return t[1]===n?i=t[2]:(i=(0,$.jsx)(`span`,{className:r,children:n}),t[1]=n,t[2]=i),i}function ho(e){let t=(0,X.c)(3),{type:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=q(J.caption,`px-2 py-0.5 rounded bg-muted`),t[0]=r):r=t[0];let i;return t[1]===n?i=t[2]:(i=(0,$.jsx)(`span`,{className:r,children:n}),t[1]=n,t[2]=i),i}function go(e){let t=(0,X.c)(3),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=q(J.caption,`font-mono break-all rounded bg-muted/60 px-1 py-0.5`),t[0]=r):r=t[0];let i;return t[1]===n?i=t[2]:(i=(0,$.jsx)(`code`,{className:r,children:n}),t[1]=n,t[2]=i),i}function _o(e){let t=(0,X.c)(5),{className:n,size:r}=e,i=(r===void 0?`sm`:r)===`sm`?`h-7 w-7`:`h-8 w-8`,a;t[0]!==n||t[1]!==i?(a=q(`shrink-0`,i,n),t[0]=n,t[1]=i,t[2]=a):a=t[2];let o;return t[3]===a?o=t[4]:(o=(0,$.jsx)(`img`,{src:`/busy.svg`,alt:``,className:a,"aria-hidden":!0}),t[3]=a,t[4]=o),o}function vo(e){let t=(0,X.c)(15),{toolName:n,displayName:r,muted:i,size:a,className:o}=e,s=i===void 0?!0:i,c;t[0]===o?c=t[1]:(c=q(`inline-flex items-center gap-1`,o),t[0]=o,t[1]=c);let l=!s&&`text-foreground`,u;t[2]===l?u=t[3]:(u=q(J.caption,l),t[2]=l,t[3]=u);let d;t[4]!==r||t[5]!==u?(d=(0,$.jsx)(`span`,{className:u,children:r}),t[4]=r,t[5]=u,t[6]=d):d=t[6];let f;t[7]!==c||t[8]!==d?(f=(0,$.jsx)(G,{asChild:!0,children:(0,$.jsx)(`span`,{className:c,children:d})}),t[7]=c,t[8]=d,t[9]=f):f=t[9];let p;t[10]===n?p=t[11]:(p=(0,$.jsx)(K,{children:n}),t[10]=n,t[11]=p);let m;return t[12]!==f||t[13]!==p?(m=(0,$.jsxs)(W,{children:[f,p]}),t[12]=f,t[13]=p,t[14]=m):m=t[14],m}function yo(e){let t=(0,X.c)(102),{data:n,inline:r,resultContent:i,isActive:a}=e,o=(0,Y.useRef)(null),[s,c]=(0,Y.useState)(!!a),[l,u]=(0,Y.useState)(!1),d=(0,Y.useRef)(!!a),f;t[0]===n.toolId?f=t[1]:(f=e=>e.toolCallProgress[n.toolId]?.executionOutput,t[0]=n.toolId,t[1]=f);let p=Q(f),m=a?p??i??``:i??``,h;t[2]===m?h=t[3]:(h=m?Va(m):``,t[2]=m,t[3]=h);let g=h,_=a?g:``,v=so(n.command,n.toolId,!!a),y,b;t[4]===a?(y=t[5],b=t[6]):(y=()=>{a&&!d.current?c(!0):!a&&d.current&&c(!1),d.current=!!a},b=[a],t[4]=a,t[5]=y,t[6]=b),(0,Y.useEffect)(y,b);let x;t[7]!==a||t[8]!==s?(x=()=>{s&&a&&o.current&&(o.current.scrollTop=o.current.scrollHeight)},t[7]=a,t[8]=s,t[9]=x):x=t[9];let S;if(t[10]!==a||t[11]!==s||t[12]!==_?(S=[s,a,_],t[10]=a,t[11]=s,t[12]=_,t[13]=S):S=t[13],(0,Y.useEffect)(x,S),r){if(a){let e;t[14]===s?e=t[15]:(e=()=>c(!s),t[14]=s,t[15]=e);let r;t[16]!==n.activeDisplayName||t[17]!==n.toolName?(r=(0,$.jsx)(vo,{toolName:n.toolName,displayName:n.activeDisplayName,isActive:!1}),t[16]=n.activeDisplayName,t[17]=n.toolName,t[18]=r):r=t[18];let i;t[19]===n.command?i=t[20]:(i=n.command!==null&&(0,$.jsx)(`span`,{className:q(J.caption,`break-all`),children:n.command}),t[19]=n.command,t[20]=i);let a;t[21]===v?a=t[22]:(a=v&&(0,$.jsx)(`span`,{className:q(J.caption,`tabular-nums shrink-0`),children:v}),t[21]=v,t[22]=a);let l;t[23]===s?l=t[24]:(l=s?(0,$.jsx)(wt,{className:`h-3 w-3 text-muted-foreground shrink-0`}):(0,$.jsx)($t,{className:`h-3 w-3 text-muted-foreground shrink-0`}),t[23]=s,t[24]=l);let u;t[25]!==s||t[26]!==a||t[27]!==l||t[28]!==e||t[29]!==r||t[30]!==i?(u=(0,$.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1.5 cursor-pointer select-none text-left w-full`,onClick:e,"aria-expanded":s,children:[r,i,a,l]}),t[25]=s,t[26]=a,t[27]=l,t[28]=e,t[29]=r,t[30]=i,t[31]=u):u=t[31];let d=s?`grid-rows-[1fr]`:`grid-rows-[0fr]`,f;t[32]===d?f=t[33]:(f=q(`grid transition-[grid-template-rows] duration-200 ease-in-out`,d),t[32]=d,t[33]=f);let p,m;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(p=q(J.caption,`ml-5 text-muted-foreground/60 whitespace-pre-wrap overflow-y-auto font-mono`),m={maxHeight:`7.5em`},t[34]=p,t[35]=m):(p=t[34],m=t[35]);let h;t[36]===_?h=t[37]:(h=(0,$.jsx)(`div`,{className:`overflow-hidden`,children:(0,$.jsx)(`div`,{ref:o,className:p,style:m,children:_})}),t[36]=_,t[37]=h);let g;t[38]!==f||t[39]!==h?(g=(0,$.jsx)(`div`,{className:f,children:h}),t[38]=f,t[39]=h,t[40]=g):g=t[40];let y;return t[41]!==u||t[42]!==g?(y=(0,$.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[u,g]}),t[41]=u,t[42]=g,t[43]=y):y=t[43],y}if(n.command!==null&&g){let e;t[44]!==n.displayName||t[45]!==n.toolName?(e=(0,$.jsx)(vo,{toolName:n.toolName,displayName:n.displayName,isActive:!1}),t[44]=n.displayName,t[45]=n.toolName,t[46]=e):e=t[46];let r,i;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>u(!0),i=q(J.caption,`font-mono hover:underline break-all cursor-pointer`),t[47]=r,t[48]=i):(r=t[47],i=t[48]);let a;t[49]===n.command?a=t[50]:(a=(0,$.jsx)(G,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:r,className:i,children:n.command})}),t[49]=n.command,t[50]=a);let o;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(K,{children:`View output`}),t[51]=o):o=t[51];let s;t[52]===a?s=t[53]:(s=(0,$.jsxs)(W,{children:[a,o]}),t[52]=a,t[53]=s);let c;t[54]!==s||t[55]!==e?(c=(0,$.jsxs)(`div`,{className:`py-0.5 flex items-center gap-2 flex-wrap`,children:[e,s]}),t[54]=s,t[55]=e,t[56]=c):c=t[56];let d;t[57]!==n.command||t[58]!==l||t[59]!==g?(d=(0,$.jsx)(lo,{open:l,onOpenChange:u,title:n.command,content:g}),t[57]=n.command,t[58]=l,t[59]=g,t[60]=d):d=t[60];let f;return t[61]!==c||t[62]!==d?(f=(0,$.jsxs)($.Fragment,{children:[c,d]}),t[61]=c,t[62]=d,t[63]=f):f=t[63],f}let e;t[64]!==n.displayName||t[65]!==n.toolName?(e=(0,$.jsx)(vo,{toolName:n.toolName,displayName:n.displayName,isActive:!1}),t[64]=n.displayName,t[65]=n.toolName,t[66]=e):e=t[66];let r;t[67]===n.command?r=t[68]:(r=n.command!==null&&(0,$.jsx)(`code`,{className:q(J.caption,`font-mono break-all rounded bg-muted/60 px-1 py-0.5`),children:n.command}),t[67]=n.command,t[68]=r);let i;return t[69]!==e||t[70]!==r?(i=(0,$.jsxs)(`div`,{className:`py-0.5 flex items-center gap-2 flex-wrap`,children:[e,r]}),t[69]=e,t[70]=r,t[71]=i):i=t[71],i}let C;t[72]===s?C=t[73]:(C=()=>c(!s),t[72]=s,t[73]=C);let w;t[74]===Symbol.for(`react.memo_cache_sentinel`)?(w=q(J.body,`w-full py-2 flex items-center gap-2 font-medium text-foreground hover:bg-muted/50 transition-colors text-left`),t[74]=w):w=t[74];let T;t[75]!==n.activeDisplayName||t[76]!==n.displayName||t[77]!==a||t[78]!==v?(T=a?(0,$.jsxs)($.Fragment,{children:[n.activeDisplayName,v&&(0,$.jsx)(`span`,{className:`ml-2 text-muted-foreground tabular-nums`,children:v})]}):n.displayName,t[75]=n.activeDisplayName,t[76]=n.displayName,t[77]=a,t[78]=v,t[79]=T):T=t[79];let E;t[80]===T?E=t[81]:(E=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:T}),t[80]=T,t[81]=E);let D;t[82]===s?D=t[83]:(D=s?(0,$.jsx)(wt,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)($t,{className:`h-4 w-4 shrink-0`}),t[82]=s,t[83]=D);let O;t[84]!==E||t[85]!==D||t[86]!==C?(O=(0,$.jsx)(G,{asChild:!0,children:(0,$.jsxs)(`button`,{onClick:C,className:w,children:[E,D]})}),t[84]=E,t[85]=D,t[86]=C,t[87]=O):O=t[87];let k;t[88]===n.toolName?k=t[89]:(k=(0,$.jsx)(K,{children:n.toolName}),t[88]=n.toolName,t[89]=k);let A;t[90]!==O||t[91]!==k?(A=(0,$.jsxs)(W,{children:[O,k]}),t[90]=O,t[91]=k,t[92]=A):A=t[92];let j;t[93]!==n.toolId||t[94]!==n.toolInput||t[95]!==a||t[96]!==s||t[97]!==_?(j=s&&(0,$.jsxs)(`div`,{className:`py-2 border-t border-border`,children:[(0,$.jsxs)(`div`,{className:q(J.compact,`text-muted-foreground mb-2 font-mono`),children:[`ID: `,n.toolId]}),a?(0,$.jsx)(`div`,{ref:o,className:q(J.caption,`text-muted-foreground/60 whitespace-pre-wrap overflow-y-auto font-mono`),style:{maxHeight:`7.5em`},children:_}):n.toolInput?(0,$.jsx)(`pre`,{className:co(),children:n.toolInput}):null]}),t[93]=n.toolId,t[94]=n.toolInput,t[95]=a,t[96]=s,t[97]=_,t[98]=j):j=t[98];let M;return t[99]!==A||t[100]!==j?(M=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[A,j]}),t[99]=A,t[100]=j,t[101]=M):M=t[101],M}function bo(e){let t=(0,X.c)(50),{data:n,inline:r,resultContent:i,isActive:a}=e,[o,s]=(0,Y.useState)(!!a),[c,l]=(0,Y.useState)(!1),u=n.fetchUrl,d;t[0]===i?d=t[1]:(d=i?xo(i):null,t[0]=i,t[1]=d);let f=d;if(r){let e;t[2]===o?e=t[3]:(e=()=>s(!o),t[2]=o,t[3]=e);let r=n.toolName,c=n.activeDisplayName,l=!!a,d;t[4]!==n.activeDisplayName||t[5]!==n.toolName||t[6]!==l?(d=(0,$.jsx)(vo,{toolName:r,displayName:c,isActive:l}),t[4]=n.activeDisplayName,t[5]=n.toolName,t[6]=l,t[7]=d):d=t[7];let p;t[8]===u?p=t[9]:(p=u!==null&&(0,$.jsx)(`span`,{className:q(J.caption,`break-all`),children:u}),t[8]=u,t[9]=p);let m;t[10]===f?m=t[11]:(m=f&&(0,$.jsxs)(`span`,{className:q(J.caption,`text-muted-foreground shrink-0`),children:[f.bytes,` bytes · HTTP `,f.code]}),t[10]=f,t[11]=m);let h;t[12]===o?h=t[13]:(h=o?(0,$.jsx)(wt,{className:`h-3 w-3 text-muted-foreground shrink-0`}):(0,$.jsx)($t,{className:`h-3 w-3 text-muted-foreground shrink-0`}),t[12]=o,t[13]=h);let g;t[14]!==o||t[15]!==e||t[16]!==d||t[17]!==p||t[18]!==m||t[19]!==h?(g=(0,$.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1.5 cursor-pointer select-none text-left w-full`,onClick:e,"aria-expanded":o,children:[d,p,m,h]}),t[14]=o,t[15]=e,t[16]=d,t[17]=p,t[18]=m,t[19]=h,t[20]=g):g=t[20];let _;t[21]!==o||t[22]!==i?(_=o&&i&&(0,$.jsx)(`pre`,{className:q(J.mono,J.caption,`whitespace-pre-wrap break-all rounded bg-muted/40 p-2 max-h-48 overflow-auto`),children:So(i)}),t[21]=o,t[22]=i,t[23]=_):_=t[23];let v;return t[24]!==g||t[25]!==_?(v=(0,$.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[g,_]}),t[24]=g,t[25]=_,t[26]=v):v=t[26],v}let p=n.toolName,m=n.displayName,h=!!a,g;t[27]!==n.displayName||t[28]!==n.toolName||t[29]!==h?(g=(0,$.jsx)(vo,{toolName:p,displayName:m,isActive:h}),t[27]=n.displayName,t[28]=n.toolName,t[29]=h,t[30]=g):g=t[30];let _;t[31]===u?_=t[32]:(_=u!==null&&(0,$.jsxs)(W,{children:[(0,$.jsx)(G,{asChild:!0,children:(0,$.jsx)(`code`,{className:q(J.mono,J.caption,`break-all`),children:u})}),(0,$.jsx)(K,{children:u})]}),t[31]=u,t[32]=_);let v;t[33]===f?v=t[34]:(v=f&&(0,$.jsxs)(`span`,{className:q(J.caption,`text-muted-foreground`),children:[f.bytes,` bytes · HTTP `,f.code,` · `,f.durationMs,`ms`]}),t[33]=f,t[34]=v);let y;t[35]===i?y=t[36]:(y=i&&(0,$.jsx)(`button`,{type:`button`,className:q(J.caption,`text-brand hover:underline ml-auto`),onClick:()=>l(!0),children:`View result`}),t[35]=i,t[36]=y);let b;t[37]!==g||t[38]!==_||t[39]!==v||t[40]!==y?(b=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[g,_,v,y]}),t[37]=g,t[38]=_,t[39]=v,t[40]=y,t[41]=b):b=t[41];let x;t[42]===i?x=t[43]:(x=i?So(i):``,t[42]=i,t[43]=x);let S;t[44]!==c||t[45]!==x?(S=(0,$.jsx)(lo,{open:c,onOpenChange:l,title:`Fetch result`,content:x}),t[44]=c,t[45]=x,t[46]=S):S=t[46];let C;return t[47]!==S||t[48]!==b?(C=(0,$.jsxs)(`div`,{className:`rounded-lg border border-border p-3 my-1`,children:[b,S]}),t[47]=S,t[48]=b,t[49]=C):C=t[49],C}function xo(e){try{let t=JSON.parse(e);if(typeof t.bytes==`number`&&typeof t.code==`number`)return{bytes:t.bytes,code:t.code,durationMs:typeof t.durationMs==`number`?t.durationMs:0}}catch{}return null}function So(e){try{let t=JSON.parse(e);if(typeof t.result==`string`)return t.result}catch{}return e}var Co=cr,wo=rr,To=Y.forwardRef((e,t)=>{let n=(0,X.c)(13),r,i,a,o;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4]):({className:r,align:a,sideOffset:o,...i}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let s=a===void 0?`center`:a,c=o===void 0?4:o,l;n[5]===r?l=n[6]:(l=q(`z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,r),n[5]=r,n[6]=l);let u;return n[7]!==s||n[8]!==i||n[9]!==t||n[10]!==c||n[11]!==l?(u=(0,$.jsx)($n,{children:(0,$.jsx)(En,{ref:t,align:s,sideOffset:c,className:l,...i})}),n[7]=s,n[8]=i,n[9]=t,n[10]=c,n[11]=l,n[12]=u):u=n[12],u});To.displayName=En.displayName;function Eo(e){let t=(0,X.c)(6),{type:n,count:r}=e,i=n===`added`?`text-green-600 dark:text-green-400`:`text-red-600 dark:text-red-400`,a;t[0]===i?a=t[1]:(a=q(J.compact,`font-mono tabular-nums`,i),t[0]=i,t[1]=a);let o=n===`added`?`+`:`-`,s;return t[2]!==r||t[3]!==a||t[4]!==o?(s=(0,$.jsxs)(`span`,{className:a,children:[o,r]}),t[2]=r,t[3]=a,t[4]=o,t[5]=s):s=t[5],s}function Do(e){let t=(0,X.c)(3),{offset:n,limit:r}=e;if(n===null&&r===null)return null;let i;i=n!==null&&r!==null?`${n}-${n+r}`:n===null?`${r}`:`${n}-`;let a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=q(J.compact,`font-mono tabular-nums text-muted-foreground`),t[0]=a):a=t[0];let o;return t[1]===i?o=t[2]:(o=(0,$.jsx)(`span`,{className:a,children:i}),t[1]=i,t[2]=o),o}function Oo(e){let t=(0,X.c)(51),{data:n,inline:r,rootPath:i,onOpenFile:a}=e,[o,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(!1),u;t[0]!==n.filePath||t[1]!==a||t[2]!==i?(u=function(){!n.filePath||!a||a(i&&n.filePath.startsWith(i)?n.filePath.slice(i.length+1):n.filePath)},t[0]=n.filePath,t[1]=a,t[2]=i,t[3]=u):u=t[3];let d=u;if(r){let e=!!(n.toolInput&&!n.command&&!n.path&&!n.pattern&&!n.fileDisplayName),r;t[4]!==n.displayName||t[5]!==n.toolId||t[6]!==n.toolInput||t[7]!==n.toolName||t[8]!==e?(r=e?(0,$.jsxs)(Co,{children:[(0,$.jsx)(wo,{asChild:!0,children:(0,$.jsx)(`span`,{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)(vo,{toolName:n.toolName,displayName:n.displayName,isActive:!1,muted:!1})})})}),(0,$.jsx)(To,{className:`w-80 max-h-80 overflow-auto`,align:`start`,children:(0,$.jsxs)(`div`,{className:q(J.caption,`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)(vo,{toolName:n.toolName,displayName:n.displayName,isActive:!1}),t[4]=n.displayName,t[5]=n.toolId,t[6]=n.toolInput,t[7]=n.toolName,t[8]=e,t[9]=r):r=t[9];let a;t[10]!==n.editAddedLineCount||t[11]!==n.editDeletedLineCount||t[12]!==n.editNewText||t[13]!==n.editOldText||t[14]!==n.fileDisplayName||t[15]!==n.filePath||t[16]!==n.hasEditDiff||t[17]!==n.limit||t[18]!==n.offset||t[19]!==n.path||t[20]!==n.toolName||t[21]!==c||t[22]!==d||t[23]!==i?(a=n.fileDisplayName?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(W,{children:[(0,$.jsx)(G,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,onClick:n.hasEditDiff?()=>l(!0):d,className:q(`inline-flex max-w-full items-center gap-2 cursor-pointer`,J.caption,`font-mono hover:underline`),children:[(0,$.jsx)(`span`,{className:`truncate max-w-[200px] sm:max-w-[320px]`,children:n.fileDisplayName}),n.toolName===`read`?(0,$.jsx)(Do,{offset:n.offset,limit:n.limit}):null,n.hasEditDiff?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 shrink-0`,children:[n.editAddedLineCount===null?null:(0,$.jsx)(Eo,{type:`added`,count:n.editAddedLineCount}),n.editDeletedLineCount===null?null:(0,$.jsx)(Eo,{type:`deleted`,count:n.editDeletedLineCount})]}):null]})}),(0,$.jsx)(K,{children:n.hasEditDiff?`View diff`:n.filePath?Ua(n.filePath,i)??n.filePath:n.fileDisplayName})]}),n.hasEditDiff&&(0,$.jsx)(h,{open:c,onOpenChange:l,children:(0,$.jsxs)(H,{className:`max-w-2xl h-[80vh] flex flex-col`,children:[(0,$.jsx)(bt,{children:(0,$.jsx)(z,{children:(0,$.jsx)(`code`,{className:q(J.caption,`font-mono`),children:Ua(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)(uo,{oldText:n.editOldText,newText:n.editNewText})})]})})]}):n.path===null?null:(0,$.jsxs)(W,{children:[(0,$.jsx)(G,{asChild:!0,children:(0,$.jsx)(`span`,{className:q(J.caption,`font-mono truncate max-w-[200px] sm:max-w-[320px]`),children:n.path})}),(0,$.jsx)(K,{children:n.path})]}),t[10]=n.editAddedLineCount,t[11]=n.editDeletedLineCount,t[12]=n.editNewText,t[13]=n.editOldText,t[14]=n.fileDisplayName,t[15]=n.filePath,t[16]=n.hasEditDiff,t[17]=n.limit,t[18]=n.offset,t[19]=n.path,t[20]=n.toolName,t[21]=c,t[22]=d,t[23]=i,t[24]=a):a=t[24];let o;return t[25]!==r||t[26]!==a?(o=(0,$.jsxs)(`div`,{className:`py-0.5 flex items-center gap-2 flex-wrap`,children:[r,a]}),t[25]=r,t[26]=a,t[27]=o):o=t[27],o}let f;t[28]===o?f=t[29]:(f=()=>s(!o),t[28]=o,t[29]=f);let p;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(p=q(J.body,`w-full py-2 flex items-center gap-2 font-medium text-foreground hover:bg-muted/50 transition-colors text-left`),t[30]=p):p=t[30];let m;t[31]===n.displayName?m=t[32]:(m=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:n.displayName}),t[31]=n.displayName,t[32]=m);let g;t[33]===o?g=t[34]:(g=o?(0,$.jsx)(wt,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)($t,{className:`h-4 w-4 shrink-0`}),t[33]=o,t[34]=g);let _;t[35]!==f||t[36]!==m||t[37]!==g?(_=(0,$.jsx)(G,{asChild:!0,children:(0,$.jsxs)(`button`,{onClick:f,className:p,children:[m,g]})}),t[35]=f,t[36]=m,t[37]=g,t[38]=_):_=t[38];let v;t[39]===n.toolName?v=t[40]:(v=(0,$.jsx)(K,{children:n.toolName}),t[39]=n.toolName,t[40]=v);let y;t[41]!==_||t[42]!==v?(y=(0,$.jsxs)(W,{children:[_,v]}),t[41]=_,t[42]=v,t[43]=y):y=t[43];let b;t[44]!==n.toolId||t[45]!==n.toolInput||t[46]!==o?(b=o&&(0,$.jsxs)(`div`,{className:`py-2 border-t border-border`,children:[(0,$.jsxs)(`div`,{className:q(J.compact,`text-muted-foreground mb-2 font-mono`),children:[`ID: `,n.toolId]}),n.toolInput?(0,$.jsx)(`pre`,{className:co(),children:n.toolInput}):null]}),t[44]=n.toolId,t[45]=n.toolInput,t[46]=o,t[47]=b):b=t[47];let x;return t[48]!==y||t[49]!==b?(x=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[y,b]}),t[48]=y,t[49]=b,t[50]=x):x=t[50],x}function ko(e){let t=(0,X.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)(go,{children:n.codeSearchQuery}),n.pattern!==null&&(0,$.jsxs)(go,{children:[`/`,n.pattern,`/`]}),n.codeSearchFilePath!==null&&(0,$.jsx)(go,{children:n.codeSearchFilePath}),n.codeSearchFileGlob!==null&&(0,$.jsx)(go,{children:n.codeSearchFileGlob})]}):n.pattern!==null&&(0,$.jsx)(go,{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 Ao(e){let t=(0,X.c)(68),{data:n,inline:r,resultContent:i,isActive:a}=e,[o,s]=(0,Y.useState)(!1),[c,l]=(0,Y.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)(vo,{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,o;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>l(!0),o=q(J.caption,`font-mono hover:underline break-all cursor-pointer`),t[4]=r,t[5]=o):(r=t[4],o=t[5]);let s;t[6]===d?s=t[7]:(s=(0,$.jsx)(G,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:r,className:o,children:d})}),t[6]=d,t[7]=s);let u;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(K,{children:`View results`}),t[8]=u):u=t[8];let f;t[9]===s?f=t[10]:(f=(0,$.jsxs)(W,{children:[s,u]}),t[9]=s,t[10]=f);let p;t[11]!==e||t[12]!==f?(p=(0,$.jsxs)(`div`,{className:`py-0.5 flex items-center gap-2 flex-wrap`,children:[e,f]}),t[11]=e,t[12]=f,t[13]=p):p=t[13];let m;t[14]!==c||t[15]!==i||t[16]!==d?(m=(0,$.jsx)(lo,{open:c,onOpenChange:l,title:d,content:i}),t[14]=c,t[15]=i,t[16]=d,t[17]=m):m=t[17];let h;return t[18]!==p||t[19]!==m?(h=(0,$.jsxs)($.Fragment,{children:[p,m]}),t[18]=p,t[19]=m,t[20]=h):h=t[20],h}let e;t[21]!==n.displayName||t[22]!==n.toolName||t[23]!==a?(e=(0,$.jsx)(vo,{toolName:n.toolName,displayName:n.displayName,isActive:a}),t[21]=n.displayName,t[22]=n.toolName,t[23]=a,t[24]=e):e=t[24];let r;t[25]===n?r=t[26]:(r=(0,$.jsx)(ko,{data:n}),t[25]=n,t[26]=r);let o;t[27]===n.lang?o=t[28]:(o=n.lang!==null&&(0,$.jsx)(`span`,{className:q(J.caption,`px-1.5 py-0.5 rounded bg-muted`),children:n.lang}),t[27]=n.lang,t[28]=o);let s;return t[29]!==e||t[30]!==r||t[31]!==o?(s=(0,$.jsxs)(`div`,{className:`py-0.5 flex items-center gap-2 flex-wrap`,children:[e,r,o]}),t[29]=e,t[30]=r,t[31]=o,t[32]=s):s=t[32],s}let f;t[33]===o?f=t[34]:(f=()=>s(!o),t[33]=o,t[34]=f);let p;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(p=q(J.body,`w-full py-2 flex items-center gap-2 font-medium text-foreground hover:bg-muted/50 transition-colors text-left`),t[35]=p):p=t[35];let m;t[36]===a?m=t[37]:(m=a&&(0,$.jsx)(_o,{size:`md`}),t[36]=a,t[37]=m);let h;t[38]===n.displayName?h=t[39]:(h=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:n.displayName}),t[38]=n.displayName,t[39]=h);let g;t[40]!==n.codeSearchFileGlob||t[41]!==n.codeSearchFilePath||t[42]!==n.codeSearchQuery||t[43]!==n.pattern||t[44]!==u?(g=u&&(0,$.jsxs)($.Fragment,{children:[n.codeSearchQuery!==null&&(0,$.jsx)(`code`,{className:q(J.caption,`font-mono bg-muted rounded px-1 py-0.5 truncate max-w-[150px]`),children:n.codeSearchQuery}),n.pattern!==null&&(0,$.jsxs)(`code`,{className:q(J.caption,`font-mono bg-muted rounded px-1 py-0.5 truncate max-w-[150px]`),children:[`/`,n.pattern,`/`]}),n.codeSearchFilePath!==null&&(0,$.jsx)(`code`,{className:q(J.caption,`font-mono bg-muted rounded px-1 py-0.5 truncate max-w-[150px]`),children:n.codeSearchFilePath}),n.codeSearchFileGlob!==null&&(0,$.jsx)(`code`,{className:q(J.caption,`font-mono bg-muted rounded px-1 py-0.5 truncate max-w-[150px]`),children:n.codeSearchFileGlob})]}),t[40]=n.codeSearchFileGlob,t[41]=n.codeSearchFilePath,t[42]=n.codeSearchQuery,t[43]=n.pattern,t[44]=u,t[45]=g):g=t[45];let _;t[46]===o?_=t[47]:(_=o?(0,$.jsx)(wt,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)($t,{className:`h-4 w-4 shrink-0`}),t[46]=o,t[47]=_);let v;t[48]!==f||t[49]!==m||t[50]!==h||t[51]!==g||t[52]!==_?(v=(0,$.jsx)(G,{asChild:!0,children:(0,$.jsxs)(`button`,{onClick:f,className:p,children:[m,h,g,_]})}),t[48]=f,t[49]=m,t[50]=h,t[51]=g,t[52]=_,t[53]=v):v=t[53];let y;t[54]===n.toolName?y=t[55]:(y=(0,$.jsx)(K,{children:n.toolName}),t[54]=n.toolName,t[55]=y);let b;t[56]!==v||t[57]!==y?(b=(0,$.jsxs)(W,{children:[v,y]}),t[56]=v,t[57]=y,t[58]=b):b=t[58];let x;t[59]!==n.toolId||t[60]!==n.toolInput||t[61]!==o||t[62]!==u||t[63]!==i?(x=o&&(0,$.jsxs)(`div`,{className:`py-2 border-t border-border`,children:[(0,$.jsxs)(`div`,{className:q(J.compact,`text-muted-foreground mb-2 font-mono`),children:[`ID: `,n.toolId]}),n.toolInput?(0,$.jsx)(`pre`,{className:co(),children:n.toolInput}):null,u&&i&&(0,$.jsx)(`pre`,{className:co({maxHeight:`64`,className:`mt-2`}),children:i})]}),t[59]=n.toolId,t[60]=n.toolInput,t[61]=o,t[62]=u,t[63]=i,t[64]=x):x=t[64];let S;return t[65]!==x||t[66]!==b?(S=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[b,x]}),t[65]=x,t[66]=b,t[67]=S):S=t[67],S}function jo(e){let t=(0,X.c)(57),{data:n,inline:r,isActive:i}=e,[a,o]=(0,Y.useState)(!1);if(r){let e;t[0]!==n.displayName||t[1]!==n.toolName||t[2]!==i?(e=(0,$.jsx)(wo,{asChild:!0,children:(0,$.jsx)(`span`,{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)(vo,{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]===Symbol.for(`react.memo_cache_sentinel`)?(r=q(J.caption,`space-y-2`),t[4]=r):r=t[4];let a;t[5]===n.toolId?a=t[6]:(a=(0,$.jsxs)(`div`,{className:`font-mono`,children:[`ID: `,n.toolId]}),t[5]=n.toolId,t[6]=a);let o;t[7]!==n.prompt||t[8]!==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[7]=n.prompt,t[8]=n.toolInput,t[9]=o):o=t[9];let s;t[10]!==a||t[11]!==o?(s=(0,$.jsx)(To,{className:`w-80 max-h-80 overflow-auto`,align:`start`,children:(0,$.jsxs)(`div`,{className:r,children:[a,o]})}),t[10]=a,t[11]=o,t[12]=s):s=t[12];let c;t[13]!==e||t[14]!==s?(c=(0,$.jsxs)(Co,{children:[e,s]}),t[13]=e,t[14]=s,t[15]=c):c=t[15];let l;t[16]===n.agentName?l=t[17]:(l=n.agentName&&(0,$.jsx)(mo,{name:n.agentName}),t[16]=n.agentName,t[17]=l);let u;t[18]===n.subagentType?u=t[19]:(u=n.subagentType&&(0,$.jsx)(ho,{type:n.subagentType}),t[18]=n.subagentType,t[19]=u);let d;return t[20]!==c||t[21]!==l||t[22]!==u?(d=(0,$.jsxs)(`div`,{className:`py-0.5 flex items-center gap-2 flex-wrap`,children:[c,l,u]}),t[20]=c,t[21]=l,t[22]=u,t[23]=d):d=t[23],d}let s;t[24]===a?s=t[25]:(s=()=>o(!a),t[24]=a,t[25]=s);let c;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(c=q(J.body,`w-full py-2 flex items-center gap-2 font-medium text-foreground hover:bg-muted/50 transition-colors text-left`),t[26]=c):c=t[26];let l;t[27]===i?l=t[28]:(l=i&&(0,$.jsx)(_o,{size:`md`}),t[27]=i,t[28]=l);let u;t[29]===n.displayName?u=t[30]:(u=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:n.displayName}),t[29]=n.displayName,t[30]=u);let d;t[31]===n.agentName?d=t[32]:(d=n.agentName&&(0,$.jsx)(mo,{name:n.agentName}),t[31]=n.agentName,t[32]=d);let f;t[33]===n.subagentType?f=t[34]:(f=n.subagentType&&(0,$.jsx)(ho,{type:n.subagentType}),t[33]=n.subagentType,t[34]=f);let p;t[35]===a?p=t[36]:(p=a?(0,$.jsx)(wt,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)($t,{className:`h-4 w-4 shrink-0`}),t[35]=a,t[36]=p);let m;t[37]!==s||t[38]!==l||t[39]!==u||t[40]!==d||t[41]!==f||t[42]!==p?(m=(0,$.jsx)(G,{asChild:!0,children:(0,$.jsxs)(`button`,{onClick:s,className:c,children:[l,u,d,f,p]})}),t[37]=s,t[38]=l,t[39]=u,t[40]=d,t[41]=f,t[42]=p,t[43]=m):m=t[43];let h;t[44]===n.toolName?h=t[45]:(h=(0,$.jsx)(K,{children:n.toolName}),t[44]=n.toolName,t[45]=h);let g;t[46]!==m||t[47]!==h?(g=(0,$.jsxs)(W,{children:[m,h]}),t[46]=m,t[47]=h,t[48]=g):g=t[48];let _;t[49]!==n.prompt||t[50]!==n.toolId||t[51]!==n.toolInput||t[52]!==a?(_=a&&(0,$.jsxs)(`div`,{className:`py-2 border-t border-border`,children:[(0,$.jsxs)(`div`,{className:q(J.compact,`text-muted-foreground mb-2 font-mono`),children:[`ID: `,n.toolId]}),n.prompt?(0,$.jsx)(`div`,{className:co({maxHeight:`64`,padding:`3`,leading:!0}),children:n.prompt}):n.toolInput?(0,$.jsx)(`pre`,{className:co(),children:n.toolInput}):null]}),t[49]=n.prompt,t[50]=n.toolId,t[51]=n.toolInput,t[52]=a,t[53]=_):_=t[53];let v;return t[54]!==g||t[55]!==_?(v=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[g,_]}),t[54]=g,t[55]=_,t[56]=v):v=t[56],v}function Mo(e){let t=(0,X.c)(26),{data:n,inline:r,isActive:i}=e,[a,o]=(0,Y.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]===Symbol.for(`react.memo_cache_sentinel`)?(c=q(J.label,`w-full py-2 flex items-center gap-2 hover:bg-muted/50 transition-colors text-left`),t[2]=c):c=t[2];let l;t[3]===i?l=t[4]:(l=i&&(0,$.jsx)(_o,{size:`md`}),t[3]=i,t[4]=l);let u;t[5]===n.displayName?u=t[6]:(u=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:n.displayName}),t[5]=n.displayName,t[6]=u);let d;t[7]===a?d=t[8]:(d=a?(0,$.jsx)(wt,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)($t,{className:`h-4 w-4 shrink-0`}),t[7]=a,t[8]=d);let f;t[9]!==s||t[10]!==l||t[11]!==u||t[12]!==d?(f=(0,$.jsx)(G,{asChild:!0,children:(0,$.jsxs)(`button`,{onClick:s,className:c,children:[l,u,d]})}),t[9]=s,t[10]=l,t[11]=u,t[12]=d,t[13]=f):f=t[13];let p;t[14]===n.toolName?p=t[15]:(p=(0,$.jsx)(K,{children:n.toolName}),t[14]=n.toolName,t[15]=p);let m;t[16]!==f||t[17]!==p?(m=(0,$.jsxs)(W,{children:[f,p]}),t[16]=f,t[17]=p,t[18]=m):m=t[18];let h;t[19]!==n.toolId||t[20]!==n.toolInput||t[21]!==a?(h=a&&(0,$.jsxs)(`div`,{className:`py-2 border-t border-border`,children:[(0,$.jsxs)(`div`,{className:q(J.compact,`text-muted-foreground mb-2 font-mono`),children:[`ID: `,n.toolId]}),n.toolInput?(0,$.jsx)(`pre`,{className:co(),children:n.toolInput}):null]}),t[19]=n.toolId,t[20]=n.toolInput,t[21]=a,t[22]=h):h=t[22];let g;return t[23]!==m||t[24]!==h?(g=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[m,h]}),t[23]=m,t[24]=h,t[25]=g):g=t[25],g}function No(e){let t=(0,X.c)(35),{data:n,inline:r,isActive:i}=e,[a,o]=(0,Y.useState)(!1);if(r){let e;t[0]!==n.displayName||t[1]!==n.toolName||t[2]!==i?(e=(0,$.jsx)(vo,{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,$.jsxs)(W,{children:[(0,$.jsx)(G,{asChild:!0,children:(0,$.jsx)(`span`,{className:q(J.caption,`truncate max-w-[200px] sm:max-w-[320px]`),children:n.imageGenPrompt})}),(0,$.jsx)(K,{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]===Symbol.for(`react.memo_cache_sentinel`)?(c=q(J.label,`w-full py-2 flex items-center gap-2 hover:bg-muted/50 transition-colors text-left`),t[11]=c):c=t[11];let l;t[12]===i?l=t[13]:(l=i&&(0,$.jsx)(_o,{size:`md`}),t[12]=i,t[13]=l);let u;t[14]===n.displayName?u=t[15]:(u=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:n.displayName}),t[14]=n.displayName,t[15]=u);let d;t[16]===a?d=t[17]:(d=a?(0,$.jsx)(wt,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)($t,{className:`h-4 w-4 shrink-0`}),t[16]=a,t[17]=d);let f;t[18]!==s||t[19]!==l||t[20]!==u||t[21]!==d?(f=(0,$.jsx)(G,{asChild:!0,children:(0,$.jsxs)(`button`,{onClick:s,className:c,children:[l,u,d]})}),t[18]=s,t[19]=l,t[20]=u,t[21]=d,t[22]=f):f=t[22];let p;t[23]===n.toolName?p=t[24]:(p=(0,$.jsx)(K,{children:n.toolName}),t[23]=n.toolName,t[24]=p);let m;t[25]!==f||t[26]!==p?(m=(0,$.jsxs)(W,{children:[f,p]}),t[25]=f,t[26]=p,t[27]=m):m=t[27];let h;t[28]!==n.toolId||t[29]!==n.toolInput||t[30]!==a?(h=a&&(0,$.jsxs)(`div`,{className:`py-2 border-t border-border`,children:[(0,$.jsxs)(`div`,{className:q(J.compact,`text-muted-foreground mb-2 font-mono`),children:[`ID: `,n.toolId]}),n.toolInput?(0,$.jsx)(`pre`,{className:co(),children:n.toolInput}):null]}),t[28]=n.toolId,t[29]=n.toolInput,t[30]=a,t[31]=h):h=t[31];let g;return t[32]!==m||t[33]!==h?(g=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[m,h]}),t[32]=m,t[33]=h,t[34]=g):g=t[34],g}function Po(e){let t=(0,X.c)(40),{data:n,inline:r,isActive:i}=e,[a,o]=(0,Y.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)(Co,{children:[(0,$.jsx)(wo,{asChild:!0,children:(0,$.jsx)(`span`,{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)(vo,{toolName:n.toolName,displayName:n.displayName,isActive:i,muted:!1})})})}),(0,$.jsx)(To,{className:`w-80 max-h-80 overflow-auto`,align:`start`,children:(0,$.jsxs)(`div`,{className:q(J.bodyMuted,`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)(vo,{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,$.jsxs)(W,{children:[(0,$.jsx)(G,{asChild:!0,children:(0,$.jsx)(`span`,{className:q(J.caption,`font-mono truncate max-w-[200px] sm:max-w-[320px]`),children:n.path})}),(0,$.jsx)(K,{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]===Symbol.for(`react.memo_cache_sentinel`)?(c=q(J.body,`w-full py-2 flex items-center gap-2 font-medium text-foreground hover:bg-muted/50 transition-colors text-left`),t[15]=c):c=t[15];let l;t[16]===i?l=t[17]:(l=i&&(0,$.jsx)(_o,{size:`md`}),t[16]=i,t[17]=l);let u;t[18]===n.displayName?u=t[19]:(u=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:n.displayName}),t[18]=n.displayName,t[19]=u);let d;t[20]===a?d=t[21]:(d=a?(0,$.jsx)(wt,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)($t,{className:`h-4 w-4 shrink-0`}),t[20]=a,t[21]=d);let f;t[22]!==s||t[23]!==l||t[24]!==u||t[25]!==d?(f=(0,$.jsx)(G,{asChild:!0,children:(0,$.jsxs)(`button`,{onClick:s,className:c,children:[l,u,d]})}),t[22]=s,t[23]=l,t[24]=u,t[25]=d,t[26]=f):f=t[26];let p;t[27]===n.toolName?p=t[28]:(p=(0,$.jsx)(K,{children:n.toolName}),t[27]=n.toolName,t[28]=p);let m;t[29]!==f||t[30]!==p?(m=(0,$.jsxs)(W,{children:[f,p]}),t[29]=f,t[30]=p,t[31]=m):m=t[31];let h;t[32]!==n.prompt||t[33]!==n.toolId||t[34]!==n.toolInput||t[35]!==a?(h=a&&(0,$.jsxs)(`div`,{className:`py-2 border-t border-border`,children:[(0,$.jsxs)(`div`,{className:q(J.compact,`text-muted-foreground mb-2 font-mono`),children:[`ID: `,n.toolId]}),n.prompt?(0,$.jsx)(`div`,{className:co({maxHeight:`64`,padding:`3`,leading:!0}),children:n.prompt}):n.toolInput?(0,$.jsx)(`pre`,{className:co(),children:n.toolInput}):null]}),t[32]=n.prompt,t[33]=n.toolId,t[34]=n.toolInput,t[35]=a,t[36]=h):h=t[36];let g;return t[37]!==m||t[38]!==h?(g=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[m,h]}),t[37]=m,t[38]=h,t[39]=g):g=t[39],g}function Fo(e){let t=(0,X.c)(40),{block:n,inline:r,resultContent:i,isActive:a}=e,{setPendingExplorerPath:o,setActiveMainTab:s}=Pa(),c=Q(Io),l=Ya(n,c),u=!!a,d;t[0]!==s||t[1]!==o?(d=function(e){o(e),s(`explorer`)},t[0]=s,t[1]=o,t[2]=d):d=t[2];let f=d;switch(l.toolType){case`bash`:{let e;return t[3]!==l||t[4]!==r||t[5]!==u||t[6]!==i?(e=(0,$.jsx)(yo,{data:l,inline:r,resultContent:i,isActive:u}),t[3]=l,t[4]=r,t[5]=u,t[6]=i,t[7]=e):e=t[7],e}case`fetch`:{let e;return t[8]!==l||t[9]!==r||t[10]!==u||t[11]!==i?(e=(0,$.jsx)(bo,{data:l,inline:r,resultContent:i,isActive:u}),t[8]=l,t[9]=r,t[10]=u,t[11]=i,t[12]=e):e=t[12],e}case`file`:{let e;return t[13]!==l||t[14]!==f||t[15]!==r||t[16]!==u||t[17]!==c?(e=(0,$.jsx)(Oo,{data:l,inline:r,rootPath:c,onOpenFile:f,isActive:u}),t[13]=l,t[14]=f,t[15]=r,t[16]=u,t[17]=c,t[18]=e):e=t[18],e}case`search`:{let e;return t[19]!==l||t[20]!==r||t[21]!==u||t[22]!==i?(e=(0,$.jsx)(Ao,{data:l,inline:r,resultContent:i,isActive:u}),t[19]=l,t[20]=r,t[21]=u,t[22]=i,t[23]=e):e=t[23],e}case`agent`:{let e;return t[24]!==l||t[25]!==r||t[26]!==u?(e=(0,$.jsx)(jo,{data:l,inline:r,isActive:u}),t[24]=l,t[25]=r,t[26]=u,t[27]=e):e=t[27],e}case`todo`:{let e;return t[28]!==l||t[29]!==r||t[30]!==u?(e=(0,$.jsx)(Mo,{data:l,inline:r,isActive:u}),t[28]=l,t[29]=r,t[30]=u,t[31]=e):e=t[31],e}case`imageGen`:{let e;return t[32]!==l||t[33]!==r||t[34]!==u?(e=(0,$.jsx)(No,{data:l,inline:r,isActive:u}),t[32]=l,t[33]=r,t[34]=u,t[35]=e):e=t[35],e}default:{let e;return t[36]!==l||t[37]!==r||t[38]!==u?(e=(0,$.jsx)(Po,{data:l,inline:r,isActive:u}),t[36]=l,t[37]=r,t[38]=u,t[39]=e):e=t[39],e}}}function Io(e){return e.projects.find(t=>t.projectId===e.selectedProjectId)?.threads.find(t=>t.threadId===e.selectedThreadId)?.path}var Lo=(0,Y.createContext)({todos:[],setTodos:()=>{}});function Ro(e){let t=(0,X.c)(10),{children:n,threadId:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=[],t[0]=i):i=t[0];let[a,o]=(0,Y.useState)(i),s=(0,Y.useRef)(-1),c;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(c=(e,t)=>{t>=s.current&&(s.current=t,o(e))},t[1]=c):c=t[1];let l=c,u;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>{s.current=-1,o([])},t[2]=u):u=t[2];let d;t[3]===r?d=t[4]:(d=[r],t[3]=r,t[4]=d),(0,Y.useEffect)(u,d);let f;t[5]===a?f=t[6]:(f={todos:a,setTodos:l},t[5]=a,t[6]=f);let p;return t[7]!==n||t[8]!==f?(p=(0,$.jsx)(Lo.Provider,{value:f,children:n}),t[7]=n,t[8]=f,t[9]=p):p=t[9],p}function zo(e){let t=[e.result,e.content],n=[];for(let e of t)if(typeof e==`string`)n.push(e);else if(Array.isArray(e))for(let t of e)typeof t==`object`&&t&&`text`in t&&typeof t.text==`string`&&n.push(t.text);for(let e of n){let t=e.trim();if(t.startsWith(`{`))try{let e=JSON.parse(t);if(e&&Array.isArray(e.todos))return e.todos}catch(e){console.error(`Failed to parse todo JSON:`,e)}}return null}function Bo(e){let t=(0,X.c)(5),{todos:n,sequence:r}=e,{setTodos:i}=(0,Y.useContext)(Lo),a,o;return t[0]!==r||t[1]!==i||t[2]!==n?(a=()=>{i(n,r)},o=[n,i,r],t[0]=r,t[1]=i,t[2]=n,t[3]=a,t[4]=o):(a=t[3],o=t[4]),(0,Y.useEffect)(a,o),null}var Vo=Sr(e=>(0,$.jsxs)(`div`,{className:`mb-3 relative group/img inline-block max-w-full`,children:[(0,$.jsx)(`img`,{src:e.v0,alt:`Generated image`,className:`max-w-full rounded-lg block`,style:e.v1}),(0,$.jsx)(`div`,{className:`absolute top-2 right-2 flex gap-1 opacity-0 group-hover/img:opacity-100 transition-opacity`,children:e.v2})]}),{name:`GeneratedImageResult_1`,portals:[`v2`]}),Ho=function(e){let t=(0,X.c)(27),{imageUrl:n,imageData:r}=e,[i,a]=(0,Y.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 He(o.startsWith(`data:`)?{imageData:o.replace(/^data:[^;]+;base64,/,``),filename:e}:{imageUrl:o,filename:e});Fi({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 Ue(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;if(!o)return null;let d;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(d={maxHeight:`512px`},t[4]=d):d=t[4];let f;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(Fe,{className:`h-3.5 w-3.5`}),t[5]=f):f=t[5];let p;t[6]===c?p=t[7]:(p=(0,$.jsx)(G,{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:f})}),t[6]=c,t[7]=p);let m;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(K,{children:`Save image`}),t[8]=m):m=t[8];let h;t[9]===p?h=t[10]:(h=(0,$.jsxs)(W,{children:[p,m]}),t[9]=p,t[10]=h);let g;t[11]===i?g=t[12]:(g=i?(0,$.jsx)(cn,{className:`h-3.5 w-3.5 text-green-500`}):(0,$.jsx)(rt,{className:`h-3.5 w-3.5`}),t[11]=i,t[12]=g);let _;t[13]!==u||t[14]!==g?(_=(0,$.jsx)(G,{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:g})}),t[13]=u,t[14]=g,t[15]=_):_=t[15];let v=i?`Copied!`:`Copy to clipboard`,y;t[16]===v?y=t[17]:(y=(0,$.jsx)(K,{children:v}),t[16]=v,t[17]=y);let b;t[18]!==y||t[19]!==_?(b=(0,$.jsxs)(W,{children:[_,y]}),t[18]=y,t[19]=_,t[20]=b):b=t[20];let x;t[21]!==b||t[22]!==h?(x=(0,$.jsxs)(Mt,{children:[h,b]}),t[21]=b,t[22]=h,t[23]=x):x=t[23];let S;return t[24]!==o||t[25]!==x?(S=(0,$.jsx)(Vo,{v0:o,v1:d,v2:x}),t[24]=o,t[25]=x,t[26]=S):S=t[26],S};function Uo(e){let t=we(e);if(!t?.imageUrl&&!t?.imageData)return null;let n;if(typeof e==`object`&&e){let t=e;if(typeof t.model==`string`)n=t.model;else if(typeof t.content==`string`)try{let e=JSON.parse(t.content);typeof e.model==`string`&&(n=e.model)}catch{}}else if(typeof e==`string`)try{let t=JSON.parse(e.trim());typeof t.model==`string`&&(n=t.model)}catch{}return{imageUrl:t.imageUrl,imageData:t.imageData,model:n}}function Wo(e){let t=(0,X.c)(79),{block:n,inline:r,sequence:i}=e,a=i===void 0?0:i,[o,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(!1),u=Q(Go),d=n.toolName??`Unknown Tool`,f=n.toolCallId??`unknown`,p=n,m=n.result??p.content,g;t[0]!==p||t[1]!==d?(g=d===`todo`?zo(p):null,t[0]=p,t[1]=d,t[2]=g):g=t[2];let _=g,v,y,b,x,S,C;if(t[3]!==p||t[4]!==r||t[5]!==m||t[6]!==u||t[7]!==a||t[8]!==_||t[9]!==d){C=Symbol.for(`react.early_return_sentinel`);bb0:{if(b=Ua(Ja(m),u),!(b.length>0)&&_===null){C=null;break bb0}let e;if(t[16]!==m||t[17]!==u||t[18]!==d){if(v=Ha(d),typeof m==`object`&&m){let e=m,n=e.returnDisplay??e.return_display;if(typeof n==`string`&&n.trim()){let e;t[21]===n?e=t[22]:(e=n.trim(),t[21]=n,t[22]=e),v=e}else if(d===`read`||d===`file_read`){let n=e.filePath??e.file_path??e.path??``;if(n){let e;t[23]===n?e=t[24]:(e=n.split(`/`).pop()??n,t[23]=n,t[24]=e),v=`Completed ${e}`}}}else if(m==null){let e;t[25]===d?e=t[26]:(e=Ha(d),t[25]=d,t[26]=e),v=`${e} (no result)`}e=Ua(v,u),t[16]=m,t[17]=u,t[18]=d,t[19]=v,t[20]=e}else v=t[19],e=t[20];if(v=e,_!==null){let e;t[27]!==a||t[28]!==_?(e=(0,$.jsx)(Bo,{todos:_,sequence:a}),t[27]=a,t[28]=_,t[29]=e):e=t[29],C=e;break bb0}if(d===`generate_image`){let e;t[30]!==p||t[31]!==m?(e=Uo(m)??Uo(p),t[30]=p,t[31]=m,t[32]=e):e=t[32];let n=e;if(n&&(n.imageUrl||n.imageData)){let e;t[33]!==n.imageData||t[34]!==n.imageUrl?(e=(0,$.jsx)(Ho,{imageUrl:n.imageUrl,imageData:n.imageData}),t[33]=n.imageData,t[34]=n.imageUrl,t[35]=e):e=t[35],C=e;break bb0}}if(r){C=null;break bb0}let n;t[36]===d?n=t[37]:(n=d.toLowerCase().includes(`bash`),t[36]=d,t[37]=n),y=n,x=b?b.split(`
|
|
22
|
+
`):[],S=y?x.slice(0,3).join(`
|
|
23
|
+
`):b}t[3]=p,t[4]=r,t[5]=m,t[6]=u,t[7]=a,t[8]=_,t[9]=d,t[10]=v,t[11]=y,t[12]=b,t[13]=x,t[14]=S,t[15]=C}else v=t[10],y=t[11],b=t[12],x=t[13],S=t[14],C=t[15];if(C!==Symbol.for(`react.early_return_sentinel`))return C;let w=S,T=y&&x.length>3;if(y){let e;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(e=q(J.body,`px-3 py-2 flex items-center gap-2 font-medium text-foreground`),t[38]=e):e=t[38];let n;t[39]===v?n=t[40]:(n=(0,$.jsx)(`div`,{className:e,children:(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:v})}),t[39]=v,t[40]=n);let r;t[41]!==T||t[42]!==w||t[43]!==b||t[44]!==x?(r=b&&(0,$.jsxs)(`div`,{className:`px-3 pb-2 bg-background border-t border-border`,children:[T?(0,$.jsxs)(W,{children:[(0,$.jsx)(G,{asChild:!0,children:(0,$.jsxs)(`pre`,{className:q(J.caption,`bg-muted p-2 rounded font-mono whitespace-pre-wrap overflow-auto text-foreground text-left mt-2 cursor-pointer hover:bg-muted/80`),onClick:()=>l(!0),children:[w,(0,$.jsxs)(`span`,{className:`text-muted-foreground`,children:[`
|
|
24
|
+
`,`...`]})]})}),(0,$.jsx)(K,{children:`Click to see full output`})]}):(0,$.jsx)(`pre`,{className:q(J.caption,`bg-muted p-2 rounded font-mono whitespace-pre-wrap overflow-auto text-foreground text-left mt-2`),children:w}),T&&(0,$.jsxs)(`button`,{type:`button`,onClick:()=>l(!0),className:q(J.caption,`mt-1 text-brand hover:underline`),children:[`Show full output (`,x.length,` lines)`]})]}),t[41]=T,t[42]=w,t[43]=b,t[44]=x,t[45]=r):r=t[45];let i;t[46]!==n||t[47]!==r?(i=(0,$.jsxs)(`div`,{className:`mb-3 rounded-lg border border-border bg-muted/50 overflow-hidden`,children:[n,r]}),t[46]=n,t[47]=r,t[48]=i):i=t[48];let a;t[49]!==c||t[50]!==T||t[51]!==b?(a=T&&(0,$.jsx)(h,{open:c,onOpenChange:l,children:(0,$.jsxs)(H,{className:`max-w-3xl max-h-[80vh] flex flex-col`,children:[(0,$.jsx)(bt,{children:(0,$.jsx)(z,{children:`Full Output`})}),(0,$.jsx)(`pre`,{className:q(J.caption,`bg-muted p-3 rounded font-mono whitespace-pre-wrap overflow-auto flex-1 text-foreground`),children:b})]})}),t[49]=c,t[50]=T,t[51]=b,t[52]=a):a=t[52];let o;return t[53]!==i||t[54]!==a?(o=(0,$.jsxs)($.Fragment,{children:[i,a]}),t[53]=i,t[54]=a,t[55]=o):o=t[55],o}let E;t[56]===o?E=t[57]:(E=()=>s(!o),t[56]=o,t[57]=E);let D;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(D=q(J.body,`w-full px-3 py-2 flex items-center gap-2 font-medium text-foreground hover:bg-muted transition-colors text-left`),t[58]=D):D=t[58];let O;t[59]===v?O=t[60]:(O=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:v}),t[59]=v,t[60]=O);let k;t[61]===o?k=t[62]:(k=o?(0,$.jsx)(wt,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)($t,{className:`h-4 w-4 shrink-0`}),t[61]=o,t[62]=k);let A;t[63]!==E||t[64]!==O||t[65]!==k?(A=(0,$.jsx)(G,{asChild:!0,children:(0,$.jsxs)(`button`,{onClick:E,className:D,children:[O,k]})}),t[63]=E,t[64]=O,t[65]=k,t[66]=A):A=t[66];let j=`${d} result`,M;t[67]===j?M=t[68]:(M=(0,$.jsx)(K,{children:j}),t[67]=j,t[68]=M);let N;t[69]!==M||t[70]!==A?(N=(0,$.jsxs)(W,{children:[A,M]}),t[69]=M,t[70]=A,t[71]=N):N=t[71];let P;t[72]!==o||t[73]!==b||t[74]!==f?(P=o&&(0,$.jsxs)(`div`,{className:`px-3 py-2 bg-background border-t border-border`,children:[(0,$.jsxs)(`div`,{className:q(J.compact,`text-muted-foreground mb-2 font-mono`),children:[`Call ID: `,f]}),b&&(0,$.jsx)(`pre`,{className:q(J.caption,`bg-muted p-2 rounded font-mono whitespace-pre-wrap overflow-auto max-h-48 text-foreground text-left`),children:b})]}),t[72]=o,t[73]=b,t[74]=f,t[75]=P):P=t[75];let F;return t[76]!==N||t[77]!==P?(F=(0,$.jsxs)(`div`,{className:`mb-3 rounded-lg border border-border bg-muted/50 overflow-hidden`,children:[N,P]}),t[76]=N,t[77]=P,t[78]=F):F=t[78],F}function Go(e){return e.projects.find(t=>t.projectId===e.selectedProjectId)?.threads.find(t=>t.threadId===e.selectedThreadId)?.path}var Ko=Sr(e=>(0,$.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,$.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1.5 cursor-pointer select-none text-left w-full`,onClick:e.v0,"aria-expanded":e.v1,children:[e.v2,(0,$.jsx)(`span`,{className:e.v3,children:e.v4})]}),(0,$.jsx)(`div`,{className:e.v5,children:(0,$.jsx)(`div`,{className:`overflow-hidden`,children:e.v6})})]}),{name:`ThinkingBlock_1`,portals:[`v2`,`v4`,`v6`]}),qo=function(e){let t=(0,X.c)(34),{text:n,isStreaming:r,label:i}=e,a=n===void 0?``:n,o=r===void 0?!1:r,s=(0,Y.useRef)(null),c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=Date.now(),t[0]=c):c=t[0];let l=(0,Y.useRef)(c),[u,d]=(0,Y.useState)(0),[f,p]=(0,Y.useState)(o),m=(0,Y.useRef)(o),h,g;t[1]===o?(h=t[2],g=t[3]):(h=()=>{o&&!m.current?(l.current=Date.now(),d(0),p(!0)):o?p(!0):m.current&&!o&&(d(Date.now()-l.current),p(!1)),m.current=o},g=[o],t[1]=o,t[2]=h,t[3]=g),(0,Y.useEffect)(h,g);let _;t[4]!==f||t[5]!==o?(_=()=>{f&&o&&s.current&&(s.current.scrollTop=s.current.scrollHeight)},t[4]=f,t[5]=o,t[6]=_):_=t[6];let v;if(t[7]!==f||t[8]!==o||t[9]!==a?(v=[a,f,o],t[7]=f,t[8]=o,t[9]=a,t[10]=v):v=t[10],(0,Y.useEffect)(_,v),!a&&!o)return null;let y=!o&&i===`Validated`,b;t[11]!==u||t[12]!==o||t[13]!==i?(b=Yo(o,i,u),t[11]=u,t[12]=o,t[13]=i,t[14]=b):b=t[14];let x=b,S;t[15]===a?S=t[16]:(S=a?Va(a):``,t[15]=a,t[16]=S);let C=S,w;t[17]===f?w=t[18]:(w=()=>p(!f),t[17]=f,t[18]=w);let T;t[19]===y?T=t[20]:(T=y?(0,$.jsx)(gt,{className:`h-3.5 w-3.5 shrink-0 text-green-600`}):null,t[19]=y,t[20]=T);let E=f?`grid-rows-[1fr]`:`grid-rows-[0fr]`,D;t[21]===E?D=t[22]:(D=[`grid transition-[grid-template-rows] duration-200 ease-in-out`,E],t[21]=E,t[22]=D);let O=D.join(` `),k,A;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(k=q(J.caption,`ml-5 text-muted-foreground/60 whitespace-pre-wrap overflow-y-auto`),A={maxHeight:`7.5em`},t[23]=k,t[24]=A):(k=t[23],A=t[24]);let j;t[25]===C?j=t[26]:(j=(0,$.jsx)(`div`,{ref:s,className:k,style:A,children:C}),t[25]=C,t[26]=j);let M;return t[27]!==f||t[28]!==x||t[29]!==w||t[30]!==T||t[31]!==O||t[32]!==j?(M=(0,$.jsx)(Ko,{v0:w,v1:f,v2:T,v3:J.caption,v4:x,v5:O,v6:j}),t[27]=f,t[28]=x,t[29]=w,t[30]=T,t[31]=O,t[32]=j,t[33]=M):M=t[33],M};function Jo(e){if(e<1e3){let t=Math.max(1,Math.round(e));return`${t} millisecond${t===1?``:`s`}`}let t=Math.max(1,Math.round(e/1e3));if(t<60)return`${t} second${t===1?``:`s`}`;let n=Math.floor(t/60),r=t%60;return r===0?`${n} minute${n===1?``:`s`}`:`${n} minute${n===1?``:`s`} ${r} second${r===1?``:`s`}`}function Yo(e,t,n){return e?t===`MCP`?`Connecting MCP servers...`:t===`Validating`?`Validating...`:`Thinking...`:t===`MCP`?`MCP setup complete.`:t===`Validated`?`Validated`:n<=0?`Thought complete.`:`Thought for ${Jo(n)}.`}function Xo(e){let t=(0,X.c)(63),{toolCall:n,className:r}=e,i=vi(),[a,o]=(0,Y.useState)(!1),s;t[0]===n.id?s=t[1]:(s=e=>e.toolCallProgress[n.id],t[0]=n.id,t[1]=s);let c=Q(s),l=Q(es),u=Q($o),d;t[2]!==n.activeDisplayName||t[3]!==n.name?(d=n.activeDisplayName??Ge(n.name),t[2]=n.activeDisplayName,t[3]=n.name,t[4]=d):d=t[4];let f=d;if(!l)return null;let p;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(p=()=>{o(Qo)},t[5]=p):p=t[5];let m=p,h;t[6]!==i||t[7]!==u||t[8]!==n.id||t[9]!==n.name?(h=()=>{i({type:Z.StopStream});let e={type:`tool-result`,toolCallId:n.id,toolName:n.name,result:`Tool execution was cancelled by the user. The command was taking too long or required user approval.`,isError:!0,content:`Tool execution was cancelled by the user. The command was taking too long or required user approval.`};i({type:Z.AppendStreamChunk,chunkType:`content`,content:JSON.stringify([e]),segments:u})},t[6]=i,t[7]=u,t[8]=n.id,t[9]=n.name,t[10]=h):h=t[10];let g=h,_=Zo,v=n.name===`bash`&&typeof n.input?.command==`string`?n.input.command:null,y=n.name===`fetch`&&typeof n.input?.url==`string`?n.input.url:null,b=!v&&typeof n.input?.description==`string`?n.input.description:null,x;t[11]===r?x=t[12]:(x=q(`overflow-hidden mb-2`,r),t[11]=r,t[12]=x);let S;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,$.jsx)(_o,{}),t[13]=S):S=t[13];let C;t[14]===f?C=t[15]:(C=(0,$.jsx)(G,{asChild:!0,children:(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[S,(0,$.jsx)(`span`,{className:J.bodyMuted,children:f})]})}),t[14]=f,t[15]=C);let w;t[16]===n.name?w=t[17]:(w=(0,$.jsx)(K,{children:n.name}),t[16]=n.name,t[17]=w);let T;t[18]!==C||t[19]!==w?(T=(0,$.jsxs)(W,{children:[C,w]}),t[18]=C,t[19]=w,t[20]=T):T=t[20];let E;t[21]===v?E=t[22]:(E=v!==null&&(0,$.jsx)(`code`,{className:q(J.mono,J.bodyMuted,`break-all rounded bg-muted/60 px-1 py-0.5`),children:v}),t[21]=v,t[22]=E);let D;t[23]===y?D=t[24]:(D=y!==null&&(0,$.jsx)(`code`,{className:q(J.mono,J.bodyMuted,`break-all rounded bg-muted/60 px-1 py-0.5`),children:y.length>60?`${y.slice(0,59)}…`:y}),t[23]=y,t[24]=D);let O;t[25]===b?O=t[26]:(O=b!==null&&(0,$.jsx)(`span`,{className:J.bodyMuted,children:b}),t[25]=b,t[26]=O);let k;t[27]!==v||t[28]!==b||t[29]!==y?(k=!v&&!y&&!b&&(0,$.jsx)(`span`,{className:J.bodyMuted,children:`running`}),t[27]=v,t[28]=b,t[29]=y,t[30]=k):k=t[30];let j;t[31]===a?j=t[32]:(j=(0,$.jsx)(G,{asChild:!0,children:(0,$.jsx)(`button`,{onClick:m,className:`p-1 hover:bg-muted/50 rounded transition-colors`,children:a?(0,$.jsx)(Lt,{className:`h-3 w-3`}):(0,$.jsx)(wt,{className:`h-3 w-3`})})}),t[31]=a,t[32]=j);let M=a?`Collapse`:`Expand`,N;t[33]===M?N=t[34]:(N=(0,$.jsx)(K,{children:M}),t[33]=M,t[34]=N);let P;t[35]!==j||t[36]!==N?(P=(0,$.jsxs)(W,{children:[j,N]}),t[35]=j,t[36]=N,t[37]=P):P=t[37];let F;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,$.jsx)(A,{className:`h-3 w-3`}),t[38]=F):F=t[38];let I;t[39]===g?I=t[40]:(I=(0,$.jsx)(G,{asChild:!0,children:(0,$.jsx)(`button`,{onClick:g,className:`p-1 hover:bg-red-200 dark:hover:bg-red-800 rounded transition-colors text-red-600 dark:text-red-400`,children:F})}),t[39]=g,t[40]=I);let L;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,$.jsx)(K,{className:`bg-red-600 text-white border-red-600`,children:`Stop this process`}),t[41]=L):L=t[41];let R;t[42]===I?R=t[43]:(R=(0,$.jsxs)(W,{children:[I,L]}),t[42]=I,t[43]=R);let ee;t[44]!==P||t[45]!==R?(ee=(0,$.jsxs)(`div`,{className:`flex items-center gap-1 ml-auto shrink-0`,children:[P,R]}),t[44]=P,t[45]=R,t[46]=ee):ee=t[46];let z;t[47]!==E||t[48]!==D||t[49]!==O||t[50]!==k||t[51]!==ee||t[52]!==T?(z=(0,$.jsxs)(`div`,{className:`py-0.5 flex items-center gap-2 flex-wrap`,children:[T,E,D,O,k,ee]}),t[47]=E,t[48]=D,t[49]=O,t[50]=k,t[51]=ee,t[52]=T,t[53]=z):z=t[53];let te;t[54]!==a||t[55]!==n.id||t[56]!==n.input||t[57]!==c?(te=a&&(0,$.jsxs)(`div`,{className:`py-2 border-t border-border min-h-[8rem] overflow-auto`,children:[(0,$.jsxs)(`div`,{className:q(J.compact,J.bodyMuted,`mb-2 font-mono`),children:[`ID: `,n.id]}),(0,$.jsxs)(`div`,{className:`mb-2`,children:[(0,$.jsx)(`div`,{className:q(J.compact,J.label,`text-muted-foreground mb-1`),children:`Input:`}),(0,$.jsx)(`pre`,{className:co({className:`border border-border`}),children:_(n.input)})]}),c&&(0,$.jsxs)(`div`,{className:`mb-2`,children:[(0,$.jsx)(`div`,{className:q(J.compact,J.label,`text-muted-foreground mb-1`),children:`Progress:`}),(0,$.jsxs)(`div`,{className:q(J.body,`bg-green-50 dark:bg-green-900/20 p-2 rounded border border-green-200 dark:border-green-800`),children:[(0,$.jsx)(`div`,{className:q(J.mono,`text-green-700 dark:text-green-300`),children:c.delta}),c.partial?.content?.[0]?.arguments&&typeof c.partial.content[0].arguments==`object`&&`content`in c.partial.content[0].arguments&&typeof c.partial.content[0].arguments.content==`string`&&(0,$.jsxs)(`div`,{className:q(J.mono,`mt-1 text-green-600 dark:text-green-400`),children:[`Building: `,c.partial.content[0].arguments.content.slice(-50),c.partial.content[0].arguments.content.length>50&&`...`]})]})]}),(0,$.jsxs)(`div`,{className:q(J.compact,`flex items-center gap-1.5 text-muted-foreground`),children:[(0,$.jsx)(_o,{}),`Executing`,c&&` with progress`,`...`]})]}),t[54]=a,t[55]=n.id,t[56]=n.input,t[57]=c,t[58]=te):te=t[58];let ne;return t[59]!==z||t[60]!==te||t[61]!==x?(ne=(0,$.jsxs)(`div`,{className:x,children:[z,te]}),t[59]=z,t[60]=te,t[61]=x,t[62]=ne):ne=t[62],ne}function Zo(e){return JSON.stringify(e,null,2)}function Qo(e){return!e}function $o(e){return e.streamingSegments}function es(e){return e.isStreaming}var ts=Sr(e=>(0,$.jsxs)(`div`,{className:`rounded-lg border-t border-border p-4 my-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-2 mb-2`,children:[e.v0,(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsx)(`div`,{className:e.v1,children:e.v2}),e.v3]})]}),(0,$.jsxs)(`div`,{className:e.v4,children:[(0,$.jsxs)(`span`,{className:`font-medium`,children:[e.v5,`:`]}),` `,(0,$.jsx)(`span`,{children:e.v6})]})]}),{name:`AskUserBlock_1`,portals:[`v0`,`v2`,`v3`,`v5`,`v6`]}),ns=Sr(e=>(0,$.jsxs)(`div`,{className:`rounded-lg border-t border-border p-4 my-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-2 mb-3`,children:[e.v0,(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsx)(`div`,{className:e.v1,children:e.v2}),e.v3]})]}),e.v4,(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(`input`,{type:`text`,value:e.v5,onChange:e.v6,onKeyDown:e.v7,placeholder:e.v8,disabled:e.v9,className:`flex-1 rounded-md border border-border bg-background px-3 py-1.5 text-base text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring disabled:opacity-50`}),(0,$.jsx)(`button`,{type:`button`,onClick:e.v10,disabled:e.v11,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:e.v12})]})]}),{name:`AskUserBlock_2`,portals:[`v0`,`v2`,`v3`,`v4`,`v12`]}),rs=function(e){let t=(0,X.c)(54),{toolCallId:n,question:r,options:i,context:a,answeredText:o,answeredLabel:s}=e,[c,l]=(0,Y.useState)(``),[u,d]=(0,Y.useState)(!!o),[f,p]=(0,Y.useState)(o??``),[m,h]=(0,Y.useState)(!1),[g,_]=(0,Y.useState)(null),v,y;t[0]===o?(v=t[1],y=t[2]):(v=()=>{let e=o?.trim();if(e){d(!0),p(e),h(!1),_(null);return}d(!1),p(``)},y=[o],t[0]=o,t[1]=v,t[2]=y),(0,Y.useEffect)(v,y);let b;t[3]!==m||t[4]!==n?(b=async e=>{if(!(!e.trim()||m)){h(!0);try{await lt(n,e.trim()),p(e.trim()),d(!0)}catch(e){console.error(`Failed to submit answer:`,e),h(!1),_(null)}}},t[3]=m,t[4]=n,t[5]=b):b=t[5];let x=b,S;t[6]!==x||t[7]!==m||t[8]!==u?(S=e=>{u||m||(_(e),x(e))},t[6]=x,t[7]=m,t[8]=u,t[9]=S):S=t[9];let C=S,w;t[10]!==c||t[11]!==x||t[12]!==m||t[13]!==u?(w=()=>{if(u||m)return;let e=c.trim();e&&x(e)},t[10]=c,t[11]=x,t[12]=m,t[13]=u,t[14]=w):w=t[14];let T=w,E;t[15]===T?E=t[16]:(E=e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),T())},t[15]=T,t[16]=E);let D=E;if(u){let e,n;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(cn,{className:`h-5 w-5 text-brand shrink-0 mt-0.5`}),n=q(J.label,`text-foreground`),t[17]=e,t[18]=n):(e=t[17],n=t[18]);let i;t[19]===r?i=t[20]:(i=(0,$.jsx)(ma,{content:r}),t[19]=r,t[20]=i);let o;t[21]===a?o=t[22]:(o=a&&(0,$.jsx)(`p`,{className:q(J.bodyMuted,`mt-1`),children:a}),t[21]=a,t[22]=o);let c=s??`You answered`,l;return t[23]!==f||t[24]!==o||t[25]!==c||t[26]!==i?(l=(0,$.jsx)(ts,{v0:e,v1:n,v2:i,v3:o,v4:J.bodyMuted,v5:c,v6:f}),t[23]=f,t[24]=o,t[25]=c,t[26]=i,t[27]=l):l=t[27],l}let O,k;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,$.jsx)(Xt,{className:`h-5 w-5 text-brand shrink-0 mt-0.5`}),k=q(J.label,`text-foreground`),t[28]=O,t[29]=k):(O=t[28],k=t[29]);let A;t[30]===r?A=t[31]:(A=(0,$.jsx)(ma,{content:r}),t[30]=r,t[31]=A);let j;t[32]===a?j=t[33]:(j=a&&(0,$.jsx)(`p`,{className:q(J.bodyMuted,`mt-1`),children:a}),t[32]=a,t[33]=j);let M;t[34]!==C||t[35]!==m||t[36]!==i||t[37]!==g?(M=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:()=>C(e),disabled:m,className:q(`rounded-md border px-3 py-1.5 transition-colors disabled:opacity-50 flex items-center gap-1.5`,J.label,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)(cn,{className:`h-3.5 w-3.5 text-foreground`}),e]},e)})}),t[34]=C,t[35]=m,t[36]=i,t[37]=g,t[38]=M):M=t[38];let N;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(N=e=>l(e.target.value),t[39]=N):N=t[39];let P=i?.length?`Or type a custom answer...`:`Type your answer...`,F;t[40]!==c||t[41]!==m?(F=m||!c.trim(),t[40]=c,t[41]=m,t[42]=F):F=t[42];let I;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,$.jsx)(pt,{className:`h-3 w-3`}),t[43]=I):I=t[43];let L;return t[44]!==c||t[45]!==T||t[46]!==D||t[47]!==m||t[48]!==j||t[49]!==M||t[50]!==P||t[51]!==F||t[52]!==A?(L=(0,$.jsx)(ns,{v0:O,v1:k,v2:A,v3:j,v4:M,v5:c,v6:N,v7:D,v8:P,v9:m,v10:T,v11:F,v12:I}),t[44]=c,t[45]=T,t[46]=D,t[47]=m,t[48]=j,t[49]=M,t[50]=P,t[51]=F,t[52]=A,t[53]=L):L=t[53],L},is=ar,as=Hn,os=Yn,ss=Y.forwardRef((e,t)=>{let n=(0,X.c)(14),r,i,a,o;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4]):({className:i,inset:a,children:r,...o}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let s;n[5]!==i||n[6]!==a?(s=q(q(J.body,`flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 outline-none focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0`),a&&`pl-8`,i),n[5]=i,n[6]=a,n[7]=s):s=n[7];let c;n[8]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)($t,{className:`ml-auto`}),n[8]=c):c=n[8];let l;return n[9]!==r||n[10]!==o||n[11]!==t||n[12]!==s?(l=(0,$.jsxs)(Xn,{ref:t,className:s,...o,children:[r,c]}),n[9]=r,n[10]=o,n[11]=t,n[12]=s,n[13]=l):l=n[13],l});ss.displayName=Xn.displayName;var cs=Y.forwardRef((e,t)=>{let n=(0,X.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=q(`z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,$.jsx)(Jn,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});cs.displayName=Jn.displayName;var ls=Y.forwardRef((e,t)=>{let n=(0,X.c)(11),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({className:r,sideOffset:a,...i}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o=a===void 0?4:a,s;n[4]===r?s=n[5]:(s=q(`z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,r),n[4]=r,n[5]=s);let c;return n[6]!==i||n[7]!==t||n[8]!==o||n[9]!==s?(c=(0,$.jsx)(Mn,{children:(0,$.jsx)(Kn,{ref:t,sideOffset:o,className:s,...i})}),n[6]=i,n[7]=t,n[8]=o,n[9]=s,n[10]=c):c=n[10],c});ls.displayName=Kn.displayName;var us=Y.forwardRef((e,t)=>{let n=(0,X.c)(11),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({className:r,inset:i,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o;n[4]!==r||n[5]!==i?(o=q(q(J.body,`relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0`),i&&`pl-8`,r),n[4]=r,n[5]=i,n[6]=o):o=n[6];let s;return n[7]!==a||n[8]!==t||n[9]!==o?(s=(0,$.jsx)(Nn,{ref:t,className:o,...a}),n[7]=a,n[8]=t,n[9]=o,n[10]=s):s=n[10],s});us.displayName=Nn.displayName;var ds=Y.forwardRef((e,t)=>{let n=(0,X.c)(14),r,i,a,o;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4]):({className:a,children:i,checked:r,...o}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let s;n[5]===a?s=n[6]:(s=q(q(J.body,`relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`),a),n[5]=a,n[6]=s);let c;n[7]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,$.jsx)(Gn,{children:(0,$.jsx)(cn,{className:`h-4 w-4`})})}),n[7]=c):c=n[7];let l;return n[8]!==r||n[9]!==i||n[10]!==o||n[11]!==t||n[12]!==s?(l=(0,$.jsxs)(On,{ref:t,className:s,checked:r,...o,children:[c,i]}),n[8]=r,n[9]=i,n[10]=o,n[11]=t,n[12]=s,n[13]=l):l=n[13],l});ds.displayName=On.displayName;var fs=Y.forwardRef((e,t)=>{let n=(0,X.c)(12),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({className:i,children:r,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o;n[4]===i?o=n[5]:(o=q(q(J.body,`relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`),i),n[4]=i,n[5]=o);let s;n[6]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,$.jsx)(Gn,{children:(0,$.jsx)(Pt,{className:`h-2 w-2 fill-current`})})}),n[6]=s):s=n[6];let c;return n[7]!==r||n[8]!==a||n[9]!==t||n[10]!==o?(c=(0,$.jsxs)(In,{ref:t,className:o,...a,children:[s,r]}),n[7]=r,n[8]=a,n[9]=t,n[10]=o,n[11]=c):c=n[11],c});fs.displayName=In.displayName;var ps=Y.forwardRef((e,t)=>{let n=(0,X.c)(11),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({className:r,inset:i,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o=i&&`pl-8`,s;n[4]!==r||n[5]!==o?(s=q(J.body,`px-2 py-1.5 font-semibold`,o,r),n[4]=r,n[5]=o,n[6]=s):s=n[6];let c;return n[7]!==a||n[8]!==t||n[9]!==s?(c=(0,$.jsx)(qn,{ref:t,className:s,...a}),n[7]=a,n[8]=t,n[9]=s,n[10]=c):c=n[10],c});ps.displayName=qn.displayName;var ms=Y.forwardRef((e,t)=>{let n=(0,X.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=q(`-mx-1 my-1 h-px bg-muted`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,$.jsx)(Fn,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});ms.displayName=Fn.displayName;var hs=e=>{let t=(0,X.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=q(J.compact,`ml-auto tracking-widest opacity-60`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`span`,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a};hs.displayName=`DropdownMenuShortcut`;var gs=Sr(e=>(0,$.jsxs)(`div`,{className:`rounded-lg border border-border p-4 my-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-2 mb-2`,children:[e.v0,(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsx)(`div`,{className:e.v1,children:`Shell command permission`}),(0,$.jsx)(`code`,{className:e.v2,children:e.v3})]})]}),(0,$.jsx)(`div`,{className:e.v4,children:`Skipped`})]}),{name:`ShellPermissionBlock_1`,portals:[`v0`,`v3`]}),_s=Sr(e=>(0,$.jsxs)(`div`,{className:`rounded-lg border border-border p-4 my-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-2 mb-3`,children:[e.v0,(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsx)(`div`,{className:e.v1,children:`Allow the agent to run this command?`}),(0,$.jsx)(`code`,{className:e.v2,children:e.v3})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsxs)(`div`,{className:`inline-flex rounded-md shadow-sm`,children:[e.v4,e.v5]}),e.v6]})]}),{name:`ShellPermissionBlock_2`,portals:[`v0`,`v3`,`v4`,`v5`,`v6`]}),vs=function({toolCallId:e,command:t,projectId:n,wildcardOptions:r,resolvedDecision:i}){let[a,o]=(0,Y.useState)(!!i),[s,c]=(0,Y.useState)(i??null),[l,u]=(0,Y.useState)(!1);(0,Y.useEffect)(()=>{i&&(o(!0),c(i),u(!1))},[i]);async function d(t,r){if(!(l||a)){u(!0);try{await pn(e,t,{pattern:r,projectId:n??void 0}),o(!0),c(t===`skip`?`skipped`:`allowed`)}catch(e){console.error(`Failed to submit shell permission response:`,e),u(!1)}}}return a&&s!==`skipped`?null:a?(0,$.jsx)(gs,{v0:(0,$.jsx)(cn,{className:`h-5 w-5 text-brand shrink-0 mt-0.5`}),v1:J.label,v2:q(J.mono,J.bodyMuted,`mt-2 block break-all rounded bg-muted/60 px-2 py-1`),v3:t,v4:J.bodyMuted}):(0,$.jsx)(_s,{v0:(0,$.jsx)(pe,{className:`h-5 w-5 text-brand shrink-0 mt-0.5`}),v1:J.label,v2:q(J.mono,J.bodyMuted,`mt-2 block break-all rounded bg-muted/60 px-2 py-1`),v3:t,v4:(0,$.jsx)(U,{type:`button`,size:`sm`,disabled:l,onClick:()=>void d(`allow_once`),className:`rounded-r-none`,children:`Allow`}),v5:r.length>0&&(0,$.jsxs)(is,{children:[(0,$.jsx)(as,{asChild:!0,children:(0,$.jsx)(U,{type:`button`,size:`sm`,disabled:l,className:q(`rounded-l-none border-l border-primary-foreground/20 px-2`),"aria-label":`More allow options`,children:(0,$.jsx)(wt,{className:`h-4 w-4`})})}),(0,$.jsx)(ls,{align:`end`,className:`max-w-md`,children:r.map(e=>(0,$.jsx)(us,{onClick:()=>void d(e.scope===`project`?`allow_pattern_project`:`allow_pattern_session`,e.pattern),children:e.label},`${e.scope}-${e.pattern}`))})]}),v6:(0,$.jsx)(U,{type:`button`,size:`sm`,variant:`outline`,disabled:l,onClick:()=>void d(`skip`),children:`Skip`})})},ys=Sr(e=>(0,$.jsxs)(`div`,{className:`rounded-lg border border-border p-4 my-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-2 mb-2`,children:[e.v0,(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsx)(`div`,{className:e.v1,children:`Web fetch permission`}),(0,$.jsx)(`code`,{className:e.v2,children:e.v3})]})]}),(0,$.jsx)(`div`,{className:e.v4,children:`Skipped`})]}),{name:`WebFetchPermissionBlock_1`,portals:[`v0`,`v3`]}),bs=Sr(e=>(0,$.jsxs)(`div`,{className:`rounded-lg border border-border p-4 my-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-2 mb-3`,children:[e.v0,(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsx)(`div`,{className:e.v1,children:`Allow the agent to fetch from this domain?`}),(0,$.jsx)(`code`,{className:e.v2,children:e.v3}),(0,$.jsx)(`div`,{className:e.v4,children:e.v5})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsxs)(`div`,{className:`inline-flex rounded-md shadow-sm`,children:[e.v6,e.v7]}),e.v8]})]}),{name:`WebFetchPermissionBlock_2`,portals:[`v0`,`v3`,`v5`,`v6`,`v7`,`v8`]}),xs=function({toolCallId:e,hostname:t,url:n,wildcardOptions:r,resolvedDecision:i}){let[a,o]=(0,Y.useState)(!!i),[s,c]=(0,Y.useState)(i??null),[l,u]=(0,Y.useState)(!1);(0,Y.useEffect)(()=>{i&&(o(!0),c(i),u(!1))},[i]);async function d(t){if(!(l||a)){u(!0);try{await Cn(e,t),o(!0),c(t===`skip`?`skipped`:`allowed`)}catch(e){console.error(`Failed to submit web fetch permission response:`,e),u(!1)}}}return a&&s!==`skipped`?null:a?(0,$.jsx)(ys,{v0:(0,$.jsx)(cn,{className:`h-5 w-5 text-brand shrink-0 mt-0.5`}),v1:J.label,v2:q(J.mono,J.bodyMuted,`mt-2 block break-all rounded bg-muted/60 px-2 py-1`),v3:t,v4:J.bodyMuted}):(0,$.jsx)(bs,{v0:(0,$.jsx)(se,{className:`h-5 w-5 text-brand shrink-0 mt-0.5`}),v1:J.label,v2:q(J.mono,J.bodyMuted,`mt-2 block break-all rounded bg-muted/60 px-2 py-1`),v3:t,v4:q(J.caption,J.bodyMuted,`mt-1 break-all`),v5:n,v6:(0,$.jsx)(U,{type:`button`,size:`sm`,disabled:l,onClick:()=>void d(`allow_once`),className:`rounded-r-none`,children:`Allow`}),v7:r.length>0&&(0,$.jsxs)(is,{children:[(0,$.jsx)(as,{asChild:!0,children:(0,$.jsx)(U,{type:`button`,size:`sm`,disabled:l,className:q(`rounded-l-none border-l border-primary-foreground/20 px-2`),"aria-label":`More allow options`,children:(0,$.jsx)(wt,{className:`h-4 w-4`})})}),(0,$.jsx)(ls,{align:`end`,className:`max-w-md`,children:r.map(e=>(0,$.jsx)(us,{onClick:()=>void d(e.scope===`project`?`allow_domain_project`:`allow_domain_session`),children:e.label},`${e.scope}-${e.pattern}`))})]}),v8:(0,$.jsx)(U,{type:`button`,size:`sm`,variant:`outline`,disabled:l,onClick:()=>void d(`skip`),children:`Deny`})})},Ss=new Map,Cs=new Map;function ws(e){return Ss.get(e)}function Ts(e,t){let n=Cs.get(e);return n||(n=new Set,Cs.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&Cs.delete(e)}}function Es(e){let t=Cs.get(e);if(t)for(let e of t)e()}function Ds(e,t){return async function(n,r){let i=await fetch(e+`/api/browser-js/execute-tool`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({threadId:t,toolName:n,params:r})});if(!i.ok){let e=await i.text();try{let t=JSON.parse(e).error||{};e=t.details||t.message||e}catch{}return{text:null,error:`Tool `+n+` failed: `+e}}let a=await i.json();return{text:a.content&&a.content[0]?a.content[0].text:null,error:null}}}function Os(e,t,n){if(Ss.has(e))return;Ss.set(e,{status:`running`}),Es(e);let r=x();(async()=>{try{let i=Ds(r,n),a=Object.getPrototypeOf(async function(){}).constructor,o=await new a(`callTool`,t)(i),s=o===void 0?null:o;Ss.set(e,{status:`success`,result:s}),Es(e),await Ve(e,s)}catch(t){let n=t instanceof Error?t.stack||t.message:String(t);Ss.set(e,{status:`error`,error:n}),Es(e);try{await Ve(e,{error:n})}catch(e){console.error(`[browser-js-executor] failed to submit error result`,e)}}})()}var ks=Sr(e=>(0,$.jsx)(`div`,{className:`overflow-hidden`,children:(0,$.jsxs)(`div`,{className:e.v0,children:[e.v1,(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:e.v2})]})}),{name:`RunWebWorkerBlock_1`,portals:[`v1`,`v2`]}),As=Sr(e=>(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[(0,$.jsxs)(`button`,{onClick:e.v0,className:e.v1,children:[e.v2,(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:e.v3}),e.v4]}),e.v5]}),{name:`RunWebWorkerBlock_2`,portals:[`v2`,`v3`,`v4`,`v5`]}),js=Sr(e=>(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[(0,$.jsxs)(`button`,{onClick:e.v0,className:e.v1,children:[e.v2,(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:e.v3}),e.v4]}),e.v5]}),{name:`RunWebWorkerBlock_3`,portals:[`v2`,`v3`,`v4`,`v5`]}),Ms=function(e){let t=(0,X.c)(41),{toolCallId:n,intention:r,code:i}=e,a=Q(Ns),o;t[0]===n?o=t[1]:(o=ws(n),t[0]=n,t[1]=o);let s=o,[c,l]=(0,Y.useState)(s?.status??`running`),u;t[2]===s?u=t[3]:(u=()=>{if(!s||s.status!==`success`)return null;let e=s.result;return e==null?null:typeof e==`string`?e:JSON.stringify(e,null,2)},t[2]=s,t[3]=u);let[d,f]=(0,Y.useState)(u),[p,m]=(0,Y.useState)(s?.error??null),h,g;t[4]===n?(h=t[5],g=t[6]):(h=()=>Ts(n,()=>{let e=ws(n);if(e)if(l(e.status),e.status===`success`){let t=e.result;f(t==null?null:typeof t==`string`?t:JSON.stringify(t,null,2))}else e.status===`error`&&m(e.error??null)}),g=[n],t[4]=n,t[5]=h,t[6]=g),(0,Y.useEffect)(h,g);let _,v;t[7]!==i||t[8]!==a||t[9]!==n?(_=()=>{a&&Os(n,i,a)},v=[n,i,a],t[7]=i,t[8]=a,t[9]=n,t[10]=_,t[11]=v):(_=t[10],v=t[11]),(0,Y.useEffect)(_,v);let[y,b]=(0,Y.useState)(!1),x;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(x=()=>b(Ps),t[12]=x):x=t[12];let S=x;if(c===`running`){let e,n;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(e=q(J.label,`w-full py-2 flex items-center gap-2`),n=(0,$.jsx)(fe,{className:`h-4 w-4 shrink-0 text-brand animate-pulse`}),t[13]=e,t[14]=n):(e=t[13],n=t[14]);let i=r||`Executing Browser JS...`,a;return t[15]===i?a=t[16]:(a=(0,$.jsx)(ks,{v0:e,v1:n,v2:i}),t[15]=i,t[16]=a),a}if(c===`success`){let e,n;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(e=q(J.label,`w-full py-2 flex items-center gap-2 hover:bg-muted/50 transition-colors text-left`),n=(0,$.jsx)(fe,{className:`h-4 w-4 shrink-0 text-brand`}),t[17]=e,t[18]=n):(e=t[17],n=t[18]);let a=r||`Browser JS Executed Successfully`,o;t[19]===y?o=t[20]:(o=y?(0,$.jsx)(wt,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)($t,{className:`h-4 w-4 shrink-0`}),t[19]=y,t[20]=o);let s;t[21]!==i||t[22]!==y||t[23]!==d?(s=y&&(0,$.jsxs)(`div`,{className:`py-2 border-t border-border flex flex-col gap-2`,children:[(0,$.jsx)(`pre`,{className:q(J.bodyMuted,`leading-relaxed whitespace-pre-wrap`),children:i}),d!=null&&(0,$.jsx)(`pre`,{className:q(J.body,`leading-relaxed whitespace-pre-wrap border-t border-border pt-2`),children:d})]}),t[21]=i,t[22]=y,t[23]=d,t[24]=s):s=t[24];let c;return t[25]!==a||t[26]!==o||t[27]!==s?(c=(0,$.jsx)(As,{v0:S,v1:e,v2:n,v3:a,v4:o,v5:s}),t[25]=a,t[26]=o,t[27]=s,t[28]=c):c=t[28],c}let C,w;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(C=q(J.label,`w-full py-2 flex items-center gap-2 hover:bg-muted/50 transition-colors text-left`),w=(0,$.jsx)(fe,{className:`h-4 w-4 shrink-0 text-destructive`}),t[29]=C,t[30]=w):(C=t[29],w=t[30]);let T=r||`Browser JS Execution Failed`,E;t[31]===y?E=t[32]:(E=y?(0,$.jsx)(wt,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)($t,{className:`h-4 w-4 shrink-0`}),t[31]=y,t[32]=E);let D;t[33]!==i||t[34]!==p||t[35]!==y?(D=y&&(0,$.jsxs)(`div`,{className:`py-2 border-t border-border flex flex-col gap-2`,children:[(0,$.jsx)(`pre`,{className:q(J.bodyMuted,`leading-relaxed whitespace-pre-wrap`),children:p}),(0,$.jsx)(`pre`,{className:q(J.bodyMuted,`leading-relaxed whitespace-pre-wrap`),children:i})]}),t[33]=i,t[34]=p,t[35]=y,t[36]=D):D=t[36];let O;return t[37]!==T||t[38]!==E||t[39]!==D?(O=(0,$.jsx)(js,{v0:S,v1:C,v2:w,v3:T,v4:E,v5:D}),t[37]=T,t[38]=E,t[39]=D,t[40]=O):O=t[40],O};function Ns(e){return e.selectedThreadId}function Ps(e){return!e}var Fs=Sr(e=>(0,$.jsx)(`div`,{className:e.v0,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-1 min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:e.v1,children:`Agent`}),e.v2]}),e.v3]})}),{name:`StreamingMessageComponent_1`,portals:[`v2`,`v3`]}),Is=function(e){let t=(0,X.c)(24),{segments:n,model:r,projectId:i,isCreatingProject:a,isProcessingThread:o,totalMessages:s,showProcessingLine:c}=e,l=s===void 0?0:s,u=c===void 0?!1:c,d=Q(Ys),f,p,m,h,g;if(t[0]!==a||t[1]!==o||t[2]!==r||t[3]!==i||t[4]!==n||t[5]!==u||t[6]!==d||t[7]!==l){let e=ai(n);f=Fs;let s=u?`pb-0`:`pb-4`;t[13]===s?p=t[14]:(p=q(`group px-4 pt-4`,s),t[13]=s,t[14]=p),t[15]===Symbol.for(`react.memo_cache_sentinel`)?(m=q(J.compact,`font-medium text-foreground`),t[15]=m):m=t[15],t[16]===r?h=t[17]:(h=r&&(0,$.jsxs)(`span`,{className:q(J.compact,`flex items-center gap-1 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity`),children:[(0,$.jsx)(fe,{className:`h-2.5 w-2.5`}),gr(r)]}),t[16]=r,t[17]=h),g=e.length>0?(0,$.jsx)(`div`,{className:`flex flex-col gap-0.5 min-w-0 text-base`,children:oi(e,!0).map((t,n)=>{if(t.type===`thinking-group`){let e=t;return(0,$.jsx)(qo,{text:e.text,label:e.label,isStreaming:e.isCurrentlyStreaming},`tg-${n}`)}let r=t;if(r.type===`tool_use`&&r.name===`todo`||r.type===`tool-result`&&r.toolName===`todo`)return r.type===`tool-result`?(0,$.jsx)(Wo,{inline:!0,sequence:l,block:r},`b-${n}`):null;if(r.type===`tool-result`&&r.toolName===`ask_user`)return null;if(r.type===`long_running_confirmation`){let t=r.prompt;return Us(t,`stream-${n}`,Hs(e,t.toolCallId))}if(r.type===`shell_permission`){let e=r.prompt;return Ws(e,`stream-${n}`,i)}if(r.type===`web_fetch_permission`){let e=r.prompt;return Gs(e,`stream-${n}`,i)}return(0,$.jsx)(`div`,{children:r.type===`text`&&`text`in r?(0,$.jsx)(ma,{content:Yr(r.text),enableMermaid:!0}):r.type===`tool_use`?(()=>{let t=r.id,n=Bs(e,t),i=zs(d[t]??{});return Ks(r,void 0,!Vs(e,t),n,i)})():r.type===`tool-result`?(0,$.jsx)(Wo,{inline:!0,block:r}):null},`b-${n}`)})}):a||o?(0,$.jsx)(`div`,{className:`min-w-0`,children:(0,$.jsx)(qo,{isStreaming:!0})}):null,t[0]=a,t[1]=o,t[2]=r,t[3]=i,t[4]=n,t[5]=u,t[6]=d,t[7]=l,t[8]=f,t[9]=p,t[10]=m,t[11]=h,t[12]=g}else f=t[8],p=t[9],m=t[10],h=t[11],g=t[12];let _;return t[18]!==f||t[19]!==p||t[20]!==m||t[21]!==h||t[22]!==g?(_=(0,$.jsx)(f,{v0:p,v1:m,v2:h,v3:g}),t[18]=f,t[19]=p,t[20]=m,t[21]=h,t[22]=g,t[23]=_):_=t[23],_},Ls=Sr(e=>(0,$.jsxs)(`div`,{className:`mt-2 relative group/img inline-block max-w-full`,children:[(0,$.jsx)(`img`,{src:e.v0,alt:`Generated image`,className:`max-w-full rounded-lg border border-border block`,style:e.v1}),(0,$.jsx)(`div`,{className:`absolute top-2 right-2 flex gap-1 opacity-0 group-hover/img:opacity-100 transition-opacity`,children:e.v2})]}),{name:`GeneratedImagePreview_1`,portals:[`v2`]}),Rs=function(e){let t=(0,X.c)(27),{src:n}=e,[r,i]=(0,Y.useState)(!1),a;t[0]===n?a=t[1]:(a=async()=>{let e=`generated-image-${Date.now()}.png`,{path:t}=await He(n.startsWith(`data:`)?{imageData:n.replace(/^data:[^;]+;base64,/,``),filename:e}:{imageUrl:n,filename:e});Fi({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 Ue(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]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(Fe,{className:`h-3.5 w-3.5`}),t[5]=u):u=t[5];let d;t[6]===o?d=t[7]:(d=(0,$.jsx)(G,{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:u})}),t[6]=o,t[7]=d);let f;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(K,{children:`Save image`}),t[8]=f):f=t[8];let p;t[9]===d?p=t[10]:(p=(0,$.jsxs)(W,{children:[d,f]}),t[9]=d,t[10]=p);let m;t[11]===r?m=t[12]:(m=r?(0,$.jsx)(cn,{className:`h-3.5 w-3.5 text-green-500`}):(0,$.jsx)(rt,{className:`h-3.5 w-3.5`}),t[11]=r,t[12]=m);let h;t[13]!==c||t[14]!==m?(h=(0,$.jsx)(G,{asChild:!0,children:(0,$.jsx)(`button`,{onClick:c,className:`flex items-center justify-center h-7 w-7 rounded-md bg-background/80 backdrop-blur-sm border border-border text-foreground hover:bg-background transition-colors`,children:m})}),t[13]=c,t[14]=m,t[15]=h):h=t[15];let g=r?`Copied!`:`Copy to clipboard`,_;t[16]===g?_=t[17]:(_=(0,$.jsx)(K,{children:g}),t[16]=g,t[17]=_);let v;t[18]!==_||t[19]!==h?(v=(0,$.jsxs)(W,{children:[h,_]}),t[18]=_,t[19]=h,t[20]=v):v=t[20];let y;t[21]!==v||t[22]!==p?(y=(0,$.jsxs)(Mt,{children:[p,v]}),t[21]=v,t[22]=p,t[23]=y):y=t[23];let b;return t[24]!==n||t[25]!==y?(b=(0,$.jsx)(Ls,{v0:n,v1:l,v2:y}),t[24]=n,t[25]=y,t[26]=b):b=t[26],b};function zs(e){if(typeof e.executionOutput==`string`)return e.executionOutput;let t=e.partial?.content?.[0]?.arguments;if(!(!t||typeof t!=`object`)&&`content`in t&&typeof t.content==`string`)return t.content}function Bs(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 Vs(e,t){return e.some(e=>e.type===`tool-result`&&e.toolCallId===t)}function Hs(e,t){if(t)return Bs(e,t)}function Us(e,t,n){return(0,$.jsx)(rs,{toolCallId:e.toolCallId??`long-running-confirmation`,question:e.question,options:e.options,context:e.context,answeredText:n,answeredLabel:`You answered`},t)}function Ws(e,t,n){return(0,$.jsx)(vs,{toolCallId:e.toolCallId,command:e.command,projectId:n,wildcardOptions:e.wildcardOptions},t)}function Gs(e,t,n){return(0,$.jsx)(xs,{toolCallId:e.toolCallId,hostname:e.hostname,url:e.url,projectId:n,wildcardOptions:e.wildcardOptions},t)}function Ks(e,t,n,r,i){if(e.name===`ask_user`)return(0,$.jsx)(rs,{toolCallId:e.id,question:typeof e.input?.question==`string`?e.input.question:``,options:e.input?.options,context:e.input?.context,answeredText:r},t);if(e.name===`run_js`||e.name===`run_web_worker`)return(0,$.jsx)(Ms,{toolCallId:e.id,intention:e.input?.intention??``,code:e.input?.code??``},t);let a=n===!0&&r===void 0;return a&&e.name!==`bash`&&e.name!==`read`&&e.name!==`file_read`?(0,$.jsx)(Xo,{toolCall:e},t):(0,$.jsx)(Fo,{inline:!0,block:e,resultContent:a?i:r,isActive:a},t)}function qs({message:e,threadId:t,messageIndex:n=0,showCheckpointRestore:r=!1,checkpointRestoreTooltip:i}){let a=e.sender===`user`,o=a?null:$r(e.content),[s,c]=(0,Y.useState)(!1),[l,u]=(0,Y.useState)(!1),d=a&&(r||!!i),f=e.timestamp?new Date(e.timestamp).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}):``;async function p(){if(!(!e.checkpointRef||!t||s)){c(!0);try{let n=await tn(t,e.checkpointRef);n.success?Fi({title:`Checkpoint restored`,description:`Working tree restored to before this agent run.`}):Fi({title:`Restore failed`,description:n.error??`Could not restore checkpoint.`,variant:`destructive`})}catch(e){Fi({title:`Restore failed`,description:e instanceof Error?e.message:`Unknown error`,variant:`destructive`})}finally{c(!1)}}}async function m(){try{await navigator.clipboard.writeText(e.content),u(!0),setTimeout(()=>u(!1),2e3)}catch(e){Fi({title:`Copy failed`,description:e instanceof Error?e.message:`Could not copy prompt.`,variant:`destructive`})}}return(0,$.jsx)(`div`,{className:q(`group px-4 py-4`,a&&`flex justify-end`),children:(0,$.jsxs)(`div`,{className:q(`flex flex-col gap-1 min-w-0 max-w-full`,a&&`items-end`),children:[(0,$.jsxs)(`div`,{className:q(`flex items-center gap-2`,a&&`flex-row-reverse`),children:[(0,$.jsx)(`span`,{className:q(J.compact,`font-medium text-foreground`),children:a?`You`:`Agent`}),a&&(0,$.jsx)(Mt,{children:(0,$.jsxs)(`div`,{className:`inline-flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity`,children:[(0,$.jsxs)(W,{children:[(0,$.jsx)(G,{asChild:!0,children:(0,$.jsx)(`span`,{tabIndex:0,className:`inline-flex`,children:(0,$.jsx)(`button`,{onClick:m,"aria-label":l?`Prompt copied`:`Copy prompt`,className:`flex items-center justify-center h-5 w-5 rounded-md text-muted-foreground transition-colors hover:text-foreground hover:bg-muted`,children:l?(0,$.jsx)(cn,{className:`h-3 w-3 text-green-500`}):(0,$.jsx)(rt,{className:`h-3 w-3`})})})}),(0,$.jsx)(K,{side:`left`,children:l?`Copied prompt`:`Copy prompt`})]}),d&&(0,$.jsxs)(W,{children:[(0,$.jsx)(G,{asChild:!0,children:(0,$.jsx)(`span`,{tabIndex:0,className:`inline-flex`,children:(0,$.jsx)(`button`,{onClick:r?p:void 0,disabled:!r||s,"aria-label":i??`Restore checkpoint`,className:`flex items-center justify-center h-5 w-5 rounded-md text-muted-foreground transition-colors hover:text-foreground hover:bg-muted disabled:opacity-50 disabled:hover:text-muted-foreground disabled:hover:bg-transparent`,children:(0,$.jsx)(Qt,{className:q(`h-3 w-3`,s&&`animate-spin`)})})})}),(0,$.jsx)(K,{side:`left`,children:i??`Restore checkpoint`})]})]})}),f&&(0,$.jsxs)(`span`,{className:q(J.compact,`flex items-center gap-1 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity`),children:[(0,$.jsx)(nn,{className:`h-2.5 w-2.5`}),f]}),e.model&&(0,$.jsxs)(`span`,{className:q(J.compact,`flex items-center gap-1 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity`),children:[(0,$.jsx)(fe,{className:`h-2.5 w-2.5`}),gr(e.model)]}),e.metadata?.processingTimeMs&&(0,$.jsxs)(`span`,{className:q(J.compact,`flex items-center gap-1 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity`),children:[(0,$.jsx)(Me,{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||e.metadata?.estimatedCost)&&(0,$.jsxs)(`span`,{className:q(J.compact,`text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity`),children:[e.metadata.tokenCount?`${e.metadata.tokenCount.toLocaleString()} tokens`:null,e.metadata.tokenCount&&e.metadata.estimatedCost?` · `:null,e.metadata.estimatedCost?ae(e.metadata.estimatedCost):null]})]}),(0,$.jsx)(`div`,{className:q(`flex flex-col gap-0.5 min-w-0 text-base`,a&&`rounded-xl px-4 py-3 bg-foreground text-background`),children:e.isThinking?(()=>{let t=Xr(e.content);return t?.length?(0,$.jsx)($.Fragment,{children:oi(t,!1).map((e,n)=>{if(e.type===`thinking-group`){let t=e;return(0,$.jsx)(qo,{text:t.text,label:t.label,isStreaming:!1},`tg-${n}`)}let r=e;if(r.type===`tool_use`)return Ks(r,n,!1,Bs(t,r.id));if(r.type===`long_running_confirmation`){let e=r.prompt;return Us(e,n,Hs(t,e.toolCallId))}if(r.type===`shell_permission`){let e=r.prompt;return Ws(e,n)}if(r.type===`web_fetch_permission`){let e=r.prompt;return Gs(e,n)}return r.type===`tool-result`?(0,$.jsx)(Wo,{inline:!0,block:r},n):null})}):(0,$.jsx)(`div`,{className:q(J.bodyMuted,`leading-relaxed whitespace-pre-wrap`),children:(0,$.jsx)(ma,{content:Yr(e.content),enableMermaid:!0})})})():o?(0,$.jsx)($.Fragment,{children:oi(o,!1).map((e,t)=>{if(e.type===`thinking-group`){let n=e;return(0,$.jsx)(qo,{text:n.text,label:n.label,isStreaming:!1},`tg-${t}`)}let r=e;if(r.type===`tool_use`&&r.name===`todo`||r.type===`tool-result`&&r.toolName===`todo`)return r.type===`tool-result`?(0,$.jsx)(Wo,{inline:!0,sequence:n,block:r},t):null;if(r.type===`tool-result`&&r.toolName===`ask_user`)return null;if(r.type===`long_running_confirmation`){let e=r.prompt;return Us(e,t,Hs(o,e.toolCallId))}return(0,$.jsx)(`div`,{children:r.type===`text`&&`text`in r?(0,$.jsx)(ma,{content:Yr(r.text),enableMermaid:!0}):r.type===`tool_use`?Ks(r,void 0,!1,Bs(o,r.id)):r.type===`tool-result`?(0,$.jsx)(Wo,{inline:!0,block:r}):null},t)})}):(0,$.jsx)(ma,{content:Yr(e.content),enableMermaid:!0,className:J.body})}),(e.generatedImageUrl||e.generatedImageData)&&(0,$.jsx)(Rs,{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:q(J.compact,`flex items-center gap-1 rounded-md bg-muted px-2 py-1 text-muted-foreground`),children:[(0,$.jsx)(Ot,{className:`h-2.5 w-2.5`}),e.fileName]},t))})]})})}var Js=(0,Y.memo)(Is,(e,t)=>{if(e.model!==t.model||e.isCreatingProject!==t.isCreatingProject||e.isProcessingThread!==t.isProcessingThread||e.showProcessingLine!==t.showProcessingLine||e.totalMessages!==t.totalMessages||e.segments.length!==t.segments.length)return!1;for(let n=0;n<e.segments.length;n++){let r=e.segments[n],i=t.segments[n];if(r.type!==i.type)return!1;if(r.type===`long_running_confirmation`){if(i.type!==`long_running_confirmation`||JSON.stringify(r.prompt)!==JSON.stringify(i.prompt))return!1;continue}if(r.type===`shell_permission`){if(i.type!==`shell_permission`||JSON.stringify(r.prompt)!==JSON.stringify(i.prompt))return!1;continue}if(r.type===`web_fetch_permission`){if(i.type!==`web_fetch_permission`||JSON.stringify(r.prompt)!==JSON.stringify(i.prompt))return!1;continue}if(i.type===`long_running_confirmation`||i.type===`shell_permission`||i.type===`web_fetch_permission`||r.chunks.length!==i.chunks.length)return!1;for(let e=0;e<r.chunks.length;e++)if(r.chunks[e]!==i.chunks[e])return!1}return!0});function Ys(e){return e.toolCallProgress}var Xs=3e3;function Zs(e){let t=[...p],n=e?t.filter(t=>t!==e):t;return n[Math.floor(Math.random()*n.length)]}function Qs(e){let t=(0,X.c)(3),[n,r]=(0,Y.useState)(_),i=(0,Y.useRef)(_),a,o;return t[0]===e?(a=t[1],o=t[2]):(a=()=>{if(!e){r(_),i.current=_;return}let t=setInterval(()=>{let e=i.current===`Processing...`?Zs():Zs(i.current);i.current=e,r(e)},Xs);return()=>clearInterval(t)},o=[e],t[0]=e,t[1]=a,t[2]=o),(0,Y.useEffect)(a,o),n}var $s=`w-7`,ec=`-ml-9`;function tc(e){let t=(0,X.c)(11),{active:n,className:r}=e,i=n===void 0?!0:n,a=Qs(i),o;t[0]===r?o=t[1]:(o=q(`flex items-center gap-2`,ec,r),t[0]=r,t[1]=o);let s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(_o,{className:$s}),t[2]=s):s=t[2];let c=i?`animate-shimmer`:void 0,l;t[3]===c?l=t[4]:(l=q(J.caption,c),t[3]=c,t[4]=l);let u;t[5]!==a||t[6]!==l?(u=(0,$.jsx)(`span`,{className:l,children:a}),t[5]=a,t[6]=l,t[7]=u):u=t[7];let d;return t[8]!==o||t[9]!==u?(d=(0,$.jsxs)(`div`,{className:o,"aria-live":`polite`,"aria-busy":`true`,children:[s,u]}),t[8]=o,t[9]=u,t[10]=d):d=t[10],d}var nc=Sr(e=>(0,$.jsxs)(`div`,{className:`mx-auto flex max-w-3xl flex-1 flex-col items-center justify-center gap-8 px-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3`,children:[(0,$.jsx)(`img`,{src:`/tarsk-color.svg`,alt:`Tarsk`,className:`h-16 w-16 rounded-lg`}),(0,$.jsxs)(`div`,{className:`text-center`,children:[(0,$.jsx)(`h1`,{className:e.v0,children:`Let's build it!`}),(0,$.jsx)(`p`,{className:e.v1,children:e.v2})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap justify-center gap-3`,children:[e.v3,(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.v4,children:[e.v5,(0,$.jsx)(`span`,{className:e.v6,children:`Connect a repo`}),(0,$.jsx)(`span`,{className:e.v7,children:`Clone an existing repository`})]}),(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.v8,children:[e.v9,(0,$.jsx)(`span`,{className:e.v10,children:`New App`}),(0,$.jsx)(`span`,{className:e.v11,children:`Create a new project from template`})]}),(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.v12,children:[e.v13,(0,$.jsx)(`span`,{className:e.v14,children:`Open Folder`}),(0,$.jsx)(`span`,{className:e.v15,children:`Use an existing local folder`})]})]})]}),{name:`WelcomeScreen_1`,portals:[`v2`,`v3`,`v5`,`v9`,`v13`]}),rc=function(e){let t=(0,X.c)(17),{projects:n,onSelectProject:r,onCreateThread:i,onConnectRepo:a,onNewApp:o,onOpenFolder:s}=e,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=q(J.pageTitle,`tracking-tight text-balance`),t[0]=c):c=t[0];let l=n.length===0?`Start or connect your first project`:`Select a project to start coding`,u;if(t[1]!==i||t[2]!==r||t[3]!==n){let e;t[5]!==i||t[6]!==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)(E,{className:`h-5 w-5 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`${J.body} text-foreground leading-snug font-medium`,children:e.name}),(0,$.jsxs)(`span`,{className:J.caption,children:[e.threads.length,` thread`,e.threads.length===1?``:`s`]})]},e.projectId),t[5]=i,t[6]=r,t[7]=e):e=t[7],u=n.map(e),t[1]=i,t[2]=r,t[3]=n,t[4]=u}else u=t[4];let d;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(Tn,{className:`h-5 w-5 text-muted-foreground`}),t[8]=d):d=t[8];let f;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(Vt,{className:`h-5 w-5 text-muted-foreground`}),t[9]=f):f=t[9];let p;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(Oe,{className:`h-5 w-5 text-muted-foreground`}),t[10]=p):p=t[10];let m;return t[11]!==a||t[12]!==o||t[13]!==s||t[14]!==l||t[15]!==u?(m=(0,$.jsx)(nc,{v0:c,v1:`mt-1 ${J.pageSubtitle}`,v2:l,v3:u,v4:a,v5:d,v6:`${J.body} text-foreground leading-snug font-medium`,v7:J.caption,v8:o,v9:f,v10:`${J.body} text-foreground leading-snug font-medium`,v11:J.caption,v12:s,v13:p,v14:`${J.body} text-foreground leading-snug font-medium`,v15:J.caption}),t[11]=a,t[12]=o,t[13]=s,t[14]=l,t[15]=u,t[16]=m):m=t[16],m};function ic(){let e=Q(e=>e.selectedThreadId),{dispatch:t}=bi(e),{setActiveMainTab:n,setDevServerUrl:r,setDevServerRunning:i,setDevServerLoading:a}=Pa();return{startServer:async o=>{if(!o?.runCommand||!o?.projectId)return;a(!0),t({type:Z.ClearTerminalOutput}),t({type:Z.SetTerminalOpen,open:!1}),t({type:Z.AppendTerminalLine,line:{type:`system`,content:`Starting dev server: ${o.runCommand}`}});let s=!1,c=setTimeout(()=>{s=!0,t({type:Z.SetTerminalOpen,open:!0})},3e3);try{let l=await ot(o.projectId,e??void 0);if(!l){clearTimeout(c),t({type:Z.AppendTerminalLine,line:{type:`error`,content:`Failed to start dev server`}}),a(!1);return}let u=l.getReader(),d=new TextDecoder;i(!0),a(!1);let f=!1,p=!1;for(;;){let{done:e,value:i}=await u.read();if(e)break;let o=d.decode(i,{stream:!0});try{let e=o.split(`
|
|
25
|
+
`).filter(e=>e.trim());for(let i of e)try{let e=JSON.parse(i);p||(p=!0,a(!1)),e.type===`url`&&e.url&&(clearTimeout(c),t({type:Z.AppendTerminalLine,line:{type:`system`,content:`✓ Server running at: ${e.url}`}}),r(e.url),n(`browser`),s&&setTimeout(()=>{t({type:Z.SetTerminalOpen,open:!1})},100),f=!0)}catch{}}catch{}}f||t({type:Z.AppendTerminalLine,line:{type:`system`,content:`Server is running but URL could not be detected`}})}catch(e){console.error(`Failed to start dev server:`,e),a(!1),t({type:Z.AppendTerminalLine,line:{type:`error`,content:`Failed to start dev server`}})}},setServerUrl:r}}var ac=Sr(e=>(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:[(0,$.jsx)(`img`,{src:`/tarsk-color.svg`,alt:`Tarsk`,className:`h-16 w-16 rounded-lg`}),(0,$.jsxs)(`div`,{className:`text-center`,children:[(0,$.jsx)(`h1`,{className:e.v0,children:e.v1}),(0,$.jsx)(`p`,{className:e.v2,children:e.v3})]}),e.v4]})}),{name:`ChatMessagesPlaceholder_1`,portals:[`v1`,`v3`,`v4`]}),oc=function(e){let t=(0,X.c)(19),{project:n}=e,{setDevServerRunning:r}=Pa(),[i,a]=(0,Y.useState)(!1),{startServer:o}=ic(),s;t[0]!==n||t[1]!==r?(s=()=>{if(!n?.projectId)return;let e=async()=>{try{let e=await qt(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,Y.useEffect)(s,l),n?.name;let u=n?.name??`your project`,d;t[5]===u?d=t[6]:(d=sc(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=q(J.pageTitle,`tracking-tight text-foreground text-balance`),t[10]=g):g=t[10];let _=n?.name??`Project`,v;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(v=q(J.pageSubtitle,`mt-2`),t[11]=v):v=t[11];let y;t[12]!==h||t[13]!==p?(y=p&&(0,$.jsx)(`button`,{type:`button`,onClick:h,className:q(J.label,`inline-flex items-center gap-2 rounded-full bg-primary px-4 py-2 text-primary-foreground hover:bg-primary/90 transition-colors`),children:`Start App`}),t[12]=h,t[13]=p,t[14]=y):y=t[14];let b;return t[15]!==f||t[16]!==y||t[17]!==_?(b=(0,$.jsx)(ac,{v0:g,v1:_,v2:v,v3:f,v4:y}),t[15]=f,t[16]=y,t[17]=_,t[18]=b):b=t[18],b};function sc(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)]}var cc=(0,Y.forwardRef)((e,t)=>{let n=(0,X.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});cc.displayName=`MessageList`;function lc(e){let t=(0,X.c)(23),{context:n}=e;if(!n)return null;let{bottomInset:r,isStreaming:i,isCreatingProject:a,isProcessingThread:o,hasPendingMessage:s,hasActiveBlockingPrompt:c,selectedProjectId:l,streamingSegments:u,streamingModel:d,totalMessages:f,error:p,onClearError:m}=n,h=u.length>0||a||o&&(i||s),g=(i||s)&&!c,_;t[0]===r?_=t[1]:(_={paddingBottom:r},t[0]=r,t[1]=_);let v;t[2]!==h||t[3]!==a||t[4]!==o||t[5]!==i||t[6]!==l||t[7]!==g||t[8]!==d||t[9]!==u||t[10]!==f?(v=h&&(i||a||o)&&(0,$.jsx)(Js,{segments:u,model:d,projectId:l,isCreatingProject:a,isProcessingThread:o,totalMessages:f,showProcessingLine:g}),t[2]=h,t[3]=a,t[4]=o,t[5]=i,t[6]=l,t[7]=g,t[8]=d,t[9]=u,t[10]=f,t[11]=v):v=t[11];let y;t[12]!==h||t[13]!==g?(y=g&&(0,$.jsx)(`div`,{className:q(`px-4 pb-4`,h?`pt-0`:`pt-2`),children:(0,$.jsx)(tc,{active:g})}),t[12]=h,t[13]=g,t[14]=y):y=t[14];let b;t[15]!==p||t[16]!==m?(b=p&&(0,$.jsxs)(`div`,{className:`mx-4 my-2`,children:[(0,$.jsx)(jr,{variant:`error`,className:`mb-0`,children:p}),(0,$.jsx)(`button`,{type:`button`,className:q(J.compact,`mt-1 text-destructive underline underline-offset-2 hover:text-destructive/80`),onClick:m,children:`Dismiss`})]}),t[15]=p,t[16]=m,t[17]=b):b=t[17];let x;return t[18]!==_||t[19]!==v||t[20]!==y||t[21]!==b?(x=(0,$.jsxs)(`div`,{className:`mx-auto max-w-3xl w-full min-w-0`,style:_,children:[v,y,b]}),t[18]=_,t[19]=v,t[20]=y,t[21]=b,t[22]=x):x=t[22],x}var uc={List:cc,Footer:lc};function dc(e){if(e.isUser)return e.hasCheckpointRef?e.isStreaming||e.hasPendingMessage||e.isCreatingProject||e.isProcessingThread?`Restore unavailable while this thread is still processing.`:`Restore checkpoint`:`Restore unavailable: no checkpoint was created for this prompt.`}function fc(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n.type===`long_running_confirmation`||n.type===`shell_permission`||n.type===`web_fetch_permission`)return t}return-1}function pc(e){let t=e.some(e=>e.type!==`long_running_confirmation`&&e.type!==`shell_permission`&&e.type!==`web_fetch_permission`&&`chunks`in e&&e.chunks.some(e=>e.includes(`"type":"tool_use"`)&&e.includes(`"name":"ask_user"`))),n=e.some(e=>e.type!==`long_running_confirmation`&&e.type!==`shell_permission`&&e.type!==`web_fetch_permission`&&`chunks`in e&&e.chunks.some(e=>e.includes(`"type":"tool-result"`)&&e.includes(`"toolName":"ask_user"`)));if(t&&!n)return!0;let r=fc(e);return r===-1?!1:!e.slice(r+1).some(e=>e.type===`content`||e.type===`thinking`?e.chunks.some(e=>e.trim().length>0):!1)}var mc=(0,Y.forwardRef)(function(e,t){let n=(0,X.c)(71),{bottomInset:r,messages:i,isStreaming:a,streamingSegments:o,streamingModel:s,isCreatingProject:c,isProcessingThread:l,hasPendingMessage:u,selectedThreadId:d,selectedProjectId:f,projects:p,projectsLoading:m,messagesLoaded:h,onSelectThread:g,onCreateThread:_,onConnectRepo:v,onNewApp:y,onOpenFolder:b,error:x,onClearError:S,onAtBottomChange:C}=e,w=r===void 0?0:r,T=(0,Y.useRef)(null),E=(0,Y.useRef)(0),D=(0,Y.useRef)(!1),O=(0,Y.useRef)(!1),k;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(k=()=>({scrollToBottom:()=>{T.current?.scrollTo({top:2**53-1,behavior:`smooth`})}}),n[0]=k):k=n[0],(0,Y.useImperativeHandle)(t,k);let A;n[1]===d?A=n[2]:(A=()=>{d&&T.current?.getState(e=>{Tt(d,e.scrollTop)})},n[1]=d,n[2]=A);let j=A,M,N;n[3]===j?(M=n[4],N=n[5]):(M=()=>{let e=()=>{j()};return window.addEventListener(`beforeunload`,e),()=>{window.removeEventListener(`beforeunload`,e),j()}},N=[j],n[3]=j,n[4]=M,n[5]=N),(0,Y.useEffect)(M,N);let P,F;n[6]===j?(P=n[7],F=n[8]):(P=()=>{let e=setInterval(()=>{j()},5e3);return()=>clearInterval(e)},F=[j],n[6]=j,n[7]=P,n[8]=F),(0,Y.useEffect)(P,F);let I,L;n[9]!==i.length||n[10]!==h||n[11]!==d?(I=()=>{if(!d||!h||O.current||(O.current=!0,i.length===0))return;let e=rn(d);e!==null&&e>0&&requestAnimationFrame(()=>{T.current?.scrollTo({top:e})})},L=[d,h,i.length],n[9]=i.length,n[10]=h,n[11]=d,n[12]=I,n[13]=L):(I=n[12],L=n[13]),(0,Y.useEffect)(I,L);let R;n[14]===Symbol.for(`react.memo_cache_sentinel`)?(R=()=>{O.current=!1,E.current=0},n[14]=R):R=n[14];let ee;n[15]===d?ee=n[16]:(ee=[d],n[15]=d,n[16]=ee),(0,Y.useEffect)(R,ee);let z;n[17]!==u||n[18]!==a||n[19]!==i.length?(z=()=>{if(!O.current)return;let e=i.length>E.current,t=D.current&&!a;(a||u||e||t)&&requestAnimationFrame(()=>{T.current?.scrollTo({top:2**53-1,behavior:`smooth`})}),E.current=i.length,D.current=a},n[17]=u,n[18]=a,n[19]=i.length,n[20]=z):z=n[20];let te;n[21]!==u||n[22]!==a||n[23]!==i||n[24]!==o.length?(te=[a,u,i,o.length],n[21]=u,n[22]=a,n[23]=i,n[24]=o.length,n[25]=te):te=n[25],(0,Y.useEffect)(z,te);let ne=i.length===0&&!a&&!c&&!d,re=h&&i.length===0&&!a&&!c&&!l&&!u&&d,B;if(n[26]!==p||n[27]!==f){let e;n[29]===f?e=n[30]:(e=e=>e.projectId===f,n[29]=f,n[30]=e),B=p.find(e),n[26]=p,n[27]=f,n[28]=B}else B=n[28];let ie=B;if(ne){let e=`transition-opacity duration-500 ease-in-out ${m?`opacity-0`:`opacity-100`}`,t;n[31]!==v||n[32]!==_||n[33]!==y||n[34]!==b||n[35]!==g||n[36]!==p?(t=(0,$.jsx)(rc,{projects:p,onSelectProject:g,onCreateThread:_,onConnectRepo:v,onNewApp:y,onOpenFolder:b}),n[31]=v,n[32]=_,n[33]=y,n[34]=b,n[35]=g,n[36]=p,n[37]=t):t=n[37];let r;return n[38]!==e||n[39]!==t?(r=(0,$.jsx)(`div`,{className:`flex-1 flex flex-col items-center justify-center`,children:(0,$.jsx)(`div`,{className:e,children:t})}),n[38]=e,n[39]=t,n[40]=r):r=n[40],r}if(re){let e;return n[41]===ie?e=n[42]:(e=(0,$.jsx)(oc,{project:ie}),n[41]=ie,n[42]=e),e}let V;n[43]===o?V=n[44]:(V=pc(o),n[43]=o,n[44]=V);let ae;n[45]!==w||n[46]!==x||n[47]!==u||n[48]!==c||n[49]!==l||n[50]!==a||n[51]!==i.length||n[52]!==S||n[53]!==f||n[54]!==s||n[55]!==o||n[56]!==V?(ae={bottomInset:w,isStreaming:a,isCreatingProject:c,isProcessingThread:l,hasPendingMessage:u,hasActiveBlockingPrompt:V,selectedProjectId:f,streamingSegments:o,streamingModel:s,totalMessages:i.length,error:x,onClearError:S},n[45]=w,n[46]=x,n[47]=u,n[48]=c,n[49]=l,n[50]=a,n[51]=i.length,n[52]=S,n[53]=f,n[54]=s,n[55]=o,n[56]=V,n[57]=ae):ae=n[57];let H=ae,oe;n[58]===Symbol.for(`react.memo_cache_sentinel`)?(oe=q(`h-full overflow-hidden`),n[58]=oe):oe=n[58];let se;n[59]===Symbol.for(`react.memo_cache_sentinel`)?(se={height:`100%`},n[59]=se):se=n[59];let ce;n[60]!==u||n[61]!==c||n[62]!==l||n[63]!==a||n[64]!==d?(ce=(e,t)=>{let n=dc({isUser:t.sender===`user`,hasCheckpointRef:!!t.checkpointRef,isStreaming:a,hasPendingMessage:u,isCreatingProject:c,isProcessingThread:l});return(0,$.jsx)(qs,{message:t,threadId:d,messageIndex:e,showCheckpointRestore:t.sender===`user`&&!!t.checkpointRef&&!a&&!u&&!c&&!l,checkpointRestoreTooltip:n})},n[60]=u,n[61]=c,n[62]=l,n[63]=a,n[64]=d,n[65]=ce):ce=n[65];let le;return n[66]!==H||n[67]!==i||n[68]!==C||n[69]!==ce?(le=(0,$.jsx)(`div`,{className:oe,children:(0,$.jsx)(or,{ref:T,style:se,data:i,context:H,itemContent:ce,overscan:500,components:uc,atBottomStateChange:C})}),n[66]=H,n[67]=i,n[68]=C,n[69]=ce,n[70]=le):le=n[70],le});function hc(e,t){return e?`linear-gradient(to right, transparent 0, transparent 40px, ${t} 40px)`:`linear-gradient(to right, ${t}, ${t})`}function gc(e){return hc(e,`hsl(var(--background))`)}function _c(e){let t=hc(e,`hsl(var(--background))`);return e?`linear-gradient(to top, hsl(var(--background)) 0, hsl(var(--background)) calc(100% - 40px), transparent calc(100% - 40px), transparent 100%), ${t}`:`linear-gradient(to top, hsl(var(--background)) 0, transparent 100%), ${t}`}function vc(e,t){return hc(e,t?`hsl(var(--background) / 0.8)`:`hsl(var(--background))`)}function yc({initialValue:e}={}){let t=vi(),n=Q(e=>e.selectedThreadId),r=Q(e=>e.selectedProjectId),i=Q(e=>e.projects),a=Q(e=>e.projectModelSelections),o=Q(e=>e.chatInputDrafts),s=Q(e=>e.configUpdatedAt),c=Q(e=>e.focusChatInput),l=Q(e=>e.isStreaming),[u,d]=(0,Y.useState)(()=>n&&o[n]?o[n]:e??``),[f,p]=(0,Y.useState)(-1),[m,h]=(0,Y.useState)(``),[g,_]=(0,Y.useState)(0),v=(0,Y.useRef)(u);(0,Y.useEffect)(()=>{v.current=u},[u]);let y=(0,Y.useRef)(o);(0,Y.useEffect)(()=>{y.current=o},[o]);let b=(0,Y.useRef)(!0);(0,Y.useEffect)(()=>(b.current=!0,()=>{b.current=!1}),[]);let[x,S]=(0,Y.useState)([]),[C,w]=(0,Y.useState)(()=>(n?a[n]:void 0)??null),T=(0,Y.useRef)(C?.id??``),E=(0,Y.useRef)(C?.provider??``),D=(0,Y.useRef)(null),[O,k]=(0,Y.useState)(!1),[A,j]=(0,Y.useState)(!1),[M,N]=(0,Y.useState)([]),[P,F]=(0,Y.useState)(!1),[I,L]=(0,Y.useState)(!1),[R,ee]=(0,Y.useState)(!1),[z,te]=(0,Y.useState)([]),[ne,re]=(0,Y.useState)(null),[B,ie]=(0,Y.useState)([]),[V,ae]=(0,Y.useState)(!1),[H,se]=(0,Y.useState)(``),[ce,le]=(0,Y.useState)(0),[ue,fe]=(0,Y.useState)([]),[pe,me]=(0,Y.useState)([]),[he,ge]=(0,Y.useState)(!1),[_e,ve]=(0,Y.useState)(``),ye=(0,Y.useRef)(null),be=(0,Y.useRef)(null),xe=(0,Y.useRef)(null),Se=(0,Y.useRef)(null),Ce=(0,Y.useRef)(null),we=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{T.current=C?.id??``,E.current=C?.provider??``},[C?.id,C?.provider]);let Te=(0,Y.useCallback)((e,r)=>{w(e);let i=n;if(!i||(t({type:Z.SetProjectModel,threadId:i,model:e}),r?.persist===!1))return;let a=`${i}:${e.provider??``}:${e.id}`;D.current!==a&&(D.current=a,console.log(`[useChatInputState] Persisting model to thread:`,{threadId:i,model:{id:e.id,provider:e.provider}}),xt(i,{model:e.id,modelProvider:e.provider}).then(()=>{D.current===a&&(D.current=null),console.log(`[useChatInputState] Model persisted successfully`)}).catch(e=>{D.current===a&&(D.current=null),console.error(`Failed to save model to thread:`,e)}))},[n,t]);(0,Y.useEffect)(()=>{(async()=>{let e=r?i.find(e=>e.projectId===r)?.threads.find(e=>e.threadId===n):void 0,t=n?a[n]:void 0,o=e?.model??t?.id??null,s=e?.modelProvider??t?.provider??null;console.log(`[useChatInputState] Loading models for thread:`,{threadId:n,projectId:r,currentThread:e?{model:e.model,modelProvider:e.modelProvider}:void 0,storedModel:t?{id:t.id,provider:t.provider}:void 0,savedModelId:o,savedModelProvider:s});try{let e=await de(),t=Object.values(e).flat();if(t.length===0){S([]),w(null);return}S(t);let n=o&&s?t.find(e=>e.id===o&&e.provider===s)??null:null,r=t[0],i=n??r,a=!n&&!!(o||s),c=T.current===i.id&&E.current===i.provider;console.log(`[useChatInputState] Model selection decision:`,{matchedSavedModel:n?{id:n.id}:null,fallbackModel:{id:r.id},modelToSelect:{id:i.id},shouldPersistFallback:a,hasSameSelection:c,currentSelected:{id:T.current,provider:E.current}}),c||Te(i,{persist:a})}catch(e){console.error(`Failed to load enabled models:`,e)}})()},[n,r,i,a,Te]);let Ee=(0,Y.useRef)(Te);(0,Y.useEffect)(()=>{Ee.current=Te},[Te]),(0,Y.useEffect)(()=>{s!==0&&(async()=>{try{let e=await de(),t=Object.values(e).flat();if(t.length>0){S(t);let e=T.current,n=E.current;t.some(t=>t.id===e&&t.provider===n)||Ee.current(t[0],{persist:!0})}}catch(e){console.error(`Failed to reload enabled models:`,e)}})()},[s]),(0,Y.useEffect)(()=>{!R||z.length>0||(async()=>{try{let e=await Re(),t=Object.values(e).flat();t.length>0&&(te(t),re(e=>e??t[0]))}catch(e){console.error(`Failed to load image models:`,e)}})()},[R,z.length]);let[De,Oe]=(0,Y.useState)(n);(0,Y.useEffect)(()=>{if(n!==De){De&&v.current.trim()&&y.current[De]!==v.current&&t({type:Z.SetChatInputDraft,threadId:De,draft:v.current});let e=!1;return queueMicrotask(()=>{e||!b.current||(Oe(n),d(n?y.current[n]??``:``),ie([]),ae(!1),fe([]),me([]),ge(!1),F(!1),ee(!1),L(!1))}),()=>{e=!0}}},[n,De]),(0,Y.useEffect)(()=>{n&&oe(n).then(({commands:e,skills:t})=>{console.log(`Loaded slash commands:`,e,`skills:`,t),fe(e),me(t)}).catch(e=>console.error(`Failed to load slash commands and skills:`,e))},[n]);let ke=n?o[n]??``:``;return(0,Y.useEffect)(()=>{n&&d(ke)},[n,ke]),(0,Y.useLayoutEffect)(()=>{let e=be.current;if(!e)return;e.style.height=`auto`;let t=Math.max(e.scrollHeight,e.offsetHeight);e.style.height=`${Math.min(t,160)}px`},[u]),(0,Y.useEffect)(()=>{c&&n&&!l&&(be.current?.focus(),t({type:Z.ClearFocusChatInput}))},[c,n,l,t]),(0,Y.useEffect)(()=>{let e=n;return()=>{e&&v.current.trim()&&y.current[e]!==v.current&&t({type:Z.SetChatInputDraft,threadId:e,draft:v.current})}},[n,t]),(0,Y.useEffect)(()=>{let e=e=>{xe.current&&!xe.current.contains(e.target)&&k(!1),Se.current&&!Se.current.contains(e.target)&&j(!1)};if(O||A)return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[O,A]),{message:u,setMessage:d,historyIndex:f,setHistoryIndex:p,draftMessage:m,setDraftMessage:h,cursorPosition:g,setCursorPosition:_,availableModels:x,setAvailableModels:S,selectedModel:C,setSelectedModel:Te,selectedModelIdRef:T,showModelMenu:O,setShowModelMenu:k,showPlusMenu:A,setShowPlusMenu:j,attachments:M,setAttachments:N,planMode:P,setPlanMode:F,ralphMode:I,setRalphMode:L,imageMode:R,setImageMode:ee,availableImageModels:z,setAvailableImageModels:te,selectedImageModel:ne,setSelectedImageModel:re,allFiles:B,setAllFiles:ie,showSuggestions:V,setShowSuggestions:ae,suggestionQuery:H,setSuggestionQuery:se,selectedIndex:ce,setSelectedIndex:le,slashCommands:ue,setSlashCommands:fe,skills:pe,setSkills:me,showCommandSuggestions:he,setShowCommandSuggestions:ge,commandQuery:_e,setCommandQuery:ve,fileInputRef:ye,textareaRef:be,modelMenuRef:xe,plusMenuRef:Se,suggestionsRef:Ce,commandSuggestionsRef:we,handleNewChat:async()=>{if(n)try{let e=await st(n);t({type:Z.ClearMessages}),console.log(`New conversation started:`,e);let r=await it(n);t({type:Z.SetMessages,messages:r.messages})}catch(e){console.error(`Failed to start new chat:`,e)}},selectedThreadId:n,dispatch:t}}var bc=e=>{M(e)};function xc(e){let t=(0,X.c)(107),{message:n,setMessage:r,userTasks:i,onMatchedUserTaskSend:a,attachments:o,selectedModel:s,onSend:c,isStreaming:l,selectedThreadId:u,isListening:d,stopListening:f,resetTranscript:p,dispatch:m,historyIndex:h,setHistoryIndex:g,draftMessage:_,setDraftMessage:v,cursorPosition:y,setCursorPosition:b,showSuggestions:x,setShowSuggestions:S,suggestionQuery:C,setSuggestionQuery:w,allFiles:T,setAllFiles:E,selectedIndex:D,setSelectedIndex:O,showCommandSuggestions:k,setShowCommandSuggestions:A,commandQuery:j,setCommandQuery:M,slashCommands:N,skills:P,textareaRef:F,setAttachments:I,planMode:L,setPlanMode:R,ralphMode:ee,setRalphMode:z,imageMode:ne,setImageMode:re,selectedImageModel:B,hasConversationMessages:ie}=e,V;t[0]!==o||t[1]!==m||t[2]!==ne||t[3]!==d||t[4]!==l||t[5]!==n||t[6]!==a||t[7]!==c||t[8]!==L||t[9]!==ee||t[10]!==p||t[11]!==B||t[12]!==s||t[13]!==u||t[14]!==I||t[15]!==v||t[16]!==g||t[17]!==r||t[18]!==f||t[19]!==F||t[20]!==i?(V=()=>{if(!n.trim()&&o.length===0||!u)return;let e=ne?B:s;if(!e)return;d&&(f(),p()),l?m({type:Z.EnqueueChatMessage,message:{id:`queued-${Date.now()}`,threadId:u,message:n,model:e.id,attachments:o,provider:e.provider,planMode:L,imageMode:ne,ralphMode:ee}}):c(n,e.id,o,e.provider,L,ne,ee);let t=n,h=i.find(e=>e.content===t);bc(n),r(``),I([]),h&&a?.(h),g(-1),v(``),u&&m({type:Z.ClearChatInputDraft,threadId:u}),F.current&&(F.current.style.height=`auto`)},t[0]=o,t[1]=m,t[2]=ne,t[3]=d,t[4]=l,t[5]=n,t[6]=a,t[7]=c,t[8]=L,t[9]=ee,t[10]=p,t[11]=B,t[12]=s,t[13]=u,t[14]=I,t[15]=v,t[16]=g,t[17]=r,t[18]=f,t[19]=F,t[20]=i,t[21]=V):V=t[21];let ae=V,H;t[22]!==y||t[23]!==n||t[24]!==r||t[25]!==S||t[26]!==C||t[27]!==F?(H=e=>{let t=n.substring(0,y-C.length-1);r(`${t}${e} ${n.substring(y)}`),S(!1),setTimeout(()=>{if(F.current){F.current.focus();let n=t.length+e.length+1;F.current.setSelectionRange(n,n)}},0)},t[22]=y,t[23]=n,t[24]=r,t[25]=S,t[26]=C,t[27]=F,t[28]=H):H=t[28];let oe=H,se;t[29]!==j||t[30]!==y||t[31]!==n||t[32]!==re||t[33]!==r||t[34]!==R||t[35]!==z||t[36]!==A||t[37]!==F?(se=e=>{let t=e.metadata.action===`compact`?`/compact`:e.content,i=n.substring(0,y-j.length-1);r(`${i}${t}${n.substring(y)}`),A(!1),setTimeout(()=>{if(F.current){F.current.focus();let e=i.length+t.length;F.current.setSelectionRange(e,e)}},0),e.metadata.mode===`plan`?(R(!0),z(!1),re(!1)):e.metadata.mode===`ralph`&&(z(!0),R(!1),re(!1))},t[29]=j,t[30]=y,t[31]=n,t[32]=re,t[33]=r,t[34]=R,t[35]=z,t[36]=A,t[37]=F,t[38]=se):se=t[38];let ce=se,le;t[39]!==j||t[40]!==y||t[41]!==n||t[42]!==r||t[43]!==A||t[44]!==F?(le=e=>{let t=n.substring(0,y-j.length-1),i=n.substring(y),a=e.name.includes(` `)?`/"${e.name}"`:`/${e.name}`;r(`${t}${a}${i}`),A(!1),setTimeout(()=>{if(F.current){F.current.focus();let e=t.length+a.length;F.current.setSelectionRange(e,e)}},0)},t[39]=j,t[40]=y,t[41]=n,t[42]=r,t[43]=A,t[44]=F,t[45]=le):le=t[45];let ue=le,de,fe,pe,he;if(t[46]!==T||t[47]!==j||t[48]!==_||t[49]!==ae||t[50]!==ie||t[51]!==h||t[52]!==ce||t[53]!==oe||t[54]!==ue||t[55]!==n||t[56]!==D||t[57]!==u||t[58]!==E||t[59]!==M||t[60]!==b||t[61]!==v||t[62]!==g||t[63]!==r||t[64]!==O||t[65]!==A||t[66]!==S||t[67]!==w||t[68]!==k||t[69]!==x||t[70]!==P||t[71]!==N||t[72]!==C){pe=e=>{if(k){if(e.key===`ArrowDown`){e.preventDefault(),O((D+1)%de.length);return}if(e.key===`ArrowUp`){e.preventDefault(),O((D-1+de.length)%de.length);return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault();let t=de[D];t&&(t.type===`command`?ce(t.data):ue(t.data));return}if(e.key===`Escape`){A(!1);return}}if(x){let t=fe.length>0;if(e.key===`ArrowDown`&&t){e.preventDefault(),O((D+1)%fe.length);return}if(e.key===`ArrowUp`&&t){e.preventDefault(),O((D-1+fe.length)%fe.length);return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault(),fe[D]&&oe(fe[D]);return}if(e.key===`Escape`){S(!1);return}}if(e.key===`Enter`&&!e.shiftKey){e.preventDefault(),ae();return}let t=me();t.length!==0&&(e.key===`ArrowUp`?(e.preventDefault(),h===-1?(v(n),g(t.length-1),r(t[t.length-1])):h>0&&(g(h-1),r(t[h-1]))):e.key===`ArrowDown`&&(e.preventDefault(),h>0?(g(h-1),r(t[h-1])):h===0&&(g(-1),r(_))))};let e;t[77]!==T||t[78]!==u||t[79]!==E||t[80]!==M||t[81]!==b||t[82]!==r||t[83]!==O||t[84]!==A||t[85]!==S||t[86]!==w?(e=e=>{let t=e.target.value,n=e.target.selectionStart;r(t),b(n);let i=t.substring(0,n),a=i.lastIndexOf(`/`);if(a!==-1){let e=a>0?i[a-1]:``;if(a===0||/\s/.test(e)){let e=i.substring(a+1);e.includes(` `)?A(!1):(M(e),A(!0),S(!1),O(0))}else A(!1)}else{A(!1);let e=i.lastIndexOf(`#`);if(e!==-1){let t=e>0?i[e-1]:``;if(e===0||/\s/.test(t)){let t=i.substring(e+1);t.includes(` `)?S(!1):(w(t),S(!0),O(0),T.length===0&&u&&te(u).then(e=>{E(e)}).catch(wc))}else S(!1)}else S(!1)}let o=e.target;o.style.height=`auto`,o.style.height=`${Math.min(o.scrollHeight,160)}px`},t[77]=T,t[78]=u,t[79]=E,t[80]=M,t[81]=b,t[82]=r,t[83]=O,t[84]=A,t[85]=S,t[86]=w,t[87]=e):e=t[87],he=e;let i;if(t[88]!==j||t[89]!==ie||t[90]!==P||t[91]!==N){let e;t[93]!==j||t[94]!==ie?(e=e=>e.metadata.action===`compact`&&!ie?!1:e.name.toLowerCase().includes(j.toLowerCase()),t[93]=j,t[94]=ie,t[95]=e):e=t[95];let n=N.filter(e),r;t[96]===j?r=t[97]:(r=e=>e.name.toLowerCase().includes(j.toLowerCase()),t[96]=j,t[97]=r);let a=P.filter(r);i=[...n.map(Cc),...a.map(Sc)],t[88]=j,t[89]=ie,t[90]=P,t[91]=N,t[92]=i}else i=t[92];de=i.slice(0,10),fe=x?T.filter(e=>e.toLowerCase().includes(C.toLowerCase())).slice(0,10):[],t[46]=T,t[47]=j,t[48]=_,t[49]=ae,t[50]=ie,t[51]=h,t[52]=ce,t[53]=oe,t[54]=ue,t[55]=n,t[56]=D,t[57]=u,t[58]=E,t[59]=M,t[60]=b,t[61]=v,t[62]=g,t[63]=r,t[64]=O,t[65]=A,t[66]=S,t[67]=w,t[68]=k,t[69]=x,t[70]=P,t[71]=N,t[72]=C,t[73]=de,t[74]=fe,t[75]=pe,t[76]=he}else de=t[73],fe=t[74],pe=t[75],he=t[76];let ge;return t[98]!==de||t[99]!==fe||t[100]!==pe||t[101]!==ae||t[102]!==he||t[103]!==ce||t[104]!==oe||t[105]!==ue?(ge={handleSend:ae,handleKeyDown:pe,handleTextareaInput:he,insertFileReference:oe,insertCommand:ce,insertSkill:ue,allSuggestions:de,fileSuggestions:fe},t[98]=de,t[99]=fe,t[100]=pe,t[101]=ae,t[102]=he,t[103]=ce,t[104]=oe,t[105]=ue,t[106]=ge):ge=t[106],ge}function Sc(e){return{type:`skill`,data:e}}function Cc(e){return{type:`command`,data:e}}function wc(e){return console.error(`Failed to fetch files:`,e)}var Tc=768;function Ec(){let e=(0,X.c)(2),[t,n]=Y.useState(Dc),r,i;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{let e=window.matchMedia(`(max-width: ${Tc-1}px)`),t=()=>{n(window.innerWidth<Tc)};return e.addEventListener(`change`,t),n(window.innerWidth<Tc),()=>e.removeEventListener(`change`,t)},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),Y.useEffect(r,i),t}function Dc(){return typeof window>`u`?!1:window.innerWidth<Tc}function Oc(e){let t=(0,X.c)(22),{visible:n,commands:r,skills:i,query:a,selectedIndex:o,onSelectCommand:s,onSelectSkill:c,onMouseEnterSuggestion:l,containerRef:u}=e;if(!n)return null;let d;if(t[0]!==r||t[1]!==a||t[2]!==i){let e;t[4]===a?e=t[5]:(e=e=>e.name.toLowerCase().includes(a.toLowerCase()),t[4]=a,t[5]=e);let n=r.filter(e),o;t[6]===a?o=t[7]:(o=e=>e.name.toLowerCase().includes(a.toLowerCase()),t[6]=a,t[7]=o);let s=i.filter(o);d=[...n.map(Ac),...s.map(kc)].slice(0,10),t[0]=r,t[1]=a,t[2]=i,t[3]=d}else d=t[3];let f=d,p,m;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(p=q(J.dropdownGroupHeading,`px-2 py-1.5 border-b border-border/50 mb-1 flex items-center gap-2`),m=(0,$.jsx)(w,{className:`h-3 w-3`}),t[8]=p,t[9]=m):(p=t[8],m=t[9]);let h=a&&` matching "${a}"`,g;t[10]===h?g=t[11]:(g=(0,$.jsxs)(`div`,{className:p,children:[m,`Commands & Skills`,h]}),t[10]=h,t[11]=g);let _;t[12]!==f||t[13]!==l||t[14]!==s||t[15]!==c||t[16]!==o?(_=f.length>0?f.map((e,t)=>{let n=t===o;if(e.type===`command`){let r=e.data;return(0,$.jsxs)(`button`,{type:`button`,className:q(`flex w-full flex-col gap-1 rounded-lg px-3 py-2 text-left transition-colors`,n?`bg-accent text-accent-foreground`:`text-popover-foreground hover:bg-accent/50`),onClick:()=>s(r),onMouseEnter:()=>l(t),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(w,{className:`h-3 w-3 text-muted-foreground`}),(0,$.jsxs)(`span`,{className:`font-medium`,children:[`/`,r.name]}),r.metadata.argumentHint&&(0,$.jsx)(`span`,{className:J.compact,children:r.metadata.argumentHint}),r.scope===`project`&&(0,$.jsx)(`span`,{className:q(J.compact,`ml-auto rounded-full bg-primary/10 px-1.5 py-0.5 text-primary`),children:`project`})]}),r.metadata.description&&(0,$.jsx)(`span`,{className:J.compact,children:r.metadata.description})]},`cmd-${r.name}`)}else{let r=e.data;return(0,$.jsxs)(`button`,{type:`button`,className:q(`flex w-full flex-col gap-1 rounded-lg px-3 py-2 text-left transition-colors`,n?`bg-accent text-accent-foreground`:`text-popover-foreground hover:bg-accent/50`),onClick:()=>c(r),onMouseEnter:()=>l(t),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(b,{className:`h-3 w-3 text-amber-500`}),(0,$.jsxs)(`span`,{className:`font-medium`,children:[`/`,r.name]}),(0,$.jsx)(`span`,{className:q(J.compact,`ml-auto rounded-full bg-amber-500/10 px-1.5 py-0.5 text-amber-700 dark:text-amber-400`),children:`skill`}),r.scope===`project`&&(0,$.jsx)(`span`,{className:q(J.compact,`rounded-full bg-primary/10 px-1.5 py-0.5 text-primary`),children:`project`})]}),(0,$.jsx)(`span`,{className:J.compact,children:r.description})]},`skill-${r.name}`)}}):(0,$.jsxs)(`div`,{className:q(J.compact,`px-3 py-4 text-center text-muted-foreground`),children:[`No commands or skills found.`,(0,$.jsx)(`br`,{}),(0,$.jsxs)(`span`,{className:J.compact,children:[`Create commands in `,(0,$.jsx)(`code`,{className:`bg-muted px-1 rounded`,children:`.agents/commands/`}),` or skills in `,(0,$.jsx)(`code`,{className:`bg-muted px-1 rounded`,children:`.agents/skills/`})]})]}),t[12]=f,t[13]=l,t[14]=s,t[15]=c,t[16]=o,t[17]=_):_=t[17];let v;return t[18]!==u||t[19]!==g||t[20]!==_?(v=(0,$.jsxs)(`div`,{ref:u,className:`absolute bottom-full left-0 mb-2 w-full max-h-64 overflow-y-auto rounded-xl border border-border bg-popover p-1 shadow-lg z-50 animate-in fade-in slide-in-from-bottom-2`,children:[g,_]}),t[18]=u,t[19]=g,t[20]=_,t[21]=v):v=t[21],v}function kc(e){return{type:`skill`,data:e}}function Ac(e){return{type:`command`,data:e}}function jc(e){return e.startsWith(`image/`)}function Mc(e){let t=(0,X.c)(7),{attachments:n,onRemove:r}=e;if(n.length===0)return null;let i;if(t[0]!==n||t[1]!==r){let e;t[3]===r?e=t[4]:(e=(e,t)=>(0,$.jsx)(`div`,{className:q(J.compact,`group relative flex items-center gap-1 rounded-md bg-muted text-muted-foreground`),children:jc(e.mimeType)?(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.content}`,alt:e.fileName,className:`h-16 w-16 rounded-md object-cover`}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>r(t),className:`absolute -right-1.5 -top-1.5 flex h-4 w-4 items-center justify-center rounded-full bg-foreground text-background opacity-0 transition-opacity group-hover:opacity-100`,children:[(0,$.jsx)(A,{className:`h-2.5 w-2.5`}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Remove attachment`})]})]}):(0,$.jsxs)(`span`,{className:`flex items-center gap-1 px-2 py-1`,children:[(0,$.jsx)(Ot,{className:`h-3 w-3`}),e.fileName,(0,$.jsxs)(`button`,{type:`button`,onClick:()=>r(t),className:`ml-1 hover:text-foreground`,children:[(0,$.jsx)(A,{className:`h-3 w-3`}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Remove attachment`})]})]})},t),t[3]=r,t[4]=e),i=n.map(e),t[0]=n,t[1]=r,t[2]=i}else i=t[2];let a;return t[5]===i?a=t[6]:(a=(0,$.jsx)(`div`,{className:`mb-2 flex flex-wrap gap-1.5`,children:i}),t[5]=i,t[6]=a),a}function Nc(e,t){let n=e.target.files;if(!n||n.length===0)return;let r=Array.from(n),i=r.length,a=Array.from({length:i}),o=0;e.target.value=``,r.forEach((e,n)=>{let r=new FileReader;r.onload=()=>{let s=r.result.split(`,`)[1];a[n]={fileName:e.name,content:s,mimeType:e.type||`application/octet-stream`},o+=1,o===i&&t(a)},r.readAsDataURL(e)})}function Pc(e){let t=(0,X.c)(17),{showSuggestions:n,fileSuggestions:r,suggestionQuery:i,selectedIndex:a,onSelectFile:o,onMouseEnterSuggestion:s,containerRef:c}=e;if(!n||r.length===0)return null;let l,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=q(J.dropdownGroupHeading,`px-2 py-1.5 border-b border-border/50 mb-1 flex items-center gap-2`),u=(0,$.jsx)(Jt,{className:`h-3 w-3`}),t[0]=l,t[1]=u):(l=t[0],u=t[1]);let d;t[2]===i?d=t[3]:(d=(0,$.jsxs)(`div`,{className:l,children:[u,`Files matching "`,i,`"`]}),t[2]=i,t[3]=d);let f;if(t[4]!==r||t[5]!==s||t[6]!==o||t[7]!==a){let e;t[9]!==s||t[10]!==o||t[11]!==a?(e=(e,t)=>{let n=e.split(`/`).pop()??e,r=t===a;return(0,$.jsxs)(`button`,{type:`button`,className:q(J.body,`flex w-full items-center gap-2 rounded-lg px-3 py-2 text-left transition-colors`,r?`bg-accent text-accent-foreground`:`text-popover-foreground hover:bg-accent/50`),onClick:()=>o(e),onMouseEnter:()=>s(t),children:[e.endsWith(`.ts`)||e.endsWith(`.tsx`)||e.endsWith(`.js`)||e.endsWith(`.jsx`)?(0,$.jsx)(C,{className:`h-4 w-4 text-blue-500`}):(0,$.jsx)(je,{className:`h-4 w-4 text-muted-foreground`}),(0,$.jsxs)(`div`,{className:`flex flex-col overflow-hidden`,children:[(0,$.jsx)(`span`,{className:`truncate font-medium`,children:n}),(0,$.jsx)(`span`,{className:q(J.compact,`truncate text-muted-foreground opacity-70`),children:e})]})]},e)},t[9]=s,t[10]=o,t[11]=a,t[12]=e):e=t[12],f=r.map(e),t[4]=r,t[5]=s,t[6]=o,t[7]=a,t[8]=f}else f=t[8];let p;return t[13]!==c||t[14]!==d||t[15]!==f?(p=(0,$.jsxs)(`div`,{ref:c,className:`absolute bottom-full left-0 mb-2 w-full max-h-64 overflow-y-auto rounded-xl border border-border bg-popover p-1 shadow-lg z-50 animate-in fade-in slide-in-from-bottom-2`,children:[d,f]}),t[13]=c,t[14]=d,t[15]=f,t[16]=p):p=t[16],p}function Fc(e){let t=(0,X.c)(5),{providerSlug:n}=e;if(!n)return null;let r;t[0]===n?r=t[1]:(r=yn(n),t[0]=n,t[1]=r);let i=`${n} logo`,a;return t[2]!==r||t[3]!==i?(a=(0,$.jsx)(`img`,{src:r,alt:i,className:`h-3.5 w-3.5 flex-shrink-0 dark:invert`,onError:Ic}),t[2]=r,t[3]=i,t[4]=a):a=t[4],a}function Ic(e){e.currentTarget.style.visibility=`hidden`}function Lc(e){let t=(0,X.c)(9),{providerSlug:n,providerData:r}=e,i=r?.name??n,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=q(J.dropdownGroupHeading,`flex items-center gap-1.5 px-3 py-1.5 uppercase tracking-wide`),t[0]=a):a=t[0];let o;t[1]===n?o=t[2]:(o=(0,$.jsx)(Fc,{providerSlug:n}),t[1]=n,t[2]=o);let s;t[3]!==i||t[4]!==r?(s=r?.url?(0,$.jsx)(hr,{url:r.url,showIcon:!1,variant:`inline`,children:i}):i,t[3]=i,t[4]=r,t[5]=s):s=t[5];let c;return t[6]!==o||t[7]!==s?(c=(0,$.jsxs)(`div`,{className:a,children:[o,s]}),t[6]=o,t[7]=s,t[8]=c):c=t[8],c}function Rc(e){let t=e.pricing?.prompt;return t==null?null:Math.ceil(t*3)}function zc(e){return`$${$e(e)}`}function Bc(e,t){return e.pricing?(0,$.jsxs)(`div`,{className:`max-w-64 whitespace-normal break-words text-left leading-relaxed`,children:[(0,$.jsx)(`div`,{children:`${zc(e.pricing.prompt??0)} input per million tokens`}),(0,$.jsx)(`div`,{children:`${zc(e.pricing.completion??0)} output per million tokens`}),(0,$.jsx)(`div`,{children:`Displayed value of ${t} is a relative price.`})]}):null}function Vc(e,t){return[...e].sort((e,n)=>{let r=(e.provider??`Other`).localeCompare(n.provider??`Other`);if(r!==0)return r;if(t===`relative-price`){let t=(Rc(e)??2**53-1)-(Rc(n)??2**53-1);if(t!==0)return t}return gr(e.id).localeCompare(gr(n.id))})}function Hc(e){let t=(0,X.c)(37),{availableModels:n,selectedModel:r,onModelSelect:i}=e,[a,o]=Y.useState(!1),[s,c]=Y.useState(`relative-price`),l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=new Map,t[0]=l):l=t[0];let[u,d]=Y.useState(l),f=Y.useRef(null),p,m;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(p=()=>{Te().then(function(e){d(new Map(e.map(Wc)))})},m=[],t[1]=p,t[2]=m):(p=t[1],m=t[2]),Y.useEffect(p,m);let h,g;t[3]===a?(h=t[4],g=t[5]):(h=()=>{let e=e=>{f.current&&!f.current.contains(e.target)&&o(!1)};if(a)return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},g=[a],t[3]=a,t[4]=h,t[5]=g),Y.useEffect(h,g);let _;t[6]===i?_=t[7]:(_=e=>{i(e),o(!1)},t[6]=i,t[7]=_);let v=_,y;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(y=()=>{c(function(e){return e===`relative-price`?`alphabetical`:`relative-price`})},t[8]=y):y=t[8];let b=y,x;t[9]!==n||t[10]!==s?(x=Vc(n,s),t[9]=n,t[10]=s,t[11]=x):x=t[11];let S=x,C=s===`relative-price`?jt:mn,w=s===`relative-price`?`Sort by relative price`:`Sort alphabetically`,T;t[12]===a?T=t[13]:(T=()=>o(!a),t[12]=a,t[13]=T);let E=r?.provider,D;t[14]===E?D=t[15]:(D=(0,$.jsx)(Fc,{providerSlug:E}),t[14]=E,t[15]=D);let O;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(O=q(J.body,`font-normal`),t[16]=O):O=t[16];let k;t[17]===r?k=t[18]:(k=r?gr(r.id):`No model`,t[17]=r,t[18]=k);let A;t[19]===k?A=t[20]:(A=(0,$.jsx)(`span`,{className:O,children:k}),t[19]=k,t[20]=A);let j;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,$.jsx)(Lt,{className:`h-3 w-3`}),t[21]=j):j=t[21];let M;t[22]!==D||t[23]!==A||t[24]!==T?(M=(0,$.jsxs)(U,{variant:`action`,size:`icon-sm`,className:`gap-1 w-auto px-2`,onClick:T,children:[D,A,j]}),t[22]=D,t[23]=A,t[24]=T,t[25]=M):M=t[25];let N;t[26]!==C||t[27]!==v||t[28]!==u||t[29]!==r?.id||t[30]!==a||t[31]!==w||t[32]!==S?(N=a&&(0,$.jsx)(`div`,{className:`absolute bottom-full left-0 mb-1 w-80 max-h-80 overflow-y-auto rounded-lg border border-border bg-popover p-1 shadow-md z-50`,children:(0,$.jsxs)(Mt,{children:[(0,$.jsx)(`div`,{className:`-mb-3 flex justify-end px-1 pb-1`,children:(0,$.jsxs)(W,{children:[(0,$.jsx)(G,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,"aria-label":w,className:`rounded-md p-1 text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground`,onClick:b,children:(0,$.jsx)(C,{className:`h-3.5 w-3.5`})})}),(0,$.jsx)(K,{side:`left`,align:`start`,sideOffset:8,children:w})]})}),Object.entries(S.reduce(Uc,{})).map((e,t)=>{let[n,i]=e;return(0,$.jsxs)(`div`,{children:[t>0&&(0,$.jsx)(mr,{className:`my-1`}),(0,$.jsx)(Lc,{providerSlug:n,providerData:u.get(n)}),i.map(e=>{let t=Rc(e),n=t==null?null:Bc(e,t);return(0,$.jsx)(`div`,{children:(0,$.jsx)(`div`,{children:(0,$.jsxs)(`button`,{type:`button`,className:q(J.body,`flex w-full items-center justify-between gap-3 whitespace-nowrap rounded-md px-3 py-1.5 pl-8 text-popover-foreground hover:bg-accent`,e.id===r?.id&&`bg-accent font-medium`),onClick:()=>v(e),children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:gr(e.id)}),t!=null&&n&&(0,$.jsxs)(W,{children:[(0,$.jsx)(G,{asChild:!0,children:(0,$.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:t})}),(0,$.jsx)(K,{side:`left`,align:`end`,sideOffset:8,className:`max-w-64`,children:n})]})]})})},e.id)})]},n)})]})}),t[26]=C,t[27]=v,t[28]=u,t[29]=r?.id,t[30]=a,t[31]=w,t[32]=S,t[33]=N):N=t[33];let P;return t[34]!==M||t[35]!==N?(P=(0,$.jsxs)(`div`,{className:`relative`,ref:f,children:[M,N]}),t[34]=M,t[35]=N,t[36]=P):P=t[36],P}function Uc(e,t){let n=t.provider??`Other`;return e[n]||(e[n]=[]),e[n].push(t),e}function Wc(e){return[e.slug,e]}var Gc=[{value:`build`,label:`Build`,icon:R},{value:`plan`,label:`Plan`,icon:V},{value:`image`,label:`Image`,icon:a},{value:`ralph`,label:`Ralph`,icon:Xe}];function Kc(e,t,n){return n?`ralph`:e?`plan`:t?`image`:`build`}function qc({planMode:e,imageMode:t,ralphMode:n,setPlanMode:r,setImageMode:i,setRalphMode:a,projectId:o}){let s=vi(),c=Q(function(e){if(o)return e.projects.find(e=>e.projectId===o)}),[l,u]=Y.useState(!0),[d,f]=Y.useState(!1),p=Kc(e,t,n),m=Gc.find(e=>e.value===p);Y.useEffect(()=>{c&&u(c.allowAllCommands===!1)},[c]);async function h(){if(!o||d)return;let e=!l;u(e),f(!0);try{await _n(o,{allowAllCommands:!e}),P(o);let t=await xe();s({type:Z.SetProjects,projects:t.projects})}catch(t){u(!e),console.error(`Failed to update command confirmation setting:`,t)}finally{f(!1)}}function g(e){r(e===`plan`),i(e===`image`),a(e===`ralph`)}return{chatModes:Gc,confirmCommands:l,currentConfig:m,currentMode:p,isUpdatingConfirmCommands:d,selectMode:g,toggleConfirmCommands:h}}function Jc(e){let t=(0,X.c)(37),{planMode:n,imageMode:r,ralphMode:i,setPlanMode:a,setImageMode:o,setRalphMode:s,projectId:c}=e,[l,u]=Y.useState(!1),d=Y.useRef(null),f;t[0]!==r||t[1]!==n||t[2]!==c||t[3]!==i||t[4]!==o||t[5]!==a||t[6]!==s?(f={planMode:n,imageMode:r,ralphMode:i,setPlanMode:a,setImageMode:o,setRalphMode:s,projectId:c},t[0]=r,t[1]=n,t[2]=c,t[3]=i,t[4]=o,t[5]=a,t[6]=s,t[7]=f):f=t[7];let{chatModes:p,confirmCommands:m,currentConfig:h,currentMode:g,isUpdatingConfirmCommands:_,selectMode:v,toggleConfirmCommands:y}=qc(f),b=h.icon,x,S;t[8]===l?(x=t[9],S=t[10]):(x=()=>{let e=function(e){d.current&&!d.current.contains(e.target)&&u(!1)};if(l)return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},S=[l],t[8]=l,t[9]=x,t[10]=S),Y.useEffect(x,S);let C;t[11]===v?C=t[12]:(C=function(e){v(e),u(!1)},t[11]=v,t[12]=C);let w=C,T;t[13]===l?T=t[14]:(T=()=>u(!l),t[13]=l,t[14]=T);let E;t[15]===b?E=t[16]:(E=(0,$.jsx)(b,{className:`h-3.5 w-3.5`}),t[15]=b,t[16]=E);let D;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(D=q(J.body,`font-normal`),t[17]=D):D=t[17];let O;t[18]===h.label?O=t[19]:(O=(0,$.jsx)(`span`,{className:D,children:h.label}),t[18]=h.label,t[19]=O);let k;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,$.jsx)(Lt,{className:`h-3 w-3`}),t[20]=k):k=t[20];let A;t[21]!==T||t[22]!==E||t[23]!==O?(A=(0,$.jsxs)(U,{variant:`action`,size:`icon-sm`,className:`gap-1 w-auto px-2`,onClick:T,children:[E,O,k]}),t[21]=T,t[22]=E,t[23]=O,t[24]=A):A=t[24];let j;t[25]!==p||t[26]!==m||t[27]!==g||t[28]!==w||t[29]!==_||t[30]!==l||t[31]!==c||t[32]!==y?(j=l&&(0,$.jsxs)(`div`,{className:`absolute bottom-full right-0 z-50 mb-1 w-56 rounded-lg border border-border bg-popover p-1 shadow-md`,children:[c&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`button`,{type:`button`,className:q(J.body,`flex w-full items-center gap-2 rounded-md px-3 py-2 text-popover-foreground hover:bg-accent disabled:opacity-50`),onClick:()=>{y()},disabled:_,children:[`Confirm Commands`,m&&(0,$.jsx)(cn,{className:`ml-auto h-3.5 w-3.5`})]}),(0,$.jsx)(`div`,{className:`my-1 h-px bg-border`})]}),p.map(e=>{let t=e.icon,n=e.value===g;return(0,$.jsxs)(`button`,{type:`button`,className:q(J.body,`flex w-full items-center gap-2 rounded-md px-3 py-2 text-popover-foreground hover:bg-accent`),onClick:()=>w(e.value),children:[(0,$.jsx)(t,{className:`h-3.5 w-3.5`}),e.label,n&&(0,$.jsx)(cn,{className:`ml-auto h-3.5 w-3.5`})]},e.value)})]}),t[25]=p,t[26]=m,t[27]=g,t[28]=w,t[29]=_,t[30]=l,t[31]=c,t[32]=y,t[33]=j):j=t[33];let M;return t[34]!==A||t[35]!==j?(M=(0,$.jsxs)(`div`,{className:`relative hidden md:block`,ref:d,children:[A,j]}),t[34]=A,t[35]=j,t[36]=M):M=t[36],M}function Yc(e){let t=(0,X.c)(32),{disabled:n,canAddTask:r,onFileAttach:i,onAddTask:a,showModes:o,planMode:s,imageMode:c,ralphMode:l,setPlanMode:u,setImageMode:d,setRalphMode:p,projectId:m}=e,h=n===void 0?!1:n,g=o===void 0?!1:o,_=s===void 0?!1:s,v=c===void 0?!1:c,y=l===void 0?!1:l,b=u??Qc,x=d??Zc,S=p??Xc,C;t[0]!==v||t[1]!==_||t[2]!==m||t[3]!==y||t[4]!==b||t[5]!==x||t[6]!==S?(C={planMode:_,imageMode:v,ralphMode:y,setPlanMode:b,setImageMode:x,setRalphMode:S,projectId:m},t[0]=v,t[1]=_,t[2]=m,t[3]=y,t[4]=b,t[5]=x,t[6]=S,t[7]=C):C=t[7];let w=qc(C),T;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(T=function(e){e()},t[8]=T):T=t[8];let E=T,D,O;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,$.jsx)(on,{}),O=(0,$.jsx)(`span`,{className:`sr-only`,children:`More options`}),t[9]=D,t[10]=O):(D=t[9],O=t[10]);let k;t[11]===h?k=t[12]:(k=(0,$.jsx)(as,{asChild:!0,children:(0,$.jsxs)(U,{variant:`action`,size:`icon-sm`,disabled:h,children:[D,O]})}),t[11]=h,t[12]=k);let A;t[13]===i?A=t[14]:(A=()=>E(i),t[13]=i,t[14]=A);let j;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,$.jsx)(Ot,{className:`mr-2 h-3.5 w-3.5`}),t[15]=j):j=t[15];let M;t[16]===A?M=t[17]:(M=(0,$.jsxs)(us,{onClick:A,children:[j,`Attach File`]}),t[16]=A,t[17]=M);let N;t[18]!==r||t[19]!==a?(N=r&&(0,$.jsxs)(us,{onClick:()=>E(a),children:[(0,$.jsx)(f,{className:`mr-2 h-3.5 w-3.5`}),`Add to Pending Tasks`]}),t[18]=r,t[19]=a,t[20]=N):N=t[20];let P;t[21]!==w||t[22]!==m||t[23]!==g?(P=g&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ms,{}),m&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(us,{onClick:()=>{w.toggleConfirmCommands()},disabled:w.isUpdatingConfirmCommands,children:[`Confirm Commands`,w.confirmCommands&&(0,$.jsx)(cn,{className:`ml-auto h-3.5 w-3.5`})]}),(0,$.jsx)(ms,{})]}),w.chatModes.map(e=>{let t=e.icon,n=e.value===w.currentMode;return(0,$.jsxs)(us,{onClick:()=>w.selectMode(e.value),className:q(n&&`bg-accent`),children:[(0,$.jsx)(t,{className:`mr-2 h-3.5 w-3.5`}),e.label,n&&(0,$.jsx)(cn,{className:`ml-auto h-3.5 w-3.5`})]},e.value)})]}),t[21]=w,t[22]=m,t[23]=g,t[24]=P):P=t[24];let F;t[25]!==M||t[26]!==N||t[27]!==P?(F=(0,$.jsxs)(ls,{align:`start`,side:`top`,className:`w-56`,children:[M,N,P]}),t[25]=M,t[26]=N,t[27]=P,t[28]=F):F=t[28];let I;return t[29]!==k||t[30]!==F?(I=(0,$.jsxs)(is,{children:[k,F]}),t[29]=k,t[30]=F,t[31]=I):I=t[31],I}function Xc(){}function Zc(){}function Qc(){}var $c=Nr(`useWebSpeech`);function el(e){switch(e){case`not-allowed`:return`Microphone access was denied. Please allow microphone access to use voice input.`;case`service-not-allowed`:return`Speech recognition is not allowed in this environment.`;case`audio-capture`:return`No microphone was found. Please connect a microphone to use voice input.`;case`network`:return`Speech recognition requires a network connection.`;case`no-speech`:case`aborted`:return null;default:return`Speech recognition error: ${e}`}}function tl(e){let t=``;for(let n=0;n<e.results.length;n+=1)t+=e.results[n][0]?.transcript??``;return t}function nl(){let[e,t]=(0,Y.useState)(`idle`),[n,r]=(0,Y.useState)(null),[i,a]=(0,Y.useState)(``),[o,s]=(0,Y.useState)(null),c=(0,Y.useRef)(null),l=(0,Y.useRef)(!1);(0,Y.useEffect)(()=>()=>{l.current=!1,c.current?.abort(),c.current=null},[]);let u=(0,Y.useCallback)(()=>{let e=Mr();if(!e){l.current=!1,t(`error`),r(!1),s(`Speech recognition is not supported in this environment.`);return}e.continuous=!0,e.interimResults=!0,e.lang=`en-US`,e.onresult=e=>{let t=tl(e).trim();t&&a(t)},e.onerror=e=>{let t=el(e.error);$c.error(`Web Speech recognition error`,{error:e.error,message:e.message}),t&&s(t)},e.onend=()=>{if(c.current=null,!l.current){t(`ready`);return}$c.info(`Web Speech recognition ended — restarting`),u()},c.current=e;try{e.start(),t(`recording`),$c.info(`Web Speech recognition started`)}catch(e){c.current=null,l.current=!1;let n=e instanceof Error?e.message:`Unknown error`;$c.error(`Failed to start Web Speech recognition`,{error:n}),t(`ready`),s(`Failed to start speech recognition: ${n}`)}},[]),d=(0,Y.useCallback)(async()=>{if(e===`ready`||e===`error`)return e;t(`checking-support`),s(null),$c.info(`Checking Web Speech API support`,{userAgent:navigator.userAgent,platform:navigator.platform});let n=Fr();return r(n),n?($c.info(`Web Speech API available — ready`),t(`ready`),`ready`):($c.error(`Web Speech API not available`),t(`error`),s(`Speech recognition is not supported in this environment.`),`error`)},[e]);return{state:e,isSupported:n,transcript:i,error:o,downloadProgress:0,startListening:(0,Y.useCallback)(async()=>{l.current=!0,s(null),a(``),$c.info(`Starting Web Speech recognition`),u()},[u]),stopListening:(0,Y.useCallback)(async()=>{l.current=!1,c.current?.stop(),c.current=null,t(`ready`),$c.info(`Web Speech recognition stopped`)},[]),requestModelDownload:(0,Y.useCallback)(async()=>{},[]),ensureReady:d,resetTranscript:(0,Y.useCallback)(()=>{a(``),s(null)},[])}}var rl=Nr(`useWhisperSpeech`),il=150;function al(e){let t=new URLSearchParams;return t.set(`model`,e),`/api/voice-model/download?${t.toString()}`}function ol(){if(typeof SharedArrayBuffer>`u`)return 1;let e=navigator.hardwareConcurrency;return!e||e<=2?1:e<=4?2:Math.min(4,e-2)}function sl(){return typeof performance<`u`&&typeof performance.now==`function`?performance.now():Date.now()}function cl(){let[e,t]=(0,Y.useState)(`idle`),[n,r]=(0,Y.useState)(null),[i,a]=(0,Y.useState)(!1),[o,s]=(0,Y.useState)(null),[c,l]=(0,Y.useState)(``),[u,d]=(0,Y.useState)(null),[f,p]=(0,Y.useState)(0),[m,h]=(0,Y.useState)(()=>Zt()),g=(0,Y.useRef)(null),_=(0,Y.useRef)(null),v=(0,Y.useRef)(null),y=(0,Y.useRef)(null),b=(0,Y.useRef)(null),x=(0,Y.useRef)(!1),S=(0,Y.useRef)(null),C=(0,Y.useRef)(null),w=(0,Y.useRef)(!1),T=(0,Y.useCallback)(e=>{w.current=e,a(e)},[]);(0,Y.useEffect)(()=>{if(typeof window>`u`)return;function e(e){e.key===`tarsk.general.voiceModel`&&h(Zt())}function t(){h(Zt())}return window.addEventListener(`storage`,e),window.addEventListener(`tarsk:voice-model-changed`,t),()=>{window.removeEventListener(`storage`,e),window.removeEventListener(`tarsk:voice-model-changed`,t)}},[]),(0,Y.useEffect)(()=>{g.current=null,_.current=null,C.current=null,T(!1),p(0),d(null),t(`idle`)},[m,T]),(0,Y.useEffect)(()=>()=>{S.current!==null&&window.clearTimeout(S.current),v.current&&v.current.getTracks().forEach(e=>e.stop())},[]);let E=(0,Y.useCallback)(async()=>{if(e===`ready`||e===`needs-model`||e===`error`)return e;if(C.current)return C.current;let n=al(m);async function i(){t(`checking-support`),T(!1),p(0),d(null),rl.separator(`VOICE SESSION START`),rl.info(`Checking WASM support`,{userAgent:navigator.userAgent,platform:navigator.platform,model:m,url:n});try{let e=new Ir;g.current=e;let i=await e.checkWasmSupport();if(rl.info(`WASM SIMD support check result`,{supported:i}),r(i),!i)return rl.error(`WASM SIMD not supported — voice input disabled`),t(`error`),d(`WebAssembly SIMD is not supported in this environment.`),`error`;let a=new Pr;_.current=a,rl.info(`Checking IndexedDB model cache`,{url:n});try{let r=await a.loadModelByUrl(n);return rl.info(`Cached model found — initializing WASM`,{sizeBytes:r.byteLength,sizeMB:(r.byteLength/1024/1024).toFixed(2),model:m}),T(!0),t(`initializing`),await e.initModel(r),rl.info(`WASM model initialized from cache — ready`),t(`ready`),`ready`}catch(e){return rl.info(`Model not in cache — download required`,{reason:e instanceof Error?e.message:String(e),model:m}),t(`needs-model`),`needs-model`}}catch(e){let n=e instanceof Error?e.message:`Unknown error`;return rl.error(`Failed to check speech recognition support`,{error:n}),t(`error`),d(`Failed to check speech recognition support: ${n}`),`error`}}let a=i();C.current=a;try{return await a}finally{C.current=null}},[e,m,T]),D=(0,Y.useCallback)(async()=>{if(!g.current||!_.current)return;let e=al(m);t(`downloading-model`),p(0),d(null),rl.info(`Model download requested`,{url:e,model:m});try{let n=await _.current.loadModelByUrl(e,e=>{p(e),e%10==0&&rl.debug(`Model download progress`,{progress:e,model:m})});rl.info(`Model download complete — initializing WASM`,{sizeBytes:n.byteLength,sizeMB:(n.byteLength/1024/1024).toFixed(2),model:m}),t(`initializing`),await g.current.initModel(n),rl.info(`WASM model initialized after download — ready`),T(!0),t(`ready`)}catch(e){let n=e instanceof Error?e.message:`An unknown error occurred.`;rl.error(`Model download or initialization failed`,{error:n,model:m}),t(`needs-model`),d(n)}},[m,T]),O=(0,Y.useCallback)(async()=>{if(!(!g.current||!w.current)){if(x.current=!1,t(`requesting-mic`),d(null),l(``),rl.separator(`RECORDING START`),rl.info(`Requesting microphone access`),!navigator.mediaDevices?.getUserMedia){rl.error(`navigator.mediaDevices.getUserMedia not available in this environment`),t(`ready`),s(!1),d(`Microphone is not available in this environment.`);return}try{let e=sl(),n=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,echoCancellation:!0,autoGainControl:!0,noiseSuppression:!0}}),r=n.getAudioTracks();rl.info(`Microphone access granted`,{durationMs:Math.round(sl()-e),trackCount:r.length,tracks:r.map(e=>({label:e.label,readyState:e.readyState,settings:e.getSettings()}))}),v.current=n,s(!0);let i=new AbortController;y.current=i,t(`recording`),rl.info(`Recording started`),b.current=Lr(n,{signal:i.signal,recordingDurationMs:12e4,logLevel:0},{onError:e=>{rl.error(`Audio conversion error during recording`,{error:e instanceof Error?e.message:String(e)})}})}catch(e){if(t(`ready`),e instanceof DOMException&&e.name===`NotAllowedError`)rl.error(`Microphone access denied (NotAllowedError)`),s(!1),d(`Microphone access was denied. Please allow microphone access to use voice input.`);else if(e instanceof DOMException&&e.name===`NotFoundError`)rl.error(`No microphone found (NotFoundError)`),s(!1),d(`No microphone was found. Please connect a microphone to use voice input.`);else{let t=e instanceof Error?e.message:`Unknown error`;rl.error(`Microphone error`,{error:t,type:e instanceof DOMException?e.name:typeof e}),d(`Microphone error: ${t}`)}}}},[]),k=(0,Y.useCallback)(async()=>{if(!b.current){rl.info(`stopListening called but no active recording`),v.current&&=(v.current.getTracks().forEach(e=>e.stop()),null),w.current&&t(`ready`);return}rl.info(`Stopping recording — waiting for audio data`);let e=sl();y.current?.abort(),t(`transcribing`);try{let n=sl(),r=await b.current;if(x.current){rl.info(`Transcription cancelled by user`),t(`ready`);return}let i=(r.audioData.length/16e3).toFixed(2),a=Math.round(sl()-n);rl.info(`Audio capture complete — starting transcription`,{sampleCount:r.audioData.length,durationSec:i,sampleRate:16e3,conversionDurationMs:a,stopToConversionReadyMs:Math.round(sl()-e)}),v.current&&=(v.current.getTracks().forEach(e=>e.stop()),null);let o=sl(),s=ol(),c=g.current.createSession(),u=``,d=``,f=null;function p(e=!1){if(!d)return;let t=d.trim();if(e){S.current!==null&&(window.clearTimeout(S.current),S.current=null),d=``,l(t);return}S.current===null&&(S.current=window.setTimeout(()=>{S.current=null;let e=d.trim();d=``,e&&l(e)},il))}let m=c.streaming(r.audioData,{language:`en`,threads:s,translate:!1}),h=``,_=0;for await(let e of m){if(x.current)break;_++,f===null&&(f=Math.round(sl()-o)),u+=e.text.trim()+` `,h=u,d=h,rl.debug(`Transcription segment received`,{index:_,text:e.text,timeStart:e.timeStart,timeEnd:e.timeEnd}),p()}p(!0),rl.info(`Transcription complete`,{segmentCount:_,durationMs:Math.round(sl()-o),timeToFirstSegmentMs:f,threadCount:s,totalStopToReadyMs:Math.round(sl()-e),textLength:h.trim().length,text:h.trim().slice(0,100)}),t(`ready`)}catch(e){if(x.current){t(`ready`);return}let n=e instanceof Error?e.message:`Unknown transcription error`;if(rl.error(`Transcription failed`,{error:n,errorType:e instanceof Error?e.constructor.name:typeof e,stack:e instanceof Error?e.stack?.split(`
|
|
26
|
+
`).slice(0,5).join(` | `):void 0}),g.current&&n.includes(`Aborted`)){rl.info(`WASM aborted — reinitializing model for next attempt`),t(`initializing`);try{await g.current.restartModel(),rl.info(`WASM reinitialized successfully`)}catch(e){rl.error(`WASM reinitialization failed`,{error:e instanceof Error?e.message:String(e)})}}t(`ready`),d(`Transcription failed: ${n}`)}finally{S.current!==null&&(window.clearTimeout(S.current),S.current=null),b.current=null,y.current=null}},[]),A=(0,Y.useCallback)(()=>{l(``),d(null)},[]);return{state:e,isSupported:n===!0,isWasmSupported:n,isModelLoaded:i,isMicrophoneAvailable:o,transcript:c,error:u,downloadProgress:f,startListening:O,stopListening:k,requestModelDownload:D,ensureReady:E,resetTranscript:A}}function ll(){let e=(0,X.c)(22),t=cl(),n=nl();if(!T()){let n;return e[0]!==t.downloadProgress||e[1]!==t.ensureReady||e[2]!==t.error||e[3]!==t.isWasmSupported||e[4]!==t.requestModelDownload||e[5]!==t.resetTranscript||e[6]!==t.startListening||e[7]!==t.state||e[8]!==t.stopListening||e[9]!==t.transcript?(n={state:t.state,isSupported:t.isWasmSupported,usesLocalModel:!0,transcript:t.transcript,error:t.error,downloadProgress:t.downloadProgress,startListening:t.startListening,stopListening:t.stopListening,requestModelDownload:t.requestModelDownload,ensureReady:t.ensureReady,resetTranscript:t.resetTranscript},e[0]=t.downloadProgress,e[1]=t.ensureReady,e[2]=t.error,e[3]=t.isWasmSupported,e[4]=t.requestModelDownload,e[5]=t.resetTranscript,e[6]=t.startListening,e[7]=t.state,e[8]=t.stopListening,e[9]=t.transcript,e[10]=n):n=e[10],n}let r;return e[11]!==n.downloadProgress||e[12]!==n.ensureReady||e[13]!==n.error||e[14]!==n.isSupported||e[15]!==n.requestModelDownload||e[16]!==n.resetTranscript||e[17]!==n.startListening||e[18]!==n.state||e[19]!==n.stopListening||e[20]!==n.transcript?(r={state:n.state,isSupported:n.isSupported,usesLocalModel:!1,transcript:n.transcript,error:n.error,downloadProgress:n.downloadProgress,startListening:n.startListening,stopListening:n.stopListening,requestModelDownload:n.requestModelDownload,ensureReady:n.ensureReady,resetTranscript:n.resetTranscript},e[11]=n.downloadProgress,e[12]=n.ensureReady,e[13]=n.error,e[14]=n.isSupported,e[15]=n.requestModelDownload,e[16]=n.resetTranscript,e[17]=n.startListening,e[18]=n.state,e[19]=n.stopListening,e[20]=n.transcript,e[21]=r):r=e[21],r}var ul=Y.forwardRef((e,t)=>{let n=(0,X.c)(13),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({className:r,value:a,...i}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o;n[4]===r?o=n[5]:(o=q(`relative h-4 w-full overflow-hidden rounded-full bg-secondary`,r),n[4]=r,n[5]=o);let s=`translateX(-${100-(a||0)}%)`,c;n[6]===s?c=n[7]:(c=(0,$.jsx)(Un,{className:`h-full w-full flex-1 bg-primary transition-all`,style:{transform:s}}),n[6]=s,n[7]=c);let l;return n[8]!==i||n[9]!==t||n[10]!==o||n[11]!==c?(l=(0,$.jsx)(dr,{ref:t,className:o,...i,children:c}),n[8]=i,n[9]=t,n[10]=o,n[11]=c,n[12]=l):l=n[12],l});ul.displayName=dr.displayName;var dl=75;function fl(e){let t=(0,X.c)(11),{open:n,onOpenChange:r,onConfirm:i,downloading:a,progress:s,error:c}=e,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsxs)(bt,{children:[(0,$.jsx)(z,{children:`Download Voice Model`}),(0,$.jsxs)(St,{children:[`To enable voice-to-text, a voice model needs to be downloaded. This is a one-time download of approximately `,dl,`MB. The model will be cached locally for future use.`]})]}),t[0]=l):l=t[0];let u;t[1]!==a||t[2]!==c||t[3]!==i||t[4]!==r||t[5]!==s?(u=(0,$.jsxs)(H,{children:[l,a?(0,$.jsxs)(`div`,{className:`space-y-3 py-4`,children:[(0,$.jsx)(ul,{value:s,className:`w-full`}),(0,$.jsx)(`p`,{className:q(J.bodyMuted,`text-center`),children:s<100?`Downloading model... ${s}%`:`Initializing model...`})]}):c?(0,$.jsxs)(`div`,{className:`space-y-4 py-2`,children:[(0,$.jsx)(jr,{variant:`error`,className:`mb-0`,children:c}),(0,$.jsxs)(o,{children:[(0,$.jsx)(U,{variant:`outline`,onClick:()=>r(!1),children:`Cancel`}),(0,$.jsx)(U,{onClick:i,children:`Try Again`})]})]}):(0,$.jsxs)(o,{children:[(0,$.jsx)(U,{variant:`outline`,onClick:()=>r(!1),children:`Cancel`}),(0,$.jsx)(U,{onClick:i,children:`Download Model`})]})]}),t[1]=a,t[2]=c,t[3]=i,t[4]=r,t[5]=s,t[6]=u):u=t[6];let d;return t[7]!==r||t[8]!==n||t[9]!==u?(d=(0,$.jsx)(h,{open:n,onOpenChange:r,children:u}),t[7]=r,t[8]=n,t[9]=u,t[10]=d):d=t[10],d}var pl=Sr(e=>(0,$.jsxs)(`slot`,{children:[(0,$.jsx)(`style`,{children:`
|
|
27
|
+
.recording-waveform {
|
|
28
|
+
display: flex;
|
|
29
|
+
align-items: center;
|
|
30
|
+
gap: 2px;
|
|
31
|
+
height: 16px;
|
|
32
|
+
}
|
|
33
|
+
.recording-waveform-bar {
|
|
34
|
+
display: block;
|
|
35
|
+
width: 3px;
|
|
36
|
+
height: 4px;
|
|
37
|
+
border-radius: 2px;
|
|
38
|
+
background: currentColor;
|
|
39
|
+
animation: waveform-bounce 0.7s ease-in-out infinite alternate;
|
|
40
|
+
}
|
|
41
|
+
@keyframes waveform-bounce {
|
|
42
|
+
from { height: 3px; }
|
|
43
|
+
to { height: 14px; }
|
|
44
|
+
}
|
|
45
|
+
`}),e.v0,e.v1]}),{name:`SpeechInput_1`,portals:[`v0`,`v1`]}),ml=function(e){let t=(0,X.c)(67),{onTranscript:n,children:r}=e,{state:i,isSupported:a,usesLocalModel:o,transcript:s,error:c,downloadProgress:l,startListening:u,stopListening:d,requestModelDownload:f,ensureReady:p,resetTranscript:m}=ll(),{toast:h}=Ii(),[_,v]=(0,Y.useState)(!1),y=(0,Y.useRef)(``),b=(0,Y.useRef)(null),x=i===`recording`,S=i===`transcribing`,C=x||S,w=i===`needs-model`,T=i===`downloading-model`||i===`initializing`,E=i===`checking-support`,D,O;t[0]!==_||t[1]!==c||t[2]!==h?(D=()=>{c&&c!==b.current&&!_&&h({title:`Voice Input Error`,description:c,variant:`destructive`}),b.current=c},O=[c,_,h],t[0]=_,t[1]=c,t[2]=h,t[3]=D,t[4]=O):(D=t[3],O=t[4]),(0,Y.useEffect)(D,O);let k,A;t[5]!==n||t[6]!==s?(k=()=>{if(s&&s!==y.current){let e=s.substring(y.current.length);y.current=s,n(e)}},A=[s,n],t[5]=n,t[6]=s,t[7]=k,t[8]=A):(k=t[7],A=t[8]),(0,Y.useEffect)(k,A);let j,M;t[9]===s?(j=t[10],M=t[11]):(j=()=>{s||(y.current=``)},M=[s],t[9]=s,t[10]=j,t[11]=M),(0,Y.useEffect)(j,M);let N;t[12]!==p||t[13]!==C||t[14]!==w||t[15]!==m||t[16]!==u||t[17]!==i||t[18]!==d?(N=async()=>{if(C){d();return}if(w){v(!0);return}if(i===`ready`){m(),u();return}if(i===`idle`){let e=await p();e===`needs-model`?v(!0):e===`ready`&&(m(),u())}},t[12]=p,t[13]=C,t[14]=w,t[15]=m,t[16]=u,t[17]=i,t[18]=d,t[19]=N):N=t[19];let P=N,F;t[20]===f?F=t[21]:(F=()=>{f()},t[20]=f,t[21]=F);let I=F,L,R;t[22]!==_||t[23]!==i?(R=()=>{i===`ready`&&_&&v(!1)},L=[i,_],t[22]=_,t[23]=i,t[24]=L,t[25]=R):(L=t[24],R=t[25]),(0,Y.useEffect)(R,L);let ee;t[26]!==c||t[27]!==E||t[28]!==T||t[29]!==x||t[30]!==a||t[31]!==S||t[32]!==w?(ee=()=>E?`Checking voice input support...`:a===!1?`Voice input not supported in this browser`:c||(T?`Downloading speech model...`:S?`Transcribing...`:x?`Stop listening`:w?`Click to download speech model`:`Start listening`),t[26]=c,t[27]=E,t[28]=T,t[29]=x,t[30]=a,t[31]=S,t[32]=w,t[33]=ee):ee=t[33];let z=ee,te;t[34]!==T||t[35]!==x||t[36]!==S?(te=()=>T||S?(0,$.jsx)(g,{className:`h-3 w-3 animate-spin`}):x?(0,$.jsxs)(`span`,{className:`recording-waveform`,"aria-hidden":!0,children:[(0,$.jsx)(`span`,{className:`recording-waveform-bar`,style:{animationDelay:`0ms`}}),(0,$.jsx)(`span`,{className:`recording-waveform-bar`,style:{animationDelay:`150ms`}}),(0,$.jsx)(`span`,{className:`recording-waveform-bar`,style:{animationDelay:`75ms`}}),(0,$.jsx)(`span`,{className:`recording-waveform-bar`,style:{animationDelay:`225ms`}})]}):(0,$.jsx)(ye,{className:`h-3 w-3`}),t[34]=T,t[35]=x,t[36]=S,t[37]=te):te=t[37];let ne=te,re,B;t[38]!==r||t[39]!==ne||t[40]!==z||t[41]!==P||t[42]!==E||t[43]!==T||t[44]!==x||t[45]!==a||t[46]!==S||t[47]!==w?(re=z(),B=r({onClick:P,disabled:E||T||S||a===!1,icon:ne(),label:re,isRecording:x,isTranscribing:S,isDownloading:T,needsModel:w,isSupported:a!==!1}),t[38]=r,t[39]=ne,t[40]=z,t[41]=P,t[42]=E,t[43]=T,t[44]=x,t[45]=a,t[46]=S,t[47]=w,t[48]=re,t[49]=B):(re=t[48],B=t[49]);let ie=B,V;t[50]===ie?V=t[51]:(V=(0,$.jsx)(G,{asChild:!0,children:ie}),t[50]=ie,t[51]=V);let ae;t[52]===re?ae=t[53]:(ae=(0,$.jsx)(K,{side:`top`,className:`bg-popover text-popover-foreground max-w-64`,children:re}),t[52]=re,t[53]=ae);let H;t[54]!==V||t[55]!==ae?(H=(0,$.jsxs)(W,{children:[V,ae]}),t[54]=V,t[55]=ae,t[56]=H):H=t[56];let oe;t[57]!==_||t[58]!==l||t[59]!==c||t[60]!==I||t[61]!==T||t[62]!==o?(oe=o?(0,$.jsx)(fl,{open:_,onOpenChange:v,onConfirm:I,downloading:T,progress:l,error:c}):null,t[57]=_,t[58]=l,t[59]=c,t[60]=I,t[61]=T,t[62]=o,t[63]=oe):oe=t[63];let se;return t[64]!==H||t[65]!==oe?(se=(0,$.jsx)(pl,{v0:H,v1:oe}),t[64]=H,t[65]=oe,t[66]=se):se=t[66],se};function hl(e){let t=(0,X.c)(8),{queuedMessages:n,onRemoveQueuedMessage:r}=e;if(n.length===0)return null;let i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(`div`,{className:q(J.compact,J.label,`text-muted-foreground`),children:`Queued messages`}),t[0]=i):i=t[0];let a;if(t[1]!==r||t[2]!==n){let e;t[4]===r?e=t[5]:(e=e=>(0,$.jsxs)(`div`,{className:q(J.body,`flex items-start justify-between gap-3 rounded-md border border-border/60 bg-background px-3 py-2`),children:[(0,$.jsx)(`p`,{className:`flex-1 whitespace-pre-wrap text-foreground`,children:e.message}),(0,$.jsx)(`button`,{type:`button`,className:`rounded-full p-1 text-muted-foreground transition-colors hover:bg-foreground hover:text-background`,onClick:()=>r(e.id),"aria-label":`Remove queued message`,children:(0,$.jsx)(A,{className:`h-3.5 w-3.5`})})]},e.id),t[4]=r,t[5]=e),a=n.map(e),t[1]=r,t[2]=n,t[3]=a}else a=t[3];let o;return t[6]===a?o=t[7]:(o=(0,$.jsxs)(jr,{className:`mb-3 border border-border/60 bg-muted/30 px-4 py-3`,children:[i,(0,$.jsx)(`div`,{className:`mt-2 flex flex-col gap-2`,children:a})]}),t[6]=a,t[7]=o),o}function gl(e){let t=(0,X.c)(27),{onSpeechClick:n,speechDisabled:r,icon:i,label:a,isRecording:o,isTranscribing:s,isDownloading:c,isSupported:l,hasMessageText:u,setIsVoiceActive:d,isStreaming:f,disabled:p,canSubmitMessage:m,attachmentsLength:h,effectiveModel:g,onStop:_,onSend:v}=e,y=o||s||c,b,x;t[0]!==y||t[1]!==d?(b=()=>{d(y)},x=[y,d],t[0]=y,t[1]=d,t[2]=b,t[3]=x):(b=t[2],x=t[3]),(0,Y.useEffect)(b,x);let S=!f&&!y&&((p??!1)||!m&&r||!u&&h>0&&!g||u&&!g),C;t[4]!==m||t[5]!==f||t[6]!==y||t[7]!==v||t[8]!==n||t[9]!==_?(C=function(){if(f){_?.();return}if(y){n();return}if(m){v();return}n()},t[4]=m,t[5]=f,t[6]=y,t[7]=v,t[8]=n,t[9]=_,t[10]=C):C=t[10];let w=C,T=f?`Stop generation`:y?a:m?`Send message`:a,E=`relative h-7 w-7 rounded-full ${o?`bg-primary text-primary-foreground hover:bg-primary/90`:``} ${f?`before:absolute before:inset-[-1px] before:rounded-full before:border before:border-primary/60 before:animate-ping-subtle before:content-['']`:``}`,D;t[11]!==m||t[12]!==i||t[13]!==f||t[14]!==y?(D=f?(0,$.jsx)(`span`,{className:`block h-3 w-3 shrink-0 rounded-[2px] bg-current`,"aria-hidden":`true`}):y||!m?i:(0,$.jsx)(pt,{className:`h-3 w-3`}),t[11]=m,t[12]=i,t[13]=f,t[14]=y,t[15]=D):D=t[15];let O;t[16]===T?O=t[17]:(O=(0,$.jsx)(`span`,{className:`sr-only`,children:T}),t[16]=T,t[17]=O);let k;t[18]===l?k=t[19]:(k=!l&&(0,$.jsx)(`span`,{className:`sr-only`,children:`Voice input not supported`}),t[18]=l,t[19]=k);let A;return t[20]!==w||t[21]!==S||t[22]!==E||t[23]!==D||t[24]!==O||t[25]!==k?(A=(0,$.jsxs)(U,{size:`icon`,className:E,onClick:w,disabled:S,children:[D,O,k]}),t[20]=w,t[21]=S,t[22]=E,t[23]=D,t[24]=O,t[25]=k,t[26]=A):A=t[26],A}function _l(e){let t=(0,X.c)(168),{onSend:n,onStop:r,isStreaming:a,disabled:o,initialValue:s,queuedMessages:c,onRemoveQueuedMessage:l,isOverlay:u,userTasks:d,onMatchedUserTaskSend:f,onUserTaskCreated:p}=e,m=a===void 0?!1:a,h=u===void 0?!1:u,g;t[0]===d?g=t[1]:(g=d===void 0?[]:d,t[0]=d,t[1]=g);let _=g,v=Q(El),y;t[2]===s?y=t[3]:(y={initialValue:s},t[2]=s,t[3]=y);let{message:b,setMessage:x,historyIndex:S,setHistoryIndex:C,draftMessage:w,setDraftMessage:T,cursorPosition:E,setCursorPosition:D,availableModels:O,selectedModel:k,setSelectedModel:A,attachments:j,setAttachments:M,planMode:N,setPlanMode:P,ralphMode:F,setRalphMode:I,imageMode:L,setImageMode:R,availableImageModels:ee,selectedImageModel:z,setSelectedImageModel:te,allFiles:ne,setAllFiles:re,showSuggestions:B,setShowSuggestions:ie,suggestionQuery:V,setSuggestionQuery:ae,selectedIndex:H,setSelectedIndex:oe,slashCommands:se,skills:ce,showCommandSuggestions:le,setShowCommandSuggestions:ue,commandQuery:de,setCommandQuery:fe,fileInputRef:pe,textareaRef:me,suggestionsRef:he,commandSuggestionsRef:ge,selectedThreadId:_e,dispatch:ve}=yc(y),ye=Q(Tl),be=Q(wl),xe;t[4]===ye?xe=t[5]:(xe=ye.some(Cl),t[4]=ye,t[5]=xe);let Se=xe,Ce=L?z:k,we=L?ee:O,Te;t[6]===b?Te=t[7]:(Te=b.trim(),t[6]=b,t[7]=Te);let Ee=Te.length>0,De=Ee||j.length>0,[Oe,Ae]=Y.useState(!1),je=Ec(),Me=_e??void 0,Ne;t[8]!==ne||t[9]!==j||t[10]!==de||t[11]!==E||t[12]!==ve||t[13]!==w||t[14]!==Se||t[15]!==S||t[16]!==L||t[17]!==m||t[18]!==b||t[19]!==f||t[20]!==n||t[21]!==N||t[22]!==F||t[23]!==z||t[24]!==H||t[25]!==k||t[26]!==re||t[27]!==M||t[28]!==fe||t[29]!==D||t[30]!==T||t[31]!==C||t[32]!==R||t[33]!==x||t[34]!==P||t[35]!==I||t[36]!==oe||t[37]!==ue||t[38]!==ie||t[39]!==ae||t[40]!==le||t[41]!==B||t[42]!==ce||t[43]!==se||t[44]!==V||t[45]!==Me||t[46]!==me||t[47]!==_?(Ne={message:b,setMessage:x,userTasks:_,onMatchedUserTaskSend:f,attachments:j,selectedModel:k,onSend:n,isStreaming:m,selectedThreadId:Me,isListening:!1,stopListening:Sl,resetTranscript:xl,dispatch:ve,historyIndex:S,setHistoryIndex:C,draftMessage:w,setDraftMessage:T,cursorPosition:E,setCursorPosition:D,showSuggestions:B,setShowSuggestions:ie,suggestionQuery:V,setSuggestionQuery:ae,allFiles:ne,setAllFiles:re,selectedIndex:H,setSelectedIndex:oe,showCommandSuggestions:le,setShowCommandSuggestions:ue,commandQuery:de,setCommandQuery:fe,slashCommands:se,skills:ce,textareaRef:me,setAttachments:M,planMode:N,setPlanMode:P,ralphMode:F,setRalphMode:I,imageMode:L,setImageMode:R,selectedImageModel:z,hasConversationMessages:Se},t[8]=ne,t[9]=j,t[10]=de,t[11]=E,t[12]=ve,t[13]=w,t[14]=Se,t[15]=S,t[16]=L,t[17]=m,t[18]=b,t[19]=f,t[20]=n,t[21]=N,t[22]=F,t[23]=z,t[24]=H,t[25]=k,t[26]=re,t[27]=M,t[28]=fe,t[29]=D,t[30]=T,t[31]=C,t[32]=R,t[33]=x,t[34]=P,t[35]=I,t[36]=oe,t[37]=ue,t[38]=ie,t[39]=ae,t[40]=le,t[41]=B,t[42]=ce,t[43]=se,t[44]=V,t[45]=Me,t[46]=me,t[47]=_,t[48]=Ne):Ne=t[48];let{handleSend:Pe,handleKeyDown:Fe,handleTextareaInput:Ie,insertFileReference:Le,insertCommand:Re,insertSkill:ze,fileSuggestions:Be}=xc(Ne),Ve;t[49]===x?Ve=t[50]:(Ve=e=>{x(t=>(t.endsWith(` `),t+e))},t[49]=x,t[50]=Ve);let He=Ve,Ue;t[51]===M?Ue=t[52]:(Ue=e=>{let t=e.clipboardData?.items;if(!t)return;let n=Array.from(t).filter(bl);if(n.length!==0){e.preventDefault();for(let e of n){let t=e.getAsFile();if(!t)continue;let n=new FileReader;n.onload=()=>{let e=n.result.split(`,`)[1];M(n=>[...n,{fileName:t.name||`pasted-image.${t.type.split(`/`)[1]||`png`}`,content:e,mimeType:t.type}])},n.readAsDataURL(t)}}},t[51]=M,t[52]=Ue);let We=Ue,Ge=h?`absolute inset-x-0 bottom-0 mx-auto w-full max-w-3xl max-md:px-2 px-4 pb-4 pointer-events-none`:`relative mx-auto w-full max-w-3xl max-md:px-0 pb-2 md:px-4 md:pb-4 md:-mx-[6px]`,Ke=`flex flex-col rounded-2xl border focus-within:ring-2 focus-within:ring-brand pointer-events-auto ${h?`border-border/50 shadow-lg backdrop-blur-sm`:`border-border shadow-2xl`}`,qe;t[53]!==h||t[54]!==v?(qe=vc(v,h),t[53]=h,t[54]=v,t[55]=qe):qe=t[55];let Je;t[56]===qe?Je=t[57]:(Je={backgroundImage:qe},t[56]=qe,t[57]=Je);let Ye;t[58]!==l||t[59]!==c?(Ye=(0,$.jsx)(hl,{queuedMessages:c,onRemoveQueuedMessage:l}),t[58]=l,t[59]=c,t[60]=Ye):Ye=t[60];let Xe=F?`Describe stories for Ralph to implement autonomously...`:N?`Describe what you want Tarsk to plan...`:L?`Describe the image you want to generate...`:Oe?`Dictate your message...`:`Ask Tarsk anything, # for files, / for commands & skills`,U;t[61]===Symbol.for(`react.memo_cache_sentinel`)?(U=q(J.body,`min-h-[4.5rem] w-full resize-none bg-transparent px-6 pt-4 pb-4 text-foreground placeholder:text-muted-foreground focus:outline-none`),t[61]=U):U=t[61];let Ze;t[62]!==o||t[63]!==Fe||t[64]!==We||t[65]!==Ie||t[66]!==b||t[67]!==Xe||t[68]!==me?(Ze=(0,$.jsx)(`textarea`,{ref:me,value:b,onChange:Ie,onKeyDown:Fe,onPaste:We,placeholder:Xe,rows:1,className:U,disabled:o}),t[62]=o,t[63]=Fe,t[64]=We,t[65]=Ie,t[66]=b,t[67]=Xe,t[68]=me,t[69]=Ze):Ze=t[69];let Qe;t[70]!==de||t[71]!==ge||t[72]!==Re||t[73]!==ze||t[74]!==H||t[75]!==oe||t[76]!==le||t[77]!==ce||t[78]!==se?(Qe=(0,$.jsx)(Oc,{visible:le,commands:se,skills:ce,query:de,selectedIndex:H,onSelectCommand:Re,onSelectSkill:ze,onMouseEnterSuggestion:oe,containerRef:ge}),t[70]=de,t[71]=ge,t[72]=Re,t[73]=ze,t[74]=H,t[75]=oe,t[76]=le,t[77]=ce,t[78]=se,t[79]=Qe):Qe=t[79];let $e;t[80]!==Be||t[81]!==Le||t[82]!==H||t[83]!==oe||t[84]!==B||t[85]!==V||t[86]!==he?($e=(0,$.jsx)(Pc,{showSuggestions:B,fileSuggestions:Be,suggestionQuery:V,selectedIndex:H,onSelectFile:Le,onMouseEnterSuggestion:oe,containerRef:he}),t[80]=Be,t[81]=Le,t[82]=H,t[83]=oe,t[84]=B,t[85]=V,t[86]=he,t[87]=$e):$e=t[87];let et;t[88]!==j||t[89]!==k?.id||t[90]!==k?.name||t[91]!==k?.supportsImages||t[92]!==M?(et=j.length>0&&(0,$.jsxs)(`div`,{className:`px-4`,children:[(0,$.jsx)(Mc,{attachments:j,onRemove:e=>M(t=>t.filter((t,n)=>n!==e))}),j.some(yl)&&k?.supportsImages===!1&&(0,$.jsxs)(`div`,{className:q(J.compact,`mb-2 flex items-center gap-1.5 text-amber-500`),children:[(0,$.jsx)(ke,{className:`h-3 w-3 shrink-0`}),(0,$.jsxs)(`span`,{children:[`Images are not supported by `,k?.name||k?.id]})]})]}),t[88]=j,t[89]=k?.id,t[90]=k?.name,t[91]=k?.supportsImages,t[92]=M,t[93]=et):et=t[93];let tt;t[94]===pe?tt=t[95]:(tt=()=>pe.current?.click(),t[94]=pe,t[95]=tt);let nt;t[96]!==ve||t[97]!==b||t[98]!==p||t[99]!==M||t[100]!==x||t[101]!==_e||t[102]!==me?(nt=()=>{let e=_e;if(!e)return;let t=b.trim();t&&i(e,t).then(t=>{p?.(t),x(``),M([]),ve({type:Z.ClearChatInputDraft,threadId:e}),me.current&&(me.current.style.height=`auto`)}).catch(vl)},t[96]=ve,t[97]=b,t[98]=p,t[99]=M,t[100]=x,t[101]=_e,t[102]=me,t[103]=nt):nt=t[103];let rt;t[104]!==o||t[105]!==Ee||t[106]!==L||t[107]!==je||t[108]!==N||t[109]!==F||t[110]!==be||t[111]!==R||t[112]!==P||t[113]!==I||t[114]!==tt||t[115]!==nt?(rt=(0,$.jsx)(Yc,{disabled:o,canAddTask:Ee,showModes:je,planMode:N,imageMode:L,ralphMode:F,setPlanMode:P,setImageMode:R,setRalphMode:I,projectId:be,onFileAttach:tt,onAddTask:nt}),t[104]=o,t[105]=Ee,t[106]=L,t[107]=je,t[108]=N,t[109]=F,t[110]=be,t[111]=R,t[112]=P,t[113]=I,t[114]=tt,t[115]=nt,t[116]=rt):rt=t[116];let it=L?te:A,at;t[117]!==we||t[118]!==Ce||t[119]!==it?(at=(0,$.jsx)(Hc,{availableModels:we,selectedModel:Ce,onModelSelect:it}),t[117]=we,t[118]=Ce,t[119]=it,t[120]=at):at=t[120];let ot;t[121]!==rt||t[122]!==at?(ot=(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[rt,at]}),t[121]=rt,t[122]=at,t[123]=ot):ot=t[123];let W;t[124]!==L||t[125]!==N||t[126]!==F||t[127]!==be||t[128]!==R||t[129]!==P||t[130]!==I?(W=(0,$.jsx)(Jc,{planMode:N,imageMode:L,ralphMode:F,setPlanMode:P,setImageMode:R,setRalphMode:I,projectId:be}),t[124]=L,t[125]=N,t[126]=F,t[127]=be,t[128]=R,t[129]=P,t[130]=I,t[131]=W):W=t[131];let st;t[132]!==j.length||t[133]!==De||t[134]!==o||t[135]!==Ce||t[136]!==Pe||t[137]!==Ee||t[138]!==m||t[139]!==r?(st=e=>{let{onClick:t,disabled:n,icon:i,label:a,isRecording:s,isTranscribing:c,isDownloading:l,isSupported:u}=e;return(0,$.jsx)(gl,{onSpeechClick:t,speechDisabled:n,icon:i,label:a,isRecording:s,isTranscribing:c,isDownloading:l,isSupported:u,hasMessageText:Ee,setIsVoiceActive:Ae,isStreaming:m,disabled:o,canSubmitMessage:De,attachmentsLength:j.length,effectiveModel:Ce,onStop:r,onSend:Pe})},t[132]=j.length,t[133]=De,t[134]=o,t[135]=Ce,t[136]=Pe,t[137]=Ee,t[138]=m,t[139]=r,t[140]=st):st=t[140];let ct;t[141]!==He||t[142]!==st?(ct=(0,$.jsx)(ml,{onTranscript:He,children:st}),t[141]=He,t[142]=st,t[143]=ct):ct=t[143];let lt;t[144]!==W||t[145]!==ct?(lt=(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[W,ct]}),t[144]=W,t[145]=ct,t[146]=lt):lt=t[146];let ut;t[147]!==ot||t[148]!==lt?(ut=(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-3 pb-2`,children:[ot,lt]}),t[147]=ot,t[148]=lt,t[149]=ut):ut=t[149];let dt;t[150]!==Ke||t[151]!==Je||t[152]!==Ye||t[153]!==Ze||t[154]!==Qe||t[155]!==$e||t[156]!==et||t[157]!==ut?(dt=(0,$.jsxs)(`div`,{className:Ke,style:Je,children:[Ye,Ze,Qe,$e,et,ut]}),t[150]=Ke,t[151]=Je,t[152]=Ye,t[153]=Ze,t[154]=Qe,t[155]=$e,t[156]=et,t[157]=ut,t[158]=dt):dt=t[158];let ft;t[159]===M?ft=t[160]:(ft=e=>Nc(e,e=>M(t=>[...t,...e])),t[159]=M,t[160]=ft);let pt;t[161]!==pe||t[162]!==ft?(pt=(0,$.jsx)(`input`,{ref:pe,type:`file`,multiple:!0,className:`hidden`,onChange:ft}),t[161]=pe,t[162]=ft,t[163]=pt):pt=t[163];let G;return t[164]!==Ge||t[165]!==dt||t[166]!==pt?(G=(0,$.jsxs)(`div`,{className:Ge,children:[dt,pt]}),t[164]=Ge,t[165]=dt,t[166]=pt,t[167]=G):G=t[167],G}function vl(e){console.error(`Failed to create user task:`,e)}function yl(e){return e.mimeType.startsWith(`image/`)}function bl(e){return e.type.startsWith(`image/`)}function xl(){}function Sl(){}function Cl(e){return e.sender===`agent`}function wl(e){return e.selectedProjectId}function Tl(e){return e.messages}function El(e){return e.sidebarOpen}function Dl(e){let t=(0,X.c)(25),{currentBranch:n,availableBranches:r,isLoadingBranches:i,isCheckingOut:a,onLoadBranches:o,onCheckoutBranch:s,onCreateBranch:c}=e,l;t[0]===o?l=t[1]:(l=e=>{e&&o()},t[0]=o,t[1]=l);let u,d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=q(J.compact,`h-7 px-2 bg-background gap-1.5 border-none text-muted-foreground hover:bg-accent hover:text-accent-foreground`),d=(0,$.jsx)(Tn,{className:`h-3.5 w-3.5 shrink-0`}),t[2]=u,t[3]=d):(u=t[2],d=t[3]);let f=n||`Unknown`,p;t[4]===f?p=t[5]:(p=(0,$.jsx)(as,{asChild:!0,children:(0,$.jsxs)(U,{variant:`outline`,size:`sm`,className:u,children:[d,f]})}),t[4]=f,t[5]=p);let m,h;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(on,{className:`h-3.5 w-3.5 mr-2 shrink-0`}),h=(0,$.jsx)(`span`,{children:`Create branch`}),t[6]=m,t[7]=h):(m=t[6],h=t[7]);let _;t[8]!==a||t[9]!==c?(_=(0,$.jsxs)(us,{onClick:c,disabled:a,children:[m,h]}),t[8]=a,t[9]=c,t[10]=_):_=t[10];let v;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(ms,{}),t[11]=v):v=t[11];let y;t[12]!==r||t[13]!==n||t[14]!==a||t[15]!==i||t[16]!==s?(y=i?(0,$.jsxs)(`div`,{className:q(J.compact,`px-2 py-1.5 text-muted-foreground flex items-center gap-2`),children:[(0,$.jsx)(g,{className:`h-3 w-3 animate-spin`}),`Loading branches...`]}):r.length===0?(0,$.jsx)(`div`,{className:q(J.compact,`px-2 py-1.5 text-muted-foreground`),children:`No branches found`}):r.map(e=>(0,$.jsxs)(us,{disabled:e===n||a,onClick:()=>s(e),children:[(0,$.jsx)(Tn,{className:`h-3.5 w-3.5 mr-2 shrink-0`}),(0,$.jsx)(`span`,{className:e===n?`font-semibold text-foreground`:``,children:e}),e===n&&(0,$.jsx)(`span`,{className:q(J.compact,`ml-auto text-muted-foreground`),children:`current`})]},e)),t[12]=r,t[13]=n,t[14]=a,t[15]=i,t[16]=s,t[17]=y):y=t[17];let b;t[18]!==y||t[19]!==_?(b=(0,$.jsxs)(ls,{align:`start`,children:[_,v,y]}),t[18]=y,t[19]=_,t[20]=b):b=t[20];let x;return t[21]!==l||t[22]!==b||t[23]!==p?(x=(0,$.jsxs)(is,{onOpenChange:l,children:[p,b]}),t[21]=l,t[22]=b,t[23]=p,t[24]=x):x=t[24],x}function Ol(e){let t=(0,X.c)(35),{open:n,onOpenChange:r,branchName:i,onBranchNameChange:a,isLoading:s,onCreateBranch:c}=e,l;t[0]!==i||t[1]!==s||t[2]!==c?(l=e=>{e.key===`Enter`&&i.trim()&&!s&&c()},t[0]=i,t[1]=s,t[2]=c,t[3]=l):l=t[3];let u=l,d;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsxs)(bt,{children:[(0,$.jsx)(z,{children:`New Branch`}),(0,$.jsx)(St,{children:`Enter a name for the new branch. It will be created from the default branch.`})]}),t[4]=d):d=t[4];let f;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(vn,{htmlFor:`branch-name`,children:`Branch Name`}),t[5]=f):f=t[5];let p;t[6]===a?p=t[7]:(p=e=>a(e.target.value),t[6]=a,t[7]=p);let m;t[8]!==i||t[9]!==u||t[10]!==s||t[11]!==p?(m=(0,$.jsx)(`div`,{className:`grid gap-4 py-4`,children:(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[f,(0,$.jsx)(y,{id:`branch-name`,placeholder:`e.g. feature/my-feature`,value:i,onChange:p,onKeyDown:u,disabled:s,autoFocus:!0})]})}),t[8]=i,t[9]=u,t[10]=s,t[11]=p,t[12]=m):m=t[12];let g;t[13]===r?g=t[14]:(g=()=>r(!1),t[13]=r,t[14]=g);let _;t[15]!==s||t[16]!==g?(_=(0,$.jsx)(U,{variant:`outline`,onClick:g,disabled:s,children:`Cancel`}),t[15]=s,t[16]=g,t[17]=_):_=t[17];let v;t[18]!==i||t[19]!==s?(v=s||!i.trim(),t[18]=i,t[19]=s,t[20]=v):v=t[20];let b=s?`Creating...`:`Create Branch`,x;t[21]!==c||t[22]!==v||t[23]!==b?(x=(0,$.jsx)(U,{onClick:c,disabled:v,children:b}),t[21]=c,t[22]=v,t[23]=b,t[24]=x):x=t[24];let S;t[25]!==x||t[26]!==_?(S=(0,$.jsxs)(o,{children:[_,x]}),t[25]=x,t[26]=_,t[27]=S):S=t[27];let C;t[28]!==S||t[29]!==m?(C=(0,$.jsxs)(H,{children:[d,m,S]}),t[28]=S,t[29]=m,t[30]=C):C=t[30];let w;return t[31]!==r||t[32]!==n||t[33]!==C?(w=(0,$.jsx)(h,{open:n,onOpenChange:r,children:C}),t[31]=r,t[32]=n,t[33]=C,t[34]=w):w=t[34],w}function kl(e){let t=(0,X.c)(8),{collapsed:n}=e,{theme:r,setTheme:i}=Rr();if(n)return null;let a;t[0]!==i||t[1]!==r?(a=()=>i(r===`dark`?`light`:`dark`),t[0]=i,t[1]=r,t[2]=a):a=t[2];let o,s,c;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(Gt,{className:`h-4 w-4 rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0`}),s=(0,$.jsx)(fn,{className:`absolute h-4 w-4 rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100`}),c=(0,$.jsx)(`span`,{className:`sr-only`,children:`Toggle theme`}),t[3]=o,t[4]=s,t[5]=c):(o=t[3],s=t[4],c=t[5]);let l;return t[6]===a?l=t[7]:(l=(0,$.jsxs)(U,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground hover:text-background`,onClick:a,children:[o,s,c]}),t[6]=a,t[7]=l),l}var Al=Sr(e=>(0,$.jsxs)(`div`,{className:`w-72 space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`h3`,{className:e.v0,children:`Context`}),e.v1]}),(0,$.jsxs)(`div`,{className:e.v2,children:[(0,$.jsxs)(`span`,{children:[e.v3,`% Full`]}),(0,$.jsxs)(`span`,{children:[`~`,e.v4,` / `,e.v5,` Tokens`]})]}),(0,$.jsx)(`div`,{className:`h-2 w-full overflow-hidden rounded-full bg-muted/60`,children:(0,$.jsx)(`div`,{className:`flex h-full w-full`,children:e.v6})}),(0,$.jsx)(`div`,{className:`space-y-1.5`,children:e.v7})]}),{name:`ContextUsagePanel_1`,portals:[`v1`,`v3`,`v4`,`v5`,`v6`,`v7`]}),jl=function(e){let t=(0,X.c)(37),{breakdown:n,onClose:r}=e,{categories:i,totalTokens:a,contextWindow:o,percentageFull:s}=n,c,l,u,d,f,p,m,h;if(t[0]!==i||t[1]!==o||t[2]!==r||t[3]!==s||t[4]!==a){let e;t[13]===i?e=t[14]:(e=e=>i[e.key]>0,t[13]=i,t[14]=e);let n=Ml.filter(e);c=Al,l=J.label,t[15]===r?u=t[16]:(u=r&&(0,$.jsxs)(U,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground hover:text-background`,onClick:r,children:[(0,$.jsx)(A,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Close`})]}),t[15]=r,t[16]=u),t[17]===Symbol.for(`react.memo_cache_sentinel`)?(d=q(J.compact,`flex items-center justify-between text-muted-foreground`),t[17]=d):d=t[17],f=s,t[18]===a?p=t[19]:(p=Nl(a),t[18]=a,t[19]=p),t[20]===o?m=t[21]:(m=Pl(o),t[20]=o,t[21]=m);let g;t[22]!==i||t[23]!==o?(g=e=>{let t=i[e.key],n=o>0?t/o*100:0;return(0,$.jsx)(`div`,{style:{width:`${Math.max(n,t>0?.5:0)}%`,backgroundColor:e.color}},e.key)},t[22]=i,t[23]=o,t[24]=g):g=t[24],h=n.map(g),t[0]=i,t[1]=o,t[2]=r,t[3]=s,t[4]=a,t[5]=c,t[6]=l,t[7]=u,t[8]=d,t[9]=f,t[10]=p,t[11]=m,t[12]=h}else c=t[5],l=t[6],u=t[7],d=t[8],f=t[9],p=t[10],m=t[11],h=t[12];let g;t[25]===i?g=t[26]:(g=Ml.map(e=>(0,$.jsxs)(`div`,{className:q(J.compact,`flex items-center justify-between text-muted-foreground`),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`h-2.5 w-2.5 shrink-0 rounded-sm`,style:{backgroundColor:e.color}}),(0,$.jsx)(`span`,{children:e.label})]}),(0,$.jsx)(`span`,{className:`tabular-nums`,children:Nl(i[e.key])})]},e.key)),t[25]=i,t[26]=g);let _;return t[27]!==c||t[28]!==l||t[29]!==u||t[30]!==d||t[31]!==f||t[32]!==p||t[33]!==m||t[34]!==h||t[35]!==g?(_=(0,$.jsx)(c,{v0:l,v1:u,v2:d,v3:f,v4:p,v5:m,v6:h,v7:g}),t[27]=c,t[28]=l,t[29]=u,t[30]=d,t[31]=f,t[32]=p,t[33]=m,t[34]=h,t[35]=g,t[36]=_):_=t[36],_},Ml=[{key:`systemPrompt`,label:`System prompt`,color:`#9CA3AF`},{key:`toolDefinitions`,label:`Tool definitions`,color:`#B088F0`},{key:`rules`,label:`Rules`,color:`#88D088`},{key:`skills`,label:`Skills`,color:`#D0A000`},{key:`subagentDefinitions`,label:`Subagent definitions`,color:`#2080D0`},{key:`conversation`,label:`Conversation`,color:`#E09030`}];function Nl(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toString()}function Pl(e){return e>=1e6?`${Math.round(e/1e6)}M`:e>=1e3?`${Math.round(e/1e3)}K`:e.toString()}function Fl({threadId:e,currentConversationId:t,initialBreakdown:n,refreshKey:r,children:i}){let[a,o]=(0,Y.useState)(n??null),[s,c]=(0,Y.useState)(!1),[l,u]=(0,Y.useState)(null),[d,f]=(0,Y.useState)(!1),[p,m]=(0,Y.useState)(n?t:void 0);return(0,Y.useEffect)(()=>{if(n){o(n),m(t),u(null);return}t!==p&&(o(null),m(void 0),u(null))},[n,t,p,r]),(0,Y.useEffect)(()=>{if(!d||!e||!t||p===t)return;let n=!1;async function r(){let r=t;if(r){c(!0),u(null);try{let t=await an(e,r);if(n)return;o(t),m(r)}catch(e){if(console.error(`[TokenUsageTooltip] Failed to load context data:`,e),n)return;o(e=>(e||u(`Failed to load context data`),e))}finally{n||c(!1)}}}return r(),()=>{n=!0}},[d,e,t,p]),!e||e===``?(0,$.jsx)($.Fragment,{children:i}):(0,$.jsxs)(Co,{open:d,onOpenChange:f,children:[(0,$.jsx)(wo,{asChild:!0,children:i}),(0,$.jsxs)(To,{side:`top`,align:`end`,className:`w-auto p-4`,children:[s&&(0,$.jsxs)(`div`,{className:q(J.compact,`flex w-72 items-center gap-2 text-muted-foreground`),children:[(0,$.jsx)(tt,{className:`h-3 w-3 animate-pulse`}),(0,$.jsx)(`span`,{children:`Loading context...`})]}),l&&!s&&(0,$.jsxs)(`div`,{className:q(J.compact,`flex w-72 items-center gap-2 text-muted-foreground`),children:[(0,$.jsx)(tt,{className:`h-3 w-3`}),(0,$.jsx)(`span`,{children:l})]}),!s&&!l&&a&&(0,$.jsx)(jl,{breakdown:a,onClose:()=>f(!1)})]})]})}var Il=Sr(e=>(0,$.jsxs)(`svg`,{className:e.v0,viewBox:`0 0 20 20`,"aria-hidden":`true`,children:[(0,$.jsx)(`circle`,{className:`text-muted-foreground/25`,cx:`10`,cy:`10`,r:e.v1,fill:`none`,stroke:`currentColor`,strokeWidth:`3`}),(0,$.jsx)(`circle`,{cx:`10`,cy:`10`,r:e.v2,fill:`none`,stroke:`currentColor`,strokeWidth:`3`,strokeLinecap:`round`,strokeDasharray:e.v3,strokeDashoffset:e.v4,transform:`rotate(-90 10 10)`})]}),{name:`ContextUsageRing_1`,svg:!0}),Ll=function(e){let t=(0,X.c)(5),{percentage:n}=e,r=2*Math.PI*7,i=r*(1-Math.min(n,100)/100),a;t[0]===n?a=t[1]:(a=zl(n),t[0]=n,t[1]=a);let o=`h-4 w-4 ${a}`,s;return t[2]!==i||t[3]!==o?(s=(0,$.jsx)(Il,{v0:o,v1:7,v2:7,v3:r,v4:i}),t[2]=i,t[3]=o,t[4]=s):s=t[4],s};function Rl(e){return e.filter(e=>e.sender===`agent`).length}function zl(e){return e>75?`text-red-500`:e>50?`text-orange-500`:`text-muted-foreground`}function Bl(e){let t=(0,X.c)(21),{threadId:n,messages:r}=e,i;t[0]===r?i=t[1]:(i=r===void 0?[]:r,t[0]=r,t[1]=i);let a=i,[o,s]=(0,Y.useState)(),[c,l]=(0,Y.useState)(),u;t[2]===a?u=t[3]:(u=Rl(a),t[2]=a,t[3]=u);let d=u,f;t[4]===n?f=t[5]:(f=()=>{(async function(){if(!n){s(void 0),l(void 0);return}try{let e=(await Ct(n)).currentConversationId;if(s(e),!e){l(void 0);return}l(await an(n,e))}catch(e){console.error(`Failed to fetch thread usage data:`,e)}})()},t[4]=n,t[5]=f);let p;if(t[6]!==n||t[7]!==d?(p=[n,d],t[6]=n,t[7]=d,t[8]=p):p=t[8],(0,Y.useEffect)(f,p),!n||n===``)return null;let m=c?.percentageFull,h=typeof m==`number`&&m>25,g=String(d),_;t[9]!==m||t[10]!==h?(_=h?(0,$.jsx)(Ll,{percentage:m}):(0,$.jsx)(D,{className:`h-4 w-4`}),t[9]=m,t[10]=h,t[11]=_):_=t[11];let v;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(`span`,{className:`sr-only`,children:`View token usage`}),t[12]=v):v=t[12];let y;t[13]===_?y=t[14]:(y=(0,$.jsxs)(U,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground hover:text-background`,children:[_,v]}),t[13]=_,t[14]=y);let b;return t[15]!==c||t[16]!==o||t[17]!==g||t[18]!==y||t[19]!==n?(b=(0,$.jsx)(Fl,{threadId:n,currentConversationId:o,initialBreakdown:c,refreshKey:g,children:y}),t[15]=c,t[16]=o,t[17]=g,t[18]=y,t[19]=n,t[20]=b):b=t[20],b}var Vl=`[gitops-timing]`;function Hl(e){let t=[],n=performance.now();async function r(n,r){let i=performance.now();try{return await r()}finally{let r=Math.round(performance.now()-i);t.push({step:n,ms:r}),console.log(`${Vl} ${e} step=${n} ${r}ms`)}}function i(n,r,i){t.push({step:n,ms:r}),console.log(`${Vl} ${e} step=${n} ${r}ms${i?` ${i}`:``}`)}function a(r){let i=Math.round(performance.now()-n),a=t.reduce((e,t)=>t.ms>=e.ms?t:e,{step:`none`,ms:0}),o=t.map(e=>`${e.step}:${e.ms}`).join(` `);console.log(`${Vl} ${e} summary total=${i}ms slowest=${a.step}@${a.ms}ms breakdown=[${o}]${r?` ${r}`:``}`)}return{step:r,record:i,summary:a}}var Ul=3e4,Wl={hasChanges:!1,changedFilesCount:0,hasUnpushedCommits:!1,currentBranch:``,hasRemoteBranch:!1,isOnGitHub:!1,remoteUrl:``,canCreateRepo:!1,repoUrl:void 0,status:`Up to date`,defaultBranch:null,prExists:!1,prUrl:void 0,prState:void 0,commitsAheadOfDefault:!1},Gl=new Map,Kl=new Map;function ql(e,t){let n=Gl.get(e);if(n)for(let e of n)e(t)}function Jl(e,t){let n=Gl.get(e);return n||(n=new Set,Gl.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&Gl.delete(e)}}function Yl(e){return`unified-git-status-${e}`}function Xl(e){return yt.getSync(Yl(e))}function Zl(e){let[t,n]=(0,Y.useState)(Wl),[r,i]=(0,Y.useState)(!1),a=(0,Y.useRef)(void 0),o=(0,Y.useRef)(0),s=(0,Y.useCallback)(e=>{(0,Y.startTransition)(()=>{n(e)})},[]),c=(0,Y.useRef)(s);c.current=s;let l=(0,Y.useCallback)(async(t=!1)=>{if(!e)return;let n=++o.current,r=Hl(`hook fetch thread=${e} force=${t}`),a=setTimeout(()=>{o.current===n&&i(!0)},100);try{let i=Yl(e),a=performance.now(),c=Xl(e);r.record(`local-cache-check`,Math.round(performance.now()-a),`result=${c?`hit`:`miss`}`),t&&(yt.invalidate(i),r.record(`invalidate-local-cache`,0));let l=await r.step(`ttl-cache-get`,()=>yt.get(i,()=>ie(e,t,!1),Ul));if(o.current!==n){r.summary(`stale-request`);return}await r.step(`update-state`,async()=>{s(l),ql(e,l)}),r.summary(`branch=${l.currentBranch} changes=${l.changedFilesCount} prExists=${l.prExists}`)}catch(e){if(o.current!==n)return;console.error(`Failed to fetch unified git status:`,e),r.summary(`error`)}finally{clearTimeout(a),o.current===n&&i(!1)}},[e,s]),u=(0,Y.useRef)(l);return u.current=l,(0,Y.useEffect)(()=>{if(e)return Jl(e,e=>{c.current(e)})},[e]),(0,Y.useEffect)(()=>{if(!e)return;let t=e;function n(){document.visibilityState===`visible`&&(yt.invalidate(Yl(t)),u.current(!1))}return document.addEventListener(`visibilitychange`,n),window.addEventListener(`focus`,n),()=>{document.removeEventListener(`visibilitychange`,n),window.removeEventListener(`focus`,n)}},[e]),(0,Y.useEffect)(()=>{if(o.current+=1,i(!1),!e){a.current=void 0,(0,Y.startTransition)(()=>{n(Wl)});return}let t=a.current!==e,r=Xl(e);t&&(console.log(`[gitops-timing] hook thread changed ${a.current??`none`} -> ${e}`),a.current=e,yt.invalidate(Yl(e))),(0,Y.startTransition)(()=>{n(r??Wl)}),console.log(r?`[gitops-timing] hook load thread=${e} local cache=hit`:`[gitops-timing] hook load thread=${e} local cache=miss`);let s=e,l=!1;function d(){if(l)return;let e=Kl.get(s);if(e){console.log(`[gitops-timing] hook initial fetch already in flight thread=${s}`),e.then(()=>{if(l)return;let e=Xl(s);e&&c.current(e)});return}console.log(`[gitops-timing] hook starting initial fetch thread=${s}`);let t=u.current(!1).finally(()=>{console.log(`[gitops-timing] hook initial fetch settled thread=${s}`),Kl.delete(s)});Kl.set(s,t)}return d(),()=>{l=!0}},[e]),{hasChanges:t.hasChanges,changedFilesCount:t.changedFilesCount,hasUnpushedCommits:t.hasUnpushedCommits,hasRemoteBranch:t.hasRemoteBranch,currentBranch:t.currentBranch,isOnGitHub:t.isOnGitHub,remoteUrl:t.remoteUrl,canCreateRepo:t.canCreateRepo,repoUrl:t.repoUrl,status:t.status,defaultBranch:t.defaultBranch,prExists:t.prExists,prUrl:t.prUrl,prState:t.prState,commitsAheadOfDefault:t.commitsAheadOfDefault,isRefreshing:r,fetchUnifiedStatus:l}}var Ql=(0,Y.createContext)(void 0);function $l(e){let t=(0,X.c)(8),{threadId:n,fetchUnifiedStatus:r}=e,i=vi(),a=Q(nu),o=Q(tu),s=Q(eu),c,l;return t[0]!==o||t[1]!==i||t[2]!==r||t[3]!==a||t[4]!==s||t[5]!==n?(c=()=>{if(!(!n||n!==s)&&!a&&o.includes(n)){let e=setTimeout(()=>{r(!0),i({type:Z.ClearThreadCompleted,threadId:n})},1e3);return()=>clearTimeout(e)}},l=[n,s,a,o,r,i],t[0]=o,t[1]=i,t[2]=r,t[3]=a,t[4]=s,t[5]=n,t[6]=c,t[7]=l):(c=t[6],l=t[7]),(0,Y.useEffect)(c,l),null}function eu(e){return e.selectedThreadId}function tu(e){return e.completedThreadIds}function nu(e){return e.isStreaming}function ru(e){let t=(0,X.c)(7),{threadId:n,children:r}=e,i=Zl(n),a;t[0]!==n||t[1]!==i.fetchUnifiedStatus?(a=(0,$.jsx)($l,{threadId:n,fetchUnifiedStatus:i.fetchUnifiedStatus}),t[0]=n,t[1]=i.fetchUnifiedStatus,t[2]=a):a=t[2];let o;return t[3]!==r||t[4]!==a||t[5]!==i?(o=(0,$.jsxs)(Ql.Provider,{value:i,children:[a,r]}),t[3]=r,t[4]=a,t[5]=i,t[6]=o):o=t[6],o}function iu(){let e=(0,Y.useContext)(Ql);if(e===void 0)throw Error(`useGitStatus must be used within a GitStatusProvider`);return e}var au=`panda.koala.penguin.bunny.kitten.puppy.hamster.otter.hedgehog.sloth.dolphin.owl.fox.deer.koala.walrus.bouncy.sparkly.fluffy.jolly.zesty.peppy.snappy.perky.breezy.chirpy.dizzy.fizzy.glossy.groggy.loopy.quirky.umbrella.taco.pickle.waffle.bubble.puzzle.rocket.tornado.volcano.rainbow.diamond.crystal.lantern.treasure.whisper.echo.boing.splat.whoosh.crunch.splash.jingle.wiggle.giggle.scramble.tumble.fumble.jumble.rumble.mumble.stumble.hustle.castle.island.mountain.forest.meadow.lagoon.canyon.geyser.oasis.glacier.waterfall.volcano.tundra.savanna.jungle.desert.magic.dream.wonder.spark.glow.shimmer.twinkle.radiance.harmony.melody.rhythm.symphony.adventure.journey.quest.odyssey`.split(`.`);function ou(){return au[Math.floor(Math.random()*au.length)]??`branch`}function su(){let e=ou(),t=ou();for(;t===e;)t=ou();return`${e}-${t}`}function cu(e){let[t,n]=(0,Y.useState)([]),[r,i]=(0,Y.useState)(!1),[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(!1),[u,d]=(0,Y.useState)(``),[f,p]=(0,Y.useState)(!1),[m,h]=(0,Y.useState)(`main`),g=iu();(0,Y.useEffect)(()=>{if(!s){d(``);return}d(su())},[s]),(0,Y.useEffect)(()=>{g.defaultBranch&&h(g.defaultBranch)},[g.defaultBranch]);async function _(){if(!(!e||r)){i(!0);try{n((await l(e)).branches)}catch{n([])}finally{i(!1)}}}async function v(t){if(!(!e||t===g.currentBranch)){o(!0);try{await S(e,t),await g.fetchUnifiedStatus(!0),Fi({title:`Switched to branch "${t}"`})}catch(e){Fi({title:`Failed to switch branch`,description:e instanceof Error?e.message:String(e),variant:`destructive`})}finally{o(!1)}}}function y(){c(!0)}async function b(){if(!(!e||!u.trim()||f)){p(!0);try{let t=await L(e,m,u);c(!1),await _(),await g.fetchUnifiedStatus(!0),Fi({title:`Branch created`,description:`Created branch "${t.branchName}" from ${m}`})}catch(e){Fi({title:`Failed to create branch`,description:e instanceof Error?e.message:String(e),variant:`destructive`})}finally{p(!1)}}}return{currentBranch:g.currentBranch,availableBranches:t,isLoadingBranches:r,isCheckingOut:a,loadBranches:_,checkoutBranch:v,fetchUnifiedStatus:g.fetchUnifiedStatus,isCreateDialogOpen:s,setIsCreateDialogOpen:c,newBranchName:u,setNewBranchName:d,isCreatingBranch:f,createBranch:b,openCreateBranchDialog:y,defaultBranch:m}}function lu({threadId:e,messages:t=[]}){let[n,r]=(0,Y.useState)(!1),[i,a]=(0,Y.useState)(null),o=cu(e);return(0,Y.useEffect)(()=>{e&&It(e).then(a).catch(()=>{})},[e]),(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-8 py-2 mt-[-1rem] min-h-[2.25rem]`,children:[e&&(0,$.jsx)(Dl,{currentBranch:o.currentBranch,availableBranches:o.availableBranches,isLoadingBranches:o.isLoadingBranches,isCheckingOut:o.isCheckingOut,onLoadBranches:o.loadBranches,onCheckoutBranch:o.checkoutBranch,onCreateBranch:o.openCreateBranchDialog}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(kl,{collapsed:!1}),(0,$.jsx)(Bl,{threadId:e,messages:t}),e&&(0,$.jsxs)(W,{children:[(0,$.jsx)(G,{asChild:!0,children:(0,$.jsx)(U,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground hover:text-background`,onClick:async()=>{if(!(!e||n)){r(!0);try{let t=await It(e);await navigator.clipboard.writeText(t)}finally{r(!1)}}},disabled:n,"aria-label":`Copy repository folder path`,children:(0,$.jsx)(Oe,{className:`h-4 w-4`})})}),(0,$.jsxs)(K,{side:`top`,className:`bg-slate-900 text-white`,children:[(0,$.jsx)(`div`,{children:`Copy repository folder path`}),i&&(0,$.jsx)(`div`,{className:q(J.compact,`opacity-70`),children:i})]})]})]})]}),(0,$.jsx)(Ol,{open:o.isCreateDialogOpen,onOpenChange:o.setIsCreateDialogOpen,branchName:o.newBranchName,onBranchNameChange:o.setNewBranchName,isLoading:o.isCreatingBranch,onCreateBranch:()=>void o.createBranch()})]})}var uu=Sr(e=>(0,$.jsxs)(`svg`,{"aria-hidden":`true`,width:e.v0,height:e.v1,viewBox:e.v2,className:`size-10 shrink-0`,children:[(0,$.jsx)(`circle`,{cx:e.v3,cy:e.v4,r:e.v5,fill:`none`,stroke:`currentColor`,strokeOpacity:`0.2`,strokeWidth:e.v6}),(0,$.jsx)(`circle`,{cx:e.v7,cy:e.v8,r:e.v9,fill:`none`,stroke:`currentColor`,strokeWidth:e.v10,strokeDasharray:e.v11,strokeDashoffset:e.v12,strokeLinecap:`round`,transform:e.v13,className:`transition-[stroke-dashoffset] duration-300 ease-out`})]}),{name:`TodoProgressRing_1`,svg:!0}),du=function(e){let t=(0,X.c)(2),{completedCount:n,totalCount:r}=e,i=hu*(1-(r>0?n/r:0)),a=fu/2,o;return t[0]===i?o=t[1]:(o=(0,$.jsx)(uu,{v0:fu,v1:fu,v2:`0 0 ${fu} ${fu}`,v3:a,v4:a,v5:mu,v6:pu,v7:a,v8:a,v9:mu,v10:pu,v11:hu,v12:i,v13:`rotate(-90 ${a} ${a})`}),t[0]=i,t[1]=o),o},fu=40,pu=4,mu=10,hu=2*Math.PI*mu;function gu(e){let t=(0,X.c)(13),{todos:n}=e,r;t[0]===n?r=t[1]:(r=n.filter(vu),t[0]=n,t[1]=r);let i=r.length,a;t[2]===n.length?a=t[3]:(a=n.length===0&&(0,$.jsx)(`p`,{className:J.compact,children:`No todo items.`}),t[2]=n.length,t[3]=a);let o;t[4]===n?o=t[5]:(o=n.map(_u),t[4]=n,t[5]=o);let s;t[6]!==i||t[7]!==n.length?(s=n.length>0&&(0,$.jsxs)(`p`,{className:q(J.compact,`pt-1`),children:[i,`/`,n.length,` completed`]}),t[6]=i,t[7]=n.length,t[8]=s):s=t[8];let c;return t[9]!==a||t[10]!==o||t[11]!==s?(c=(0,$.jsxs)(`div`,{className:`space-y-1`,children:[a,o,s]}),t[9]=a,t[10]=o,t[11]=s,t[12]=c):c=t[12],c}function _u(e){return(0,$.jsxs)(`div`,{className:q(J.caption,`flex items-start gap-2`),children:[e.status===`done`?(0,$.jsx)(gt,{className:`h-4 w-4 shrink-0 mt-0.5 text-brand`}):e.status===`working`?(0,$.jsx)(nn,{className:`h-4 w-4 shrink-0 mt-0.5 text-yellow-500`}):(0,$.jsx)(Pt,{className:`h-4 w-4 shrink-0 mt-0.5 text-muted-foreground`}),(0,$.jsx)(`span`,{className:e.status===`done`?`line-through text-muted-foreground`:`text-foreground`,children:e.description})]},e.id)}function vu(e){return e.status===`done`}function yu(e){let t=(0,X.c)(43),{layout:n}=e,r=n===void 0?`bar`:n,{todos:i}=(0,Y.useContext)(Lo),[a,o]=(0,Y.useState)(!1),s;t[0]===i?s=t[1]:(s=i.filter(bu),t[0]=i,t[1]=s);let c=s.length,l=i.length-c,u=`${c} of ${i.length} complete`;if(l<=0)return null;if(r===`menu`){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=()=>o(!0),t[2]=e):e=t[2];let n;t[3]!==c||t[4]!==i.length?(n=(0,$.jsx)(du,{completedCount:c,totalCount:i.length}),t[3]=c,t[4]=i.length,t[5]=n):n=t[5];let r;t[6]===u?r=t[7]:(r=(0,$.jsx)(`span`,{children:u}),t[6]=u,t[7]=r);let s;t[8]!==n||t[9]!==r?(s=(0,$.jsxs)(U,{variant:`ghost`,size:`sm`,className:`w-full justify-start gap-2`,onClick:e,children:[n,r]}),t[8]=n,t[9]=r,t[10]=s):s=t[10];let l;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(bt,{children:(0,$.jsx)(z,{children:`Agent Todos`})}),t[11]=l):l=t[11];let d;t[12]===i?d=t[13]:(d=(0,$.jsxs)(H,{className:`max-w-md`,children:[l,(0,$.jsx)(gu,{todos:i})]}),t[12]=i,t[13]=d);let f;t[14]!==a||t[15]!==d?(f=(0,$.jsx)(h,{open:a,onOpenChange:o,children:d}),t[14]=a,t[15]=d,t[16]=f):f=t[16];let p;return t[17]!==s||t[18]!==f?(p=(0,$.jsxs)($.Fragment,{children:[s,f]}),t[17]=s,t[18]=f,t[19]=p):p=t[19],p}let d;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>o(!0),t[20]=d):d=t[20];let f;t[21]!==c||t[22]!==i.length?(f=(0,$.jsx)(du,{completedCount:c,totalCount:i.length}),t[21]=c,t[22]=i.length,t[23]=f):f=t[23];let p;t[24]===u?p=t[25]:(p=(0,$.jsx)(`span`,{className:`sr-only`,children:u}),t[24]=u,t[25]=p);let m;t[26]!==f||t[27]!==p?(m=(0,$.jsx)(G,{asChild:!0,children:(0,$.jsxs)(U,{variant:`ghost`,size:`icon`,className:`ml-2 rounded-full [&_svg]:!size-10`,onClick:d,children:[f,p]})}),t[26]=f,t[27]=p,t[28]=m):m=t[28];let g;t[29]===u?g=t[30]:(g=(0,$.jsx)(K,{children:u}),t[29]=u,t[30]=g);let _;t[31]!==m||t[32]!==g?(_=(0,$.jsx)(Mt,{children:(0,$.jsxs)(W,{children:[m,g]})}),t[31]=m,t[32]=g,t[33]=_):_=t[33];let v;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(bt,{children:(0,$.jsx)(z,{children:`Agent Todos`})}),t[34]=v):v=t[34];let y;t[35]===i?y=t[36]:(y=(0,$.jsxs)(H,{className:`max-w-md`,children:[v,(0,$.jsx)(gu,{todos:i})]}),t[35]=i,t[36]=y);let b;t[37]!==a||t[38]!==y?(b=(0,$.jsx)(h,{open:a,onOpenChange:o,children:y}),t[37]=a,t[38]=y,t[39]=b):b=t[39];let x;return t[40]!==b||t[41]!==_?(x=(0,$.jsxs)($.Fragment,{children:[_,b]}),t[40]=b,t[41]=_,t[42]=x):x=t[42],x}function bu(e){return e.status===`done`}function xu(e){let t=(0,X.c)(30),{tasks:n,disabled:r,onSelectTask:i,onRemoveTask:a,layout:o}=e,s=r===void 0?!1:r,c=o===void 0?`bar`:o,[l,u]=(0,Y.useState)(!1),d=n.length,f=`${d} Pending ${d===1?`Task`:`Tasks`}`;if(d===0)return null;let p;t[0]===i?p=t[1]:(p=function(e){i(e),u(!1)},t[0]=i,t[1]=p);let m=p,h;t[2]!==a||t[3]!==d?(h=function(e){a(e),d===1&&u(!1)},t[2]=a,t[3]=d,t[4]=h):h=t[4];let g=h,_=c===`menu`?`ghost`:`outline`,v=c===`bar`&&`bg-background`,y=c===`menu`&&`w-full justify-start`,b;t[5]!==v||t[6]!==y?(b=q(`gap-2`,v,y),t[5]=v,t[6]=y,t[7]=b):b=t[7];let x;t[8]===f?x=t[9]:(x=(0,$.jsx)(`span`,{children:f}),t[8]=f,t[9]=x);let S;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,$.jsx)(Lt,{className:`h-4 w-4 shrink-0`}),t[10]=S):S=t[10];let C;t[11]!==s||t[12]!==_||t[13]!==b||t[14]!==x?(C=(0,$.jsx)(wo,{asChild:!0,children:(0,$.jsxs)(U,{variant:_,size:`sm`,className:b,disabled:s,children:[x,S]})}),t[11]=s,t[12]=_,t[13]=b,t[14]=x,t[15]=C):C=t[15];let w;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(`div`,{className:q(J.compact,J.label,`px-2 pb-1 pt-1 text-muted-foreground`),children:`Tasks`}),t[16]=w):w=t[16];let T;if(t[17]!==g||t[18]!==m||t[19]!==n){let e;t[21]!==g||t[22]!==m?(e=e=>(0,$.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-transparent px-2 py-2 hover:bg-accent`,children:[(0,$.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-start gap-2 text-left`,onClick:()=>m(e),children:[(0,$.jsx)(Nt,{className:`mt-0.5 h-4 w-4 shrink-0 text-muted-foreground`}),(0,$.jsx)(`span`,{className:q(J.body,`line-clamp-3 text-foreground`),children:e.content})]}),(0,$.jsxs)(U,{type:`button`,variant:`ghost`,size:`icon`,className:`h-7 w-7 shrink-0`,onClick:()=>g(e.id),children:[(0,$.jsx)(A,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Remove task`})]})]},e.id),t[21]=g,t[22]=m,t[23]=e):e=t[23],T=n.map(e),t[17]=g,t[18]=m,t[19]=n,t[20]=T}else T=t[20];let E;t[24]===T?E=t[25]:(E=(0,$.jsx)(To,{align:`start`,className:`w-96 p-2`,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[w,T]})}),t[24]=T,t[25]=E);let D;return t[26]!==l||t[27]!==C||t[28]!==E?(D=(0,$.jsxs)(Co,{open:l,onOpenChange:u,children:[C,E]}),t[26]=l,t[27]=C,t[28]=E,t[29]=D):D=t[29],D}var Su=(0,Y.createContext)(void 0);function Cu(e){let t=(0,X.c)(24),{children:n}=e,r=vi(),i=Q(Du),a=Q(Eu),o=Q(Tu),s=Q(wu),{toast:c}=Ii(),l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=[],t[0]=l):l=t[0];let[u,d]=(0,Y.useState)(l),f=s?.threadId===i,p=o||f,m,h;t[1]!==i||t[2]!==c?(m=()=>{if(!i){d([]);return}let e=!1;return(async function(){try{let t=await ue(i);e||d(t)}catch(t){e||(console.error(`Failed to load user tasks:`,t),c({title:`Could not load tasks`,description:`Failed to load UserTasks for this thread.`,variant:`destructive`}))}})(),()=>{e=!0}},h=[i,c],t[1]=i,t[2]=c,t[3]=m,t[4]=h):(m=t[3],h=t[4]),(0,Y.useEffect)(m,h);let g;t[5]!==r||t[6]!==i?(g=async function(){if(i)try{let e=await st(i);r({type:Z.ClearMessages}),console.log(`New conversation started:`,e),setTimeout(()=>{(async()=>{try{let e=await it(i);r({type:Z.SetMessages,messages:e.messages})}catch(e){console.error(`Failed to refresh chat history after starting new chat:`,e)}})()},0)}catch(e){console.error(`Failed to start new chat:`,e)}},t[5]=r,t[6]=i,t[7]=g):g=t[7];let _=g,v;t[8]!==i||t[9]!==c?(v=async function(e){if(i)try{await ge(i,e),d(t=>t.filter(t=>t.id!==e))}catch(e){console.error(`Failed to delete user task:`,e),c({title:`Could not remove task`,description:`Failed to delete the selected task.`,variant:`destructive`})}},t[8]=i,t[9]=c,t[10]=v):v=t[10];let y=v,b;t[11]!==r||t[12]!==i?(b=function(e){i&&r({type:Z.SetChatInputDraft,threadId:i,draft:e.content})},t[11]=r,t[12]=i,t[13]=b):b=t[13];let x=b,S;t[14]!==p||t[15]!==_||t[16]!==y||t[17]!==x||t[18]!==a||t[19]!==u?(S={userTasks:u,setUserTasks:d,handleNewChat:_,handleSelectUserTask:x,handleRemoveUserTask:y,effectiveIsStreaming:p,isCreatingProject:a},t[14]=p,t[15]=_,t[16]=y,t[17]=x,t[18]=a,t[19]=u,t[20]=S):S=t[20];let C;return t[21]!==n||t[22]!==S?(C=(0,$.jsx)(Su.Provider,{value:S,children:n}),t[21]=n,t[22]=S,t[23]=C):C=t[23],C}function wu(e){return e.pendingChatMessage}function Tu(e){return e.isStreaming}function Eu(e){return e.isCreatingProject}function Du(e){return e.selectedThreadId}function Ou(){let e=(0,Y.useContext)(Su);if(e===void 0)throw Error(`useChatInputToolbar must be used within a ChatInputToolbarProvider`);return e}var ku=function({workspaceEntries:e,hasMultipleWorkspaces:t,runningScripts:n,onScriptClick:r}){return t?e.map(([e,t])=>(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`div`,{className:`px-2 py-1 text-xs font-medium text-muted-foreground`,children:e}),t.map(e=>(0,$.jsxs)(`button`,{type:`button`,className:`flex items-center gap-2 rounded-sm px-2 py-1.5 text-sm hover:bg-accent`,onClick:()=>{r(e)},children:[n.has(e.name)?(0,$.jsx)(g,{className:`h-3 w-3 animate-spin shrink-0`}):(0,$.jsx)(`div`,{className:`h-3 w-3 shrink-0`}),e.friendlyName]},e.name))]},e)):e[0]?.[1].map(e=>(0,$.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-sm hover:bg-accent`,onClick:()=>{r(e)},children:[n.has(e.name)?(0,$.jsx)(g,{className:`h-3 w-3 animate-spin shrink-0`}):(0,$.jsx)(`div`,{className:`h-3 w-3 shrink-0`}),e.friendlyName]},e.name))};function Au({workspaceEntries:e,hasMultipleWorkspaces:t,runningScripts:n,onScriptClick:r}){return t?e.map(([e,t])=>(0,$.jsxs)(os,{children:[(0,$.jsx)(ss,{children:e}),(0,$.jsx)(cs,{className:`max-h-[min(400px,80vh)] overflow-y-auto`,children:t.map(e=>(0,$.jsxs)(us,{onClick:()=>{r(e)},className:`gap-2`,children:[n.has(e.name)?(0,$.jsx)(g,{className:`h-3 w-3 animate-spin shrink-0`}):(0,$.jsx)(`div`,{className:`h-3 w-3 shrink-0`}),e.friendlyName]},e.name))})]},e)):e[0]?.[1].map(e=>(0,$.jsxs)(us,{onClick:()=>{r(e)},className:`gap-2`,children:[n.has(e.name)?(0,$.jsx)(g,{className:`h-3 w-3 animate-spin shrink-0`}):(0,$.jsx)(`div`,{className:`h-3 w-3 shrink-0`}),e.friendlyName]},e.name))}function ju({threadId:e,layout:t=`bar`}){let n=vi(),{setTerminalNotification:r}=Pa(),[i,a]=(0,Y.useState)(null),[o,s]=(0,Y.useState)(new Set),c=(0,Y.useRef)(new Map);(0,Y.useEffect)(()=>((async()=>{try{let t=await Je(e);if(t.length===0){a(null);return}a(t),s(new Set(t.filter(e=>e.isRunning).map(e=>e.name)))}catch{a(null)}})(),()=>{for(let e of c.current.values())e.abort();c.current.clear()}),[e]);let l=async t=>{if(o.has(t.name)){let r=c.current.get(t.name);r&&(r.abort(),c.current.delete(t.name));try{await ft(e,t.name)}catch{}n({type:Z.AppendTerminalLine,threadId:e,line:{type:`system`,content:`■ ${t.friendlyName} stopped`}}),s(e=>{let n=new Set(e);return n.delete(t.name),n})}else{let i=new AbortController;c.current.set(t.name,i),s(e=>new Set([...e,t.name])),r(!0),n({type:Z.AppendTerminalLine,threadId:e,line:{type:`system`,content:`▶ ${t.friendlyName}`}});try{let r=await Yt(e,t.name,t.command,{signal:i.signal});if(r){let t=r.getReader(),i=new TextDecoder,a=``;try{for(;;){let{done:r,value:o}=await t.read();if(r)break;a+=i.decode(o,{stream:!0});let s=a.split(`
|
|
46
|
+
`);a=s.pop()??``;for(let t of s)if(t.trim())try{let r=JSON.parse(t);typeof r==`string`?n({type:Z.AppendTerminalLine,threadId:e,line:{type:`output`,content:r}}):r.type===`error`&&n({type:Z.AppendTerminalLine,threadId:e,line:{type:`error`,content:r.message}})}catch{n({type:Z.AppendTerminalLine,threadId:e,line:{type:`output`,content:t}})}}if(a.trim())try{let t=JSON.parse(a);typeof t==`string`?n({type:Z.AppendTerminalLine,threadId:e,line:{type:`output`,content:t}}):t.type===`error`&&n({type:Z.AppendTerminalLine,threadId:e,line:{type:`error`,content:t.message}})}catch{n({type:Z.AppendTerminalLine,threadId:e,line:{type:`output`,content:a}})}}finally{t.releaseLock()}}n({type:Z.AppendTerminalLine,threadId:e,line:{type:`system`,content:`✓ ${t.friendlyName} done`}})}catch{}finally{c.current.delete(t.name),s(e=>{let n=new Set(e);return n.delete(t.name),n})}}};if(!i)return null;let u=i.reduce((e,t)=>(e[t.workspace]||(e[t.workspace]=[]),e[t.workspace].push(t),e),{}),d=Object.entries(u).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>[e,[...t].sort((e,t)=>e.friendlyName.localeCompare(t.friendlyName))]),f=d.length>1;function p(e){l(e)}return t===`menu`?(0,$.jsxs)(Co,{children:[(0,$.jsx)(wo,{asChild:!0,children:(0,$.jsxs)(U,{variant:`ghost`,size:`sm`,className:`w-full justify-start gap-2`,children:[(0,$.jsx)(mt,{className:`h-4 w-4 shrink-0`}),`Project Scripts`]})}),(0,$.jsx)(To,{align:`start`,className:`w-56 p-1`,children:(0,$.jsx)(ku,{workspaceEntries:d,hasMultipleWorkspaces:f,runningScripts:o,onScriptClick:p})})]}):(0,$.jsxs)(is,{children:[(0,$.jsx)(Mt,{children:(0,$.jsxs)(W,{children:[(0,$.jsx)(G,{asChild:!0,children:(0,$.jsx)(as,{asChild:!0,children:(0,$.jsx)(U,{variant:`action`,size:`icon-md`,children:(0,$.jsx)(mt,{})})})}),(0,$.jsx)(K,{children:`Project Scripts`})]})}),(0,$.jsx)(ls,{align:`end`,className:`min-w-[180px]`,children:(0,$.jsx)(Au,{workspaceEntries:d,hasMultipleWorkspaces:f,runningScripts:o,onScriptClick:p})})]})}var Mu=`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 Nu({open:e,onOpenChange:t,projectId:n,commands:r,onRefresh:i}){let[a,o]=(0,Y.useState)(null),[s,c]=(0,Y.useState)(!1),[l,u]=(0,Y.useState)(!1),[d,f]=(0,Y.useState)([]),[p,m]=(0,Y.useState)(0),[g,_]=(0,Y.useState)(!1),v=(0,Y.useRef)(null),b=(0,Y.useRef)(null),x=()=>{o({id:crypto.randomUUID(),name:``,icon:`Play`,commandLine:``}),u(!1),f([])},S=e=>{o({...e}),u(!1),f([])},C=async()=>{try{_(!0);let e=await un(n);f(e.scripts),m(0),u(e.scripts.length>0)}catch(e){console.error(`Failed to load package scripts:`,e),Fi({title:`Error`,description:`Failed to load package scripts`,variant:`destructive`})}finally{_(!1)}},w=e=>{o(t=>t?{...t,name:e.name,commandLine:e.commandLine,relativeFolder:e.relativePath||``}:null),u(!1),f([]),v.current?.focus()},T=e=>{l&&(e.key===`ArrowDown`?(e.preventDefault(),m(e=>e<d.length-1?e+1:e)):e.key===`ArrowUp`?(e.preventDefault(),m(e=>e>0?e-1:0)):e.key===`Enter`?(e.preventDefault(),p<d.length&&w(d[p])):e.key===`Escape`&&(e.preventDefault(),u(!1),f([])))};(0,Y.useEffect)(()=>{let e=e=>{b.current&&!b.current.contains(e.target)&&(u(!1),f([]))};return l&&document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[l]);let E=async e=>{try{await _t(n,e),Fi({title:`Success`,description:`Command deleted`}),i()}catch{Fi({title:`Error`,description:`Failed to delete command`,variant:`destructive`})}};return(0,$.jsx)(h,{open:e,onOpenChange:t,children:(0,$.jsxs)(H,{className:`sm:max-w-[500px]`,children:[(0,$.jsxs)(bt,{children:[(0,$.jsx)(z,{children:`Project Commands`}),(0,$.jsx)(St,{children:`Manage custom commands for this project.`})]}),(0,$.jsx)(`div`,{className:`py-4 flex flex-col gap-4`,children:a?(0,$.jsxs)(`div`,{className:`p-4 border rounded-lg bg-muted/30 flex flex-col gap-4 animate-in slide-in-from-top-2`,children:[(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[(0,$.jsx)(vn,{htmlFor:`name`,children:`Command Name`}),(0,$.jsx)(y,{id:`name`,value:a.name,onChange:e=>o({...a,name:e.target.value}),placeholder:`e.g. Run Tests`,autoComplete:`off`})]}),(0,$.jsxs)(`div`,{className:`grid gap-2 relative`,children:[(0,$.jsx)(vn,{htmlFor:`commandLine`,children:`Command Line`}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(xi,{ref:v,id:`commandLine`,value:a.commandLine,onChange:e=>o({...a,commandLine:e.target.value}),onKeyDown:T,placeholder:`e.g. npm test`,className:`font-mono text-base min-h-[100px] resize-none pr-10`}),(0,$.jsx)(Mt,{children:(0,$.jsxs)(W,{children:[(0,$.jsx)(G,{asChild:!0,children:(0,$.jsx)(U,{type:`button`,variant:`ghost`,size:`icon`,className:`absolute right-2 top-2 h-6 w-6 text-muted-foreground transition-colors`,onClick:()=>void C(),disabled:g,children:(0,$.jsx)(wt,{className:`h-4 w-4`})})}),(0,$.jsx)(K,{children:(0,$.jsx)(`p`,{children:`Discover package scripts`})})]})})]}),l&&(0,$.jsx)(`div`,{ref:b,className:`absolute bottom-full left-0 right-0 mb-2 max-h-60 overflow-y-auto rounded-lg border border-border bg-popover shadow-lg z-50`,children:(0,$.jsxs)(`div`,{className:`p-2`,children:[(0,$.jsxs)(`div`,{className:q(J.dropdownGroupHeading,`px-2 py-1.5 border-b border-border/50 mb-1 flex items-center gap-2`),children:[(0,$.jsx)(wt,{className:`h-3 w-3`}),`Available Scripts `,g&&`(loading...)`]}),d.length>0?(()=>{let e={};d.forEach(t=>{e[t.relativePath]||(e[t.relativePath]=[]),e[t.relativePath].push(t)});let t=Object.keys(e).sort(),n=0;return t.map(t=>{let r=e[t].sort((e,t)=>e.name.localeCompare(t.name));return(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:q(J.dropdownGroupHeading,`px-3 py-1.5 text-muted-foreground/70 bg-muted/30`),children:t}),r.map(e=>{let t=n===p;return n++,(0,$.jsxs)(`button`,{type:`button`,className:q(`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:()=>w(e),onMouseEnter:()=>m(n-1),children:[(0,$.jsx)(`span`,{className:`font-medium`,children:e.name}),(0,$.jsx)(`span`,{className:q(J.caption,`font-mono`),children:e.commandLine})]},e.commandLine)})]},t)})})():(0,$.jsx)(`div`,{className:q(J.caption,`px-3 py-4 text-center`),children:g?`Loading scripts...`:`No package scripts found`})]})})]}),(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[(0,$.jsx)(vn,{htmlFor:`relativeFolder`,children:`Relative Folder`}),(0,$.jsx)(y,{id:`relativeFolder`,value:a.relativeFolder??``,onChange:e=>o({...a,relativeFolder:e.target.value}),placeholder:`e.g. frontend, packages/api (optional)`,autoComplete:`off`}),(0,$.jsx)(`p`,{className:J.bodyMuted,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)(vn,{children:`Icon`}),(0,$.jsx)(Mt,{children:(0,$.jsx)(`div`,{className:`grid grid-cols-10 gap-1 p-2 bg-background rounded-md border border-border`,children:Mu.map(e=>{let t=ce[e]||Xt;return(0,$.jsxs)(W,{children:[(0,$.jsx)(G,{asChild:!0,children:(0,$.jsx)(U,{variant:a.icon===e?`default`:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:()=>o({...a,icon:e}),children:(0,$.jsx)(t,{className:`h-4 w-4`})})}),(0,$.jsx)(K,{children:e})]},e)})})})]}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2 mt-2`,children:[(0,$.jsxs)(U,{variant:`ghost`,size:`sm`,onClick:()=>o(null),children:[(0,$.jsx)(A,{className:`h-4 w-4 mr-2`}),` Cancel`]}),(0,$.jsxs)(U,{size:`sm`,onClick:async()=>{if(!a?.name||!a?.commandLine){Fi({title:`Error`,description:`Name and Command Line are required`,variant:`destructive`});return}try{c(!0),await ht(n,a),Fi({title:`Success`,description:`Command saved`}),o(null),i()}catch{Fi({title:`Error`,description:`Failed to save command`,variant:`destructive`})}finally{c(!1)}},disabled:s,children:[(0,$.jsx)(cn,{className:`h-4 w-4 mr-2`}),` `,s?`Saving...`:`Save Command`]})]})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 max-h-[400px] overflow-y-auto pr-2`,children:[r.length===0&&(0,$.jsx)(`div`,{className:`text-center py-8 text-muted-foreground border-2 border-dashed rounded-lg`,children:`No commands defined yet.`}),r.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between p-3 rounded-md border border-border bg-card hover:bg-muted/50 cursor-pointer group transition-colors`,onClick:()=>S(e),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`div`,{className:`p-2 bg-muted rounded`,children:(0,$.jsx)(ce[e.icon]||Qe,{className:`h-4 w-4`})}),(0,$.jsxs)(`div`,{className:`flex flex-col`,children:[(0,$.jsx)(`span`,{className:J.label,children:e.name}),(0,$.jsx)(`span`,{className:q(J.caption,`line-clamp-1 font-mono`),children:e.commandLine})]})]}),(0,$.jsx)(`div`,{className:`flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,$.jsx)(U,{variant:`ghost`,size:`icon`,className:`h-8 w-8 text-muted-foreground hover:bg-destructive hover:text-destructive-foreground transition-colors`,onClick:t=>{t.stopPropagation(),E(e.id)},children:(0,$.jsx)(Ee,{className:`h-4 w-4`})})})]},e.id))]}),(0,$.jsxs)(U,{variant:`outline`,className:`w-full border-dashed`,onClick:x,children:[(0,$.jsx)(on,{className:`h-4 w-4 mr-2`}),` Add New Command`]})]})})]})})}function Pu(e){let t=(0,X.c)(36),{layout:n}=e,r=n===void 0?`bar`:n,i=Q(Ru),a=Q(Lu),o=Q(Iu),s=Q(Fu),{dispatch:c}=bi(a),[l,u]=(0,Y.useState)(!1),d,f,p,m,h;if(t[0]!==c||t[1]!==s||t[2]!==r||t[3]!==o||t[4]!==i||t[5]!==a||t[6]!==l){h=Symbol.for(`react.early_return_sentinel`);bb0:{let e;t[12]===i?e=t[13]:(e=e=>e.projectId===i,t[12]=i,t[13]=e),d=o.find(e)?.commands??[];let n;t[14]!==c||t[15]!==i||t[16]!==a?(n=e=>{!i||!a||c({type:Z.QueueTerminalCommand,threadId:a,command:e.commandLine,relativeFolder:e.relativeFolder})},t[14]=c,t[15]=i,t[16]=a,t[17]=n):n=t[17];let g=n,_;if(t[18]===c?_=t[19]:(_=async()=>{c({type:Z.ConfigUpdated})},t[18]=c,t[19]=_),f=_,!i){h=null;break bb0}if(r===`menu`){let e;t[20]!==g||t[21]!==s?(e=e=>(0,$.jsxs)(U,{variant:`ghost`,size:`sm`,className:`w-full justify-start gap-2`,onClick:()=>g({commandLine:e.commandLine,relativeFolder:e.relativeFolder}),disabled:s,children:[(0,$.jsx)(ce[e.icon]||Qe,{className:`h-4 w-4 shrink-0`}),e.name]},e.id),t[20]=g,t[21]=s,t[22]=e):e=t[22];let n,r;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>u(!0),n=(0,$.jsx)(nt,{className:`h-4 w-4 shrink-0`}),t[23]=n,t[24]=r):(n=t[23],r=t[24]);let a=d.length===0?`Project Commands`:`Manage commands`,o;t[25]===a?o=t[26]:(o=(0,$.jsxs)(U,{variant:`ghost`,size:`sm`,className:`w-full justify-start gap-2`,onClick:r,children:[n,a]}),t[25]=a,t[26]=o),h=(0,$.jsxs)($.Fragment,{children:[d.map(e),o,(0,$.jsx)(Nu,{open:l,onOpenChange:u,projectId:i,commands:d,onRefresh:f})]});break bb0}p=`flex items-center gap-1`,m=d.length===0?(0,$.jsx)(Mt,{children:(0,$.jsxs)(W,{children:[(0,$.jsx)(G,{asChild:!0,children:(0,$.jsx)(U,{variant:`action`,size:`icon-md`,onClick:()=>u(!0),children:(0,$.jsx)(nt,{})})}),(0,$.jsx)(K,{children:`Manage commands`})]})}):(0,$.jsx)($.Fragment,{children:(0,$.jsxs)(Mt,{children:[d.map(e=>(0,$.jsxs)(W,{children:[(0,$.jsx)(G,{asChild:!0,children:(0,$.jsx)(U,{variant:`action`,size:`icon-md`,onClick:()=>g({commandLine:e.commandLine,relativeFolder:e.relativeFolder}),disabled:s,children:(0,$.jsx)(ce[e.icon]||Qe,{})})}),(0,$.jsx)(K,{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)(W,{children:[(0,$.jsx)(G,{asChild:!0,children:(0,$.jsx)(U,{variant:`action`,size:`icon-md`,className:`ml-1`,onClick:()=>u(!0),children:(0,$.jsx)(nt,{})})}),(0,$.jsx)(K,{children:`Manage commands`})]})]})})}t[0]=c,t[1]=s,t[2]=r,t[3]=o,t[4]=i,t[5]=a,t[6]=l,t[7]=d,t[8]=f,t[9]=p,t[10]=m,t[11]=h}else d=t[7],f=t[8],p=t[9],m=t[10],h=t[11];if(h!==Symbol.for(`react.early_return_sentinel`))return h;let g;t[27]!==d||t[28]!==f||t[29]!==i||t[30]!==l?(g=(0,$.jsx)(Nu,{open:l,onOpenChange:u,projectId:i,commands:d,onRefresh:f}),t[27]=d,t[28]=f,t[29]=i,t[30]=l,t[31]=g):g=t[31];let _;return t[32]!==p||t[33]!==m||t[34]!==g?(_=(0,$.jsxs)(`div`,{className:p,children:[m,g]}),t[32]=p,t[33]=m,t[34]=g,t[35]=_):_=t[35],_}function Fu(e){return e.isRunningCommand}function Iu(e){return e.projects}function Lu(e){return e.selectedThreadId}function Ru(e){return e.selectedProjectId}var zu=`VS Code`;function Bu(e){return e||r(zu)}var Vu={"VS Code":`vscode`,Antigravity:`antigravity`,Cursor:`cursor`,"Devin Desktop":`devin`,Windsurf:`windsurf`,Xcode:`xcode`,"Android Studio":`android-studio`,Kiro:`kiro`,Terminal:`terminal`};function Hu({projectId:e,threadId:n,openWith:i,layout:a=`bar`}){let[o,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)([]),[u,d]=(0,Y.useState)(()=>Bu(i)),[f,p]=(0,Y.useState)(!0);(0,Y.useEffect)(()=>{(async()=>{try{let e=await t();l(e);let n=Bu(i);e.includes(n)?d(n):e.length>0&&d(e[0])}catch(e){console.error(`Failed to fetch available programs:`,e),l([zu])}finally{p(!1)}})()},[]),(0,Y.useEffect)(()=>{if(i&&c.includes(i)){d(i);return}let e=r(zu);!i&&c.includes(e)&&d(e)},[i,c]);async function m(t){d(t),en(t),await v(e,t)}let h=async t=>{try{s(!0),await m(t),n?await Be(n,t):await Pe(e,t),Fi({title:`Success`,description:`Opened project in ${t}`})}catch(e){console.error(`Failed to open project in ${t}:`,e);let n=`Failed to open project in ${t}`;if(e instanceof Error){let t=e;n=t.details?t.details:e.message}Fi({title:`Error`,description:n,variant:`destructive`})}finally{s(!1)}};async function g(e){try{await m(e)}catch(t){console.error(`Failed to save preferred IDE (${e}):`,t),Fi({title:`Error`,description:`Failed to save IDE preference`,variant:`destructive`})}}let _=async()=>{await h(u)};return f?(0,$.jsx)(U,{variant:`outline`,size:`sm`,className:`h-8`,disabled:!0,children:(0,$.jsx)(`div`,{className:`h-4 w-4 animate-pulse bg-muted rounded`})}):a===`menu`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(U,{variant:`ghost`,size:`sm`,className:`w-full justify-start gap-2`,disabled:o,onClick:()=>{_()},children:[(0,$.jsx)(`img`,{src:`/ide/${Vu[u]||Vu[zu]}.svg`,alt:u,className:`h-4 w-4 shrink-0`}),`Open in `,u]}),(0,$.jsxs)(Co,{children:[(0,$.jsx)(wo,{asChild:!0,children:(0,$.jsxs)(U,{variant:`ghost`,size:`sm`,className:`w-full justify-start gap-2`,children:[(0,$.jsx)(wt,{className:`h-4 w-4 shrink-0`}),`Change IDE`]})}),(0,$.jsx)(To,{align:`start`,className:`w-56 p-1`,children:c.map(e=>(0,$.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-sm hover:bg-accent disabled:opacity-50`,onClick:()=>{g(e)},disabled:o,children:[(0,$.jsx)(`img`,{src:`/ide/${Vu[e]||Vu[zu]}.svg`,alt:e,className:`h-4 w-4 shrink-0`}),e]},e))})]})]}):(0,$.jsxs)(`div`,{className:`flex items-center gap-0`,children:[(0,$.jsxs)(W,{children:[(0,$.jsx)(G,{asChild:!0,children:(0,$.jsx)(U,{variant:`outline`,size:`sm`,className:`h-8 rounded-r-none border-r-0 border-transparent`,disabled:o,onClick:_,children:(0,$.jsx)(`img`,{src:`/ide/${Vu[u]||Vu[zu]}.svg`,alt:u,className:`h-4 w-4`})})}),(0,$.jsx)(K,{children:`Open in ${u}`})]}),(0,$.jsxs)(is,{children:[(0,$.jsx)(as,{asChild:!0,children:(0,$.jsx)(U,{variant:`outline`,size:`sm`,className:`h-8 w-8 rounded-l-none px-1 border-transparent`,disabled:o,children:(0,$.jsx)(wt,{className:`h-3.5 w-3.5`})})}),(0,$.jsx)(ls,{align:`end`,children:c.map(e=>(0,$.jsxs)(us,{onClick:()=>void g(e),disabled:o,className:`flex items-center gap-2`,children:[(0,$.jsx)(`img`,{src:`/ide/${Vu[e]||Vu[zu]}.svg`,alt:e,className:`h-4 w-4`}),e]},e))})]})]})}var Uu=Sr(e=>(0,$.jsxs)(`button`,{onClick:e.v0,disabled:e.v1,className:e.v2,children:[e.v3,(0,$.jsx)(`span`,{className:e.v4,children:e.v5})]}),{name:`RunStopButton_1`,portals:[`v3`,`v5`]}),Wu=Sr(e=>e.v0,{name:`RunStopButton_2`,portals:[`v0`]}),Gu=Sr(e=>(0,$.jsx)(`slot`,{children:e.v0}),{name:`RunStopButton_3`,portals:[`v0`]}),Ku=function({projectId:e,runCommand:t,large:n,layout:r=`bar`}){let{dispatch:i}=bi(Q(e=>e.selectedThreadId)),{setDevServerUrl:a,devServerRunning:o,setDevServerRunning:s,devServerLoading:c,setDevServerLoading:l}=Pa(),{startServer:u}=ic(),d=(0,Y.useRef)(!1);(0,Y.useEffect)(()=>{(async()=>{try{s((await qt(e)).isRunning)}catch{s(!1)}})()},[e]);let f=()=>{u({projectId:e,runCommand:t||``})},p=async()=>{d.current=!0,l(!0);try{await At(e),s(!1),a(null),i({type:Z.AppendTerminalLine,line:{type:`system`,content:`Server stopped`}})}catch(e){let t=e instanceof Error?e.message:`Failed to stop dev server`;i({type:Z.AppendTerminalLine,line:{type:`error`,content:t}}),Fi({title:`Error`,description:t,variant:`destructive`})}finally{l(!1)}},m=!!t,h=c?`Starting...`:o?`Stop dev server`:`Start dev server`;return n?(0,$.jsx)(Uu,{v0:o?p:f,v1:c||!o&&!m,v2:`flex flex-col items-center gap-3 group disabled:opacity-40 disabled:cursor-not-allowed ${o?`text-orange-500`:`text-muted-foreground`}`,v3:c?(0,$.jsx)(g,{className:`h-10 w-10 animate-spin`}):o?(0,$.jsx)(Ie,{className:`h-10 w-10 fill-current`}):(0,$.jsx)(Qe,{className:`h-10 w-10 fill-current group-hover:text-foreground transition-colors`}),v4:q(J.body,`group-hover:text-foreground transition-colors`),v5:h}):r===`menu`?(0,$.jsx)(Wu,{v0:(0,$.jsxs)(U,{variant:`ghost`,size:`sm`,className:q(`w-full justify-start gap-2`,o&&`text-orange-500`),onClick:o?p:f,disabled:c||!o&&!m,children:[c?(0,$.jsx)(g,{className:`h-4 w-4 shrink-0 animate-spin`}):o?(0,$.jsx)(Ie,{className:`h-4 w-4 shrink-0 fill-current`}):(0,$.jsx)(Qe,{className:`h-4 w-4 shrink-0`}),h]})}):(0,$.jsx)(Gu,{v0:(0,$.jsx)(Mt,{children:(0,$.jsxs)(W,{children:[(0,$.jsx)(G,{asChild:!0,children:(0,$.jsxs)(U,{variant:`ghost`,size:`icon`,className:`h-8 w-8 ${o?`text-orange-500 bg-orange-500/10`:`text-muted-foreground`}`,onClick:o?p:f,disabled:c||!o&&!m,children:[c?(0,$.jsx)(g,{className:`h-4 w-4 animate-spin`}):o?(0,$.jsx)(Ie,{className:`h-4 w-4 fill-current`}):(0,$.jsx)(Qe,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`sr-only`,children:o?`Stop dev server`:`Start dev server`})]})}),(0,$.jsx)(K,{children:o?`Stop dev server`:m?`Start dev server: ${t}`:`Set run command in project settings`})]})})})},qu=(0,Y.lazy)(()=>fr(()=>import(`./git-ops-button-DZzOCOr8.js`).then(e=>({default:e.GitOpsButton})),__vite__mapDeps([2,1,3,4,5])));function Ju(e){return e===`menu`?`w-full justify-start gap-2`:`gap-2`}function Yu(e){let t=(0,X.c)(4),{threadId:n,projectId:r,messages:i,userTasks:a}=e,{hasChanges:o}=iu(),s=i.length>0,c=!!n&&(s||o||a.length>0||!!(n&&r)),l;return t[0]!==o||t[1]!==s||t[2]!==c?(l={isVisible:c,hasMessages:s,hasChanges:o},t[0]=o,t[1]=s,t[2]=c,t[3]=l):l=t[3],l}function Xu(e){let t=(0,X.c)(60),{threadId:n,projectId:r,messages:i,userTasks:a,effectiveIsStreaming:o,isCreatingProject:s,onNewChat:c,onSelectUserTask:l,onRemoveUserTask:u,layout:d}=e,f=d===void 0?`bar`:d,{setActiveMainTab:p}=Pa(),m;t[0]!==i||t[1]!==r||t[2]!==n||t[3]!==a?(m={threadId:n,projectId:r,messages:i,userTasks:a},t[0]=i,t[1]=r,t[2]=n,t[3]=a,t[4]=m):m=t[4];let{hasMessages:h,hasChanges:g,isVisible:_}=Yu(m),{changedFilesCount:v}=iu(),y;t[5]===f?y=t[6]:(y=Ju(f),t[5]=f,t[6]=y);let b=y,x=Q(Zu),S;if(t[7]!==r||t[8]!==x){let e;t[10]===r?e=t[11]:(e=e=>e.projectId===r,t[10]=r,t[11]=e),S=x.find(e),t[7]=r,t[8]=x,t[9]=S}else S=t[9];let C=S,w=f===`menu`&&!!n&&!!r,T=h||g||a.length>0||!!(n&&r);if(!_)return null;let E=f===`bar`&&`absolute -top-12 left-0 z-10 ml-8 flex flex-wrap items-center gap-2`,D=f===`menu`&&`flex flex-col items-stretch gap-1 p-1 min-w-[220px]`,O;t[12]!==E||t[13]!==D?(O=q(E,D),t[12]=E,t[13]=D,t[14]=O):O=t[14];let k=f===`bar`?!0:void 0,A;t[15]!==h||t[16]!==f||t[17]!==c||t[18]!==b?(A=h&&(0,$.jsxs)(U,{variant:f===`menu`?`ghost`:`outline`,size:`sm`,className:b,onClick:c,children:[(0,$.jsx)(on,{className:`h-4 w-4 shrink-0`}),`New Chat`]}),t[15]=h,t[16]=f,t[17]=c,t[18]=b,t[19]=A):A=t[19];let j;t[20]!==v||t[21]!==g||t[22]!==f||t[23]!==p||t[24]!==b?(j=g&&(0,$.jsxs)(U,{variant:f===`menu`?`ghost`:`outline`,size:`sm`,className:b,onClick:()=>p(`review`),children:[(0,$.jsx)(F,{className:`h-4 w-4 shrink-0`}),v,` `,v===1?`File`:`Files`,` Changed`]}),t[20]=v,t[21]=g,t[22]=f,t[23]=p,t[24]=b,t[25]=j):j=t[25];let M;t[26]!==o||t[27]!==s||t[28]!==f||t[29]!==u||t[30]!==l||t[31]!==n||t[32]!==a?(M=a.length>0&&(0,$.jsx)(xu,{tasks:a,disabled:o||!n&&!s,onSelectTask:l,onRemoveTask:u,layout:f}),t[26]=o,t[27]=s,t[28]=f,t[29]=u,t[30]=l,t[31]=n,t[32]=a,t[33]=M):M=t[33];let N;t[34]!==f||t[35]!==r||t[36]!==n?(N=n&&r&&(0,$.jsx)(Y.Suspense,{fallback:null,children:(0,$.jsx)(qu,{projectId:r,threadId:n,layout:f},n)}),t[34]=f,t[35]=r,t[36]=n,t[37]=N):N=t[37];let P;t[38]!==h||t[39]!==f?(P=h&&(0,$.jsx)(yu,{layout:f}),t[38]=h,t[39]=f,t[40]=P):P=t[40];let I;t[41]!==T||t[42]!==w?(I=w&&T&&(0,$.jsx)(ms,{className:`my-1`}),t[41]=T,t[42]=w,t[43]=I):I=t[43];let L;t[44]!==r||t[45]!==C?.openWith||t[46]!==C?.runCommand||t[47]!==w||t[48]!==n?(L=w&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ku,{projectId:r,runCommand:C?.runCommand,layout:`menu`}),(0,$.jsx)(ju,{threadId:n,layout:`menu`}),(0,$.jsx)(Pu,{layout:`menu`}),(0,$.jsx)(Hu,{projectId:r,threadId:n,openWith:C?.openWith,layout:`menu`})]}),t[44]=r,t[45]=C?.openWith,t[46]=C?.runCommand,t[47]=w,t[48]=n,t[49]=L):L=t[49];let R;return t[50]!==j||t[51]!==M||t[52]!==N||t[53]!==P||t[54]!==I||t[55]!==L||t[56]!==O||t[57]!==k||t[58]!==A?(R=(0,$.jsxs)(`div`,{className:O,"data-chat-toolbar":k,children:[A,j,M,N,P,I,L]}),t[50]=j,t[51]=M,t[52]=N,t[53]=P,t[54]=I,t[55]=L,t[56]=O,t[57]=k,t[58]=A,t[59]=R):R=t[59],R}function Zu(e){return e.projects}function Qu(e){let t=(0,X.c)(2),n;return t[0]===e?n=t[1]:(n=(0,$.jsx)(Xu,{...e}),t[0]=e,t[1]=n),n}function $u(){let e=(0,X.c)(20),t=Q(nd),n=Q(td),r=Q(ed),{userTasks:i,handleNewChat:a,handleSelectUserTask:o,handleRemoveUserTask:s,effectiveIsStreaming:c,isCreatingProject:l}=Ou(),u;e[0]!==r||e[1]!==n||e[2]!==t||e[3]!==i?(u={threadId:t,projectId:n,messages:r,userTasks:i},e[0]=r,e[1]=n,e[2]=t,e[3]=i,e[4]=u):u=e[4];let{isVisible:d}=Yu(u);if(!t||!d)return null;let f;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(as,{asChild:!0,children:(0,$.jsxs)(U,{variant:`ghost`,size:`icon`,className:`h-8 w-8 text-muted-foreground shrink-0 md:hidden electrobun-webkit-app-region-no-drag`,children:[(0,$.jsx)(gn,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Chat actions`})]})}),e[5]=f):f=e[5];let p=n??``,m;e[6]===a?m=e[7]:(m=()=>{a()},e[6]=a,e[7]=m);let h;e[8]===s?h=e[9]:(h=e=>{s(e)},e[8]=s,e[9]=h);let g;return e[10]!==c||e[11]!==o||e[12]!==l||e[13]!==r||e[14]!==t||e[15]!==p||e[16]!==m||e[17]!==h||e[18]!==i?(g=(0,$.jsxs)(is,{children:[f,(0,$.jsx)(ls,{align:`end`,className:`electrobun-webkit-app-region-no-drag`,children:(0,$.jsx)(Xu,{threadId:t,projectId:p,messages:r,userTasks:i,effectiveIsStreaming:c,isCreatingProject:l,onNewChat:m,onSelectUserTask:o,onRemoveUserTask:h,layout:`menu`})})]}),e[10]=c,e[11]=o,e[12]=l,e[13]=r,e[14]=t,e[15]=p,e[16]=m,e[17]=h,e[18]=i,e[19]=g):g=e[19],g}function ed(e){return e.messages}function td(e){return e.selectedProjectId}function nd(e){return e.selectedThreadId}function rd(e){let t=(0,X.c)(3),{threadId:n,children:r}=e,i;return t[0]!==r||t[1]!==n?(i=(0,$.jsx)(ru,{threadId:n,children:r}),t[0]=r,t[1]=n,t[2]=i):i=t[2],i}var id=new Set,ad=new Map,od=5e3;function sd(e){id.add(e);let t=ad.get(e);t&&clearTimeout(t),ad.set(e,setTimeout(()=>{id.delete(e),ad.delete(e)},od))}function cd(e){return id.has(e)}function ld(e){return e.filter(e=>!id.has(e))}function ud(e,t){if(!(!t||!e.includes(`"run_js"`)))try{let n=JSON.parse(e.trim());if(!Array.isArray(n))return;for(let e of n)e?.type===`tool_use`&&e?.name===`run_js`&&e?.id&&e?.input?.code&&Os(e.id,e.input.code,t)}catch{}}function dd(e){if(!(!e.includes(`"tool_use"`)||!e.includes(`"bash"`)))try{let t=JSON.parse(e.trim());if(!Array.isArray(t))return;for(let e of t)e?.type===`tool_use`&&e?.id&&typeof e.name==`string`&&e.name.toLowerCase()===`bash`&&typeof e.input?.command==`string`&&no(e.id,e.input.command)}catch{}}function fd(e){if(!(!e.includes(`"tool-result"`)||!e.includes(`"bash"`)))try{let t=JSON.parse(e.trim());if(!Array.isArray(t))return;for(let e of t)e?.type===`tool-result`&&e?.toolCallId&&typeof e.toolName==`string`&&e.toolName.toLowerCase()===`bash`&&ro(e.toolCallId)}catch{}}function pd(e,t,n){let r={type:`thinking`,content:hd,model:n};e({type:Z.SetStreaming,isStreaming:!0,threadId:t}),e({type:Z.SetStreamModel,model:n,threadId:t}),e({type:Z.AppendStreamChunk,chunkType:`thinking`,content:r.content??``,segments:ei([],`thinking`,r.content??``),threadId:t})}var md=/^\/compact(?:\s+(.*))?$/i,hd=`[Compact] Compaction in progress...`;function gd(){let e=vi(),{toast:t}=Ii(),[n,r]=(0,Y.useState)(null),[i,a]=(0,Y.useState)(!1),[o,s]=(0,Y.useState)(null),c=(0,Y.useRef)(null),l=(0,Y.useRef)(new Map),u=Q(e=>e.selectedThreadId),d=Q(e=>e.selectedProjectId),f=Q(e=>e.messages),p=Q(e=>e.queuedChatMessages),m=Q(e=>e.isStreaming),h=Q(e=>e.processingThreadIds),g=Q(e=>e.streamingModel),_=Q(e=>e.threadStreamingStates),v=Q(e=>e.pendingChatMessage);c.current=u;let y=(0,Y.useCallback)((t,n,r)=>{if(l.current.get(t)!==r){l.current.has(t)||(sd(t),e({type:Z.ResetStream,threadId:t}),e({type:Z.RemoveProcessingThread,threadId:t}));return}if(l.current.delete(t),e({type:Z.ClearToolCallProgress}),r.stopHandled)return;if(sd(t),r.error){let i={messageId:`msg-${Date.now()}-error`,sender:`agent`,content:`Error: ${r.error}`,contentType:`text`,timestamp:new Date().toISOString(),model:n||`default`,isThinking:!1};e({type:Z.AddMessage,message:i,threadId:t}),e({type:Z.ResetStream,threadId:t}),e({type:Z.RemoveProcessingThread,threadId:t});return}let i=si(r.segments)||`...`,a={messageId:`msg-${Date.now()}-agent`,sender:`agent`,content:i,contentType:`markdown`,timestamp:new Date().toISOString(),model:n||`default`,isThinking:!1};async function o(){for(let n=0;n<4;n++){n>0&&await new Promise(e=>setTimeout(e,150*n));try{let n=await it(t);if(t===c.current){e({type:Z.SetMessages,messages:n.messages});return}}catch(e){console.error(`Failed to reload chat history after stream:`,e);break}}e({type:Z.AddMessage,message:a,threadId:t})}o(),e({type:Z.ResetStream,threadId:t}),e({type:Z.MarkThreadCompleted,threadId:t}),e({type:Z.RemoveProcessingThread,threadId:t})},[e]),b=(0,Y.useCallback)(()=>{if(!u)return;s(u);let t=l.current.get(u);t&&(t.stopHandled=!0,t.controller.abort(),t.cancel?.(),l.current.delete(u)),Ut(u);let n={messageId:`msg-${Date.now()}-stopped`,sender:`agent`,content:`I've stopped working on your request.`,contentType:`text`,timestamp:new Date().toISOString(),model:g||`default`,isThinking:!1};e({type:Z.AddMessage,message:n,threadId:u}),e({type:Z.ClearToolCallProgress}),e({type:Z.ResetStream,threadId:u}),e({type:Z.MarkThreadCompleted,threadId:u}),e({type:Z.RemoveProcessingThread,threadId:u}),sd(u)},[u,e,g]);(0,Y.useEffect)(()=>()=>{for(let[t,n]of l.current.entries())n.controller.abort(),n.cancel?.(),e({type:Z.ResetStream,threadId:t});l.current.clear()},[e]);let x=(0,Y.useCallback)((t,n,i)=>{let o=l.current.get(t);o&&(o.controller.abort(),o.cancel?.());let s=new AbortController,u={controller:s,cancel:null,segments:[],assistantMessage:``,assistantThinking:``,hasStructuredContent:!1,error:null,stopHandled:!1};return l.current.set(t,u),e({type:Z.ResetStream,threadId:t}),e({type:Z.SetStreaming,isStreaming:!0,threadId:t}),n(s.signal).then(n=>{if(!n||s.signal.aborted){y(t,i,u);return}u.cancel=he(n,n=>{if(e({type:Z.IncrementStreamEventCount,threadId:t}),n.type===`error`){let e=n.content?.trim()||n.error?.message?.trim()||n.message?.trim()||`Unknown error occurred`;u.error=e,t===c.current&&r(e);return}if(n.type!==`message`){if(n.type===`long_running_confirmation`){let r=n.prompt;if(!r)return;u.segments=ni(u.segments,r),e({type:Z.AppendStreamChunk,chunkType:`content`,content:``,segments:u.segments,threadId:t});return}if(n.type===`shell_permission`){let r=n.shellPermission;if(!r)return;u.segments=ri(u.segments,r),e({type:Z.AppendStreamChunk,chunkType:`content`,content:``,segments:u.segments,threadId:t});return}if(n.type===`web_fetch_permission`){let r=n.webFetchPermission;if(!r)return;u.segments=ii(u.segments,r),e({type:Z.AppendStreamChunk,chunkType:`content`,content:``,segments:u.segments,threadId:t});return}if(n.type===`toolcall_delta`){n.partial?.content?.[0]?.id&&n.delta&&e({type:Z.UpdateToolCallProgress,toolCallId:n.partial.content[0].id,progress:{toolCallId:n.partial.content[0].id,toolName:n.partial.content[0].name,delta:n.delta,partial:n.partial}});return}if(n.type===`tool_execution_update`){n.toolCallId&&n.executionOutput!==void 0&&e({type:Z.UpdateToolExecutionOutput,toolCallId:n.toolCallId,toolName:n.toolName,executionOutput:n.executionOutput});return}if(n.model&&e({type:Z.SetStreamModel,model:n.model,threadId:t}),n.type===`thinking`||n.isThinking){let r=n.content??``;ud(r,t),u.assistantThinking+=r,u.segments=ei(u.segments,`thinking`,r),e({type:Z.AppendStreamChunk,chunkType:`thinking`,content:r,segments:u.segments,threadId:t})}else if(n.type===`result`){u.hasStructuredContent=!0;let r=n.content??``;u.assistantMessage=r,u.segments=ti(u.segments,r),e({type:Z.SetStreamContent,content:r,threadId:t}),typeof r==`string`&&ud(r,t)}else{if(u.hasStructuredContent)return;let r=n.content??``;u.assistantMessage+=r,u.segments=ei(u.segments,`content`,r),e({type:Z.AppendStreamChunk,chunkType:`content`,content:r,segments:u.segments,threadId:t})}}},()=>{y(t,i,u)},e=>{if(e.includes(`AbortError`)||e.includes(`canceled`)||e.includes(`BodyStreamBuffer was aborted`)){y(t,i,u);return}u.error=e,t===c.current&&r(e)},n=>{if(e({type:Z.IncrementStreamEventCount,threadId:t}),n.role===`assistant`){let r=n.content??``,i=typeof r==`string`?r:JSON.stringify(r);if(n.isThinking??!1){u.assistantThinking+=i,u.segments=ei(u.segments,`thinking`,i),e({type:Z.AppendStreamChunk,chunkType:`thinking`,content:i,segments:u.segments,threadId:t});return}let a=!1;if(typeof r==`object`&&Array.isArray(r)&&r.length>0)a=!0;else if(typeof i==`string`&&i.trim().startsWith(`[`))try{let e=JSON.parse(i);a=Array.isArray(e)&&e.length>0}catch{}a?(u.hasStructuredContent=!0,u.assistantMessage=i,u.segments=ti(u.segments,i),e({type:Z.SetStreamContent,content:i,threadId:t}),ud(i,t)):(u.assistantMessage+=i,u.segments=ei(u.segments,`content`,i),e({type:Z.AppendStreamChunk,chunkType:`content`,content:i,segments:u.segments,threadId:t}))}else if(n.role===`tool`){let r=n.content??``,i=typeof r==`string`?r:JSON.stringify(r);i&&(dd(i),fd(i),u.assistantMessage+=i,u.segments=ei(u.segments,`content`,i),e({type:Z.AppendStreamChunk,chunkType:`content`,content:i,segments:u.segments,threadId:t}))}})}).catch(n=>{if(l.current.delete(t),n instanceof Error&&n.name===`AbortError`){e({type:Z.ResetStream,threadId:t});return}if(n instanceof Ze){e({type:Z.ResetStream,threadId:t}),a(!0);return}if(n instanceof Error&&n.message.includes(`not currently processing`)){e({type:Z.ResetStream,threadId:t});return}let i=n instanceof Error?n.message:`Failed to send message. Please ensure the CLI server is running on localhost:641`;t===c.current&&r(i),console.error(`Failed to subscribe to chat stream:`,n),e({type:Z.ResetStream,threadId:t})}),s},[e,y]);(0,Y.useEffect)(()=>{for(let e of h)l.current.has(e)||_[e]?.isStreaming||cd(e)||x(e,t=>Ke(e,t),`default`)},[x,h,_]);let S=(0,Y.useCallback)(async(n,i,a,o,c,l,p)=>{if(!u)return;let g=u;r(null),s(null);let _=n.trim().match(md);if(_){if(f.filter(e=>e.sender===`agent`).length<2){t({title:`Nothing to compact`,description:`Start a conversation with at least two exchanges first.`});return}if(h.includes(g)||m&&u===g){t({title:`Agent is busy`,description:`Wait for the agent to finish before compacting.`});return}let n=_[1]?.trim();pd(e,g,i);try{let r=await dn(g,{model:i,provider:o,instructions:n});e({type:Z.SetMessages,messages:r.messages}),e({type:Z.ResetStream,threadId:g}),t({title:`Conversation compacted`,description:`${r.messagesBefore} messages → ${r.messagesAfter} summary`})}catch(n){e({type:Z.ResetStream,threadId:g}),t({title:`Compaction failed`,description:n instanceof Error?n.message:`Failed to compact conversation`,variant:`destructive`})}return}let v=`msg-${Date.now()}`,y;try{let e=await ve(g,v);e.success&&e.stashed&&e.checkpointRef&&(y=e.checkpointRef)}catch{}let b={messageId:v,sender:`user`,content:n,contentType:`text`,timestamp:new Date().toISOString(),model:i,attachments:a.map(e=>({fileName:e.fileName,content:e.content,mimeType:e.mimeType})),checkpointRef:y};e({type:Z.AddMessage,message:b,threadId:g});let S=n.trim().replace(/\n/g,` `).slice(0,100);if(d&&(xt(g,{title:S}).catch(e=>{console.error(`Failed to update thread title:`,e)}),e({type:Z.UpdateThreadTitle,projectId:d,threadId:g,title:S})),l){let t=o??void 0;if(!t&&typeof i==`string`){let e=i.split(/[:/]/)[0]?.trim();e&&(t=e)}if(!t){let t={messageId:`msg-${Date.now()}-error`,sender:`agent`,content:`Image generation is not available because no provider is configured for the selected model.`,contentType:`text`,timestamp:new Date().toISOString(),model:i,isThinking:!1};e({type:Z.AddMessage,message:t,threadId:g}),e({type:Z.ResetStream,threadId:g});return}e({type:Z.SetStreaming,isStreaming:!0,threadId:g});try{let r=await Wt(n,i,t,g),a={messageId:`msg-${Date.now()}-agent`,sender:`agent`,content:n,contentType:`text`,timestamp:new Date().toISOString(),model:i,isThinking:!1,generatedImageUrl:r.imageUrl,generatedImageData:r.imageData};e({type:Z.AddMessage,message:a,threadId:g})}catch(t){let n=t instanceof Error?t.message:`Image generation failed`,r={messageId:`msg-${Date.now()}-error`,sender:`agent`,content:`Error: ${n}`,contentType:`text`,timestamp:new Date().toISOString(),model:i,isThinking:!1};e({type:Z.AddMessage,message:r,threadId:g})}finally{e({type:Z.ResetStream,threadId:g})}return}x(g,e=>et(g,n,i,a,e,o,c,p,y),i)},[u,d,e,x,f,h,m,t]);(0,Y.useEffect)(()=>{let t=v;if(!t||m||t.threadId!==u)return;let n=setTimeout(()=>{e({type:Z.ClearPendingChatMessage}),S(t.message,t.model,[],t.provider)},100);return()=>clearTimeout(n)},[v,m,u,e,S]);let C=(0,Y.useMemo)(()=>u?p.filter(e=>e.threadId===u):[],[u,p]),w=(0,Y.useRef)(!1);return(0,Y.useEffect)(()=>{if(m||!u||C.length===0||w.current)return;let[t]=C;w.current=!0,e({type:Z.RemoveQueuedChatMessage,queuedMessageId:t.id});let n=setTimeout(()=>{S(t.message,t.model,t.attachments,t.provider,t.planMode,t.imageMode,t.ralphMode),w.current=!1},0);return()=>{clearTimeout(n),w.current=!1}},[e,S,m,C,u]),{error:n,setError:r,handleSend:S,handleStop:b,isStreaming:m,selectedThreadId:u,queuedMessagesForThread:C,handleRemoveQueuedMessage:(0,Y.useCallback)(t=>{let n=C.find(e=>e.id===t);e({type:Z.RemoveQueuedChatMessage,queuedMessageId:t}),!(!n||m||f.length>0||!u)&&S(n.message,n.model,n.attachments,n.provider,n.planMode,n.imageMode,n.ralphMode)},[e,S,m,f.length,C,u]),showEmptyBalanceDialog:i,setShowEmptyBalanceDialog:a}}function _d(e){let t=(0,X.c)(10),{open:n,onClose:r}=e,i=Qn(),a;t[0]===r?a=t[1]:(a=e=>{e||r()},t[0]=r,t[1]=a);let o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsxs)(vr,{children:[(0,$.jsx)(yr,{children:`Balance empty`}),(0,$.jsx)(xr,{children:`You have no prompts remaining. Purchase additional prompts to continue.`})]}),t[2]=o):o=t[2];let s;t[3]!==i||t[4]!==r?(s=(0,$.jsxs)(br,{children:[o,(0,$.jsx)(Cr,{children:(0,$.jsx)(U,{onClick:()=>{r(),i(`/settings/account`)},children:`Go to Account`})})]}),t[3]=i,t[4]=r,t[5]=s):s=t[5];let c;return t[6]!==n||t[7]!==a||t[8]!==s?(c=(0,$.jsx)(Er,{open:n,onOpenChange:a,children:s}),t[6]=n,t[7]=a,t[8]=s,t[9]=c):c=t[9],c}function vd(e){let t=(0,X.c)(4),{messages:n}=e,r;t[0]===n?r=t[1]:(r=n===void 0?[]:n,t[0]=n,t[1]=r);let i=r,a;return t[2]===i?a=t[3]:(a=(0,$.jsx)(yd,{messages:i}),t[2]=i,t[3]=a),a}function yd(e){let t=(0,X.c)(44),{messages:n}=e,r=Q(Sd),i=Q(xd),a=Q(bd),{handleSend:o,handleStop:s,queuedMessagesForThread:c,handleRemoveQueuedMessage:l,showEmptyBalanceDialog:u,setShowEmptyBalanceDialog:d}=gd(),{userTasks:f,setUserTasks:p,handleNewChat:m,handleSelectUserTask:h,handleRemoveUserTask:g,effectiveIsStreaming:_}=Ou(),v=Ec()||T(),y;t[0]===d?y=t[1]:(y=()=>d(!1),t[0]=d,t[1]=y);let b;t[2]!==u||t[3]!==y?(b=(0,$.jsx)(_d,{open:u,onClose:y}),t[2]=u,t[3]=y,t[4]=b):b=t[4];let x=v?`w-full min-w-0`:`w-[90vw] min-w-[400px]`,S;t[5]===x?S=t[6]:(S=q(`relative mx-auto max-w-3xl`,x),t[5]=x,t[6]=S);let C;t[7]!==_||t[8]!==m||t[9]!==g||t[10]!==h||t[11]!==r||t[12]!==n||t[13]!==a||t[14]!==i||t[15]!==f?(C=i&&(a||n.length>0||f.length>0)&&(0,$.jsx)(`div`,{className:`max-md:hidden`,children:(0,$.jsx)(Qu,{threadId:i,projectId:a??``,messages:n,userTasks:f,effectiveIsStreaming:_,isCreatingProject:r,onNewChat:()=>{m()},onSelectUserTask:h,onRemoveUserTask:e=>{g(e)}})}),t[7]=_,t[8]=m,t[9]=g,t[10]=h,t[11]=r,t[12]=n,t[13]=a,t[14]=i,t[15]=f,t[16]=C):C=t[16];let w=!i&&!r,E;t[17]===g?E=t[18]:(E=e=>{g(e.id)},t[17]=g,t[18]=E);let D;t[19]===p?D=t[20]:(D=e=>{p(t=>[...t,e])},t[19]=p,t[20]=D);let O;t[21]!==_||t[22]!==l||t[23]!==o||t[24]!==s||t[25]!==c||t[26]!==w||t[27]!==E||t[28]!==D||t[29]!==f?(O=(0,$.jsx)(_l,{onSend:o,onStop:s,isStreaming:_,disabled:w,initialValue:``,queuedMessages:c,onRemoveQueuedMessage:l,isOverlay:!1,userTasks:f,onMatchedUserTaskSend:E,onUserTaskCreated:D}),t[21]=_,t[22]=l,t[23]=o,t[24]=s,t[25]=c,t[26]=w,t[27]=E,t[28]=D,t[29]=f,t[30]=O):O=t[30];let k;t[31]!==C||t[32]!==O?(k=(0,$.jsxs)(`div`,{className:`relative`,children:[C,O]}),t[31]=C,t[32]=O,t[33]=k):k=t[33];let A=i??void 0,j;t[34]!==n||t[35]!==A?(j=(0,$.jsx)(`div`,{className:`max-md:hidden`,children:(0,$.jsx)(lu,{threadId:A,messages:n})}),t[34]=n,t[35]=A,t[36]=j):j=t[36];let M;t[37]!==k||t[38]!==j||t[39]!==S?(M=(0,$.jsxs)(`div`,{className:S,children:[k,j]}),t[37]=k,t[38]=j,t[39]=S,t[40]=M):M=t[40];let N;return t[41]!==M||t[42]!==b?(N=(0,$.jsxs)($.Fragment,{children:[b,M]}),t[41]=M,t[42]=b,t[43]=N):N=t[43],N}function bd(e){return e.selectedProjectId}function xd(e){return e.selectedThreadId}function Sd(e){return e.isCreatingProject}var Cd=768;function wd(){let e=(0,X.c)(2),[t,n]=Y.useState(void 0),r,i;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{let e=window.matchMedia(`(max-width: ${Cd-1}px)`),t=()=>{n(window.innerWidth<Cd)};return e.addEventListener(`change`,t),n(window.innerWidth<Cd),()=>e.removeEventListener(`change`,t)},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),Y.useEffect(r,i),!!t}function Td(){let e=(0,X.c)(7),t=vi(),n=Q(Dd),r=Q(Ed),i;e[0]!==t||e[1]!==n?(i=()=>{if(!n)return;let e=n,r=!1;return(async function(){try{let n=await it(e);r||t({type:Z.SetMessages,messages:n.messages})}catch(e){console.error(`Failed to load chat history:`,e),r||t({type:Z.SetMessages,messages:[]})}})(),()=>{r=!0}},e[0]=t,e[1]=n,e[2]=i):i=e[2];let a;e[3]!==t||e[4]!==r||e[5]!==n?(a=[n,r,t],e[3]=t,e[4]=r,e[5]=n,e[6]=a):a=e[6],(0,Y.useEffect)(i,a)}function Ed(e){return e.selectedProjectId}function Dd(e){return e.selectedThreadId}async function Od(e){return le(`api/projects/${B(e)}/todos`)}async function kd(e,t){return _e(`api/projects/${B(e)}/todos`,{description:t})}async function Ad(e,t,n){return I(`api/projects/${B(e)}/todos/${B(t)}`,n)}async function jd(e,t){await ee(`api/projects/${B(e)}/todos/${B(t)}`)}var Md=Sr(e=>(0,$.jsxs)(`div`,{className:e.v0,onClick:e.v1,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`p`,{className:e.v2,children:e.v3}),e.v4]}),e.v5]}),{name:`KanbanTodoCard_1`,portals:[`v3`,`v4`,`v5`]}),Nd=function({todo:e,projectId:t,onUpdate:n,onEdit:r,onAction:i,onThreadSelect:a}){let[o,s]=(0,Y.useState)(!1),c=Pd[e.status]??[];function l(t){t.stopPropagation(),e.threadId&&a&&a(e.threadId)}async function u(r,a){r.stopPropagation(),s(!0);try{i?await i(e,a):n(await Ad(t,e.id,{status:a,working:a!==`Done`}))}finally{s(!1)}}return(0,$.jsx)(Md,{v0:q(`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`),v1:t=>{t.stopPropagation(),r(e)},v2:q(J.label,`leading-tight`),v3:e.title,v4:e.working&&(0,$.jsx)(g,{className:`h-3 w-3 animate-spin text-primary shrink-0`}),v5:(c.length>0||e.status!==`Ready`&&e.threadId&&a)&&(0,$.jsxs)(`div`,{className:`flex gap-1.5 flex-wrap items-center pt-1`,children:[c.map(t=>(0,$.jsxs)(W,{children:[(0,$.jsx)(G,{asChild:!0,children:(0,$.jsx)(U,{size:`sm`,variant:`outline`,className:`h-6 px-2 text-base`,onClick:e=>void u(e,t.target),disabled:o||e.working,children:t.label})}),(0,$.jsx)(K,{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)(W,{children:[(0,$.jsx)(G,{asChild:!0,children:(0,$.jsxs)(U,{size:`icon`,variant:`ghost`,className:`h-7 w-7 shrink-0 group-hover:flex items-center justify-center`,onClick:l,children:[(0,$.jsx)(j,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Open thread`})]})}),(0,$.jsx)(K,{side:`right`,children:`Open thread`})]})]})})},Pd={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:[]},Fd=`Please analyze this task and create a detailed implementation plan.
|
|
47
|
+
|
|
48
|
+
Task description:
|
|
49
|
+
{description}`,Id="\nWrite your complete plan to the file `{todoId}-plan.md` in the current directory.",Ld=`Act as a Quality Assurance Manager. Rephrase the task into a rigorous test case: {description}`,Rd=`Code review: The systematic examination of code to find mistakes, ensure it follows best practices, and identify areas for improvement
|
|
50
|
+
Directions:
|
|
51
|
+
Carefully read through the list of code changes creating a todo list of code to review.
|
|
52
|
+
Analyze the code structure, variable names, functions, and logic flow
|
|
53
|
+
Look for any syntax errors, bugs, or inefficiencies
|
|
54
|
+
Consider best practices for the specific programming language used
|
|
55
|
+
Provide clear and constructive feedback on areas that could be improved
|
|
56
|
+
If applicable, include examples of how to refactor problematic code
|
|
57
|
+
Offer praise for portions of the code that are well-written and follow best practices
|
|
58
|
+
|
|
59
|
+
Task description:
|
|
60
|
+
{description}`,zd={plan:Fd,test:Ld,review:Rd},Bd={plan:`planPrompt`,test:`testPrompt`,review:`reviewPrompt`};function Vd(e,t){let n=e?.[Bd[t]];return n&&n.trim()?n:zd[t]}function Hd(e,t,n,r){let i=e.replace(/\{description\}/g,r);return t===`plan`&&(i+=Id.replace(/\{todoId\}/g,n)),i}var Ud=[`Ready`,`Plan`,`Build`,`Test`,`Review`,`Done`],Wd={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 Gd(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(`
|
|
61
|
+
`);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 Kd(e){let t=e.getReader();try{for(;;){let{done:e}=await t.read();if(e)break}}catch{}}async function qd(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(`
|
|
62
|
+
`);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}async function Jd(e){let t=await Od(e),n=t.filter(e=>e.threadId&&e.status!==`Done`),r=[...t];return await Promise.all(n.map(async t=>{try{await Ct(t.threadId)}catch(n){if(n instanceof Error&&n.message.includes(`not found`)){let n=await Ad(e,t.id,{status:`Done`}),i=r.findIndex(e=>e.id===t.id);i!==-1&&(r[i]=n)}}})),r}function Yd(e,t){return`project-todos:${e}:${t}`}function Xd({projectId:e,addOpen:t,onAddOpenChange:n,onThreadSelect:r,initialTodos:i}){let a=vi(),s=Q(e=>e.selectedThreadId),c=Q(e=>e.projectModelSelections),l=Q(e=>e.projects),[u,f]=(0,Y.useState)(i),[p,m]=(0,Y.useState)(null),[_,v]=(0,Y.useState)(``),[y,b]=(0,Y.useState)(!1),[x,S]=(0,Y.useState)(!1),[C,w]=(0,Y.useState)(null),[T,E]=(0,Y.useState)(``),[D,O]=(0,Y.useState)(!1),[A,j]=(0,Y.useState)(!1);(0,Y.useEffect)(()=>{if(!u.some(e=>e.working))return;let t=setInterval(async()=>{try{let n=await Od(e);f(n),n.some(e=>e.working)||clearInterval(t)}catch(e){console.error(`Failed to poll project todos:`,e)}},2e3);return()=>clearInterval(t)},[u,e]),(0,Y.useEffect)(()=>{t&&v(``)},[t]);function M(e){v(e.description),m({todo:e})}function N(){m(null),v(``)}async function P(){if(_.trim()){b(!0);try{let t=await kd(e,_);f(e=>[...e,t]),n(!1),v(``)}finally{b(!1)}}}async function F(){if(!(!_.trim()||!p)){b(!0);try{let t=await Ad(e,p.todo.id,{description:_});f(e=>e.map(e=>e.id===t.id?t:e)),N()}finally{b(!1)}}}async function I(){if(p){b(!0);try{await jd(e,p.todo.id),f(e=>e.filter(e=>e.id!==p.todo.id)),N()}finally{b(!1)}}}function L(e){f(t=>t.map(t=>t.id===e.id?e:t))}async function R(t){let n=s?c[s]:void 0,r=l.find(t=>t.projectId===e),i=r?.threads.find(e=>e.threadId===s),o=n?.id??i?.model,u=n?.provider??i?.modelProvider;if(!o||!u)throw console.error(`No model or provider found for project`,e,i),Error(`No model configuration found. Please configure a model and provider for this project first.`);let f=await d(e);if(!f)return;let p=null,m=await Gd(f,n=>{Ad(e,t.id,{status:`Plan`,working:!0,threadId:n}).then(e=>{p=e,L(e)})});if(!m)return;p||L(await Ad(e,t.id,{status:`Plan`,working:!0,threadId:m}));let h=n??{id:o,provider:u,name:o,description:``};a({type:Z.SetProjectModel,threadId:m,model:h}),xt(m,{model:o,modelProvider:u});let g=await et(m,Hd(Vd(r,`plan`),`plan`,t.id,t.description),o,[],void 0,u);g&&Kd(g)}async function ee(t){let n=await d(e);if(!n)return;let r=null,i=await Gd(n,n=>{Ad(e,t.id,{status:`Build`,working:!0,threadId:n}).then(e=>{r=e,L(e)})});if(!i)return;r||L(await Ad(e,t.id,{status:`Build`,working:!0,threadId:i}));let o=await Ct(i),s=o.model,c=o.modelProvider;if(!s||!c)try{let t=(await le(`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:Z.SetProjectModel,threadId:i,model:{id:s,provider:c,name:s,description:``}}),xt(i,{model:s,modelProvider:c}),console.log(`Sending chat message with provider:`,i,t.description,c);let l=await et(i,t.description,s,[],void 0,c);l&&Kd(l)}async function te(t){try{let n=await d(e);if(!n){S(!1),w(null);return}let r=null;if(r=await Gd(n,e=>{r=e}),!r){S(!1),w(null);return}let i=await Ct(r),a=i.model,o=i.modelProvider;if(!a||!o)try{let t=(await le(`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&&(a=t.model,o=t.modelProvider)}catch(e){console.error(`Failed to get project threads:`,e)}if(!a||!o){k(e,r),S(!1),w(null);return}let s=Hd(Vd(l.find(t=>t.projectId===e),`test`),`test`,t.id,t.description),c=await et(r,s,a,[],void 0,o);c&&E(await qd(c)),k(e,r)}catch(e){console.error(`Failed to generate test case:`,e),S(!1),w(null)}finally{O(!1)}}function ne(e){w(e),E(``),O(!0),S(!0),te(e)}function re(){S(!1),w(null),E(``)}async function B(){if(!C||!T.trim())return;let t=C,n=T;re(),j(!0);try{let r=await d(e);if(!r)return;let i=null,o=await Gd(r,n=>{Ad(e,t.id,{status:`Test`,working:!0,threadId:n}).then(e=>{i=e,L(e)})});if(!o)return;i||L(await Ad(e,t.id,{status:`Test`,working:!0,threadId:o}));let s=await Ct(o),c=s.model,l=s.modelProvider;if(!c||!l)try{let t=(await le(`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:Z.SetProjectModel,threadId:o,model:{id:c,provider:l,name:c,description:``}}),xt(o,{model:c,modelProvider:l});let u=await et(o,n,c,[],void 0,l);u&&Kd(u)}finally{j(!1)}}async function ie(t){let n=await d(e);if(!n)return;let r=null,i=await Gd(n,n=>{Ad(e,t.id,{status:`Review`,working:!0,threadId:n}).then(e=>{r=e,L(e)})});if(!i)return;r||L(await Ad(e,t.id,{status:`Review`,working:!0,threadId:i}));let o=await Ct(i),s=o.model,c=o.modelProvider;if(!s||!c)try{let t=(await le(`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:Z.SetProjectModel,threadId:i,model:{id:s,provider:c,name:s,description:``}}),xt(i,{model:s,modelProvider:c});let u=await et(i,Hd(Vd(l.find(t=>t.projectId===e),`review`),`review`,t.id,t.description),s,[],void 0,c);u&&Kd(u)}async function V(t,n){n===`Plan`?await R(t):n===`Build`?await ee(t):n===`Test`?ne(t):n===`Review`?await ie(t):L(await Ad(e,t.id,{status:n,working:n!==`Done`}))}return(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:Ud.map(t=>{let i=u.filter(e=>e.status===t),a=t===`Ready`;return(0,$.jsxs)(`div`,{className:q(`flex flex-col rounded-lg border border-t-4 bg-muted/30 min-w-[200px] w-[200px] shrink-0`,Wd[t]),children:[(0,$.jsxs)(`div`,{className:`px-3 py-2 flex items-center justify-between`,children:[(0,$.jsx)(`h3`,{className:q(J.dropdownGroupHeading,`uppercase tracking-wide`),children:t}),(0,$.jsx)(`span`,{className:q(J.compact,`text-muted-foreground bg-muted rounded-full px-1.5 py-0.5`),children:i.length})]}),(0,$.jsx)(Ye,{className:`flex-1 px-2 pb-2`,children:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[a&&(0,$.jsxs)(U,{variant:`outline`,size:`sm`,className:`w-full h-8 border-dashed text-muted-foreground hover:text-foreground`,onClick:()=>n(!0),children:[(0,$.jsx)(on,{className:`h-3 w-3 mr-1`}),`Add Task`]}),i.map(t=>(0,$.jsx)(Nd,{todo:t,projectId:e,onUpdate:L,onEdit:M,onAction:V,onThreadSelect:r},t.id))]})})]},t)})}),(0,$.jsx)(h,{open:t,onOpenChange:n,children:(0,$.jsxs)(H,{className:`sm:max-w-2xl`,children:[(0,$.jsx)(bt,{children:(0,$.jsx)(z,{children:`Add Task`})}),(0,$.jsxs)(`div`,{className:`py-2`,children:[(0,$.jsx)(xi,{placeholder:`Describe what needs to be done...`,value:_,onChange:e=>v(e.target.value),rows:12,className:`resize-none text-base`,autoFocus:!0,onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&P()}}),(0,$.jsx)(`p`,{className:q(J.caption,`mt-1.5`),children:`A title will be generated automatically from your description.`})]}),(0,$.jsx)(o,{children:(0,$.jsx)(U,{onClick:()=>void P(),disabled:y||!_.trim(),children:y?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(g,{className:`h-3 w-3 animate-spin mr-1`}),`Generating title...`]}):`Add`})})]})}),(0,$.jsx)(h,{open:x,onOpenChange:e=>!e&&re(),children:(0,$.jsxs)(H,{className:`sm:max-w-2xl`,children:[(0,$.jsx)(bt,{children:(0,$.jsx)(z,{children:`Test Case`})}),(0,$.jsx)(`div`,{className:`py-2`,children:D?(0,$.jsxs)(`div`,{className:`flex items-center justify-center h-32 gap-2 text-muted-foreground`,children:[(0,$.jsx)(g,{className:`h-4 w-4 animate-spin`}),(0,$.jsx)(`span`,{className:J.body,children:`Generating test case...`})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(xi,{value:T,onChange:e=>E(e.target.value),rows:12,className:`resize-none text-base`,autoFocus:!0}),(0,$.jsx)(`p`,{className:q(J.caption,`mt-1.5`),children:`Review or edit the test case before confirming.`})]})}),(0,$.jsxs)(o,{children:[(0,$.jsx)(U,{variant:`outline`,onClick:re,disabled:D,children:`Cancel`}),(0,$.jsx)(U,{onClick:()=>void B(),disabled:D||!T.trim()||A,children:A?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(g,{className:`h-3 w-3 animate-spin mr-1`}),`Starting...`]}):`Confirm`})]})]})}),(0,$.jsx)(h,{open:p!==null,onOpenChange:e=>!e&&N(),children:(0,$.jsxs)(H,{className:`sm:max-w-2xl`,children:[(0,$.jsx)(bt,{children:(0,$.jsx)(z,{children:`Edit Task`})}),(0,$.jsx)(`div`,{className:`py-2`,children:(0,$.jsx)(xi,{placeholder:`Describe what needs to be done...`,value:_,onChange:e=>v(e.target.value),rows:12,className:`resize-none text-base`,autoFocus:!0,onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&F()}})}),(0,$.jsxs)(o,{className:`gap-2 sm:gap-0`,children:[(0,$.jsx)(U,{variant:`destructive`,onClick:()=>void I(),disabled:y,className:`mr-auto`,children:`Delete`}),(0,$.jsx)(U,{onClick:()=>void F(),disabled:y||!_.trim(),children:y?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(g,{className:`h-3 w-3 animate-spin mr-1`}),`Saving...`]}):`Save`})]})]})})]})}function Zd(e){let t=(0,X.c)(13),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({projectId:r,loadVersion:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]!==n||t[5]!==r?(a=Yd(r,n),t[4]=n,t[5]=r,t[6]=a):a=t[6];let o;t[7]===r?o=t[8]:(o=()=>Jd(r),t[7]=r,t[8]=o);let s=wr(a,o),c;return t[9]!==s||t[10]!==r||t[11]!==i?(c=(0,$.jsx)(Xd,{projectId:r,initialTodos:s,...i}),t[9]=s,t[10]=r,t[11]=i,t[12]=c):c=t[12],c}function Qd(e){let t=(0,X.c)(11),[n,r]=(0,Y.useState)(0),i;t[0]!==n||t[1]!==e.projectId?(i=function(){kr(Yd(e.projectId,n)),r($d)},t[0]=n,t[1]=e.projectId,t[2]=i):i=t[2];let a=i,o;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(Dr,{className:`h-64`}),t[3]=o):o=t[3];let s=`${e.projectId}:${n}`,c;t[4]!==n||t[5]!==e||t[6]!==s?(c=(0,$.jsx)(Y.Suspense,{fallback:o,children:(0,$.jsx)(Zd,{...e,loadVersion:n},s)}),t[4]=n,t[5]=e,t[6]=s,t[7]=c):c=t[7];let l;return t[8]!==a||t[9]!==c?(l=(0,$.jsx)(Or,{fallbackTitle:`Failed to load tasks`,onRetry:a,children:c}),t[8]=a,t[9]=c,t[10]=l):l=t[10],l}function $d(e){return e+1}var ef=Pn,tf=Y.forwardRef((e,t)=>{let n=(0,X.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=q(`inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,$.jsx)(jn,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});tf.displayName=jn.displayName;var nf=Y.forwardRef((e,t)=>{let n=(0,X.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=q(`inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-base font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,$.jsx)(Ln,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});nf.displayName=Ln.displayName;var rf=Y.forwardRef((e,t)=>{let n=(0,X.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=q(`mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,$.jsx)(Vn,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});rf.displayName=Vn.displayName;var af=[{value:`plan`,label:`Plan`,field:`planPrompt`,defaultPrompt:Fd},{value:`review`,label:`Code Review`,field:`reviewPrompt`,defaultPrompt:Rd},{value:`test`,label:`Test`,field:`testPrompt`,defaultPrompt:Ld}];function of({open:e,onOpenChange:t,projectId:n}){let r=Q(e=>e.projects),[i,a]=(0,Y.useState)({plan:``,review:``,test:``}),[s,c]=(0,Y.useState)(!1);(0,Y.useEffect)(()=>{if(!e)return;let t=r.find(e=>e.projectId===n);a({plan:t?.planPrompt??``,review:t?.reviewPrompt??``,test:t?.testPrompt??``})},[e,n,r]);async function l(){c(!0);try{await _n(n,{planPrompt:i.plan.trim()===Fd?null:i.plan.trim()||null,testPrompt:i.test.trim()===Ld?null:i.test.trim()||null,reviewPrompt:i.review.trim()===Rd?null:i.review.trim()||null}),P(),Fi({title:`AI prompt settings saved`}),t(!1)}catch(e){Fi({title:`Error`,description:e instanceof Error?e.message:`Failed to save prompt settings`,variant:`destructive`})}finally{c(!1)}}function u(e,t){a(n=>({...n,[e]:t}))}return(0,$.jsx)(h,{open:e,onOpenChange:t,children:(0,$.jsxs)(H,{className:`max-w-2xl`,children:[(0,$.jsxs)(bt,{children:[(0,$.jsx)(z,{children:`AI Prompt Settings`}),(0,$.jsx)(St,{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)(ef,{defaultValue:`plan`,className:`w-full`,children:[(0,$.jsx)(tf,{className:`w-full`,children:af.map(e=>(0,$.jsx)(nf,{value:e.value,className:`flex-1`,children:e.label},e.value))}),af.map(e=>(0,$.jsxs)(rf,{value:e.value,children:[(0,$.jsx)(xi,{value:i[e.value]||e.defaultPrompt,onChange:t=>u(e.value,t.target.value),className:`min-h-[250px] font-mono resize-none`,placeholder:e.defaultPrompt,disabled:s}),(0,$.jsxs)(`p`,{className:q(J.bodyMuted,`mt-1.5`),children:[`Use `,(0,$.jsx)(`code`,{className:J.mono,children:`{description}`}),` for the task description. Leave empty to use the default.`]})]},e.value))]}),(0,$.jsx)(o,{children:(0,$.jsx)(U,{onClick:()=>void l(),disabled:s,children:s?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(g,{className:`mr-2 h-4 w-4 animate-spin`}),`Saving...`]}):`Save`})})]})})}function sf({projectId:e}){let t=vi(),r=Q(e=>e.projects),i=Q(e=>e.selectedThreadId),a=Q(e=>e.selectedProjectId),[o,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(!1),u=Qn(),{setActiveMainTab:d}=Pa();async function f(n){if(r.find(t=>t.projectId===e)){u(`/`),d(`chat`);try{let{getProjects:r,invalidateProjectsCache:o}=await fr(async()=>{let{getProjects:e,invalidateProjectsCache:t}=await import(`./dialogs-config-DZKtVbNK.js`).then(e=>e.f);return{getProjects:e,invalidateProjectsCache:t}},__vite__mapDeps([5,1]));o();let s=await r();t({type:Z.SetProjects,projects:s.projects});let c=s.projects.find(t=>t.projectId===e);if(c&&c.threads.find(e=>e.threadId===n)){(i!==n||a!==e)&&t({type:Z.SelectThread,threadId:n,projectId:e});try{let e=await ut();t({type:Z.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),(i!==n||a!==e)&&t({type:Z.SelectThread,threadId:n,projectId:e});try{let e=await ut();t({type:Z.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)(Qd,{projectId:e,addOpen:o,onAddOpenChange:s,onThreadSelect:f})}),(0,$.jsx)(U,{variant:`outline`,size:`icon`,className:`absolute bottom-8 right-4`,onClick:()=>l(!0),children:(0,$.jsx)(n,{className:`h-4 w-4`})}),(0,$.jsx)(of,{open:c,onOpenChange:l,projectId:e})]})}var cf=4,lf=`(max-width: 767px)`;function uf(e,t){let n=e.getBoundingClientRect().bottom,r=t.getBoundingClientRect().top,i=t.querySelector(`[data-chat-toolbar]`);return i&&i.getBoundingClientRect().height>0&&(r=Math.min(r,i.getBoundingClientRect().top)),Math.max(0,Math.ceil(n-r))+(window.matchMedia(lf).matches?cf:0)}function df(e,t,n){let r=(0,X.c)(5),[i,a]=(0,Y.useState)(0),o,s;return r[0]!==t||r[1]!==e||r[2]!==n?(o=()=>{if(!n){a(0);return}let r=e.current,i=t.current;if(!r||!i){a(0);return}let o=function(){let n=e.current,r=t.current;!n||!r||a(uf(n,r))};o();let s=new ResizeObserver(o);s.observe(r),s.observe(i);let c=i.querySelector(`[data-chat-toolbar]`);c&&s.observe(c);let l=new MutationObserver(o);l.observe(i,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`class`,`style`,`hidden`]}),window.addEventListener(`resize`,o);let u=window.visualViewport;return u?.addEventListener(`resize`,o),u?.addEventListener(`scroll`,o),()=>{s.disconnect(),l.disconnect(),window.removeEventListener(`resize`,o),u?.removeEventListener(`resize`,o),u?.removeEventListener(`scroll`,o)}},s=[e,t,n],r[0]=t,r[1]=e,r[2]=n,r[3]=o,r[4]=s):(o=r[3],s=r[4]),(0,Y.useEffect)(o,s),i}var ff;(function(e){e.Unimplemented=`UNIMPLEMENTED`,e.Unavailable=`UNAVAILABLE`})(ff||={});var pf=class extends Error{constructor(e,t,n){super(e),this.message=e,this.code=t,this.data=n}},mf=e=>e?.androidBridge?`android`:e?.webkit?.messageHandlers?.bridge?`ios`:`web`,hf=e=>{let t=e.CapacitorCustomPlatform||null,n=e.Capacitor||{},r=n.Plugins=n.Plugins||{},i=()=>t===null?mf(e):t.name,a=()=>i()!==`web`,o=e=>!!(l.get(e)?.platforms.has(i())||s(e)),s=e=>n.PluginHeaders?.find(t=>t.name===e),c=t=>e.console.error(t),l=new Map;return n.convertFileSrc||=e=>e,n.getPlatform=i,n.handleError=c,n.isNativePlatform=a,n.isPluginAvailable=o,n.registerPlugin=(e,a={})=>{let o=l.get(e);if(o)return console.warn(`Capacitor plugin "${e}" already registered. Cannot register plugins twice.`),o.proxy;let c=i(),u=s(e),d,f=async()=>(!d&&c in a?d=d=typeof a[c]==`function`?await a[c]():a[c]:t!==null&&!d&&`web`in a&&(d=d=typeof a.web==`function`?await a.web():a.web),d),p=(t,r)=>{if(u){let i=u?.methods.find(e=>r===e.name);if(i)return i.rtype===`promise`?t=>n.nativePromise(e,r.toString(),t):(t,i)=>n.nativeCallback(e,r.toString(),t,i);if(t)return t[r]?.bind(t)}else if(t)return t[r]?.bind(t);else throw new pf(`"${e}" plugin is not implemented on ${c}`,ff.Unimplemented)},m=t=>{let n,r=(...r)=>{let i=f().then(i=>{let a=p(i,t);if(a){let e=a(...r);return n=e?.remove,e}else throw new pf(`"${e}.${t}()" is not implemented on ${c}`,ff.Unimplemented)});return t===`addListener`&&(i.remove=async()=>n()),i};return r.toString=()=>`${t.toString()}() { [capacitor code] }`,Object.defineProperty(r,"name",{value:t,writable:!1,configurable:!1}),r},h=m(`addListener`),g=m(`removeListener`),_=(e,t)=>{let n=h({eventName:e},t),r=async()=>{g({eventName:e,callbackId:await n},t)},i=new Promise(e=>n.then(()=>e({remove:r})));return i.remove=async()=>{console.warn(`Using addListener() without 'await' is deprecated.`),await r()},i},v=new Proxy({},{get(e,t){switch(t){case`$$typeof`:return;case`toJSON`:return()=>({});case`addListener`:return u?_:h;case`removeListener`:return g;default:return m(t)}}});return r[e]=v,l.set(e,{name:e,proxy:v,platforms:new Set([...Object.keys(a),...u?[c]:[]])}),v},n.Exception=pf,n.DEBUG=!!n.DEBUG,n.isLoggingEnabled=!!n.isLoggingEnabled,n},gf=(e=>e.Capacitor=hf(e))(typeof globalThis<`u`?globalThis:typeof self<`u`?self:typeof window<`u`?window:typeof global<`u`?global:{}),_f=gf.registerPlugin,vf=class{constructor(){this.listeners={},this.retainedEventArguments={},this.windowListeners={}}addListener(e,t){let n=!1;this.listeners[e]||(this.listeners[e]=[],n=!0),this.listeners[e].push(t);let r=this.windowListeners[e];return r&&!r.registered&&this.addWindowListener(r),n&&this.sendRetainedArgumentsForEvent(e),Promise.resolve({remove:async()=>this.removeListener(e,t)})}async removeAllListeners(){this.listeners={};for(let e in this.windowListeners)this.removeWindowListener(this.windowListeners[e]);this.windowListeners={}}notifyListeners(e,t,n){let r=this.listeners[e];if(!r){if(n){let n=this.retainedEventArguments[e];n||=[],n.push(t),this.retainedEventArguments[e]=n}return}r.forEach(e=>e(t))}hasListeners(e){return!!this.listeners[e]?.length}registerWindowListener(e,t){this.windowListeners[t]={registered:!1,windowEventName:e,pluginEventName:t,handler:e=>{this.notifyListeners(t,e)}}}unimplemented(e=`not implemented`){return new gf.Exception(e,ff.Unimplemented)}unavailable(e=`not available`){return new gf.Exception(e,ff.Unavailable)}async removeListener(e,t){let n=this.listeners[e];if(!n)return;let r=n.indexOf(t);this.listeners[e].splice(r,1),this.listeners[e].length||this.removeWindowListener(this.windowListeners[e])}addWindowListener(e){window.addEventListener(e.windowEventName,e.handler),e.registered=!0}removeWindowListener(e){e&&(window.removeEventListener(e.windowEventName,e.handler),e.registered=!1)}sendRetainedArgumentsForEvent(e){let t=this.retainedEventArguments[e];t&&(delete this.retainedEventArguments[e],t.forEach(t=>{this.notifyListeners(e,t)}))}},yf=e=>encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape),bf=e=>e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent),xf=class extends vf{async getCookies(){let e=document.cookie,t={};return e.split(`;`).forEach(e=>{if(e.length<=0)return;let[n,r]=e.replace(/=/,`CAP_COOKIE`).split(`CAP_COOKIE`);n=bf(n).trim(),r=bf(r).trim(),t[n]=r}),t}async setCookie(e){try{let t=yf(e.key),n=yf(e.value),r=e.expires?`; expires=${e.expires.replace(`expires=`,``)}`:``,i=(e.path||`/`).replace(`path=`,``),a=e.url!=null&&e.url.length>0?`domain=${e.url}`:``;document.cookie=`${t}=${n||``}${r}; path=${i}; ${a};`}catch(e){return Promise.reject(e)}}async deleteCookie(e){try{document.cookie=`${e.key}=; Max-Age=0`}catch(e){return Promise.reject(e)}}async clearCookies(){try{let e=document.cookie.split(`;`)||[];for(let t of e)document.cookie=t.replace(/^ +/,``).replace(/=.*/,`=;expires=${new Date().toUTCString()};path=/`)}catch(e){return Promise.reject(e)}}async clearAllCookies(){try{await this.clearCookies()}catch(e){return Promise.reject(e)}}};_f(`CapacitorCookies`,{web:()=>new xf});var Sf=async e=>new Promise((t,n)=>{let r=new FileReader;r.onload=()=>{let e=r.result;t(e.indexOf(`,`)>=0?e.split(`,`)[1]:e)},r.onerror=e=>n(e),r.readAsDataURL(e)}),Cf=(e={})=>{let t=Object.keys(e);return Object.keys(e).map(e=>e.toLocaleLowerCase()).reduce((n,r,i)=>(n[r]=e[t[i]],n),{})},wf=(e,t=!0)=>e?Object.entries(e).reduce((e,n)=>{let[r,i]=n,a,o;return Array.isArray(i)?(o=``,i.forEach(e=>{a=t?encodeURIComponent(e):e,o+=`${r}=${a}&`}),o.slice(0,-1)):(a=t?encodeURIComponent(i):i,o=`${r}=${a}`),`${e}&${o}`},``).substr(1):null,Tf=(e,t={})=>{let n=Object.assign({method:e.method||`GET`,headers:e.headers},t),r=Cf(e.headers)[`content-type`]||``;if(typeof e.data==`string`)n.body=e.data;else if(r.includes(`application/x-www-form-urlencoded`)){let t=new URLSearchParams;for(let[n,r]of Object.entries(e.data||{}))t.set(n,r);n.body=t.toString()}else if(r.includes(`multipart/form-data`)||e.data instanceof FormData){let t=new FormData;if(e.data instanceof FormData)e.data.forEach((e,n)=>{t.append(n,e)});else for(let n of Object.keys(e.data))t.append(n,e.data[n]);n.body=t;let r=new Headers(n.headers);r.delete(`content-type`),n.headers=r}else (r.includes(`application/json`)||typeof e.data==`object`)&&(n.body=JSON.stringify(e.data));return n},Ef=class extends vf{async request(e){let t=Tf(e,e.webFetchExtra),n=wf(e.params,e.shouldEncodeUrlParams),r=n?`${e.url}?${n}`:e.url,i=await fetch(r,t),a=i.headers.get(`content-type`)||``,{responseType:o=`text`}=i.ok?e:{};a.includes(`application/json`)&&(o=`json`);let s,c;switch(o){case`arraybuffer`:case`blob`:c=await i.blob(),s=await Sf(c);break;case`json`:s=await i.json();break;default:s=await i.text()}let l={};return i.headers.forEach((e,t)=>{l[t]=e}),{data:s,headers:l,status:i.status,url:i.url}}async get(e){return this.request(Object.assign(Object.assign({},e),{method:`GET`}))}async post(e){return this.request(Object.assign(Object.assign({},e),{method:`POST`}))}async put(e){return this.request(Object.assign(Object.assign({},e),{method:`PUT`}))}async patch(e){return this.request(Object.assign(Object.assign({},e),{method:`PATCH`}))}async delete(e){return this.request(Object.assign(Object.assign({},e),{method:`DELETE`}))}};_f(`CapacitorHttp`,{web:()=>new Ef});var Df;(function(e){e.Dark=`DARK`,e.Light=`LIGHT`,e.Default=`DEFAULT`})(Df||={});var Of;(function(e){e.StatusBar=`StatusBar`,e.NavigationBar=`NavigationBar`})(Of||={});var kf=class extends vf{async setStyle(){this.unavailable(`not available for web`)}async setAnimation(){this.unavailable(`not available for web`)}async show(){this.unavailable(`not available for web`)}async hide(){this.unavailable(`not available for web`)}};_f(`SystemBars`,{web:()=>new kf});var Af;(function(e){e.Dark=`DARK`,e.Light=`LIGHT`,e.Default=`DEFAULT`})(Af||={});var jf;(function(e){e.Body=`body`,e.Ionic=`ionic`,e.Native=`native`,e.None=`none`})(jf||={});var Mf=_f(`Keyboard`);function Nf(e){let t=window.visualViewport;if(!e||!t)return 0;let n=t.height+t.offsetTop,r=e.getBoundingClientRect().bottom;return Math.max(0,Math.round(r-n))}function Pf(e,t){return Ne()?t:e>0?e:t}function Ff(e){let t=(0,X.c)(6),[n,r]=(0,Y.useState)(0),[i,a]=(0,Y.useState)(0),o,s;t[0]===e?(o=t[1],s=t[2]):(o=()=>{let t=function(){r(Nf(e.current))},n=function(){t(),requestAnimationFrame(t)};n();let i=window.visualViewport;i?.addEventListener(`resize`,n),i?.addEventListener(`scroll`,n),window.addEventListener(`resize`,n);let o=[];return T()&&o.push(Mf.addListener(`keyboardWillShow`,e=>{a(e.keyboardHeight)}),Mf.addListener(`keyboardDidShow`,e=>{a(e.keyboardHeight)}),Mf.addListener(`keyboardWillHide`,()=>{a(0)}),Mf.addListener(`keyboardDidHide`,()=>{a(0)})),()=>{i?.removeEventListener(`resize`,n),i?.removeEventListener(`scroll`,n),window.removeEventListener(`resize`,n);for(let e of o)e.then(If)}},s=[e],t[0]=e,t[1]=o,t[2]=s),(0,Y.useEffect)(o,s);let c;return t[3]!==n||t[4]!==i?(c=Pf(n,i),t[3]=n,t[4]=i,t[5]=c):c=t[5],c}function If(e){e.remove()}var Lf=(0,Y.lazy)(()=>fr(()=>import(`./diff-view-DL3hFREY.js`),__vite__mapDeps([6,1,3,4,7,5,8,9,10,11]))),Rf=(0,Y.lazy)(()=>fr(()=>import(`./dialogs-config-DZKtVbNK.js`).then(e=>e.t),__vite__mapDeps([5,1])));function zf(e){let t=(0,X.c)(61),{onCreateThread:n}=e,r=vi(),i=Qn(),a=sr(),[o,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(null),u=Q($f),d=Q(Qf),f=Q(Zf),p=Q(Xf),m=Q(Yf),h=Q(Jf),g=Q(qf),_=Q(Kf),v=Q(Gf),y=Q(Wf),b=Q(Uf),x=Q(Hf),S=Q(Vf),C;t[0]!==p||t[1]!==u?(C=u&&p.includes(u),t[0]=p,t[1]=u,t[2]=C):C=t[2];let w=!!C,T=b?.threadId===u,E;t[3]===r?E=t[4]:(E=()=>{r({type:Z.CloseSidebar})},t[3]=r,t[4]=E);let D=E,O;t[5]===D?O=t[6]:(O=()=>{D(),l(`clone`),s(!0)},t[5]=D,t[6]=O);let k=O,A;t[7]===D?A=t[8]:(A=()=>{D(),l(`webapp`),s(!0)},t[7]=D,t[8]=A);let j=A,M;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(M=async(e,t)=>{try{await hn(e,t),s(!1),l(null)}catch(e){console.error(`Failed to clone repository:`,e)}},t[9]=M):M=t[9];let N=M,P;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(P=async(e,t,n)=>{try{await Se(e,t,n),s(!1),l(null)}catch(e){console.error(`Failed to create project:`,e)}},t[10]=P):P=t[10];let F=P,I;t[11]===D?I=t[12]:(I=async()=>{D();try{await Le(),s(!1),l(null)}catch(e){console.error(`Failed to open folder:`,e)}},t[11]=D,t[12]=I);let L=I,R;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(R=async e=>{try{await bn(e),s(!1),l(null)}catch(e){console.error(`Failed to create folder:`,e)}},t[13]=R):R=t[13];let ee=R,z=a.pathname===`/review`,te=a.pathname===`/todos`,ne;t[14]===i?ne=t[15]:(ne=()=>{i(`/`)},t[14]=i,t[15]=ne);let re=ne;Td();let B;t[16]===x?B=t[17]:(B=gc(x),t[16]=x,t[17]=B);let ie=B,V;t[18]===x?V=t[19]:(V=_c(x),t[18]=x,t[19]=V);let ae=V,H=(0,Y.useRef)(null),oe=(0,Y.useRef)(null),se=(0,Y.useRef)(null),ce=wd(),[le,ue]=(0,Y.useState)(!0),de=!z&&!te&&!!u,fe=ce&&de&&!le,pe=df(H,oe,de),me=Ff(oe),he;t[20]!==pe||t[21]!==D||t[22]!==r||t[23]!==k||t[24]!==re||t[25]!==j||t[26]!==L||t[27]!==T||t[28]!==f||t[29]!==w||t[30]!==_||t[31]!==d||t[32]!==g||t[33]!==n||t[34]!==m||t[35]!==h||t[36]!==z||t[37]!==S||t[38]!==u||t[39]!==y||t[40]!==v||t[41]!==te?(he=te&&S?(0,$.jsx)(sf,{projectId:S}):z&&u?(0,$.jsx)(Y.Suspense,{fallback:(0,$.jsx)(Dr,{}),children:(0,$.jsx)(Lf,{threadId:u,onExit:re})}):(0,$.jsx)(mc,{ref:se,bottomInset:pe,messages:d,isStreaming:_,streamingSegments:v,streamingModel:y,isCreatingProject:f,isProcessingThread:w,hasPendingMessage:T,selectedThreadId:u,selectedProjectId:S,projects:m,projectsLoading:h,messagesLoaded:g,onSelectThread:(e,t)=>{D(),r({type:Z.SelectThread,projectId:e,threadId:t})},onCreateThread:n,onConnectRepo:k,onNewApp:j,onOpenFolder:L,error:null,onClearError:Bf,onAtBottomChange:ue}),t[20]=pe,t[21]=D,t[22]=r,t[23]=k,t[24]=re,t[25]=j,t[26]=L,t[27]=T,t[28]=f,t[29]=w,t[30]=_,t[31]=d,t[32]=g,t[33]=n,t[34]=m,t[35]=h,t[36]=z,t[37]=S,t[38]=u,t[39]=y,t[40]=v,t[41]=te,t[42]=he):he=t[42];let ge;t[43]!==ie||t[44]!==ae||t[45]!==me||t[46]!==d||t[47]!==de||t[48]!==fe?(ge=de&&(0,$.jsxs)(`div`,{ref:oe,className:`absolute left-0 right-0 z-10 max-md:px-2`,style:{bottom:me},children:[(0,$.jsx)(`div`,{className:`h-0 md:h-6`,style:{backgroundImage:ae}}),(0,$.jsx)(`div`,{className:`h-0 md:h-8`,style:{backgroundImage:ie}}),fe&&(0,$.jsx)(`div`,{className:`mb-1 flex justify-center`,children:(0,$.jsx)(`button`,{type:`button`,onClick:()=>se.current?.scrollToBottom(),className:`flex h-8 w-8 items-center justify-center rounded-full border border-border bg-background shadow-md transition-colors hover:bg-accent active:bg-accent`,"aria-label":`Scroll to bottom`,children:(0,$.jsx)(wt,{className:`h-4 w-4`})})}),(0,$.jsx)(`div`,{style:{backgroundImage:ie},children:(0,$.jsx)(vd,{messages:d})})]}),t[43]=ie,t[44]=ae,t[45]=me,t[46]=d,t[47]=de,t[48]=fe,t[49]=ge):ge=t[49];let _e=c??void 0,ve;t[50]!==o||t[51]!==L||t[52]!==_e?(ve=(0,$.jsx)(Y.Suspense,{fallback:null,children:(0,$.jsx)(Rf,{open:o,onOpenChange:s,initialMode:_e,onSubmitClone:N,onSubmitWebApp:F,onSubmitFolder:ee,onOpenFolder:L})}),t[50]=o,t[51]=L,t[52]=_e,t[53]=ve):ve=t[53];let ye;t[54]!==he||t[55]!==ge||t[56]!==ve?(ye=(0,$.jsxs)(`div`,{ref:H,className:`relative flex h-full flex-col`,children:[he,ge,ve]}),t[54]=he,t[55]=ge,t[56]=ve,t[57]=ye):ye=t[57];let be;return t[58]!==u||t[59]!==ye?(be=(0,$.jsx)(Ro,{threadId:u,children:ye}),t[58]=u,t[59]=ye,t[60]=be):be=t[60],be}function Bf(){}function Vf(e){return e.selectedProjectId}function Hf(e){return e.sidebarOpen}function Uf(e){return e.pendingChatMessage}function Wf(e){return e.streamingModel}function Gf(e){return e.streamingSegments}function Kf(e){return e.isStreaming}function qf(e){return e.messagesLoaded}function Jf(e){return e.projectsLoading}function Yf(e){return e.projects}function Xf(e){return e.processingThreadIds}function Zf(e){return e.isCreatingProject}function Qf(e){return e.messages}function $f(e){return e.selectedThreadId}function ep(e){let t=(0,X.c)(5),{children:n,className:r}=e,i;t[0]===r?i=t[1]:(i=q(`flex min-h-[71px] shrink-0 items-center gap-2 px-4 py-2 electrobun-webkit-app-region-drag`,r),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,$.jsx)(`header`,{className:i,children:n}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a}function tp(e){let t=(0,X.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 np(){let e=(0,X.c)(42),t=vi(),n=Q(op),r=Q(ap),i=Q(ip),a=Q(rp),o;if(e[0]!==i||e[1]!==r){let t;e[3]===r?t=e[4]:(t=e=>e.projectId===r,e[3]=r,e[4]=t),o=i.find(t),e[0]=i,e[1]=r,e[2]=o}else o=e[2];let s=o,c=!a&&`max-md:pb-2 md:h-auto md:pb-3 md:h-[103px] md:pb-0`,l;e[5]===c?l=e[6]:(l=q(`pt-8 md:min-h-[103px]`,c),e[5]=c,e[6]=l);let u;e[7]===t?u=e[8]:(u=()=>t({type:Z.ToggleSidebar}),e[7]=t,e[8]=u);let d;e[9]===a?d=e[10]:(d=a?(0,$.jsx)(ct,{className:`h-4 w-4`}):(0,$.jsx)(dt,{className:`h-4 w-4`}),e[9]=a,e[10]=d);let f;e[11]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(`span`,{className:`sr-only`,children:`Toggle sidebar`}),e[11]=f):f=e[11];let p;e[12]!==u||e[13]!==d?(p=(0,$.jsxs)(U,{variant:`ghost`,size:`icon`,className:`h-8 w-8 text-muted-foreground shrink-0 electrobun-webkit-app-region-no-drag`,onClick:u,children:[d,f]}),e[12]=u,e[13]=d,e[14]=p):p=e[14];let m;e[15]!==i||e[16]!==r||e[17]!==n?(m=n&&(0,$.jsx)(`span`,{className:q(J.sectionTitle,`text-foreground truncate min-w-0`),children:Ht(i,r)}),e[15]=i,e[16]=r,e[17]=n,e[18]=m):m=e[18];let h;e[19]!==p||e[20]!==m?(h=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[p,m]}),e[19]=p,e[20]=m,e[21]=h):h=e[21];let g;e[22]===n?g=e[23]:(g=n&&(0,$.jsx)($u,{}),e[22]=n,e[23]=g);let _;e[24]!==s?.runCommand||e[25]!==r||e[26]!==n?(_=r&&(0,$.jsxs)(tp,{className:`electrobun-webkit-app-region-no-drag`,children:[(0,$.jsx)(Ku,{projectId:r,runCommand:s?.runCommand}),n&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ju,{threadId:n}),(0,$.jsx)(Pu,{})]})]}),e[24]=s?.runCommand,e[25]=r,e[26]=n,e[27]=_):_=e[27];let v;e[28]!==s?.openWith||e[29]!==r||e[30]!==n?(v=n&&r&&(0,$.jsx)(tp,{className:`electrobun-webkit-app-region-no-drag`,children:(0,$.jsx)(Hu,{projectId:r,threadId:n,openWith:s?.openWith})}),e[28]=s?.openWith,e[29]=r,e[30]=n,e[31]=v):v=e[31];let y;e[32]!==_||e[33]!==v?(y=(0,$.jsxs)(`div`,{className:`hidden md:flex flex-wrap items-center justify-end gap-2`,children:[_,v]}),e[32]=_,e[33]=v,e[34]=y):y=e[34];let b;e[35]!==y||e[36]!==g?(b=(0,$.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-2`,children:[g,y]}),e[35]=y,e[36]=g,e[37]=b):b=e[37];let x;return e[38]!==b||e[39]!==l||e[40]!==h?(x=(0,$.jsxs)(ep,{className:l,children:[h,b]}),e[38]=b,e[39]=l,e[40]=h,e[41]=x):x=e[41],x}function rp(e){return e.sidebarOpen}function ip(e){return e.projects}function ap(e){return e.selectedProjectId}function op(e){return e.selectedThreadId}function sp(e){let t=(0,X.c)(14),{open:n,projectName:r,onOpenChange:i,onConfirm:a}=e,o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(yr,{children:`Delete Project`}),t[0]=o):o=t[0];let s;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(s=q(J.body,`font-semibold text-foreground`),t[1]=s):s=t[1];let c;t[2]===r?c=t[3]:(c=(0,$.jsxs)(vr,{children:[o,(0,$.jsxs)(xr,{children:[`Are you sure you want to delete`,` `,(0,$.jsxs)(`span`,{className:s,children:[`"`,r,`"`]}),`? This will remove the project and all its data. This action cannot be undone.`]})]}),t[2]=r,t[3]=c);let l;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(Tr,{children:`Cancel`}),t[4]=l):l=t[4];let u;t[5]===a?u=t[6]:(u=(0,$.jsxs)(Cr,{children:[l,(0,$.jsx)(_r,{onClick:a,className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:`Delete`})]}),t[5]=a,t[6]=u);let d;t[7]!==c||t[8]!==u?(d=(0,$.jsxs)(br,{children:[c,u]}),t[7]=c,t[8]=u,t[9]=d):d=t[9];let f;return t[10]!==i||t[11]!==n||t[12]!==d?(f=(0,$.jsx)(Er,{open:n,onOpenChange:i,children:d}),t[10]=i,t[11]=n,t[12]=d,t[13]=f):f=t[13],f}function cp(e){let t=(0,X.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)(yr,{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)(vr,{children:[o,(0,$.jsxs)(xr,{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(lp),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)(Tr,{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)(_r,{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)(Cr,{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)(br,{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)(Er,{open:n,onOpenChange:a,children:h}),t[24]=n,t[25]=a,t[26]=h,t[27]=g):g=t[27],g}function lp(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:J.label,children:r||`root`}),(0,$.jsx)(`div`,{className:J.bodyMuted,children:i})]})]})},t)}function up(){let[e,t]=(0,Y.useState)(!0),[n,r]=(0,Y.useState)(O),[i,a]=(0,Y.useState)(null),[o,s]=(0,Y.useState)(!1);(0,Y.useEffect)(()=>{let e=!0;return(async()=>{try{let n=await fetch(`${x()}/health`,{method:`GET`});e&&t(n.ok)}catch{e&&t(!1)}})(),()=>{e=!1}},[]);let l=(0,Y.useCallback)(async()=>{let e=c(n);if(e){a(null),s(!0);try{if(!await N(e)){a(e);return}Ae(n)}finally{s(!1)}}},[n]);return e?null:(0,$.jsx)(Er,{open:!0,children:(0,$.jsxs)(br,{children:[(0,$.jsxs)(vr,{children:[(0,$.jsx)(`img`,{src:`/tarsk-color.svg`,alt:`Tarsk`,className:`mx-auto h-16 w-16 rounded-lg`}),(0,$.jsx)(yr,{children:`Connect to Tarsk`}),(0,$.jsx)(xr,{children:`Connect to the Tarsk server running on your local network by entering the IP Address or domain name below.`})]}),(0,$.jsx)(y,{value:n,onChange:e=>{r(e.target.value),a(null)},onKeyDown:e=>{e.key===`Enter`&&!o&&l()},placeholder:`192.168.1.100`,autoComplete:`off`,spellCheck:!1,disabled:o}),i&&(0,$.jsxs)(jr,{variant:`error`,className:`mb-0 flex items-start gap-3`,children:[(0,$.jsxs)(`p`,{className:`flex-1`,children:[`Unable to connect to `,i,`. Please check that you are on the same network and that the Tarsk server is running and accessible on the network.`]}),(0,$.jsx)(U,{type:`button`,variant:`ghost`,size:`icon`,className:`h-8 w-8 shrink-0`,"aria-label":`Dismiss error`,onClick:()=>a(null),children:(0,$.jsx)(A,{className:`h-4 w-4`})})]}),(0,$.jsx)(Cr,{children:(0,$.jsx)(U,{onClick:()=>void l(),disabled:!n.trim()||o,children:o?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(g,{className:`mr-2 h-4 w-4 animate-spin`}),`Connecting...`]}):`Connect`})}),(0,$.jsxs)(jr,{variant:`hint`,className:`mb-0`,children:[(0,$.jsx)(`p`,{className:J.bodyMuted,children:`Start the Tarsk server on your local machine by running:`}),(0,$.jsx)(`code`,{className:q(J.mono,`mt-2 block rounded bg-background/60 px-2 py-1 text-foreground`),children:`npx tarsk --server`})]})]})})}var dp=e=>{let t=(0,X.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=q(`flex h-full w-full data-[panel-group-direction=vertical]:flex-col`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(Rn,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a},fp=tr,pp=e=>{let t=(0,X.c)(12),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({withHandle:i,className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===n?a=t[5]:(a=q(`relative flex w-px items-center justify-center bg-transparent after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:-translate-y-1/2 data-[panel-group-direction=vertical]:after:translate-x-0 [&[data-panel-group-direction=vertical]>div]:rotate-90`,n),t[4]=n,t[5]=a);let o;t[6]===i?o=t[7]:(o=i&&(0,$.jsx)(`div`,{className:`hidden z-10 flex h-4 w-3 items-center justify-center rounded-sm border bg-border`,children:(0,$.jsx)(re,{className:`h-2.5 w-2.5`})}),t[6]=i,t[7]=o);let s;return t[8]!==r||t[9]!==a||t[10]!==o?(s=(0,$.jsx)(zn,{className:a,...r,children:o}),t[8]=r,t[9]=a,t[10]=o,t[11]=s):s=t[11],s},mp=kn,hp=Y.forwardRef((e,t)=>{let n=(0,X.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=q(`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)(Dn,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});hp.displayName=Dn.displayName;var gp=kt(`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`}}),_p=Y.forwardRef((e,t)=>{let n=(0,X.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=q(gp({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)(Bn,{ref:t,className:o,...i}),n[7]=i,n[8]=t,n[9]=o,n[10]=s):s=n[10],s});_p.displayName=Bn.displayName;var vp=Y.forwardRef((e,t)=>{let n=(0,X.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=q(`inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 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`,J.body,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,$.jsx)(ur,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});vp.displayName=ur.displayName;var yp=Y.forwardRef((e,t)=>{let n=(0,X.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=q(`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)(A,{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)(Wn,{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});yp.displayName=Wn.displayName;var bp=Y.forwardRef((e,t)=>{let n=(0,X.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=q(J.dialogTitle,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,$.jsx)(nr,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});bp.displayName=nr.displayName;var xp=Y.forwardRef((e,t)=>{let n=(0,X.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=q(J.body,`opacity-90 text-muted-foreground group-[.destructive]:text-destructive-foreground`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,$.jsx)(An,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});xp.displayName=An.displayName;function Sp(){let e=(0,X.c)(5),{toasts:t}=Ii(),n;e[0]===t?n=e[1]:(n=t.map(Cp),e[0]=t,e[1]=n);let r;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(hp,{}),e[2]=r):r=e[2];let i;return e[3]===n?i=e[4]:(i=(0,$.jsxs)(mp,{children:[n,r]}),e[3]=n,e[4]=i),i}function Cp(e){let{id:t,title:n,description:r,action:i,...a}=e;return(0,$.jsxs)(_p,{...a,children:[(0,$.jsxs)(`div`,{className:`grid gap-1`,children:[n&&(0,$.jsx)(bp,{children:n}),r&&(0,$.jsx)(xp,{children:r})]}),i,(0,$.jsx)(yp,{})]},t)}function wp(){let e=(0,X.c)(4),{resolvedTheme:t,theme:n}=Rr(),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,Y.useEffect)(r,i),null}function Tp(e){let t=(0,X.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)(wp,{}),t[3]=i):i=t[3];let a;return t[4]!==n||t[5]!==r?(a=(0,$.jsxs)(zr,{...r,children:[i,n]}),t[4]=n,t[5]=r,t[6]=a):a=t[6],a}function Ep(){let e=(0,X.c)(14),t=vi(),n=Q(kp),r=wr(`projects:bootstrap:${Q(Op)}`,xe),i;e[0]!==r.projects||e[1]!==t?(i=()=>{t({type:Z.SetProjects,projects:r.projects}),t({type:Z.SetProjectsLoading,projectsLoading:!1})},e[0]=r.projects,e[1]=t,e[2]=i):i=e[2];let a;e[3]!==r||e[4]!==t?(a=[r,t],e[3]=r,e[4]=t,e[5]=a):a=e[5],(0,Y.useLayoutEffect)(i,a);let o;e[6]!==r.projects||e[7]!==t||e[8]!==n?(o=()=>{if(!n)for(let e of r.projects){let n=e.threads.find(Dp);if(n){t({type:Z.SelectThread,threadId:n.threadId,projectId:e.projectId});break}}},e[6]=r.projects,e[7]=t,e[8]=n,e[9]=o):o=e[9];let s;return e[10]!==r||e[11]!==t||e[12]!==n?(s=[r,t,n],e[10]=r,e[11]=t,e[12]=n,e[13]=s):s=e[13],(0,Y.useLayoutEffect)(o,s),null}function Dp(e){return e.isSelected}function Op(e){return e.configUpdatedAt}function kp(e){return e.selectedThreadId}function Ap(e){let t=vi(),n=Q(e=>e.projects),r=Q(e=>e.selectedProjectId),i=Q(e=>e.selectedThreadId),{toast:a}=Ii(),o=bi(`project-creation`).dispatch,[s,c]=(0,Y.useState)(null),l=(0,Y.useCallback)(async()=>{try{t({type:Z.SetProjectsLoading,projectsLoading:!0}),P(),Ar(`projects:bootstrap:`);let e=await xe();t({type:Z.SetProjects,projects:e.projects})}catch(e){console.error(`Failed to refresh projects:`,e)}finally{t({type:Z.SetProjectsLoading,projectsLoading:!1})}},[t]),u=(0,Y.useCallback)((e,n)=>{(i!==n||r!==e)&&t({type:Z.SelectThread,threadId:n,projectId:e}),sn(e,n).catch(e=>{console.error(`Failed to select thread:`,e)})},[t,i,r]),f=(0,Y.useCallback)(async n=>{t({type:Z.SetCreatingProject,isCreating:!0});try{let r=await n.apiCall();if(!r){t({type:Z.SetCreatingProject,isCreating:!1}),await l();return}let i=n.useTerminalDispatch?o:t;i({type:Z.ClearTerminalOutput}),i({type:Z.SetTerminalOpen,open:!0}),i({type:Z.AppendTerminalLine,line:{type:`system`,content:n.initialMessage}});let a=r.getReader(),s=new TextDecoder,u=``,d=null,f=!1,p=null,m=null;for(;;){let{done:e,value:r}=await a.read();if(e)break;u+=s.decode(r,{stream:!0});let o=u.split(`
|
|
63
|
+
`);u=o.pop()??``;for(let e of o){let r=e.trim();if(r)try{let e=JSON.parse(r);if(e.type===`progress`)!f&&e.threadId&&e.projectId&&(f=!0,p=e.projectId,m=e.threadId,t({type:Z.AddCreatingProject,projectId:e.projectId,threadId:e.threadId,projectName:n.optimisticProjectName,gitUrl:n.gitUrl??``}),t({type:Z.AddProcessingThread,threadId:e.threadId})),t({type:Z.AppendTerminalLine,...n.useTerminalDispatch?{threadId:m??`project-creation`}:{},line:{type:`output`,content:e.message}});else if(e.type===`complete`){if(e.project){d=e.project.id;let r=n.includeThreadPath&&e.project.threads?.length>0?`${e.project.path}/${e.project.threads[0]}`:e.project.path;i({type:Z.AppendTerminalLine,line:{type:`system`,content:`Project created successfully at: ${r}`}}),t({type:Z.SetTerminalOpen,open:!1}),n.handleSetupScript&&e.suggestedSetupScript&&c({projectId:e.project.id,command:e.suggestedSetupScript,remainingScripts:e.project.pendingSetupScripts??[]})}}else e.type===`error`&&(f&&p&&(t({type:Z.RemoveCreatingProject,projectId:p}),m&&t({type:Z.RemoveProcessingThread,threadId:m})),t({type:Z.AppendTerminalLine,...n.useTerminalDispatch?{threadId:m??`project-creation`}:{},line:{type:`error`,content:`Error: ${e.message}`}}))}catch(e){console.error(`Failed to parse ${n.logTag} event`,e)}}}t({type:Z.SetCreatingProject,isCreating:!1}),f&&m&&t({type:Z.RemoveProcessingThread,threadId:m}),P();let h=await xe();if(t({type:Z.SetProjects,projects:h.projects}),t({type:Z.SetProjectsLoading,projectsLoading:!1}),d){let n=h.projects.find(e=>e.projectId===d);if(n&&n.threads.length>0){let e=n.threads[0].threadId;t({type:Z.SelectThread,threadId:e,projectId:d,focusInput:!0})}e?.onProjectCreated?.(d)}}catch(e){console.error(`Failed to ${n.logTag}:`,e),t({type:Z.SetCreatingProject,isCreating:!1}),(n.useTerminalDispatch?o:t)({type:Z.AppendTerminalLine,line:{type:`error`,content:`${n.catchErrorPrefix}: ${e instanceof Error?e.message:`Unknown error`}`}})}},[t,l,o,e?.onProjectCreated]),p=(0,Y.useCallback)(async(e,t)=>{let n=e.split(`/`).pop()?.replace(`.git`,``)??`project`;await f({apiCall:()=>hn(e,t),initialMessage:`Cloning repository: ${e}...`,optimisticProjectName:n,gitUrl:e,useTerminalDispatch:!0,includeThreadPath:!0,handleSetupScript:!0,logTag:`create project`,catchErrorPrefix:`Failed to create project`})},[f]),h=(0,Y.useCallback)(async(e,t,n)=>{await f({apiCall:()=>Se(e,t,n),initialMessage:`Creating app "${e}"...`,optimisticProjectName:e,useTerminalDispatch:!0,handleSetupScript:!1,logTag:`create web app`,catchErrorPrefix:`Failed to create web app`})},[f]),g=(0,Y.useCallback)(async e=>{await f({apiCall:()=>bn(e),initialMessage:`Creating folder "${e}"...`,optimisticProjectName:e,useTerminalDispatch:!0,handleSetupScript:!1,logTag:`create folder`,catchErrorPrefix:`Failed to create folder`})},[f]),_=(0,Y.useCallback)(async(e,r)=>{try{let i=r??(()=>{let t=n.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 d(e,r);if(!o){await l();return}let s=o.getReader(),c=new TextDecoder,u=``,f=!1,p=null,m=!0,h=[{type:`system`,content:`Creating thread "${i}"...`}];try{for(;;){let{done:n,value:r}=await s.read();if(n)break;u+=c.decode(r,{stream:!0});let o=u.split(`
|
|
64
|
+
`);u=o.pop()??``;for(let n of o){let r=n.trim();if(r)try{let n=JSON.parse(r);if(n.type===`progress`){if(!f&&n.threadId){f=!0,p=n.threadId,t({type:Z.AddCreatingThread,projectId:e,threadId:n.threadId,title:i}),t({type:Z.AddProcessingThread,threadId:n.threadId}),t({type:Z.ClearTerminalOutput,threadId:p});for(let e of h)t({type:Z.AppendTerminalLine,threadId:p,line:e});h.length=0}let r={type:`output`,content:n.message};p?t({type:Z.AppendTerminalLine,threadId:p,line:r}):h.push(r)}else if(n.type===`error`){f&&p&&(t({type:Z.RemoveCreatingThread,projectId:e,threadId:p}),t({type:Z.RemoveProcessingThread,threadId:p}));let r={type:`error`,content:`Error: ${n.message}`};p?t({type:Z.AppendTerminalLine,threadId:p,line:r}):h.push(r),console.error(`Thread creation error:`,n.message),a({title:`Thread Creation Failed`,description:n.message,variant:`destructive`}),m=!1}}catch(e){console.error(`Failed to parse thread event`,e)}}}f&&p&&t({type:Z.RemoveProcessingThread,threadId:p}),P(),await l(),p&&m&&t({type:Z.SelectThread,threadId:p,projectId:e,focusInput:!0})}catch(n){throw f&&p&&(t({type:Z.RemoveCreatingThread,projectId:e,threadId:p}),t({type:Z.RemoveProcessingThread,threadId:p})),a({title:`Thread Creation Failed`,description:n instanceof Error?n.message:String(n),variant:`destructive`}),n}}catch(e){console.error(`Failed to create thread:`,e);let n=`Failed to create thread: ${e instanceof Error?e.message:`Unknown error`}`;throw t({type:Z.AppendTerminalLine,line:{type:`error`,content:n}}),a({variant:`destructive`,title:`Thread Creation Failed`,description:n}),e}},[l,t,n,a]),v=(0,Y.useCallback)(async(e,n)=>{t({type:Z.AddDeletingThread,threadId:n}),t({type:Z.ClearChatInputDraft,threadId:n});try{await k(e,n),i===n&&t({type:Z.SelectThread,threadId:``,projectId:``}),await l(),t({type:Z.ConfigUpdated})}catch(e){console.error(`Failed to delete thread:`,e),a({variant:`destructive`,title:`Failed to delete thread`,description:e instanceof Error?e.message:`Unknown error`})}finally{t({type:Z.RemoveDeletingThread,threadId:n})}},[l,i,t,a]),y=(0,Y.useCallback)(async e=>{t({type:Z.AddDeletingProject,projectId:e});let i=n.find(t=>t.projectId===e)?.threads.map(e=>e.threadId)??[];for(let e of i)t({type:Z.AddDeletingThread,threadId:e}),t({type:Z.ClearChatInputDraft,threadId:e});try{await ne(e),r===e&&t({type:Z.SelectThread,threadId:``,projectId:``}),await l(),t({type:Z.ConfigUpdated})}catch(e){console.error(`Failed to delete project:`,e)}finally{t({type:Z.RemoveDeletingProject,projectId:e});for(let e of i)t({type:Z.RemoveDeletingThread,threadId:e})}},[l,r,n,t]),b=(0,Y.useCallback)(async e=>{let n=s;if(c(null),!n||!e)return;let{projectId:r,command:i,remainingScripts:a}=n,o=[i,...a||[]];try{t({type:Z.SetCreatingProject,isCreating:!0}),t({type:Z.SetTerminalOpen,open:!0}),t({type:Z.AppendTerminalLine,line:{type:`system`,content:`Installing dependencies for ${o.length} package${o.length===1?``:`s`}...`}});for(let e=0;e<o.length;e++){let n=o[e],i=n.match(/^cd "([^"]+)" && (.+)$/),a=i?i[1]:`root`;t({type:Z.AppendTerminalLine,line:{type:`system`,content:`Installing package ${e+1}/${o.length} in ${a}...`}}),t({type:Z.AppendTerminalLine,line:{type:`output`,content:`📦 Installing dependencies in ${a}: ${n}`}});let s=await m(r,n,!0);if(s){let e=s.getReader(),n=new TextDecoder,r=``;for(;;){let{done:i,value:a}=await e.read();if(i)break;r+=n.decode(a,{stream:!0});let o=r.split(`
|
|
65
|
+
`);r=o.pop()??``;for(let e of o)if(e.trim())try{let n=JSON.parse(e);typeof n==`string`?t({type:Z.AppendTerminalLine,line:{type:`output`,content:n}}):n.type===`error`&&t({type:Z.AppendTerminalLine,line:{type:`error`,content:n.message}})}catch{t({type:Z.AppendTerminalLine,line:{type:`output`,content:e}})}}if(r.trim())try{let e=JSON.parse(r);typeof e==`string`?t({type:Z.AppendTerminalLine,line:{type:`output`,content:e}}):e.type===`error`&&t({type:Z.AppendTerminalLine,line:{type:`error`,content:e.message}})}catch{t({type:Z.AppendTerminalLine,line:{type:`output`,content:r}})}}e<o.length-1&&(t({type:Z.AppendTerminalLine,line:{type:`system`,content:``}}),t({type:Z.AppendTerminalLine,line:{type:`system`,content:`---`}}),t({type:Z.AppendTerminalLine,line:{type:`system`,content:``}}))}t({type:Z.AppendTerminalLine,line:{type:`system`,content:`All dependencies installed successfully!`}}),t({type:Z.SetCreatingProject,isCreating:!1}),await l()}catch(e){t({type:Z.SetCreatingProject,isCreating:!1}),console.error(`Failed to run setup script:`,e),t({type:Z.AppendTerminalLine,line:{type:`error`,content:`Failed to run setup script: ${e instanceof Error?e.message:`Unknown error`}`}})}},[s,t,l]);return{projects:n,selectedProjectId:r,selectedThreadId:i,refreshProjects:l,handleSelectThread:u,handleCreateProject:p,handleCreateWebApp:h,handleCreateFolder:g,handleOpenFolder:(0,Y.useCallback)(async()=>{await f({apiCall:Le,initialMessage:`Opening folder...`,optimisticProjectName:`Opening folder...`,useTerminalDispatch:!0,handleSetupScript:!0,logTag:`open folder`,catchErrorPrefix:`Failed to open folder`})},[f]),handleCreateThread:_,handleDeleteThread:v,confirmDeleteProject:y,pendingSetupScriptConfirmation:s,resolveSetupScriptConfirmation:b}}function jp(){let e=(0,X.c)(2),[t,n]=(0,Y.useState)(Mp),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,Y.useEffect)(r,i),t}function Mp(){return document.hasFocus()}var Np=null;function Pp(){Np??=new Audio(`/pop.wav`),Np.currentTime=0,Np.play().catch(e=>{console.debug(`Could not play completion sound:`,e)})}function Fp(){let e=vi(),t=_i(),n=Q(e=>e.processingThreadIds),r=Q(e=>e.completedThreadIds),i=Q(e=>e.isCreatingProject),a=Q(e=>Object.values(e.threadStreamingStates).some(e=>e.isStreaming)),o=jp(),s=(0,Y.useRef)(null),c=(0,Y.useRef)(!1),l=(0,Y.useRef)([]),u=(0,Y.useRef)(o);(0,Y.useEffect)(()=>{u.current=o},[o]);let d=(0,Y.useCallback)(async()=>{try{let n=ld(await ut()),r=l.current.filter(e=>!n.includes(e));for(let n of r)n!==t.getState().selectedThreadId&&e({type:Z.MarkThreadCompleted,threadId:n});return r.length>0&&!u.current&&Pp(),l.current=n,e({type:Z.SetProcessingThreads,threadIds:n}),n}catch(e){return console.error(`Failed to fetch processing threads:`,e),[]}},[e,t]);return(0,Y.useEffect)(()=>{let e=()=>{if(s.current||c.current)return;c.current=!0;let e=async()=>{let n=await d(),r=t.getState(),i=Object.values(r.threadStreamingStates).some(e=>e.isStreaming);n.length>0||i||r.isCreatingProject?s.current=setTimeout(e,1e3):(s.current=null,c.current=!1)};e()},n=()=>{s.current&&=(clearTimeout(s.current),null),c.current=!1};return e(),()=>{n()}},[n.length,a,i,d]),{processingThreadIds:n,completedThreadIds:r,isThreadProcessing:e=>n.includes(e),isThreadCompleted:e=>r.includes(e),clearCompleted:(0,Y.useCallback)(t=>{e({type:Z.ClearThreadCompleted,threadId:t})},[e])}}var Ip=(0,Y.lazy)(()=>fr(()=>import(`./terminal-panel-D3Ru16FT.js`).then(e=>({default:e.TerminalPanel})),__vite__mapDeps([12,1,5]))),Lp=(0,Y.lazy)(()=>fr(()=>import(`./diff-view-DL3hFREY.js`),__vite__mapDeps([6,1,3,4,7,5,8,9,10,11]))),Rp=(0,Y.lazy)(()=>fr(()=>import(`./explorer-tab-view-DAs4rpHu.js`),__vite__mapDeps([13,1,3,4,7,5]))),zp=(0,Y.lazy)(()=>fr(()=>import(`./browser-tab-DeoHDVON.js`).then(e=>({default:e.BrowserTab})),__vite__mapDeps([14,1,5]))),Bp=(0,Y.lazy)(()=>fr(()=>import(`./dialogs-config-DZKtVbNK.js`).then(e=>e.t),__vite__mapDeps([5,1]))),Vp=(0,Y.lazy)(()=>fr(()=>import(`./onboarding-CxtzQldG.js`).then(e=>e.t),__vite__mapDeps([8,1,7,5]))),Hp=(0,Y.lazy)(()=>fr(()=>import(`./settings-view-rUCFRiPR.js`),__vite__mapDeps([15,1,3,4,7,5,8,16,17,10])));function Up(e){return e.startsWith(`/settings`)||e===`/review`}function Wp(){let e=(0,X.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 Gp(){let e=vi(),t=Q(e=>e.selectedThreadId),n=Q(e=>e.selectedProjectId),r=Q(e=>e.sidebarOpen),i=Q(e=>e.deletingThreadIds),a=Q(e=>e.deletingProjectIds);(0,Y.useEffect)(()=>{window.__electrobunWebviewId&&new Jr({})},[]);let o=Qn(),s=sr(),c=Ec(),l=c||T(),[u,d]=(0,Y.useState)(null),{projects:f,handleSelectThread:p,handleCreateProject:m,handleCreateWebApp:h,handleCreateFolder:g,handleOpenFolder:_,handleCreateThread:v,handleDeleteThread:y,confirmDeleteProject:b,refreshProjects:x,pendingSetupScriptConfirmation:S,resolveSetupScriptConfirmation:C}=Ap({onProjectCreated:d}),{processingThreadIds:w,completedThreadIds:E,clearCompleted:D}=Fp(),[O,k]=(0,Y.useState)(`chat`),[A,j]=(0,Y.useState)(null),[M,N]=(0,Y.useState)(!1),[P,F]=(0,Y.useState)(!1),[I,L]=(0,Y.useState)(!1),[R,ee]=(0,Y.useState)(null),[z,te]=(0,Y.useState)(0),[ne,re]=(0,Y.useState)(null),[B,ie]=(0,Y.useState)(0),{terminalState:V}=bi(t),ae=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{V.open&&t===ae.current&&!Up(s.pathname)&&k(`terminal`),ae.current=t},[V.open,t,s.pathname]);let[H,oe]=(0,Y.useState)(!1),[se,ce]=(0,Y.useState)(!1),[le,ue]=(0,Y.useState)(!1),[de,fe]=(0,Y.useState)(null),[pe,me]=(0,Y.useState)(!1),[he,ge]=(0,Y.useState)(!1),_e=(0,Y.useRef)(null),ve=(0,Y.useRef)(null),ye=s.pathname.startsWith(`/settings`),be=s.pathname===`/review`;(0,Y.useEffect)(()=>{c&&(ve.current?.querySelector(`[data-tab="${O}"]`))?.scrollIntoView({inline:`nearest`,block:`nearest`})},[O,c]);let xe=(0,Y.useRef)(O),Se=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{if(ye){if(Se.current===null){Se.current=Date.now(),xe.current=O;return}xe.current!==O&&o(`/`)}else Se.current=null;xe.current=O},[O,ye,o]);let Ce=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{let t=ye||be;if(t&&Ce.current===null)Ce.current=r,r&&e({type:Z.ToggleSidebar});else if(!t&&Ce.current!==null){let t=Ce.current;Ce.current=null,t&&!r&&e({type:Z.ToggleSidebar})}},[ye,be]),(0,Y.useEffect)(()=>{(async()=>{try{(await Dt()).updateAvailable&&me(!0)}catch{}})()},[]);let we=(0,Y.useCallback)(async()=>{ge(!0);try{await Bt()}catch{ge(!1)}},[]);(0,Y.useEffect)(()=>{le||(async()=>{try{(await Et()).onboardingCompleted||ce(!0)}catch(e){console.error(`Failed to check onboarding status:`,e)}finally{ue(!0)}})()},[le]),(0,Y.useEffect)(()=>{se||e({type:Z.ConfigUpdated})},[se,e]);let Te=(0,Y.useCallback)(e=>{let t=f.find(t=>t.projectId===e);t&&fe({id:t.projectId,name:at(t)})},[f]),Ee=(0,Y.useCallback)(e=>{d(e),v(e,void 0)},[v]);(0,Y.useEffect)(()=>{u&&n===u&&t&&d(null)},[u,n,t]);let De=(0,Y.useCallback)(async(n,r)=>{d(null),D(r),s.pathname!==`/`&&o(`/`),k(`chat`),t!==r&&ie(e=>e+1),p(n,r),l&&e({type:Z.CloseSidebar})},[p,l,t,e,D,s.pathname,o]);(0,Y.useEffect)(()=>{r?_e.current?.expand():_e.current?.collapse()},[r]);let Oe={activeMainTab:O,setActiveMainTab:k,devServerUrl:A,setDevServerUrl:j,devServerRunning:M,setDevServerRunning:N,devServerLoading:P,setDevServerLoading:F,terminalNotification:I,setTerminalNotification:L,pendingExplorerPath:R,setPendingExplorerPath:ee,explorerRefreshTick:z,triggerExplorerRefresh:()=>te(e=>e+1),explorerClearPath:ne,setExplorerClearPath:re,browserResetTrigger:B,triggerBrowserReset:()=>ie(e=>e+1)};return(0,$.jsxs)(Na.Provider,{value:Oe,children:[(0,$.jsx)(Y.Suspense,{fallback:null,children:(0,$.jsx)(Ep,{})}),(0,$.jsxs)(Mt,{delayDuration:200,children:[(0,$.jsxs)(dp,{direction:`horizontal`,className:`h-screen bg-background`,children:[(0,$.jsx)(fp,{ref:_e,defaultSize:l?100:25,minSize:l?50:12,maxSize:l?100:32,collapsible:!0,collapsedSize:0,className:q(`border-r border-transparent`,l&&!r&&`hidden`),children:(0,$.jsx)(`div`,{className:`h-full overflow-hidden`,children:(0,$.jsx)(Vi,{projects:f,selectedThreadId:t,selectedProjectId:n,processingThreadIds:w,completedThreadIds:E,deletingThreadIds:i,deletingProjectIds:a,onSelectThread:De,onCreateProject:()=>oe(!0),onCreateThread:Ee,onDeleteThread:y,onDeleteProject:Te,onDeselect:()=>e({type:Z.ClearSelection}),collapsed:!r,updateAvailable:pe,updatingApp:he,onUpdateApp:we,expandProjectId:u})})}),!l&&(0,$.jsx)(pp,{withHandle:!0,className:r?`ml-[-40px]`:``}),(0,$.jsx)(fp,{minSize:40,className:q(`overflow-hidden`,l&&r&&`hidden`),children:(0,$.jsx)(rd,{threadId:t??void 0,children:(0,$.jsx)(Cu,{children:(0,$.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden`,children:[!be&&!ye&&(0,$.jsx)(np,{}),!be&&!ye&&t&&(0,$.jsx)(`div`,{ref:ve,className:`flex shrink-0 select-none overflow-x-auto overflow-y-hidden border-b border-border`,children:[`Chat`,`Explorer`,`Review`,`Browser`,`Terminal`].map(e=>{let t=e.toLowerCase();return(0,$.jsxs)(`button`,{"data-tab":t,onClick:()=>{k(t),t===`terminal`&&L(!1)},className:`relative shrink-0 px-4 py-2 text-base font-medium transition-colors ${O===t?`border-b-2 border-primary text-foreground -mb-px`:`text-muted-foreground hover:text-foreground`}`,children:[e,t===`terminal`&&I&&O!==`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${!be&&!ye&&O!==`chat`?` hidden`:``}`,children:(0,$.jsxs)(ir,{children:[(0,$.jsx)(Zn,{path:`/settings/providers/:providerSlug`,element:(0,$.jsx)(Y.Suspense,{fallback:(0,$.jsx)(Wp,{}),children:(0,$.jsx)(Hp,{})})}),(0,$.jsx)(Zn,{path:`/settings/project/:projectId`,element:(0,$.jsx)(Y.Suspense,{fallback:(0,$.jsx)(Wp,{}),children:(0,$.jsx)(Hp,{})})}),(0,$.jsx)(Zn,{path:`/settings/:tab?`,element:(0,$.jsx)(Y.Suspense,{fallback:(0,$.jsx)(Wp,{}),children:(0,$.jsx)(Hp,{})})}),(0,$.jsx)(Zn,{path:`*`,element:(0,$.jsx)(zf,{onCreateThread:Ee})})]})}),(0,$.jsx)(`div`,{className:`flex-1 overflow-hidden${O===`terminal`&&!be&&!ye?``:` hidden`}`,children:(0,$.jsx)(Y.Suspense,{fallback:null,children:(0,$.jsx)(Ip,{})})}),(0,$.jsx)(`div`,{className:`flex-1 overflow-hidden${O===`browser`&&!be&&!ye?``:` hidden`}`,children:(0,$.jsx)(Y.Suspense,{fallback:null,children:(0,$.jsx)(zp,{})})}),!be&&!ye&&O!==`chat`&&O!==`terminal`&&O!==`browser`&&(O===`explorer`?(0,$.jsx)(Y.Suspense,{fallback:null,children:(0,$.jsx)(Rp,{})}):O===`review`&&t?(0,$.jsx)(Y.Suspense,{fallback:null,children:(0,$.jsx)(Lp,{threadId:t,onExit:()=>k(`chat`)})}):(0,$.jsx)(`div`,{className:`flex-1 overflow-hidden`}))]})})})}),(0,$.jsx)(Y.Suspense,{fallback:null,children:(0,$.jsx)(Bp,{open:H,onOpenChange:oe,onSubmitClone:m,onSubmitWebApp:h,onSubmitFolder:g,onOpenFolder:_})}),(0,$.jsx)(sp,{open:de!==null,projectName:de?.name,onOpenChange:e=>!e&&fe(null),onConfirm:()=>{de&&(b(de.id),fe(null))}}),(0,$.jsx)(cp,{open:S!==null,setupScripts:S?[S.command,...S.remainingScripts||[]]:[],onConfirm:C}),(0,$.jsx)(Y.Suspense,{fallback:null,children:(0,$.jsx)(Vp,{open:se,onOpenChange:ce,onComplete:()=>{ue(!0),x()}})}),(0,$.jsx)(up,{})]}),(0,$.jsx)(Sp,{})]})]})}function Kp(){let e=(0,X.c)(3),[t]=(0,Y.useState)(hi),n;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(Gp,{}),e[0]=n):n=e[0];let r;return e[1]===t?r=e[2]:(r=(0,$.jsx)(Tp,{attribute:`class`,defaultTheme:`system`,enableSystem:!0,storageKey:`tarsk-theme`,children:(0,$.jsx)(gi.Provider,{value:t,children:n})}),e[1]=t,e[2]=r),r}var qp=75,Jp=125,Yp=100;function Xp(){return window.matchMedia(`(max-width: 767px)`).matches}function Zp(e){let t=be(e,Xp());document.documentElement.style.fontSize=`${t}%`}var Qp=!1;function $p(){Qp||(Qp=!0,window.matchMedia(`(max-width: 767px)`).addEventListener(`change`,()=>{Zp(ze(Yp))}))}function em(){let[e,t]=(0,Y.useState)(()=>ze(Yp));(0,Y.useEffect)(()=>{$p(),Zp(e)},[e]);function n(e){let n=Math.max(qp,Math.min(Jp,Math.round(e)));t(n),Rt(n)}return{scale:e,updateScale:n,resetScale:(0,Y.useCallback)(()=>{n(Yp)},[]),min:qp,max:Jp,default:Yp}}function tm(){$p(),Zp(ze(Yp))}var nm;(function(e){e.Dark=`DARK`,e.Light=`LIGHT`,e.Default=`DEFAULT`})(nm||={});var rm;(function(e){e.None=`NONE`,e.Slide=`SLIDE`,e.Fade=`FADE`})(rm||={});var im=_f(`StatusBar`),am=`--app-viewport-height`;function om(){let e=window.visualViewport,t=Math.round(De()===`ios`?window.innerHeight:e?.height??window.innerHeight);document.documentElement.style.setProperty(am,`${t}px`)}function sm(){om(),requestAnimationFrame(om)}function cm(){document.documentElement.dataset.nativeShell=`true`,sm(),window.addEventListener(`resize`,om),window.addEventListener(`orientationchange`,sm);let e=window.visualViewport;e?.addEventListener(`resize`,om),e?.addEventListener(`scroll`,om)}async function lm(){try{await im.hide(),sm()}catch{}}async function um(){try{let e=De()===`ios`?jf.None:jf.Body;await Mf.setResizeMode({mode:e})}catch{}}function dm(){T()&&(cm(),lm(),um(),document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`&&(sm(),lm())}))}tm(),dm();var fm=!1;window.addEventListener(`resize`,()=>{fm||=(window.__electrobunWebviewId&&(document.body.style.height=`calc(100%)`),!0)}),(0,Br.createRoot)(document.getElementById(`root`)).render((0,$.jsx)(Y.StrictMode,{children:(0,$.jsx)(er,{children:(0,$.jsx)(Kp,{})})}));export{vi as A,Pa as C,wi as D,Fi as E,bi as M,xi as O,Va as S,Bi as T,ms as _,ep as a,To as b,tf as c,Ku as d,iu as f,us as g,ls as h,dp as i,Q as j,Z as k,nf as l,is as m,pp as n,ef as o,Ec as p,fp as r,rf as s,em as t,vd as u,as as v,ma as w,wo as x,Co as y};
|