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.
Files changed (78) hide show
  1. package/dist/index.js +28 -15
  2. package/dist/public/assets/{account-view-k5jIArY-.js → account-view-Cn4P1srV.js} +1 -1
  3. package/dist/public/assets/api-DWU0D34A.js +1 -0
  4. package/dist/public/assets/{browser-tab-C9kJT-C5.js → browser-tab-DeoHDVON.js} +1 -1
  5. package/dist/public/assets/commit-dialog-CWb_KVrD.js +1 -0
  6. package/dist/public/assets/context-menu-C7FTMa2c.js +1 -0
  7. package/dist/public/assets/create-repo-dialog-BCPrWkIv.js +1 -0
  8. package/dist/public/assets/{dialogs-config-B4TDFSrS.js → dialogs-config-DZKtVbNK.js} +14 -14
  9. package/dist/public/assets/diff-view-DL3hFREY.js +3 -0
  10. package/dist/public/assets/explorer-tab-view-DAs4rpHu.js +2 -0
  11. package/dist/public/assets/{explorer-tree-uXbr6cCI.js → explorer-tree-BV1LcznV.js} +1 -1
  12. package/dist/public/assets/explorer-view-BGSxs_-F.js +1 -0
  13. package/dist/public/assets/git-history-dialog-Bqv0bD41.js +1 -0
  14. package/dist/public/assets/git-ops-button-DZzOCOr8.js +2 -0
  15. package/dist/public/assets/history-view-jX3PPID6.js +9 -0
  16. package/dist/public/assets/index-CbJ3v0Sr.js +65 -0
  17. package/dist/public/assets/index-jIBJk8xl.css +1 -0
  18. package/dist/public/assets/mcp-server-card-CTCrhFIS.js +1 -0
  19. package/dist/public/assets/merged-pr-dialog-B2qqrQ1g.js +1 -0
  20. package/dist/public/assets/onboarding-CxtzQldG.js +1 -0
  21. package/dist/public/assets/project-settings-view-B7RBOfiB.js +1 -0
  22. package/dist/public/assets/providers-list-view-BQFttbEU.js +1 -0
  23. package/dist/public/assets/pull-request-dialog-BIRSLJAA.js +1 -0
  24. package/dist/public/assets/pull-with-changes-dialog-LUgd2a4S.js +1 -0
  25. package/dist/public/assets/push-before-pr-dialog-CFmgu9H_.js +1 -0
  26. package/dist/public/assets/radio-group-Bd8YbtFD.js +1 -0
  27. package/dist/public/assets/{react-vendor-unlDVFpU.js → react-vendor-Ba8DSNiO.js} +5 -5
  28. package/dist/public/assets/settings-general-view-CH-51vI0.js +1 -0
  29. package/dist/public/assets/settings-instructions-view-D9HZldUk.js +1 -0
  30. package/dist/public/assets/settings-list-CKPEGohm.js +1 -0
  31. package/dist/public/assets/settings-mcp-servers-view-o2gqb0qo.js +5 -0
  32. package/dist/public/assets/{settings-models-skeleton-B_56ozbA.js → settings-models-skeleton-l966LEN8.js} +1 -1
  33. package/dist/public/assets/{settings-models-view-ms828HDa.js → settings-models-view-m-MDG6JH.js} +1 -1
  34. package/dist/public/assets/settings-rules-view-tG9JJQzK.js +8 -0
  35. package/dist/public/assets/settings-skills-view-DLyWp1pq.js +2 -0
  36. package/dist/public/assets/settings-slash-commands-view-B7OCA_J1.js +1 -0
  37. package/dist/public/assets/settings-subagents-view-CSkVwd-J.js +2 -0
  38. package/dist/public/assets/settings-system-prompt-view-Br6r4RXb.js +1 -0
  39. package/dist/public/assets/settings-view-rUCFRiPR.js +2 -0
  40. package/dist/public/assets/skeleton-qzmFgKhS.js +1 -0
  41. package/dist/public/assets/{terminal-panel-Bm5ECpK_.js → terminal-panel-D3Ru16FT.js} +2 -2
  42. package/dist/public/assets/{ui-components-BZYnvMGc.js → ui-components-f8jJJzEo.js} +1 -1
  43. package/dist/public/assets/{utils-umVhs9to.js → utils-BlXPFbY9.js} +1 -1
  44. package/dist/public/assets/{whisper-wasm-Cq5Ofwpd.js → whisper-wasm-EGutPGND.js} +2 -2
  45. package/dist/public/index.html +12 -9
  46. package/package.json +1 -1
  47. package/dist/public/assets/api-OCjPhv01.js +0 -1
  48. package/dist/public/assets/commit-dialog-8Ce6d3H8.js +0 -1
  49. package/dist/public/assets/context-menu-CMsWrzLD.js +0 -1
  50. package/dist/public/assets/create-repo-dialog-CVUtteNS.js +0 -1
  51. package/dist/public/assets/diff-view-DGfmGlB_.js +0 -3
  52. package/dist/public/assets/explorer-tab-view-CCXVTkVu.js +0 -2
  53. package/dist/public/assets/explorer-view-CupxzDId.js +0 -1
  54. package/dist/public/assets/git-history-dialog-BCGOZ6ua.js +0 -1
  55. package/dist/public/assets/git-ops-button-BV9X3fo-.js +0 -2
  56. package/dist/public/assets/history-view-Ds_0e_bx.js +0 -7
  57. package/dist/public/assets/index-C0lTt0ZK.css +0 -1
  58. package/dist/public/assets/index-DOsSr4dl.js +0 -65
  59. package/dist/public/assets/mcp-server-card-DrUUKNXv.js +0 -1
  60. package/dist/public/assets/merged-pr-dialog-DqWSFdCH.js +0 -1
  61. package/dist/public/assets/onboarding-DfL8a0LZ.js +0 -1
  62. package/dist/public/assets/project-settings-view-Cd_l3Lfy.js +0 -1
  63. package/dist/public/assets/providers-list-view-VXhgM3vp.js +0 -1
  64. package/dist/public/assets/pull-request-dialog-DZXTHHuh.js +0 -1
  65. package/dist/public/assets/pull-with-changes-dialog-CYQrwzcw.js +0 -1
  66. package/dist/public/assets/push-before-pr-dialog-D-ZnRpJi.js +0 -1
  67. package/dist/public/assets/radio-group-c0sU992r.js +0 -1
  68. package/dist/public/assets/settings-general-view-DI-lvP0L.js +0 -1
  69. package/dist/public/assets/settings-instructions-view-kUG32_dT.js +0 -1
  70. package/dist/public/assets/settings-list-CUbZrggr.js +0 -1
  71. package/dist/public/assets/settings-mcp-servers-view-DmxUO42I.js +0 -5
  72. package/dist/public/assets/settings-rules-view-Xx0ymfnQ.js +0 -8
  73. package/dist/public/assets/settings-skills-view-DvPPdsi_.js +0 -2
  74. package/dist/public/assets/settings-slash-commands-view-BULIAW2o.js +0 -1
  75. package/dist/public/assets/settings-subagents-view-B7FcLaZT.js +0 -2
  76. package/dist/public/assets/settings-system-prompt-view-66zf0gRc.js +0 -1
  77. package/dist/public/assets/settings-view-B4CMq7it.js +0 -2
  78. package/dist/public/assets/skeleton-BvSNJL9q.js +0 -1
@@ -1,65 +0,0 @@
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-BV9X3fo-.js","assets/monaco-CZnIWXyV.js","assets/monaco-Br_kD0ds.css","assets/dialogs-config-B4TDFSrS.js","assets/diff-view-DGfmGlB_.js","assets/history-view-Ds_0e_bx.js","assets/onboarding-DfL8a0LZ.js","assets/context-menu-CMsWrzLD.js","assets/react-vendor-unlDVFpU.js","assets/utils-umVhs9to.js","assets/terminal-panel-Bm5ECpK_.js","assets/explorer-tab-view-CCXVTkVu.js","assets/browser-tab-C9kJT-C5.js","assets/settings-view-B4CMq7it.js","assets/settings-models-skeleton-B_56ozbA.js","assets/skeleton-BvSNJL9q.js"])))=>i.map(i=>d[i]);
2
- import{i as e,n as t}from"./rolldown-runtime-aKtaBQYM.js";import{$ as n,$a as r,$t as i,A as a,Aa as o,Ai as s,An as c,At as l,Ca as u,Cn as d,Cr as f,D as p,Da as m,Dn as h,Ea as g,Er as _,Et as v,F as y,Fa as b,Fi as x,Ga as S,Ha as C,Hn as w,Ii as T,In as E,J as D,Ja as O,Ji as k,Jn as A,Jt as j,Ki as M,Kn as N,Kt as P,La as F,Li as I,Ln as L,Lt as R,Ma as z,Mt as ee,N as B,Na as te,Nn as ne,O as V,Oi as re,On as ie,Pa as H,Pn as ae,Pt as oe,Q as se,Qi as ce,Qn as le,Ra as ue,Ri as de,Rn as fe,S as pe,Si as me,Sn as he,Sr as ge,St as _e,Ta as ve,Ti as ye,Tn as be,Tr as xe,Tt as Se,Ui as Ce,Un as we,Ut as Te,Va as Ee,Vi as De,W as Oe,Wn as ke,Wt as Ae,X as je,Xa as Me,Xi as Ne,Y as Pe,Ya as Fe,Yt as Ie,Z as Le,Za as Re,Zi as ze,Zn as Be,Zt as Ve,_ as He,_a as Ue,_t as We,ai as Ge,ar as Ke,ba as qe,bi as Je,bn as Ye,br as Xe,c as Ze,ca as Qe,ci as $e,cn as et,co as tt,d as nt,da as rt,dn as it,do as at,en as ot,eo as st,er as ct,fn as lt,fo as ut,ga as dt,gi as ft,gn as pt,h as mt,ha as ht,hi as gt,hn as _t,hr as vt,ia as yt,ii as U,io as bt,ir as W,jn as xt,jt as St,ki as Ct,kn as wt,kt as Tt,la as Et,ln as Dt,mi as Ot,mn as kt,mo as At,na as jt,ni as G,no as Mt,oa as Nt,oi as Pt,on as Ft,or as K,ot as It,p as Lt,pa as Rt,pn as zt,po as Bt,pt as Vt,qa as Ht,qi as Ut,qn as Wt,qt as Gt,ra as Kt,ro as qt,rr as q,rt as Jt,sa as Yt,si as Xt,sn as Zt,so as Qt,st as $t,ta as en,tn,tr as nn,u as rn,un as an,v as on,va as sn,vi as J,vr as cn,w as ln,wr as un,x as dn,xa as fn,xi as pn,xr as mn,xt as hn,y as gn,ya as _n,yi as vn,yt as yn,zi as bn,zn as xn}from"./dialogs-config-B4TDFSrS.js";import{$ as Sn,A as Cn,B as wn,D as Tn,E as En,F as Dn,G as On,H as kn,I as An,J as jn,K as Mn,L as Nn,M as Pn,N as Fn,O as In,P as Ln,Q as Rn,R as zn,T as Bn,U as Vn,V as Hn,W as Un,X as Wn,Y as Gn,Z as Kn,at as qn,ct as Jn,et as Yn,it as Xn,j as Zn,k as Qn,nt as $n,ot as er,q as tr,rt as nr,st as rr,tt as ir,ut as ar,w as or,z as sr}from"./react-vendor-unlDVFpU.js";import{r as cr}from"./monaco-CZnIWXyV.js";import{c as lr,l as ur,r as dr,u as fr}from"./onboarding-DfL8a0LZ.js";import{A as pr,F as mr,M as hr,N as gr,O as _r,P as vr,a as yr,j as br,k as xr,l as Sr,n as Cr,o as wr,s as Tr,x as Er}from"./history-view-Ds_0e_bx.js";import{i as Dr,n as Or,r as kr,t as Ar}from"./whisper-wasm-Cq5Ofwpd.js";import{n as jr,t as Mr}from"./utils-umVhs9to.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(At(),1),Nr=ar(),X=ut(),Pr=1e10,Fr=1e3;function Ir(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 Lr(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=Fr}=e;e.transport&&i(e.transport),e.requestHandler&&a(e.requestHandler),e._debugHooks&&(t=e._debugHooks);let s=0;function c(){return s<=Pr?++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 Ir([`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 Ir([`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 Ir([`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 Ir([`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 Rr(e,t){let n=Lr({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 zr=window.__electrobunWebviewId,Br=window.__electrobunRpcSocketPort,Vr=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:${Br}/socket?webviewId=${zr}`);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 Rr(`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 Hr(e){return typeof e==`string`?e.replace(/\\n/g,`
3
- `).replace(/✅/g,`✓`):``}function Ur(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 Wr(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 Gr(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 Kr(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 Wr(e);if(typeof e==`object`&&e)return Gr(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(...Wr(i)):n.push(...Gr(i));let a=t.substring(r+1).trim();return a&&n.push({type:`text`,text:a}),n}catch{}}}return null}function qr(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 Jr(e,t){return e[e.length-1]?.type===`content`?[...e.slice(0,-1),{type:`content`,chunks:[t]}]:[...e,{type:`content`,chunks:[t]}]}function Yr(e,t){return[...e,{type:`long_running_confirmation`,prompt:t}]}function Xr(e,t){return[...e,{type:`shell_permission`,prompt:t}]}function Zr(e,t){return[...e,{type:`web_fetch_permission`,prompt:t}]}function Qr(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=Ur(e)??[];t.push(...n)}else{let n=Kr(e)??(e.trim()?[{type:`text`,text:e}]:[]);t.push(...n)}}return t}function $r(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 ei(e){let t=Qr(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.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}({}),ti={isStreaming:!1,streamingContent:``,streamingThinking:``,streamingSegments:[],streamingModel:``,streamingEventCount:0};function ni(){return{...ti,streamingSegments:[]}}function ri(e,t){return t?e[t]??ni():ni()}function ii(e,t){return t.threadId??e.selectedThreadId}function ai(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 oi={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 si(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=ri(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,...ni(),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=ii(e,t);return ai(e,n,{...ri(e.threadStreamingStates,n),isStreaming:t.isStreaming})}case`APPEND_STREAM_CONTENT`:{let n=ii(e,t),r=ri(e.threadStreamingStates,n);return ai(e,n,{...r,streamingContent:r.streamingContent+t.content})}case`SET_STREAM_CONTENT`:{let n=ii(e,t),r=ri(e.threadStreamingStates,n),i=Jr(r.streamingSegments,t.content);return ai(e,n,{...r,streamingContent:t.content,streamingSegments:i})}case`APPEND_STREAM_THINKING`:{let n=ii(e,t),r=ri(e.threadStreamingStates,n);return ai(e,n,{...r,streamingThinking:r.streamingThinking+t.content})}case`INCREMENT_STREAM_EVENT_COUNT`:{let n=ii(e,t),r=ri(e.threadStreamingStates,n);return ai(e,n,{...r,streamingEventCount:r.streamingEventCount+1})}case`APPEND_STREAM_CHUNK`:{let n=ii(e,t),r=ri(e.threadStreamingStates,n);return ai(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=ii(e,t);return ai(e,n,{...ri(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 ai(e,ii(e,t),ni(),!0);case`STOP_STREAM`:{let n=ii(e,t);return ai(e,n,{...ri(e.threadStreamingStates,n),isStreaming:!1})}case`TOGGLE_SIDEBAR`:return{...e,sidebarOpen:!e.sidebarOpen};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 ci(e=oi){let t=e,n=new Set;function r(){return t}function i(e){let r=si(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 li=(0,Y.createContext)(null);function ui(){let e=(0,Y.useContext)(li);if(!e)throw Error(`useAppStore must be used within an AppStoreContext.Provider`);return e}function Q(e){let t=(0,X.c)(3),n=ui(),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 di(){return ui().dispatch}var fi={open:!1,queuedCommand:null,queuedRelativeFolder:null,outputLines:[],height:300,history:[],historyIndex:-1,cwd:`.`,isRunning:!1};function pi(e){let t=(0,X.c)(8),n=di(),r;t[0]===e?r=t[1]:(r=t=>(e?t.terminalStates[e]:void 0)??fi,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 $=ye(),mi=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=U(`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});mi.displayName=`Textarea`;function hi(e){let t=(0,X.c)(47),{open:n,onOpenChange:r,feedbackName:i,onFeedbackNameChange:a,feedbackEmail:o,onFeedbackEmailChange:s,feedbackText:c,onFeedbackTextChange:l,loadingFeedbackUser:u,submittingFeedback:d,onSubmit:p}=e,m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsxs)(xe,{children:[(0,$.jsx)(_,{children:`Send Feedback`}),(0,$.jsx)(f,{children:`Share feedback about Tarsk.`})]}),t[0]=m):m=t[0];let h;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(cn,{htmlFor:`feedback-name`,children:`Name`}),t[1]=h):h=t[1];let g;t[2]===a?g=t[3]:(g=e=>a(e.target.value),t[2]=a,t[3]=g);let v=d||u,y;t[4]!==i||t[5]!==g||t[6]!==v?(y=(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[h,(0,$.jsx)(Xe,{id:`feedback-name`,value:i,onChange:g,placeholder:`Your name`,disabled:v})]}),t[4]=i,t[5]=g,t[6]=v,t[7]=y):y=t[7];let b;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(cn,{htmlFor:`feedback-email`,children:`Email`}),t[8]=b):b=t[8];let x;t[9]===s?x=t[10]:(x=e=>s(e.target.value),t[9]=s,t[10]=x);let S=d||u,C;t[11]!==o||t[12]!==x||t[13]!==S?(C=(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[b,(0,$.jsx)(Xe,{id:`feedback-email`,type:`email`,value:o,onChange:x,placeholder:`you@example.com`,disabled:S})]}),t[11]=o,t[12]=x,t[13]=S,t[14]=C):C=t[14];let w;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(cn,{htmlFor:`feedback-text`,children:`Feedback`}),t[15]=w):w=t[15];let T;t[16]===l?T=t[17]:(T=e=>l(e.target.value),t[16]=l,t[17]=T);let E;t[18]!==c||t[19]!==d||t[20]!==T?(E=(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[w,(0,$.jsx)(mi,{id:`feedback-text`,value:c,onChange:T,placeholder:`Tell us what you think...`,className:`min-h-32`,disabled:d})]}),t[18]=c,t[19]=d,t[20]=T,t[21]=E):E=t[21];let D;t[22]!==E||t[23]!==y||t[24]!==C?(D=(0,$.jsxs)(`div`,{className:`grid gap-4 py-2`,children:[y,C,E]}),t[22]=E,t[23]=y,t[24]=C,t[25]=D):D=t[25];let O;t[26]===r?O=t[27]:(O=()=>r(!1),t[26]=r,t[27]=O);let k;t[28]!==d||t[29]!==O?(k=(0,$.jsx)(G,{variant:`outline`,onClick:O,disabled:d,children:`Cancel`}),t[28]=d,t[29]=O,t[30]=k):k=t[30];let A;t[31]===d?A=t[32]:(A=d?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(_n,{className:`mr-2 h-4 w-4 animate-spin`}),`Sending...`]}):`Send`,t[31]=d,t[32]=A);let j;t[33]!==p||t[34]!==d||t[35]!==A?(j=(0,$.jsx)(G,{onClick:p,disabled:d,children:A}),t[33]=p,t[34]=d,t[35]=A,t[36]=j):j=t[36];let M;t[37]!==k||t[38]!==j?(M=(0,$.jsxs)(un,{children:[k,j]}),t[37]=k,t[38]=j,t[39]=M):M=t[39];let N;t[40]!==D||t[41]!==M?(N=(0,$.jsxs)(ge,{className:`max-w-xl`,children:[m,D,M]}),t[40]=D,t[41]=M,t[42]=N):N=t[42];let P;return t[43]!==r||t[44]!==n||t[45]!==N?(P=(0,$.jsx)(mn,{open:n,onOpenChange:r,children:N}),t[43]=r,t[44]=n,t[45]=N,t[46]=P):P=t[46],P}function gi(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)(gi,{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 _i(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=U(`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)(gi,{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 vi=1,yi=1e6,bi=0;function xi(){return bi=(bi+1)%(2**53-1),bi.toString()}var Si=new Map,Ci=e=>{if(Si.has(e))return;let t=setTimeout(()=>{Si.delete(e),Di({type:`REMOVE_TOAST`,toastId:e})},yi);Si.set(e,t)},wi=(e,t)=>{switch(t.type){case`ADD_TOAST`:return{...e,toasts:[t.toast,...e.toasts].slice(0,vi)};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?Ci(n):e.toasts.forEach(e=>{Ci(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)}}},Ti=[],Ei={toasts:[]};function Di(e){Ei=wi(Ei,e),Ti.forEach(e=>{e(Ei)})}function Oi({...e}){let t=xi(),n=e=>Di({type:`UPDATE_TOAST`,toast:{...e,id:t}}),r=()=>Di({type:`DISMISS_TOAST`,toastId:t});return Di({type:`ADD_TOAST`,toast:{...e,id:t,open:!0,onOpenChange:e=>{e||r()}}}),{id:t,dismiss:r,update:n}}function ki(){let e=(0,X.c)(4),[t,n]=Y.useState(Ei),r,i;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>(Ti.push(n),()=>{let e=Ti.indexOf(n);e>-1&&Ti.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:Oi,dismiss:Ai},e[2]=t,e[3]=a),a}function Ai(e){return Di({type:`DISMISS_TOAST`,toastId:e})}function ji(){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),Jt().then(e=>{t&&(r(t=>t||e.name),a(t=>t||e.email))}).catch(()=>{t&&Oi({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){Oi({title:`Feedback required`,description:`Please enter your feedback before submitting.`,variant:`destructive`});return}d(!0);try{await ae(`api/feedback`,{name:n.trim(),email:i.trim(),feedback:e}),Oi({title:`Feedback sent`,description:`Thanks for sharing your feedback.`}),s(``),t(!1)}catch(e){Oi({title:`Failed to send feedback`,description:e instanceof Error?e.message:`Please try again.`,variant:`destructive`})}finally{d(!1)}}}}function Mi(e){let t=(0,X.c)(28),{children:n,collapsed:r,title:i,onTitleClose:a,subtitle:o,headerAction:c,footer:l,onLogoClick:u}=e,d;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(d={containerType:`inline-size`,height:`calc(100% - 42px)`},t[0]=d):d=t[0];let f=u&&`cursor-pointer`,p;t[1]===f?p=t[2]:(p=U(`h-full w-full`,f),t[1]=f,t[2]=p);let m;t[3]!==u||t[4]!==p?(m=(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:p,onClick:u})}),t[3]=u,t[4]=p,t[5]=m):m=t[5];let h;t[6]!==r||t[7]!==o?(h=!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)(st,{className:`h-3 w-3 text-sidebar-foreground/60`}),(0,$.jsx)(`span`,{className:U(J.label,`text-sidebar-foreground/80`),children:o})]})]}),t[6]=r,t[7]=o,t[8]=h):h=t[8];let g;t[9]!==m||t[10]!==h?(g=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[m,h]}),t[9]=m,t[10]=h,t[11]=g):g=t[11];let _;t[12]!==r||t[13]!==c||t[14]!==a||t[15]!==i?(_=(i??a??c)&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 ml-auto`,children:[c&&!r&&c,i&&(0,$.jsx)(`span`,{className:U(J.compact,`font-medium text-sidebar-foreground/80`),children:i}),a&&(0,$.jsxs)(G,{variant:`ghost`,size:`icon`,className:`h-7 w-7 text-sidebar-foreground`,onClick:a,children:[(0,$.jsx)(s,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]}),t[12]=r,t[13]=c,t[14]=a,t[15]=i,t[16]=_):_=t[16];let v;t[17]!==g||t[18]!==_?(v=(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b border-sidebar-border px-4 py-3 h-[61px]`,children:[g,_]}),t[17]=g,t[18]=_,t[19]=v):v=t[19];let y;t[20]===n?y=t[21]:(y=(0,$.jsx)(vt,{className:`flex-1`,children:n}),t[20]=n,t[21]=y);let b;t[22]===l?b=t[23]:(b=l&&(0,$.jsx)(`div`,{className:`border-t border-sidebar-border`,children:l}),t[22]=l,t[23]=b);let x;return t[24]!==b||t[25]!==v||t[26]!==y?(x=(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:d,children:[v,y,b]}),t[24]=b,t[25]=v,t[26]=y,t[27]=x):x=t[27],x}function Ni(e){let t=(0,X.c)(80),{projects:n,selectedThreadId:r,selectedProjectId:i,processingThreadIds:a,completedThreadIds:o,deletingThreadIds:s,deletingProjectIds:c,onSelectThread:l,onCreateProject:u,onCreateThread:d,onDeleteThread:f,onDeleteProject:p,onDeselect:m,collapsed:h,updateAvailable:g,updatingApp:_,onUpdateApp:v,expandProjectId:y}=e,b=Jn(),{showFeedback:x,feedbackName:S,setFeedbackName:w,feedbackEmail:T,setFeedbackEmail:E,feedbackText:D,setFeedbackText:O,loadingFeedbackUser:k,submittingFeedback:A,handleFeedbackDialogChange:j,handleSubmitFeedback:M}=ji(),N;t[0]===n?N=t[1]:(N=n.map(Pi),t[0]=n,t[1]=N);let P=N,F;t[2]!==h||t[3]!==u?(F=!h&&(0,$.jsxs)(G,{variant:`outline`,size:`sm`,className:`gap-2`,onClick:u,children:[(0,$.jsx)(Kt,{className:`h-4 w-4 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:`New Project`})]}),t[2]=h,t[3]=u,t[4]=F):F=t[4];let I;t[5]!==h||t[6]!==v||t[7]!==g||t[8]!==_?(I=g&&(0,$.jsxs)(G,{variant:`ghost`,size:`sm`,className:`w-full justify-start gap-2 text-emerald-600 dark:text-emerald-400`,onClick:v,disabled:_,children:[_?(0,$.jsx)(_n,{className:`h-4 w-4 animate-spin`}):(0,$.jsx)(C,{className:`h-4 w-4`}),!h&&(0,$.jsx)(`span`,{className:`truncate`,children:_?`Updating...`:`Update to Latest`})]}),t[5]=h,t[6]=v,t[7]=g,t[8]=_,t[9]=I):I=t[9];let L;t[10]===b?L=t[11]:(L=()=>void b(`/settings/general`),t[10]=b,t[11]=L);let R;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,$.jsx)(Ut,{className:`h-4 w-4`}),t[12]=R):R=t[12];let z;t[13]===h?z=t[14]:(z=!h&&(0,$.jsx)(`span`,{className:`truncate`,children:`Settings`}),t[13]=h,t[14]=z);let ee;t[15]!==L||t[16]!==z?(ee=(0,$.jsxs)(G,{variant:`ghost`,size:`sm`,className:`flex-1 justify-start gap-2 text-sidebar-foreground`,onClick:L,children:[R,z]}),t[15]=L,t[16]=z,t[17]=ee):ee=t[17];let B;t[18]===j?B=t[19]:(B=()=>j(!0),t[18]=j,t[19]=B);let te,ne;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(ne=(0,$.jsx)(dt,{className:`h-4 w-4`}),te=(0,$.jsx)(`span`,{className:`sr-only`,children:`Feedback`}),t[20]=te,t[21]=ne):(te=t[20],ne=t[21]);let V;t[22]===B?V=t[23]:(V=(0,$.jsx)(K,{asChild:!0,children:(0,$.jsxs)(G,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground hover:text-background`,onClick:B,children:[ne,te]})}),t[22]=B,t[23]=V);let re;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(re=(0,$.jsx)(W,{children:`Send feedback to the Tarsk team`}),t[24]=re):re=t[24];let ie;t[25]===V?ie=t[26]:(ie=(0,$.jsx)(Ke,{children:(0,$.jsxs)(q,{children:[V,re]})}),t[25]=V,t[26]=ie);let H;t[27]!==ie||t[28]!==ee?(H=(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[ee,ie]}),t[27]=ie,t[28]=ee,t[29]=H):H=t[29];let ae;t[30]!==H||t[31]!==I?(ae=(0,$.jsxs)(`div`,{className:`px-3 py-2 flex flex-col gap-1`,children:[I,H]}),t[30]=H,t[31]=I,t[32]=ae):ae=t[32];let oe;t[33]===n.length?oe=t[34]:(oe=n.length===0&&(0,$.jsx)(`p`,{className:U(J.compact,`px-3 py-6 text-center text-muted-foreground`),children:`No projects yet. Clone a repository to get started.`}),t[33]=n.length,t[34]=oe);let se;t[35]===y?se=t[36]:(se=y?[y]:void 0,t[35]=y,t[36]=se);let ce;t[37]!==o||t[38]!==c||t[39]!==s||t[40]!==b||t[41]!==d||t[42]!==p||t[43]!==f||t[44]!==l||t[45]!==a||t[46]!==n||t[47]!==i||t[48]!==r?(ce=(e,t)=>{let{isOpen:u,toggle:m}=t;return e.kind===`project`?(0,$.jsx)(Fi,{project:e.project,isOpen:u,onToggle:m,isDeletingProject:c.includes(e.project.projectId),isSelected:i?e.project.projectId===i:!1,onCreateThread:d,onDeleteProject:p,onProjectSettings:e=>void b(`/settings/project/${e}`),hasSelectedThread:e.project.threads.some(e=>e.threadId===r)}):(0,$.jsx)(Ii,{thread:e.thread,projectId:e.projectId,selectedThreadId:r,isProcessing:a.includes(e.thread.threadId),isDeleting:s.includes(e.thread.threadId),isCompleted:o.includes(e.thread.threadId),projectTitlePrefix:`${Pt(n.find(t=>t.projectId===e.projectId))} - `,onSelectThread:l,onDeleteThread:f})},t[37]=o,t[38]=c,t[39]=s,t[40]=b,t[41]=d,t[42]=p,t[43]=f,t[44]=l,t[45]=a,t[46]=n,t[47]=i,t[48]=r,t[49]=ce):ce=t[49];let le;t[50]!==P||t[51]!==se||t[52]!==ce?(le=(0,$.jsx)(_i,{nodes:P,defaultOpen:!0,forceOpenIds:se,childContainerClassName:`ml-4 border-l border-sidebar-border pl-2`,renderNode:ce}),t[50]=P,t[51]=se,t[52]=ce,t[53]=le):le=t[53];let ue;t[54]!==oe||t[55]!==le?(ue=(0,$.jsx)(vt,{className:`flex-1 w-full`,children:(0,$.jsxs)(`div`,{className:`px-2 py-2 w-full max-w-full overflow-hidden`,children:[oe,le]})}),t[54]=oe,t[55]=le,t[56]=ue):ue=t[56];let de;t[57]!==h||t[58]!==m||t[59]!==ae||t[60]!==F||t[61]!==ue?(de=(0,$.jsx)(Mi,{collapsed:h,onLogoClick:m,headerAction:F,footer:ae,children:ue}),t[57]=h,t[58]=m,t[59]=ae,t[60]=F,t[61]=ue,t[62]=de):de=t[62];let fe;t[63]===M?fe=t[64]:(fe=()=>void M(),t[63]=M,t[64]=fe);let pe;t[65]!==T||t[66]!==S||t[67]!==D||t[68]!==j||t[69]!==k||t[70]!==E||t[71]!==w||t[72]!==O||t[73]!==x||t[74]!==A||t[75]!==fe?(pe=(0,$.jsx)(hi,{open:x,onOpenChange:j,feedbackName:S,onFeedbackNameChange:w,feedbackEmail:T,onFeedbackEmailChange:E,feedbackText:D,onFeedbackTextChange:O,loadingFeedbackUser:k,submittingFeedback:A,onSubmit:fe}),t[65]=T,t[66]=S,t[67]=D,t[68]=j,t[69]=k,t[70]=E,t[71]=w,t[72]=O,t[73]=x,t[74]=A,t[75]=fe,t[76]=pe):pe=t[76];let me;return t[77]!==de||t[78]!==pe?(me=(0,$.jsxs)($.Fragment,{children:[de,pe]}),t[77]=de,t[78]=pe,t[79]=me):me=t[79],me}function Pi(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 Fi(e){let t=(0,X.c)(29),{project:n,isOpen:r,onToggle:i,isDeletingProject:a,hasSelectedThread:o,isSelected:s,onCreateThread:c,onDeleteProject:l,onProjectSettings:u}=e,d;t[0]===n?d=t[1]:(d=Pt(n),t[0]=n,t[1]=d);let f=d,p=o||s,m=r&&`rotate-90`,h;t[2]===m?h=t[3]:(h=U(`h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform`,m),t[2]=m,t[3]=h);let g;t[4]===h?g=t[5]:(g=(0,$.jsx)(st,{className:h}),t[4]=h,t[5]=g);let _;t[6]===n.gitUrl?_=t[7]:(_=n.gitUrl?(0,$.jsx)(b,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}):(0,$.jsx)(te,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}),t[6]=n.gitUrl,t[7]=_);let v=(o||s)&&`font-bold text-foreground`,y;t[8]===v?y=t[9]:(y=U(`min-w-0 truncate transition-all block`,v),t[8]=v,t[9]=y);let x;t[10]!==f||t[11]!==y?(x=(0,$.jsx)(`span`,{className:y,children:f}),t[10]=f,t[11]=y,t[12]=x):x=t[12];let S;t[13]!==g||t[14]!==_||t[15]!==x?(S=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1.5 w-0`,children:[g,_,x]}),t[13]=g,t[14]=_,t[15]=x,t[16]=S):S=t[16];let C;t[17]!==a||t[18]!==c||t[19]!==l||t[20]!==u||t[21]!==n.projectId||t[22]!==n.threads?(C=(0,$.jsx)(`div`,{className:`flex shrink-0 items-center ml-auto`,children:a?(0,$.jsx)(_n,{className:`h-3.5 w-3.5 shrink-0 animate-spin text-muted-foreground mr-1`}):(0,$.jsxs)(Ke,{children:[(0,$.jsxs)(q,{children:[(0,$.jsx)(K,{asChild:!0,children:(0,$.jsxs)(G,{variant:`ghost`,size:`icon`,className:`h-7 w-7 shrink-0 hidden group-hover:flex items-center justify-center`,onClick:e=>{e.stopPropagation(),u(n.projectId)},children:[(0,$.jsx)(Ut,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Project settings`})]})}),(0,$.jsx)(W,{side:`right`,children:`Project settings`})]}),(0,$.jsxs)(q,{children:[(0,$.jsx)(K,{asChild:!0,children:(0,$.jsxs)(G,{variant:`action`,size:`icon-sm`,className:`shrink-0 hidden group-hover:flex items-center justify-center`,onClick:e=>{e.stopPropagation(),c(n.projectId)},children:[(0,$.jsx)(Kt,{}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Add thread`})]})}),(0,$.jsx)(W,{side:`right`,children:`Add thread`})]}),n.threads.length===0&&(0,$.jsxs)(q,{children:[(0,$.jsx)(K,{asChild:!0,children:(0,$.jsxs)(G,{variant:`ghost`,size:`icon-sm`,className:`shrink-0 hidden group-hover:flex items-center justify-center text-muted-foreground hover:bg-destructive hover:text-destructive-foreground transition-colors`,onClick:e=>{e.stopPropagation(),l(n.projectId)},children:[(0,$.jsx)(I,{}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Delete project`})]})}),(0,$.jsx)(W,{side:`right`,children:`Delete project`})]})]})}),t[17]=a,t[18]=c,t[19]=l,t[20]=u,t[21]=n.projectId,t[22]=n.threads,t[23]=C):C=t[23];let w;return t[24]!==i||t[25]!==S||t[26]!==C||t[27]!==p?(w=(0,$.jsxs)(fr,{selected:p,noBackground:!0,className:`mb-1 h-9`,onClick:i,children:[S,C]}),t[24]=i,t[25]=S,t[26]=C,t[27]=p,t[28]=w):w=t[28],w}function Ii(e){let t=(0,X.c)(51),{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,g;t[0]===a?(h=t[1],g=t[2]):(h=()=>{a&&p.current&&p.current.scrollIntoView({behavior:`smooth`,block:`nearest`})},g=[a],t[0]=a,t[1]=h,t[2]=g),(0,Y.useEffect)(h,g);let _;t[3]!==u||t[4]!==r||t[5]!==n.gitStatusDot||t[6]!==n.threadId?(_=e=>{e.stopPropagation(),n.gitStatusDot?f(!0):u(r,n.threadId)},t[3]=u,t[4]=r,t[5]=n.gitStatusDot,t[6]=n.threadId,t[7]=_):_=t[7];let v=_,y;t[8]!==c||t[9]!==n.threadId||t[10]!==n.title?(y=n.title?.startsWith(c)?n.title.slice(c.length):n.title??n.threadId,t[8]=c,t[9]=n.threadId,t[10]=n.title,t[11]=y):y=t[11];let b=y,x;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(mr,{children:`Delete Thread`}),t[12]=x):x=t[12];let S;t[13]===b?S=t[14]:(S=(0,$.jsxs)(hr,{children:[`Are you sure you want to delete "`,b,`" and all its files? This action cannot be undone.`]}),t[13]=b,t[14]=S);let C;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,$.jsx)(pr,{children:`Cancel`}),t[15]=C):C=t[15];let w;t[16]!==u||t[17]!==r||t[18]!==n.threadId?(w=(0,$.jsxs)(`div`,{className:`flex gap-3 justify-end`,children:[C,(0,$.jsx)(xr,{onClick:()=>{f(!1),u(r,n.threadId)},className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:`Delete`})]}),t[16]=u,t[17]=r,t[18]=n.threadId,t[19]=w):w=t[19];let T;t[20]!==S||t[21]!==w?(T=(0,$.jsxs)(br,{children:[x,S,w]}),t[20]=S,t[21]=w,t[22]=T):T=t[22];let E;t[23]!==d||t[24]!==T?(E=(0,$.jsx)(_r,{open:d,onOpenChange:f,children:T}),t[23]=d,t[24]=T,t[25]=E):E=t[25];let D,O;t[26]!==l||t[27]!==r||t[28]!==n.threadId?(D=()=>l(r,n.threadId),O=e=>{(e.key===`Enter`||e.key===` `)&&l(r,n.threadId)},t[26]=l,t[27]=r,t[28]=n.threadId,t[29]=D,t[30]=O):(D=t[29],O=t[30]);let k;t[31]===n.gitStatusDot?k=t[32]:(k=n.gitStatusDot?(0,$.jsx)(`svg`,{className:`h-3 w-3 shrink-0`,viewBox:`0 0 12 12`,fill:`hsl(var(--brand))`,xmlns:`http://www.w3.org/2000/svg`,children:(0,$.jsx)(`circle`,{cx:`6`,cy:`6`,r:`5`})}):(0,$.jsx)(`svg`,{className:`h-3 w-3 shrink-0 text-muted-foreground`,viewBox:`0 0 12 12`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.0`,xmlns:`http://www.w3.org/2000/svg`,children:(0,$.jsx)(`circle`,{cx:`6`,cy:`6`,r:`4.5`})}),t[31]=n.gitStatusDot,t[32]=k);let A;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(A=U(J.body,`truncate block`),t[33]=A):A=t[33];let j;t[34]===b?j=t[35]:(j=(0,$.jsx)(`div`,{className:`flex-1 min-w-0 w-0`,children:(0,$.jsx)(`span`,{className:A,children:b})}),t[34]=b,t[35]=j);let M;t[36]!==v||t[37]!==s||t[38]!==o||t[39]!==a?(M=a||o?(0,$.jsx)(_n,{className:`ml-auto h-3 w-3 shrink-0 animate-spin text-muted-foreground`}):s?(0,$.jsx)(qt,{className:`ml-auto h-3 w-3 shrink-0 text-green-500`}):(0,$.jsx)(`div`,{className:`ml-auto flex items-center gap-1`,children:(0,$.jsxs)(q,{children:[(0,$.jsx)(K,{asChild:!0,children:(0,$.jsxs)(G,{variant:`ghost`,size:`icon-sm`,className:`shrink-0 opacity-0 group-hover:opacity-100 flex items-center justify-center text-muted-foreground hover:bg-destructive hover:text-destructive-foreground transition-opacity transition-colors`,onClick:v,children:[(0,$.jsx)(I,{}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Delete thread`})]})}),(0,$.jsx)(W,{side:`right`,children:`Delete thread and files from the repo`})]})}),t[36]=v,t[37]=s,t[38]=o,t[39]=a,t[40]=M):M=t[40];let N;t[41]!==m||t[42]!==D||t[43]!==O||t[44]!==k||t[45]!==j||t[46]!==M?(N=(0,$.jsxs)(fr,{ref:p,selected:m,onClick:D,onKeyDown:O,role:`button`,tabIndex:0,children:[k,j,M]}),t[41]=m,t[42]=D,t[43]=O,t[44]=k,t[45]=j,t[46]=M,t[47]=N):N=t[47];let P;return t[48]!==E||t[49]!==N?(P=(0,$.jsxs)($.Fragment,{children:[E,N]}),t[48]=E,t[49]=N,t[50]=P):P=t[50],P}var Li=e(Bt(),1),Ri=.1,zi=10,Bi=1.25,Vi=.001;function Hi(){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=Ui,u;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>n(e=>l(e*Bi)),e[1]=u):u=e[1];let d=u,f;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=()=>n(e=>l(e/Bi)),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*Vi;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 Ui(e){return Math.min(Math.max(e,Ri),zi)}function Wi(){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 Gi(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 cr(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 Ki(e){let t=(0,X.c)(70),{svgOutput:n,onClose:r}=e,{scale:i,offset:a,isDragging:o,containerRef:c,zoomIn:l,zoomOut:u,reset:d,onMouseDown:f,onMouseMove:p,onMouseUp:m}=Hi(),h,g;t[0]===r?(h=t[1],g=t[2]):(h=()=>{let e=function(e){e.key===`Escape`&&r()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},g=[r],t[0]=r,t[1]=h,t[2]=g),(0,Y.useEffect)(h,g);let _;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(_=[],t[3]=_):_=t[3],(0,Y.useEffect)(qi,_);let v;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(`span`,{className:U(J.compact,`font-mono text-muted-foreground`),children:`mermaid diagram`}),t[4]=v):v=t[4];let y,b;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(Rt,{className:`h-3.5 w-3.5`}),b=(0,$.jsx)(`span`,{className:`sr-only`,children:`Zoom out`}),t[5]=y,t[6]=b):(y=t[5],b=t[6]);let x;t[7]===u?x=t[8]:(x=(0,$.jsx)(K,{asChild:!0,children:(0,$.jsxs)(G,{variant:`ghost`,size:`icon-xs`,onClick:u,children:[y,b]})}),t[7]=u,t[8]=x);let S;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,$.jsx)(W,{children:`Zoom out`}),t[9]=S):S=t[9];let C;t[10]===x?C=t[11]:(C=(0,$.jsxs)(q,{children:[x,S]}),t[10]=x,t[11]=C);let w;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(w=U(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]=w):w=t[12];let T;t[13]===i?T=t[14]:(T=Math.round(i*100),t[13]=i,t[14]=T);let E;t[15]!==d||t[16]!==T?(E=(0,$.jsx)(K,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,onClick:d,className:w,children:[T,`%`]})}),t[15]=d,t[16]=T,t[17]=E):E=t[17];let D;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,$.jsx)(W,{children:`Reset zoom`}),t[18]=D):D=t[18];let O;t[19]===E?O=t[20]:(O=(0,$.jsxs)(q,{children:[E,D]}),t[19]=E,t[20]=O);let k,A;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,$.jsx)(Kt,{className:`h-3.5 w-3.5`}),A=(0,$.jsx)(`span`,{className:`sr-only`,children:`Zoom in`}),t[21]=k,t[22]=A):(k=t[21],A=t[22]);let j;t[23]===l?j=t[24]:(j=(0,$.jsx)(K,{asChild:!0,children:(0,$.jsxs)(G,{variant:`ghost`,size:`icon-xs`,onClick:l,children:[k,A]})}),t[23]=l,t[24]=j);let M;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,$.jsx)(W,{children:`Zoom in`}),t[25]=M):M=t[25];let N;t[26]===j?N=t[27]:(N=(0,$.jsxs)(q,{children:[j,M]}),t[26]=j,t[27]=N);let P,F;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,$.jsx)(en,{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]===d?I=t[31]:(I=(0,$.jsx)(K,{asChild:!0,children:(0,$.jsxs)(G,{variant:`ghost`,size:`icon-xs`,onClick:d,children:[P,F]})}),t[30]=d,t[31]=I);let L;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,$.jsx)(W,{children:`Reset view`}),t[32]=L):L=t[32];let R;t[33]===I?R=t[34]:(R=(0,$.jsxs)(q,{children:[I,L]}),t[33]=I,t[34]=R);let z;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,$.jsx)(`div`,{className:`w-px h-4 bg-border mx-1`}),t[35]=z):z=t[35];let ee,B;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(ee=(0,$.jsx)(s,{className:`h-3.5 w-3.5`}),B=(0,$.jsx)(`span`,{className:`sr-only`,children:`Close`}),t[36]=ee,t[37]=B):(ee=t[36],B=t[37]);let te;t[38]===r?te=t[39]:(te=(0,$.jsx)(K,{asChild:!0,children:(0,$.jsxs)(G,{variant:`ghost`,size:`icon-xs`,onClick:r,children:[ee,B]})}),t[38]=r,t[39]=te);let ne;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(ne=(0,$.jsx)(W,{children:`Close (Esc)`}),t[40]=ne):ne=t[40];let V;t[41]===te?V=t[42]:(V=(0,$.jsxs)(q,{children:[te,ne]}),t[41]=te,t[42]=V);let re;t[43]!==O||t[44]!==N||t[45]!==R||t[46]!==V||t[47]!==C?(re=(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 bg-background/90 border-b border-border shrink-0`,children:[v,(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[C,O,N,R,z,V]})]}),t[43]=O,t[44]=N,t[45]=R,t[46]=V,t[47]=C,t[48]=re):re=t[48];let ie=o?`cursor-grabbing`:`cursor-grab`,H;t[49]===ie?H=t[50]:(H=U(`flex-1 overflow-hidden select-none`,ie),t[49]=ie,t[50]=H);let ae=`translate(${a.x}px, ${a.y}px) scale(${i})`,oe=o?`none`:`transform 0.1s ease-out`,se;t[51]!==ae||t[52]!==oe?(se={transform:ae,transformOrigin:`center center`,transition:oe},t[51]=ae,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]!==c||t[60]!==f||t[61]!==p||t[62]!==m||t[63]!==H||t[64]!==le?(ue=(0,$.jsx)(`div`,{ref:c,className:H,onMouseDown:f,onMouseMove:p,onMouseUp:m,onMouseLeave:m,children:le}),t[59]=c,t[60]=f,t[61]=p,t[62]=m,t[63]=H,t[64]=le,t[65]=ue):ue=t[65];let de;t[66]===Symbol.for(`react.memo_cache_sentinel`)?(de=(0,$.jsx)(`div`,{className:U(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]!==re||t[68]!==ue?(fe=(0,Li.createPortal)((0,$.jsx)(Ke,{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:[re,ue,de]})}),document.body),t[67]=re,t[68]=ue,t[69]=fe):fe=t[69],fe}function qi(){return document.body.style.overflow=`hidden`,Ji}function Ji(){document.body.style.overflow=``}function Yi(e){let t=(0,X.c)(53),{content:n,className:r}=e,[i,a]=(0,Y.useState)(!1),[o,s]=(0,Y.useState)(!1),{svgOutput:c,renderError:l}=Gi(n,Wi()),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=U(J.compact,`font-mono text-muted-foreground`),t[2]=f):f=t[2];let p=l?`mermaid (render error)`:`mermaid diagram`,m;t[3]===p?m=t[4]:(m=(0,$.jsx)(`span`,{className:f,children:p}),t[3]=p,t[4]=m);let h;t[5]!==l||t[6]!==c?(h=c&&!l&&(0,$.jsxs)(q,{children:[(0,$.jsx)(K,{asChild:!0,children:(0,$.jsxs)(G,{variant:`action`,size:`icon-xs`,onClick:()=>s(!0),children:[(0,$.jsx)(sn,{}),(0,$.jsx)(`span`,{className:`sr-only`,children:`View fullscreen`})]})}),(0,$.jsx)(W,{children:`View fullscreen`})]}),t[5]=l,t[6]=c,t[7]=h):h=t[7];let g;t[8]===i?g=t[9]:(g=i?(0,$.jsx)(qt,{}):(0,$.jsx)(Ht,{}),t[8]=i,t[9]=g);let _;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(`span`,{className:`sr-only`,children:`Copy mermaid code`}),t[10]=_):_=t[10];let v;t[11]!==d||t[12]!==g?(v=(0,$.jsxs)(G,{variant:`action`,size:`icon-xs`,onClick:d,children:[g,_]}),t[11]=d,t[12]=g,t[13]=v):v=t[13];let y;t[14]!==h||t[15]!==v?(y=(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[h,v]}),t[14]=h,t[15]=v,t[16]=y):y=t[16];let b;t[17]!==m||t[18]!==y?(b=(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border bg-muted/80 px-4 py-2`,children:[m,y]}),t[17]=m,t[18]=y,t[19]=b):b=t[19];let x=b;if(l){let e;t[20]===r?e=t[21]:(e=U(`group relative overflow-hidden rounded-lg border border-border bg-muted`,r),t[20]=r,t[21]=e);let i;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(i=U(J.compact,`font-mono text-foreground leading-relaxed`),t[22]=i):i=t[22];let a;t[23]===n?a=t[24]:(a=(0,$.jsx)(`pre`,{className:`overflow-x-auto p-4 max-w-full`,children:(0,$.jsx)(`code`,{className:i,children:n})}),t[23]=n,t[24]=a);let o;return t[25]!==x||t[26]!==e||t[27]!==a?(o=(0,$.jsxs)(`div`,{className:e,children:[x,a]}),t[25]=x,t[26]=e,t[27]=a,t[28]=o):o=t[28],o}if(!c){let e;t[29]===r?e=t[30]:(e=U(`group relative overflow-hidden rounded-lg border border-border bg-muted`,r),t[29]=r,t[30]=e);let n;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(`div`,{className:U(J.compact,`p-4 text-muted-foreground`),children:`Rendering diagram…`}),t[31]=n):n=t[31];let i;return t[32]!==x||t[33]!==e?(i=(0,$.jsxs)(`div`,{className:e,children:[x,n]}),t[32]=x,t[33]=e,t[34]=i):i=t[34],i}let S;t[35]===r?S=t[36]:(S=U(`group relative overflow-hidden rounded-lg border border-border bg-muted`,r),t[35]=r,t[36]=S);let C;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(C=()=>s(!0),t[37]=C):C=t[37];let w;t[38]===c?w=t[39]:(w=(0,$.jsx)(K,{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:C,dangerouslySetInnerHTML:{__html:c}})}),t[38]=c,t[39]=w);let T;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(W,{children:`Click to view fullscreen`}),t[40]=T):T=t[40];let E;t[41]===w?E=t[42]:(E=(0,$.jsxs)(q,{children:[w,T]}),t[41]=w,t[42]=E);let D;t[43]!==x||t[44]!==S||t[45]!==E?(D=(0,$.jsxs)(`div`,{className:S,children:[x,E]}),t[43]=x,t[44]=S,t[45]=E,t[46]=D):D=t[46];let O;t[47]!==o||t[48]!==c?(O=o&&(0,$.jsx)(Ki,{svgOutput:c,onClose:()=>s(!1)}),t[47]=o,t[48]=c,t[49]=O):O=t[49];let k;return t[50]!==D||t[51]!==O?(k=(0,$.jsxs)(Ke,{children:[D,O]}),t[50]=D,t[51]=O,t[52]=k):k=t[52],k}var Xi=`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(`.`),Zi=[/-->/,/--\./,/-\./,/==>/,/--\|/,/\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 Qi(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(Xi.some(e=>n===e.toLowerCase()||n.startsWith(e.toLowerCase()+` `)))return!0;let r=0;for(let t of Zi)t.test(e)&&r++;return r>=2}function $i(e){if(!Qi(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 Xi.some(e=>n===e.toLowerCase()||n.startsWith(e.toLowerCase()+` `))?e.trim():null}var ea=(0,Y.memo)(function({content:e,className:t,enableMermaid:n=!1}){let r=(0,Y.useMemo)(()=>!e||typeof e!=`string`?[]:ta(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:U(`prose-custom space-y-3 min-w-0 break-words`,t),children:r.map((e,t)=>(0,$.jsx)(na,{block:e,start:i[t]},t))})});function ta(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`||Qi(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&&Qi(e)){let t=$i(e);t?r.push({type:`mermaid`,code:t}):r.push({type:`paragraph`,text:e})}else r.push({type:`paragraph`,text:e})}}return r}var na=(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;if(t[0]!==e||t[1]!==n.level){let a={1:J.sectionTitle,2:U(J.body,`font-semibold`),3:U(J.body,`font-semibold`),4:J.sectionSubtitle,5:J.sectionSubtitle,6:J.sectionSubtitle};r=e,i=U(a[n.level]),t[0]=e,t[1]=n.level,t[2]=r,t[3]=i}else r=t[2],i=t[3];let a;t[4]===n.text?a=t[5]:(a=(0,$.jsx)(ra,{text:n.text}),t[4]=n.text,t[5]=a);let o;return t[6]!==r||t[7]!==i||t[8]!==a?(o=(0,$.jsx)(r,{className:i,children:a}),t[6]=r,t[7]=i,t[8]=a,t[9]=o):o=t[9],o}case`code`:{let e;return t[10]!==n.code||t[11]!==n.language?(e=(0,$.jsx)(aa,{language:n.language,code:n.code}),t[10]=n.code,t[11]=n.language,t[12]=e):e=t[12],e}case`blockquote`:{let e;return t[13]===n.text?e=t[14]:(e=(0,$.jsx)(`blockquote`,{className:`border-l-2 border-border pl-4 text-muted-foreground italic`,children:(0,$.jsx)(ra,{text:n.text})}),t[13]=n.text,t[14]=e),e}case`list`:{if(n.ordered){let e;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(e=U(J.body,`space-y-1`),t[15]=e):e=t[15];let r;if(t[16]!==n.items||t[17]!==i){let e;t[19]===i?e=t[20]:(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)(ra,{text:e})})]},t),t[19]=i,t[20]=e),r=n.items.map(e),t[16]=n.items,t[17]=i,t[18]=r}else r=t[18];let a;return t[21]===r?a=t[22]:(a=(0,$.jsx)(`ol`,{className:e,children:r}),t[21]=r,t[22]=a),a}let e;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(e=U(J.body,`space-y-1 pl-5 list-outside overflow-visible list-disc`),t[23]=e):e=t[23];let r;t[24]===n.items?r=t[25]:(r=n.items.map(oa),t[24]=n.items,t[25]=r);let a;return t[26]===r?a=t[27]:(a=(0,$.jsx)(`ul`,{className:e,children:r}),t[26]=r,t[27]=a),a}case`paragraph`:{let e;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(e=U(J.body,`leading-relaxed whitespace-pre-wrap break-words`),t[28]=e):e=t[28];let r;return t[29]===n.text?r=t[30]:(r=(0,$.jsx)(`p`,{className:e,children:(0,$.jsx)(ra,{text:n.text})}),t[29]=n.text,t[30]=r),r}case`hr`:{let e;return t[31]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`hr`,{className:`border-border`}),t[31]=e):e=t[31],e}case`table`:{let e;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(e=U(J.body,`w-full`),t[32]=e):e=t[32];let r;t[33]===n.headers?r=t[34]:(r=n.headers.map(sa),t[33]=n.headers,t[34]=r);let i;t[35]===r?i=t[36]:(i=(0,$.jsx)(`thead`,{children:(0,$.jsx)(`tr`,{className:`border-b border-border bg-muted/50`,children:r})}),t[35]=r,t[36]=i);let a;t[37]===n.rows?a=t[38]:(a=n.rows.map(la),t[37]=n.rows,t[38]=a);let o;t[39]===a?o=t[40]:(o=(0,$.jsx)(`tbody`,{children:a}),t[39]=a,t[40]=o);let s;return t[41]!==i||t[42]!==o?(s=(0,$.jsx)(`div`,{className:`overflow-x-auto rounded-md border border-border max-w-full`,children:(0,$.jsxs)(`table`,{className:e,children:[i,o]})}),t[41]=i,t[42]=o,t[43]=s):s=t[43],s}case`mermaid`:{let e;return t[44]===n.code?e=t[45]:(e=(0,$.jsx)(Yi,{content:n.code}),t[44]=n.code,t[45]=e),e}default:return null}}),ra=(0,Y.memo)(function(e){let t=(0,X.c)(6),{text:n}=e,r;t[0]===n?r=t[1]:(r=ia(n),t[0]=n,t[1]=r);let i=r,a;t[2]===i?a=t[3]:(a=i.map(ua),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 ia(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 aa(e){let t=(0,X.c)(20),{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=U(J.compact,`text-muted-foreground font-mono`),t[2]=c):c=t[2];let l=n||`text`,u;t[3]===l?u=t[4]:(u=(0,$.jsx)(`span`,{className:c,children:l}),t[3]=l,t[4]=u);let d;t[5]===i?d=t[6]:(d=i?(0,$.jsx)(qt,{}):(0,$.jsx)(Ht,{}),t[5]=i,t[6]=d);let f;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(`span`,{className:`sr-only`,children:`Copy code`}),t[7]=f):f=t[7];let p;t[8]!==s||t[9]!==d?(p=(0,$.jsxs)(G,{variant:`action`,size:`icon-xs`,onClick:s,children:[d,f]}),t[8]=s,t[9]=d,t[10]=p):p=t[10];let m;t[11]!==u||t[12]!==p?(m=(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border bg-muted/80 px-4 py-2`,children:[u,p]}),t[11]=u,t[12]=p,t[13]=m):m=t[13];let h;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(h=U(J.mono,`text-foreground leading-relaxed`),t[14]=h):h=t[14];let g;t[15]===r?g=t[16]:(g=(0,$.jsx)(`pre`,{className:`overflow-x-auto p-4 max-w-full`,children:(0,$.jsx)(`code`,{className:h,children:r})}),t[15]=r,t[16]=g);let _;return t[17]!==g||t[18]!==m?(_=(0,$.jsxs)(`div`,{className:`group relative overflow-hidden rounded-lg border border-border bg-muted`,children:[m,g]}),t[17]=g,t[18]=m,t[19]=_):_=t[19],_}function oa(e,t){return(0,$.jsx)(`li`,{children:(0,$.jsx)(ra,{text:e})},t)}function sa(e,t){return(0,$.jsx)(`th`,{className:`px-3 py-2 text-left font-medium`,children:(0,$.jsx)(ra,{text:e})},t)}function ca(e,t){return(0,$.jsx)(`td`,{className:`px-3 py-2`,children:(0,$.jsx)(ra,{text:e})},t)}function la(e,t){return(0,$.jsx)(`tr`,{className:`border-b border-border last:border-0`,children:e.map(ca)},t)}function ua(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:U(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 da=(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 fa(){return(0,Y.useContext)(da)}var pa=new RegExp(String.raw`\x1B\[[0-?]*[ -/]*[@-~]`,`g`),ma=new RegExp(String.raw`\x1B\].*?(?:\x07|\x1B\\)`,`g`),ha=new RegExp(String.raw`\x1B[@-_]`,`g`),ga=/\r(?!\n)/g,_a=/\\n/g;function va(e){return e.replace(ma,``).replace(pa,``).replace(ha,``)}function ya(e){return va(e).replace(_a,`
14
- `).replace(ga,`
15
- `)}function ba(e){return gt(e)}function xa(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 Sa(e){return typeof e==`string`?e:typeof e==`object`&&e?JSON.stringify(e,null,2):String(e)}function Ca(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 wa(e){if(typeof e!=`object`||!e)return e;if(Array.isArray(e))return e.map(wa);let t={};for(let[n,r]of Object.entries(e))if(typeof r==`string`){let e=Ca(r);t[n]=typeof e==`object`?wa(e):r}else t[n]=wa(r);return t}function Ta(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 Ea(e){if(e==null)return``;let t=typeof e==`object`&&e?wa(e):e;return ya(Ta(typeof t==`string`?t:t==null?``:JSON.stringify(t,null,2)))}function Da(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:xa(Sa(i),t),d=xa(o?String(i.prompt):null,t),f=xa(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=xa(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??gt(n),I=e.activeDisplayName??Ot(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 Oa=new Map;function ka(e){return e.trim()}function Aa(){let e=Wt(fe.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[ka(e)]=r);return n}catch{return{}}}function ja(e){nn(fe.BASH_COMMAND_DURATIONS,JSON.stringify(e))}function Ma(e){return Aa()[ka(e)]??null}function Na(e,t){let n=ka(e);if(!n||!Number.isFinite(t)||t<=0)return;let r=Aa();r[n]=Math.round(t),ja(r)}function Pa(e,t){!t?.trim()||Oa.has(e)||Oa.set(e,{command:ka(t),startedAt:Date.now()})}function Fa(e){let t=Oa.get(e);if(!t)return;let n=Date.now()-t.startedAt;Na(t.command,n),Oa.delete(e)}function Ia(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 La(e,t){return t!==null&&t>0?`${Math.min(99,Math.round(e/t*100))}% complete`:Ia(e)}var Ra=1e3;function za(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?Ma(n):null),Pa(t,e),s.current=Date.now(),i(0)}else !n&&c.current&&(Fa(t),s.current=null,i(0),o(null));c.current=n},[n,e,t]),(0,Y.useEffect)(()=>()=>{l.current&&Fa(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,Ra);return()=>clearInterval(t)},[n]),n?La(r,a):null}function Ba(e){let{maxHeight:t=`48`,padding:n=`2`,leading:r=!1,className:i}=e??{};return U(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 Va(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)(xe,{children:(0,$.jsx)(_,{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=Ba({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)(ge,{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)(mn,{open:n,onOpenChange:r,children:l}),t[8]=r,t[9]=n,t[10]=l,t[11]=u):u=t[11],u}function Ha(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=U(J.caption,`font-mono whitespace-pre-wrap overflow-auto`),t[5]=i):i=t[5],a=e.map(Wa),o=s.map(Ua),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 Ua(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 Wa(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 Ga(e){let t=(0,X.c)(3),{name:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=U(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 Ka(e){let t=(0,X.c)(3),{type:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=U(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 qa(e){let t=(0,X.c)(3),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=U(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 Ja(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=U(`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 Ya(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=U(`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=U(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)(K,{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)(W,{children:n}),t[10]=n,t[11]=p);let m;return t[12]!==f||t[13]!==p?(m=(0,$.jsxs)(q,{children:[f,p]}),t[12]=f,t[13]=p,t[14]=m):m=t[14],m}function Xa(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?ya(m):``,t[2]=m,t[3]=h);let g=h,_=a?g:``,v=za(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)(Ya,{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:U(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:U(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)(Mt,{className:`h-3 w-3 text-muted-foreground shrink-0`}):(0,$.jsx)(st,{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=U(`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=U(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)(Ya,{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=U(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)(K,{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)(W,{children:`View output`}),t[51]=o):o=t[51];let s;t[52]===a?s=t[53]:(s=(0,$.jsxs)(q,{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)(Va,{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)(Ya,{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:U(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=U(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)(Mt,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(st,{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)(K,{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)(W,{children:n.toolName}),t[88]=n.toolName,t[89]=k);let A;t[90]!==O||t[91]!==k?(A=(0,$.jsxs)(q,{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:U(J.compact,`text-muted-foreground mb-2 font-mono`),children:[`ID: `,n.toolId]}),a?(0,$.jsx)(`div`,{ref:o,className:U(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:Ba(),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 Za(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?Qa(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)(Ya,{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:U(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:U(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)(Mt,{className:`h-3 w-3 text-muted-foreground shrink-0`}):(0,$.jsx)(st,{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:U(J.mono,J.caption,`whitespace-pre-wrap break-all rounded bg-muted/40 p-2 max-h-48 overflow-auto`),children:$a(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)(Ya,{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)(q,{children:[(0,$.jsx)(K,{asChild:!0,children:(0,$.jsx)(`code`,{className:U(J.mono,J.caption,`break-all`),children:u})}),(0,$.jsx)(W,{children:u})]}),t[31]=u,t[32]=_);let v;t[33]===f?v=t[34]:(v=f&&(0,$.jsxs)(`span`,{className:U(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:U(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?$a(i):``,t[42]=i,t[43]=x);let S;t[44]!==c||t[45]!==x?(S=(0,$.jsx)(Va,{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 Qa(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 $a(e){try{let t=JSON.parse(e);if(typeof t.result==`string`)return t.result}catch{}return e}var eo=ir,to=$n,no=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=U(`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)(Yn,{children:(0,$.jsx)(Sn,{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});no.displayName=Sn.displayName;function ro(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=U(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 io(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=U(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 ao(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)(eo,{children:[(0,$.jsx)(to,{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)(Ya,{toolName:n.toolName,displayName:n.displayName,isActive:!1,muted:!1})})})}),(0,$.jsx)(no,{className:`w-80 max-h-80 overflow-auto`,align:`start`,children:(0,$.jsxs)(`div`,{className:U(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)(Ya,{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)(q,{children:[(0,$.jsx)(K,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,onClick:n.hasEditDiff?()=>l(!0):d,className:U(`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)(io,{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)(ro,{type:`added`,count:n.editAddedLineCount}),n.editDeletedLineCount===null?null:(0,$.jsx)(ro,{type:`deleted`,count:n.editDeletedLineCount})]}):null]})}),(0,$.jsx)(W,{children:n.hasEditDiff?`View diff`:n.filePath?xa(n.filePath,i)??n.filePath:n.fileDisplayName})]}),n.hasEditDiff&&(0,$.jsx)(mn,{open:c,onOpenChange:l,children:(0,$.jsxs)(ge,{className:`max-w-2xl h-[80vh] flex flex-col`,children:[(0,$.jsx)(xe,{children:(0,$.jsx)(_,{children:(0,$.jsx)(`code`,{className:U(J.caption,`font-mono`),children:xa(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)(Ha,{oldText:n.editOldText,newText:n.editNewText})})]})})]}):n.path===null?null:(0,$.jsxs)(q,{children:[(0,$.jsx)(K,{asChild:!0,children:(0,$.jsx)(`span`,{className:U(J.caption,`font-mono truncate max-w-[200px] sm:max-w-[320px]`),children:n.path})}),(0,$.jsx)(W,{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=U(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 h;t[33]===o?h=t[34]:(h=o?(0,$.jsx)(Mt,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(st,{className:`h-4 w-4 shrink-0`}),t[33]=o,t[34]=h);let g;t[35]!==f||t[36]!==m||t[37]!==h?(g=(0,$.jsx)(K,{asChild:!0,children:(0,$.jsxs)(`button`,{onClick:f,className:p,children:[m,h]})}),t[35]=f,t[36]=m,t[37]=h,t[38]=g):g=t[38];let v;t[39]===n.toolName?v=t[40]:(v=(0,$.jsx)(W,{children:n.toolName}),t[39]=n.toolName,t[40]=v);let y;t[41]!==g||t[42]!==v?(y=(0,$.jsxs)(q,{children:[g,v]}),t[41]=g,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:U(J.compact,`text-muted-foreground mb-2 font-mono`),children:[`ID: `,n.toolId]}),n.toolInput?(0,$.jsx)(`pre`,{className:Ba(),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 oo(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)(qa,{children:n.codeSearchQuery}),n.pattern!==null&&(0,$.jsxs)(qa,{children:[`/`,n.pattern,`/`]}),n.codeSearchFilePath!==null&&(0,$.jsx)(qa,{children:n.codeSearchFilePath}),n.codeSearchFileGlob!==null&&(0,$.jsx)(qa,{children:n.codeSearchFileGlob})]}):n.pattern!==null&&(0,$.jsx)(qa,{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 so(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)(Ya,{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=U(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)(K,{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)(W,{children:`View results`}),t[8]=u):u=t[8];let f;t[9]===s?f=t[10]:(f=(0,$.jsxs)(q,{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)(Va,{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)(Ya,{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)(oo,{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:U(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=U(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)(Ja,{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:U(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:U(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:U(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:U(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)(Mt,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(st,{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)(K,{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)(W,{children:n.toolName}),t[54]=n.toolName,t[55]=y);let b;t[56]!==v||t[57]!==y?(b=(0,$.jsxs)(q,{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:U(J.compact,`text-muted-foreground mb-2 font-mono`),children:[`ID: `,n.toolId]}),n.toolInput?(0,$.jsx)(`pre`,{className:Ba(),children:n.toolInput}):null,u&&i&&(0,$.jsx)(`pre`,{className:Ba({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 co(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)(to,{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)(Ya,{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=U(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)(no,{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)(eo,{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)(Ga,{name:n.agentName}),t[16]=n.agentName,t[17]=l);let u;t[18]===n.subagentType?u=t[19]:(u=n.subagentType&&(0,$.jsx)(Ka,{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=U(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)(Ja,{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)(Ga,{name:n.agentName}),t[31]=n.agentName,t[32]=d);let f;t[33]===n.subagentType?f=t[34]:(f=n.subagentType&&(0,$.jsx)(Ka,{type:n.subagentType}),t[33]=n.subagentType,t[34]=f);let p;t[35]===a?p=t[36]:(p=a?(0,$.jsx)(Mt,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(st,{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)(K,{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)(W,{children:n.toolName}),t[44]=n.toolName,t[45]=h);let g;t[46]!==m||t[47]!==h?(g=(0,$.jsxs)(q,{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:U(J.compact,`text-muted-foreground mb-2 font-mono`),children:[`ID: `,n.toolId]}),n.prompt?(0,$.jsx)(`div`,{className:Ba({maxHeight:`64`,padding:`3`,leading:!0}),children:n.prompt}):n.toolInput?(0,$.jsx)(`pre`,{className:Ba(),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 lo(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=U(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)(Ja,{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)(Mt,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(st,{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)(K,{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)(W,{children:n.toolName}),t[14]=n.toolName,t[15]=p);let m;t[16]!==f||t[17]!==p?(m=(0,$.jsxs)(q,{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:U(J.compact,`text-muted-foreground mb-2 font-mono`),children:[`ID: `,n.toolId]}),n.toolInput?(0,$.jsx)(`pre`,{className:Ba(),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 uo(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)(Ya,{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)(q,{children:[(0,$.jsx)(K,{asChild:!0,children:(0,$.jsx)(`span`,{className:U(J.caption,`truncate max-w-[200px] sm:max-w-[320px]`),children:n.imageGenPrompt})}),(0,$.jsx)(W,{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=U(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)(Ja,{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)(Mt,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(st,{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)(K,{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)(W,{children:n.toolName}),t[23]=n.toolName,t[24]=p);let m;t[25]!==f||t[26]!==p?(m=(0,$.jsxs)(q,{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:U(J.compact,`text-muted-foreground mb-2 font-mono`),children:[`ID: `,n.toolId]}),n.toolInput?(0,$.jsx)(`pre`,{className:Ba(),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 fo(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)(eo,{children:[(0,$.jsx)(to,{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)(Ya,{toolName:n.toolName,displayName:n.displayName,isActive:i,muted:!1})})})}),(0,$.jsx)(no,{className:`w-80 max-h-80 overflow-auto`,align:`start`,children:(0,$.jsxs)(`div`,{className:U(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)(Ya,{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)(q,{children:[(0,$.jsx)(K,{asChild:!0,children:(0,$.jsx)(`span`,{className:U(J.caption,`font-mono truncate max-w-[200px] sm:max-w-[320px]`),children:n.path})}),(0,$.jsx)(W,{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=U(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)(Ja,{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)(Mt,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(st,{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)(K,{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)(W,{children:n.toolName}),t[27]=n.toolName,t[28]=p);let m;t[29]!==f||t[30]!==p?(m=(0,$.jsxs)(q,{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:U(J.compact,`text-muted-foreground mb-2 font-mono`),children:[`ID: `,n.toolId]}),n.prompt?(0,$.jsx)(`div`,{className:Ba({maxHeight:`64`,padding:`3`,leading:!0}),children:n.prompt}):n.toolInput?(0,$.jsx)(`pre`,{className:Ba(),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 po(e){let t=(0,X.c)(40),{block:n,inline:r,resultContent:i,isActive:a}=e,{setPendingExplorerPath:o,setActiveMainTab:s}=fa(),c=Q(mo),l=Da(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)(Xa,{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)(Za,{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)(ao,{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)(so,{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)(co,{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)(lo,{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)(uo,{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)(fo,{data:l,inline:r,isActive:u}),t[36]=l,t[37]=r,t[38]=u,t[39]=e):e=t[39],e}}}function mo(e){return e.projects.find(t=>t.projectId===e.selectedProjectId)?.threads.find(t=>t.threadId===e.selectedThreadId)?.path}var ho=(0,Y.createContext)({todos:[],setTodos:()=>{}});function go(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)(ho.Provider,{value:f,children:n}),t[7]=n,t[8]=f,t[9]=p):p=t[9],p}function _o(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 vo(e){let t=(0,X.c)(5),{todos:n,sequence:r}=e,{setTodos:i}=(0,Y.useContext)(ho),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}function yo(e){let t=vn(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 bo(e){let t=(0,X.c)(29),{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 tn(o.startsWith(`data:`)?{imageData:o.replace(/^data:[^;]+;base64,/,``),filename:e}:{imageUrl:o,filename:e});Oi({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 He(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]===o?f=t[6]:(f=(0,$.jsx)(`img`,{src:o,alt:`Generated image`,className:`max-w-full rounded-lg block`,style:d}),t[5]=o,t[6]=f);let p;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(C,{className:`h-3.5 w-3.5`}),t[7]=p):p=t[7];let m;t[8]===c?m=t[9]:(m=(0,$.jsx)(K,{asChild:!0,children:(0,$.jsx)(`button`,{onClick:c,className:`flex items-center justify-center h-7 w-7 rounded-md bg-background/80 backdrop-blur-sm border border-border text-foreground hover:bg-background transition-colors`,children:p})}),t[8]=c,t[9]=m);let h;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(W,{children:`Save image`}),t[10]=h):h=t[10];let g;t[11]===m?g=t[12]:(g=(0,$.jsxs)(q,{children:[m,h]}),t[11]=m,t[12]=g);let _;t[13]===i?_=t[14]:(_=i?(0,$.jsx)(qt,{className:`h-3.5 w-3.5 text-green-500`}):(0,$.jsx)(Ht,{className:`h-3.5 w-3.5`}),t[13]=i,t[14]=_);let v;t[15]!==u||t[16]!==_?(v=(0,$.jsx)(K,{asChild:!0,children:(0,$.jsx)(`button`,{onClick:u,className:`flex items-center justify-center h-7 w-7 rounded-md bg-background/80 backdrop-blur-sm border border-border text-foreground hover:bg-background transition-colors`,children:_})}),t[15]=u,t[16]=_,t[17]=v):v=t[17];let y=i?`Copied!`:`Copy to clipboard`,b;t[18]===y?b=t[19]:(b=(0,$.jsx)(W,{children:y}),t[18]=y,t[19]=b);let x;t[20]!==v||t[21]!==b?(x=(0,$.jsxs)(q,{children:[v,b]}),t[20]=v,t[21]=b,t[22]=x):x=t[22];let S;t[23]!==x||t[24]!==g?(S=(0,$.jsx)(`div`,{className:`absolute top-2 right-2 flex gap-1 opacity-0 group-hover/img:opacity-100 transition-opacity`,children:(0,$.jsxs)(Ke,{children:[g,x]})}),t[23]=x,t[24]=g,t[25]=S):S=t[25];let w;return t[26]!==S||t[27]!==f?(w=(0,$.jsxs)(`div`,{className:`mb-3 relative group/img inline-block max-w-full`,children:[f,S]}),t[26]=S,t[27]=f,t[28]=w):w=t[28],w}function xo(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(So),d=n.toolName??`Unknown Tool`,f=n.toolCallId??`unknown`,p=n,m=n.result??p.content,h;t[0]!==p||t[1]!==d?(h=d===`todo`?_o(p):null,t[0]=p,t[1]=d,t[2]=h):h=t[2];let g=h,v,y,b,x,S,C;if(t[3]!==p||t[4]!==r||t[5]!==m||t[6]!==u||t[7]!==a||t[8]!==g||t[9]!==d){C=Symbol.for(`react.early_return_sentinel`);bb0:{if(b=xa(Ea(m),u),!(b.length>0)&&g===null){C=null;break bb0}let e;if(t[16]!==m||t[17]!==u||t[18]!==d){if(v=ba(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=ba(d),t[25]=d,t[26]=e),v=`${e} (no result)`}e=xa(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,g!==null){let e;t[27]!==a||t[28]!==g?(e=(0,$.jsx)(vo,{todos:g,sequence:a}),t[27]=a,t[28]=g,t[29]=e):e=t[29],C=e;break bb0}if(d===`generate_image`){let e;t[30]!==p||t[31]!==m?(e=yo(m)??yo(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)(bo,{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]=g,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=U(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)(q,{children:[(0,$.jsx)(K,{asChild:!0,children:(0,$.jsxs)(`pre`,{className:U(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)(W,{children:`Click to see full output`})]}):(0,$.jsx)(`pre`,{className:U(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:U(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)(mn,{open:c,onOpenChange:l,children:(0,$.jsxs)(ge,{className:`max-w-3xl max-h-[80vh] flex flex-col`,children:[(0,$.jsx)(xe,{children:(0,$.jsx)(_,{children:`Full Output`})}),(0,$.jsx)(`pre`,{className:U(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=U(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)(Mt,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(st,{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)(K,{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)(W,{children:j}),t[67]=j,t[68]=M);let N;t[69]!==M||t[70]!==A?(N=(0,$.jsxs)(q,{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:U(J.compact,`text-muted-foreground mb-2 font-mono`),children:[`Call ID: `,f]}),b&&(0,$.jsx)(`pre`,{className:U(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 So(e){return e.projects.find(t=>t.projectId===e.selectedProjectId)?.threads.find(t=>t.threadId===e.selectedThreadId)?.path}function Co(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 wo(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 ${Co(n)}.`}function To(e){let t=(0,X.c)(40),{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=wo(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?ya(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)(Re,{className:`h-3.5 w-3.5 shrink-0 text-green-600`}):null,t[19]=y,t[20]=T);let E;t[21]===x?E=t[22]:(E=(0,$.jsx)(`span`,{className:J.caption,children:x}),t[21]=x,t[22]=E);let D;t[23]!==f||t[24]!==w||t[25]!==T||t[26]!==E?(D=(0,$.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1.5 cursor-pointer select-none text-left w-full`,onClick:w,"aria-expanded":f,children:[T,E]}),t[23]=f,t[24]=w,t[25]=T,t[26]=E,t[27]=D):D=t[27];let O=f?`grid-rows-[1fr]`:`grid-rows-[0fr]`,k;t[28]===O?k=t[29]:(k=[`grid transition-[grid-template-rows] duration-200 ease-in-out`,O],t[28]=O,t[29]=k);let A=k.join(` `),j,M;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(j=U(J.caption,`ml-5 text-muted-foreground/60 whitespace-pre-wrap overflow-y-auto`),M={maxHeight:`7.5em`},t[30]=j,t[31]=M):(j=t[30],M=t[31]);let N;t[32]===C?N=t[33]:(N=(0,$.jsx)(`div`,{className:`overflow-hidden`,children:(0,$.jsx)(`div`,{ref:s,className:j,style:M,children:C})}),t[32]=C,t[33]=N);let P;t[34]!==A||t[35]!==N?(P=(0,$.jsx)(`div`,{className:A,children:N}),t[34]=A,t[35]=N,t[36]=P):P=t[36];let F;return t[37]!==D||t[38]!==P?(F=(0,$.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[D,P]}),t[37]=D,t[38]=P,t[39]=F):F=t[39],F}function Eo(e){let t=(0,X.c)(63),{toolCall:n,className:i}=e,a=di(),[o,c]=(0,Y.useState)(!1),l;t[0]===n.id?l=t[1]:(l=e=>e.toolCallProgress[n.id],t[0]=n.id,t[1]=l);let u=Q(l),d=Q(Ao),f=Q(ko),p;t[2]!==n.activeDisplayName||t[3]!==n.name?(p=n.activeDisplayName??Ot(n.name),t[2]=n.activeDisplayName,t[3]=n.name,t[4]=p):p=t[4];let m=p;if(!d)return null;let h;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(h=()=>{c(Oo)},t[5]=h):h=t[5];let g=h,_;t[6]!==a||t[7]!==f||t[8]!==n.id||t[9]!==n.name?(_=()=>{a({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.`};a({type:Z.AppendStreamChunk,chunkType:`content`,content:JSON.stringify([e]),segments:f})},t[6]=a,t[7]=f,t[8]=n.id,t[9]=n.name,t[10]=_):_=t[10];let v=_,y=Do,b=n.name===`bash`&&typeof n.input?.command==`string`?n.input.command:null,x=n.name===`fetch`&&typeof n.input?.url==`string`?n.input.url:null,S=!b&&typeof n.input?.description==`string`?n.input.description:null,C;t[11]===i?C=t[12]:(C=U(`overflow-hidden mb-2`,i),t[11]=i,t[12]=C);let w;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(Ja,{}),t[13]=w):w=t[13];let T;t[14]===m?T=t[15]:(T=(0,$.jsx)(K,{asChild:!0,children:(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[w,(0,$.jsx)(`span`,{className:J.bodyMuted,children:m})]})}),t[14]=m,t[15]=T);let E;t[16]===n.name?E=t[17]:(E=(0,$.jsx)(W,{children:n.name}),t[16]=n.name,t[17]=E);let D;t[18]!==T||t[19]!==E?(D=(0,$.jsxs)(q,{children:[T,E]}),t[18]=T,t[19]=E,t[20]=D):D=t[20];let O;t[21]===b?O=t[22]:(O=b!==null&&(0,$.jsx)(`code`,{className:U(J.mono,J.bodyMuted,`break-all rounded bg-muted/60 px-1 py-0.5`),children:b}),t[21]=b,t[22]=O);let k;t[23]===x?k=t[24]:(k=x!==null&&(0,$.jsx)(`code`,{className:U(J.mono,J.bodyMuted,`break-all rounded bg-muted/60 px-1 py-0.5`),children:x.length>60?`${x.slice(0,59)}…`:x}),t[23]=x,t[24]=k);let A;t[25]===S?A=t[26]:(A=S!==null&&(0,$.jsx)(`span`,{className:J.bodyMuted,children:S}),t[25]=S,t[26]=A);let j;t[27]!==b||t[28]!==S||t[29]!==x?(j=!b&&!x&&!S&&(0,$.jsx)(`span`,{className:J.bodyMuted,children:`running`}),t[27]=b,t[28]=S,t[29]=x,t[30]=j):j=t[30];let M;t[31]===o?M=t[32]:(M=(0,$.jsx)(K,{asChild:!0,children:(0,$.jsx)(`button`,{onClick:g,className:`p-1 hover:bg-muted/50 rounded transition-colors`,children:o?(0,$.jsx)(r,{className:`h-3 w-3`}):(0,$.jsx)(Mt,{className:`h-3 w-3`})})}),t[31]=o,t[32]=M);let N=o?`Collapse`:`Expand`,P;t[33]===N?P=t[34]:(P=(0,$.jsx)(W,{children:N}),t[33]=N,t[34]=P);let F;t[35]!==M||t[36]!==P?(F=(0,$.jsxs)(q,{children:[M,P]}),t[35]=M,t[36]=P,t[37]=F):F=t[37];let I;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,$.jsx)(s,{className:`h-3 w-3`}),t[38]=I):I=t[38];let L;t[39]===v?L=t[40]:(L=(0,$.jsx)(K,{asChild:!0,children:(0,$.jsx)(`button`,{onClick:v,className:`p-1 hover:bg-red-200 dark:hover:bg-red-800 rounded transition-colors text-red-600 dark:text-red-400`,children:I})}),t[39]=v,t[40]=L);let R;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,$.jsx)(W,{className:`bg-red-600 text-white border-red-600`,children:`Stop this process`}),t[41]=R):R=t[41];let z;t[42]===L?z=t[43]:(z=(0,$.jsxs)(q,{children:[L,R]}),t[42]=L,t[43]=z);let ee;t[44]!==F||t[45]!==z?(ee=(0,$.jsxs)(`div`,{className:`flex items-center gap-1 ml-auto shrink-0`,children:[F,z]}),t[44]=F,t[45]=z,t[46]=ee):ee=t[46];let B;t[47]!==O||t[48]!==k||t[49]!==A||t[50]!==j||t[51]!==ee||t[52]!==D?(B=(0,$.jsxs)(`div`,{className:`py-0.5 flex items-center gap-2 flex-wrap`,children:[D,O,k,A,j,ee]}),t[47]=O,t[48]=k,t[49]=A,t[50]=j,t[51]=ee,t[52]=D,t[53]=B):B=t[53];let te;t[54]!==o||t[55]!==n.id||t[56]!==n.input||t[57]!==u?(te=o&&(0,$.jsxs)(`div`,{className:`py-2 border-t border-border min-h-[8rem] overflow-auto`,children:[(0,$.jsxs)(`div`,{className:U(J.compact,J.bodyMuted,`mb-2 font-mono`),children:[`ID: `,n.id]}),(0,$.jsxs)(`div`,{className:`mb-2`,children:[(0,$.jsx)(`div`,{className:U(J.compact,J.label,`text-muted-foreground mb-1`),children:`Input:`}),(0,$.jsx)(`pre`,{className:Ba({className:`border border-border`}),children:y(n.input)})]}),u&&(0,$.jsxs)(`div`,{className:`mb-2`,children:[(0,$.jsx)(`div`,{className:U(J.compact,J.label,`text-muted-foreground mb-1`),children:`Progress:`}),(0,$.jsxs)(`div`,{className:U(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:U(J.mono,`text-green-700 dark:text-green-300`),children:u.delta}),u.partial?.content?.[0]?.arguments&&typeof u.partial.content[0].arguments==`object`&&`content`in u.partial.content[0].arguments&&typeof u.partial.content[0].arguments.content==`string`&&(0,$.jsxs)(`div`,{className:U(J.mono,`mt-1 text-green-600 dark:text-green-400`),children:[`Building: `,u.partial.content[0].arguments.content.slice(-50),u.partial.content[0].arguments.content.length>50&&`...`]})]})]}),(0,$.jsxs)(`div`,{className:U(J.compact,`flex items-center gap-1.5 text-muted-foreground`),children:[(0,$.jsx)(Ja,{}),`Executing`,u&&` with progress`,`...`]})]}),t[54]=o,t[55]=n.id,t[56]=n.input,t[57]=u,t[58]=te):te=t[58];let ne;return t[59]!==B||t[60]!==te||t[61]!==C?(ne=(0,$.jsxs)(`div`,{className:C,children:[B,te]}),t[59]=B,t[60]=te,t[61]=C,t[62]=ne):ne=t[62],ne}function Do(e){return JSON.stringify(e,null,2)}function Oo(e){return!e}function ko(e){return e.streamingSegments}function Ao(e){return e.isStreaming}function jo(e){let t=(0,X.c)(70),{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;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(qt,{className:`h-5 w-5 text-brand shrink-0 mt-0.5`}),t[17]=e):e=t[17];let n;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(n=U(J.label,`text-foreground`),t[18]=n):n=t[18];let i;t[19]===r?i=t[20]:(i=(0,$.jsx)(`div`,{className:n,children:(0,$.jsx)(ea,{content:r})}),t[19]=r,t[20]=i);let o;t[21]===a?o=t[22]:(o=a&&(0,$.jsx)(`p`,{className:U(J.bodyMuted,`mt-1`),children:a}),t[21]=a,t[22]=o);let c;t[23]!==o||t[24]!==i?(c=(0,$.jsxs)(`div`,{className:`flex items-start gap-2 mb-2`,children:[e,(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[i,o]})]}),t[23]=o,t[24]=i,t[25]=c):c=t[25];let l=s??`You answered`,u;t[26]===l?u=t[27]:(u=(0,$.jsxs)(`span`,{className:`font-medium`,children:[l,`:`]}),t[26]=l,t[27]=u);let d;t[28]===f?d=t[29]:(d=(0,$.jsx)(`span`,{children:f}),t[28]=f,t[29]=d);let p;t[30]!==u||t[31]!==d?(p=(0,$.jsxs)(`div`,{className:J.bodyMuted,children:[u,` `,d]}),t[30]=u,t[31]=d,t[32]=p):p=t[32];let m;return t[33]!==c||t[34]!==p?(m=(0,$.jsxs)(`div`,{className:`rounded-lg border-t border-border p-4 my-2`,children:[c,p]}),t[33]=c,t[34]=p,t[35]=m):m=t[35],m}let O;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,$.jsx)(Me,{className:`h-5 w-5 text-brand shrink-0 mt-0.5`}),t[36]=O):O=t[36];let k;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(k=U(J.label,`text-foreground`),t[37]=k):k=t[37];let A;t[38]===r?A=t[39]:(A=(0,$.jsx)(`div`,{className:k,children:(0,$.jsx)(ea,{content:r})}),t[38]=r,t[39]=A);let j;t[40]===a?j=t[41]:(j=a&&(0,$.jsx)(`p`,{className:U(J.bodyMuted,`mt-1`),children:a}),t[40]=a,t[41]=j);let M;t[42]!==j||t[43]!==A?(M=(0,$.jsxs)(`div`,{className:`flex items-start gap-2 mb-3`,children:[O,(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[A,j]})]}),t[42]=j,t[43]=A,t[44]=M):M=t[44];let N;t[45]!==C||t[46]!==m||t[47]!==i||t[48]!==g?(N=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:U(`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)(qt,{className:`h-3.5 w-3.5 text-foreground`}),e]},e)})}),t[45]=C,t[46]=m,t[47]=i,t[48]=g,t[49]=N):N=t[49];let P;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(P=e=>l(e.target.value),t[50]=P):P=t[50];let F=i?.length?`Or type a custom answer...`:`Type your answer...`,I;t[51]!==c||t[52]!==D||t[53]!==m||t[54]!==F?(I=(0,$.jsx)(`input`,{type:`text`,value:c,onChange:P,onKeyDown:D,placeholder:F,disabled:m,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`}),t[51]=c,t[52]=D,t[53]=m,t[54]=F,t[55]=I):I=t[55];let L;t[56]!==c||t[57]!==m?(L=m||!c.trim(),t[56]=c,t[57]=m,t[58]=L):L=t[58];let R;t[59]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,$.jsx)(tt,{className:`h-3 w-3`}),t[59]=R):R=t[59];let z;t[60]!==T||t[61]!==L?(z=(0,$.jsx)(`button`,{type:`button`,onClick:T,disabled:L,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:R}),t[60]=T,t[61]=L,t[62]=z):z=t[62];let ee;t[63]!==I||t[64]!==z?(ee=(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[I,z]}),t[63]=I,t[64]=z,t[65]=ee):ee=t[65];let B;return t[66]!==M||t[67]!==N||t[68]!==ee?(B=(0,$.jsxs)(`div`,{className:`rounded-lg border-t border-border p-4 my-2`,children:[M,N,ee]}),t[66]=M,t[67]=N,t[68]=ee,t[69]=B):B=t[69],B}var Mo=tr,No=Rn,Po=Gn,Fo=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=U(U(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)(st,{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)(Kn,{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});Fo.displayName=Kn.displayName;var Io=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=U(`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)(Wn,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});Io.displayName=Wn.displayName;var Lo=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=U(`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)(On,{children:(0,$.jsx)(Hn,{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});Lo.displayName=Hn.displayName;var Ro=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=U(U(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)(kn,{ref:t,className:o,...a}),n[7]=a,n[8]=t,n[9]=o,n[10]=s):s=n[10],s});Ro.displayName=kn.displayName;var zo=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=U(U(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)(Vn,{children:(0,$.jsx)(qt,{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)(wn,{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});zo.displayName=wn.displayName;var Bo=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=U(U(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)(Vn,{children:(0,$.jsx)(Fe,{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)(Mn,{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});Bo.displayName=Mn.displayName;var Vo=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=U(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)(Un,{ref:t,className:s,...a}),n[7]=a,n[8]=t,n[9]=s,n[10]=c):c=n[10],c});Vo.displayName=Un.displayName;var Ho=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=U(`-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)(jn,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});Ho.displayName=jn.displayName;var Uo=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=U(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};Uo.displayName=`DropdownMenuShortcut`;function Wo({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 kt(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,$.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:[(0,$.jsx)(qt,{className:`h-5 w-5 text-brand shrink-0 mt-0.5`}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsx)(`div`,{className:J.label,children:`Shell command permission`}),(0,$.jsx)(`code`,{className:U(J.mono,J.bodyMuted,`mt-2 block break-all rounded bg-muted/60 px-2 py-1`),children:t})]})]}),(0,$.jsx)(`div`,{className:J.bodyMuted,children:`Skipped`})]}):(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:[(0,$.jsx)(M,{className:`h-5 w-5 text-brand shrink-0 mt-0.5`}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsx)(`div`,{className:J.label,children:`Allow the agent to run this command?`}),(0,$.jsx)(`code`,{className:U(J.mono,J.bodyMuted,`mt-2 block break-all rounded bg-muted/60 px-2 py-1`),children:t})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsxs)(`div`,{className:`inline-flex rounded-md shadow-sm`,children:[(0,$.jsx)(G,{type:`button`,size:`sm`,disabled:l,onClick:()=>void d(`allow_once`),className:`rounded-r-none`,children:`Allow`}),r.length>0&&(0,$.jsxs)(Mo,{children:[(0,$.jsx)(No,{asChild:!0,children:(0,$.jsx)(G,{type:`button`,size:`sm`,disabled:l,className:U(`rounded-l-none border-l border-primary-foreground/20 px-2`),"aria-label":`More allow options`,children:(0,$.jsx)(Mt,{className:`h-4 w-4`})})}),(0,$.jsx)(Lo,{align:`end`,className:`max-w-md`,children:r.map(e=>(0,$.jsx)(Ro,{onClick:()=>void d(e.scope===`project`?`allow_pattern_project`:`allow_pattern_session`,e.pattern),children:e.label},`${e.scope}-${e.pattern}`))})]})]}),(0,$.jsx)(G,{type:`button`,size:`sm`,variant:`outline`,disabled:l,onClick:()=>void d(`skip`),children:`Skip`})]})]})}function Go({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 _t(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,$.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:[(0,$.jsx)(qt,{className:`h-5 w-5 text-brand shrink-0 mt-0.5`}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsx)(`div`,{className:J.label,children:`Web fetch permission`}),(0,$.jsx)(`code`,{className:U(J.mono,J.bodyMuted,`mt-2 block break-all rounded bg-muted/60 px-2 py-1`),children:t})]})]}),(0,$.jsx)(`div`,{className:J.bodyMuted,children:`Skipped`})]}):(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:[(0,$.jsx)(m,{className:`h-5 w-5 text-brand shrink-0 mt-0.5`}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsx)(`div`,{className:J.label,children:`Allow the agent to fetch from this domain?`}),(0,$.jsx)(`code`,{className:U(J.mono,J.bodyMuted,`mt-2 block break-all rounded bg-muted/60 px-2 py-1`),children:t}),(0,$.jsx)(`div`,{className:U(J.caption,J.bodyMuted,`mt-1 break-all`),children:n})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsxs)(`div`,{className:`inline-flex rounded-md shadow-sm`,children:[(0,$.jsx)(G,{type:`button`,size:`sm`,disabled:l,onClick:()=>void d(`allow_once`),className:`rounded-r-none`,children:`Allow`}),r.length>0&&(0,$.jsxs)(Mo,{children:[(0,$.jsx)(No,{asChild:!0,children:(0,$.jsx)(G,{type:`button`,size:`sm`,disabled:l,className:U(`rounded-l-none border-l border-primary-foreground/20 px-2`),"aria-label":`More allow options`,children:(0,$.jsx)(Mt,{className:`h-4 w-4`})})}),(0,$.jsx)(Lo,{align:`end`,className:`max-w-md`,children:r.map(e=>(0,$.jsx)(Ro,{onClick:()=>void d(e.scope===`project`?`allow_domain_project`:`allow_domain_session`),children:e.label},`${e.scope}-${e.pattern}`))})]})]}),(0,$.jsx)(G,{type:`button`,size:`sm`,variant:`outline`,disabled:l,onClick:()=>void d(`skip`),children:`Deny`})]})]})}var Ko=new Map,qo=new Map;function Jo(e){return Ko.get(e)}function Yo(e,t){let n=qo.get(e);return n||(n=new Set,qo.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&qo.delete(e)}}function Xo(e){let t=qo.get(e);if(t)for(let e of t)e()}function Zo(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 Qo(e,t,n){if(Ko.has(e))return;Ko.set(e,{status:`running`}),Xo(e);let r=xt();(async()=>{try{let i=Zo(r,n),a=Object.getPrototypeOf(async function(){}).constructor,o=await new a(`callTool`,t)(i),s=o===void 0?null:o;Ko.set(e,{status:`success`,result:s}),Xo(e),await zt(e,s)}catch(t){let n=t instanceof Error?t.stack||t.message:String(t);Ko.set(e,{status:`error`,error:n}),Xo(e);try{await zt(e,{error:n})}catch(e){console.error(`[browser-js-executor] failed to submit error result`,e)}}})()}function $o(e){let t=(0,X.c)(49),{toolCallId:n,intention:r,code:i}=e,a=Q(ts),o;t[0]===n?o=t[1]:(o=Jo(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=()=>Yo(n,()=>{let e=Jo(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&&Qo(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(es),t[12]=x):x=t[12];let C=x;if(c===`running`){let e,n;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(e=U(J.label,`w-full py-2 flex items-center gap-2`),n=(0,$.jsx)(S,{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)(`div`,{className:`overflow-hidden`,children:(0,$.jsxs)(`div`,{className:e,children:[n,(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:i})]})}),t[15]=i,t[16]=a),a}if(c===`success`){let e,n;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(e=U(J.label,`w-full py-2 flex items-center gap-2 hover:bg-muted/50 transition-colors text-left`),n=(0,$.jsx)(S,{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]===a?o=t[20]:(o=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:a}),t[19]=a,t[20]=o);let s;t[21]===y?s=t[22]:(s=y?(0,$.jsx)(Mt,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(st,{className:`h-4 w-4 shrink-0`}),t[21]=y,t[22]=s);let c;t[23]!==o||t[24]!==s?(c=(0,$.jsxs)(`button`,{onClick:C,className:e,children:[n,o,s]}),t[23]=o,t[24]=s,t[25]=c):c=t[25];let l;t[26]!==i||t[27]!==y||t[28]!==d?(l=y&&(0,$.jsxs)(`div`,{className:`py-2 border-t border-border flex flex-col gap-2`,children:[(0,$.jsx)(`pre`,{className:U(J.bodyMuted,`leading-relaxed whitespace-pre-wrap`),children:i}),d!=null&&(0,$.jsx)(`pre`,{className:U(J.body,`leading-relaxed whitespace-pre-wrap border-t border-border pt-2`),children:d})]}),t[26]=i,t[27]=y,t[28]=d,t[29]=l):l=t[29];let u;return t[30]!==c||t[31]!==l?(u=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[c,l]}),t[30]=c,t[31]=l,t[32]=u):u=t[32],u}let w,T;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(w=U(J.label,`w-full py-2 flex items-center gap-2 hover:bg-muted/50 transition-colors text-left`),T=(0,$.jsx)(S,{className:`h-4 w-4 shrink-0 text-destructive`}),t[33]=w,t[34]=T):(w=t[33],T=t[34]);let E=r||`Browser JS Execution Failed`,D;t[35]===E?D=t[36]:(D=(0,$.jsx)(`span`,{className:`flex-1 text-left min-w-0 truncate`,children:E}),t[35]=E,t[36]=D);let O;t[37]===y?O=t[38]:(O=y?(0,$.jsx)(Mt,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(st,{className:`h-4 w-4 shrink-0`}),t[37]=y,t[38]=O);let k;t[39]!==D||t[40]!==O?(k=(0,$.jsxs)(`button`,{onClick:C,className:w,children:[T,D,O]}),t[39]=D,t[40]=O,t[41]=k):k=t[41];let A;t[42]!==i||t[43]!==p||t[44]!==y?(A=y&&(0,$.jsxs)(`div`,{className:`py-2 border-t border-border flex flex-col gap-2`,children:[(0,$.jsx)(`pre`,{className:U(J.bodyMuted,`leading-relaxed whitespace-pre-wrap`),children:p}),(0,$.jsx)(`pre`,{className:U(J.bodyMuted,`leading-relaxed whitespace-pre-wrap`),children:i})]}),t[42]=i,t[43]=p,t[44]=y,t[45]=A):A=t[45];let j;return t[46]!==k||t[47]!==A?(j=(0,$.jsxs)(`div`,{className:`overflow-hidden`,children:[k,A]}),t[46]=k,t[47]=A,t[48]=j):j=t[48],j}function es(e){return!e}function ts(e){return e.selectedThreadId}function ns(e){let t=(0,X.c)(29),{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 tn(n.startsWith(`data:`)?{imageData:n.replace(/^data:[^;]+;base64,/,``),filename:e}:{imageUrl:n,filename:e});Oi({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 He(n.startsWith(`data:`)?{imageData:n.replace(/^data:[^;]+;base64,/,``)}:{imageUrl:n}),i(!0),setTimeout(()=>i(!1),2e3)},t[2]=n,t[3]=s);let c=s,l;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(l={maxHeight:`512px`},t[4]=l):l=t[4];let u;t[5]===n?u=t[6]:(u=(0,$.jsx)(`img`,{src:n,alt:`Generated image`,className:`max-w-full rounded-lg border border-border block`,style:l}),t[5]=n,t[6]=u);let d;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(C,{className:`h-3.5 w-3.5`}),t[7]=d):d=t[7];let f;t[8]===o?f=t[9]:(f=(0,$.jsx)(K,{asChild:!0,children:(0,$.jsx)(`button`,{onClick:o,className:`flex items-center justify-center h-7 w-7 rounded-md bg-background/80 backdrop-blur-sm border border-border text-foreground hover:bg-background transition-colors`,children:d})}),t[8]=o,t[9]=f);let p;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(W,{children:`Save image`}),t[10]=p):p=t[10];let m;t[11]===f?m=t[12]:(m=(0,$.jsxs)(q,{children:[f,p]}),t[11]=f,t[12]=m);let h;t[13]===r?h=t[14]:(h=r?(0,$.jsx)(qt,{className:`h-3.5 w-3.5 text-green-500`}):(0,$.jsx)(Ht,{className:`h-3.5 w-3.5`}),t[13]=r,t[14]=h);let g;t[15]!==c||t[16]!==h?(g=(0,$.jsx)(K,{asChild:!0,children:(0,$.jsx)(`button`,{onClick:c,className:`flex items-center justify-center h-7 w-7 rounded-md bg-background/80 backdrop-blur-sm border border-border text-foreground hover:bg-background transition-colors`,children:h})}),t[15]=c,t[16]=h,t[17]=g):g=t[17];let _=r?`Copied!`:`Copy to clipboard`,v;t[18]===_?v=t[19]:(v=(0,$.jsx)(W,{children:_}),t[18]=_,t[19]=v);let y;t[20]!==g||t[21]!==v?(y=(0,$.jsxs)(q,{children:[g,v]}),t[20]=g,t[21]=v,t[22]=y):y=t[22];let b;t[23]!==y||t[24]!==m?(b=(0,$.jsx)(`div`,{className:`absolute top-2 right-2 flex gap-1 opacity-0 group-hover/img:opacity-100 transition-opacity`,children:(0,$.jsxs)(Ke,{children:[m,y]})}),t[23]=y,t[24]=m,t[25]=b):b=t[25];let x;return t[26]!==b||t[27]!==u?(x=(0,$.jsxs)(`div`,{className:`mt-2 relative group/img inline-block max-w-full`,children:[u,b]}),t[26]=b,t[27]=u,t[28]=x):x=t[28],x}function rs(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 is(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 as(e,t){return e.some(e=>e.type===`tool-result`&&e.toolCallId===t)}function os(e,t){if(t)return is(e,t)}function ss(e,t,n){return(0,$.jsx)(jo,{toolCallId:e.toolCallId??`long-running-confirmation`,question:e.question,options:e.options,context:e.context,answeredText:n,answeredLabel:`You answered`},t)}function cs(e,t,n){return(0,$.jsx)(Wo,{toolCallId:e.toolCallId,command:e.command,projectId:n,wildcardOptions:e.wildcardOptions},t)}function ls(e,t,n){return(0,$.jsx)(Go,{toolCallId:e.toolCallId,hostname:e.hostname,url:e.url,projectId:n,wildcardOptions:e.wildcardOptions},t)}function us(e,t,n,r,i){if(e.name===`ask_user`)return(0,$.jsx)(jo,{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)($o,{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)(Eo,{toolCall:e},t):(0,$.jsx)(po,{inline:!0,block:e,resultContent:a?i:r,isActive:a},t)}function ds({message:e,threadId:t,messageIndex:n=0,showCheckpointRestore:r=!1,checkpointRestoreTooltip:i}){let a=e.sender===`user`,o=a?null:Kr(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 Ve(t,e.checkpointRef);n.success?Oi({title:`Checkpoint restored`,description:`Working tree restored to before this agent run.`}):Oi({title:`Restore failed`,description:n.error??`Could not restore checkpoint.`,variant:`destructive`})}catch(e){Oi({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){Oi({title:`Copy failed`,description:e instanceof Error?e.message:`Could not copy prompt.`,variant:`destructive`})}}return(0,$.jsx)(`div`,{className:U(`group px-4 py-4`,a&&`flex justify-end`),children:(0,$.jsxs)(`div`,{className:U(`flex flex-col gap-1 min-w-0 max-w-full`,a&&`items-end`),children:[(0,$.jsxs)(`div`,{className:U(`flex items-center gap-2`,a&&`flex-row-reverse`),children:[(0,$.jsx)(`span`,{className:U(J.compact,`font-medium text-foreground`),children:a?`You`:`Agent`}),a&&(0,$.jsx)(Ke,{children:(0,$.jsxs)(`div`,{className:`inline-flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity`,children:[(0,$.jsxs)(q,{children:[(0,$.jsx)(K,{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)(qt,{className:`h-3 w-3 text-green-500`}):(0,$.jsx)(Ht,{className:`h-3 w-3`})})})}),(0,$.jsx)(W,{side:`left`,children:l?`Copied prompt`:`Copy prompt`})]}),d&&(0,$.jsxs)(q,{children:[(0,$.jsx)(K,{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)(en,{className:U(`h-3 w-3`,s&&`animate-spin`)})})})}),(0,$.jsx)(W,{side:`left`,children:i??`Restore checkpoint`})]})]})}),f&&(0,$.jsxs)(`span`,{className:U(J.compact,`flex items-center gap-1 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity`),children:[(0,$.jsx)(O,{className:`h-2.5 w-2.5`}),f]}),e.model&&(0,$.jsxs)(`span`,{className:U(J.compact,`flex items-center gap-1 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity`),children:[(0,$.jsx)(S,{className:`h-2.5 w-2.5`}),ur(e.model)]}),e.metadata?.processingTimeMs&&(0,$.jsxs)(`span`,{className:U(J.compact,`flex items-center gap-1 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity`),children:[(0,$.jsx)(de,{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:U(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?me(e.metadata.estimatedCost):null]})]}),(0,$.jsx)(`div`,{className:U(`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=Ur(e.content);return t?.length?(0,$.jsx)($.Fragment,{children:$r(t,!1).map((e,n)=>{if(e.type===`thinking-group`){let t=e;return(0,$.jsx)(To,{text:t.text,label:t.label,isStreaming:!1},`tg-${n}`)}let r=e;if(r.type===`tool_use`)return us(r,n,!1,is(t,r.id));if(r.type===`long_running_confirmation`){let e=r.prompt;return ss(e,n,os(t,e.toolCallId))}if(r.type===`shell_permission`){let e=r.prompt;return cs(e,n)}if(r.type===`web_fetch_permission`){let e=r.prompt;return ls(e,n)}return r.type===`tool-result`?(0,$.jsx)(xo,{inline:!0,block:r},n):null})}):(0,$.jsx)(`div`,{className:U(J.bodyMuted,`leading-relaxed whitespace-pre-wrap`),children:(0,$.jsx)(ea,{content:Hr(e.content),enableMermaid:!0})})})():o?(0,$.jsx)($.Fragment,{children:$r(o,!1).map((e,t)=>{if(e.type===`thinking-group`){let n=e;return(0,$.jsx)(To,{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)(xo,{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 ss(e,t,os(o,e.toolCallId))}return(0,$.jsx)(`div`,{children:r.type===`text`&&`text`in r?(0,$.jsx)(ea,{content:Hr(r.text),enableMermaid:!0}):r.type===`tool_use`?us(r,void 0,!1,is(o,r.id)):r.type===`tool-result`?(0,$.jsx)(xo,{inline:!0,block:r}):null},t)})}):(0,$.jsx)(ea,{content:Hr(e.content),enableMermaid:!0,className:J.body})}),(e.generatedImageUrl||e.generatedImageData)&&(0,$.jsx)(ns,{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:U(J.compact,`flex items-center gap-1 rounded-md bg-muted px-2 py-1 text-muted-foreground`),children:[(0,$.jsx)(Yt,{className:`h-2.5 w-2.5`}),e.fileName]},t))})]})})}function fs(e){let t=(0,X.c)(26),{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(ps),f,p,m,h;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=Qr(n),s=u?`pb-0`:`pb-4`;t[12]===s?h=t[13]:(h=U(`group px-4 pt-4`,s),t[12]=s,t[13]=h),f=`flex flex-col gap-1 min-w-0`;let c;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(`span`,{className:U(J.compact,`font-medium text-foreground`),children:`Agent`}),t[14]=c):c=t[14];let g;t[15]===r?g=t[16]:(g=r&&(0,$.jsxs)(`span`,{className:U(J.compact,`flex items-center gap-1 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity`),children:[(0,$.jsx)(S,{className:`h-2.5 w-2.5`}),ur(r)]}),t[15]=r,t[16]=g),t[17]===g?p=t[18]:(p=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[c,g]}),t[17]=g,t[18]=p),m=e.length>0?(0,$.jsx)(`div`,{className:`flex flex-col gap-0.5 min-w-0 text-base`,children:$r(e,!0).map((t,n)=>{if(t.type===`thinking-group`){let e=t;return(0,$.jsx)(To,{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)(xo,{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 ss(t,`stream-${n}`,os(e,t.toolCallId))}if(r.type===`shell_permission`){let e=r.prompt;return cs(e,`stream-${n}`,i)}if(r.type===`web_fetch_permission`){let e=r.prompt;return ls(e,`stream-${n}`,i)}return(0,$.jsx)(`div`,{children:r.type===`text`&&`text`in r?(0,$.jsx)(ea,{content:Hr(r.text),enableMermaid:!0}):r.type===`tool_use`?(()=>{let t=r.id,n=is(e,t),i=rs(d[t]??{});return us(r,void 0,!as(e,t),n,i)})():r.type===`tool-result`?(0,$.jsx)(xo,{inline:!0,block:r}):null},`b-${n}`)})}):a||o?(0,$.jsx)(`div`,{className:`min-w-0`,children:(0,$.jsx)(To,{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}else f=t[8],p=t[9],m=t[10],h=t[11];let g;t[19]!==f||t[20]!==p||t[21]!==m?(g=(0,$.jsxs)(`div`,{className:f,children:[p,m]}),t[19]=f,t[20]=p,t[21]=m,t[22]=g):g=t[22];let _;return t[23]!==h||t[24]!==g?(_=(0,$.jsx)(`div`,{className:h,children:g}),t[23]=h,t[24]=g,t[25]=_):_=t[25],_}function ps(e){return e.toolCallProgress}var ms=(0,Y.memo)(fs,(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}),hs=3e3;function gs(e){let t=[...pn],n=e?t.filter(t=>t!==e):t;return n[Math.floor(Math.random()*n.length)]}function _s(e){let t=(0,X.c)(3),[n,r]=(0,Y.useState)(Je),i=(0,Y.useRef)(Je),a,o;return t[0]===e?(a=t[1],o=t[2]):(a=()=>{if(!e){r(Je),i.current=Je;return}let t=setInterval(()=>{let e=i.current===`Processing...`?gs():gs(i.current);i.current=e,r(e)},hs);return()=>clearInterval(t)},o=[e],t[0]=e,t[1]=a,t[2]=o),(0,Y.useEffect)(a,o),n}var vs=`w-7`,ys=`-ml-9`;function bs(e){let t=(0,X.c)(11),{active:n,className:r}=e,i=n===void 0?!0:n,a=_s(i),o;t[0]===r?o=t[1]:(o=U(`flex items-center gap-2`,ys,r),t[0]=r,t[1]=o);let s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(Ja,{className:vs}),t[2]=s):s=t[2];let c=i?`animate-shimmer`:void 0,l;t[3]===c?l=t[4]:(l=U(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}function xs(e){let t=(0,X.c)(34),{projects:n,onSelectProject:r,onCreateThread:i,onConnectRepo:a,onNewApp:o,onOpenFolder:s}=e,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(`img`,{src:`/tarsk-color.svg`,alt:`Tarsk`,className:`h-16 w-16 rounded-lg`}),t[0]=c):c=t[0];let l;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(`h1`,{className:U(J.pageTitle,`tracking-tight text-balance`),children:`Let's build it!`}),t[1]=l):l=t[1];let u=n.length===0?`Start or connect your first project`:`Select a project to start coding`,d;t[2]===u?d=t[3]:(d=(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3`,children:[c,(0,$.jsxs)(`div`,{className:`text-center`,children:[l,(0,$.jsx)(`p`,{className:`mt-1 ${J.pageSubtitle}`,children:u})]})]}),t[2]=u,t[3]=d);let f;if(t[4]!==i||t[5]!==r||t[6]!==n){let e;t[8]!==i||t[9]!==r?(e=e=>(0,$.jsxs)(`button`,{type:`button`,className:`flex w-56 flex-col gap-2 rounded-xl border border-border bg-background p-4 text-left shadow-sm transition-colors hover:bg-muted`,onClick:()=>{e.threads.length===0?i(e.projectId):r(e.projectId,e.threads[0].threadId)},children:[(0,$.jsx)(b,{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[8]=i,t[9]=r,t[10]=e):e=t[10],f=n.map(e),t[4]=i,t[5]=r,t[6]=n,t[7]=f}else f=t[7];let p,m,h;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(z,{className:`h-5 w-5 text-muted-foreground`}),m=(0,$.jsx)(`span`,{className:`${J.body} text-foreground leading-snug font-medium`,children:`Connect a repo`}),h=(0,$.jsx)(`span`,{className:J.caption,children:`Clone an existing repository`}),t[11]=p,t[12]=m,t[13]=h):(p=t[11],m=t[12],h=t[13]);let g;t[14]===a?g=t[15]:(g=(0,$.jsxs)(`button`,{type:`button`,className:`flex w-56 flex-col gap-2 rounded-xl border border-border bg-background p-4 text-left shadow-sm transition-colors hover:bg-muted`,onClick:a,children:[p,m,h]}),t[14]=a,t[15]=g);let _,v,y;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(Nt,{className:`h-5 w-5 text-muted-foreground`}),v=(0,$.jsx)(`span`,{className:`${J.body} text-foreground leading-snug font-medium`,children:`New App`}),y=(0,$.jsx)(`span`,{className:J.caption,children:`Create a new project from template`}),t[16]=_,t[17]=v,t[18]=y):(_=t[16],v=t[17],y=t[18]);let x;t[19]===o?x=t[20]:(x=(0,$.jsxs)(`button`,{type:`button`,className:`flex w-56 flex-col gap-2 rounded-xl border border-border bg-background p-4 text-left shadow-sm transition-colors hover:bg-muted`,onClick:o,children:[_,v,y]}),t[19]=o,t[20]=x);let S,C,w;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,$.jsx)(H,{className:`h-5 w-5 text-muted-foreground`}),C=(0,$.jsx)(`span`,{className:`${J.body} text-foreground leading-snug font-medium`,children:`Open Folder`}),w=(0,$.jsx)(`span`,{className:J.caption,children:`Use an existing local folder`}),t[21]=S,t[22]=C,t[23]=w):(S=t[21],C=t[22],w=t[23]);let T;t[24]===s?T=t[25]:(T=(0,$.jsxs)(`button`,{type:`button`,className:`flex w-56 flex-col gap-2 rounded-xl border border-border bg-background p-4 text-left shadow-sm transition-colors hover:bg-muted`,onClick:s,children:[S,C,w]}),t[24]=s,t[25]=T);let E;t[26]!==x||t[27]!==T||t[28]!==f||t[29]!==g?(E=(0,$.jsxs)(`div`,{className:`flex flex-wrap justify-center gap-3`,children:[f,g,x,T]}),t[26]=x,t[27]=T,t[28]=f,t[29]=g,t[30]=E):E=t[30];let D;return t[31]!==E||t[32]!==d?(D=(0,$.jsxs)(`div`,{className:`mx-auto flex max-w-3xl flex-1 flex-col items-center justify-center gap-8 px-4`,children:[d,E]}),t[31]=E,t[32]=d,t[33]=D):D=t[33],D}function Ss(){let e=Q(e=>e.selectedThreadId),{dispatch:t}=pi(e),{setActiveMainTab:n,setDevServerUrl:r,setDevServerRunning:i,setDevServerLoading:a}=fa();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 et(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}}function Cs(e){let t=[`What would you like to add to ${e}?`,`What should we build in ${e}?`,`What changes do you want to make to ${e}?`,`What feature should we add to ${e}?`,`What would you like to fix in ${e}?`,`What are we working on in ${e}?`,`What's next for ${e}?`,`What should we improve in ${e}?`,`How can we make ${e} better?`,`What would you like to change in ${e}?`,`What should we ship in ${e} next?`];return t[Math.floor(Math.random()*t.length)]}function ws(e){let t=(0,X.c)(26),{project:n}=e,{setDevServerRunning:r}=fa(),[i,a]=(0,Y.useState)(!1),{startServer:o}=Ss(),s;t[0]!==n||t[1]!==r?(s=()=>{if(!n?.projectId)return;let e=async()=>{try{let e=await Ae(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=Cs(u),t[5]=u,t[6]=d);let f=d,p=!i&&n?.runCommand,m;t[7]!==n||t[8]!==o?(m=()=>{n&&o(n)},t[7]=n,t[8]=o,t[9]=m):m=t[9];let h=m,g;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(`img`,{src:`/tarsk-color.svg`,alt:`Tarsk`,className:`h-16 w-16 rounded-lg`}),t[10]=g):g=t[10];let _;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(_=U(J.pageTitle,`tracking-tight text-foreground text-balance`),t[11]=_):_=t[11];let v=n?.name??`Project`,y;t[12]===v?y=t[13]:(y=(0,$.jsx)(`h1`,{className:_,children:v}),t[12]=v,t[13]=y);let b;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(b=U(J.pageSubtitle,`mt-2`),t[14]=b):b=t[14];let x;t[15]===f?x=t[16]:(x=(0,$.jsx)(`p`,{className:b,children:f}),t[15]=f,t[16]=x);let S;t[17]!==y||t[18]!==x?(S=(0,$.jsxs)(`div`,{className:`text-center`,children:[y,x]}),t[17]=y,t[18]=x,t[19]=S):S=t[19];let C;t[20]!==h||t[21]!==p?(C=p&&(0,$.jsx)(`button`,{type:`button`,onClick:h,className:U(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[20]=h,t[21]=p,t[22]=C):C=t[22];let w;return t[23]!==S||t[24]!==C?(w=(0,$.jsx)(`div`,{className:`flex-1 flex flex-col items-center justify-center`,children:(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-6 px-4`,children:[g,S,C]})}),t[23]=S,t[24]=C,t[25]=w):w=t[25],w}var Ts=(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});Ts.displayName=`MessageList`;function Es(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)(ms,{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:U(`px-4 pb-4`,h?`pt-0`:`pt-2`),children:(0,$.jsx)(bs,{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)(Er,{variant:`error`,className:`mb-0`,children:p}),(0,$.jsx)(`button`,{type:`button`,className:U(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 Ds={List:Ts,Footer:Es};function Os(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 ks(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 As(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=ks(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)}function js(e){let t=(0,X.c)(69),{bottomInset:n,messages:r,isStreaming:i,streamingSegments:a,streamingModel:o,isCreatingProject:s,isProcessingThread:c,hasPendingMessage:l,selectedThreadId:u,selectedProjectId:d,projects:f,projectsLoading:p,messagesLoaded:m,onSelectThread:h,onCreateThread:g,onConnectRepo:_,onNewApp:v,onOpenFolder:y,error:b,onClearError:x}=e,S=n===void 0?0:n,C=(0,Y.useRef)(null),w=(0,Y.useRef)(0),T=(0,Y.useRef)(!1),E=(0,Y.useRef)(!1),D;t[0]===u?D=t[1]:(D=()=>{u&&C.current?.getState(e=>{ct(u,e.scrollTop)})},t[0]=u,t[1]=D);let O=D,k,A;t[2]===O?(k=t[3],A=t[4]):(k=()=>{let e=()=>{O()};return window.addEventListener(`beforeunload`,e),()=>{window.removeEventListener(`beforeunload`,e),O()}},A=[O],t[2]=O,t[3]=k,t[4]=A),(0,Y.useEffect)(k,A);let j,M;t[5]===O?(j=t[6],M=t[7]):(j=()=>{let e=setInterval(()=>{O()},5e3);return()=>clearInterval(e)},M=[O],t[5]=O,t[6]=j,t[7]=M),(0,Y.useEffect)(j,M);let P,F;t[8]!==r.length||t[9]!==m||t[10]!==u?(P=()=>{if(!u||!m||E.current||(E.current=!0,r.length===0))return;let e=N(u);e!==null&&e>0&&requestAnimationFrame(()=>{C.current?.scrollTo({top:e})})},F=[u,m,r.length],t[8]=r.length,t[9]=m,t[10]=u,t[11]=P,t[12]=F):(P=t[11],F=t[12]),(0,Y.useEffect)(P,F);let I;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(I=()=>{E.current=!1,w.current=0},t[13]=I):I=t[13];let L;t[14]===u?L=t[15]:(L=[u],t[14]=u,t[15]=L),(0,Y.useEffect)(I,L);let R;t[16]!==l||t[17]!==i||t[18]!==r.length?(R=()=>{if(!E.current)return;let e=r.length>w.current,t=T.current&&!i;(i||l||e||t)&&requestAnimationFrame(()=>{C.current?.scrollTo({top:2**53-1,behavior:`smooth`})}),w.current=r.length,T.current=i},t[16]=l,t[17]=i,t[18]=r.length,t[19]=R):R=t[19];let z;t[20]!==l||t[21]!==i||t[22]!==r||t[23]!==a.length?(z=[i,l,r,a.length],t[20]=l,t[21]=i,t[22]=r,t[23]=a.length,t[24]=z):z=t[24],(0,Y.useEffect)(R,z);let ee=r.length===0&&!i&&!s&&!u,B=m&&r.length===0&&!i&&!s&&!c&&!l&&u,te;if(t[25]!==f||t[26]!==d){let e;t[28]===d?e=t[29]:(e=e=>e.projectId===d,t[28]=d,t[29]=e),te=f.find(e),t[25]=f,t[26]=d,t[27]=te}else te=t[27];let ne=te;if(ee){let e=`transition-opacity duration-500 ease-in-out ${p?`opacity-0`:`opacity-100`}`,n;t[30]!==_||t[31]!==g||t[32]!==v||t[33]!==y||t[34]!==h||t[35]!==f?(n=(0,$.jsx)(xs,{projects:f,onSelectProject:h,onCreateThread:g,onConnectRepo:_,onNewApp:v,onOpenFolder:y}),t[30]=_,t[31]=g,t[32]=v,t[33]=y,t[34]=h,t[35]=f,t[36]=n):n=t[36];let r;return t[37]!==e||t[38]!==n?(r=(0,$.jsx)(`div`,{className:`flex-1 flex flex-col items-center justify-center`,children:(0,$.jsx)(`div`,{className:e,children:n})}),t[37]=e,t[38]=n,t[39]=r):r=t[39],r}if(B){let e;return t[40]===ne?e=t[41]:(e=(0,$.jsx)(ws,{project:ne}),t[40]=ne,t[41]=e),e}let V;t[42]===a?V=t[43]:(V=As(a),t[42]=a,t[43]=V);let re;t[44]!==S||t[45]!==b||t[46]!==l||t[47]!==s||t[48]!==c||t[49]!==i||t[50]!==r.length||t[51]!==x||t[52]!==d||t[53]!==o||t[54]!==a||t[55]!==V?(re={bottomInset:S,isStreaming:i,isCreatingProject:s,isProcessingThread:c,hasPendingMessage:l,hasActiveBlockingPrompt:V,selectedProjectId:d,streamingSegments:a,streamingModel:o,totalMessages:r.length,error:b,onClearError:x},t[44]=S,t[45]=b,t[46]=l,t[47]=s,t[48]=c,t[49]=i,t[50]=r.length,t[51]=x,t[52]=d,t[53]=o,t[54]=a,t[55]=V,t[56]=re):re=t[56];let ie=re,H;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(H=U(`h-full overflow-hidden`),t[57]=H):H=t[57];let ae;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(ae={height:`100%`},t[58]=ae):ae=t[58];let oe;t[59]!==l||t[60]!==s||t[61]!==c||t[62]!==i||t[63]!==u?(oe=(e,t)=>{let n=Os({isUser:t.sender===`user`,hasCheckpointRef:!!t.checkpointRef,isStreaming:i,hasPendingMessage:l,isCreatingProject:s,isProcessingThread:c});return(0,$.jsx)(ds,{message:t,threadId:u,messageIndex:e,showCheckpointRestore:t.sender===`user`&&!!t.checkpointRef&&!i&&!l&&!s&&!c,checkpointRestoreTooltip:n})},t[59]=l,t[60]=s,t[61]=c,t[62]=i,t[63]=u,t[64]=oe):oe=t[64];let se;return t[65]!==ie||t[66]!==r||t[67]!==oe?(se=(0,$.jsx)(`div`,{className:H,children:(0,$.jsx)(nr,{ref:C,style:ae,data:r,context:ie,itemContent:oe,overscan:500,components:Ds})}),t[65]=ie,t[66]=r,t[67]=oe,t[68]=se):se=t[68],se}function Ms(e,t){return e?`linear-gradient(to right, transparent 0, transparent 40px, ${t} 40px)`:`linear-gradient(to right, ${t}, ${t})`}function Ns(e){return Ms(e,`hsl(var(--background))`)}function Ps(e){let t=Ms(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 Fs(e,t){return Ms(e,t?`hsl(var(--background) / 0.8)`:`hsl(var(--background))`)}function Is({initialValue:e}={}){let t=di(),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??``),O=(0,Y.useRef)(null),[k,A]=(0,Y.useState)(!1),[j,M]=(0,Y.useState)(!1),[N,P]=(0,Y.useState)([]),[F,I]=(0,Y.useState)(!1),[L,R]=(0,Y.useState)(!1),[z,ee]=(0,Y.useState)(!1),[B,te]=(0,Y.useState)([]),[ne,V]=(0,Y.useState)(null),[re,ie]=(0,Y.useState)([]),[H,ae]=(0,Y.useState)(!1),[oe,se]=(0,Y.useState)(``),[ce,le]=(0,Y.useState)(0),[ue,de]=(0,Y.useState)([]),[fe,pe]=(0,Y.useState)([]),[me,he]=(0,Y.useState)(!1),[ge,_e]=(0,Y.useState)(``),ve=(0,Y.useRef)(null),ye=(0,Y.useRef)(null),xe=(0,Y.useRef)(null),Ce=(0,Y.useRef)(null),we=(0,Y.useRef)(null),Te=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{T.current=C?.id??``,E.current=C?.provider??``},[C?.id,C?.provider]);let Ee=(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}`;O.current!==a&&(O.current=a,console.log(`[useChatInputState] Persisting model to thread:`,{threadId:i,model:{id:e.id,provider:e.provider}}),be(i,{model:e.id,modelProvider:e.provider}).then(()=>{O.current===a&&(O.current=null),console.log(`[useChatInputState] Model persisted successfully`)}).catch(e=>{O.current===a&&(O.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 Pe(),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||Ee(i,{persist:a})}catch(e){console.error(`Failed to load enabled models:`,e)}})()},[n,r,i,a,Ee]);let De=(0,Y.useRef)(Ee);(0,Y.useEffect)(()=>{De.current=Ee},[Ee]),(0,Y.useEffect)(()=>{s!==0&&(async()=>{try{let e=await Pe(),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)||De.current(t[0],{persist:!0})}}catch(e){console.error(`Failed to reload enabled models:`,e)}})()},[s]),(0,Y.useEffect)(()=>{!z||B.length>0||(async()=>{try{let e=await D(),t=Object.values(e).flat();t.length>0&&(te(t),V(e=>e??t[0]))}catch(e){console.error(`Failed to load image models:`,e)}})()},[z,B.length]);let[Oe,ke]=(0,Y.useState)(n);(0,Y.useEffect)(()=>{if(n!==Oe){Oe&&v.current.trim()&&y.current[Oe]!==v.current&&t({type:Z.SetChatInputDraft,threadId:Oe,draft:v.current});let e=!1;return queueMicrotask(()=>{e||!b.current||(ke(n),d(n?y.current[n]??``:``),ie([]),ae(!1),de([]),pe([]),he(!1),I(!1),ee(!1),R(!1))}),()=>{e=!0}}},[n,Oe]),(0,Y.useEffect)(()=>{n&&Se(n).then(({commands:e,skills:t})=>{console.log(`Loaded slash commands:`,e,`skills:`,t),de(e),pe(t)}).catch(e=>console.error(`Failed to load slash commands and skills:`,e))},[n]);let Ae=n?o[n]??``:``;return(0,Y.useEffect)(()=>{n&&d(Ae)},[n,Ae]),(0,Y.useLayoutEffect)(()=>{let e=ye.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&&(ye.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)&&A(!1),Ce.current&&!Ce.current.contains(e.target)&&M(!1)};if(k||j)return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[k,j]),{message:u,setMessage:d,historyIndex:f,setHistoryIndex:p,draftMessage:m,setDraftMessage:h,cursorPosition:g,setCursorPosition:_,availableModels:x,setAvailableModels:S,selectedModel:C,setSelectedModel:Ee,selectedModelIdRef:T,showModelMenu:k,setShowModelMenu:A,showPlusMenu:j,setShowPlusMenu:M,attachments:N,setAttachments:P,planMode:F,setPlanMode:I,ralphMode:L,setRalphMode:R,imageMode:z,setImageMode:ee,availableImageModels:B,setAvailableImageModels:te,selectedImageModel:ne,setSelectedImageModel:V,allFiles:re,setAllFiles:ie,showSuggestions:H,setShowSuggestions:ae,suggestionQuery:oe,setSuggestionQuery:se,selectedIndex:ce,setSelectedIndex:le,slashCommands:ue,setSlashCommands:de,skills:fe,setSkills:pe,showCommandSuggestions:me,setShowCommandSuggestions:he,commandQuery:ge,setCommandQuery:_e,fileInputRef:ve,textareaRef:ye,modelMenuRef:xe,plusMenuRef:Ce,suggestionsRef:we,commandSuggestionsRef:Te,handleNewChat:async()=>{if(n)try{let e=await Lt(n);t({type:Z.ClearMessages}),console.log(`New conversation started:`,e);let r=await Le(n);t({type:Z.SetMessages,messages:r.messages})}catch(e){console.error(`Failed to start new chat:`,e)}},selectedThreadId:n,dispatch:t}}var Ls=e=>{xn(e)};function Rs(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:z,setRalphMode:ee,imageMode:B,setImageMode:te,selectedImageModel:ne,hasConversationMessages:V}=e,re;t[0]!==o||t[1]!==m||t[2]!==B||t[3]!==d||t[4]!==l||t[5]!==n||t[6]!==a||t[7]!==c||t[8]!==L||t[9]!==z||t[10]!==p||t[11]!==ne||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?(re=()=>{if(!n.trim()&&o.length===0||!u)return;let e=B?ne: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:B,ralphMode:z}}):c(n,e.id,o,e.provider,L,B,z);let t=n,h=i.find(e=>e.content===t);Ls(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]=B,t[3]=d,t[4]=l,t[5]=n,t[6]=a,t[7]=c,t[8]=L,t[9]=z,t[10]=p,t[11]=ne,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]=re):re=t[21];let ie=re,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 ae=H,oe;t[29]!==j||t[30]!==y||t[31]!==n||t[32]!==te||t[33]!==r||t[34]!==R||t[35]!==ee||t[36]!==A||t[37]!==F?(oe=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),ee(!1),te(!1)):e.metadata.mode===`ralph`&&(ee(!0),R(!1),te(!1))},t[29]=j,t[30]=y,t[31]=n,t[32]=te,t[33]=r,t[34]=R,t[35]=ee,t[36]=A,t[37]=F,t[38]=oe):oe=t[38];let se=oe,ce;t[39]!==j||t[40]!==y||t[41]!==n||t[42]!==r||t[43]!==A||t[44]!==F?(ce=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]=ce):ce=t[45];let le=ce,ue,de,fe,pe;if(t[46]!==T||t[47]!==j||t[48]!==_||t[49]!==ie||t[50]!==V||t[51]!==h||t[52]!==se||t[53]!==ae||t[54]!==le||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){fe=e=>{if(k){if(e.key===`ArrowDown`){e.preventDefault(),O((D+1)%ue.length);return}if(e.key===`ArrowUp`){e.preventDefault(),O((D-1+ue.length)%ue.length);return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault();let t=ue[D];t&&(t.type===`command`?se(t.data):le(t.data));return}if(e.key===`Escape`){A(!1);return}}if(x){let t=de.length>0;if(e.key===`ArrowDown`&&t){e.preventDefault(),O((D+1)%de.length);return}if(e.key===`ArrowUp`&&t){e.preventDefault(),O((D-1+de.length)%de.length);return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault(),de[D]&&ae(de[D]);return}if(e.key===`Escape`){S(!1);return}}if(e.key===`Enter`&&!e.shiftKey){e.preventDefault(),ie();return}let t=we();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&&Tt(u).then(e=>{E(e)}).catch(Vs))}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],pe=e;let i;if(t[88]!==j||t[89]!==V||t[90]!==P||t[91]!==N){let e;t[93]!==j||t[94]!==V?(e=e=>e.metadata.action===`compact`&&!V?!1:e.name.toLowerCase().includes(j.toLowerCase()),t[93]=j,t[94]=V,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(Bs),...a.map(zs)],t[88]=j,t[89]=V,t[90]=P,t[91]=N,t[92]=i}else i=t[92];ue=i.slice(0,10),de=x?T.filter(e=>e.toLowerCase().includes(C.toLowerCase())).slice(0,10):[],t[46]=T,t[47]=j,t[48]=_,t[49]=ie,t[50]=V,t[51]=h,t[52]=se,t[53]=ae,t[54]=le,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]=ue,t[74]=de,t[75]=fe,t[76]=pe}else ue=t[73],de=t[74],fe=t[75],pe=t[76];let me;return t[98]!==ue||t[99]!==de||t[100]!==fe||t[101]!==ie||t[102]!==pe||t[103]!==se||t[104]!==ae||t[105]!==le?(me={handleSend:ie,handleKeyDown:fe,handleTextareaInput:pe,insertFileReference:ae,insertCommand:se,insertSkill:le,allSuggestions:ue,fileSuggestions:de},t[98]=ue,t[99]=de,t[100]=fe,t[101]=ie,t[102]=pe,t[103]=se,t[104]=ae,t[105]=le,t[106]=me):me=t[106],me}function zs(e){return{type:`skill`,data:e}}function Bs(e){return{type:`command`,data:e}}function Vs(e){return console.error(`Failed to fetch files:`,e)}function Hs(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(Ws),...s.map(Us)].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=U(J.dropdownGroupHeading,`px-2 py-1.5 border-b border-border/50 mb-1 flex items-center gap-2`),m=(0,$.jsx)(bn,{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:U(`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)(bn,{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:U(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:U(`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)(Ct,{className:`h-3 w-3 text-amber-500`}),(0,$.jsxs)(`span`,{className:`font-medium`,children:[`/`,r.name]}),(0,$.jsx)(`span`,{className:U(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:U(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:U(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 Us(e){return{type:`skill`,data:e}}function Ws(e){return{type:`command`,data:e}}function Gs(e){return e.startsWith(`image/`)}function Ks(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:U(J.compact,`group relative flex items-center gap-1 rounded-md bg-muted text-muted-foreground`),children:Gs(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)(s,{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)(Yt,{className:`h-3 w-3`}),e.fileName,(0,$.jsxs)(`button`,{type:`button`,onClick:()=>r(t),className:`ml-1 hover:text-foreground`,children:[(0,$.jsx)(s,{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 qs(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 Js(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=U(J.dropdownGroupHeading,`px-2 py-1.5 border-b border-border/50 mb-1 flex items-center gap-2`),u=(0,$.jsx)(ze,{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:U(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)(ue,{className:`h-4 w-4 text-blue-500`}):(0,$.jsx)(F,{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:U(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 Ys(e){let t=(0,X.c)(5),{providerSlug:n}=e;if(!n)return null;let r;t[0]===n?r=t[1]:(r=hn(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:Xs}),t[2]=r,t[3]=i,t[4]=a):a=t[4],a}function Xs(e){e.currentTarget.style.visibility=`hidden`}function Zs(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=U(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)(Ys,{providerSlug:n}),t[1]=n,t[2]=o);let s;t[3]!==i||t[4]!==r?(s=r?.url?(0,$.jsx)(dr,{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 Qs(e){let t=e.pricing?.prompt;return t==null?null:Math.ceil(t*3)}function $s(e){return`$${Ge(e)}`}function ec(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:`${$s(e.pricing.prompt??0)} input per million tokens`}),(0,$.jsx)(`div`,{children:`${$s(e.pricing.completion??0)} output per million tokens`}),(0,$.jsx)(`div`,{children:`Displayed value of ${t} is a relative price.`})]}):null}function tc(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=(Qs(e)??2**53-1)-(Qs(n)??2**53-1);if(t!==0)return t}return ur(e.id).localeCompare(ur(n.id))})}function nc(e){let t=(0,X.c)(37),{availableModels:n,selectedModel:i,onModelSelect:a}=e,[o,s]=Y.useState(!1),[c,l]=Y.useState(`relative-price`),u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=new Map,t[0]=u):u=t[0];let[d,f]=Y.useState(u),p=Y.useRef(null),m,h;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>{_e().then(function(e){f(new Map(e.map(ic)))})},h=[],t[1]=m,t[2]=h):(m=t[1],h=t[2]),Y.useEffect(m,h);let g,_;t[3]===o?(g=t[4],_=t[5]):(g=()=>{let e=e=>{p.current&&!p.current.contains(e.target)&&s(!1)};if(o)return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},_=[o],t[3]=o,t[4]=g,t[5]=_),Y.useEffect(g,_);let v;t[6]===a?v=t[7]:(v=e=>{a(e),s(!1)},t[6]=a,t[7]=v);let y=v,b;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(b=()=>{l(function(e){return e===`relative-price`?`alphabetical`:`relative-price`})},t[8]=b):b=t[8];let x=b,S;t[9]!==n||t[10]!==c?(S=tc(n,c),t[9]=n,t[10]=c,t[11]=S):S=t[11];let C=S,w=c===`relative-price`?Qt:at,T=c===`relative-price`?`Sort by relative price`:`Sort alphabetically`,E;t[12]===o?E=t[13]:(E=()=>s(!o),t[12]=o,t[13]=E);let D=i?.provider,O;t[14]===D?O=t[15]:(O=(0,$.jsx)(Ys,{providerSlug:D}),t[14]=D,t[15]=O);let k;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(k=U(J.body,`font-normal`),t[16]=k):k=t[16];let A;t[17]===i?A=t[18]:(A=i?ur(i.id):`No model`,t[17]=i,t[18]=A);let j;t[19]===A?j=t[20]:(j=(0,$.jsx)(`span`,{className:k,children:A}),t[19]=A,t[20]=j);let M;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,$.jsx)(r,{className:`h-3 w-3`}),t[21]=M):M=t[21];let N;t[22]!==O||t[23]!==j||t[24]!==E?(N=(0,$.jsxs)(G,{variant:`action`,size:`icon-sm`,className:`gap-1 w-auto px-2`,onClick:E,children:[O,j,M]}),t[22]=O,t[23]=j,t[24]=E,t[25]=N):N=t[25];let P;t[26]!==w||t[27]!==y||t[28]!==d||t[29]!==i?.id||t[30]!==o||t[31]!==T||t[32]!==C?(P=o&&(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)(Ke,{children:[(0,$.jsx)(`div`,{className:`-mb-3 flex justify-end px-1 pb-1`,children:(0,$.jsxs)(q,{children:[(0,$.jsx)(K,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,"aria-label":T,className:`rounded-md p-1 text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground`,onClick:x,children:(0,$.jsx)(w,{className:`h-3.5 w-3.5`})})}),(0,$.jsx)(W,{side:`left`,align:`start`,sideOffset:8,children:T})]})}),Object.entries(C.reduce(rc,{})).map((e,t)=>{let[n,r]=e;return(0,$.jsxs)(`div`,{children:[t>0&&(0,$.jsx)(lr,{className:`my-1`}),(0,$.jsx)(Zs,{providerSlug:n,providerData:d.get(n)}),r.map(e=>{let t=Qs(e),n=t==null?null:ec(e,t);return(0,$.jsx)(`div`,{children:(0,$.jsx)(`div`,{children:(0,$.jsxs)(`button`,{type:`button`,className:U(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===i?.id&&`bg-accent font-medium`),onClick:()=>y(e),children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:ur(e.id)}),t!=null&&n&&(0,$.jsxs)(q,{children:[(0,$.jsx)(K,{asChild:!0,children:(0,$.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:t})}),(0,$.jsx)(W,{side:`left`,align:`end`,sideOffset:8,className:`max-w-64`,children:n})]})]})})},e.id)})]},n)})]})}),t[26]=w,t[27]=y,t[28]=d,t[29]=i?.id,t[30]=o,t[31]=T,t[32]=C,t[33]=P):P=t[33];let F;return t[34]!==N||t[35]!==P?(F=(0,$.jsxs)(`div`,{className:`relative`,ref:p,children:[N,P]}),t[34]=N,t[35]=P,t[36]=F):F=t[36],F}function rc(e,t){let n=t.provider??`Other`;return e[n]||(e[n]=[]),e[n].push(t),e}function ic(e){return[e.slug,e]}var ac=[{value:`build`,label:`Build`,icon:ve},{value:`plan`,label:`Plan`,icon:fn},{value:`image`,label:`Image`,icon:u},{value:`ralph`,label:`Ralph`,icon:jt}];function oc(e,t,n){return n?`ralph`:e?`plan`:t?`image`:`build`}function sc({planMode:e,imageMode:t,ralphMode:n,setPlanMode:i,setImageMode:a,setRalphMode:o,projectId:s}){let c=di(),l=Q(function(e){if(s)return e.projects.find(e=>e.projectId===s)}),[u,d]=Y.useState(!1),[f,p]=Y.useState(!0),[m,h]=Y.useState(!1),g=Y.useRef(null),_=oc(e,t,n),v=ac.find(e=>e.value===_),y=v.icon;Y.useEffect(()=>{function e(e){g.current&&!g.current.contains(e.target)&&d(!1)}if(u)return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[u]),Y.useEffect(()=>{l&&p(l.allowAllCommands===!1)},[l]);async function b(){if(!s||m)return;let e=!f;p(e),h(!0);try{await Ye(s,{allowAllCommands:!e}),Te(s);let t=await yn();c({type:Z.SetProjects,projects:t.projects})}catch(t){p(!e),console.error(`Failed to update command confirmation setting:`,t)}finally{h(!1)}}function x(e){i(e===`plan`),a(e===`image`),o(e===`ralph`),d(!1)}return(0,$.jsxs)(`div`,{className:`relative`,ref:g,children:[(0,$.jsxs)(G,{variant:`action`,size:`icon-sm`,className:`gap-1 w-auto px-2`,onClick:()=>d(!u),children:[(0,$.jsx)(y,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:U(J.body,`font-normal`),children:v.label}),(0,$.jsx)(r,{className:`h-3 w-3`})]}),u&&(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:[s&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`button`,{type:`button`,className:U(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:()=>{b()},disabled:m,children:[`Confirm Commands`,f&&(0,$.jsx)(qt,{className:`ml-auto h-3.5 w-3.5`})]}),(0,$.jsx)(`div`,{className:`my-1 h-px bg-border`})]}),ac.map(e=>{let t=e.icon,n=e.value===_;return(0,$.jsxs)(`button`,{type:`button`,className:U(J.body,`flex w-full items-center gap-2 rounded-md px-3 py-2 text-popover-foreground hover:bg-accent`),onClick:()=>x(e.value),children:[(0,$.jsx)(t,{className:`h-3.5 w-3.5`}),e.label,n&&(0,$.jsx)(qt,{className:`ml-auto h-3.5 w-3.5`})]},e.value)})]})]})}function cc(e){let t=(0,X.c)(19),{disabled:n,canAddTask:r,onFileAttach:i,onAddTask:a}=e,o=n===void 0?!1:n,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=function(e){e()},t[0]=s):s=t[0];let c=s,l,u;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(Kt,{}),u=(0,$.jsx)(`span`,{className:`sr-only`,children:`More options`}),t[1]=l,t[2]=u):(l=t[1],u=t[2]);let d;t[3]===o?d=t[4]:(d=(0,$.jsx)(No,{asChild:!0,children:(0,$.jsxs)(G,{variant:`action`,size:`icon-sm`,disabled:o,children:[l,u]})}),t[3]=o,t[4]=d);let f;t[5]===i?f=t[6]:(f=()=>c(i),t[5]=i,t[6]=f);let p;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(Yt,{className:`mr-2 h-3.5 w-3.5`}),t[7]=p):p=t[7];let m;t[8]===f?m=t[9]:(m=(0,$.jsxs)(Ro,{onClick:f,children:[p,`Attach File`]}),t[8]=f,t[9]=m);let h;t[10]!==r||t[11]!==a?(h=r&&(0,$.jsxs)(Ro,{onClick:()=>c(a),children:[(0,$.jsx)(qe,{className:`mr-2 h-3.5 w-3.5`}),`Add to Pending Tasks`]}),t[10]=r,t[11]=a,t[12]=h):h=t[12];let g;t[13]!==m||t[14]!==h?(g=(0,$.jsxs)(Lo,{align:`start`,side:`top`,className:`w-56`,children:[m,h]}),t[13]=m,t[14]=h,t[15]=g):g=t[15];let _;return t[16]!==g||t[17]!==d?(_=(0,$.jsxs)(Mo,{children:[d,g]}),t[16]=g,t[17]=d,t[18]=_):_=t[18],_}var lc=Dr(`useWhisperSpeech`),uc=150;function dc(e){let t=new URLSearchParams;return t.set(`model`,e),`/api/voice-model/download?${t.toString()}`}function fc(){if(typeof SharedArrayBuffer>`u`)return 1;let e=navigator.hardwareConcurrency;return!e||e<=2?1:e<=4?2:Math.min(4,e-2)}function pc(){return typeof performance<`u`&&typeof performance.now==`function`?performance.now():Date.now()}function mc(){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)(()=>A()),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(A())}function t(){h(A())}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=dc(m);async function i(){t(`checking-support`),T(!1),p(0),d(null),lc.separator(`VOICE SESSION START`),lc.info(`Checking WASM support`,{userAgent:navigator.userAgent,platform:navigator.platform,model:m,url:n});try{let e=new kr;g.current=e;let i=await e.checkWasmSupport();if(lc.info(`WASM SIMD support check result`,{supported:i}),r(i),!i)return lc.error(`WASM SIMD not supported — voice input disabled`),t(`error`),d(`WebAssembly SIMD is not supported in this environment.`),`error`;let a=new Or;_.current=a,lc.info(`Checking IndexedDB model cache`,{url:n});try{let r=await a.loadModelByUrl(n);return lc.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),lc.info(`WASM model initialized from cache — ready`),t(`ready`),`ready`}catch(e){return lc.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 lc.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=dc(m);t(`downloading-model`),p(0),d(null),lc.info(`Model download requested`,{url:e,model:m});try{let n=await _.current.loadModelByUrl(e,e=>{p(e),e%10==0&&lc.debug(`Model download progress`,{progress:e,model:m})});lc.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),lc.info(`WASM model initialized after download — ready`),T(!0),t(`ready`)}catch(e){let n=e instanceof Error?e.message:`An unknown error occurred.`;lc.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(``),lc.separator(`RECORDING START`),lc.info(`Requesting microphone access`),!navigator.mediaDevices?.getUserMedia){lc.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=pc(),n=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,echoCancellation:!0,autoGainControl:!0,noiseSuppression:!0}}),r=n.getAudioTracks();lc.info(`Microphone access granted`,{durationMs:Math.round(pc()-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`),lc.info(`Recording started`),b.current=Ar(n,{signal:i.signal,recordingDurationMs:12e4,logLevel:0},{onError:e=>{lc.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`)lc.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`)lc.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`;lc.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){lc.info(`stopListening called but no active recording`),v.current&&=(v.current.getTracks().forEach(e=>e.stop()),null),w.current&&t(`ready`);return}lc.info(`Stopping recording — waiting for audio data`);let e=pc();y.current?.abort(),t(`transcribing`);try{let n=pc(),r=await b.current;if(x.current){lc.info(`Transcription cancelled by user`),t(`ready`);return}let i=(r.audioData.length/16e3).toFixed(2),a=Math.round(pc()-n);lc.info(`Audio capture complete — starting transcription`,{sampleCount:r.audioData.length,durationSec:i,sampleRate:16e3,conversionDurationMs:a,stopToConversionReadyMs:Math.round(pc()-e)}),v.current&&=(v.current.getTracks().forEach(e=>e.stop()),null);let o=pc(),s=fc(),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)},uc))}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(pc()-o)),u+=e.text.trim()+` `,h=u,d=h,lc.debug(`Transcription segment received`,{index:_,text:e.text,timeStart:e.timeStart,timeEnd:e.timeEnd}),p()}p(!0),lc.info(`Transcription complete`,{segmentCount:_,durationMs:Math.round(pc()-o),timeToFirstSegmentMs:f,threadCount:s,totalStopToReadyMs:Math.round(pc()-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(lc.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`)){lc.info(`WASM aborted — reinitializing model for next attempt`),t(`initializing`);try{await g.current.restartModel(),lc.info(`WASM reinitialized successfully`)}catch(e){lc.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}},[]),j=(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:j}}var hc=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=U(`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)(zn,{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)(sr,{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});hc.displayName=sr.displayName;var gc=75;function _c(e){let t=(0,X.c)(11),{open:n,onOpenChange:r,onConfirm:i,downloading:a,progress:o,error:s}=e,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsxs)(xe,{children:[(0,$.jsx)(_,{children:`Download Voice Model`}),(0,$.jsxs)(f,{children:[`To enable voice-to-text, a voice model needs to be downloaded. This is a one-time download of approximately `,gc,`MB. The model will be cached locally for future use.`]})]}),t[0]=c):c=t[0];let l;t[1]!==a||t[2]!==s||t[3]!==i||t[4]!==r||t[5]!==o?(l=(0,$.jsxs)(ge,{children:[c,a?(0,$.jsxs)(`div`,{className:`space-y-3 py-4`,children:[(0,$.jsx)(hc,{value:o,className:`w-full`}),(0,$.jsx)(`p`,{className:U(J.bodyMuted,`text-center`),children:o<100?`Downloading model... ${o}%`:`Initializing model...`})]}):s?(0,$.jsxs)(`div`,{className:`space-y-4 py-2`,children:[(0,$.jsx)(Er,{variant:`error`,className:`mb-0`,children:s}),(0,$.jsxs)(un,{children:[(0,$.jsx)(G,{variant:`outline`,onClick:()=>r(!1),children:`Cancel`}),(0,$.jsx)(G,{onClick:i,children:`Try Again`})]})]}):(0,$.jsxs)(un,{children:[(0,$.jsx)(G,{variant:`outline`,onClick:()=>r(!1),children:`Cancel`}),(0,$.jsx)(G,{onClick:i,children:`Download Model`})]})]}),t[1]=a,t[2]=s,t[3]=i,t[4]=r,t[5]=o,t[6]=l):l=t[6];let u;return t[7]!==r||t[8]!==n||t[9]!==l?(u=(0,$.jsx)(mn,{open:n,onOpenChange:r,children:l}),t[7]=r,t[8]=n,t[9]=l,t[10]=u):u=t[10],u}function vc(e){let t=(0,X.c)(67),{onTranscript:n,children:r}=e,{state:i,isWasmSupported:a,transcript:o,error:s,downloadProgress:c,startListening:l,stopListening:u,requestModelDownload:d,ensureReady:f,resetTranscript:p}=mc(),{toast:m}=ki(),[h,g]=(0,Y.useState)(!1),_=(0,Y.useRef)(``),v=(0,Y.useRef)(null),y=i===`recording`,b=i===`transcribing`,x=y||b,S=i===`needs-model`,C=i===`downloading-model`||i===`initializing`,w=i===`checking-support`,T,E;t[0]!==h||t[1]!==s||t[2]!==m?(T=()=>{s&&s!==v.current&&!h&&m({title:`Voice Input Error`,description:s,variant:`destructive`}),v.current=s},E=[s,h,m],t[0]=h,t[1]=s,t[2]=m,t[3]=T,t[4]=E):(T=t[3],E=t[4]),(0,Y.useEffect)(T,E);let D,O;t[5]!==n||t[6]!==o?(D=()=>{if(o&&o!==_.current){let e=o.substring(_.current.length);_.current=o,n(e)}},O=[o,n],t[5]=n,t[6]=o,t[7]=D,t[8]=O):(D=t[7],O=t[8]),(0,Y.useEffect)(D,O);let k,A;t[9]===o?(k=t[10],A=t[11]):(k=()=>{o||(_.current=``)},A=[o],t[9]=o,t[10]=k,t[11]=A),(0,Y.useEffect)(k,A);let j;t[12]!==f||t[13]!==x||t[14]!==S||t[15]!==p||t[16]!==l||t[17]!==i||t[18]!==u?(j=async()=>{if(x){u();return}if(S){g(!0);return}if(i===`ready`){p(),l();return}if(i===`idle`){let e=await f();e===`needs-model`?g(!0):e===`ready`&&(p(),l())}},t[12]=f,t[13]=x,t[14]=S,t[15]=p,t[16]=l,t[17]=i,t[18]=u,t[19]=j):j=t[19];let M=j,N;t[20]===d?N=t[21]:(N=()=>{d()},t[20]=d,t[21]=N);let P=N,F,I;t[22]!==h||t[23]!==i?(I=()=>{i===`ready`&&h&&g(!1)},F=[i,h],t[22]=h,t[23]=i,t[24]=F,t[25]=I):(F=t[24],I=t[25]),(0,Y.useEffect)(I,F);let L;t[26]!==s||t[27]!==w||t[28]!==C||t[29]!==y||t[30]!==b||t[31]!==a||t[32]!==S?(L=()=>w?`Checking voice input support...`:a===!1?`Voice input not supported in this browser`:s||(C?`Downloading speech model...`:b?`Transcribing...`:y?`Stop listening`:S?`Click to download speech model`:`Start listening`),t[26]=s,t[27]=w,t[28]=C,t[29]=y,t[30]=b,t[31]=a,t[32]=S,t[33]=L):L=t[33];let R=L,z;t[34]!==C||t[35]!==y||t[36]!==b?(z=()=>C||b?(0,$.jsx)(_n,{className:`h-3 w-3 animate-spin`}):y?(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)(ht,{className:`h-3 w-3`}),t[34]=C,t[35]=y,t[36]=b,t[37]=z):z=t[37];let ee=z,B,te;t[38]!==r||t[39]!==ee||t[40]!==R||t[41]!==M||t[42]!==w||t[43]!==C||t[44]!==y||t[45]!==b||t[46]!==a||t[47]!==S?(B=R(),te=r({onClick:M,disabled:w||C||b||a===!1,icon:ee(),label:B,isRecording:y,isTranscribing:b,isDownloading:C,needsModel:S,isSupported:a!==!1}),t[38]=r,t[39]=ee,t[40]=R,t[41]=M,t[42]=w,t[43]=C,t[44]=y,t[45]=b,t[46]=a,t[47]=S,t[48]=B,t[49]=te):(B=t[48],te=t[49]);let ne=te,V;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(V=(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
- `}),t[50]=V):V=t[50];let re;t[51]===ne?re=t[52]:(re=(0,$.jsx)(K,{asChild:!0,children:ne}),t[51]=ne,t[52]=re);let ie;t[53]===B?ie=t[54]:(ie=(0,$.jsx)(W,{side:`top`,className:`bg-popover text-popover-foreground max-w-64`,children:B}),t[53]=B,t[54]=ie);let H;t[55]!==re||t[56]!==ie?(H=(0,$.jsxs)(q,{children:[re,ie]}),t[55]=re,t[56]=ie,t[57]=H):H=t[57];let ae;t[58]!==h||t[59]!==c||t[60]!==s||t[61]!==P||t[62]!==C?(ae=(0,$.jsx)(_c,{open:h,onOpenChange:g,onConfirm:P,downloading:C,progress:c,error:s}),t[58]=h,t[59]=c,t[60]=s,t[61]=P,t[62]=C,t[63]=ae):ae=t[63];let oe;return t[64]!==H||t[65]!==ae?(oe=(0,$.jsxs)($.Fragment,{children:[V,H,ae]}),t[64]=H,t[65]=ae,t[66]=oe):oe=t[66],oe}function yc(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:U(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:U(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)(s,{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)(Er,{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 bc(e){let t=(0,X.c)(28),{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,b;t[0]!==u||t[1]!==c||t[2]!==o||t[3]!==s||t[4]!==d?(y=()=>{u||d(o||s||c)},b=[u,c,o,s,d],t[0]=u,t[1]=c,t[2]=o,t[3]=s,t[4]=d,t[5]=y,t[6]=b):(y=t[5],b=t[6]),(0,Y.useEffect)(y,b);let x=!f&&((p??!1)||!m&&r||!u&&h>0&&!g||u&&!g),S;t[7]!==m||t[8]!==f||t[9]!==v||t[10]!==n||t[11]!==_?(S=function(){if(f){_?.();return}if(m){v();return}n()},t[7]=m,t[8]=f,t[9]=v,t[10]=n,t[11]=_,t[12]=S):S=t[12];let C=S,w=f?`Stop generation`:m?`Send message`:a,T=`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-['']`:``}`,E;t[13]!==m||t[14]!==i||t[15]!==f?(E=f?(0,$.jsx)(`span`,{className:`block h-3 w-3 shrink-0 rounded-[2px] bg-current`,"aria-hidden":`true`}):m?(0,$.jsx)(tt,{className:`h-3 w-3`}):i,t[13]=m,t[14]=i,t[15]=f,t[16]=E):E=t[16];let D;t[17]===w?D=t[18]:(D=(0,$.jsx)(`span`,{className:`sr-only`,children:w}),t[17]=w,t[18]=D);let O;t[19]===l?O=t[20]:(O=!l&&(0,$.jsx)(`span`,{className:`sr-only`,children:`Voice input not supported`}),t[19]=l,t[20]=O);let k;return t[21]!==C||t[22]!==x||t[23]!==T||t[24]!==E||t[25]!==D||t[26]!==O?(k=(0,$.jsxs)(G,{size:`icon`,className:T,onClick:C,disabled:x,children:[E,D,O]}),t[21]=C,t[22]=x,t[23]=T,t[24]=E,t[25]=D,t[26]=O,t[27]=k):k=t[27],k}function xc(e){let t=(0,X.c)(163),{onSend:n,onStop:r,isStreaming:i,disabled:a,initialValue:o,queuedMessages:s,onRemoveQueuedMessage:c,isOverlay:l,userTasks:u,onMatchedUserTaskSend:d,onUserTaskCreated:f}=e,m=i===void 0?!1:i,h=l===void 0?!1:l,g;t[0]===u?g=t[1]:(g=u===void 0?[]:u,t[0]=u,t[1]=g);let _=g,v=Q(Ac),y;t[2]===o?y=t[3]:(y={initialValue:o},t[2]=o,t[3]=y);let{message:b,setMessage:S,historyIndex:C,setHistoryIndex:w,draftMessage:T,setDraftMessage:E,cursorPosition:D,setCursorPosition:O,availableModels:k,selectedModel:A,setSelectedModel:j,attachments:M,setAttachments:N,planMode:P,setPlanMode:F,ralphMode:I,setRalphMode:L,imageMode:R,setImageMode:z,availableImageModels:ee,selectedImageModel:B,setSelectedImageModel:te,allFiles:ne,setAllFiles:V,showSuggestions:re,setShowSuggestions:ie,suggestionQuery:H,setSuggestionQuery:ae,selectedIndex:oe,setSelectedIndex:se,slashCommands:ce,skills:le,showCommandSuggestions:ue,setShowCommandSuggestions:de,commandQuery:fe,setCommandQuery:pe,fileInputRef:me,textareaRef:he,suggestionsRef:ge,commandSuggestionsRef:_e,selectedThreadId:ve,dispatch:ye}=Is(y),be=Q(kc),xe=Q(Oc),Se;t[4]===be?Se=t[5]:(Se=be.some(Dc),t[4]=be,t[5]=Se);let Ce=Se,we=R?B:A,Te=R?ee:k,Ee;t[6]===b?Ee=t[7]:(Ee=b.trim(),t[6]=b,t[7]=Ee);let De=Ee.length>0,Oe=De||M.length>0,[ke,Ae]=Y.useState(!1),je,Me;t[8]===De?(je=t[9],Me=t[10]):(je=()=>{De&&Ae(!1)},Me=[De],t[8]=De,t[9]=je,t[10]=Me),(0,Y.useEffect)(je,Me);let Ne=ve??void 0,Pe;t[11]!==ne||t[12]!==M||t[13]!==fe||t[14]!==D||t[15]!==ye||t[16]!==T||t[17]!==Ce||t[18]!==C||t[19]!==R||t[20]!==m||t[21]!==b||t[22]!==d||t[23]!==n||t[24]!==P||t[25]!==I||t[26]!==B||t[27]!==oe||t[28]!==A||t[29]!==V||t[30]!==N||t[31]!==pe||t[32]!==O||t[33]!==E||t[34]!==w||t[35]!==z||t[36]!==S||t[37]!==F||t[38]!==L||t[39]!==se||t[40]!==de||t[41]!==ie||t[42]!==ae||t[43]!==ue||t[44]!==re||t[45]!==le||t[46]!==ce||t[47]!==H||t[48]!==Ne||t[49]!==he||t[50]!==_?(Pe={message:b,setMessage:S,userTasks:_,onMatchedUserTaskSend:d,attachments:M,selectedModel:A,onSend:n,isStreaming:m,selectedThreadId:Ne,isListening:!1,stopListening:Ec,resetTranscript:Tc,dispatch:ye,historyIndex:C,setHistoryIndex:w,draftMessage:T,setDraftMessage:E,cursorPosition:D,setCursorPosition:O,showSuggestions:re,setShowSuggestions:ie,suggestionQuery:H,setSuggestionQuery:ae,allFiles:ne,setAllFiles:V,selectedIndex:oe,setSelectedIndex:se,showCommandSuggestions:ue,setShowCommandSuggestions:de,commandQuery:fe,setCommandQuery:pe,slashCommands:ce,skills:le,textareaRef:he,setAttachments:N,planMode:P,setPlanMode:F,ralphMode:I,setRalphMode:L,imageMode:R,setImageMode:z,selectedImageModel:B,hasConversationMessages:Ce},t[11]=ne,t[12]=M,t[13]=fe,t[14]=D,t[15]=ye,t[16]=T,t[17]=Ce,t[18]=C,t[19]=R,t[20]=m,t[21]=b,t[22]=d,t[23]=n,t[24]=P,t[25]=I,t[26]=B,t[27]=oe,t[28]=A,t[29]=V,t[30]=N,t[31]=pe,t[32]=O,t[33]=E,t[34]=w,t[35]=z,t[36]=S,t[37]=F,t[38]=L,t[39]=se,t[40]=de,t[41]=ie,t[42]=ae,t[43]=ue,t[44]=re,t[45]=le,t[46]=ce,t[47]=H,t[48]=Ne,t[49]=he,t[50]=_,t[51]=Pe):Pe=t[51];let{handleSend:Fe,handleKeyDown:Ie,handleTextareaInput:Le,insertFileReference:Re,insertCommand:ze,insertSkill:Be,fileSuggestions:Ve}=Rs(Pe),He;t[52]===S?He=t[53]:(He=e=>{S(t=>(t.endsWith(` `),t+e))},t[52]=S,t[53]=He);let Ue=He,We;t[54]===N?We=t[55]:(We=e=>{let t=e.clipboardData?.items;if(!t)return;let n=Array.from(t).filter(wc);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];N(n=>[...n,{fileName:t.name||`pasted-image.${t.type.split(`/`)[1]||`png`}`,content:e,mimeType:t.type}])},n.readAsDataURL(t)}}},t[54]=N,t[55]=We);let Ge=We,Ke=h?`absolute inset-x-0 bottom-0 mx-auto w-full max-w-3xl px-4 pb-4 pointer-events-none`:`relative mx-auto w-full max-w-3xl px-4 pb-2 -mx-[6px] md:pb-4`,qe=`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`}`,Je;t[56]!==h||t[57]!==v?(Je=Fs(v,h),t[56]=h,t[57]=v,t[58]=Je):Je=t[58];let Ye;t[59]===Je?Ye=t[60]:(Ye={backgroundImage:Je},t[59]=Je,t[60]=Ye);let Xe;t[61]!==c||t[62]!==s?(Xe=(0,$.jsx)(yc,{queuedMessages:s,onRemoveQueuedMessage:c}),t[61]=c,t[62]=s,t[63]=Xe):Xe=t[63];let Ze=I?`Describe stories for Ralph to implement autonomously...`:P?`Describe what you want Tarsk to plan...`:R?`Describe the image you want to generate...`:ke?`Dictate your message...`:`Ask Tarsk anything, # for files, / for commands & skills`,Qe;t[64]===Symbol.for(`react.memo_cache_sentinel`)?(Qe=U(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[64]=Qe):Qe=t[64];let $e;t[65]!==a||t[66]!==Ie||t[67]!==Ge||t[68]!==Le||t[69]!==b||t[70]!==Ze||t[71]!==he?($e=(0,$.jsx)(`textarea`,{ref:he,value:b,onChange:Le,onKeyDown:Ie,onPaste:Ge,placeholder:Ze,rows:1,className:Qe,disabled:a}),t[65]=a,t[66]=Ie,t[67]=Ge,t[68]=Le,t[69]=b,t[70]=Ze,t[71]=he,t[72]=$e):$e=t[72];let et;t[73]!==fe||t[74]!==_e||t[75]!==ze||t[76]!==Be||t[77]!==oe||t[78]!==se||t[79]!==ue||t[80]!==le||t[81]!==ce?(et=(0,$.jsx)(Hs,{visible:ue,commands:ce,skills:le,query:fe,selectedIndex:oe,onSelectCommand:ze,onSelectSkill:Be,onMouseEnterSuggestion:se,containerRef:_e}),t[73]=fe,t[74]=_e,t[75]=ze,t[76]=Be,t[77]=oe,t[78]=se,t[79]=ue,t[80]=le,t[81]=ce,t[82]=et):et=t[82];let tt;t[83]!==Ve||t[84]!==Re||t[85]!==oe||t[86]!==se||t[87]!==re||t[88]!==H||t[89]!==ge?(tt=(0,$.jsx)(Js,{showSuggestions:re,fileSuggestions:Ve,suggestionQuery:H,selectedIndex:oe,onSelectFile:Re,onMouseEnterSuggestion:se,containerRef:ge}),t[83]=Ve,t[84]=Re,t[85]=oe,t[86]=se,t[87]=re,t[88]=H,t[89]=ge,t[90]=tt):tt=t[90];let nt;t[91]!==M||t[92]!==A?.id||t[93]!==A?.name||t[94]!==A?.supportsImages||t[95]!==N?(nt=M.length>0&&(0,$.jsxs)(`div`,{className:`px-4`,children:[(0,$.jsx)(Ks,{attachments:M,onRemove:e=>N(t=>t.filter((t,n)=>n!==e))}),M.some(Cc)&&A?.supportsImages===!1&&(0,$.jsxs)(`div`,{className:U(J.compact,`mb-2 flex items-center gap-1.5 text-amber-500`),children:[(0,$.jsx)(x,{className:`h-3 w-3 shrink-0`}),(0,$.jsxs)(`span`,{children:[`Images are not supported by `,A?.name||A?.id]})]})]}),t[91]=M,t[92]=A?.id,t[93]=A?.name,t[94]=A?.supportsImages,t[95]=N,t[96]=nt):nt=t[96];let rt;t[97]===me?rt=t[98]:(rt=()=>me.current?.click(),t[97]=me,t[98]=rt);let it;t[99]!==ye||t[100]!==b||t[101]!==f||t[102]!==N||t[103]!==S||t[104]!==ve||t[105]!==he?(it=()=>{let e=ve;if(!e)return;let t=b.trim();t&&p(e,t).then(t=>{f?.(t),S(``),N([]),ye({type:Z.ClearChatInputDraft,threadId:e}),he.current&&(he.current.style.height=`auto`)}).catch(Sc)},t[99]=ye,t[100]=b,t[101]=f,t[102]=N,t[103]=S,t[104]=ve,t[105]=he,t[106]=it):it=t[106];let at;t[107]!==a||t[108]!==De||t[109]!==rt||t[110]!==it?(at=(0,$.jsx)(cc,{disabled:a,canAddTask:De,onFileAttach:rt,onAddTask:it}),t[107]=a,t[108]=De,t[109]=rt,t[110]=it,t[111]=at):at=t[111];let ot=R?te:j,st;t[112]!==Te||t[113]!==we||t[114]!==ot?(st=(0,$.jsx)(nc,{availableModels:Te,selectedModel:we,onModelSelect:ot}),t[112]=Te,t[113]=we,t[114]=ot,t[115]=st):st=t[115];let ct;t[116]!==at||t[117]!==st?(ct=(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[at,st]}),t[116]=at,t[117]=st,t[118]=ct):ct=t[118];let lt;t[119]!==R||t[120]!==P||t[121]!==I||t[122]!==xe||t[123]!==z||t[124]!==F||t[125]!==L?(lt=(0,$.jsx)(sc,{planMode:P,imageMode:R,ralphMode:I,setPlanMode:F,setImageMode:z,setRalphMode:L,projectId:xe}),t[119]=R,t[120]=P,t[121]=I,t[122]=xe,t[123]=z,t[124]=F,t[125]=L,t[126]=lt):lt=t[126];let ut;t[127]!==M.length||t[128]!==Oe||t[129]!==a||t[130]!==we||t[131]!==Fe||t[132]!==De||t[133]!==m||t[134]!==r?(ut=e=>{let{onClick:t,disabled:n,icon:i,label:o,isRecording:s,isTranscribing:c,isDownloading:l,isSupported:u}=e;return(0,$.jsx)(bc,{onSpeechClick:t,speechDisabled:n,icon:i,label:o,isRecording:s,isTranscribing:c,isDownloading:l,isSupported:u,hasMessageText:De,setIsVoiceActive:Ae,isStreaming:m,disabled:a,canSubmitMessage:Oe,attachmentsLength:M.length,effectiveModel:we,onStop:r,onSend:Fe})},t[127]=M.length,t[128]=Oe,t[129]=a,t[130]=we,t[131]=Fe,t[132]=De,t[133]=m,t[134]=r,t[135]=ut):ut=t[135];let dt;t[136]!==Ue||t[137]!==ut?(dt=(0,$.jsx)(vc,{onTranscript:Ue,children:ut}),t[136]=Ue,t[137]=ut,t[138]=dt):dt=t[138];let ft;t[139]!==lt||t[140]!==dt?(ft=(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[lt,dt]}),t[139]=lt,t[140]=dt,t[141]=ft):ft=t[141];let pt;t[142]!==ct||t[143]!==ft?(pt=(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-3 pb-2`,children:[ct,ft]}),t[142]=ct,t[143]=ft,t[144]=pt):pt=t[144];let mt;t[145]!==qe||t[146]!==Ye||t[147]!==Xe||t[148]!==$e||t[149]!==et||t[150]!==tt||t[151]!==nt||t[152]!==pt?(mt=(0,$.jsxs)(`div`,{className:qe,style:Ye,children:[Xe,$e,et,tt,nt,pt]}),t[145]=qe,t[146]=Ye,t[147]=Xe,t[148]=$e,t[149]=et,t[150]=tt,t[151]=nt,t[152]=pt,t[153]=mt):mt=t[153];let ht;t[154]===N?ht=t[155]:(ht=e=>qs(e,e=>N(t=>[...t,...e])),t[154]=N,t[155]=ht);let gt;t[156]!==me||t[157]!==ht?(gt=(0,$.jsx)(`input`,{ref:me,type:`file`,multiple:!0,className:`hidden`,onChange:ht}),t[156]=me,t[157]=ht,t[158]=gt):gt=t[158];let _t;return t[159]!==Ke||t[160]!==mt||t[161]!==gt?(_t=(0,$.jsxs)(`div`,{className:Ke,children:[mt,gt]}),t[159]=Ke,t[160]=mt,t[161]=gt,t[162]=_t):_t=t[162],_t}function Sc(e){console.error(`Failed to create user task:`,e)}function Cc(e){return e.mimeType.startsWith(`image/`)}function wc(e){return e.type.startsWith(`image/`)}function Tc(){}function Ec(){}function Dc(e){return e.sender===`agent`}function Oc(e){return e.selectedProjectId}function kc(e){return e.messages}function Ac(e){return e.sidebarOpen}function jc(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=U(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)(z,{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)(No,{asChild:!0,children:(0,$.jsxs)(G,{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)(Kt,{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 g;t[8]!==a||t[9]!==c?(g=(0,$.jsxs)(Ro,{onClick:c,disabled:a,children:[m,h]}),t[8]=a,t[9]=c,t[10]=g):g=t[10];let _;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(Ho,{}),t[11]=_):_=t[11];let v;t[12]!==r||t[13]!==n||t[14]!==a||t[15]!==i||t[16]!==s?(v=i?(0,$.jsxs)(`div`,{className:U(J.compact,`px-2 py-1.5 text-muted-foreground flex items-center gap-2`),children:[(0,$.jsx)(_n,{className:`h-3 w-3 animate-spin`}),`Loading branches...`]}):r.length===0?(0,$.jsx)(`div`,{className:U(J.compact,`px-2 py-1.5 text-muted-foreground`),children:`No branches found`}):r.map(e=>(0,$.jsxs)(Ro,{disabled:e===n||a,onClick:()=>s(e),children:[(0,$.jsx)(z,{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:U(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]=v):v=t[17];let y;t[18]!==v||t[19]!==g?(y=(0,$.jsxs)(Lo,{align:`start`,children:[g,_,v]}),t[18]=v,t[19]=g,t[20]=y):y=t[20];let b;return t[21]!==l||t[22]!==y||t[23]!==p?(b=(0,$.jsxs)(Mo,{onOpenChange:l,children:[p,y]}),t[21]=l,t[22]=y,t[23]=p,t[24]=b):b=t[24],b}function Mc(e){let t=(0,X.c)(35),{open:n,onOpenChange:r,branchName:i,onBranchNameChange:a,isLoading:o,onCreateBranch:s}=e,c;t[0]!==i||t[1]!==o||t[2]!==s?(c=e=>{e.key===`Enter`&&i.trim()&&!o&&s()},t[0]=i,t[1]=o,t[2]=s,t[3]=c):c=t[3];let l=c,u;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsxs)(xe,{children:[(0,$.jsx)(_,{children:`New Branch`}),(0,$.jsx)(f,{children:`Enter a name for the new branch. It will be created from the default branch.`})]}),t[4]=u):u=t[4];let d;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(cn,{htmlFor:`branch-name`,children:`Branch Name`}),t[5]=d):d=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]!==l||t[10]!==o||t[11]!==p?(m=(0,$.jsx)(`div`,{className:`grid gap-4 py-4`,children:(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[d,(0,$.jsx)(Xe,{id:`branch-name`,placeholder:`e.g. feature/my-feature`,value:i,onChange:p,onKeyDown:l,disabled:o,autoFocus:!0})]})}),t[8]=i,t[9]=l,t[10]=o,t[11]=p,t[12]=m):m=t[12];let h;t[13]===r?h=t[14]:(h=()=>r(!1),t[13]=r,t[14]=h);let g;t[15]!==o||t[16]!==h?(g=(0,$.jsx)(G,{variant:`outline`,onClick:h,disabled:o,children:`Cancel`}),t[15]=o,t[16]=h,t[17]=g):g=t[17];let v;t[18]!==i||t[19]!==o?(v=o||!i.trim(),t[18]=i,t[19]=o,t[20]=v):v=t[20];let y=o?`Creating...`:`Create Branch`,b;t[21]!==s||t[22]!==v||t[23]!==y?(b=(0,$.jsx)(G,{onClick:s,disabled:v,children:y}),t[21]=s,t[22]=v,t[23]=y,t[24]=b):b=t[24];let x;t[25]!==b||t[26]!==g?(x=(0,$.jsxs)(un,{children:[g,b]}),t[25]=b,t[26]=g,t[27]=x):x=t[27];let S;t[28]!==x||t[29]!==m?(S=(0,$.jsxs)(ge,{children:[u,m,x]}),t[28]=x,t[29]=m,t[30]=S):S=t[30];let C;return t[31]!==r||t[32]!==n||t[33]!==S?(C=(0,$.jsx)(mn,{open:n,onOpenChange:r,children:S}),t[31]=r,t[32]=n,t[33]=S,t[34]=C):C=t[34],C}function Nc(e){let t=(0,X.c)(8),{collapsed:n}=e,{theme:r,setTheme:i}=jr();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)(De,{className:`h-4 w-4 rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0`}),s=(0,$.jsx)(rt,{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)(G,{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 Pc=[{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 Fc(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toString()}function Ic(e){return e>=1e6?`${Math.round(e/1e6)}M`:e>=1e3?`${Math.round(e/1e3)}K`:e.toString()}function Lc(e){let t=(0,X.c)(50),{breakdown:n,onClose:r}=e,{categories:i,totalTokens:a,contextWindow:o,percentageFull:c}=n,l,u,d,f,p,m;if(t[0]!==i||t[1]!==o||t[2]!==r||t[3]!==c||t[4]!==a){let e;t[11]===i?e=t[12]:(e=e=>i[e.key]>0,t[11]=i,t[12]=e);let n=Pc.filter(e);f=`w-72 space-y-3`;let h;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(`h3`,{className:J.label,children:`Context`}),t[13]=h):h=t[13];let g;t[14]===r?g=t[15]:(g=r&&(0,$.jsxs)(G,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground hover:text-background`,onClick:r,children:[(0,$.jsx)(s,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Close`})]}),t[14]=r,t[15]=g),t[16]===g?p=t[17]:(p=(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[h,g]}),t[16]=g,t[17]=p);let _;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(_=U(J.compact,`flex items-center justify-between text-muted-foreground`),t[18]=_):_=t[18];let v;t[19]===c?v=t[20]:(v=(0,$.jsxs)(`span`,{children:[c,`% Full`]}),t[19]=c,t[20]=v);let y;t[21]===a?y=t[22]:(y=Fc(a),t[21]=a,t[22]=y);let b;t[23]===o?b=t[24]:(b=Ic(o),t[23]=o,t[24]=b);let x;t[25]!==y||t[26]!==b?(x=(0,$.jsxs)(`span`,{children:[`~`,y,` / `,b,` Tokens`]}),t[25]=y,t[26]=b,t[27]=x):x=t[27],t[28]!==v||t[29]!==x?(m=(0,$.jsxs)(`div`,{className:_,children:[v,x]}),t[28]=v,t[29]=x,t[30]=m):m=t[30],d=`h-2 w-full overflow-hidden rounded-full bg-muted/60`,l=`flex h-full w-full`;let S;t[31]!==i||t[32]!==o?(S=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[31]=i,t[32]=o,t[33]=S):S=t[33],u=n.map(S),t[0]=i,t[1]=o,t[2]=r,t[3]=c,t[4]=a,t[5]=l,t[6]=u,t[7]=d,t[8]=f,t[9]=p,t[10]=m}else l=t[5],u=t[6],d=t[7],f=t[8],p=t[9],m=t[10];let h;t[34]!==l||t[35]!==u?(h=(0,$.jsx)(`div`,{className:l,children:u}),t[34]=l,t[35]=u,t[36]=h):h=t[36];let g;t[37]!==d||t[38]!==h?(g=(0,$.jsx)(`div`,{className:d,children:h}),t[37]=d,t[38]=h,t[39]=g):g=t[39];let _;t[40]===i?_=t[41]:(_=Pc.map(e=>(0,$.jsxs)(`div`,{className:U(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:Fc(i[e.key])})]},e.key)),t[40]=i,t[41]=_);let v;t[42]===_?v=t[43]:(v=(0,$.jsx)(`div`,{className:`space-y-1.5`,children:_}),t[42]=_,t[43]=v);let y;return t[44]!==v||t[45]!==f||t[46]!==p||t[47]!==m||t[48]!==g?(y=(0,$.jsxs)(`div`,{className:f,children:[p,m,g,v]}),t[44]=v,t[45]=f,t[46]=p,t[47]=m,t[48]=g,t[49]=y):y=t[49],y}function Rc({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 se(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)(eo,{open:d,onOpenChange:f,children:[(0,$.jsx)(to,{asChild:!0,children:i}),(0,$.jsxs)(no,{side:`top`,align:`end`,className:`w-auto p-4`,children:[s&&(0,$.jsxs)(`div`,{className:U(J.compact,`flex w-72 items-center gap-2 text-muted-foreground`),children:[(0,$.jsx)(bt,{className:`h-3 w-3 animate-pulse`}),(0,$.jsx)(`span`,{children:`Loading context...`})]}),l&&!s&&(0,$.jsxs)(`div`,{className:U(J.compact,`flex w-72 items-center gap-2 text-muted-foreground`),children:[(0,$.jsx)(bt,{className:`h-3 w-3`}),(0,$.jsx)(`span`,{children:l})]}),!s&&!l&&a&&(0,$.jsx)(Lc,{breakdown:a,onClose:()=>f(!1)})]})]})}function zc(e){return e.filter(e=>e.sender===`agent`).length}function Bc(e){return e>75?`text-red-500`:e>50?`text-orange-500`:`text-muted-foreground`}function Vc(e){let t=(0,X.c)(8),{percentage:n}=e,r=2*Math.PI*7,i=r*(1-Math.min(n,100)/100),a;t[0]===n?a=t[1]:(a=Bc(n),t[0]=n,t[1]=a);let o=`h-4 w-4 ${a}`,s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(`circle`,{className:`text-muted-foreground/25`,cx:`10`,cy:`10`,r:7,fill:`none`,stroke:`currentColor`,strokeWidth:`3`}),t[2]=s):s=t[2];let c;t[3]===i?c=t[4]:(c=(0,$.jsx)(`circle`,{cx:`10`,cy:`10`,r:7,fill:`none`,stroke:`currentColor`,strokeWidth:`3`,strokeLinecap:`round`,strokeDasharray:r,strokeDashoffset:i,transform:`rotate(-90 10 10)`}),t[3]=i,t[4]=c);let l;return t[5]!==o||t[6]!==c?(l=(0,$.jsxs)(`svg`,{className:o,viewBox:`0 0 20 20`,"aria-hidden":`true`,children:[s,c]}),t[5]=o,t[6]=c,t[7]=l):l=t[7],l}function Hc(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=zc(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 v(n)).currentConversationId;if(s(e),!e){l(void 0);return}l(await se(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)(Vc,{percentage:m}):(0,$.jsx)(T,{className:`h-4 w-4`}),t[9]=m,t[10]=h,t[11]=_):_=t[11];let y;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(`span`,{className:`sr-only`,children:`View token usage`}),t[12]=y):y=t[12];let b;t[13]===_?b=t[14]:(b=(0,$.jsxs)(G,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground hover:text-background`,children:[_,y]}),t[13]=_,t[14]=b);let x;return t[15]!==c||t[16]!==o||t[17]!==g||t[18]!==b||t[19]!==n?(x=(0,$.jsx)(Rc,{threadId:n,currentConversationId:o,initialBreakdown:c,refreshKey:g,children:b}),t[15]=c,t[16]=o,t[17]=g,t[18]=b,t[19]=n,t[20]=x):x=t[20],x}var Uc=`[gitops-timing]`;function Wc(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(`${Uc} ${e} step=${n} ${r}ms`)}}function i(n,r,i){t.push({step:n,ms:r}),console.log(`${Uc} ${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(`${Uc} ${e} summary total=${i}ms slowest=${a.step}@${a.ms}ms breakdown=[${o}]${r?` ${r}`:``}`)}return{step:r,record:i,summary:a}}var Gc=3e4,Kc={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},qc=new Map,Jc=new Map;function Yc(e,t){let n=qc.get(e);if(n)for(let e of n)e(t)}function Xc(e,t){let n=qc.get(e);return n||(n=new Set,qc.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&qc.delete(e)}}function Zc(e){return`unified-git-status-${e}`}function Qc(e){return h.getSync(Zc(e))}function $c(e){let[t,n]=(0,Y.useState)(Kc),[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 u=(0,Y.useCallback)(async(t=!1)=>{if(!e)return;let n=++o.current,r=Wc(`hook fetch thread=${e} force=${t}`),a=setTimeout(()=>{o.current===n&&i(!0)},100);try{let i=Zc(e),a=performance.now(),c=Qc(e);r.record(`local-cache-check`,Math.round(performance.now()-a),`result=${c?`hit`:`miss`}`),t&&(h.invalidate(i),r.record(`invalidate-local-cache`,0));let u=await r.step(`ttl-cache-get`,()=>h.get(i,()=>l(e,t,!1),Gc));if(o.current!==n){r.summary(`stale-request`);return}await r.step(`update-state`,async()=>{s(u),Yc(e,u)}),r.summary(`branch=${u.currentBranch} changes=${u.changedFilesCount} prExists=${u.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]),d=(0,Y.useRef)(u);return d.current=u,(0,Y.useEffect)(()=>{if(e)return Xc(e,e=>{c.current(e)})},[e]),(0,Y.useEffect)(()=>{if(!e)return;let t=e;function n(){document.visibilityState===`visible`&&(h.invalidate(Zc(t)),d.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(Kc)});return}let t=a.current!==e,r=Qc(e);t&&(console.log(`[gitops-timing] hook thread changed ${a.current??`none`} -> ${e}`),a.current=e,h.invalidate(Zc(e))),(0,Y.startTransition)(()=>{n(r??Kc)}),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 u(){if(l)return;let e=Jc.get(s);if(e){console.log(`[gitops-timing] hook initial fetch already in flight thread=${s}`),e.then(()=>{if(l)return;let e=Qc(s);e&&c.current(e)});return}console.log(`[gitops-timing] hook starting initial fetch thread=${s}`);let t=d.current(!1).finally(()=>{console.log(`[gitops-timing] hook initial fetch settled thread=${s}`),Jc.delete(s)});Jc.set(s,t)}return u(),()=>{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:u}}var el=(0,Y.createContext)(void 0);function tl(e){let t=(0,X.c)(8),{threadId:n,fetchUnifiedStatus:r}=e,i=di(),a=Q(il),o=Q(rl),s=Q(nl),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 nl(e){return e.selectedThreadId}function rl(e){return e.completedThreadIds}function il(e){return e.isStreaming}function al(e){let t=(0,X.c)(7),{threadId:n,children:r}=e,i=$c(n),a;t[0]!==n||t[1]!==i.fetchUnifiedStatus?(a=(0,$.jsx)(tl,{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)(el.Provider,{value:i,children:[a,r]}),t[3]=r,t[4]=a,t[5]=i,t[6]=o):o=t[6],o}function ol(){let e=(0,Y.useContext)(el);if(e===void 0)throw Error(`useGitStatus must be used within a GitStatusProvider`);return e}var sl=`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 cl(){return sl[Math.floor(Math.random()*sl.length)]??`branch`}function ll(){let e=cl(),t=cl();for(;t===e;)t=cl();return`${e}-${t}`}function ul(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),[l,u]=(0,Y.useState)(``),[d,f]=(0,Y.useState)(!1),[p,m]=(0,Y.useState)(`main`),h=ol();(0,Y.useEffect)(()=>{if(!s){u(``);return}u(ll())},[s]),(0,Y.useEffect)(()=>{h.defaultBranch&&m(h.defaultBranch)},[h.defaultBranch]);async function g(){if(!(!e||r)){i(!0);try{n((await R(e)).branches)}catch{n([])}finally{i(!1)}}}async function _(t){if(!(!e||t===h.currentBranch)){o(!0);try{await ee(e,t),await h.fetchUnifiedStatus(!0),Oi({title:`Switched to branch "${t}"`})}catch(e){Oi({title:`Failed to switch branch`,description:e instanceof Error?e.message:String(e),variant:`destructive`})}finally{o(!1)}}}function v(){c(!0)}async function y(){if(!(!e||!l.trim()||d)){f(!0);try{let t=await oe(e,p,l);c(!1),await g(),await h.fetchUnifiedStatus(!0),Oi({title:`Branch created`,description:`Created branch "${t.branchName}" from ${p}`})}catch(e){Oi({title:`Failed to create branch`,description:e instanceof Error?e.message:String(e),variant:`destructive`})}finally{f(!1)}}}return{currentBranch:h.currentBranch,availableBranches:t,isLoadingBranches:r,isCheckingOut:a,loadBranches:g,checkoutBranch:_,fetchUnifiedStatus:h.fetchUnifiedStatus,isCreateDialogOpen:s,setIsCreateDialogOpen:c,newBranchName:l,setNewBranchName:u,isCreatingBranch:d,createBranch:y,openCreateBranchDialog:v,defaultBranch:p}}function dl({threadId:e,messages:t=[]}){let[r,i]=(0,Y.useState)(!1),[a,o]=(0,Y.useState)(null),s=ul(e);return(0,Y.useEffect)(()=>{e&&n(e).then(o).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)(jc,{currentBranch:s.currentBranch,availableBranches:s.availableBranches,isLoadingBranches:s.isLoadingBranches,isCheckingOut:s.isCheckingOut,onLoadBranches:s.loadBranches,onCheckoutBranch:s.checkoutBranch,onCreateBranch:s.openCreateBranchDialog}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Nc,{collapsed:!1}),(0,$.jsx)(Hc,{threadId:e,messages:t}),e&&(0,$.jsxs)(q,{children:[(0,$.jsx)(K,{asChild:!0,children:(0,$.jsx)(G,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground hover:text-background`,onClick:async()=>{if(!(!e||r)){i(!0);try{let t=await n(e);await navigator.clipboard.writeText(t)}finally{i(!1)}}},disabled:r,"aria-label":`Copy repository folder path`,children:(0,$.jsx)(H,{className:`h-4 w-4`})})}),(0,$.jsxs)(W,{side:`top`,className:`bg-slate-900 text-white`,children:[(0,$.jsx)(`div`,{children:`Copy repository folder path`}),a&&(0,$.jsx)(`div`,{className:U(J.compact,`opacity-70`),children:a})]})]})]})]}),(0,$.jsx)(Mc,{open:s.isCreateDialogOpen,onOpenChange:s.setIsCreateDialogOpen,branchName:s.newBranchName,onBranchNameChange:s.setNewBranchName,isLoading:s.isCreatingBranch,onCreateBranch:()=>void s.createBranch()})]})}var fl=40,pl=4,ml=10,hl=2*Math.PI*ml;function gl(e){let t=(0,X.c)(13),{todos:n}=e,r;t[0]===n?r=t[1]:(r=n.filter(vl),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(_l),t[4]=n,t[5]=o);let s;t[6]!==i||t[7]!==n.length?(s=n.length>0&&(0,$.jsxs)(`p`,{className:U(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 _l(e){return(0,$.jsxs)(`div`,{className:U(J.caption,`flex items-start gap-2`),children:[e.status===`done`?(0,$.jsx)(Re,{className:`h-4 w-4 shrink-0 mt-0.5 text-brand`}):e.status===`working`?(0,$.jsx)(O,{className:`h-4 w-4 shrink-0 mt-0.5 text-yellow-500`}):(0,$.jsx)(Fe,{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 vl(e){return e.status===`done`}function yl(e){let t=(0,X.c)(3),{completedCount:n,totalCount:r}=e,i=hl*(1-(r>0?n/r:0)),a=fl/2,o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(`circle`,{cx:a,cy:a,r:ml,fill:`none`,stroke:`currentColor`,strokeOpacity:`0.2`,strokeWidth:pl}),t[0]=o):o=t[0];let s;return t[1]===i?s=t[2]:(s=(0,$.jsxs)(`svg`,{"aria-hidden":`true`,width:fl,height:fl,viewBox:`0 0 ${fl} ${fl}`,className:`size-10 shrink-0`,children:[o,(0,$.jsx)(`circle`,{cx:a,cy:a,r:ml,fill:`none`,stroke:`currentColor`,strokeWidth:pl,strokeDasharray:hl,strokeDashoffset:i,strokeLinecap:`round`,transform:`rotate(-90 ${a} ${a})`,className:`transition-[stroke-dashoffset] duration-300 ease-out`})]}),t[1]=i,t[2]=s),s}function bl(e){let t=(0,X.c)(43),{layout:n}=e,r=n===void 0?`bar`:n,{todos:i}=(0,Y.useContext)(ho),[a,o]=(0,Y.useState)(!1),s;t[0]===i?s=t[1]:(s=i.filter(xl),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)(yl,{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)(G,{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)(xe,{children:(0,$.jsx)(_,{children:`Agent Todos`})}),t[11]=l):l=t[11];let d;t[12]===i?d=t[13]:(d=(0,$.jsxs)(ge,{className:`max-w-md`,children:[l,(0,$.jsx)(gl,{todos:i})]}),t[12]=i,t[13]=d);let f;t[14]!==a||t[15]!==d?(f=(0,$.jsx)(mn,{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)(yl,{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)(K,{asChild:!0,children:(0,$.jsxs)(G,{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 h;t[29]===u?h=t[30]:(h=(0,$.jsx)(W,{children:u}),t[29]=u,t[30]=h);let g;t[31]!==m||t[32]!==h?(g=(0,$.jsx)(Ke,{children:(0,$.jsxs)(q,{children:[m,h]})}),t[31]=m,t[32]=h,t[33]=g):g=t[33];let v;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(xe,{children:(0,$.jsx)(_,{children:`Agent Todos`})}),t[34]=v):v=t[34];let y;t[35]===i?y=t[36]:(y=(0,$.jsxs)(ge,{className:`max-w-md`,children:[v,(0,$.jsx)(gl,{todos:i})]}),t[35]=i,t[36]=y);let b;t[37]!==a||t[38]!==y?(b=(0,$.jsx)(mn,{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]!==g?(x=(0,$.jsxs)($.Fragment,{children:[g,b]}),t[40]=b,t[41]=g,t[42]=x):x=t[42],x}function xl(e){return e.status===`done`}function Sl(e){let t=(0,X.c)(30),{tasks:n,disabled:i,onSelectTask:a,onRemoveTask:o,layout:c}=e,l=i===void 0?!1:i,u=c===void 0?`bar`:c,[d,f]=(0,Y.useState)(!1),p=n.length,m=`${p} Pending ${p===1?`Task`:`Tasks`}`;if(p===0)return null;let h;t[0]===a?h=t[1]:(h=function(e){a(e),f(!1)},t[0]=a,t[1]=h);let g=h,_;t[2]!==o||t[3]!==p?(_=function(e){o(e),p===1&&f(!1)},t[2]=o,t[3]=p,t[4]=_):_=t[4];let v=_,y=u===`menu`?`ghost`:`outline`,b=u===`bar`&&`bg-background`,x=u===`menu`&&`w-full justify-start`,S;t[5]!==b||t[6]!==x?(S=U(`gap-2`,b,x),t[5]=b,t[6]=x,t[7]=S):S=t[7];let C;t[8]===m?C=t[9]:(C=(0,$.jsx)(`span`,{children:m}),t[8]=m,t[9]=C);let w;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(r,{className:`h-4 w-4 shrink-0`}),t[10]=w):w=t[10];let T;t[11]!==l||t[12]!==y||t[13]!==S||t[14]!==C?(T=(0,$.jsx)(to,{asChild:!0,children:(0,$.jsxs)(G,{variant:y,size:`sm`,className:S,disabled:l,children:[C,w]})}),t[11]=l,t[12]=y,t[13]=S,t[14]=C,t[15]=T):T=t[15];let E;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,$.jsx)(`div`,{className:U(J.compact,J.label,`px-2 pb-1 pt-1 text-muted-foreground`),children:`Tasks`}),t[16]=E):E=t[16];let D;if(t[17]!==v||t[18]!==g||t[19]!==n){let e;t[21]!==v||t[22]!==g?(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:()=>g(e),children:[(0,$.jsx)(Ne,{className:`mt-0.5 h-4 w-4 shrink-0 text-muted-foreground`}),(0,$.jsx)(`span`,{className:U(J.body,`line-clamp-3 text-foreground`),children:e.content})]}),(0,$.jsxs)(G,{type:`button`,variant:`ghost`,size:`icon`,className:`h-7 w-7 shrink-0`,onClick:()=>v(e.id),children:[(0,$.jsx)(s,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Remove task`})]})]},e.id),t[21]=v,t[22]=g,t[23]=e):e=t[23],D=n.map(e),t[17]=v,t[18]=g,t[19]=n,t[20]=D}else D=t[20];let O;t[24]===D?O=t[25]:(O=(0,$.jsx)(no,{align:`start`,className:`w-96 p-2`,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[E,D]})}),t[24]=D,t[25]=O);let k;return t[26]!==d||t[27]!==T||t[28]!==O?(k=(0,$.jsxs)(eo,{open:d,onOpenChange:f,children:[T,O]}),t[26]=d,t[27]=T,t[28]=O,t[29]=k):k=t[29],k}var Cl=(0,Y.createContext)(void 0);function wl(e){let t=(0,X.c)(24),{children:n}=e,r=di(),i=Q(Ol),a=Q(Dl),o=Q(El),s=Q(Tl),{toast:c}=ki(),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 St(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 Lt(i);r({type:Z.ClearMessages}),console.log(`New conversation started:`,e),setTimeout(()=>{(async()=>{try{let e=await Le(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 y(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 b=v,x;t[11]!==r||t[12]!==i?(x=function(e){i&&r({type:Z.SetChatInputDraft,threadId:i,draft:e.content})},t[11]=r,t[12]=i,t[13]=x):x=t[13];let S=x,C;t[14]!==p||t[15]!==_||t[16]!==b||t[17]!==S||t[18]!==a||t[19]!==u?(C={userTasks:u,setUserTasks:d,handleNewChat:_,handleSelectUserTask:S,handleRemoveUserTask:b,effectiveIsStreaming:p,isCreatingProject:a},t[14]=p,t[15]=_,t[16]=b,t[17]=S,t[18]=a,t[19]=u,t[20]=C):C=t[20];let w;return t[21]!==n||t[22]!==C?(w=(0,$.jsx)(Cl.Provider,{value:C,children:n}),t[21]=n,t[22]=C,t[23]=w):w=t[23],w}function Tl(e){return e.pendingChatMessage}function El(e){return e.isStreaming}function Dl(e){return e.isCreatingProject}function Ol(e){return e.selectedThreadId}function kl(){let e=(0,Y.useContext)(Cl);if(e===void 0)throw Error(`useChatInputToolbar must be used within a ChatInputToolbarProvider`);return e}function Al({workspaceEntries:e,hasMultipleWorkspaces:t,runningScripts:n,onScriptClick:r}){return t?e.map(([e,t])=>(0,$.jsxs)(Po,{children:[(0,$.jsx)(Fo,{children:e}),(0,$.jsx)(Io,{className:`max-h-[min(400px,80vh)] overflow-y-auto`,children:t.map(e=>(0,$.jsxs)(Ro,{onClick:()=>{r(e)},className:`gap-2`,children:[n.has(e.name)?(0,$.jsx)(_n,{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)(Ro,{onClick:()=>{r(e)},className:`gap-2`,children:[n.has(e.name)?(0,$.jsx)(_n,{className:`h-3 w-3 animate-spin shrink-0`}):(0,$.jsx)(`div`,{className:`h-3 w-3 shrink-0`}),e.friendlyName]},e.name))}function jl({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)(_n,{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)(_n,{className:`h-3 w-3 animate-spin shrink-0`}):(0,$.jsx)(`div`,{className:`h-3 w-3 shrink-0`}),e.friendlyName]},e.name))}function Ml({threadId:e,layout:t=`bar`}){let n=di(),{setTerminalNotification:r}=fa(),[a,o]=(0,Y.useState)(null),[s,c]=(0,Y.useState)(new Set),l=(0,Y.useRef)(new Map);(0,Y.useEffect)(()=>((async()=>{try{let t=await We(e);if(t.length===0){o(null);return}o(t),c(new Set(t.filter(e=>e.isRunning).map(e=>e.name)))}catch{o(null)}})(),()=>{for(let e of l.current.values())e.abort();l.current.clear()}),[e]);let u=async t=>{if(s.has(t.name)){let r=l.current.get(t.name);r&&(r.abort(),l.current.delete(t.name));try{await it(e,t.name)}catch{}n({type:Z.AppendTerminalLine,threadId:e,line:{type:`system`,content:`■ ${t.friendlyName} stopped`}}),c(e=>{let n=new Set(e);return n.delete(t.name),n})}else{let a=new AbortController;l.current.set(t.name,a),c(e=>new Set([...e,t.name])),r(!0),n({type:Z.AppendTerminalLine,threadId:e,line:{type:`system`,content:`▶ ${t.friendlyName}`}});try{let r=await i(e,t.name,t.command,{signal:a.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{l.current.delete(t.name),c(e=>{let n=new Set(e);return n.delete(t.name),n})}}};if(!a)return null;let d=a.reduce((e,t)=>(e[t.workspace]||(e[t.workspace]=[]),e[t.workspace].push(t),e),{}),f=Object.entries(d).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>[e,[...t].sort((e,t)=>e.friendlyName.localeCompare(t.friendlyName))]),p=f.length>1;function m(e){u(e)}return t===`menu`?(0,$.jsxs)(eo,{children:[(0,$.jsx)(to,{asChild:!0,children:(0,$.jsxs)(G,{variant:`ghost`,size:`sm`,className:`w-full justify-start gap-2`,children:[(0,$.jsx)(ce,{className:`h-4 w-4 shrink-0`}),`Project Scripts`]})}),(0,$.jsx)(no,{align:`start`,className:`w-56 p-1`,children:(0,$.jsx)(jl,{workspaceEntries:f,hasMultipleWorkspaces:p,runningScripts:s,onScriptClick:m})})]}):(0,$.jsxs)(Mo,{children:[(0,$.jsx)(Ke,{children:(0,$.jsxs)(q,{children:[(0,$.jsx)(K,{asChild:!0,children:(0,$.jsx)(No,{asChild:!0,children:(0,$.jsx)(G,{variant:`action`,size:`icon-md`,children:(0,$.jsx)(ce,{})})})}),(0,$.jsx)(W,{children:`Project Scripts`})]})}),(0,$.jsx)(Lo,{align:`end`,className:`min-w-[180px]`,children:(0,$.jsx)(Al,{workspaceEntries:f,hasMultipleWorkspaces:p,runningScripts:s,onScriptClick:m})})]})}var Nl=`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 Pl({open:e,onOpenChange:t,projectId:n,commands:r,onRefresh:i}){let[a,o]=(0,Y.useState)(null),[c,l]=(0,Y.useState)(!1),[u,d]=(0,Y.useState)(!1),[p,m]=(0,Y.useState)([]),[h,g]=(0,Y.useState)(0),[v,y]=(0,Y.useState)(!1),b=(0,Y.useRef)(null),x=(0,Y.useRef)(null),S=()=>{o({id:crypto.randomUUID(),name:``,icon:`Play`,commandLine:``}),d(!1),m([])},C=e=>{o({...e}),d(!1),m([])},w=async()=>{try{y(!0);let e=await $t(n);m(e.scripts),g(0),d(e.scripts.length>0)}catch(e){console.error(`Failed to load package scripts:`,e),Oi({title:`Error`,description:`Failed to load package scripts`,variant:`destructive`})}finally{y(!1)}},T=e=>{o(t=>t?{...t,name:e.name,commandLine:e.commandLine,relativeFolder:e.relativePath||``}:null),d(!1),m([]),b.current?.focus()},E=e=>{u&&(e.key===`ArrowDown`?(e.preventDefault(),g(e=>e<p.length-1?e+1:e)):e.key===`ArrowUp`?(e.preventDefault(),g(e=>e>0?e-1:0)):e.key===`Enter`?(e.preventDefault(),h<p.length&&T(p[h])):e.key===`Escape`&&(e.preventDefault(),d(!1),m([])))};(0,Y.useEffect)(()=>{let e=e=>{x.current&&!x.current.contains(e.target)&&(d(!1),m([]))};return u&&document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[u]);let D=async e=>{try{await V(n,e),Oi({title:`Success`,description:`Command deleted`}),i()}catch{Oi({title:`Error`,description:`Failed to delete command`,variant:`destructive`})}};return(0,$.jsx)(mn,{open:e,onOpenChange:t,children:(0,$.jsxs)(ge,{className:`sm:max-w-[500px]`,children:[(0,$.jsxs)(xe,{children:[(0,$.jsx)(_,{children:`Project Commands`}),(0,$.jsx)(f,{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)(cn,{htmlFor:`name`,children:`Command Name`}),(0,$.jsx)(Xe,{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)(cn,{htmlFor:`commandLine`,children:`Command Line`}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(mi,{ref:b,id:`commandLine`,value:a.commandLine,onChange:e=>o({...a,commandLine:e.target.value}),onKeyDown:E,placeholder:`e.g. npm test`,className:`font-mono text-base min-h-[100px] resize-none pr-10`}),(0,$.jsx)(Ke,{children:(0,$.jsxs)(q,{children:[(0,$.jsx)(K,{asChild:!0,children:(0,$.jsx)(G,{type:`button`,variant:`ghost`,size:`icon`,className:`absolute right-2 top-2 h-6 w-6 text-muted-foreground transition-colors`,onClick:()=>void w(),disabled:v,children:(0,$.jsx)(Mt,{className:`h-4 w-4`})})}),(0,$.jsx)(W,{children:(0,$.jsx)(`p`,{children:`Discover package scripts`})})]})})]}),u&&(0,$.jsx)(`div`,{ref:x,className:`absolute bottom-full left-0 right-0 mb-2 max-h-60 overflow-y-auto rounded-lg border border-border bg-popover shadow-lg z-50`,children:(0,$.jsxs)(`div`,{className:`p-2`,children:[(0,$.jsxs)(`div`,{className:U(J.dropdownGroupHeading,`px-2 py-1.5 border-b border-border/50 mb-1 flex items-center gap-2`),children:[(0,$.jsx)(Mt,{className:`h-3 w-3`}),`Available Scripts `,v&&`(loading...)`]}),p.length>0?(()=>{let e={};p.forEach(t=>{e[t.relativePath]||(e[t.relativePath]=[]),e[t.relativePath].push(t)});let t=Object.keys(e).sort(),n=0;return t.map(t=>{let r=e[t].sort((e,t)=>e.name.localeCompare(t.name));return(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:U(J.dropdownGroupHeading,`px-3 py-1.5 text-muted-foreground/70 bg-muted/30`),children:t}),r.map(e=>{let t=n===h;return n++,(0,$.jsxs)(`button`,{type:`button`,className:U(`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:()=>T(e),onMouseEnter:()=>g(n-1),children:[(0,$.jsx)(`span`,{className:`font-medium`,children:e.name}),(0,$.jsx)(`span`,{className:U(J.caption,`font-mono`),children:e.commandLine})]},e.commandLine)})]},t)})})():(0,$.jsx)(`div`,{className:U(J.caption,`px-3 py-4 text-center`),children:v?`Loading scripts...`:`No package scripts found`})]})})]}),(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[(0,$.jsx)(cn,{htmlFor:`relativeFolder`,children:`Relative Folder`}),(0,$.jsx)(Xe,{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)(cn,{children:`Icon`}),(0,$.jsx)(Ke,{children:(0,$.jsx)(`div`,{className:`grid grid-cols-10 gap-1 p-2 bg-background rounded-md border border-border`,children:Nl.map(e=>{let t=re[e]||Me;return(0,$.jsxs)(q,{children:[(0,$.jsx)(K,{asChild:!0,children:(0,$.jsx)(G,{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)(W,{children:e})]},e)})})})]}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2 mt-2`,children:[(0,$.jsxs)(G,{variant:`ghost`,size:`sm`,onClick:()=>o(null),children:[(0,$.jsx)(s,{className:`h-4 w-4 mr-2`}),` Cancel`]}),(0,$.jsxs)(G,{size:`sm`,onClick:async()=>{if(!a?.name||!a?.commandLine){Oi({title:`Error`,description:`Name and Command Line are required`,variant:`destructive`});return}try{l(!0),await ot(n,a),Oi({title:`Success`,description:`Command saved`}),o(null),i()}catch{Oi({title:`Error`,description:`Failed to save command`,variant:`destructive`})}finally{l(!1)}},disabled:c,children:[(0,$.jsx)(qt,{className:`h-4 w-4 mr-2`}),` `,c?`Saving...`:`Save Command`]})]})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 max-h-[400px] overflow-y-auto pr-2`,children:[r.length===0&&(0,$.jsx)(`div`,{className:`text-center py-8 text-muted-foreground border-2 border-dashed rounded-lg`,children:`No commands defined yet.`}),r.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between p-3 rounded-md border border-border bg-card hover:bg-muted/50 cursor-pointer group transition-colors`,onClick:()=>C(e),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`div`,{className:`p-2 bg-muted rounded`,children:(0,$.jsx)(re[e.icon]||yt,{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:U(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)(G,{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(),D(e.id)},children:(0,$.jsx)(I,{className:`h-4 w-4`})})})]},e.id))]}),(0,$.jsxs)(G,{variant:`outline`,className:`w-full border-dashed`,onClick:S,children:[(0,$.jsx)(Kt,{className:`h-4 w-4 mr-2`}),` Add New Command`]})]})})]})})}function Fl(e){let t=(0,X.c)(36),{layout:n}=e,r=n===void 0?`bar`:n,i=Q(zl),a=Q(Rl),o=Q(Ll),s=Q(Il),{dispatch:c}=pi(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)(G,{variant:`ghost`,size:`sm`,className:`w-full justify-start gap-2`,onClick:()=>g({commandLine:e.commandLine,relativeFolder:e.relativeFolder}),disabled:s,children:[(0,$.jsx)(re[e.icon]||yt,{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)(k,{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)(G,{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)(Pl,{open:l,onOpenChange:u,projectId:i,commands:d,onRefresh:f})]});break bb0}p=`flex items-center gap-1`,m=d.length===0?(0,$.jsx)(Ke,{children:(0,$.jsxs)(q,{children:[(0,$.jsx)(K,{asChild:!0,children:(0,$.jsx)(G,{variant:`action`,size:`icon-md`,onClick:()=>u(!0),children:(0,$.jsx)(k,{})})}),(0,$.jsx)(W,{children:`Manage commands`})]})}):(0,$.jsx)($.Fragment,{children:(0,$.jsxs)(Ke,{children:[d.map(e=>(0,$.jsxs)(q,{children:[(0,$.jsx)(K,{asChild:!0,children:(0,$.jsx)(G,{variant:`action`,size:`icon-md`,onClick:()=>g({commandLine:e.commandLine,relativeFolder:e.relativeFolder}),disabled:s,children:(0,$.jsx)(re[e.icon]||yt,{})})}),(0,$.jsx)(W,{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)(q,{children:[(0,$.jsx)(K,{asChild:!0,children:(0,$.jsx)(G,{variant:`action`,size:`icon-md`,className:`ml-1`,onClick:()=>u(!0),children:(0,$.jsx)(k,{})})}),(0,$.jsx)(W,{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)(Pl,{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 Il(e){return e.isRunningCommand}function Ll(e){return e.projects}function Rl(e){return e.selectedThreadId}function zl(e){return e.selectedProjectId}var Bl=`VS Code`;function Vl(e){return e||ke(Bl)}var Hl={"VS Code":`vscode`,Antigravity:`antigravity`,Cursor:`cursor`,"Devin Desktop":`devin`,Windsurf:`windsurf`,Xcode:`xcode`,"Android Studio":`android-studio`,Kiro:`kiro`,Terminal:`terminal`};function Ul({projectId:e,threadId:t,openWith:n,layout:r=`bar`}){let[i,a]=(0,Y.useState)(!1),[o,s]=(0,Y.useState)([]),[c,l]=(0,Y.useState)(()=>Vl(n)),[u,d]=(0,Y.useState)(!0);(0,Y.useEffect)(()=>{(async()=>{try{let e=await je();s(e);let t=Vl(n);e.includes(t)?l(t):e.length>0&&l(e[0])}catch(e){console.error(`Failed to fetch available programs:`,e),s([Bl])}finally{d(!1)}})()},[]),(0,Y.useEffect)(()=>{if(n&&o.includes(n)){l(n);return}let e=ke(Bl);!n&&o.includes(e)&&l(e)},[n,o]);async function f(t){l(t),le(t),await he(e,t)}let p=async n=>{try{a(!0),await f(n),t?await j(t,n):await Gt(e,n),Oi({title:`Success`,description:`Opened project in ${n}`})}catch(e){console.error(`Failed to open project in ${n}:`,e);let t=`Failed to open project in ${n}`;if(e instanceof Error){let n=e;t=n.details?n.details:e.message}Oi({title:`Error`,description:t,variant:`destructive`})}finally{a(!1)}};async function m(e){try{await f(e)}catch(t){console.error(`Failed to save preferred IDE (${e}):`,t),Oi({title:`Error`,description:`Failed to save IDE preference`,variant:`destructive`})}}let h=async()=>{await p(c)};return u?(0,$.jsx)(G,{variant:`outline`,size:`sm`,className:`h-8`,disabled:!0,children:(0,$.jsx)(`div`,{className:`h-4 w-4 animate-pulse bg-muted rounded`})}):r===`menu`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(G,{variant:`ghost`,size:`sm`,className:`w-full justify-start gap-2`,disabled:i,onClick:()=>{h()},children:[(0,$.jsx)(`img`,{src:`/ide/${Hl[c]||Hl[Bl]}.svg`,alt:c,className:`h-4 w-4 shrink-0`}),`Open in `,c]}),(0,$.jsxs)(eo,{children:[(0,$.jsx)(to,{asChild:!0,children:(0,$.jsxs)(G,{variant:`ghost`,size:`sm`,className:`w-full justify-start gap-2`,children:[(0,$.jsx)(Mt,{className:`h-4 w-4 shrink-0`}),`Change IDE`]})}),(0,$.jsx)(no,{align:`start`,className:`w-56 p-1`,children:o.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:()=>{m(e)},disabled:i,children:[(0,$.jsx)(`img`,{src:`/ide/${Hl[e]||Hl[Bl]}.svg`,alt:e,className:`h-4 w-4 shrink-0`}),e]},e))})]})]}):(0,$.jsxs)(`div`,{className:`flex items-center gap-0`,children:[(0,$.jsxs)(q,{children:[(0,$.jsx)(K,{asChild:!0,children:(0,$.jsx)(G,{variant:`outline`,size:`sm`,className:`h-8 rounded-r-none border-r-0 border-transparent`,disabled:i,onClick:h,children:(0,$.jsx)(`img`,{src:`/ide/${Hl[c]||Hl[Bl]}.svg`,alt:c,className:`h-4 w-4`})})}),(0,$.jsx)(W,{children:`Open in ${c}`})]}),(0,$.jsxs)(Mo,{children:[(0,$.jsx)(No,{asChild:!0,children:(0,$.jsx)(G,{variant:`outline`,size:`sm`,className:`h-8 w-8 rounded-l-none px-1 border-transparent`,disabled:i,children:(0,$.jsx)(Mt,{className:`h-3.5 w-3.5`})})}),(0,$.jsx)(Lo,{align:`end`,children:o.map(e=>(0,$.jsxs)(Ro,{onClick:()=>void m(e),disabled:i,className:`flex items-center gap-2`,children:[(0,$.jsx)(`img`,{src:`/ide/${Hl[e]||Hl[Bl]}.svg`,alt:e,className:`h-4 w-4`}),e]},e))})]})]})}function Wl({projectId:e,runCommand:t,large:n,layout:r=`bar`}){let{dispatch:i}=pi(Q(e=>e.selectedThreadId)),{setDevServerUrl:a,devServerRunning:o,setDevServerRunning:s,devServerLoading:c,setDevServerLoading:l}=fa(),{startServer:u}=Ss(),d=(0,Y.useRef)(!1);(0,Y.useEffect)(()=>{(async()=>{try{s((await Ae(e)).isRunning)}catch{s(!1)}})()},[e]);let f=()=>{u({projectId:e,runCommand:t||``})},p=async()=>{d.current=!0,l(!0);try{await an(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}}),Oi({title:`Error`,description:t,variant:`destructive`})}finally{l(!1)}},m=!!t,h=c?`Starting...`:o?`Stop dev server`:`Start dev server`;return n?(0,$.jsxs)(`button`,{onClick:o?p:f,disabled:c||!o&&!m,className:`flex flex-col items-center gap-3 group disabled:opacity-40 disabled:cursor-not-allowed ${o?`text-orange-500`:`text-muted-foreground`}`,children:[c?(0,$.jsx)(_n,{className:`h-10 w-10 animate-spin`}):o?(0,$.jsx)(Ce,{className:`h-10 w-10 fill-current`}):(0,$.jsx)(yt,{className:`h-10 w-10 fill-current group-hover:text-foreground transition-colors`}),(0,$.jsx)(`span`,{className:U(J.body,`group-hover:text-foreground transition-colors`),children:h})]}):r===`menu`?(0,$.jsxs)(G,{variant:`ghost`,size:`sm`,className:U(`w-full justify-start gap-2`,o&&`text-orange-500`),onClick:o?p:f,disabled:c||!o&&!m,children:[c?(0,$.jsx)(_n,{className:`h-4 w-4 shrink-0 animate-spin`}):o?(0,$.jsx)(Ce,{className:`h-4 w-4 shrink-0 fill-current`}):(0,$.jsx)(yt,{className:`h-4 w-4 shrink-0`}),h]}):(0,$.jsx)($.Fragment,{children:(0,$.jsx)(Ke,{children:(0,$.jsxs)(q,{children:[(0,$.jsx)(K,{asChild:!0,children:(0,$.jsxs)(G,{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)(_n,{className:`h-4 w-4 animate-spin`}):o?(0,$.jsx)(Ce,{className:`h-4 w-4 fill-current`}):(0,$.jsx)(yt,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`sr-only`,children:o?`Stop dev server`:`Start dev server`})]})}),(0,$.jsx)(W,{children:o?`Stop dev server`:m?`Start dev server: ${t}`:`Set run command in project settings`})]})})})}var Gl=(0,Y.lazy)(()=>cr(()=>import(`./git-ops-button-BV9X3fo-.js`).then(e=>({default:e.GitOpsButton})),__vite__mapDeps([2,1,3,4,5])));function Kl(e){return e===`menu`?`w-full justify-start gap-2`:`gap-2`}function ql(e){let t=(0,X.c)(4),{threadId:n,projectId:r,messages:i,userTasks:a}=e,{hasChanges:o}=ol(),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 Jl(e){let t=(0,X.c)(60),{threadId:n,projectId:r,messages:i,userTasks:a,effectiveIsStreaming:s,isCreatingProject:c,onNewChat:l,onSelectUserTask:u,onRemoveUserTask:d,layout:f}=e,p=f===void 0?`bar`:f,{setActiveMainTab:m}=fa(),h;t[0]!==i||t[1]!==r||t[2]!==n||t[3]!==a?(h={threadId:n,projectId:r,messages:i,userTasks:a},t[0]=i,t[1]=r,t[2]=n,t[3]=a,t[4]=h):h=t[4];let{hasMessages:g,hasChanges:_,isVisible:v}=ql(h),{changedFilesCount:y}=ol(),b;t[5]===p?b=t[6]:(b=Kl(p),t[5]=p,t[6]=b);let x=b,S=Q(Yl),C;if(t[7]!==r||t[8]!==S){let e;t[10]===r?e=t[11]:(e=e=>e.projectId===r,t[10]=r,t[11]=e),C=S.find(e),t[7]=r,t[8]=S,t[9]=C}else C=t[9];let w=C,T=p===`menu`&&!!n&&!!r,E=g||_||a.length>0||!!(n&&r);if(!v)return null;let D=p===`bar`&&`absolute -top-12 left-0 z-10 ml-8 flex flex-wrap items-center gap-2`,O=p===`menu`&&`flex flex-col items-stretch gap-1 p-1 min-w-[220px]`,k;t[12]!==D||t[13]!==O?(k=U(D,O),t[12]=D,t[13]=O,t[14]=k):k=t[14];let A=p===`bar`?!0:void 0,j;t[15]!==g||t[16]!==p||t[17]!==l||t[18]!==x?(j=g&&(0,$.jsxs)(G,{variant:p===`menu`?`ghost`:`outline`,size:`sm`,className:x,onClick:l,children:[(0,$.jsx)(Kt,{className:`h-4 w-4 shrink-0`}),`New Chat`]}),t[15]=g,t[16]=p,t[17]=l,t[18]=x,t[19]=j):j=t[19];let M;t[20]!==y||t[21]!==_||t[22]!==p||t[23]!==m||t[24]!==x?(M=_&&(0,$.jsxs)(G,{variant:p===`menu`?`ghost`:`outline`,size:`sm`,className:x,onClick:()=>m(`review`),children:[(0,$.jsx)(o,{className:`h-4 w-4 shrink-0`}),y,` `,y===1?`File`:`Files`,` Changed`]}),t[20]=y,t[21]=_,t[22]=p,t[23]=m,t[24]=x,t[25]=M):M=t[25];let N;t[26]!==s||t[27]!==c||t[28]!==p||t[29]!==d||t[30]!==u||t[31]!==n||t[32]!==a?(N=a.length>0&&(0,$.jsx)(Sl,{tasks:a,disabled:s||!n&&!c,onSelectTask:u,onRemoveTask:d,layout:p}),t[26]=s,t[27]=c,t[28]=p,t[29]=d,t[30]=u,t[31]=n,t[32]=a,t[33]=N):N=t[33];let P;t[34]!==p||t[35]!==r||t[36]!==n?(P=n&&r&&(0,$.jsx)(Y.Suspense,{fallback:null,children:(0,$.jsx)(Gl,{projectId:r,threadId:n,layout:p},n)}),t[34]=p,t[35]=r,t[36]=n,t[37]=P):P=t[37];let F;t[38]!==g||t[39]!==p?(F=g&&(0,$.jsx)(bl,{layout:p}),t[38]=g,t[39]=p,t[40]=F):F=t[40];let I;t[41]!==E||t[42]!==T?(I=T&&E&&(0,$.jsx)(Ho,{className:`my-1`}),t[41]=E,t[42]=T,t[43]=I):I=t[43];let L;t[44]!==r||t[45]!==w?.openWith||t[46]!==w?.runCommand||t[47]!==T||t[48]!==n?(L=T&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Wl,{projectId:r,runCommand:w?.runCommand,layout:`menu`}),(0,$.jsx)(Ml,{threadId:n,layout:`menu`}),(0,$.jsx)(Fl,{layout:`menu`}),(0,$.jsx)(Ul,{projectId:r,threadId:n,openWith:w?.openWith,layout:`menu`})]}),t[44]=r,t[45]=w?.openWith,t[46]=w?.runCommand,t[47]=T,t[48]=n,t[49]=L):L=t[49];let R;return t[50]!==M||t[51]!==N||t[52]!==P||t[53]!==F||t[54]!==I||t[55]!==L||t[56]!==k||t[57]!==A||t[58]!==j?(R=(0,$.jsxs)(`div`,{className:k,"data-chat-toolbar":A,children:[j,M,N,P,F,I,L]}),t[50]=M,t[51]=N,t[52]=P,t[53]=F,t[54]=I,t[55]=L,t[56]=k,t[57]=A,t[58]=j,t[59]=R):R=t[59],R}function Yl(e){return e.projects}function Xl(e){let t=(0,X.c)(2),n;return t[0]===e?n=t[1]:(n=(0,$.jsx)(Jl,{...e}),t[0]=e,t[1]=n),n}function Zl(){let e=(0,X.c)(20),t=Q(eu),n=Q($l),r=Q(Ql),{userTasks:i,handleNewChat:a,handleSelectUserTask:o,handleRemoveUserTask:s,effectiveIsStreaming:c,isCreatingProject:l}=kl(),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}=ql(u);if(!t||!d)return null;let f;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(No,{asChild:!0,children:(0,$.jsxs)(G,{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)(Ue,{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)(Mo,{children:[f,(0,$.jsx)(Lo,{align:`end`,className:`electrobun-webkit-app-region-no-drag`,children:(0,$.jsx)(Jl,{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 Ql(e){return e.messages}function $l(e){return e.selectedProjectId}function eu(e){return e.selectedThreadId}function tu(e){let t=(0,X.c)(3),{threadId:n,children:r}=e,i;return t[0]!==r||t[1]!==n?(i=(0,$.jsx)(al,{threadId:n,children:r}),t[0]=r,t[1]=n,t[2]=i):i=t[2],i}var nu=new Set,ru=new Map,iu=5e3;function au(e){nu.add(e);let t=ru.get(e);t&&clearTimeout(t),ru.set(e,setTimeout(()=>{nu.delete(e),ru.delete(e)},iu))}function ou(e){return nu.has(e)}function su(e){return e.filter(e=>!nu.has(e))}function cu(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&&Qo(e.id,e.input.code,t)}catch{}}function lu(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`&&Pa(e.id,e.input.command)}catch{}}function uu(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`&&Fa(e.toolCallId)}catch{}}function du(e,t,n){let r={type:`thinking`,content:pu,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:qr([],`thinking`,r.content??``),threadId:t})}var fu=/^\/compact(?:\s+(.*))?$/i,pu=`[Compact] Compaction in progress...`;function mu(){let e=di(),{toast:t}=ki(),[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)||(au(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;au(t);let i=ei(r.segments)||`...`;if(r.error&&(r.segments.length===0||i===`...`)){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 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 Le(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)),Dt(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}),au(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=Ie(n,n=>{if(e({type:Z.IncrementStreamEventCount,threadId:t}),n.type===`error`){let e=n.content||`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=Yr(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=Xr(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=Zr(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??``;cu(r,t),u.assistantThinking+=r,u.segments=qr(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=Jr(u.segments,r),e({type:Z.SetStreamContent,content:r,threadId:t}),typeof r==`string`&&cu(r,t)}else{if(u.hasStructuredContent)return;let r=n.content??``;u.assistantMessage+=r,u.segments=qr(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=qr(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=Jr(u.segments,i),e({type:Z.SetStreamContent,content:i,threadId:t}),cu(i,t)):(u.assistantMessage+=i,u.segments=qr(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&&(lu(i),uu(i),u.assistantMessage+=i,u.segments=qr(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||ou(e)||x(e,t=>pt(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(fu);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();du(e,g,i);try{let r=await mt(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 gn(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&&(be(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 Oe(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=>Zt(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 hu(e){let t=(0,X.c)(10),{open:n,onClose:r}=e,i=Jn(),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)(mr,{children:`Balance empty`}),(0,$.jsx)(hr,{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)(gr,{children:(0,$.jsx)(G,{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)(_r,{open:n,onOpenChange:a,children:s}),t[6]=n,t[7]=a,t[8]=s,t[9]=c):c=t[9],c}function gu(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)(_u,{messages:i}),t[2]=i,t[3]=a),a}function _u(e){let t=(0,X.c)(41),{messages:n}=e,r=Q(bu),i=Q(yu),a=Q(vu),{handleSend:o,handleStop:s,queuedMessagesForThread:c,handleRemoveQueuedMessage:l,showEmptyBalanceDialog:u,setShowEmptyBalanceDialog:d}=mu(),{userTasks:f,setUserTasks:p,handleNewChat:m,handleSelectUserTask:h,handleRemoveUserTask:g,effectiveIsStreaming:_}=kl(),v;t[0]===d?v=t[1]:(v=()=>d(!1),t[0]=d,t[1]=v);let y;t[2]!==u||t[3]!==v?(y=(0,$.jsx)(hu,{open:u,onClose:v}),t[2]=u,t[3]=v,t[4]=y):y=t[4];let b;t[5]!==_||t[6]!==m||t[7]!==g||t[8]!==h||t[9]!==r||t[10]!==n||t[11]!==a||t[12]!==i||t[13]!==f?(b=i&&(a||n.length>0||f.length>0)&&(0,$.jsx)(`div`,{className:`max-md:hidden`,children:(0,$.jsx)(Xl,{threadId:i,projectId:a??``,messages:n,userTasks:f,effectiveIsStreaming:_,isCreatingProject:r,onNewChat:()=>{m()},onSelectUserTask:h,onRemoveUserTask:e=>{g(e)}})}),t[5]=_,t[6]=m,t[7]=g,t[8]=h,t[9]=r,t[10]=n,t[11]=a,t[12]=i,t[13]=f,t[14]=b):b=t[14];let x=!i&&!r,S;t[15]===g?S=t[16]:(S=e=>{g(e.id)},t[15]=g,t[16]=S);let C;t[17]===p?C=t[18]:(C=e=>{p(t=>[...t,e])},t[17]=p,t[18]=C);let w;t[19]!==_||t[20]!==l||t[21]!==o||t[22]!==s||t[23]!==c||t[24]!==x||t[25]!==S||t[26]!==C||t[27]!==f?(w=(0,$.jsx)(xc,{onSend:o,onStop:s,isStreaming:_,disabled:x,initialValue:``,queuedMessages:c,onRemoveQueuedMessage:l,isOverlay:!1,userTasks:f,onMatchedUserTaskSend:S,onUserTaskCreated:C}),t[19]=_,t[20]=l,t[21]=o,t[22]=s,t[23]=c,t[24]=x,t[25]=S,t[26]=C,t[27]=f,t[28]=w):w=t[28];let T;t[29]!==b||t[30]!==w?(T=(0,$.jsxs)(`div`,{className:`relative`,children:[b,w]}),t[29]=b,t[30]=w,t[31]=T):T=t[31];let E=i??void 0,D;t[32]!==n||t[33]!==E?(D=(0,$.jsx)(dl,{threadId:E,messages:n}),t[32]=n,t[33]=E,t[34]=D):D=t[34];let O;t[35]!==D||t[36]!==T?(O=(0,$.jsxs)(`div`,{className:`relative mx-auto min-w-[400px] w-[90vw] max-w-3xl`,children:[T,D]}),t[35]=D,t[36]=T,t[37]=O):O=t[37];let k;return t[38]!==O||t[39]!==y?(k=(0,$.jsxs)($.Fragment,{children:[y,O]}),t[38]=O,t[39]=y,t[40]=k):k=t[40],k}function vu(e){return e.selectedProjectId}function yu(e){return e.selectedThreadId}function bu(e){return e.isCreatingProject}function xu(){let e=(0,X.c)(7),t=di(),n=Q(Cu),r=Q(Su),i;e[0]!==t||e[1]!==n?(i=()=>{if(!n)return;let e=n,r=!1;return(async function(){try{let n=await Le(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 Su(e){return e.selectedProjectId}function Cu(e){return e.selectedThreadId}async function wu(e){return c(`api/projects/${wt(e)}/todos`)}async function Tu(e,t){return ae(`api/projects/${wt(e)}/todos`,{description:t})}async function Eu(e,t,n){return ne(`api/projects/${wt(e)}/todos/${wt(t)}`,n)}async function Du(e,t){await ie(`api/projects/${wt(e)}/todos/${wt(t)}`)}var Ou={Ready:[{label:`Plan`,target:`Plan`},{label:`Build`,target:`Build`}],Plan:[{label:`Build`,target:`Build`}],Build:[{label:`Test`,target:`Test`},{label:`Review`,target:`Review`}],Test:[{label:`Review`,target:`Review`}],Review:[{label:`Done`,target:`Done`}],Done:[]};function ku({todo:e,projectId:t,onUpdate:n,onEdit:r,onAction:i,onThreadSelect:a}){let[o,s]=(0,Y.useState)(!1),c=Ou[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 Eu(t,e.id,{status:a,working:a!==`Done`}))}finally{s(!1)}}return(0,$.jsxs)(`div`,{className:U(`rounded-lg border bg-card p-3 shadow-sm space-y-2 cursor-pointer hover:bg-accent/50 transition-colors`,e.working&&`border-primary/50 bg-primary/5`),onClick:t=>{t.stopPropagation(),r(e)},children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`p`,{className:U(J.label,`leading-tight`),children:e.title}),e.working&&(0,$.jsx)(_n,{className:`h-3 w-3 animate-spin text-primary shrink-0`})]}),(c.length>0||e.status!==`Ready`&&e.threadId&&a)&&(0,$.jsxs)(`div`,{className:`flex gap-1.5 flex-wrap items-center pt-1`,children:[c.map(t=>(0,$.jsxs)(q,{children:[(0,$.jsx)(K,{asChild:!0,children:(0,$.jsx)(G,{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)(W,{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)(q,{children:[(0,$.jsx)(K,{asChild:!0,children:(0,$.jsxs)(G,{size:`icon`,variant:`ghost`,className:`h-7 w-7 shrink-0 group-hover:flex items-center justify-center`,onClick:l,children:[(0,$.jsx)(Ee,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Open thread`})]})}),(0,$.jsx)(W,{side:`right`,children:`Open thread`})]})]})]})}var Au=`Please analyze this task and create a detailed implementation plan.
47
-
48
- Task description:
49
- {description}`,ju="\nWrite your complete plan to the file `{todoId}-plan.md` in the current directory.",Mu=`Act as a Quality Assurance Manager. Rephrase the task into a rigorous test case: {description}`,Nu=`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}`,Pu={plan:Au,test:Mu,review:Nu},Fu={plan:`planPrompt`,test:`testPrompt`,review:`reviewPrompt`};function Iu(e,t){let n=e?.[Fu[t]];return n&&n.trim()?n:Pu[t]}function Lu(e,t,n,r){let i=e.replace(/\{description\}/g,r);return t===`plan`&&(i+=ju.replace(/\{todoId\}/g,n)),i}var Ru=[`Ready`,`Plan`,`Build`,`Test`,`Review`,`Done`],zu={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 Bu(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 Vu(e){let t=e.getReader();try{for(;;){let{done:e}=await t.read();if(e)break}}catch{}}async function Hu(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 Uu(e){let t=await wu(e),n=t.filter(e=>e.threadId&&e.status!==`Done`),r=[...t];return await Promise.all(n.map(async t=>{try{await v(t.threadId)}catch(n){if(n instanceof Error&&n.message.includes(`not found`)){let n=await Eu(e,t.id,{status:`Done`}),i=r.findIndex(e=>e.id===t.id);i!==-1&&(r[i]=n)}}})),r}function Wu(e,t){return`project-todos:${e}:${t}`}function Gu({projectId:e,addOpen:t,onAddOpenChange:n,onThreadSelect:r,initialTodos:i}){let a=di(),o=Q(e=>e.selectedThreadId),s=Q(e=>e.projectModelSelections),l=Q(e=>e.projects),[u,d]=(0,Y.useState)(i),[f,p]=(0,Y.useState)(null),[m,h]=(0,Y.useState)(``),[g,y]=(0,Y.useState)(!1),[b,x]=(0,Y.useState)(!1),[S,C]=(0,Y.useState)(null),[w,T]=(0,Y.useState)(``),[E,D]=(0,Y.useState)(!1),[O,k]=(0,Y.useState)(!1);(0,Y.useEffect)(()=>{if(!u.some(e=>e.working))return;let t=setInterval(async()=>{try{let n=await wu(e);d(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&&h(``)},[t]);function A(e){h(e.description),p({todo:e})}function j(){p(null),h(``)}async function M(){if(m.trim()){y(!0);try{let t=await Tu(e,m);d(e=>[...e,t]),n(!1),h(``)}finally{y(!1)}}}async function N(){if(!(!m.trim()||!f)){y(!0);try{let t=await Eu(e,f.todo.id,{description:m});d(e=>e.map(e=>e.id===t.id?t:e)),j()}finally{y(!1)}}}async function P(){if(f){y(!0);try{await Du(e,f.todo.id),d(e=>e.filter(e=>e.id!==f.todo.id)),j()}finally{y(!1)}}}function F(e){d(t=>t.map(t=>t.id===e.id?e:t))}async function I(t){let n=o?s[o]:void 0,r=l.find(t=>t.projectId===e),i=r?.threads.find(e=>e.threadId===o),c=n?.id??i?.model,u=n?.provider??i?.modelProvider;if(!c||!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 d=await ln(e);if(!d)return;let f=null,p=await Bu(d,n=>{Eu(e,t.id,{status:`Plan`,working:!0,threadId:n}).then(e=>{f=e,F(e)})});if(!p)return;f||F(await Eu(e,t.id,{status:`Plan`,working:!0,threadId:p}));let m=n??{id:c,provider:u,name:c,description:``};a({type:Z.SetProjectModel,threadId:p,model:m}),be(p,{model:c,modelProvider:u});let h=await Zt(p,Lu(Iu(r,`plan`),`plan`,t.id,t.description),c,[],void 0,u);h&&Vu(h)}async function L(t){let n=await ln(e);if(!n)return;let r=null,i=await Bu(n,n=>{Eu(e,t.id,{status:`Build`,working:!0,threadId:n}).then(e=>{r=e,F(e)})});if(!i)return;r||F(await Eu(e,t.id,{status:`Build`,working:!0,threadId:i}));let o=await v(i),s=o.model,l=o.modelProvider;if(!s||!l)try{let t=(await c(`api/threads?projectId=${encodeURIComponent(e)}`)||[]).map(e=>{let t=e;return{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,l=t.modelProvider)}catch(e){console.error(`Failed to get project threads:`,e)}if(!s||!l)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:l,name:s,description:``}}),be(i,{model:s,modelProvider:l}),console.log(`Sending chat message with provider:`,i,t.description,l);let u=await Zt(i,t.description,s,[],void 0,l);u&&Vu(u)}async function R(t){try{let n=await ln(e);if(!n){x(!1),C(null);return}let r=null;if(r=await Bu(n,e=>{r=e}),!r){x(!1),C(null);return}let i=await v(r),a=i.model,o=i.modelProvider;if(!a||!o)try{let t=(await c(`api/threads?projectId=${encodeURIComponent(e)}`)||[]).map(e=>{let t=e;return{model:t.model??void 0,modelProvider:t.modelProvider??void 0}}).find(e=>e.model&&e.modelProvider);t&&(a=t.model,o=t.modelProvider)}catch(e){console.error(`Failed to get project threads:`,e)}if(!a||!o){B(e,r),x(!1),C(null);return}let s=Lu(Iu(l.find(t=>t.projectId===e),`test`),`test`,t.id,t.description),u=await Zt(r,s,a,[],void 0,o);u&&T(await Hu(u)),B(e,r)}catch(e){console.error(`Failed to generate test case:`,e),x(!1),C(null)}finally{D(!1)}}function z(e){C(e),T(``),D(!0),x(!0),R(e)}function ee(){x(!1),C(null),T(``)}async function te(){if(!S||!w.trim())return;let t=S,n=w;ee(),k(!0);try{let r=await ln(e);if(!r)return;let i=null,o=await Bu(r,n=>{Eu(e,t.id,{status:`Test`,working:!0,threadId:n}).then(e=>{i=e,F(e)})});if(!o)return;i||F(await Eu(e,t.id,{status:`Test`,working:!0,threadId:o}));let s=await v(o),l=s.model,u=s.modelProvider;if(!l||!u)try{let t=(await c(`api/threads?projectId=${encodeURIComponent(e)}`)||[]).map(e=>{let t=e;return{model:t.model??void 0,modelProvider:t.modelProvider??void 0}}).find(e=>e.model&&e.modelProvider);t&&(l=t.model,u=t.modelProvider)}catch(e){console.error(`Failed to get project threads:`,e)}if(!l||!u)throw Error(`No model configuration found. Please configure a model and provider for this project first.`);a({type:Z.SetProjectModel,threadId:o,model:{id:l,provider:u,name:l,description:``}}),be(o,{model:l,modelProvider:u});let d=await Zt(o,n,l,[],void 0,u);d&&Vu(d)}finally{k(!1)}}async function ne(t){let n=await ln(e);if(!n)return;let r=null,i=await Bu(n,n=>{Eu(e,t.id,{status:`Review`,working:!0,threadId:n}).then(e=>{r=e,F(e)})});if(!i)return;r||F(await Eu(e,t.id,{status:`Review`,working:!0,threadId:i}));let o=await v(i),s=o.model,u=o.modelProvider;if(!s||!u)try{let t=(await c(`api/threads?projectId=${encodeURIComponent(e)}`)||[]).map(e=>{let t=e;return{threadId:t.threadId??t.id,model:t.model??void 0,modelProvider:t.modelProvider??void 0}}).find(e=>e.model&&e.modelProvider);t&&(s=t.model,u=t.modelProvider)}catch(e){console.error(`Failed to get project threads:`,e)}if(!s||!u)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:u,name:s,description:``}}),be(i,{model:s,modelProvider:u});let d=await Zt(i,Lu(Iu(l.find(t=>t.projectId===e),`review`),`review`,t.id,t.description),s,[],void 0,u);d&&Vu(d)}async function V(t,n){n===`Plan`?await I(t):n===`Build`?await L(t):n===`Test`?z(t):n===`Review`?await ne(t):F(await Eu(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:Ru.map(t=>{let i=u.filter(e=>e.status===t),a=t===`Ready`;return(0,$.jsxs)(`div`,{className:U(`flex flex-col rounded-lg border border-t-4 bg-muted/30 min-w-[200px] w-[200px] shrink-0`,zu[t]),children:[(0,$.jsxs)(`div`,{className:`px-3 py-2 flex items-center justify-between`,children:[(0,$.jsx)(`h3`,{className:U(J.dropdownGroupHeading,`uppercase tracking-wide`),children:t}),(0,$.jsx)(`span`,{className:U(J.compact,`text-muted-foreground bg-muted rounded-full px-1.5 py-0.5`),children:i.length})]}),(0,$.jsx)(vt,{className:`flex-1 px-2 pb-2`,children:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[a&&(0,$.jsxs)(G,{variant:`outline`,size:`sm`,className:`w-full h-8 border-dashed text-muted-foreground hover:text-foreground`,onClick:()=>n(!0),children:[(0,$.jsx)(Kt,{className:`h-3 w-3 mr-1`}),`Add Task`]}),i.map(t=>(0,$.jsx)(ku,{todo:t,projectId:e,onUpdate:F,onEdit:A,onAction:V,onThreadSelect:r},t.id))]})})]},t)})}),(0,$.jsx)(mn,{open:t,onOpenChange:n,children:(0,$.jsxs)(ge,{className:`sm:max-w-2xl`,children:[(0,$.jsx)(xe,{children:(0,$.jsx)(_,{children:`Add Task`})}),(0,$.jsxs)(`div`,{className:`py-2`,children:[(0,$.jsx)(mi,{placeholder:`Describe what needs to be done...`,value:m,onChange:e=>h(e.target.value),rows:12,className:`resize-none text-base`,autoFocus:!0,onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&M()}}),(0,$.jsx)(`p`,{className:U(J.caption,`mt-1.5`),children:`A title will be generated automatically from your description.`})]}),(0,$.jsx)(un,{children:(0,$.jsx)(G,{onClick:()=>void M(),disabled:g||!m.trim(),children:g?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(_n,{className:`h-3 w-3 animate-spin mr-1`}),`Generating title...`]}):`Add`})})]})}),(0,$.jsx)(mn,{open:b,onOpenChange:e=>!e&&ee(),children:(0,$.jsxs)(ge,{className:`sm:max-w-2xl`,children:[(0,$.jsx)(xe,{children:(0,$.jsx)(_,{children:`Test Case`})}),(0,$.jsx)(`div`,{className:`py-2`,children:E?(0,$.jsxs)(`div`,{className:`flex items-center justify-center h-32 gap-2 text-muted-foreground`,children:[(0,$.jsx)(_n,{className:`h-4 w-4 animate-spin`}),(0,$.jsx)(`span`,{className:J.body,children:`Generating test case...`})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(mi,{value:w,onChange:e=>T(e.target.value),rows:12,className:`resize-none text-base`,autoFocus:!0}),(0,$.jsx)(`p`,{className:U(J.caption,`mt-1.5`),children:`Review or edit the test case before confirming.`})]})}),(0,$.jsxs)(un,{children:[(0,$.jsx)(G,{variant:`outline`,onClick:ee,disabled:E,children:`Cancel`}),(0,$.jsx)(G,{onClick:()=>void te(),disabled:E||!w.trim()||O,children:O?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(_n,{className:`h-3 w-3 animate-spin mr-1`}),`Starting...`]}):`Confirm`})]})]})}),(0,$.jsx)(mn,{open:f!==null,onOpenChange:e=>!e&&j(),children:(0,$.jsxs)(ge,{className:`sm:max-w-2xl`,children:[(0,$.jsx)(xe,{children:(0,$.jsx)(_,{children:`Edit Task`})}),(0,$.jsx)(`div`,{className:`py-2`,children:(0,$.jsx)(mi,{placeholder:`Describe what needs to be done...`,value:m,onChange:e=>h(e.target.value),rows:12,className:`resize-none text-base`,autoFocus:!0,onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&N()}})}),(0,$.jsxs)(un,{className:`gap-2 sm:gap-0`,children:[(0,$.jsx)(G,{variant:`destructive`,onClick:()=>void P(),disabled:g,className:`mr-auto`,children:`Delete`}),(0,$.jsx)(G,{onClick:()=>void N(),disabled:g||!m.trim(),children:g?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(_n,{className:`h-3 w-3 animate-spin mr-1`}),`Saving...`]}):`Save`})]})]})})]})}function Ku(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=Wu(r,n),t[4]=n,t[5]=r,t[6]=a):a=t[6];let o;t[7]===r?o=t[8]:(o=()=>Uu(r),t[7]=r,t[8]=o);let s=yr(a,o),c;return t[9]!==s||t[10]!==r||t[11]!==i?(c=(0,$.jsx)(Gu,{projectId:r,initialTodos:s,...i}),t[9]=s,t[10]=r,t[11]=i,t[12]=c):c=t[12],c}function qu(e){let t=(0,X.c)(11),[n,r]=(0,Y.useState)(0),i;t[0]!==n||t[1]!==e.projectId?(i=function(){wr(Wu(e.projectId,n)),r(Ju)},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)(Sr,{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)(Ku,{...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)(Cr,{fallbackTitle:`Failed to load tasks`,onRetry:a,children:c}),t[8]=a,t[9]=c,t[10]=l):l=t[10],l}function Ju(e){return e+1}var Yu=An,Xu=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=U(`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)(Dn,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});Xu.displayName=Dn.displayName;var Zu=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=U(`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)(Nn,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});Zu.displayName=Nn.displayName;var Qu=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=U(`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)(Ln,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});Qu.displayName=Ln.displayName;var $u=[{value:`plan`,label:`Plan`,field:`planPrompt`,defaultPrompt:Au},{value:`review`,label:`Code Review`,field:`reviewPrompt`,defaultPrompt:Nu},{value:`test`,label:`Test`,field:`testPrompt`,defaultPrompt:Mu}];function ed({open:e,onOpenChange:t,projectId:n}){let r=Q(e=>e.projects),[i,a]=(0,Y.useState)({plan:``,review:``,test:``}),[o,s]=(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 c(){s(!0);try{await Ye(n,{planPrompt:i.plan.trim()===Au?null:i.plan.trim()||null,testPrompt:i.test.trim()===Mu?null:i.test.trim()||null,reviewPrompt:i.review.trim()===Nu?null:i.review.trim()||null}),Te(),Oi({title:`AI prompt settings saved`}),t(!1)}catch(e){Oi({title:`Error`,description:e instanceof Error?e.message:`Failed to save prompt settings`,variant:`destructive`})}finally{s(!1)}}function l(e,t){a(n=>({...n,[e]:t}))}return(0,$.jsx)(mn,{open:e,onOpenChange:t,children:(0,$.jsxs)(ge,{className:`max-w-2xl`,children:[(0,$.jsxs)(xe,{children:[(0,$.jsx)(_,{children:`AI Prompt Settings`}),(0,$.jsx)(f,{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)(Yu,{defaultValue:`plan`,className:`w-full`,children:[(0,$.jsx)(Xu,{className:`w-full`,children:$u.map(e=>(0,$.jsx)(Zu,{value:e.value,className:`flex-1`,children:e.label},e.value))}),$u.map(e=>(0,$.jsxs)(Qu,{value:e.value,children:[(0,$.jsx)(mi,{value:i[e.value]||e.defaultPrompt,onChange:t=>l(e.value,t.target.value),className:`min-h-[250px] font-mono resize-none`,placeholder:e.defaultPrompt,disabled:o}),(0,$.jsxs)(`p`,{className:U(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)(un,{children:(0,$.jsx)(G,{onClick:()=>void c(),disabled:o,children:o?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(_n,{className:`mr-2 h-4 w-4 animate-spin`}),`Saving...`]}):`Save`})})]})})}var td=t({TodosView:()=>nd});function nd({projectId:e}){let t=di(),n=Q(e=>e.projects),r=Q(e=>e.selectedThreadId),i=Q(e=>e.selectedProjectId),[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(!1),l=Jn(),{setActiveMainTab:u}=fa();async function d(a){if(n.find(t=>t.projectId===e)){l(`/`),u(`chat`);try{let{getProjects:n,invalidateProjectsCache:o}=await cr(async()=>{let{getProjects:e,invalidateProjectsCache:t}=await import(`./dialogs-config-B4TDFSrS.js`).then(e=>e.l);return{getProjects:e,invalidateProjectsCache:t}},__vite__mapDeps([5,1]));o();let s=await n();t({type:Z.SetProjects,projects:s.projects});let c=s.projects.find(t=>t.projectId===e);if(c&&c.threads.find(e=>e.threadId===a)){(r!==a||i!==e)&&t({type:Z.SelectThread,threadId:a,projectId:e});try{let e=await Vt();t({type:Z.SetProcessingThreads,threadIds:e})}catch(e){console.error(`Failed to fetch processing threads after thread selection:`,e)}}}catch(n){console.error(`Failed to refresh projects for thread selection:`,n),(r!==a||i!==e)&&t({type:Z.SelectThread,threadId:a,projectId:e});try{let e=await Vt();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)(qu,{projectId:e,addOpen:a,onAddOpenChange:o,onThreadSelect:d})}),(0,$.jsx)(G,{variant:`outline`,size:`icon`,className:`absolute bottom-8 right-4`,onClick:()=>c(!0),children:(0,$.jsx)(Ut,{className:`h-4 w-4`})}),(0,$.jsx)(ed,{open:s,onOpenChange:c,projectId:e})]})}var rd=4,id=`(max-width: 767px)`;function ad(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(id).matches?rd:0)}function od(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(ad(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);return l.observe(i,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`class`,`style`,`hidden`]}),window.addEventListener(`resize`,o),()=>{s.disconnect(),l.disconnect(),window.removeEventListener(`resize`,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 sd=(0,Y.lazy)(()=>cr(()=>import(`./diff-view-DGfmGlB_.js`),__vite__mapDeps([6,1,3,4,7,5,8,9,10,11]))),cd=(0,Y.lazy)(()=>cr(()=>import(`./dialogs-config-B4TDFSrS.js`).then(e=>e.t),__vite__mapDeps([5,1])));function ld(e){let t=(0,X.c)(60),{onCreateThread:n}=e,r=di(),i=Jn(),a=rr(),[o,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(null),u=Q(Cd),d=Q(Sd),f=Q(xd),p=Q(bd),m=Q(yd),h=Q(vd),g=Q(_d),_=Q(gd),v=Q(hd),y=Q(md),b=Q(pd),x=Q(fd),S=Q(dd),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||t[4]!==x?(E=()=>{x&&r({type:Z.ToggleSidebar})},t[3]=r,t[4]=x,t[5]=E):E=t[5];let D=E,O;t[6]===D?O=t[7]:(O=()=>{D(),l(`clone`),s(!0)},t[6]=D,t[7]=O);let k=O,A;t[8]===D?A=t[9]:(A=()=>{D(),l(`webapp`),s(!0)},t[8]=D,t[9]=A);let j=A,M;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(M=async(e,t)=>{try{await dn(e,t),s(!1),l(null)}catch(e){console.error(`Failed to clone repository:`,e)}},t[10]=M):M=t[10];let N=M,F;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(F=async(e,t,n)=>{try{await pe(e,t,n),s(!1),l(null)}catch(e){console.error(`Failed to create project:`,e)}},t[11]=F):F=t[11];let I=F,L;t[12]===D?L=t[13]:(L=async()=>{D();try{await P(),s(!1),l(null)}catch(e){console.error(`Failed to open folder:`,e)}},t[12]=D,t[13]=L);let R=L,z;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(z=async e=>{try{await on(e),s(!1),l(null)}catch(e){console.error(`Failed to create folder:`,e)}},t[14]=z):z=t[14];let ee=z,B=a.pathname===`/review`,te=a.pathname===`/todos`,ne;t[15]===i?ne=t[16]:(ne=()=>{i(`/`)},t[15]=i,t[16]=ne);let V=ne;xu();let re;t[17]===x?re=t[18]:(re=Ns(x),t[17]=x,t[18]=re);let ie=re,H;t[19]===x?H=t[20]:(H=Ps(x),t[19]=x,t[20]=H);let ae=H,oe=(0,Y.useRef)(null),se=(0,Y.useRef)(null),ce=!B&&!te&&!!u,le=od(oe,se,ce),ue;t[21]!==le||t[22]!==D||t[23]!==r||t[24]!==k||t[25]!==V||t[26]!==j||t[27]!==R||t[28]!==T||t[29]!==f||t[30]!==w||t[31]!==_||t[32]!==d||t[33]!==g||t[34]!==n||t[35]!==m||t[36]!==h||t[37]!==B||t[38]!==S||t[39]!==u||t[40]!==y||t[41]!==v||t[42]!==te?(ue=te&&S?(0,$.jsx)(nd,{projectId:S}):B&&u?(0,$.jsx)(Y.Suspense,{fallback:(0,$.jsx)(Sr,{}),children:(0,$.jsx)(sd,{threadId:u,onExit:V})}):(0,$.jsx)(js,{bottomInset:le,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:R,error:null,onClearError:ud}),t[21]=le,t[22]=D,t[23]=r,t[24]=k,t[25]=V,t[26]=j,t[27]=R,t[28]=T,t[29]=f,t[30]=w,t[31]=_,t[32]=d,t[33]=g,t[34]=n,t[35]=m,t[36]=h,t[37]=B,t[38]=S,t[39]=u,t[40]=y,t[41]=v,t[42]=te,t[43]=ue):ue=t[43];let de;t[44]!==ie||t[45]!==ae||t[46]!==d||t[47]!==ce?(de=ce&&(0,$.jsxs)(`div`,{ref:se,className:`absolute bottom-0 left-0 right-0 z-10 pr-4`,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}}),(0,$.jsx)(`div`,{style:{backgroundImage:ie},children:(0,$.jsx)(gu,{messages:d})})]}),t[44]=ie,t[45]=ae,t[46]=d,t[47]=ce,t[48]=de):de=t[48];let fe=c??void 0,me;t[49]!==o||t[50]!==R||t[51]!==fe?(me=(0,$.jsx)(Y.Suspense,{fallback:null,children:(0,$.jsx)(cd,{open:o,onOpenChange:s,initialMode:fe,onSubmitClone:N,onSubmitWebApp:I,onSubmitFolder:ee,onOpenFolder:R})}),t[49]=o,t[50]=R,t[51]=fe,t[52]=me):me=t[52];let he;t[53]!==ue||t[54]!==de||t[55]!==me?(he=(0,$.jsxs)(`div`,{ref:oe,className:`relative flex h-full flex-col`,children:[ue,de,me]}),t[53]=ue,t[54]=de,t[55]=me,t[56]=he):he=t[56];let ge;return t[57]!==u||t[58]!==he?(ge=(0,$.jsx)(go,{threadId:u,children:he}),t[57]=u,t[58]=he,t[59]=ge):ge=t[59],ge}function ud(){}function dd(e){return e.selectedProjectId}function fd(e){return e.sidebarOpen}function pd(e){return e.pendingChatMessage}function md(e){return e.streamingModel}function hd(e){return e.streamingSegments}function gd(e){return e.isStreaming}function _d(e){return e.messagesLoaded}function vd(e){return e.projectsLoading}function yd(e){return e.projects}function bd(e){return e.processingThreadIds}function xd(e){return e.isCreatingProject}function Sd(e){return e.messages}function Cd(e){return e.selectedThreadId}function wd(e){let t=(0,X.c)(5),{children:n,className:r}=e,i;t[0]===r?i=t[1]:(i=U(`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 Td(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 Ed(){let e=(0,X.c)(42),t=di(),n=Q(Ad),r=Q(kd),i=Q(Od),a=Q(Dd),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=U(`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)(Et,{className:`h-4 w-4`}):(0,$.jsx)(Qe,{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)(G,{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:U(J.sectionTitle,`text-foreground truncate min-w-0`),children:Xt(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)(Zl,{}),e[22]=n,e[23]=g);let _;e[24]!==s?.runCommand||e[25]!==r||e[26]!==n?(_=r&&(0,$.jsxs)(Td,{className:`electrobun-webkit-app-region-no-drag`,children:[(0,$.jsx)(Wl,{projectId:r,runCommand:s?.runCommand}),n&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ml,{threadId:n}),(0,$.jsx)(Fl,{})]})]}),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)(Td,{className:`electrobun-webkit-app-region-no-drag`,children:(0,$.jsx)(Ul,{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)(wd,{className:l,children:[h,b]}),e[38]=b,e[39]=l,e[40]=h,e[41]=x):x=e[41],x}function Dd(e){return e.sidebarOpen}function Od(e){return e.projects}function kd(e){return e.selectedProjectId}function Ad(e){return e.selectedThreadId}function jd(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)(mr,{children:`Delete Project`}),t[0]=o):o=t[0];let s;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(s=U(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)(hr,{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)(pr,{children:`Cancel`}),t[4]=l):l=t[4];let u;t[5]===a?u=t[6]:(u=(0,$.jsxs)(gr,{children:[l,(0,$.jsx)(xr,{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)(_r,{open:n,onOpenChange:i,children:d}),t[10]=i,t[11]=n,t[12]=d,t[13]=f):f=t[13],f}function Md(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)(mr,{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)(hr,{children:[`Found `,r.length,` package`,s,` with dependencies to install:`]})]}),t[3]=r.length,t[4]=s,t[5]=c):c=t[5];let l;t[6]===r?l=t[7]:(l=r.map(Nd),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)(pr,{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)(xr,{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)(gr,{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)(_r,{open:n,onOpenChange:a,children:h}),t[24]=n,t[25]=a,t[26]=h,t[27]=g):g=t[27],g}function Nd(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 Pd(){let e=(0,X.c)(19),[t,n]=(0,Y.useState)(!0),[r,i]=(0,Y.useState)(L),a,o;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=()=>{let e=!0;return(async()=>{try{let t=await fetch(`${xt()}/health`,{method:`GET`});e&&n(t.ok)}catch{e&&n(!1)}})(),()=>{e=!1}},o=[],e[0]=a,e[1]=o):(a=e[0],o=e[1]),(0,Y.useEffect)(a,o);let s;e[2]===r?s=e[3]:(s=()=>{E(r)},e[2]=r,e[3]=s);let c=s;if(t)return null;let l;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsxs)(vr,{children:[(0,$.jsx)(mr,{children:`Connect to Tarsk`}),(0,$.jsx)(hr,{children:`Connect to the Tarsk server running on your local network by entering the IP Address or domain name below.`})]}),e[4]=l):l=e[4];let u;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(u=e=>i(e.target.value),e[5]=u):u=e[5];let d;e[6]===c?d=e[7]:(d=e=>{e.key===`Enter`&&c()},e[6]=c,e[7]=d);let f;e[8]!==r||e[9]!==d?(f=(0,$.jsx)(Xe,{value:r,onChange:u,onKeyDown:d,placeholder:`192.168.1.100`,autoComplete:`off`,spellCheck:!1}),e[8]=r,e[9]=d,e[10]=f):f=e[10];let p;e[11]===r?p=e[12]:(p=r.trim(),e[11]=r,e[12]=p);let m=!p,h;e[13]!==c||e[14]!==m?(h=(0,$.jsx)(gr,{children:(0,$.jsx)(G,{onClick:c,disabled:m,children:`Connect`})}),e[13]=c,e[14]=m,e[15]=h):h=e[15];let g;return e[16]!==f||e[17]!==h?(g=(0,$.jsx)(_r,{open:!0,children:(0,$.jsxs)(br,{children:[l,f,h]})}),e[16]=f,e[17]=h,e[18]=g):g=e[18],g}var Fd=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=U(`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)(Pn,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a},Id=Zn,Ld=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=U(`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)(g,{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)(Fn,{className:a,...r,children:o}),t[8]=r,t[9]=a,t[10]=o,t[11]=s):s=t[11],s},Rd=Tn,zd=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=U(`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)(Cn,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});zd.displayName=Cn.displayName;var Bd=$e(`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`}}),Vd=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=U(Bd({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)(In,{ref:t,className:o,...i}),n[7]=i,n[8]=t,n[9]=o,n[10]=s):s=n[10],s});Vd.displayName=In.displayName;var Hd=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=U(`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)(or,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});Hd.displayName=or.displayName;var Ud=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=U(`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)(s,{className:`h-4 w-4`}),n[5]=o):o=n[5];let c;return n[6]!==i||n[7]!==t||n[8]!==a?(c=(0,$.jsx)(Bn,{ref:t,className:a,"toast-close":``,...i,children:o}),n[6]=i,n[7]=t,n[8]=a,n[9]=c):c=n[9],c});Ud.displayName=Bn.displayName;var Wd=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=U(J.dialogTitle,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,$.jsx)(Qn,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});Wd.displayName=Qn.displayName;var Gd=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=U(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)(En,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});Gd.displayName=En.displayName;function Kd(){let e=(0,X.c)(5),{toasts:t}=ki(),n;e[0]===t?n=e[1]:(n=t.map(qd),e[0]=t,e[1]=n);let r;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(zd,{}),e[2]=r):r=e[2];let i;return e[3]===n?i=e[4]:(i=(0,$.jsxs)(Rd,{children:[n,r]}),e[3]=n,e[4]=i),i}function qd(e){let{id:t,title:n,description:r,action:i,...a}=e;return(0,$.jsxs)(Vd,{...a,children:[(0,$.jsxs)(`div`,{className:`grid gap-1`,children:[n&&(0,$.jsx)(Wd,{children:n}),r&&(0,$.jsx)(Gd,{children:r})]}),i,(0,$.jsx)(Ud,{})]},t)}function Jd(){let e=(0,X.c)(4),{resolvedTheme:t,theme:n}=jr(),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 Yd(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)(Jd,{}),t[3]=i):i=t[3];let a;return t[4]!==n||t[5]!==r?(a=(0,$.jsxs)(Mr,{...r,children:[i,n]}),t[4]=n,t[5]=r,t[6]=a):a=t[6],a}function Xd(){let e=(0,X.c)(14),t=di(),n=Q($d),r=yr(`projects:bootstrap:${Q(Qd)}`,yn),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(Zd);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 Zd(e){return e.isSelected}function Qd(e){return e.configUpdatedAt}function $d(e){return e.selectedThreadId}function ef(e){let t=di(),n=Q(e=>e.projects),r=Q(e=>e.selectedProjectId),i=Q(e=>e.selectedThreadId),{toast:o}=ki(),s=pi(`project-creation`).dispatch,[c,l]=(0,Y.useState)(null),u=(0,Y.useCallback)(async()=>{try{t({type:Z.SetProjectsLoading,projectsLoading:!0}),Te(),Tr(`projects:bootstrap:`);let e=await yn();t({type:Z.SetProjects,projects:e.projects})}catch(e){console.error(`Failed to refresh projects:`,e)}finally{t({type:Z.SetProjectsLoading,projectsLoading:!1})}},[t]),f=(0,Y.useCallback)((e,n)=>{(i!==n||r!==e)&&t({type:Z.SelectThread,threadId:n,projectId:e}),Ft(e,n).catch(e=>{console.error(`Failed to select thread:`,e)})},[t,i,r]),p=(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 u();return}let i=n.useTerminalDispatch?s: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(),o=new TextDecoder,c=``,d=null,f=!1,p=null,m=null;for(;;){let{done:e,value:r}=await a.read();if(e)break;c+=o.decode(r,{stream:!0});let s=c.split(`
63
- `);c=s.pop()??``;for(let e of s){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&&l({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}),Te();let h=await yn();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?s:t)({type:Z.AppendTerminalLine,line:{type:`error`,content:`${n.catchErrorPrefix}: ${e instanceof Error?e.message:`Unknown error`}`}})}},[t,u,s,e?.onProjectCreated]),m=(0,Y.useCallback)(async(e,t)=>{let n=e.split(`/`).pop()?.replace(`.git`,``)??`project`;await p({apiCall:()=>dn(e,t),initialMessage:`Cloning repository: ${e}...`,optimisticProjectName:n,gitUrl:e,useTerminalDispatch:!0,includeThreadPath:!0,handleSetupScript:!0,logTag:`create project`,catchErrorPrefix:`Failed to create project`})},[p]),h=(0,Y.useCallback)(async(e,t,n)=>{await p({apiCall:()=>pe(e,t,n),initialMessage:`Creating app "${e}"...`,optimisticProjectName:e,useTerminalDispatch:!0,handleSetupScript:!1,logTag:`create web app`,catchErrorPrefix:`Failed to create web app`})},[p]),g=(0,Y.useCallback)(async e=>{await p({apiCall:()=>on(e),initialMessage:`Creating folder "${e}"...`,optimisticProjectName:e,useTerminalDispatch:!0,handleSetupScript:!1,logTag:`create folder`,catchErrorPrefix:`Failed to create folder`})},[p]),_=(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}`})(),a=await ln(e,r);if(!a){await u();return}let s=a.getReader(),c=new TextDecoder,l=``,d=!1,f=null,p=!0,m=[{type:`system`,content:`Creating thread "${i}"...`}];try{for(;;){let{done:n,value:r}=await s.read();if(n)break;l+=c.decode(r,{stream:!0});let a=l.split(`
64
- `);l=a.pop()??``;for(let n of a){let r=n.trim();if(r)try{let n=JSON.parse(r);if(n.type===`progress`){if(!d&&n.threadId){d=!0,f=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:f});for(let e of m)t({type:Z.AppendTerminalLine,threadId:f,line:e});m.length=0}let r={type:`output`,content:n.message};f?t({type:Z.AppendTerminalLine,threadId:f,line:r}):m.push(r)}else if(n.type===`error`){d&&f&&(t({type:Z.RemoveCreatingThread,projectId:e,threadId:f}),t({type:Z.RemoveProcessingThread,threadId:f}));let r={type:`error`,content:`Error: ${n.message}`};f?t({type:Z.AppendTerminalLine,threadId:f,line:r}):m.push(r),console.error(`Thread creation error:`,n.message),o({title:`Thread Creation Failed`,description:n.message,variant:`destructive`}),p=!1}}catch(e){console.error(`Failed to parse thread event`,e)}}}d&&f&&t({type:Z.RemoveProcessingThread,threadId:f}),Te(),await u(),f&&p&&t({type:Z.SelectThread,threadId:f,projectId:e,focusInput:!0})}catch(n){throw d&&f&&(t({type:Z.RemoveCreatingThread,projectId:e,threadId:f}),t({type:Z.RemoveProcessingThread,threadId:f})),o({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}}),o({variant:`destructive`,title:`Thread Creation Failed`,description:n}),e}},[u,t,n,o]),v=(0,Y.useCallback)(async(e,n)=>{t({type:Z.AddDeletingThread,threadId:n}),t({type:Z.ClearChatInputDraft,threadId:n});try{await B(e,n),i===n&&t({type:Z.SelectThread,threadId:``,projectId:``}),await u(),t({type:Z.ConfigUpdated})}catch(e){console.error(`Failed to delete thread:`,e),o({variant:`destructive`,title:`Failed to delete thread`,description:e instanceof Error?e.message:`Unknown error`})}finally{t({type:Z.RemoveDeletingThread,threadId:n})}},[u,i,t,o]),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 a(e),r===e&&t({type:Z.SelectThread,threadId:``,projectId:``}),await u(),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})}},[u,r,n,t]),b=(0,Y.useCallback)(async e=>{let n=c;if(l(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 d(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 u()}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`}`}})}},[c,t,u]);return{projects:n,selectedProjectId:r,selectedThreadId:i,refreshProjects:u,handleSelectThread:f,handleCreateProject:m,handleCreateWebApp:h,handleCreateFolder:g,handleOpenFolder:(0,Y.useCallback)(async()=>{await p({apiCall:P,initialMessage:`Opening folder...`,optimisticProjectName:`Opening folder...`,useTerminalDispatch:!0,handleSetupScript:!0,logTag:`open folder`,catchErrorPrefix:`Failed to open folder`})},[p]),handleCreateThread:_,handleDeleteThread:v,confirmDeleteProject:y,pendingSetupScriptConfirmation:c,resolveSetupScriptConfirmation:b}}function tf(){let e=(0,X.c)(2),[t,n]=(0,Y.useState)(nf),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 nf(){return document.hasFocus()}var rf=null;function af(){rf??=new Audio(`/pop.wav`),rf.currentTime=0,rf.play().catch(e=>{console.debug(`Could not play completion sound:`,e)})}function of(){let e=di(),t=ui(),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=tf(),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=su(await Vt()),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&&af(),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 sf=768;function cf(){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: ${sf-1}px)`),t=()=>{n(window.innerWidth<sf)};return e.addEventListener(`change`,t),n(window.innerWidth<sf),()=>e.removeEventListener(`change`,t)},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),Y.useEffect(r,i),!!t}var lf=(0,Y.lazy)(()=>cr(()=>import(`./terminal-panel-Bm5ECpK_.js`).then(e=>({default:e.TerminalPanel})),__vite__mapDeps([12,1,5]))),uf=(0,Y.lazy)(()=>cr(()=>Promise.resolve().then(()=>td).then(e=>({default:e.TodosView})),void 0)),df=(0,Y.lazy)(()=>cr(()=>import(`./diff-view-DGfmGlB_.js`),__vite__mapDeps([6,1,3,4,7,5,8,9,10,11]))),ff=(0,Y.lazy)(()=>cr(()=>import(`./explorer-tab-view-CCXVTkVu.js`),__vite__mapDeps([13,1,3,4,7,5]))),pf=(0,Y.lazy)(()=>cr(()=>import(`./browser-tab-C9kJT-C5.js`).then(e=>({default:e.BrowserTab})),__vite__mapDeps([14,1,5]))),mf=(0,Y.lazy)(()=>cr(()=>import(`./dialogs-config-B4TDFSrS.js`).then(e=>e.t),__vite__mapDeps([5,1]))),hf=(0,Y.lazy)(()=>cr(()=>import(`./onboarding-DfL8a0LZ.js`).then(e=>e.t),__vite__mapDeps([8,1,7,5]))),gf=(0,Y.lazy)(()=>cr(()=>import(`./settings-view-B4CMq7it.js`),__vite__mapDeps([15,1,3,4,7,5,8,16,17,10])));function _f(e){return e.startsWith(`/settings`)||e===`/review`||e===`/todos`}function vf(){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 yf(){let e=di(),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 Vr({})},[]);let o=Jn(),s=rr(),c=cf(),[l,u]=(0,Y.useState)(null),{projects:d,handleSelectThread:f,handleCreateProject:p,handleCreateWebApp:m,handleCreateFolder:h,handleOpenFolder:g,handleCreateThread:_,handleDeleteThread:v,confirmDeleteProject:y,refreshProjects:b,pendingSetupScriptConfirmation:x,resolveSetupScriptConfirmation:S}=ef({onProjectCreated:u}),{processingThreadIds:C,completedThreadIds:w,clearCompleted:T}=of(),[E,D]=(0,Y.useState)(`chat`),[O,k]=(0,Y.useState)(null),[A,j]=(0,Y.useState)(!1),[M,N]=(0,Y.useState)(!1),[P,F]=(0,Y.useState)(!1),[I,L]=(0,Y.useState)(null),[R,z]=(0,Y.useState)(0),[ee,B]=(0,Y.useState)(null),[te,ne]=(0,Y.useState)(0),{terminalState:V}=pi(t),re=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{V.open&&t===re.current&&!_f(s.pathname)&&D(`terminal`),re.current=t},[V.open,t,s.pathname]);let[ie,H]=(0,Y.useState)(!1),[ae,oe]=(0,Y.useState)(!1),[se,ce]=(0,Y.useState)(!1),[le,ue]=(0,Y.useState)(null),[de,fe]=(0,Y.useState)(!1),[pe,me]=(0,Y.useState)(!1),he=(0,Y.useRef)(null),ge=(0,Y.useRef)(null),_e=s.pathname.startsWith(`/settings`),ve=s.pathname===`/review`,ye=s.pathname===`/todos`;(0,Y.useEffect)(()=>{s.pathname===`/`&&E===`tasks`&&D(`chat`)},[s.pathname]),(0,Y.useEffect)(()=>{c&&(ge.current?.querySelector(`[data-tab="${E}"]`))?.scrollIntoView({inline:`nearest`,block:`nearest`})},[E,c]);let be=(0,Y.useRef)(E),xe=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{if(_e){if(xe.current===null){xe.current=Date.now(),be.current=E;return}be.current!==E&&o(`/`)}else xe.current=null;be.current=E},[E,_e,o]);let Se=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{let t=_e||ve||ye;if(t&&Se.current===null)Se.current=r,r&&e({type:Z.ToggleSidebar});else if(!t&&Se.current!==null){let t=Se.current;Se.current=null,t&&!r&&e({type:Z.ToggleSidebar})}},[_e,ve,ye]),(0,Y.useEffect)(()=>{(async()=>{try{(await nt()).updateAvailable&&fe(!0)}catch{}})()},[]);let Ce=(0,Y.useCallback)(async()=>{me(!0);try{await rn()}catch{me(!1)}},[]);(0,Y.useEffect)(()=>{se||(async()=>{try{(await It()).onboardingCompleted||oe(!0)}catch(e){console.error(`Failed to check onboarding status:`,e)}finally{ce(!0)}})()},[se]),(0,Y.useEffect)(()=>{ae||e({type:Z.ConfigUpdated})},[ae,e]);let we=(0,Y.useCallback)(e=>{let t=d.find(t=>t.projectId===e);t&&ue({id:t.projectId,name:Pt(t)})},[d]),Te=(0,Y.useCallback)(e=>{u(e),_(e,void 0)},[_]);(0,Y.useEffect)(()=>{l&&n===l&&t&&u(null)},[l,n,t]);let Ee=(0,Y.useCallback)(async(n,i)=>{u(null),T(i),s.pathname!==`/`&&o(`/`),D(`chat`),t!==i&&ne(e=>e+1),f(n,i),c&&r&&e({type:Z.ToggleSidebar})},[f,c,r,t,e,T,s.pathname,o]);(0,Y.useEffect)(()=>{r?he.current?.expand():he.current?.collapse()},[r]);let De={activeMainTab:E,setActiveMainTab:D,devServerUrl:O,setDevServerUrl:k,devServerRunning:A,setDevServerRunning:j,devServerLoading:M,setDevServerLoading:N,terminalNotification:P,setTerminalNotification:F,pendingExplorerPath:I,setPendingExplorerPath:L,explorerRefreshTick:R,triggerExplorerRefresh:()=>z(e=>e+1),explorerClearPath:ee,setExplorerClearPath:B,browserResetTrigger:te,triggerBrowserReset:()=>ne(e=>e+1)};return(0,$.jsxs)(da.Provider,{value:De,children:[(0,$.jsx)(Y.Suspense,{fallback:null,children:(0,$.jsx)(Xd,{})}),(0,$.jsxs)(Ke,{delayDuration:200,children:[(0,$.jsxs)(Fd,{direction:`horizontal`,className:`h-screen bg-background`,children:[(0,$.jsx)(Id,{ref:he,defaultSize:c?100:25,minSize:c?50:12,maxSize:c?100:32,collapsible:!0,collapsedSize:0,className:`border-r border-transparent`,children:(0,$.jsx)(`div`,{className:`h-full overflow-hidden`,children:(0,$.jsx)(Ni,{projects:d,selectedThreadId:t,selectedProjectId:n,processingThreadIds:C,completedThreadIds:w,deletingThreadIds:i,deletingProjectIds:a,onSelectThread:Ee,onCreateProject:()=>H(!0),onCreateThread:Te,onDeleteThread:v,onDeleteProject:we,onDeselect:()=>e({type:Z.ClearSelection}),collapsed:!r,updateAvailable:de,updatingApp:pe,onUpdateApp:Ce,expandProjectId:l})})}),!c&&(0,$.jsx)(Ld,{withHandle:!0,className:r?`ml-[-40px]`:``}),(0,$.jsx)(Id,{minSize:40,className:`overflow-hidden ${c&&r?`hidden`:``}`,children:(0,$.jsx)(tu,{threadId:t??void 0,children:(0,$.jsx)(wl,{children:(0,$.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden`,children:[!ve&&!_e&&!ye&&(0,$.jsx)(Ed,{}),!ve&&!_e&&!ye&&t&&(0,$.jsx)(`div`,{ref:ge,className:`flex shrink-0 select-none overflow-x-auto border-b border-border`,children:[`Chat`,`Explorer`,`Review`,`Browser`,`Terminal`,`Tasks`].map(e=>{let t=e.toLowerCase();return(0,$.jsxs)(`button`,{"data-tab":t,onClick:()=>{D(t),t===`terminal`&&F(!1)},className:`relative shrink-0 px-4 py-2 text-base font-medium transition-colors ${E===t?`border-b-2 border-primary text-foreground -mb-px`:`text-muted-foreground hover:text-foreground`}`,children:[e,t===`terminal`&&P&&E!==`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${!ve&&!_e&&!ye&&E!==`chat`?` hidden`:``}`,children:(0,$.jsxs)(er,{children:[(0,$.jsx)(qn,{path:`/settings/project/:projectId`,element:(0,$.jsx)(Y.Suspense,{fallback:(0,$.jsx)(vf,{}),children:(0,$.jsx)(gf,{})})}),(0,$.jsx)(qn,{path:`/settings/:tab?`,element:(0,$.jsx)(Y.Suspense,{fallback:(0,$.jsx)(vf,{}),children:(0,$.jsx)(gf,{})})}),(0,$.jsx)(qn,{path:`*`,element:(0,$.jsx)(ld,{onCreateThread:Te})})]})}),(0,$.jsx)(`div`,{className:`flex-1 overflow-hidden${E===`terminal`&&!ve&&!_e&&!ye?``:` hidden`}`,children:(0,$.jsx)(Y.Suspense,{fallback:null,children:(0,$.jsx)(lf,{})})}),(0,$.jsx)(`div`,{className:`flex-1 overflow-hidden${E===`browser`&&!ve&&!_e&&!ye?``:` hidden`}`,children:(0,$.jsx)(Y.Suspense,{fallback:null,children:(0,$.jsx)(pf,{})})}),!ve&&!_e&&!ye&&E!==`chat`&&E!==`terminal`&&E!==`browser`&&(E===`explorer`?(0,$.jsx)(Y.Suspense,{fallback:null,children:(0,$.jsx)(ff,{})}):E===`tasks`&&n?(0,$.jsx)(Y.Suspense,{fallback:null,children:(0,$.jsx)(uf,{projectId:n})}):E===`review`&&t?(0,$.jsx)(Y.Suspense,{fallback:null,children:(0,$.jsx)(df,{threadId:t,onExit:()=>D(`chat`)})}):(0,$.jsx)(`div`,{className:`flex-1 overflow-hidden`}))]})})})}),(0,$.jsx)(Y.Suspense,{fallback:null,children:(0,$.jsx)(mf,{open:ie,onOpenChange:H,onSubmitClone:p,onSubmitWebApp:m,onSubmitFolder:h,onOpenFolder:g})}),(0,$.jsx)(jd,{open:le!==null,projectName:le?.name,onOpenChange:e=>!e&&ue(null),onConfirm:()=>{le&&(y(le.id),ue(null))}}),(0,$.jsx)(Md,{open:x!==null,setupScripts:x?[x.command,...x.remainingScripts||[]]:[],onConfirm:S}),(0,$.jsx)(Y.Suspense,{fallback:null,children:(0,$.jsx)(hf,{open:ae,onOpenChange:oe,onComplete:()=>{ce(!0),b()}})}),(0,$.jsx)(Pd,{})]}),(0,$.jsx)(Kd,{})]})]})}function bf(){let e=(0,X.c)(3),[t]=(0,Y.useState)(ci),n;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(yf,{}),e[0]=n):n=e[0];let r;return e[1]===t?r=e[2]:(r=(0,$.jsx)(Yd,{attribute:`class`,defaultTheme:`system`,enableSystem:!0,storageKey:`tarsk-theme`,children:(0,$.jsx)(li.Provider,{value:t,children:n})}),e[1]=t,e[2]=r),r}var xf=75,Sf=125,Cf=100;function wf(){return window.matchMedia(`(max-width: 767px)`).matches}function Tf(e){let t=ft(e,wf());document.documentElement.style.fontSize=`${t}%`}var Ef=!1;function Df(){Ef||(Ef=!0,window.matchMedia(`(max-width: 767px)`).addEventListener(`change`,()=>{Tf(w(Cf))}))}function Of(){let[e,t]=(0,Y.useState)(()=>w(Cf));(0,Y.useEffect)(()=>{Df(),Tf(e)},[e]);function n(e){let n=Math.max(xf,Math.min(Sf,Math.round(e)));t(n),Be(n)}return{scale:e,updateScale:n,resetScale:(0,Y.useCallback)(()=>{n(Cf)},[]),min:xf,max:Sf,default:Cf}}function kf(){Df(),Tf(w(Cf))}kf();var Af=!1;window.addEventListener(`resize`,()=>{Af||=(window.__electrobunWebviewId&&(document.body.style.height=`calc(100%)`),!0)}),(0,Nr.createRoot)(document.getElementById(`root`)).render((0,$.jsx)(Y.StrictMode,{children:(0,$.jsx)(Xn,{children:(0,$.jsx)(bf,{})})}));export{di as A,fa as C,_i as D,Oi as E,pi as M,mi as O,ya as S,Mi as T,Ho as _,Fd as a,no as b,Qu as c,gu as d,Wl as f,Ro as g,Lo as h,Id as i,Q as j,Z as k,Xu as l,Mo as m,cf as n,wd as o,ol as p,Ld as r,Yu as s,Of as t,Zu as u,No as v,ea as w,to as x,eo as y};