tarsk 0.3.39 → 0.3.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +4335 -2705
- package/dist/public/assets/index-7w1xN3In.css +1 -0
- package/dist/public/assets/index-C0siF70s.js +18 -0
- package/dist/public/assets/monaco-w6PwaWGP.js +11 -0
- package/dist/public/assets/radix-ui-e1yigncZ.js +1 -0
- package/dist/public/assets/react-vendor-LZWkwdTn.js +59 -0
- package/dist/public/assets/ui-styling-CyCIFleB.js +1 -0
- package/dist/public/assets/utils-D3eY_iAj.js +1 -0
- package/dist/public/index.html +7 -2
- package/dist/scaffold-templates.json +1 -1
- package/package.json +6 -4
- package/dist/public/assets/index-C85yPisA.js +0 -86
- package/dist/public/assets/index-CfhNkIT6.css +0 -1
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import{r as m,c as $,j as n,S as va,R as Ln,a as $n,b as Na,V as wa,C as Sa,d as Ca,e as Ta,f as Ia,g as On,P as Ra,h as Ea,T as ka,i as _a,M as Pa,k as Fn,l as hs,m as Gn,L as ve,n as sn,o as Ks,p as Js,q as Mt,F as Hn,G as gs,s as ht,t as ds,Z as nn,u as rn,X as ut,v as an,w as Ma,x as Da,y as Tt,z as It,A as Un,B as Aa,D as La,E as $a,H as zn,I as Bn,J as Oa,K as qn,N as Fa,O as Ga,Q as Ha,U as Ua,W as Wn,Y as za,_ as Ss,$ as Ba,a0 as qa,a1 as ln,a2 as Wa,a3 as Va,a4 as Vn,a5 as on,a6 as Ka,a7 as Kn,a8 as Jn,a9 as Ja,aa as Qa,ab as Ya,ac as Xa,ad as Za,ae as Qn,af as el,ag as Yn,ah as Xn,ai as Zn,aj as tl,ak as sl,al as er,am as tr,an as sr,ao as nr,ap as xs,aq as rr,ar,as as nl,at as lr,au as or,av as ir,aw as cr,ax as dr,ay as ur,az as mr,aA as rl,aB as al,aC as ll,aD as ol,aE as fr,aF as pr,aG as il,aH as cl,aI as dl,aJ as ul,aK as ml,aL as fl,aM as Qs,aN as cn,aO as pl,aP as hl,aQ as gl,aR as hr,aS as xl,aT as gr,aU as xr,aV as jr,aW as yr,aX as br,aY as jl,aZ as vr,a_ as Nr,a$ as wr,b0 as yl,b1 as Sr,b2 as Cr,b3 as Tr,b4 as Ir,b5 as bl,b6 as vl,b7 as Nl,b8 as wl,b9 as Sl,ba as Cl,bb as Rr,bc as Er,bd as kr,be as _r,bf as bn,bg as Tl,bh as Il,bi as Rl,bj as El,bk as kl,bl as Pr,bm as Mr,bn as Dr,bo as Ar,bp as Lr,bq as $r,br as _l,bs as Pl}from"./react-vendor-LZWkwdTn.js";import{t as Ml,c as Dl,a as js}from"./ui-styling-CyCIFleB.js";import{z as Al,J as Ll}from"./utils-D3eY_iAj.js";import"./radix-ui-e1yigncZ.js";import"./monaco-w6PwaWGP.js";(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))r(a);new MutationObserver(a=>{for(const l of a)if(l.type==="childList")for(const o of l.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function t(a){const l={};return a.integrity&&(l.integrity=a.integrity),a.referrerPolicy&&(l.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?l.credentials="include":a.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function r(a){if(a.ep)return;a.ep=!0;const l=t(a);fetch(a.href,l)}})();function es(s){return typeof s!="string"?"":s.replace(/\\n/g,`
|
|
2
|
+
`)}function Or(s){if(!s||typeof s!="string")return null;const e=s.trim();if(!e.startsWith("[")){if(!e.startsWith("{"))return null;try{const a=JSON.parse(e);if(a&&typeof a=="object"&&(a.type==="tool-result"||a.type==="tool_use"))return[a]}catch{}return null}const t=[];let r=0;for(;r<e.length;){const a=e.indexOf("[",r);if(a===-1)break;let l=0,o=-1;for(let i=a;i<e.length;i++)if(e[i]==="[")l++;else if(e[i]==="]"&&(l--,l===0)){o=i;break}if(o===-1)break;try{const i=JSON.parse(e.slice(a,o+1));if(Array.isArray(i)){for(const c of i)if(c&&typeof c=="object"&&"type"in c){const d=c.type;(d==="tool-result"||d==="tool_use")&&t.push(c)}}}catch{}r=o+1}return t.length>0?t:null}function vn(s){return s.map(e=>{if(typeof e=="object"&&e!==null&&!("type"in e)){const t=e;if(t.reasoning)return{type:"reasoning",text:String(t.reasoning)};const r=t.text||t.content||t.answer;if(r)return{type:"text",text:String(r)}}return e})}function Nn(s){const e=[];s.reasoning&&typeof s.reasoning=="string"&&e.push({type:"reasoning",text:s.reasoning});const t=(typeof s.text=="string"?s.text:null)||(typeof s.content=="string"?s.content:null)||(typeof s.answer=="string"?s.answer:null);return t&&e.push({type:"text",text:t}),e.length===0&&Object.keys(s).length>0&&e.push({type:"text",text:JSON.stringify(s,null,2)}),e}function Fr(s){if(!s)return null;const e=s.trim();if(e.startsWith("{")||e.startsWith("["))try{const i=JSON.parse(e);if(Array.isArray(i))return vn(i);if(typeof i=="object"&&i!==null)return Nn(i)}catch{}const r=[],a=s.indexOf("{"),l=s.indexOf("["),o=a===-1?l:l===-1?a:Math.min(a,l);if(o!==-1){const i=s.slice(o),c=Math.max(i.lastIndexOf("]"),i.lastIndexOf("}"));if(c!==-1){const d=i.substring(0,c+1);try{const u=JSON.parse(d);Array.isArray(u)?r.push(...vn(u)):r.push(...Nn(u));const f=i.substring(c+1).trim();return f&&r.push({type:"text",text:f}),r}catch{}}}return null}function zs(s,e,t){const r=s[s.length-1];return r?.type===e?[...s.slice(0,-1),{type:e,chunks:[...r.chunks,t]}]:[...s,{type:e,chunks:[t]}]}function Ys(s,e){return s[s.length-1]?.type==="content"?[...s.slice(0,-1),{type:"content",chunks:[e]}]:[...s,{type:"content",chunks:[e]}]}function Gr(s){const e=[];for(const t of s){const r=t.chunks.join("");if(t.type==="thinking"){const a=Or(r)??[];e.push(...a)}else{const a=Fr(r)??(r.trim()?[{type:"text",text:r}]:[]);e.push(...a)}}return e}function $l(s){const e=Gr(s);return e.length===0?"...":e.length===1&&e[0]?.type==="text"&&"text"in e[0]?e[0].text:JSON.stringify(e)}var P=(s=>(s.SetProjects="SET_PROJECTS",s.SelectThread="SELECT_THREAD",s.SetMessages="SET_MESSAGES",s.AddMessage="ADD_MESSAGE",s.EnqueueChatMessage="ENQUEUE_CHAT_MESSAGE",s.RemoveQueuedChatMessage="REMOVE_QUEUED_CHAT_MESSAGE",s.SetStreaming="SET_STREAMING",s.AppendStreamContent="APPEND_STREAM_CONTENT",s.SetStreamContent="SET_STREAM_CONTENT",s.AppendStreamThinking="APPEND_STREAM_THINKING",s.AppendStreamChunk="APPEND_STREAM_CHUNK",s.SetStreamModel="SET_STREAM_MODEL",s.SetProjectModel="SET_PROJECT_MODEL",s.ResetStream="RESET_STREAM",s.StopStream="STOP_STREAM",s.ToggleSidebar="TOGGLE_SIDEBAR",s.SetCreatingProject="SET_CREATING_PROJECT",s.ConfigUpdated="CONFIG_UPDATED",s.SetProcessingThreads="SET_PROCESSING_THREADS",s.AddProcessingThread="ADD_PROCESSING_THREAD",s.RemoveProcessingThread="REMOVE_PROCESSING_THREAD",s.AddCreatingProject="ADD_CREATING_PROJECT",s.AddCreatingThread="ADD_CREATING_THREAD",s.RemoveCreatingProject="REMOVE_CREATING_PROJECT",s.RemoveCreatingThread="REMOVE_CREATING_THREAD",s.MarkThreadCompleted="MARK_THREAD_COMPLETED",s.ClearThreadCompleted="CLEAR_THREAD_COMPLETED",s.AddDeletingThread="ADD_DELETING_THREAD",s.RemoveDeletingThread="REMOVE_DELETING_THREAD",s.AddDeletingProject="ADD_DELETING_PROJECT",s.RemoveDeletingProject="REMOVE_DELETING_PROJECT",s.AppendCommandOutput="APPEND_COMMAND_OUTPUT",s.SetRunningCommand="SET_RUNNING_COMMAND",s.ClearCommandOutput="CLEAR_COMMAND_OUTPUT",s.ToggleTerminal="TOGGLE_TERMINAL",s.SetTerminalOpen="SET_TERMINAL_OPEN",s.QueueTerminalCommand="QUEUE_TERMINAL_COMMAND",s.ClearQueuedTerminalCommand="CLEAR_QUEUED_TERMINAL_COMMAND",s.AppendTerminalLine="APPEND_TERMINAL_LINE",s.ClearTerminalOutput="CLEAR_TERMINAL_OUTPUT",s.SetTerminalHeight="SET_TERMINAL_HEIGHT",s.SetTerminalCwd="SET_TERMINAL_CWD",s.SetTerminalRunning="SET_TERMINAL_RUNNING",s.SetTerminalHistory="SET_TERMINAL_HISTORY",s.SetTerminalHistoryIndex="SET_TERMINAL_HISTORY_INDEX",s.UpdateThreadTitle="UPDATE_THREAD_TITLE",s.ClearFocusChatInput="CLEAR_FOCUS_CHAT_INPUT",s.ToggleReviewMode="TOGGLE_REVIEW_MODE",s.SetReviewMode="SET_REVIEW_MODE",s.ClearMessages="CLEAR_MESSAGES",s.UpdateToolCallProgress="UPDATE_TOOL_CALL_PROGRESS",s.OpenHistoryView="OPEN_HISTORY_VIEW",s.CloseHistoryView="CLOSE_HISTORY_VIEW",s))(P||{});const Hr={projects:[],selectedThreadId:null,selectedProjectId:null,messages:[],queuedChatMessages:[],isStreaming:!1,streamingContent:"",streamingThinking:"",streamingSegments:[],streamingModel:"",projectModelSelections:{},sidebarOpen:!0,isCreatingProject:!1,configUpdatedAt:0,processingThreadIds:[],completedThreadIds:[],deletingThreadIds:[],deletingProjectIds:[],commandOutput:"",isRunningCommand:!1,terminalStates:{},focusChatInput:!1,reviewMode:!1,toolCallProgress:{},historyView:{isOpen:!1}};function Ol(s,e){switch(e.type){case"SET_PROJECTS":return{...s,projects:e.projects};case"SELECT_THREAD":return{...s,selectedThreadId:e.threadId,selectedProjectId:e.projectId,messages:e.initialMessages||[],focusChatInput:e.focusInput??!1};case"SET_MESSAGES":return{...s,messages:e.messages};case"ADD_MESSAGE":return{...s,messages:[...s.messages,e.message]};case"ENQUEUE_CHAT_MESSAGE":return{...s,queuedChatMessages:[...s.queuedChatMessages,e.message]};case"REMOVE_QUEUED_CHAT_MESSAGE":return{...s,queuedChatMessages:s.queuedChatMessages.filter(t=>t.id!==e.queuedMessageId)};case"SET_STREAMING":return{...s,isStreaming:e.isStreaming};case"APPEND_STREAM_CONTENT":return{...s,streamingContent:s.streamingContent+e.content};case"SET_STREAM_CONTENT":{const t=Ys(s.streamingSegments,e.content);return{...s,streamingContent:e.content,streamingSegments:t}}case"APPEND_STREAM_THINKING":return{...s,streamingThinking:s.streamingThinking+e.content};case"APPEND_STREAM_CHUNK":return{...s,streamingSegments:e.segments,streamingContent:e.chunkType==="content"?s.streamingContent+e.content:s.streamingContent,streamingThinking:e.chunkType==="thinking"?s.streamingThinking+e.content:s.streamingThinking};case"SET_STREAM_MODEL":return{...s,streamingModel:e.model};case"SET_PROJECT_MODEL":return{...s,projectModelSelections:{...s.projectModelSelections,[e.projectId]:e.modelId}};case"RESET_STREAM":return{...s,streamingContent:"",streamingThinking:"",streamingSegments:[],streamingModel:"",isStreaming:!1,toolCallProgress:{}};case"STOP_STREAM":return{...s,isStreaming:!1};case"TOGGLE_SIDEBAR":return{...s,sidebarOpen:!s.sidebarOpen};case"SET_CREATING_PROJECT":return{...s,isCreatingProject:e.isCreating};case"CONFIG_UPDATED":return{...s,configUpdatedAt:Date.now()};case"SET_PROCESSING_THREADS":return{...s,processingThreadIds:e.threadIds};case"ADD_PROCESSING_THREAD":return{...s,processingThreadIds:s.processingThreadIds.includes(e.threadId)?s.processingThreadIds:[...s.processingThreadIds,e.threadId]};case"REMOVE_PROCESSING_THREAD":return{...s,processingThreadIds:s.processingThreadIds.filter(t=>t!==e.threadId)};case"ADD_CREATING_PROJECT":return{...s,projects:[...s.projects,{projectId:e.projectId,name:e.projectName,gitUrl:e.gitUrl,threads:[{threadId:e.threadId,title:"thread-1",path:"",currentBranch:""}]}]};case"ADD_CREATING_THREAD":return{...s,projects:s.projects.map(t=>t.projectId===e.projectId?{...t,threads:[...t.threads,{threadId:e.threadId,title:e.title,path:"",currentBranch:""}]}:t)};case"REMOVE_CREATING_PROJECT":return{...s,projects:s.projects.filter(t=>t.projectId!==e.projectId)};case"REMOVE_CREATING_THREAD":return{...s,projects:s.projects.map(t=>t.projectId===e.projectId?{...t,threads:t.threads.filter(r=>r.threadId!==e.threadId)}:t)};case"MARK_THREAD_COMPLETED":return{...s,completedThreadIds:s.completedThreadIds.includes(e.threadId)?s.completedThreadIds:[...s.completedThreadIds,e.threadId]};case"CLEAR_THREAD_COMPLETED":return{...s,completedThreadIds:s.completedThreadIds.filter(t=>t!==e.threadId)};case"ADD_DELETING_THREAD":return{...s,deletingThreadIds:s.deletingThreadIds.includes(e.threadId)?s.deletingThreadIds:[...s.deletingThreadIds,e.threadId]};case"REMOVE_DELETING_THREAD":return{...s,deletingThreadIds:s.deletingThreadIds.filter(t=>t!==e.threadId)};case"ADD_DELETING_PROJECT":return{...s,deletingProjectIds:s.deletingProjectIds.includes(e.projectId)?s.deletingProjectIds:[...s.deletingProjectIds,e.projectId]};case"REMOVE_DELETING_PROJECT":return{...s,deletingProjectIds:s.deletingProjectIds.filter(t=>t!==e.projectId)};case"APPEND_COMMAND_OUTPUT":return{...s,commandOutput:s.commandOutput+e.content};case"SET_RUNNING_COMMAND":return{...s,isRunningCommand:e.isRunning};case"CLEAR_COMMAND_OUTPUT":return{...s,commandOutput:""};case"TOGGLE_TERMINAL":{const t=e.threadId,r=s.terminalStates[t]||{open:!1,queuedCommand:null,outputLines:[],height:300,history:[],historyIndex:-1,cwd:".",isRunning:!1};return{...s,terminalStates:{...s.terminalStates,[t]:{...r,open:!r.open}}}}case"SET_TERMINAL_OPEN":{const t=e.threadId||"default",r=s.terminalStates[t]||{open:!1,queuedCommand:null,outputLines:[],height:300,history:[],historyIndex:-1,cwd:".",isRunning:!1};return{...s,terminalStates:{...s.terminalStates,[t]:{...r,open:e.open}}}}case"QUEUE_TERMINAL_COMMAND":{const t=e.threadId,r=s.terminalStates[t]||{open:!1,queuedCommand:null,outputLines:[],height:300,history:[],historyIndex:-1,cwd:".",isRunning:!1};return{...s,terminalStates:{...s.terminalStates,[t]:{...r,queuedCommand:e.command,open:!0}}}}case"CLEAR_QUEUED_TERMINAL_COMMAND":{const t=e.threadId,r=s.terminalStates[t]||{open:!1,queuedCommand:null,outputLines:[],height:300,history:[],historyIndex:-1,cwd:".",isRunning:!1};return{...s,terminalStates:{...s.terminalStates,[t]:{...r,queuedCommand:null}}}}case"APPEND_TERMINAL_LINE":{const t=e.threadId||"default",r=s.terminalStates[t]||{open:!1,queuedCommand:null,outputLines:[],height:300,history:[],historyIndex:-1,cwd:".",isRunning:!1};return{...s,terminalStates:{...s.terminalStates,[t]:{...r,outputLines:[...r.outputLines,e.line]}}}}case"CLEAR_TERMINAL_OUTPUT":{const t=e.threadId||"default",r=s.terminalStates[t]||{open:!1,queuedCommand:null,outputLines:[],height:300,history:[],historyIndex:-1,cwd:".",isRunning:!1};return{...s,terminalStates:{...s.terminalStates,[t]:{...r,outputLines:[]}}}}case"SET_TERMINAL_HEIGHT":{const t=e.threadId,r=s.terminalStates[t]||{open:!1,queuedCommand:null,outputLines:[],height:300,history:[],historyIndex:-1,cwd:".",isRunning:!1};return{...s,terminalStates:{...s.terminalStates,[t]:{...r,height:e.height}}}}case"SET_TERMINAL_CWD":{const t=e.threadId,r=s.terminalStates[t]||{open:!1,queuedCommand:null,outputLines:[],height:300,history:[],historyIndex:-1,cwd:".",isRunning:!1};return{...s,terminalStates:{...s.terminalStates,[t]:{...r,cwd:e.cwd}}}}case"SET_TERMINAL_RUNNING":{const t=e.threadId,r=s.terminalStates[t]||{open:!1,queuedCommand:null,outputLines:[],height:300,history:[],historyIndex:-1,cwd:".",isRunning:!1};return{...s,terminalStates:{...s.terminalStates,[t]:{...r,isRunning:e.isRunning}}}}case"SET_TERMINAL_HISTORY":{const t=e.threadId,r=s.terminalStates[t]||{open:!1,queuedCommand:null,outputLines:[],height:300,history:[],historyIndex:-1,cwd:".",isRunning:!1};return{...s,terminalStates:{...s.terminalStates,[t]:{...r,history:e.history}}}}case"SET_TERMINAL_HISTORY_INDEX":{const t=e.threadId,r=s.terminalStates[t]||{open:!1,queuedCommand:null,outputLines:[],height:300,history:[],historyIndex:-1,cwd:".",isRunning:!1};return{...s,terminalStates:{...s.terminalStates,[t]:{...r,historyIndex:e.index}}}}case"UPDATE_THREAD_TITLE":return{...s,projects:s.projects.map(t=>t.projectId===e.projectId?{...t,threads:t.threads.map(r=>r.threadId===e.threadId?{...r,title:e.title}:r)}:t)};case"CLEAR_FOCUS_CHAT_INPUT":return{...s,focusChatInput:!1};case"TOGGLE_REVIEW_MODE":return{...s,reviewMode:!s.reviewMode};case"SET_REVIEW_MODE":return{...s,reviewMode:e.reviewMode};case"CLEAR_MESSAGES":return{...s,messages:[]};case"UPDATE_TOOL_CALL_PROGRESS":return{...s,toolCallProgress:{...s.toolCallProgress,[e.toolCallId]:e.progress}};case"OPEN_HISTORY_VIEW":return{...s,historyView:{isOpen:!0,initialFilter:e.initialFilter}};case"CLOSE_HISTORY_VIEW":return{...s,historyView:{isOpen:!1}};default:return s}}const Ur=m.createContext({state:Hr,dispatch:()=>{}});function Se(){return m.useContext(Ur)}function ys(s){const e=$.c(11),{state:t,dispatch:r}=Se();if(!s){let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=[],e[0]=d):d=e[0];let u;return e[1]===Symbol.for("react.memo_cache_sentinel")?(u={terminalState:{open:!1,queuedCommand:null,outputLines:d,height:300,history:[],historyIndex:-1,cwd:".",isRunning:!1},dispatch:Fl},e[1]=u):u=e[1],u}let a;e[2]!==t.terminalStates||e[3]!==s?(a=t.terminalStates[s]||{open:!1,queuedCommand:null,outputLines:[],height:300,history:[],historyIndex:-1,cwd:".",isRunning:!1},e[2]=t.terminalStates,e[3]=s,e[4]=a):a=e[4];const l=a;let o;e[5]!==r||e[6]!==s?(o=d=>{r({...d,threadId:s})},e[5]=r,e[6]=s,e[7]=o):o=e[7];const i=o;let c;return e[8]!==i||e[9]!==l?(c={terminalState:l,dispatch:i},e[8]=i,e[9]=l,e[10]=c):c=e[10],c}function Fl(){}function U(...s){return Ml(Dl(s))}function Es(s){return s.name?s.name:s.gitUrl?.split("/").pop()?.replace(".git","")||s.projectId}function Gl(s,e){if(!e)return"";for(const t of s){const r=t.threads.find(a=>a.threadId===e);if(r)return r.title}return""}function Hl(s,e){if(!e)return"";const t=s.find(r=>r.projectId===e);return t?Es(t):""}function is(s){return s.toFixed(2).replace(/\.00$/,"")}const dn=js("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),K=m.forwardRef((s,e)=>{const t=$.c(15);let r,a,l,o,i;t[0]!==s?({className:r,variant:i,size:l,asChild:o,...a}=s,t[0]=s,t[1]=r,t[2]=a,t[3]=l,t[4]=o,t[5]=i):(r=t[1],a=t[2],l=t[3],o=t[4],i=t[5]);const d=(o===void 0?!1:o)?va:"button";let u;t[6]!==r||t[7]!==l||t[8]!==i?(u=U(dn({variant:i,size:l,className:r})),t[6]=r,t[7]=l,t[8]=i,t[9]=u):u=t[9];let f;return t[10]!==d||t[11]!==a||t[12]!==e||t[13]!==u?(f=n.jsx(d,{className:u,ref:e,...a}),t[10]=d,t[11]=a,t[12]=e,t[13]=u,t[14]=f):f=t[14],f});K.displayName="Button";const Ve=m.forwardRef((s,e)=>{const t=$.c(15);let r,a,l;t[0]!==s?({className:a,children:r,...l}=s,t[0]=s,t[1]=r,t[2]=a,t[3]=l):(r=t[1],a=t[2],l=t[3]);let o;t[4]!==a?(o=U("relative overflow-hidden",a),t[4]=a,t[5]=o):o=t[5];let i;t[6]!==r?(i=n.jsx(wa,{className:"h-full w-full rounded-[inherit]",children:r}),t[6]=r,t[7]=i):i=t[7];let c,d;t[8]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(zr,{}),d=n.jsx(Sa,{}),t[8]=c,t[9]=d):(c=t[8],d=t[9]);let u;return t[10]!==l||t[11]!==e||t[12]!==o||t[13]!==i?(u=n.jsxs(Ln,{ref:e,className:o,...l,children:[i,c,d]}),t[10]=l,t[11]=e,t[12]=o,t[13]=i,t[14]=u):u=t[14],u});Ve.displayName=Ln.displayName;const zr=m.forwardRef((s,e)=>{const t=$.c(14);let r,a,l;t[0]!==s?({className:r,orientation:l,...a}=s,t[0]=s,t[1]=r,t[2]=a,t[3]=l):(r=t[1],a=t[2],l=t[3]);const o=l===void 0?"vertical":l,i=o==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",c=o==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]";let d;t[4]!==r||t[5]!==i||t[6]!==c?(d=U("flex touch-none select-none transition-colors",i,c,r),t[4]=r,t[5]=i,t[6]=c,t[7]=d):d=t[7];let u;t[8]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx(Na,{className:"relative flex-1 rounded-full bg-border"}),t[8]=u):u=t[8];let f;return t[9]!==o||t[10]!==a||t[11]!==e||t[12]!==d?(f=n.jsx($n,{ref:e,orientation:o,className:d,...a,children:u}),t[9]=o,t[10]=a,t[11]=e,t[12]=d,t[13]=f):f=t[13],f});zr.displayName=$n.displayName;const Ul=Ca,zl=Ta,Bl=Ia,we=Ra,fe=Ea,pe=ka,me=m.forwardRef((s,e)=>{const t=$.c(11);let r,a,l;t[0]!==s?({className:r,sideOffset:l,...a}=s,t[0]=s,t[1]=r,t[2]=a,t[3]=l):(r=t[1],a=t[2],l=t[3]);const o=l===void 0?4:l;let i;t[4]!==r?(i=U("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-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),t[4]=r,t[5]=i):i=t[5];let c;return t[6]!==a||t[7]!==e||t[8]!==o||t[9]!==i?(c=n.jsx(On,{ref:e,sideOffset:o,className:i,...a}),t[6]=a,t[7]=e,t[8]=o,t[9]=i,t[10]=c):c=t[10],c});me.displayName=On.displayName;function ql(){const s=$.c(8),{theme:e,setTheme:t}=Al();let r;s[0]!==t||s[1]!==e?(r=()=>t(e==="dark"?"light":"dark"),s[0]=t,s[1]=e,s[2]=r):r=s[2];let a,l,o;s[3]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx(_a,{className:"h-[1.2rem] w-[1.2rem] rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0"}),l=n.jsx(Pa,{className:"absolute h-[1.2rem] w-[1.2rem] rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100"}),o=n.jsx("span",{className:"sr-only",children:"Toggle theme"}),s[3]=a,s[4]=l,s[5]=o):(a=s[3],l=s[4],o=s[5]);let i;return s[6]!==r?(i=n.jsxs(K,{variant:"ghost",size:"icon",className:"h-8 w-8 text-sidebar-foreground hover:bg-sidebar-accent",onClick:r,children:[a,l,o]}),s[6]=r,s[7]=i):i=s[7],i}function Wl(s){const e=$.c(65),{projects:t,selectedThreadId:r,processingThreadIds:a,completedThreadIds:l,deletingThreadIds:o,deletingProjectIds:i,onSelectThread:c,onCreateProject:d,onCreateThread:u,onDeleteThread:f,onDeleteProject:g,onOpenConfiguration:h,onProjectSettings:p,onCollapseSidebar:j,onViewHistory:v,isMobile:b,collapsed:I}=s;let C;e[0]===Symbol.for("react.memo_cache_sentinel")?(C={containerType:"inline-size"},e[0]=C):C=e[0];let x;e[1]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx("div",{className:"flex h-7 w-7 items-center justify-center overflow-hidden rounded-md border border-sidebar-border shadow-sm",children:n.jsx("img",{src:"/tarsk.svg",alt:"Tarsk",className:"h-full w-full"})}),e[1]=x):x=e[1];let T;e[2]!==I?(T=!I&&n.jsx("span",{className:"text-sm font-semibold tracking-tight",children:"Tarsk"}),e[2]=I,e[3]=T):T=e[3];let _;e[4]!==T?(_=n.jsxs("div",{className:"flex items-center gap-2",children:[x,T]}),e[4]=T,e[5]=_):_=e[5];let w;e[6]!==I||e[7]!==b||e[8]!==j?(w=!I&&b&&n.jsxs(K,{variant:"ghost",size:"icon",className:"h-7 w-7 text-sidebar-foreground hover:bg-sidebar-accent",onClick:j,children:[n.jsx(Fn,{className:"h-4 w-4"}),n.jsx("span",{className:"sr-only",children:"Collapse sidebar"})]}),e[6]=I,e[7]=b,e[8]=j,e[9]=w):w=e[9];let R;e[10]!==w?(R=n.jsx("div",{className:"flex items-center gap-1",children:w}),e[10]=w,e[11]=R):R=e[11];let N;e[12]!==_||e[13]!==R?(N=n.jsxs("div",{className:"flex items-center justify-between border-b border-sidebar-border px-4 py-3",children:[_,R]}),e[12]=_,e[13]=R,e[14]=N):N=e[14];let y;e[15]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx(hs,{className:"h-4 w-4"}),e[15]=y):y=e[15];let S;e[16]!==I?(S=!I&&n.jsx("span",{children:"New Project"}),e[16]=I,e[17]=S):S=e[17];let E;e[18]!==d||e[19]!==S?(E=n.jsx("div",{className:"border-b border-sidebar-border px-3 py-2",children:n.jsxs(K,{variant:"ghost",size:"sm",className:"w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent",onClick:d,children:[y,S]})}),e[18]=d,e[19]=S,e[20]=E):E=e[20];let k;e[21]!==t.length?(k=t.length===0&&n.jsx("p",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:"No projects yet. Clone a repository to get started."}),e[21]=t.length,e[22]=k):k=e[22];let A;if(e[23]!==l||e[24]!==i||e[25]!==o||e[26]!==u||e[27]!==g||e[28]!==f||e[29]!==p||e[30]!==c||e[31]!==v||e[32]!==a||e[33]!==t||e[34]!==r){let Q;e[36]!==l||e[37]!==i||e[38]!==o||e[39]!==u||e[40]!==g||e[41]!==f||e[42]!==p||e[43]!==c||e[44]!==v||e[45]!==a||e[46]!==r?(Q=(se,de)=>n.jsx(Vl,{project:se,selectedThreadId:r,processingThreadIds:a,completedThreadIds:l,deletingThreadIds:o,deletingProjectIds:i,onSelectThread:c,onCreateThread:u,onDeleteThread:f,onDeleteProject:g,onProjectSettings:p,onViewHistory:v},se.projectId||se.gitUrl||`project-${de}`),e[36]=l,e[37]=i,e[38]=o,e[39]=u,e[40]=g,e[41]=f,e[42]=p,e[43]=c,e[44]=v,e[45]=a,e[46]=r,e[47]=Q):Q=e[47],A=t.map(Q),e[23]=l,e[24]=i,e[25]=o,e[26]=u,e[27]=g,e[28]=f,e[29]=p,e[30]=c,e[31]=v,e[32]=a,e[33]=t,e[34]=r,e[35]=A}else A=e[35];let D;e[48]!==k||e[49]!==A?(D=n.jsx(Ve,{className:"flex-1",children:n.jsxs("div",{className:"px-2 py-2",children:[k,A]})}),e[48]=k,e[49]=A,e[50]=D):D=e[50];let z;e[51]===Symbol.for("react.memo_cache_sentinel")?(z=n.jsx(Gn,{className:"h-4 w-4"}),e[51]=z):z=e[51];let O;e[52]!==I?(O=!I&&n.jsx("span",{children:"Settings"}),e[52]=I,e[53]=O):O=e[53];let L;e[54]!==h||e[55]!==O?(L=n.jsxs(K,{variant:"ghost",size:"sm",className:"flex-1 justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent",onClick:h,children:[z,O]}),e[54]=h,e[55]=O,e[56]=L):L=e[56];let F;e[57]===Symbol.for("react.memo_cache_sentinel")?(F=n.jsx(ql,{}),e[57]=F):F=e[57];let B;e[58]!==L?(B=n.jsxs("div",{className:"border-t border-sidebar-border px-3 py-2 flex items-center gap-1",children:[L,F]}),e[58]=L,e[59]=B):B=e[59];let W;return e[60]!==E||e[61]!==D||e[62]!==B||e[63]!==N?(W=n.jsxs("div",{className:"flex h-full flex-col bg-sidebar text-sidebar-foreground",style:C,children:[N,E,D,B]}),e[60]=E,e[61]=D,e[62]=B,e[63]=N,e[64]=W):W=e[64],W}function Vl(s){const e=$.c(78),{project:t,selectedThreadId:r,processingThreadIds:a,completedThreadIds:l,deletingThreadIds:o,deletingProjectIds:i,onSelectThread:c,onCreateThread:d,onDeleteThread:u,onDeleteProject:f,onProjectSettings:g,onViewHistory:h}=s,[p,j]=m.useState(!0);let v;e[0]!==i||e[1]!==t.projectId?(v=i.includes(t.projectId),e[0]=i,e[1]=t.projectId,e[2]=v):v=e[2];const b=v;let I;e[3]!==t?(I=Es(t),e[3]=t,e[4]=I):I=e[4];const C=I,x=`${C} - `;let T,_,w,R,N,y,S,E,k;if(e[5]!==p||e[6]!==t.threads||e[7]!==r){let ae;e[17]!==r?(ae=ce=>ce.threadId===r,e[17]=r,e[18]=ae):ae=e[18];const le=t.threads.some(ae);_=Ul,S=p,E=j,k="mb-1",y="group flex min-w-0 items-center",T=zl,N=!0,w="button",R=U("flex min-w-0 flex-1 items-center gap-1.5 rounded-md px-2 py-1.5 text-left text-sm transition-colors hover:bg-sidebar-accent",le&&"text-sidebar-foreground font-medium"),e[5]=p,e[6]=t.threads,e[7]=r,e[8]=T,e[9]=_,e[10]=w,e[11]=R,e[12]=N,e[13]=y,e[14]=S,e[15]=E,e[16]=k}else T=e[8],_=e[9],w=e[10],R=e[11],N=e[12],y=e[13],S=e[14],E=e[15],k=e[16];const A=p&&"rotate-90";let D;e[19]!==A?(D=U("h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform",A),e[19]=A,e[20]=D):D=e[20];let z;e[21]!==D?(z=n.jsx(Mt,{className:D}),e[21]=D,e[22]=z):z=e[22];let O;e[23]===Symbol.for("react.memo_cache_sentinel")?(O=n.jsx(Hn,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e[23]=O):O=e[23];let L;e[24]!==C?(L=n.jsx("span",{className:"min-w-0 truncate",children:C}),e[24]=C,e[25]=L):L=e[25];let F;e[26]!==z||e[27]!==L||e[28]!==w||e[29]!==R?(F=n.jsxs("button",{type:w,className:R,children:[z,O,L]}),e[26]=z,e[27]=L,e[28]=w,e[29]=R,e[30]=F):F=e[30];let B;e[31]!==T||e[32]!==F||e[33]!==N?(B=n.jsx(T,{asChild:N,children:F}),e[31]=T,e[32]=F,e[33]=N,e[34]=B):B=e[34];let W;e[35]!==b||e[36]!==d||e[37]!==f||e[38]!==g||e[39]!==h||e[40]!==t.projectId||e[41]!==t.threads.length?(W=n.jsx("div",{className:"flex shrink-0 items-center",children:b?n.jsx(ve,{className:"h-3.5 w-3.5 shrink-0 animate-spin text-muted-foreground mr-1"}):n.jsxs(we,{children:[n.jsxs(fe,{children:[n.jsx(pe,{asChild:!0,children:n.jsxs(K,{variant:"ghost",size:"icon",className:"h-6 w-6 shrink-0 opacity-0 group-hover:opacity-100",onClick:()=>h({type:"project",id:t.projectId}),children:[n.jsx(sn,{className:"h-3 w-3"}),n.jsx("span",{className:"sr-only",children:"View project history"})]})}),n.jsx(me,{side:"right",children:"View project history"})]}),n.jsxs(fe,{children:[n.jsx(pe,{asChild:!0,children:n.jsxs(K,{variant:"ghost",size:"icon",className:"h-6 w-6 shrink-0 opacity-0 group-hover:opacity-100",onClick:()=>g(t.projectId),children:[n.jsx(Ks,{className:"h-3 w-3"}),n.jsx("span",{className:"sr-only",children:"Project settings"})]})}),n.jsx(me,{side:"right",children:"Project settings"})]}),n.jsxs(fe,{children:[n.jsx(pe,{asChild:!0,children:n.jsxs(K,{variant:"ghost",size:"icon",className:"h-6 w-6 shrink-0 opacity-0 group-hover:opacity-100",onClick:()=>d(t.projectId),children:[n.jsx(hs,{className:"h-3 w-3"}),n.jsx("span",{className:"sr-only",children:"Add thread"})]})}),n.jsx(me,{side:"right",children:"Add thread"})]}),t.threads.length===0&&n.jsxs(fe,{children:[n.jsx(pe,{asChild:!0,children:n.jsxs(K,{variant:"ghost",size:"icon",className:"h-6 w-6 shrink-0 opacity-0 group-hover:opacity-100 text-muted-foreground hover:text-destructive",onClick:()=>f(t.projectId),children:[n.jsx(Js,{className:"h-3 w-3"}),n.jsx("span",{className:"sr-only",children:"Delete project"})]})}),n.jsx(me,{side:"right",children:"Delete project"})]})]})}),e[35]=b,e[36]=d,e[37]=f,e[38]=g,e[39]=h,e[40]=t.projectId,e[41]=t.threads.length,e[42]=W):W=e[42];let Q;e[43]!==B||e[44]!==W||e[45]!==y?(Q=n.jsxs("div",{className:y,children:[B,W]}),e[43]=B,e[44]=W,e[45]=y,e[46]=Q):Q=e[46];let se;if(e[47]!==l||e[48]!==o||e[49]!==u||e[50]!==c||e[51]!==a||e[52]!==t.projectId||e[53]!==t.threads||e[54]!==x||e[55]!==r){let ae;e[57]!==l||e[58]!==o||e[59]!==u||e[60]!==c||e[61]!==a||e[62]!==t.projectId||e[63]!==x||e[64]!==r?(ae=(le,ce)=>{const ee=a.includes(le.threadId),te=o.includes(le.threadId),M=l.includes(le.threadId);return n.jsxs("div",{className:U("group/thread flex min-w-0 items-center gap-1.5 rounded-md px-2 py-1 text-sm transition-colors hover:bg-sidebar-accent cursor-pointer",le.threadId===r&&"bg-sidebar-accent text-sidebar-accent-foreground font-medium"),onClick:()=>c(t.projectId,le.threadId),onKeyDown:H=>{(H.key==="Enter"||H.key===" ")&&c(t.projectId,le.threadId)},role:"button",tabIndex:0,children:[n.jsx(gs,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),n.jsx("span",{className:"min-w-0 text-xs",style:{display:"block",textOverflow:"ellipsis"},children:le.title?.startsWith(x)?le.title.slice(x.length):le.title||le.threadId}),ee||te?n.jsx(ve,{className:"ml-auto h-3 w-3 shrink-0 animate-spin text-muted-foreground"}):M?n.jsx(ht,{className:"ml-auto h-3 w-3 shrink-0 text-green-500"}):n.jsx("div",{className:"ml-auto flex items-center gap-1",children:n.jsxs(fe,{children:[n.jsx(pe,{asChild:!0,children:n.jsxs(K,{variant:"ghost",size:"icon",className:"h-5 w-5 shrink-0 opacity-0 group-hover/thread:opacity-100 text-muted-foreground hover:text-destructive",onClick:H=>{H.stopPropagation(),u(t.projectId,le.threadId)},children:[n.jsx(Js,{className:"h-3 w-3"}),n.jsx("span",{className:"sr-only",children:"Delete thread"})]})}),n.jsx(me,{side:"right",children:"Delete thread and files from the repo"})]})})]},le.threadId||`${t.projectId}-${le.title||ce}`)},e[57]=l,e[58]=o,e[59]=u,e[60]=c,e[61]=a,e[62]=t.projectId,e[63]=x,e[64]=r,e[65]=ae):ae=e[65],se=t.threads.map(ae),e[47]=l,e[48]=o,e[49]=u,e[50]=c,e[51]=a,e[52]=t.projectId,e[53]=t.threads,e[54]=x,e[55]=r,e[56]=se}else se=e[56];let de;e[66]!==t.threads.length?(de=t.threads.length===0&&n.jsx("p",{className:"px-2 py-1 text-xs text-muted-foreground",children:"No threads"}),e[66]=t.threads.length,e[67]=de):de=e[67];let ie;e[68]!==se||e[69]!==de?(ie=n.jsx(Bl,{children:n.jsxs("div",{className:"ml-4 border-l border-sidebar-border pl-2",children:[se,de]})}),e[68]=se,e[69]=de,e[70]=ie):ie=e[70];let re;return e[71]!==_||e[72]!==Q||e[73]!==ie||e[74]!==S||e[75]!==E||e[76]!==k?(re=n.jsxs(_,{open:S,onOpenChange:E,className:k,children:[Q,ie]}),e[71]=_,e[72]=Q,e[73]=ie,e[74]=S,e[75]=E,e[76]=k,e[77]=re):re=e[77],re}const Kl=()=>{if(typeof window>"u")return null;const s=window.SpeechRecognition||window.webkitSpeechRecognition;return s?new s:null};function Br(){const s=$.c(14),[e,t]=m.useState(!1),[r,a]=m.useState(""),[l,o]=m.useState(null),[i,c]=m.useState(!1),d=m.useRef(null),u=m.useRef("");let f,g;s[0]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{try{const x=Kl();x?(x.continuous=!0,x.interimResults=!0,x.lang="en-US",x.onstart=()=>{t(!0),o(null),u.current=""},x.onresult=T=>{let _="";for(let w=T.resultIndex;w<T.results.length;w++){const R=T.results[w][0].transcript;T.results[w].isFinal?a(N=>N+R+" "):_=_+R}u.current=_},x.onerror=T=>{console.error("Speech recognition error:",T.error),o(T.error||"An error occurred during speech recognition")},x.onend=()=>{t(!1)},d.current=x,c(!0)):(c(!1),o("Speech Recognition API is not supported in your browser"))}catch(x){console.error("Failed to initialize speech recognition:",x),c(!1),o("Failed to initialize speech recognition")}return()=>{d.current&&d.current.abort()}},g=[],s[0]=f,s[1]=g):(f=s[0],g=s[1]),m.useEffect(f,g);let h;s[2]!==e?(h=()=>{d.current&&!e&&d.current.start()},s[2]=e,s[3]=h):h=s[3];const p=h;let j;s[4]!==e?(j=()=>{d.current&&e&&d.current.stop()},s[4]=e,s[5]=j):j=s[5];const v=j;let b;s[6]===Symbol.for("react.memo_cache_sentinel")?(b=()=>{a(""),u.current=""},s[6]=b):b=s[6];const I=b;let C;return s[7]!==l||s[8]!==e||s[9]!==i||s[10]!==p||s[11]!==v||s[12]!==r?(C={isListening:e,transcript:r,error:l,startListening:p,stopListening:v,resetTranscript:I,isSupported:i},s[7]=l,s[8]=e,s[9]=i,s[10]=p,s[11]=v,s[12]=r,s[13]=C):C=s[13],C}const ls=[{id:"openrouter/minimax/minimax-m2",name:"Minimax M2",description:"Minimax model optimized for chat",provider:"openrouter",pricing:{prompt:.15,completion:.15}},{id:"openrouter/google/gemini-3-flash-preview",name:"Gemini 3 Flash",description:"Google Gemini 3 Flash model",provider:"openrouter",pricing:{prompt:.075,completion:.3}}];function At(s){if(!s)return"Unknown Model";const t=(s.split("/").filter(Boolean).pop()||s).replace(/[-_]+/g," ").trim();return t?t.split(/\s+/g).filter(Boolean).map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join(" "):s}const qr=["462","8100"].includes(document.location.port)?"http://localhost:462":"http://localhost:641";function wn(){return qr}function Rt(s){const e=s.startsWith("/")?s:`/${s}`;return`${qr}${e}`}async function Et(s){try{const e=await s.json();if(typeof e.error=="string")return e.error;if(e.error&&typeof e.error=="object")return e.error.details||e.error.message||"Unknown error"}catch{}return s.statusText||"Unknown error"}function Wr(s,e,t){const r=new Error(s);return t?.error&&typeof t.error=="object"&&(r.details=t.error.details,r.code=t.error.code),r}async function ye(s,e){const t=await fetch(Rt(s),{...e,method:"GET"});if(!t.ok){const r=await Et(t);throw new Error(r)}return t.json()}async function Ce(s,e,t){const r=await fetch(Rt(s),{...t,method:"POST",headers:{"Content-Type":"application/json",...t?.headers},body:e?JSON.stringify(e):void 0});if(!r.ok){const a=await Et(r);throw new Error(a)}return r.json()}async function Jl(s,e,t){const r=await fetch(Rt(s),{...t,method:"PATCH",headers:{"Content-Type":"application/json",...t?.headers},body:e?JSON.stringify(e):void 0});if(!r.ok){const a=await Et(r);throw new Error(a)}return r.json()}async function Ql(s,e,t){const r=await fetch(Rt(s),{...t,method:"PUT",headers:{"Content-Type":"application/json",...t?.headers},body:e?JSON.stringify(e):void 0});if(!r.ok){const a=await Et(r);throw new Error(a)}return r.body}async function Ms(s,e){const t=await fetch(Rt(s),{...e,method:"DELETE"});if(!t.ok){const r=await Et(t);throw new Error(r)}if(t.status!==204)return t.json()}async function ts(s,e,t){const r=await fetch(Rt(s),{...t,method:"POST",headers:{"Content-Type":"application/json",...t?.headers},body:e?JSON.stringify(e):void 0});if(!r.ok){const a=await Et(r);throw new Error(a)}return r.body}async function Vr(s,e,t){const r=await fetch(Rt(s),{...t,method:"POST",headers:{"Content-Type":"application/json",...t?.headers},body:e?JSON.stringify(e):void 0});if(!r.ok){let a;try{a=await r.json()}catch{}const l=await Et(r);throw Wr(l,r,a)}return r.json()}async function Yl(s,e,t){const r=await fetch(Rt(s),{...t,method:"PUT",headers:{"Content-Type":"application/json",...t?.headers},body:e?JSON.stringify(e):void 0});if(!r.ok){let a;try{a=await r.json()}catch{}const l=await Et(r);throw Wr(l,r,a)}return r.json()}function ue(...s){return s.map(e=>encodeURIComponent(String(e))).join("/")}async function Sn(){return ye("api/scaffold/templates")}async function Kr(s,e,t){return ts("api/scaffold",{projectName:s,templateId:e,packageManager:t})}async function un(){return ye("api/providers")}async function Xl(s){return ye(`api/providers/${ue(s)}/credits`)}async function Zl(s,e){await Ce("api/providers/keys",{providerName:s,apiKey:e})}async function eo(s){await Ce("api/providers/bulk-keys",{keys:s})}async function to(){return(await ye("api/programs")).programs||[]}async function so(){return(await ye("api/threads/processing")).processingThreadIds||[]}async function no(){try{return(await ye("api/git/username")).name||""}catch{return""}}async function Ns(){const e=(await ye("api/projects")||[]).map(r=>{const a=r;return{projectId:a.projectId??a.id,name:a.name,gitUrl:a.gitUrl,projectPath:a.projectPath??a.path,threads:a.threads||[],commands:a.commands||[],setupScript:a.setupScript,runCommand:a.runCommand}});return{projects:await Promise.all(e.map(async r=>{try{const l=(await ye(`api/threads?projectId=${encodeURIComponent(String(r.projectId))}`)||[]).map(o=>{const i=o,c=i.threadId??i.id;return{threadId:c,title:i.title||c,path:i.path||"",currentBranch:i.currentBranch||"",isSelected:!!i.isSelected}});return{...r,threads:l}}catch{return{...r,threads:(r.threads||[]).map(a=>({threadId:a,title:a,path:"",currentBranch:"",isSelected:!1}))}}}))}}async function Jr(s,e){return ts("api/projects",{gitUrl:s,commitMethod:e})}async function ro(s){return ye(`api/projects/${ue(s)}`)}async function ao(s){await Ms(`api/projects/${ue(s)}`)}async function lo(s,e){return ts("api/threads",{projectId:s,title:e})}async function oo(s,e){await Ms(`api/threads/${ue(e)}`)}async function io(s,e){await Jl(`api/threads/${ue(s)}`,e)}async function co(s,e){await Ce(`api/threads/${ue(e)}/select`)}async function uo(s){const e=await ye(`api/threads/${ue(s)}/messages`);return{threadId:s,messages:e}}async function mo(s){return(await ye(`api/threads/${ue(s)}/conversation-folder-path`)).path}async function fo(s,e,t,r=[],a,l){const o={threadId:s,content:e,model:t,provider:l,attachments:r.map(i=>({name:i.fileName,content:i.content.split(",")[1]||i.content,size:0,mimeType:"application/octet-stream"}))};return ts("api/chat",o,{signal:a})}async function po(s){return(await Ms(`api/chat/${ue(s)}`))?.conversationId||""}function ho(s,e,t,r,a){const l=s.getReader();let o=!1;const i=()=>{o=!0,l.cancel().catch(()=>{})},c=new TextDecoder;let d="";const u=g=>g?[/^Cannot read properties/i,/^Error:/i,/^TypeError:/i,/^ReferenceError:/i,/^SyntaxError:/i,/^failed to/i,/^error:/i,/forbidden/i,/unauthorized/i].some(p=>p.test(g.trim())):!1;async function f(){try{for(;!o;){const{done:g,value:h}=await l.read();if(g||o){if(!o&&g){if(d.trim())try{const j=JSON.parse(d);j.type==="error"?r(j.content||"Unknown error"):j.type==="message"?a?.({role:j.role||"assistant",content:j.content||""}):j.type==="complete"||(j.type==="result"&&u(j.content)?r(j.content||"Unknown error"):e(j))}catch{d.trim()&&e({type:"result",content:d})}t()}break}d+=c.decode(h,{stream:!0});const p=d.split(`
|
|
3
|
+
`);d=p.pop()||"";for(const j of p){const v=j.trim();if(v)try{const b=JSON.parse(v);if(b.type==="error"){r(b.content||"Unknown error"),t();return}else if(b.type==="message")a?.({role:b.role||"assistant",content:b.content||""});else if(b.type==="complete"){t();return}else if(b.type==="result"&&u(b.content)){r(b.content||"Unknown error"),t();return}else e(b)}catch{}}}}catch(g){r(g instanceof Error?g.message:"Stream error")}}return f(),i}async function bs(s,e){return e.runNow&&e.setupScript?Ql(`api/projects/${ue(s)}`,e):(await Yl(`api/projects/${ue(s)}`,e),null)}async function go(s,e){await Vr(`api/projects/${ue(s)}/open`,{program:e})}async function xo(s,e){await Vr(`api/threads/${ue(s)}/open`,{program:e})}async function jo(s,e){await bs(s,{program:e})}async function Qr(s,e,t){return bs(s,{setupScript:e,runNow:t})}async function yo(s,e){await bs(s,{name:e})}async function mn(s,e){const t=new URLSearchParams({provider:s});return((await ye(`api/models?${t.toString()}`)).models||[]).filter(l=>{const o=l.name.toLowerCase().trim(),i=At(l.id).toLowerCase().trim();return o!=="free"&&o!=="auto"&&i!=="free"&&i!=="auto"})}async function Yr(s,e){await Ce(`api/models/${ue(s,e)}/enable`)}async function bo(s,e){await Ce(`api/models/${ue(s,e)}/disable`)}async function ks(){const e=(await ye("api/models/enabled")).enabledModels||{},t={};for(const[r,a]of Object.entries(e))t[r]=a.filter(l=>{const o=l.name.toLowerCase().trim(),i=At(l.id).toLowerCase().trim();return o!=="free"&&o!=="auto"&&i!=="free"&&i!=="auto"});return t}async function vo(s){return ye(`api/git/status/${ue(s)}`)}async function No(s,e,t){return(await Ce(`api/git/generate-commit-message/${ue(s)}`,{model:e,provider:t})).message}async function wo(s,e){await Ce(`api/git/commit/${ue(s)}`,{message:e})}async function Cn(s){await Ce(`api/git/push/${ue(s)}`)}async function So(s,e,t){return Ce(`api/git/generate-pr-info/${ue(s)}`,{model:e,provider:t})}async function Tn(s,e,t){return Ce(`api/git/create-pr/${ue(s)}`,{title:e,description:t})}async function Co(s){await Ce(`api/git/fetch/${ue(s)}`)}async function To(s,e=50){return(await ye(`api/git/log/${ue(s)}?limit=${e}`)).commits}async function Io(s){return ye(`api/git/github-status/${ue(s)}`)}async function Ro(s,e,t,r){return Ce(`api/git/create-repo/${ue(s)}`,{repoName:e,description:t,isPrivate:r})}async function Eo(s,e){await Ce(`api/projects/${ue(s)}/commands`,e)}async function ko(s,e){await Ms(`api/projects/${ue(s)}/commands/${ue(e)}`)}async function _o(s,e,t,r){return ts(`api/projects/${ue(s)}/threads/${ue(e)}/commands/run`,{commandLine:t,cwd:r})}async function Po(s){return ye(`api/threads/${ue(s)}/files`)}async function Mo(s){return Ce(`api/projects/${ue(s)}/run-suggest`,{})}async function Do(s){return ts(`api/projects/${ue(s)}/run`,{})}async function Ao(s){return Ce(`api/projects/${ue(s)}/stop`,{})}async function Lo(s){return ye(`api/projects/${ue(s)}/running`)}async function $o(s,e){await bs(s,{runCommand:e})}async function Oo(s){return ye(`api/git/diff/${ue(s)}`)}async function Fo(){return ye("api/onboarding/status")}async function Go(){return ye("api/onboarding/git-check")}async function In(){return Ce("api/onboarding/complete",{})}async function Ho(){return Ce("api/onboarding/reset",{})}async function Uo(s){const e=await ye(`api/slash-commands?threadId=${ue(s)}`);return{commands:e.commands||[],skills:e.skills||[]}}async function Xr(s){return ye(`api/conversations/${ue(s)}`)}function ss(s){return typeof localStorage>"u"?null:localStorage.getItem(s)}function ns(s,e){typeof localStorage>"u"||localStorage.setItem(s,e)}function zo(s){return typeof sessionStorage>"u"?null:sessionStorage.getItem(s)}function Bo(s,e){typeof sessionStorage>"u"||sessionStorage.setItem(s,e)}function qo(s="npm"){return ss("tarsk.create-project.packageManager")||s}function Wo(s){ns("tarsk.create-project.packageManager",s)}function Vo(s="pull-request"){return ss("tarsk.create-project.commitMethod")||s}function Rn(s){ns("tarsk.create-project.commitMethod",s)}function Ko(s=""){return ss("tarsk.create-project.templateId")||s}function Jo(s){ns("tarsk.create-project.templateId",s)}function Qo(s=!1){const e=ss("autoGenerateCommitMessage");return e!==null?e==="true":s}function Yo(s){ns("autoGenerateCommitMessage",s.toString())}function Xo(s=!1){const e=ss("privateRepositoryDefault");return e!==null?e==="true":s}function Zo(s){ns("privateRepositoryDefault",s.toString())}function En(s){const e="selected-model-"+s;return ss(e)}function ei(s,e){const t="selected-model-"+s;ns(t,e)}function Zr(){const s=zo("chat_message_history");return s?JSON.parse(s):[]}function ti(s){const e=Zr();s.trim()&&e[e.length-1]!==s&&(e.push(s),Bo("chat_message_history",JSON.stringify(e)))}function si({initialValue:s}={}){const{state:e,dispatch:t}=Se(),[r,a]=m.useState(s||""),[l,o]=m.useState(-1),[i,c]=m.useState(""),[d,u]=m.useState(0),[f,g]=m.useState(ls),[h,p]=m.useState(ls[0]),j=m.useRef(h.id),[v,b]=m.useState(!1),[I,C]=m.useState(!1),[x,T]=m.useState([]),[_,w]=m.useState(!1),[R,N]=m.useState([]),[y,S]=m.useState(!1),[E,k]=m.useState(""),[A,D]=m.useState(0),[z,O]=m.useState([]),[L,F]=m.useState([]),[B,W]=m.useState(!1),[Q,se]=m.useState(""),de=m.useRef(null),ie=m.useRef(null),re=m.useRef(null),ae=m.useRef(null),le=m.useRef(null),ce=m.useRef(null);m.useEffect(()=>{j.current=h.id},[h.id]),m.useEffect(()=>{(async()=>{try{const G=await ks(),V=Object.values(G).flat();if(V.length>0){g(V);const X=e.selectedProjectId?En(e.selectedProjectId):null,Y=(X?V.find(q=>q.id===X):null)||V[0];Y.id!==h.id&&p(Y)}}catch(G){console.error("Failed to load enabled models:",G),g(ls);const V=e.selectedProjectId?En(e.selectedProjectId):null,Z=(V?ls.find(Y=>Y.id===V):null)||ls[0];Z.id!==h.id&&p(Z)}})()},[e.selectedProjectId,h.id]),m.useEffect(()=>{if(e.configUpdatedAt===0)return;(async()=>{try{const G=await ks(),V=Object.values(G).flat();if(V.length>0){g(V);const X=j.current;V.some(Y=>Y.id===X)||p(V[0])}}catch(G){console.error("Failed to reload enabled models:",G)}})()},[e.configUpdatedAt,e.selectedProjectId]);const[ee,te]=m.useState(e.selectedThreadId);return m.useEffect(()=>{e.selectedThreadId!==ee&&setTimeout(()=>{te(e.selectedThreadId),N([]),S(!1),O([]),F([]),W(!1)},0)},[e.selectedThreadId,ee]),m.useEffect(()=>{e.selectedThreadId&&Uo(e.selectedThreadId).then(({commands:H,skills:G})=>{console.log("Loaded slash commands:",H,"skills:",G),O(H),F(G)}).catch(H=>console.error("Failed to load slash commands and skills:",H))},[e.selectedThreadId]),m.useEffect(()=>{e.focusChatInput&&e.selectedThreadId&&!e.isStreaming&&(ie.current?.focus(),t({type:P.ClearFocusChatInput}))},[e.focusChatInput,e.selectedThreadId,e.isStreaming,t]),m.useEffect(()=>{const H=G=>{re.current&&!re.current.contains(G.target)&&b(!1),ae.current&&!ae.current.contains(G.target)&&C(!1)};if(v||I)return document.addEventListener("mousedown",H),()=>{document.removeEventListener("mousedown",H)}},[v,I]),{message:r,setMessage:a,historyIndex:l,setHistoryIndex:o,draftMessage:i,setDraftMessage:c,cursorPosition:d,setCursorPosition:u,availableModels:f,setAvailableModels:g,selectedModel:h,setSelectedModel:p,selectedModelIdRef:j,showModelMenu:v,setShowModelMenu:b,showPlusMenu:I,setShowPlusMenu:C,attachments:x,setAttachments:T,planMode:_,setPlanMode:w,allFiles:R,setAllFiles:N,showSuggestions:y,setShowSuggestions:S,suggestionQuery:E,setSuggestionQuery:k,selectedIndex:A,setSelectedIndex:D,slashCommands:z,setSlashCommands:O,skills:L,setSkills:F,showCommandSuggestions:B,setShowCommandSuggestions:W,commandQuery:Q,setCommandQuery:se,fileInputRef:de,textareaRef:ie,modelMenuRef:re,plusMenuRef:ae,suggestionsRef:le,commandSuggestionsRef:ce,handleNewChat:async()=>{if(e.selectedThreadId)try{const H=await po(e.selectedThreadId);t({type:P.ClearMessages}),console.log("New conversation started:",H)}catch(H){console.error("Failed to start new chat:",H)}},state:e,dispatch:t}}const ni=s=>{ti(s)};function ri(s){const e=$.c(95),{message:t,setMessage:r,attachments:a,selectedModel:l,onSend:o,isStreaming:i,selectedThreadId:c,isListening:d,stopListening:u,resetTranscript:f,dispatch:g,historyIndex:h,setHistoryIndex:p,draftMessage:j,setDraftMessage:v,cursorPosition:b,setCursorPosition:I,showSuggestions:C,setShowSuggestions:x,suggestionQuery:T,setSuggestionQuery:_,allFiles:w,setAllFiles:R,selectedIndex:N,setSelectedIndex:y,showCommandSuggestions:S,setShowCommandSuggestions:E,commandQuery:k,setCommandQuery:A,slashCommands:D,skills:z,textareaRef:O,setPlanMode:L}=s;let F;e[0]!==a||e[1]!==g||e[2]!==d||e[3]!==i||e[4]!==t||e[5]!==o||e[6]!==f||e[7]!==l||e[8]!==c||e[9]!==v||e[10]!==p||e[11]!==r||e[12]!==u||e[13]!==O?(F=()=>{!t.trim()&&a.length===0||c&&(d&&(u(),f()),i?g({type:P.EnqueueChatMessage,message:{id:`queued-${Date.now()}`,threadId:c,message:t,model:l.id,attachments:a,provider:l.provider}}):o(t,l.id,a,l.provider),ni(t),r(""),p(-1),v(""),O.current&&(O.current.style.height="auto"))},e[0]=a,e[1]=g,e[2]=d,e[3]=i,e[4]=t,e[5]=o,e[6]=f,e[7]=l,e[8]=c,e[9]=v,e[10]=p,e[11]=r,e[12]=u,e[13]=O,e[14]=F):F=e[14];const B=F;let W;e[15]!==b||e[16]!==t||e[17]!==r||e[18]!==x||e[19]!==T||e[20]!==O?(W=M=>{const H=t.substring(0,b-T.length-1),G=t.substring(b),V=`${H}${M} ${G}`;r(V),x(!1),setTimeout(()=>{if(O.current){O.current.focus();const X=H.length+M.length+1;O.current.setSelectionRange(X,X)}},0)},e[15]=b,e[16]=t,e[17]=r,e[18]=x,e[19]=T,e[20]=O,e[21]=W):W=e[21];const Q=W;let se;e[22]!==k||e[23]!==b||e[24]!==t||e[25]!==r||e[26]!==L||e[27]!==E||e[28]!==O?(se=M=>{const H=t.substring(0,b-k.length-1),G=t.substring(b),V=`${H}${M.content}${G}`;r(V),E(!1),setTimeout(()=>{if(O.current){O.current.focus();const X=H.length+M.content.length;O.current.setSelectionRange(X,X)}},0),M.metadata.mode==="plan"&&L(!0)},e[22]=k,e[23]=b,e[24]=t,e[25]=r,e[26]=L,e[27]=E,e[28]=O,e[29]=se):se=e[29];const de=se;let ie;e[30]!==k||e[31]!==b||e[32]!==t||e[33]!==r||e[34]!==E||e[35]!==O?(ie=M=>{const H=t.substring(0,b-k.length-1),G=t.substring(b),V=`Use the "${M.name}" skill to help with this task.`,X=`${H}${V}${G}`;r(X),E(!1),setTimeout(()=>{if(O.current){O.current.focus();const Z=H.length+V.length;O.current.setSelectionRange(Z,Z)}},0)},e[30]=k,e[31]=b,e[32]=t,e[33]=r,e[34]=E,e[35]=O,e[36]=ie):ie=e[36];const re=ie;let ae,le,ce,ee;if(e[37]!==w||e[38]!==k||e[39]!==j||e[40]!==B||e[41]!==h||e[42]!==de||e[43]!==Q||e[44]!==re||e[45]!==t||e[46]!==N||e[47]!==c||e[48]!==R||e[49]!==A||e[50]!==I||e[51]!==v||e[52]!==p||e[53]!==r||e[54]!==y||e[55]!==E||e[56]!==x||e[57]!==_||e[58]!==S||e[59]!==C||e[60]!==z||e[61]!==D||e[62]!==T){ce=G=>{if(S){if(G.key==="ArrowDown"){G.preventDefault(),y((N+1)%ae.length);return}if(G.key==="ArrowUp"){G.preventDefault(),y((N-1+ae.length)%ae.length);return}if(G.key==="Enter"||G.key==="Tab"){G.preventDefault();const X=ae[N];X&&(X.type==="command"?de(X.data):re(X.data));return}if(G.key==="Escape"){E(!1);return}}if(C){const X=le.length>0;if(G.key==="ArrowDown"&&X){G.preventDefault(),y((N+1)%le.length);return}if(G.key==="ArrowUp"&&X){G.preventDefault(),y((N-1+le.length)%le.length);return}if(G.key==="Enter"||G.key==="Tab"){G.preventDefault(),le[N]&&Q(le[N]);return}if(G.key==="Escape"){x(!1);return}}if(G.key==="Enter"&&!G.shiftKey){G.preventDefault(),B();return}const V=Zr();V.length!==0&&(G.key==="ArrowUp"?(G.preventDefault(),h===-1?(v(t),p(V.length-1),r(V[V.length-1])):h>0&&(p(h-1),r(V[h-1]))):G.key==="ArrowDown"&&(G.preventDefault(),h>0?(p(h-1),r(V[h-1])):h===0&&(p(-1),r(j))))};let M;e[67]!==w||e[68]!==c||e[69]!==R||e[70]!==A||e[71]!==I||e[72]!==r||e[73]!==y||e[74]!==E||e[75]!==x||e[76]!==_?(M=G=>{const V=G.target.value,X=G.target.selectionStart;r(V),I(X);const Z=V.substring(0,X),Y=Z.lastIndexOf("/");if(Y!==-1){const oe=Y>0?Z[Y-1]:"";if(Y===0||/\s/.test(oe)){const Ne=Z.substring(Y+1);Ne.includes(" ")?E(!1):(A(Ne),E(!0),x(!1),y(0))}else E(!1)}else{E(!1);const oe=Z.lastIndexOf("#");if(oe!==-1){const Te=oe>0?Z[oe-1]:"";if(oe===0||/\s/.test(Te)){const ze=Z.substring(oe+1);ze.includes(" ")?x(!1):(_(ze),x(!0),y(0),w.length===0&&c&&Po(c).then(Xe=>{R(Xe)}).catch(oi))}else x(!1)}else x(!1)}const q=G.target;q.style.height="auto",q.style.height=`${Math.min(q.scrollHeight,160)}px`},e[67]=w,e[68]=c,e[69]=R,e[70]=A,e[71]=I,e[72]=r,e[73]=y,e[74]=E,e[75]=x,e[76]=_,e[77]=M):M=e[77],ee=M;let H;if(e[78]!==k||e[79]!==z||e[80]!==D){let G;e[82]!==k?(G=Y=>Y.name.toLowerCase().includes(k.toLowerCase()),e[82]=k,e[83]=G):G=e[83];const V=D.filter(G);let X;e[84]!==k?(X=Y=>Y.name.toLowerCase().includes(k.toLowerCase()),e[84]=k,e[85]=X):X=e[85];const Z=z.filter(X);H=[...V.map(li),...Z.map(ai)],e[78]=k,e[79]=z,e[80]=D,e[81]=H}else H=e[81];ae=H.slice(0,10),le=C?w.filter(G=>G.toLowerCase().includes(T.toLowerCase())).slice(0,10):[],e[37]=w,e[38]=k,e[39]=j,e[40]=B,e[41]=h,e[42]=de,e[43]=Q,e[44]=re,e[45]=t,e[46]=N,e[47]=c,e[48]=R,e[49]=A,e[50]=I,e[51]=v,e[52]=p,e[53]=r,e[54]=y,e[55]=E,e[56]=x,e[57]=_,e[58]=S,e[59]=C,e[60]=z,e[61]=D,e[62]=T,e[63]=ae,e[64]=le,e[65]=ce,e[66]=ee}else ae=e[63],le=e[64],ce=e[65],ee=e[66];let te;return e[86]!==ae||e[87]!==le||e[88]!==ce||e[89]!==B||e[90]!==ee||e[91]!==de||e[92]!==Q||e[93]!==re?(te={handleSend:B,handleKeyDown:ce,handleTextareaInput:ee,insertFileReference:Q,insertCommand:de,insertSkill:re,allSuggestions:ae,fileSuggestions:le},e[86]=ae,e[87]=le,e[88]=ce,e[89]=B,e[90]=ee,e[91]=de,e[92]=Q,e[93]=re,e[94]=te):te=e[94],te}function ai(s){return{type:"skill",data:s}}function li(s){return{type:"command",data:s}}function oi(s){return console.error("Failed to fetch files:",s)}function ii(s){const e=$.c(21),{visible:t,commands:r,skills:a,query:l,selectedIndex:o,onSelectCommand:i,onSelectSkill:c,onMouseEnterSuggestion:d,containerRef:u}=s;if(!t)return null;let f;if(e[0]!==r||e[1]!==l||e[2]!==a){let I;e[4]!==l?(I=_=>_.name.toLowerCase().includes(l.toLowerCase()),e[4]=l,e[5]=I):I=e[5];const C=r.filter(I);let x;e[6]!==l?(x=_=>_.name.toLowerCase().includes(l.toLowerCase()),e[6]=l,e[7]=x):x=e[7];const T=a.filter(x);f=[...C.map(di),...T.map(ci)].slice(0,10),e[0]=r,e[1]=l,e[2]=a,e[3]=f}else f=e[3];const g=f;let h;e[8]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(ds,{className:"h-3 w-3"}),e[8]=h):h=e[8];const p=l&&` matching "${l}"`;let j;e[9]!==p?(j=n.jsxs("div",{className:"px-2 py-1.5 text-xs font-semibold text-muted-foreground border-b border-border/50 mb-1 flex items-center gap-2",children:[h,"Commands & Skills",p]}),e[9]=p,e[10]=j):j=e[10];let v;e[11]!==g||e[12]!==d||e[13]!==i||e[14]!==c||e[15]!==o?(v=g.length>0?g.map((I,C)=>{const x=C===o;if(I.type==="command"){const T=I.data;return n.jsxs("button",{type:"button",className:U("flex w-full flex-col gap-1 rounded-lg px-3 py-2 text-left transition-colors",x?"bg-accent text-accent-foreground":"text-popover-foreground hover:bg-accent/50"),onClick:()=>i(T),onMouseEnter:()=>d(C),children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(ds,{className:"h-3 w-3 text-muted-foreground"}),n.jsxs("span",{className:"font-medium",children:["/",T.name]}),T.metadata.argumentHint&&n.jsx("span",{className:"text-xs text-muted-foreground",children:T.metadata.argumentHint}),T.scope==="project"&&n.jsx("span",{className:"ml-auto text-[10px] rounded-full bg-primary/10 px-1.5 py-0.5 text-primary",children:"project"})]}),T.metadata.description&&n.jsx("span",{className:"text-xs text-muted-foreground",children:T.metadata.description})]},`cmd-${T.name}`)}else{const T=I.data;return n.jsxs("button",{type:"button",className:U("flex w-full flex-col gap-1 rounded-lg px-3 py-2 text-left transition-colors",x?"bg-accent text-accent-foreground":"text-popover-foreground hover:bg-accent/50"),onClick:()=>c(T),onMouseEnter:()=>d(C),children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(nn,{className:"h-3 w-3 text-amber-500"}),n.jsxs("span",{className:"font-medium",children:["/",T.name]}),n.jsx("span",{className:"ml-auto text-[10px] rounded-full bg-amber-500/10 px-1.5 py-0.5 text-amber-700 dark:text-amber-400",children:"skill"}),T.scope==="project"&&n.jsx("span",{className:"text-[10px] rounded-full bg-primary/10 px-1.5 py-0.5 text-primary",children:"project"})]}),n.jsx("span",{className:"text-xs text-muted-foreground",children:T.description})]},`skill-${T.name}`)}}):n.jsxs("div",{className:"px-3 py-4 text-center text-xs text-muted-foreground",children:["No commands or skills found.",n.jsx("br",{}),n.jsxs("span",{className:"text-[10px]",children:["Create commands in ",n.jsx("code",{className:"bg-muted px-1 rounded",children:"~/.tarsk/commands/"})," or skills in ",n.jsx("code",{className:"bg-muted px-1 rounded",children:"~/.tarsk/skills/"})]})]}),e[11]=g,e[12]=d,e[13]=i,e[14]=c,e[15]=o,e[16]=v):v=e[16];let b;return e[17]!==u||e[18]!==j||e[19]!==v?(b=n.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:[j,v]}),e[17]=u,e[18]=j,e[19]=v,e[20]=b):b=e[20],b}function ci(s){return{type:"skill",data:s}}function di(s){return{type:"command",data:s}}function ui(s){const e=$.c(7),{attachments:t,onRemove:r}=s;if(t.length===0)return null;let a;if(e[0]!==t||e[1]!==r){let o;e[3]!==r?(o=(i,c)=>n.jsxs("span",{className:"flex items-center gap-1 rounded-md bg-muted px-2 py-1 text-xs text-muted-foreground",children:[n.jsx(rn,{className:"h-3 w-3"}),i.fileName,n.jsxs("button",{type:"button",onClick:()=>r(c),className:"ml-1 hover:text-foreground",children:[n.jsx(ut,{className:"h-3 w-3"}),n.jsx("span",{className:"sr-only",children:"Remove attachment"})]})]},c),e[3]=r,e[4]=o):o=e[4],a=t.map(o),e[0]=t,e[1]=r,e[2]=a}else a=e[2];let l;return e[5]!==a?(l=n.jsx("div",{className:"mb-2 flex flex-wrap gap-1.5",children:a}),e[5]=a,e[6]=l):l=e[6],l}function mi(s,e){const t=s.target.files;if(!t)return;const r=[];Array.from(t).forEach(a=>{const l=new FileReader;l.onload=()=>{const o=l.result.split(",")[1];r.push({fileName:a.name,content:o}),r.length===t.length&&e(r)},l.readAsDataURL(a)}),s.target.value=""}function fi(s){const e=$.c(16),{showSuggestions:t,fileSuggestions:r,suggestionQuery:a,selectedIndex:l,onSelectFile:o,onMouseEnterSuggestion:i,containerRef:c}=s;if(!t||r.length===0)return null;let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(an,{className:"h-3 w-3"}),e[0]=d):d=e[0];let u;e[1]!==a?(u=n.jsxs("div",{className:"px-2 py-1.5 text-xs font-semibold text-muted-foreground border-b border-border/50 mb-1 flex items-center gap-2",children:[d,'Files matching "',a,'"']}),e[1]=a,e[2]=u):u=e[2];let f;if(e[3]!==r||e[4]!==i||e[5]!==o||e[6]!==l){let h;e[8]!==i||e[9]!==o||e[10]!==l?(h=(p,j)=>{const v=p.split("/").pop()||p,b=j===l;return n.jsxs("button",{type:"button",className:U("flex w-full items-center gap-2 rounded-lg px-3 py-2 text-sm text-left transition-colors",b?"bg-accent text-accent-foreground":"text-popover-foreground hover:bg-accent/50"),onClick:()=>o(p),onMouseEnter:()=>i(j),children:[p.endsWith(".ts")||p.endsWith(".tsx")||p.endsWith(".js")||p.endsWith(".jsx")?n.jsx(Ma,{className:"h-4 w-4 text-blue-500"}):n.jsx(Da,{className:"h-4 w-4 text-muted-foreground"}),n.jsxs("div",{className:"flex flex-col overflow-hidden",children:[n.jsx("span",{className:"truncate font-medium",children:v}),n.jsx("span",{className:"truncate text-[10px] text-muted-foreground opacity-70",children:p})]})]},p)},e[8]=i,e[9]=o,e[10]=l,e[11]=h):h=e[11],f=r.map(h),e[3]=r,e[4]=i,e[5]=o,e[6]=l,e[7]=f}else f=e[7];let g;return e[12]!==c||e[13]!==u||e[14]!==f?(g=n.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:[u,f]}),e[12]=c,e[13]=u,e[14]=f,e[15]=g):g=e[15],g}function pi(s){const e=$.c(22),{availableModels:t,selectedModel:r,onModelSelect:a,selectedProjectId:l}=s,[o,i]=Tt.useState(!1),c=Tt.useRef(null),d=hi;let u,f;e[0]!==o?(u=()=>{const x=T=>{c.current&&!c.current.contains(T.target)&&i(!1)};if(o)return document.addEventListener("mousedown",x),()=>{document.removeEventListener("mousedown",x)}},f=[o],e[0]=o,e[1]=u,e[2]=f):(u=e[1],f=e[2]),Tt.useEffect(u,f);let g;e[3]!==a||e[4]!==l?(g=x=>{a(x),l&&ei(l,x.id),i(!1)},e[3]=a,e[4]=l,e[5]=g):g=e[5];const h=g;let p;e[6]!==o?(p=()=>i(!o),e[6]=o,e[7]=p):p=e[7];let j;e[8]!==r?(j=d(r),e[8]=r,e[9]=j):j=e[9];let v;e[10]===Symbol.for("react.memo_cache_sentinel")?(v=n.jsx(It,{className:"h-3 w-3"}),e[10]=v):v=e[10];let b;e[11]!==p||e[12]!==j?(b=n.jsxs("button",{type:"button",className:"flex items-center gap-1 rounded-md px-2 py-1 text-xs text-muted-foreground hover:bg-muted hover:text-foreground transition-colors",onClick:p,children:[j,v]}),e[11]=p,e[12]=j,e[13]=b):b=e[13];let I;e[14]!==t||e[15]!==h||e[16]!==r||e[17]!==o?(I=o&&n.jsx("div",{className:"absolute bottom-full left-0 mb-1 w-80 rounded-lg border border-border bg-popover p-1 shadow-md z-50 overflow-hidden",children:t.map(x=>n.jsx("button",{type:"button",className:`flex w-full items-center whitespace-nowrap rounded-md px-3 py-2 text-sm text-popover-foreground hover:bg-accent ${x.id===r.id?"bg-accent font-medium":""}`,onClick:()=>h(x),children:d(x)},x.id))}),e[14]=t,e[15]=h,e[16]=r,e[17]=o,e[18]=I):I=e[18];let C;return e[19]!==b||e[20]!==I?(C=n.jsxs("div",{className:"relative",ref:c,children:[b,I]}),e[19]=b,e[20]=I,e[21]=C):C=e[21],C}function hi(s){const e=At(s.id);return s.provider?`${e} (${s.provider})`:e}function gi(s){const e=$.c(23),{onFileAttach:t,onPlanModeToggle:r,onNewChat:a}=s,[l,o]=Tt.useState(!1),i=Tt.useRef(null);let c,d;e[0]!==l?(c=()=>{const _=w=>{i.current&&!i.current.contains(w.target)&&o(!1)};if(l)return document.addEventListener("mousedown",_),()=>{document.removeEventListener("mousedown",_)}},d=[l],e[0]=l,e[1]=c,e[2]=d):(c=e[1],d=e[2]),Tt.useEffect(c,d);let u;e[3]!==t?(u=()=>{t(),o(!1)},e[3]=t,e[4]=u):u=e[4];const f=u;let g;e[5]!==r?(g=()=>{r(),o(!1)},e[5]=r,e[6]=g):g=e[6];const h=g;let p;e[7]!==a?(p=()=>{o(!1),a()},e[7]=a,e[8]=p):p=e[8];const j=p;let v;e[9]!==l?(v=()=>o(!l),e[9]=l,e[10]=v):v=e[10];let b,I;e[11]===Symbol.for("react.memo_cache_sentinel")?(b=n.jsx(hs,{className:"h-4 w-4"}),I=n.jsx("span",{className:"sr-only",children:"More options"}),e[11]=b,e[12]=I):(b=e[11],I=e[12]);let C;e[13]!==v?(C=n.jsxs(K,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-foreground",onClick:v,children:[b,I]}),e[13]=v,e[14]=C):C=e[14];let x;e[15]!==f||e[16]!==j||e[17]!==h||e[18]!==l?(x=l&&n.jsxs("div",{className:"absolute bottom-full left-0 mb-1 w-48 rounded-lg border border-border bg-popover p-1 shadow-md z-50",children:[n.jsxs("button",{type:"button",className:"flex w-full items-center gap-2 rounded-md px-3 py-2 text-sm text-popover-foreground hover:bg-accent",onClick:f,children:[n.jsx(rn,{className:"h-3.5 w-3.5"}),"Attach File"]}),n.jsxs("button",{type:"button",className:"flex w-full items-center gap-2 rounded-md px-3 py-2 text-sm text-popover-foreground hover:bg-accent",onClick:h,children:[n.jsx(Un,{className:"h-3.5 w-3.5"}),"Plan Mode"]}),n.jsxs("button",{type:"button",className:"flex w-full items-center gap-2 rounded-md px-3 py-2 text-sm text-popover-foreground hover:bg-accent",onClick:j,children:[n.jsx(Aa,{className:"h-3.5 w-3.5"}),"New Chat"]})]}),e[15]=f,e[16]=j,e[17]=h,e[18]=l,e[19]=x):x=e[19];let T;return e[20]!==x||e[21]!==C?(T=n.jsxs("div",{className:"relative",ref:i,children:[C,x]}),e[20]=x,e[21]=C,e[22]=T):T=e[22],T}function xi(s){const e=$.c(14),{onToggleSpeech:t}=s,{isListening:r,isSupported:a}=Br();if(!a)return null;const l=`h-7 w-7 ${r?"bg-red-500/20 text-red-500 hover:bg-red-500/30":"text-muted-foreground hover:text-foreground"}`;let o;e[0]!==r?(o=r?n.jsx(La,{className:"h-4 w-4"}):n.jsx($a,{className:"h-4 w-4"}),e[0]=r,e[1]=o):o=e[1];const i=r?"Stop listening":"Start listening";let c;e[2]!==i?(c=n.jsx("span",{className:"sr-only",children:i}),e[2]=i,e[3]=c):c=e[3];let d;e[4]!==t||e[5]!==l||e[6]!==o||e[7]!==c?(d=n.jsx(pe,{asChild:!0,children:n.jsxs(K,{variant:"ghost",size:"icon",className:l,onClick:t,children:[o,c]})}),e[4]=t,e[5]=l,e[6]=o,e[7]=c,e[8]=d):d=e[8];const u=r?"Stop listening":"Start listening";let f;e[9]!==u?(f=n.jsx(me,{side:"top",className:"bg-popover text-popover-foreground",children:u}),e[9]=u,e[10]=f):f=e[10];let g;return e[11]!==d||e[12]!==f?(g=n.jsxs(fe,{children:[d,f]}),e[11]=d,e[12]=f,e[13]=g):g=e[13],g}function ji(s){const e=$.c(8),{queuedMessages:t,onRemoveQueuedMessage:r}=s;if(t.length===0)return null;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Queued messages"}),e[0]=a):a=e[0];let l;if(e[1]!==r||e[2]!==t){let i;e[4]!==r?(i=c=>n.jsxs("div",{className:"flex items-start justify-between gap-3 rounded-md border border-border/60 bg-background px-3 py-2 text-sm",children:[n.jsx("p",{className:"flex-1 whitespace-pre-wrap text-foreground",children:c.message}),n.jsx("button",{type:"button",className:"rounded-full p-1 text-muted-foreground hover:text-foreground",onClick:()=>r(c.id),"aria-label":"Remove queued message",children:n.jsx(ut,{className:"h-3.5 w-3.5"})})]},c.id),e[4]=r,e[5]=i):i=e[5],l=t.map(i),e[1]=r,e[2]=t,e[3]=l}else l=e[3];let o;return e[6]!==l?(o=n.jsxs("div",{className:"mb-3 rounded-lg border border-border/60 bg-muted/30 px-4 py-3",children:[a,n.jsx("div",{className:"mt-2 flex flex-col gap-2",children:l})]}),e[6]=l,e[7]=o):o=e[7],o}function yi(s){const e=$.c(141),{onSend:t,onStop:r,isStreaming:a,disabled:l,initialValue:o,queuedMessages:i,onRemoveQueuedMessage:c}=s,d=a===void 0?!1:a,{isListening:u,transcript:f,startListening:g,stopListening:h,resetTranscript:p}=Br();let j;e[0]!==o?(j={initialValue:o},e[0]=o,e[1]=j):j=e[1];const v=si(j),{message:b,setMessage:I,historyIndex:C,setHistoryIndex:x,draftMessage:T,setDraftMessage:_,cursorPosition:w,setCursorPosition:R,availableModels:N,selectedModel:y,setSelectedModel:S,attachments:E,setAttachments:k,planMode:A,setPlanMode:D,allFiles:z,setAllFiles:O,showSuggestions:L,setShowSuggestions:F,suggestionQuery:B,setSuggestionQuery:W,selectedIndex:Q,setSelectedIndex:se,slashCommands:de,skills:ie,showCommandSuggestions:re,setShowCommandSuggestions:ae,commandQuery:le,setCommandQuery:ce,fileInputRef:ee,textareaRef:te,suggestionsRef:M,commandSuggestionsRef:H,handleNewChat:G,state:V,dispatch:X}=v,Z=V.selectedThreadId||void 0;let Y;e[2]!==z||e[3]!==E||e[4]!==le||e[5]!==w||e[6]!==X||e[7]!==T||e[8]!==C||e[9]!==u||e[10]!==d||e[11]!==b||e[12]!==t||e[13]!==A||e[14]!==p||e[15]!==Q||e[16]!==y||e[17]!==O||e[18]!==ce||e[19]!==R||e[20]!==_||e[21]!==x||e[22]!==I||e[23]!==D||e[24]!==se||e[25]!==ae||e[26]!==F||e[27]!==W||e[28]!==re||e[29]!==L||e[30]!==ie||e[31]!==de||e[32]!==h||e[33]!==B||e[34]!==Z||e[35]!==te?(Y={message:b,setMessage:I,attachments:E,selectedModel:y,onSend:t,isStreaming:d,selectedThreadId:Z,isListening:u,stopListening:h,resetTranscript:p,dispatch:X,historyIndex:C,setHistoryIndex:x,draftMessage:T,setDraftMessage:_,cursorPosition:w,setCursorPosition:R,showSuggestions:L,setShowSuggestions:F,suggestionQuery:B,setSuggestionQuery:W,allFiles:z,setAllFiles:O,selectedIndex:Q,setSelectedIndex:se,showCommandSuggestions:re,setShowCommandSuggestions:ae,commandQuery:le,setCommandQuery:ce,slashCommands:de,skills:ie,textareaRef:te,planMode:A,setPlanMode:D},e[2]=z,e[3]=E,e[4]=le,e[5]=w,e[6]=X,e[7]=T,e[8]=C,e[9]=u,e[10]=d,e[11]=b,e[12]=t,e[13]=A,e[14]=p,e[15]=Q,e[16]=y,e[17]=O,e[18]=ce,e[19]=R,e[20]=_,e[21]=x,e[22]=I,e[23]=D,e[24]=se,e[25]=ae,e[26]=F,e[27]=W,e[28]=re,e[29]=L,e[30]=ie,e[31]=de,e[32]=h,e[33]=B,e[34]=Z,e[35]=te,e[36]=Y):Y=e[36];const q=ri(Y),{handleSend:oe,handleKeyDown:Te,handleTextareaInput:Ne,insertFileReference:ze,insertCommand:Xe,insertSkill:gt,fileSuggestions:Lt}=q,xt=Tt.useRef("");let jt,ft;e[37]!==I||e[38]!==f?(jt=()=>{if(f&&f!==xt.current){const ct=f.substring(xt.current.length);I(Ue=>(Ue.endsWith(" ")||Ue==="",Ue+ct)),xt.current=f}},ft=[f,I],e[37]=I,e[38]=f,e[39]=jt,e[40]=ft):(jt=e[39],ft=e[40]),Tt.useEffect(jt,ft);let yt;e[41]!==u||e[42]!==p||e[43]!==g||e[44]!==h?(yt=()=>{u?(h(),p()):(p(),g())},e[41]=u,e[42]=p,e[43]=g,e[44]=h,e[45]=yt):yt=e[45];const bt=yt;let Ie;e[46]!==k?(Ie=ct=>k(Ue=>Ue.filter((pt,as)=>as!==ct)),e[46]=k,e[47]=Ie):Ie=e[47];let Be;e[48]!==E||e[49]!==Ie?(Be=n.jsx(ui,{attachments:E,onRemove:Ie}),e[48]=E,e[49]=Ie,e[50]=Be):Be=e[50];let Ze;e[51]!==A||e[52]!==D?(Ze=A&&n.jsxs("div",{className:"mb-2 flex items-center gap-2 rounded-md bg-accent px-3 py-1.5",children:[n.jsx(Un,{className:"h-3.5 w-3.5 text-accent-foreground"}),n.jsx("span",{className:"text-xs text-accent-foreground font-medium",children:"Plan Mode"}),n.jsxs("button",{type:"button",onClick:()=>D(!1),className:"ml-auto",children:[n.jsx(ut,{className:"h-3 w-3 text-accent-foreground"}),n.jsx("span",{className:"sr-only",children:"Exit plan mode"})]})]}),e[51]=A,e[52]=D,e[53]=Ze):Ze=e[53];let Ee;e[54]!==c||e[55]!==i?(Ee=n.jsx(ji,{queuedMessages:i,onRemoveQueuedMessage:c}),e[54]=c,e[55]=i,e[56]=Ee):Ee=e[56];let ne;e[57]!==l||e[58]!==Te||e[59]!==Ne||e[60]!==b||e[61]!==te?(ne=n.jsx("textarea",{ref:te,value:b,onChange:Ne,onKeyDown:Te,placeholder:"Ask Tarsk anything, # for files, / for commands & skills",rows:1,className:"w-full resize-none bg-transparent px-4 pt-3 pb-2 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none",disabled:l}),e[57]=l,e[58]=Te,e[59]=Ne,e[60]=b,e[61]=te,e[62]=ne):ne=e[62];let qe;e[63]!==le||e[64]!==H||e[65]!==Xe||e[66]!==gt||e[67]!==Q||e[68]!==se||e[69]!==re||e[70]!==ie||e[71]!==de?(qe=n.jsx(ii,{visible:re,commands:de,skills:ie,query:le,selectedIndex:Q,onSelectCommand:Xe,onSelectSkill:gt,onMouseEnterSuggestion:se,containerRef:H}),e[63]=le,e[64]=H,e[65]=Xe,e[66]=gt,e[67]=Q,e[68]=se,e[69]=re,e[70]=ie,e[71]=de,e[72]=qe):qe=e[72];let ge;e[73]!==Lt||e[74]!==ze||e[75]!==Q||e[76]!==se||e[77]!==L||e[78]!==B||e[79]!==M?(ge=n.jsx(fi,{showSuggestions:L,fileSuggestions:Lt,suggestionQuery:B,selectedIndex:Q,onSelectFile:ze,onMouseEnterSuggestion:se,containerRef:M}),e[73]=Lt,e[74]=ze,e[75]=Q,e[76]=se,e[77]=L,e[78]=B,e[79]=M,e[80]=ge):ge=e[80];let We;e[81]!==ee?(We=()=>ee.current?.click(),e[81]=ee,e[82]=We):We=e[82];let et;e[83]!==D?(et=()=>D(!0),e[83]=D,e[84]=et):et=e[84];let ke;e[85]!==G||e[86]!==We||e[87]!==et?(ke=n.jsx(gi,{onFileAttach:We,onPlanModeToggle:et,onNewChat:G}),e[85]=G,e[86]=We,e[87]=et,e[88]=ke):ke=e[88];let _e;e[89]!==bt?(_e=n.jsx(xi,{onToggleSpeech:bt}),e[89]=bt,e[90]=_e):_e=e[90];const kt=V.selectedProjectId||void 0;let Pe;e[91]!==N||e[92]!==y||e[93]!==S||e[94]!==kt?(Pe=n.jsx(pi,{availableModels:N,selectedModel:y,onModelSelect:S,selectedProjectId:kt}),e[91]=N,e[92]=y,e[93]=S,e[94]=kt,e[95]=Pe):Pe=e[95];let Me;e[96]!==ke||e[97]!==_e||e[98]!==Pe?(Me=n.jsxs("div",{className:"flex items-center gap-1",children:[ke,_e,Pe]}),e[96]=ke,e[97]=_e,e[98]=Pe,e[99]=Me):Me=e[99];const _t=!d&&"bg-[url('/tarsk-color.svg')] bg-cover bg-center hover:opacity-80";let De;e[100]!==_t?(De=U("h-7 w-7 rounded-full",_t),e[100]=_t,e[101]=De):De=e[101];const tt=d?r:oe;let st;e[102]!==E||e[103]!==l||e[104]!==d||e[105]!==b?(st=!d&&(l||!b.trim()&&E.length===0),e[102]=E,e[103]=l,e[104]=d,e[105]=b,e[106]=st):st=e[106];let Ae;e[107]!==d?(Ae=d&&n.jsx(zn,{className:"h-3 w-3 fill-current"}),e[107]=d,e[108]=Ae):Ae=e[108];const nt=d?"Stop generation":"Send message";let rt;e[109]!==nt?(rt=n.jsx("span",{className:"sr-only",children:nt}),e[109]=nt,e[110]=rt):rt=e[110];let Le;e[111]!==De||e[112]!==tt||e[113]!==st||e[114]!==Ae||e[115]!==rt?(Le=n.jsx(pe,{asChild:!0,children:n.jsxs(K,{size:"icon",className:De,onClick:tt,disabled:st,children:[Ae,rt]})}),e[111]=De,e[112]=tt,e[113]=st,e[114]=Ae,e[115]=rt,e[116]=Le):Le=e[116];const at=d?"Stop":"Send";let lt;e[117]!==at?(lt=n.jsx(me,{side:"top",className:"bg-popover text-popover-foreground",children:at}),e[117]=at,e[118]=lt):lt=e[118];let $e;e[119]!==Le||e[120]!==lt?($e=n.jsxs(fe,{children:[Le,lt]}),e[119]=Le,e[120]=lt,e[121]=$e):$e=e[121];let Oe;e[122]!==Me||e[123]!==$e?(Oe=n.jsxs("div",{className:"flex items-center justify-between px-3 pb-2",children:[Me,$e]}),e[122]=Me,e[123]=$e,e[124]=Oe):Oe=e[124];let Fe;e[125]!==Ee||e[126]!==ne||e[127]!==qe||e[128]!==ge||e[129]!==Oe?(Fe=n.jsxs("div",{className:"flex flex-col rounded-2xl border border-border bg-background shadow-sm focus-within:ring-1 focus-within:ring-ring/20",children:[Ee,ne,qe,ge,Oe]}),e[125]=Ee,e[126]=ne,e[127]=qe,e[128]=ge,e[129]=Oe,e[130]=Fe):Fe=e[130];let ot;e[131]!==k?(ot=ct=>mi(ct,Ue=>k(pt=>[...pt,...Ue])),e[131]=k,e[132]=ot):ot=e[132];let it;e[133]!==ee||e[134]!==ot?(it=n.jsx("input",{ref:ee,type:"file",multiple:!0,className:"hidden",onChange:ot}),e[133]=ee,e[134]=ot,e[135]=it):it=e[135];let vt;return e[136]!==Ze||e[137]!==Fe||e[138]!==it||e[139]!==Be?(vt=n.jsxs("div",{className:"relative mx-auto w-full max-w-3xl px-4 pb-4",children:[Be,Ze,Fe,it]}),e[136]=Ze,e[137]=Fe,e[138]=it,e[139]=Be,e[140]=vt):vt=e[140],vt}function _s(s){const e=$.c(10),{content:t,className:r}=s;let a;e:{if(!t||typeof t!="string"){let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=[],e[0]=u):u=e[0],a=u;break e}let d;e[1]!==t?(d=vi(t),e[1]=t,e[2]=d):d=e[2],a=d}const l=a;if(l.length===0)return null;let o;e[3]!==r?(o=U("prose-custom space-y-3 min-w-0 break-words",r),e[3]=r,e[4]=o):o=e[4];let i;e[5]!==l?(i=l.map(bi),e[5]=l,e[6]=i):i=e[6];let c;return e[7]!==o||e[8]!==i?(c=n.jsx("div",{className:o,children:i}),e[7]=o,e[8]=i,e[9]=c):c=e[9],c}function bi(s,e){return n.jsx(Ni,{block:s},e)}function vi(s){const e=s.split(`
|
|
4
|
+
`),t=[];let r=0;for(;r<e.length;){const a=e[r];if(a.trimStart().startsWith("```")){const i=a.trimStart().slice(3).trim(),c=[];for(r++;r<e.length&&!e[r].trimStart().startsWith("```");)c.push(e[r]),r++;t.push({type:"code",language:i,code:c.join(`
|
|
5
|
+
`)}),r++;continue}const l=a.match(/^(#{1,6})(\s.*)?$/);if(l){t.push({type:"heading",level:l[1].length,text:l[2]?l[2].trim():""}),r++;continue}if(/^(---|\*\*\*|___)/.test(a.trim())){t.push({type:"hr"}),r++;continue}if(a.includes("|")&&r+1<e.length&&e[r+1].match(/^\|?\s*[-:]+/)){const i=a.split("|").map(d=>d.trim()).filter(Boolean);r+=2;const c=[];for(;r<e.length&&e[r].includes("|");)c.push(e[r].split("|").map(d=>d.trim()).filter(Boolean)),r++;t.push({type:"table",headers:i,rows:c});continue}if(a.startsWith("> ")){const i=[];for(;r<e.length&&e[r].startsWith("> ");)i.push(e[r].slice(2)),r++;t.push({type:"blockquote",text:i.join(`
|
|
6
|
+
`)});continue}if(/^\s*[-*+]\s/.test(a)){const i=[];for(;r<e.length&&/^\s*[-*+]\s/.test(e[r]);)i.push(e[r].replace(/^\s*[-*+]\s/,"")),r++;t.push({type:"list",ordered:!1,items:i});continue}if(/^\s*\d+\.\s/.test(a)){const i=[];for(;r<e.length&&/^\s*\d+\.\s/.test(e[r]);)i.push(e[r].replace(/^\s*\d+\.\s/,"")),r++;t.push({type:"list",ordered:!0,items:i});continue}if(a.trim()===""){r++;continue}const o=[];for(;r<e.length&&e[r].trim()!==""&&!e[r].startsWith("#")&&!e[r].startsWith("```")&&!e[r].startsWith("> ")&&!/^\s*[-*+]\s/.test(e[r])&&!/^\s*\d+\.\s/.test(e[r]);)o.push(e[r]),r++;o.length>0&&t.push({type:"paragraph",text:o.join(`
|
|
7
|
+
`)})}return t}function Ni(s){const e=$.c(37),{block:t}=s;switch(t.type){case"heading":{const r=`h${t.level}`;let a,l;if(e[0]!==r||e[1]!==t.level){const c={1:"text-xl font-bold",2:"text-lg font-semibold",3:"text-base font-semibold",4:"text-sm font-semibold",5:"text-sm font-medium",6:"text-xs font-medium"};a=r,l=U(c[t.level],"text-foreground"),e[0]=r,e[1]=t.level,e[2]=a,e[3]=l}else a=e[2],l=e[3];let o;e[4]!==t.text?(o=n.jsx(Cs,{text:t.text}),e[4]=t.text,e[5]=o):o=e[5];let i;return e[6]!==a||e[7]!==l||e[8]!==o?(i=n.jsx(a,{className:l,children:o}),e[6]=a,e[7]=l,e[8]=o,e[9]=i):i=e[9],i}case"code":{let r;return e[10]!==t.code||e[11]!==t.language?(r=n.jsx(Ei,{language:t.language,code:t.code}),e[10]=t.code,e[11]=t.language,e[12]=r):r=e[12],r}case"blockquote":{let r;return e[13]!==t.text?(r=n.jsx("blockquote",{className:"border-l-2 border-border pl-4 text-muted-foreground italic",children:n.jsx(Cs,{text:t.text})}),e[13]=t.text,e[14]=r):r=e[14],r}case"list":{const r=t.ordered?"ol":"ul",a=t.ordered?"list-decimal":"list-disc";let l;e[15]!==a?(l=U("space-y-1 pl-5 text-sm text-foreground",a),e[15]=a,e[16]=l):l=e[16];let o;e[17]!==t.items?(o=t.items.map(Ti),e[17]=t.items,e[18]=o):o=e[18];let i;return e[19]!==r||e[20]!==l||e[21]!==o?(i=n.jsx(r,{className:l,children:o}),e[19]=r,e[20]=l,e[21]=o,e[22]=i):i=e[22],i}case"paragraph":{let r;return e[23]!==t.text?(r=n.jsx("p",{className:"text-sm leading-relaxed text-foreground whitespace-pre-wrap break-words",children:n.jsx(Cs,{text:t.text})}),e[23]=t.text,e[24]=r):r=e[24],r}case"hr":{let r;return e[25]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx("hr",{className:"border-border"}),e[25]=r):r=e[25],r}case"table":{let r;e[26]!==t.headers?(r=t.headers.map(Ci),e[26]=t.headers,e[27]=r):r=e[27];let a;e[28]!==r?(a=n.jsx("thead",{children:n.jsx("tr",{className:"border-b border-border bg-muted/50",children:r})}),e[28]=r,e[29]=a):a=e[29];let l;e[30]!==t.rows?(l=t.rows.map(wi),e[30]=t.rows,e[31]=l):l=e[31];let o;e[32]!==l?(o=n.jsx("tbody",{children:l}),e[32]=l,e[33]=o):o=e[33];let i;return e[34]!==a||e[35]!==o?(i=n.jsx("div",{className:"overflow-x-auto rounded-md border border-border max-w-full",children:n.jsxs("table",{className:"w-full text-sm",children:[a,o]})}),e[34]=a,e[35]=o,e[36]=i):i=e[36],i}default:return null}}function wi(s,e){return n.jsx("tr",{className:"border-b border-border last:border-0",children:s.map(Si)},e)}function Si(s,e){return n.jsx("td",{className:"px-3 py-2 text-foreground",children:s},e)}function Ci(s,e){return n.jsx("th",{className:"px-3 py-2 text-left font-medium text-foreground",children:s},e)}function Ti(s,e){return n.jsx("li",{children:n.jsx(Cs,{text:s})},e)}function Cs(s){const e=$.c(4),{text:t}=s;let r;e[0]!==t?(r=Ri(t).map(Ii),e[0]=t,e[1]=r):r=e[1];let a;return e[2]!==r?(a=n.jsx(n.Fragment,{children:r}),e[2]=r,e[3]=a):a=e[3],a}function Ii(s,e){switch(s.type){case"bold":return n.jsx("strong",{className:"font-semibold",children:s.text},e);case"italic":return n.jsx("em",{children:s.text},e);case"strikethrough":return n.jsx("del",{className:"text-muted-foreground",children:s.text},e);case"code":return n.jsx("code",{className:"rounded bg-muted px-1.5 py-0.5 text-xs font-mono text-foreground",children:s.text},e);case"link":return n.jsx("a",{href:s.href,className:"text-primary underline underline-offset-2 hover:text-primary/80",target:"_blank",rel:"noopener noreferrer",children:s.text},e);default:return n.jsx("span",{children:s.text},e)}}function Ri(s){const e=[],t=/(`[^`]+`)|(\*\*[^*]+\*\*)|(\*[^*]+\*)|(__[^_]+__)|(_[^_]+_)|(~~[^~]+~~)|(\[[^\]]+\]\([^)]+\))/g;let r=0,a;for(;(a=t.exec(s))!==null;){a.index>r&&e.push({type:"text",text:s.slice(r,a.index)});const l=a[0];if(l.startsWith("`"))e.push({type:"code",text:l.slice(1,-1)});else if(l.startsWith("**"))e.push({type:"bold",text:l.slice(2,-2)});else if(l.startsWith("__"))e.push({type:"bold",text:l.slice(2,-2)});else if(l.startsWith("~~"))e.push({type:"strikethrough",text:l.slice(2,-2)});else if(l.startsWith("*")||l.startsWith("_"))e.push({type:"italic",text:l.slice(1,-1)});else if(l.startsWith("[")){const o=l.match(/\[([^\]]+)\]\(([^)]+)\)/);o&&e.push({type:"link",text:o[1],href:o[2]})}r=a.index+l.length}return r<s.length&&e.push({type:"text",text:s.slice(r)}),e.length>0?e:[{type:"text",text:s}]}function Ei(s){const e=$.c(18),{language:t,code:r}=s,[a,l]=m.useState(!1);let o;e[0]!==r?(o=async()=>{await navigator.clipboard.writeText(r),l(!0),setTimeout(()=>l(!1),2e3)},e[0]=r,e[1]=o):o=e[1];const i=o,c=t||"text";let d;e[2]!==c?(d=n.jsx("span",{className:"text-xs text-muted-foreground font-mono",children:c}),e[2]=c,e[3]=d):d=e[3];let u;e[4]!==a?(u=a?n.jsx(ht,{className:"h-3 w-3"}):n.jsx(Bn,{className:"h-3 w-3"}),e[4]=a,e[5]=u):u=e[5];let f;e[6]===Symbol.for("react.memo_cache_sentinel")?(f=n.jsx("span",{className:"sr-only",children:"Copy code"}),e[6]=f):f=e[6];let g;e[7]!==i||e[8]!==u?(g=n.jsxs(K,{variant:"ghost",size:"icon",className:"h-6 w-6 text-muted-foreground hover:text-foreground",onClick:i,children:[u,f]}),e[7]=i,e[8]=u,e[9]=g):g=e[9];let h;e[10]!==d||e[11]!==g?(h=n.jsxs("div",{className:"flex items-center justify-between border-b border-border bg-muted/80 px-4 py-2",children:[d,g]}),e[10]=d,e[11]=g,e[12]=h):h=e[12];let p;e[13]!==r?(p=n.jsx("pre",{className:"overflow-x-auto p-4 max-w-full",children:n.jsx("code",{className:"text-xs font-mono text-foreground leading-relaxed",children:r})}),e[13]=r,e[14]=p):p=e[14];let j;return e[15]!==h||e[16]!==p?(j=n.jsxs("div",{className:"group relative overflow-hidden rounded-lg border border-border bg-muted",children:[h,p]}),e[15]=h,e[16]=p,e[17]=j):j=e[17],j}const ea=Fa,ta=Ga,fn=m.forwardRef((s,e)=>{const t=$.c(13);let r,a,l,o;t[0]!==s?({className:r,align:l,sideOffset:o,...a}=s,t[0]=s,t[1]=r,t[2]=a,t[3]=l,t[4]=o):(r=t[1],a=t[2],l=t[3],o=t[4]);const i=l===void 0?"center":l,c=o===void 0?4:o;let d;t[5]!==r?(d=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),t[5]=r,t[6]=d):d=t[6];let u;return t[7]!==i||t[8]!==a||t[9]!==e||t[10]!==c||t[11]!==d?(u=n.jsx(Oa,{children:n.jsx(qn,{ref:e,align:i,sideOffset:c,className:d,...a})}),t[7]=i,t[8]=a,t[9]=e,t[10]=c,t[11]=d,t[12]=u):u=t[12],u});fn.displayName=qn.displayName;function ki(s){const e=s.toLowerCase();return e.includes("read")||e.includes("file")?Ha:e.includes("create")?hs:e.includes("replace")||e.includes("edit")?Ua:e.includes("delete")?Wn:e.includes("terminal")||e.includes("bash")||e.includes("shell")?ds:e.includes("run")?nn:e.includes("git")||e.includes("branch")?gs:e.includes("search")||e.includes("grep")||e.includes("find")?an:e.includes("code")||e.includes("debug")?za:e.includes("test")?Ss:e.includes("agent")||e.includes("subagent")?Ba:e.includes("copy")?Bn:e.includes("dir")||e.includes("list")||e.includes("ls")?qa:e.includes("view")||e.includes("show")?ln:e.includes("config")||e.includes("setting")?Gn:e.includes("chat")||e.includes("message")?Wa:Va}function Xs(s){const e=s.toLowerCase();return e.includes("bash")||e.includes("terminal")||e.includes("shell")?"Ran":e.includes("read")||e.includes("file")?"Read":s}function Zt(s,e){if(!e||!s||typeof s!="string")return s;try{const t=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return s.replace(new RegExp(t,"g"),".")}catch{return s}}function _i(s){return typeof s=="string"?s:typeof s=="object"&&s!==null?JSON.stringify(s,null,2):String(s)}function Pi(s){const e=s.trim();if(e.startsWith("{")&&e.endsWith("}")||e.startsWith("[")&&e.endsWith("]"))try{return JSON.parse(e)}catch{return s}return s}function Ts(s){if(typeof s!="object"||s===null)return s;if(Array.isArray(s))return s.map(Ts);const e={};for(const[t,r]of Object.entries(s))if(typeof r=="string"){const a=Pi(r);e[t]=typeof a=="object"?Ts(a):r}else e[t]=Ts(r);return e}function Mi(s){if(s==null||typeof s!="string")return"";let e=s;return e=e.replace(/\\\\n/g,`
|
|
8
|
+
`),e=e.replace(/\\\\"/g,'"'),e=e.replace(/\\n/g,`
|
|
9
|
+
`),e=e.replace(/\\"/g,'"'),e}function Di(s){if(s==null)return"";const e=typeof s=="object"&&s!==null?Ts(s):s,t=typeof e=="string"?e:e==null?"":JSON.stringify(e,null,2);return Mi(t)}function pn(s){const e=$.c(75),{block:t,inline:r}=s,[a,l]=m.useState(!1),{state:o}=Se();let i,c,d,u,f,g,h,p;if(e[0]!==t.id||e[1]!==t.input||e[2]!==t.name||e[3]!==o.projects||e[4]!==o.selectedProjectId||e[5]!==o.selectedThreadId){let D;e[14]!==o.selectedProjectId?(D=W=>W.projectId===o.selectedProjectId,e[14]=o.selectedProjectId,e[15]=D):D=e[15];const L=o.projects.find(D)?.threads.find(W=>W.threadId===o.selectedThreadId)?.path;p=t.name||"Unknown Tool",g=t.id||"unknown";const F=t.input,B=F&&typeof F=="object"&&"description"in F;u=B?String(F.subagent_type):null,c=F&&typeof F=="object"?F:null,h=B?null:Zt(_i(F),L),d=Zt(B?String(F.prompt):null,L),i=Zt(c&&typeof c.command=="string"?c.command:null,L),f=Zt(c&&typeof c.path=="string"?c.path:null,L),e[0]=t.id,e[1]=t.input,e[2]=t.name,e[3]=o.projects,e[4]=o.selectedProjectId,e[5]=o.selectedThreadId,e[6]=i,e[7]=c,e[8]=d,e[9]=u,e[10]=f,e[11]=g,e[12]=h,e[13]=p}else i=e[6],c=e[7],d=e[8],u=e[9],f=e[10],g=e[11],h=e[12],p=e[13];const j=f,v=c&&typeof c.offset=="number"?c.offset:null,b=c&&typeof c.limit=="number"?c.limit:null;let I,C,x,T,_,w;if(e[16]!==i||e[17]!==a||e[18]!==r||e[19]!==b||e[20]!==v||e[21]!==j||e[22]!==d||e[23]!==u||e[24]!==g||e[25]!==h||e[26]!==p){w=Symbol.for("react.early_return_sentinel");e:{const D=ki(p);let z;e[33]!==b||e[34]!==v||e[35]!==p?(z=()=>{let L=p.charAt(0).toUpperCase()+p.slice(1);if(p.toLowerCase()==="bash"&&(L="Ran"),p.toLowerCase().includes("read")&&(v!==null||b!==null)){const F=v!==null?v+1:1,B=b!==null&&v!==null?F+b-1:null;L=L+` lines ${F}${B?` to ${B}`:"+"}`}return L},e[33]=b,e[34]=v,e[35]=p,e[36]=z):z=e[36];const O=z;if(r){const F=!!(d||h&&!i&&!j)?n.jsxs(ea,{children:[n.jsx(ta,{asChild:!0,children:n.jsx("span",{title:p,className:"inline-flex",children:n.jsxs("button",{type:"button",className:"inline-flex shrink-0 items-center gap-1 rounded p-0.5 text-muted-foreground hover:text-foreground focus:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":"Show tool details",children:[m.createElement(D,{className:"h-3.5 w-3.5 text-brand"}),n.jsx("span",{className:"text-xs",children:O()})]})})}),n.jsx(fn,{className:"w-80 max-h-80 overflow-auto",align:"start",children:n.jsxs("div",{className:"text-xs text-muted-foreground space-y-2",children:[n.jsxs("div",{className:"font-mono",children:["ID: ",g]}),d?n.jsx("div",{className:"whitespace-pre-wrap leading-relaxed",children:d}):h?n.jsx("pre",{className:"font-mono whitespace-pre-wrap overflow-auto max-h-48",children:h}):null]})})]}):n.jsxs("span",{title:p,className:"inline-flex items-center gap-1",children:[m.createElement(D,{className:"h-3.5 w-3.5 shrink-0 text-brand"}),n.jsx("span",{className:"text-xs text-muted-foreground",children:O()})]});let B;e[37]!==i?(B=i!==null&&n.jsx("code",{className:"text-xs font-mono text-muted-foreground break-all rounded bg-muted/60 px-1 py-0.5",children:i}),e[37]=i,e[38]=B):B=e[38];let W;e[39]!==j?(W=j!==null&&n.jsx("span",{className:"text-xs font-mono text-muted-foreground truncate max-w-[200px] sm:max-w-[320px]",title:j,children:j}),e[39]=j,e[40]=W):W=e[40];let Q;e[41]!==u?(Q=u&&n.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-muted text-muted-foreground",children:u}),e[41]=u,e[42]=Q):Q=e[42];let se;e[43]!==B||e[44]!==W||e[45]!==Q||e[46]!==F?(se=n.jsxs("div",{className:"py-1 flex items-center gap-2 flex-wrap",children:[F,B,W,Q]}),e[43]=B,e[44]=W,e[45]=Q,e[46]=F,e[47]=se):se=e[47],w=se;break e}_="mb-3 rounded-lg border border-blue-200 dark:border-blue-800 bg-blue-50 dark:bg-blue-900/20 overflow-hidden",e[48]!==a?(I=()=>l(!a),e[48]=a,e[49]=I):I=e[49],C="w-full px-3 py-2 flex items-center gap-2 text-sm font-medium text-blue-900 dark:text-blue-100 hover:bg-blue-100 dark:hover:bg-blue-900/40 transition-colors",x=p,T=m.createElement(D,{className:"h-4 w-4 text-brand"})}e[16]=i,e[17]=a,e[18]=r,e[19]=b,e[20]=v,e[21]=j,e[22]=d,e[23]=u,e[24]=g,e[25]=h,e[26]=p,e[27]=I,e[28]=C,e[29]=x,e[30]=T,e[31]=_,e[32]=w}else I=e[27],C=e[28],x=e[29],T=e[30],_=e[31],w=e[32];if(w!==Symbol.for("react.early_return_sentinel"))return w;let R;e[50]!==p?(R=Xs(p),e[50]=p,e[51]=R):R=e[51];let N;e[52]!==R?(N=n.jsx("span",{className:"flex-1 text-left min-w-0 truncate",children:R}),e[52]=R,e[53]=N):N=e[53];let y;e[54]!==u?(y=u&&n.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-blue-200 dark:bg-blue-800 text-blue-800 dark:text-blue-200",children:u}),e[54]=u,e[55]=y):y=e[55];let S;e[56]!==a?(S=a?n.jsx(It,{className:"h-4 w-4 shrink-0"}):n.jsx(Mt,{className:"h-4 w-4 shrink-0"}),e[56]=a,e[57]=S):S=e[57];let E;e[58]!==y||e[59]!==S||e[60]!==I||e[61]!==C||e[62]!==x||e[63]!==T||e[64]!==N?(E=n.jsxs("button",{onClick:I,className:C,title:x,children:[T,N,y,S]}),e[58]=y,e[59]=S,e[60]=I,e[61]=C,e[62]=x,e[63]=T,e[64]=N,e[65]=E):E=e[65];let k;e[66]!==a||e[67]!==d||e[68]!==g||e[69]!==h?(k=a&&n.jsxs("div",{className:"px-3 py-2 bg-white dark:bg-slate-950 border-t border-blue-200 dark:border-blue-800",children:[n.jsxs("div",{className:"text-xs text-muted-foreground mb-2 font-mono text-blue-700 dark:text-blue-300",children:["ID: ",g]}),d?n.jsx("div",{className:"text-xs bg-slate-100 dark:bg-slate-900 p-3 rounded whitespace-pre-wrap overflow-auto max-h-64 leading-relaxed",children:d}):h?n.jsx("pre",{className:"text-xs bg-slate-100 dark:bg-slate-900 p-2 rounded font-mono whitespace-pre-wrap overflow-auto max-h-48",children:h}):null]}),e[66]=a,e[67]=d,e[68]=g,e[69]=h,e[70]=k):k=e[70];let A;return e[71]!==E||e[72]!==k||e[73]!==_?(A=n.jsxs("div",{className:_,children:[E,k]}),e[71]=E,e[72]=k,e[73]=_,e[74]=A):A=e[74],A}function hn(s){const e=$.c(45),{block:t,inline:r}=s,[a,l]=m.useState(!1),{state:o}=Se(),i=o.projects;let c,d,u,f,g,h,p;if(e[0]!==t.result||e[1]!==t.toolCallId||e[2]!==t.toolName||e[3]!==o.projects||e[4]!==o.selectedProjectId||e[5]!==o.selectedThreadId){g=Symbol.for("react.early_return_sentinel");e:{let w;e[13]!==o.selectedProjectId?(w=E=>E.projectId===o.selectedProjectId,e[13]=o.selectedProjectId,e[14]=w):w=e[14];const y=i.find(w)?.threads.find(E=>E.threadId===o.selectedThreadId)?.path;p=t.toolName||"Unknown Tool",h=t.toolCallId||"unknown";const S=t.result;if(u=Zt(Di(S),y),d=u.length>0,!d){g=null;break e}if(c=Xs(p),typeof S=="object"&&S!==null){const E=S,k=E.returnDisplay??E.return_display;if(typeof k=="string"&&k.trim()){let A;e[15]!==k?(A=k.trim(),e[15]=k,e[16]=A):A=e[16],c=A}else if(p==="read"||p==="file_read"){const A=E.filePath||E.file_path||E.path||"";if(A){let D;e[17]!==A?(D=A.split("/").pop()||A,e[17]=A,e[18]=D):D=e[18],c=`Completed ${D}`}}}else if(S==null){let E;e[19]!==p?(E=Xs(p),e[19]=p,e[20]=E):E=e[20],c=`${E} (no result)`}f=Zt(c,y)}e[0]=t.result,e[1]=t.toolCallId,e[2]=t.toolName,e[3]=o.projects,e[4]=o.selectedProjectId,e[5]=o.selectedThreadId,e[6]=c,e[7]=d,e[8]=u,e[9]=f,e[10]=g,e[11]=h,e[12]=p}else c=e[6],d=e[7],u=e[8],f=e[9],g=e[10],h=e[11],p=e[12];if(g!==Symbol.for("react.early_return_sentinel"))return g;if(c=f,r){let w;return e[21]!==d||e[22]!==u||e[23]!==h||e[24]!==p?(w=n.jsx("div",{className:"py-1 flex items-center gap-2",children:d?n.jsxs(ea,{children:[n.jsx(ta,{asChild:!0,children:n.jsx("button",{type:"button",className:"inline-flex shrink-0 rounded p-0.5 text-muted-foreground hover:text-foreground focus:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":"Show result details",title:`${p} result`,children:n.jsx(Ss,{className:"h-3.5 w-3.5"})})}),n.jsx(fn,{className:"w-80 max-h-80 overflow-auto",align:"start",children:n.jsxs("div",{className:"text-xs space-y-2",children:[n.jsxs("div",{className:"text-muted-foreground font-mono",children:["Call ID: ",h]}),n.jsx("pre",{className:"font-mono whitespace-pre-wrap overflow-auto max-h-48 text-foreground text-left",children:u})]})})]}):n.jsx("span",{title:`${p} result`,children:n.jsx(Ss,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"})})}),e[21]=d,e[22]=u,e[23]=h,e[24]=p,e[25]=w):w=e[25],w}let j;e[26]!==a?(j=()=>l(!a),e[26]=a,e[27]=j):j=e[27];const v=`${p} result`;let b;e[28]===Symbol.for("react.memo_cache_sentinel")?(b=n.jsx(Ss,{className:"h-4 w-4 shrink-0"}),e[28]=b):b=e[28];let I;e[29]!==c?(I=n.jsx("span",{className:"flex-1 text-left min-w-0 truncate",children:c}),e[29]=c,e[30]=I):I=e[30];let C;e[31]!==a?(C=a?n.jsx(It,{className:"h-4 w-4 shrink-0"}):n.jsx(Mt,{className:"h-4 w-4 shrink-0"}),e[31]=a,e[32]=C):C=e[32];let x;e[33]!==j||e[34]!==v||e[35]!==I||e[36]!==C?(x=n.jsxs("button",{onClick:j,className:"w-full px-3 py-2 flex items-center gap-2 text-sm font-medium text-foreground hover:bg-muted transition-colors text-left",title:v,children:[b,I,C]}),e[33]=j,e[34]=v,e[35]=I,e[36]=C,e[37]=x):x=e[37];let T;e[38]!==a||e[39]!==u||e[40]!==h?(T=a&&n.jsxs("div",{className:"px-3 py-2 bg-background border-t border-border",children:[n.jsxs("div",{className:"text-xs text-muted-foreground mb-2 font-mono",children:["Call ID: ",h]}),u&&n.jsx("pre",{className:"text-xs bg-muted p-2 rounded font-mono whitespace-pre-wrap overflow-auto max-h-48 text-foreground text-left",children:u})]}),e[38]=a,e[39]=u,e[40]=h,e[41]=T):T=e[41];let _;return e[42]!==T||e[43]!==x?(_=n.jsxs("div",{className:"mb-3 rounded-lg border border-border bg-muted/50 overflow-hidden",children:[x,T]}),e[42]=T,e[43]=x,e[44]=_):_=e[44],_}function Ai({toolCall:s,className:e}){const{state:t,dispatch:r}=Se(),[a,l]=m.useState(!1),o=t.toolCallProgress[s.id];if(!m.useMemo(()=>{if(!t.isStreaming)return{isActive:!1,isCompleted:!0};let f=!1,g=!1;for(const h of t.streamingSegments)if(h.type==="thinking"){for(const p of h.chunks)if(p.includes(s.id))try{const j=JSON.parse(p);if(Array.isArray(j))for(const v of j)v.type==="tool_use"&&v.id===s.id&&(f=!0),v.type==="tool-result"&&v.toolCallId===s.id&&(g=!0,f=!1)}catch{}}return f&&!t.isStreaming&&(g=!0,f=!1),{isActive:f,isCompleted:g}},[t.isStreaming,t.streamingSegments,s.id]).isActive)return null;const c=()=>{l(f=>!f)},d=()=>{r({type:P.StopStream});const f={type:"tool-result",toolCallId:s.id,toolName:s.name,result:"Tool execution was cancelled by the user. The command was taking too long or required user approval.",isError:!0,content:"Tool execution was cancelled by the user. The command was taking too long or required user approval."};r({type:P.AppendStreamChunk,chunkType:"content",content:JSON.stringify([f]),segments:t.streamingSegments})},u=f=>JSON.stringify(f,null,2);return n.jsxs("div",{className:U("border border-blue-200 dark:border-blue-800 bg-blue-50 dark:bg-blue-900/20 rounded-lg overflow-hidden mb-2",e),children:[n.jsxs("div",{className:"px-3 py-2 flex items-center gap-2",children:[n.jsxs("div",{className:"flex items-center gap-1.5 flex-1",children:[n.jsx(ve,{className:"h-3.5 w-3.5 animate-spin"}),n.jsx("span",{className:"text-sm font-medium text-blue-900 dark:text-blue-100",children:s.name}),n.jsx("span",{className:"text-xs text-blue-700 dark:text-blue-300",children:"running"})]}),n.jsxs("div",{className:"flex items-center gap-1",children:[n.jsx("button",{onClick:c,className:"p-1 hover:bg-blue-200 dark:hover:bg-blue-800 rounded transition-colors",title:a?"Collapse":"Expand",children:a?n.jsx(Vn,{className:"h-3.5 w-3.5"}):n.jsx(It,{className:"h-3.5 w-3.5"})}),n.jsx("button",{onClick:d,className:"p-1 hover:bg-red-200 dark:hover:bg-red-800 rounded transition-colors text-red-600 dark:text-red-400",title:"Stop tool execution",children:n.jsx(ut,{className:"h-3.5 w-3.5"})})]})]}),a&&n.jsxs("div",{className:"px-3 py-2 bg-white dark:bg-slate-950 border-t border-blue-200 dark:border-blue-800 min-h-[8rem] overflow-auto",children:[n.jsxs("div",{className:"text-xs text-muted-foreground mb-2 font-mono text-blue-700 dark:text-blue-300",children:["ID: ",s.id]}),n.jsxs("div",{className:"mb-2",children:[n.jsx("div",{className:"text-xs font-medium text-muted-foreground mb-1",children:"Input:"}),n.jsx("pre",{className:"text-xs bg-slate-100 dark:bg-slate-900 p-2 rounded font-mono whitespace-pre-wrap overflow-auto max-h-48 border border-slate-200 dark:border-slate-700",children:u(s.input)})]}),o&&n.jsxs("div",{className:"mb-2",children:[n.jsx("div",{className:"text-xs font-medium text-muted-foreground mb-1",children:"Progress:"}),n.jsxs("div",{className:"text-xs bg-green-50 dark:bg-green-900/20 p-2 rounded border border-green-200 dark:border-green-800",children:[n.jsx("div",{className:"text-green-700 dark:text-green-300 font-mono",children:o.delta}),o.partial?.content?.[0]?.arguments&&typeof o.partial.content[0].arguments=="object"&&"content"in o.partial.content[0].arguments&&typeof o.partial.content[0].arguments.content=="string"&&n.jsxs("div",{className:"mt-1 text-green-600 dark:text-green-400 font-mono text-xs",children:["Building: ",o.partial.content[0].arguments.content.slice(-50),o.partial.content[0].arguments.content.length>50&&"..."]})]})]}),n.jsxs("div",{className:"flex items-center gap-2 text-xs text-blue-600 dark:text-blue-400",children:[n.jsx(ve,{className:"h-3 w-3 animate-spin"}),"Executing",o&&" with progress","..."]})]})]})}function Li(s){const e=$.c(59),{message:t}=s,r=t.sender==="user";let a,l,o,i,c,d;if(e[0]!==r||e[1]!==t.content||e[2]!==t.contentType||e[3]!==t.isThinking||e[4]!==t.metadata||e[5]!==t.model||e[6]!==t.sender||e[7]!==t.timestamp){const p=r?null:Fr(t.content);let j;e[14]!==t.timestamp?(j=t.timestamp?new Date(t.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):"",e[14]=t.timestamp,e[15]=j):j=e[15];const v=j,b=r?"flex-row-reverse":"flex-row";e[16]!==b?(c=U("group flex gap-3 px-4 py-4",b),e[16]=b,e[17]=c):c=e[17];const I=r?"bg-foreground":"bg-muted";let C;e[18]!==I?(C=U("flex h-7 w-7 shrink-0 items-center justify-center rounded-full",I),e[18]=I,e[19]=C):C=e[19];let x;e[20]!==r?(x=r?n.jsx(Ka,{className:"h-3.5 w-3.5 text-background"}):n.jsx(Kn,{className:"h-3.5 w-3.5 text-muted-foreground"}),e[20]=r,e[21]=x):x=e[21],e[22]!==C||e[23]!==x?(d=n.jsx("div",{className:C,children:x}),e[22]=C,e[23]=x,e[24]=d):d=e[24];const T=r&&"items-end";e[25]!==T?(o=U("flex flex-1 flex-col gap-1 min-w-0",T),e[25]=T,e[26]=o):o=e[26];const _=r&&"flex-row-reverse";let w;e[27]!==_?(w=U("flex items-center gap-2",_),e[27]=_,e[28]=w):w=e[28];const R=r?"You":"Agent";let N;e[29]!==R?(N=n.jsx("span",{className:"text-xs font-medium text-foreground",children:R}),e[29]=R,e[30]=N):N=e[30];let y;e[31]!==v?(y=v&&n.jsxs("span",{className:"flex items-center gap-1 text-[10px] text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity",children:[n.jsx(sn,{className:"h-2.5 w-2.5"}),v]}),e[31]=v,e[32]=y):y=e[32];let S;e[33]!==t.model?(S=t.model&&n.jsxs("span",{className:"flex items-center gap-1 text-[10px] text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity",children:[n.jsx(on,{className:"h-2.5 w-2.5"}),At(t.model)]}),e[33]=t.model,e[34]=S):S=e[34];let E;e[35]!==t.metadata?(E=t.metadata?.tokenCount&&n.jsxs("span",{className:"text-[10px] text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity",children:[t.metadata.tokenCount," tokens"]}),e[35]=t.metadata,e[36]=E):E=e[36],e[37]!==w||e[38]!==N||e[39]!==y||e[40]!==S||e[41]!==E?(i=n.jsxs("div",{className:w,children:[N,y,S,E]}),e[37]=w,e[38]=N,e[39]=y,e[40]=S,e[41]=E,e[42]=i):i=e[42];const k=r?"bg-foreground text-background":"bg-muted text-foreground";e[43]!==k?(a=U("rounded-xl px-4 py-3 flex flex-col gap-2 min-w-0",k),e[43]=k,e[44]=a):a=e[44],l=t.isThinking?(()=>{const A=Or(t.content);return A?.length?A.map(Fi):n.jsx("div",{className:"text-xs text-muted-foreground leading-relaxed whitespace-pre-wrap",children:n.jsx(_s,{content:es(t.content)})})})():p?n.jsx(n.Fragment,{children:p.map(Oi)}):t.contentType==="markdown"||t.sender==="agent"?n.jsx(_s,{content:es(t.content)}):n.jsx("p",{className:"text-sm whitespace-pre-wrap",children:t.content}),e[0]=r,e[1]=t.content,e[2]=t.contentType,e[3]=t.isThinking,e[4]=t.metadata,e[5]=t.model,e[6]=t.sender,e[7]=t.timestamp,e[8]=a,e[9]=l,e[10]=o,e[11]=i,e[12]=c,e[13]=d}else a=e[8],l=e[9],o=e[10],i=e[11],c=e[12],d=e[13];let u;e[45]!==a||e[46]!==l?(u=n.jsx("div",{className:a,children:l}),e[45]=a,e[46]=l,e[47]=u):u=e[47];let f;e[48]!==t.attachments?(f=t.attachments&&t.attachments.length>0&&n.jsx("div",{className:"flex flex-wrap gap-1.5 mt-1",children:t.attachments.map($i)}),e[48]=t.attachments,e[49]=f):f=e[49];let g;e[50]!==o||e[51]!==i||e[52]!==u||e[53]!==f?(g=n.jsxs("div",{className:o,children:[i,u,f]}),e[50]=o,e[51]=i,e[52]=u,e[53]=f,e[54]=g):g=e[54];let h;return e[55]!==c||e[56]!==d||e[57]!==g?(h=n.jsxs("div",{className:c,children:[d,g]}),e[55]=c,e[56]=d,e[57]=g,e[58]=h):h=e[58],h}function $i(s,e){return n.jsxs("span",{className:"flex items-center gap-1 rounded-md bg-muted px-2 py-1 text-[10px] text-muted-foreground",children:[n.jsx(rn,{className:"h-2.5 w-2.5"}),s.fileName]},e)}function Oi(s,e){return n.jsx("div",{children:s.type==="reasoning"&&"text"in s?n.jsx("div",{className:"text-xs text-muted-foreground leading-relaxed whitespace-pre-wrap",children:es(s.text)}):s.type==="text"&&"text"in s?n.jsx(_s,{content:es(s.text)}):s.type==="tool_use"?n.jsx(pn,{inline:!0,block:s}):s.type==="tool-result"?n.jsx(hn,{inline:!0,block:s}):null},e)}function Fi(s,e){return s.type==="tool_use"?n.jsx(pn,{inline:!0,block:s},e):s.type==="tool-result"?n.jsx(hn,{inline:!0,block:s},e):null}function Gi(s){const e=$.c(21),{segments:t,model:r}=s;let a,l,o,i,c;if(e[0]!==r||e[1]!==t){const f=Gr(t);i="group flex gap-3 px-4 py-4",e[7]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx("div",{className:"flex h-7 w-7 shrink-0 self-end items-center justify-center rounded-full bg-brand animate-radial-pulse-brand",children:n.jsx(Kn,{className:"h-3.5 w-3.5 text-white"})}),e[7]=c):c=e[7],a="flex flex-1 flex-col gap-1 min-w-0";let g;e[8]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx("span",{className:"text-xs font-medium text-foreground",children:"Agent"}),e[8]=g):g=e[8];let h;e[9]!==r?(h=r&&n.jsxs("span",{className:"flex items-center gap-1 text-[10px] text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity",children:[n.jsx(on,{className:"h-2.5 w-2.5"}),At(r)]}),e[9]=r,e[10]=h):h=e[10],e[11]!==h?(l=n.jsxs("div",{className:"flex items-center gap-2",children:[g,h]}),e[11]=h,e[12]=l):l=e[12],o=f.length>0?n.jsx("div",{className:"rounded-xl bg-muted px-4 py-3 text-foreground flex flex-col gap-2 min-w-0",children:f.map(Hi)}):n.jsx("div",{className:"rounded-xl bg-muted px-4 py-3 min-w-0",children:n.jsxs("div",{className:"flex items-center justify-center gap-1.5",children:[n.jsx("div",{className:"h-2 w-2 rounded-full bg-muted-foreground/40 animate-bounce [animation-delay:0ms]"}),n.jsx("div",{className:"h-2 w-2 rounded-full bg-muted-foreground/40 animate-bounce [animation-delay:150ms]"}),n.jsx("div",{className:"h-2 w-2 rounded-full bg-muted-foreground/40 animate-bounce [animation-delay:300ms]"})]})}),e[0]=r,e[1]=t,e[2]=a,e[3]=l,e[4]=o,e[5]=i,e[6]=c}else a=e[2],l=e[3],o=e[4],i=e[5],c=e[6];let d;e[13]!==a||e[14]!==l||e[15]!==o?(d=n.jsxs("div",{className:a,children:[l,o]}),e[13]=a,e[14]=l,e[15]=o,e[16]=d):d=e[16];let u;return e[17]!==i||e[18]!==c||e[19]!==d?(u=n.jsxs("div",{className:i,children:[c,d]}),e[17]=i,e[18]=c,e[19]=d,e[20]=u):u=e[20],u}function Hi(s,e){return n.jsx("div",{children:s.type==="reasoning"&&"text"in s?n.jsx("div",{className:"text-xs text-muted-foreground leading-relaxed whitespace-pre-wrap",children:es(s.text)}):s.type==="text"&&"text"in s?n.jsx(_s,{content:es(s.text)}):s.type==="tool_use"?n.jsxs(n.Fragment,{children:[n.jsx(Ai,{toolCall:s}),n.jsx(pn,{inline:!0,block:s})]}):s.type==="tool-result"?n.jsx(hn,{inline:!0,block:s}):null},`b-${e}`)}const Ui=m.memo(Gi,(s,e)=>{if(s.model!==e.model||s.segments.length!==e.segments.length)return!1;for(let t=0;t<s.segments.length;t++){if(s.segments[t].type!==e.segments[t].type||s.segments[t].chunks.length!==e.segments[t].chunks.length)return!1;for(let r=0;r<s.segments[t].chunks.length;r++)if(s.segments[t].chunks[r]!==e.segments[t].chunks[r])return!1}return!0});function zi(s){const e=$.c(28),{projects:t,onSelectProject:r,onCreateThread:a,onConnectRepo:l,onNewApp:o}=s;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx("div",{className:"flex h-14 w-14 items-center justify-center rounded-2xl border border-border bg-background shadow-sm",children:n.jsxs("svg",{width:"28",height:"28",viewBox:"0 0 28 28",fill:"none",className:"text-foreground",children:[n.jsx("path",{d:"M14 4C8.477 4 4 8.477 4 14s4.477 10 10 10 10-4.477 10-10S19.523 4 14 4z",stroke:"currentColor",strokeWidth:"1.5",fill:"none"}),n.jsx("path",{d:"M10 12.5c0-.828.672-1.5 1.5-1.5s1.5.672 1.5 1.5M15 12.5c0-.828.672-1.5 1.5-1.5s1.5.672 1.5 1.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),n.jsx("path",{d:"M10.5 17c.833 1 2.167 1.5 3.5 1.5s2.667-.5 3.5-1.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})}),e[0]=i):i=e[0];let c;e[1]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx("h1",{className:"text-2xl font-semibold tracking-tight text-foreground text-balance",children:"Let's build"}),e[1]=c):c=e[1];const d=t.length===0?"Start or connect your first project":"Select a project to start coding";let u;e[2]!==d?(u=n.jsxs("div",{className:"flex flex-col items-center gap-3",children:[i,n.jsxs("div",{className:"text-center",children:[c,n.jsx("p",{className:"mt-1 text-base text-muted-foreground",children:d})]})]}),e[2]=d,e[3]=u):u=e[3];let f;if(e[4]!==a||e[5]!==r||e[6]!==t){let _;e[8]!==a||e[9]!==r?(_=w=>n.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:()=>{w.threads.length===0?a(w.projectId):r(w.projectId,w.threads[0].threadId)},children:[n.jsx(Hn,{className:"h-5 w-5 text-muted-foreground"}),n.jsx("span",{className:"text-sm text-foreground leading-snug font-medium",children:w.name}),n.jsxs("span",{className:"text-xs text-muted-foreground",children:[w.threads.length," thread",w.threads.length!==1?"s":""]})]},w.projectId),e[8]=a,e[9]=r,e[10]=_):_=e[10],f=t.map(_),e[4]=a,e[5]=r,e[6]=t,e[7]=f}else f=e[7];let g,h,p;e[11]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx(gs,{className:"h-5 w-5 text-muted-foreground"}),h=n.jsx("span",{className:"text-sm text-foreground leading-snug font-medium",children:"Connect a repo"}),p=n.jsx("span",{className:"text-xs text-muted-foreground",children:"Clone an existing repository"}),e[11]=g,e[12]=h,e[13]=p):(g=e[11],h=e[12],p=e[13]);let j;e[14]!==l?(j=n.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:l,children:[g,h,p]}),e[14]=l,e[15]=j):j=e[15];let v,b,I;e[16]===Symbol.for("react.memo_cache_sentinel")?(v=n.jsx(Jn,{className:"h-5 w-5 text-muted-foreground"}),b=n.jsx("span",{className:"text-sm text-foreground leading-snug font-medium",children:"New App"}),I=n.jsx("span",{className:"text-xs text-muted-foreground",children:"Create a new project from template"}),e[16]=v,e[17]=b,e[18]=I):(v=e[16],b=e[17],I=e[18]);let C;e[19]!==o?(C=n.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,b,I]}),e[19]=o,e[20]=C):C=e[20];let x;e[21]!==C||e[22]!==f||e[23]!==j?(x=n.jsxs("div",{className:"flex flex-wrap justify-center gap-3",children:[f,j,C]}),e[21]=C,e[22]=f,e[23]=j,e[24]=x):x=e[24];let T;return e[25]!==x||e[26]!==u?(T=n.jsxs("div",{className:"mx-auto flex max-w-3xl flex-1 flex-col items-center justify-center gap-8 px-4",children:[u,x]}),e[25]=x,e[26]=u,e[27]=T):T=e[27],T}function Bi(s){const e=$.c(32),{messages:t,isStreaming:r,streamingSegments:a,streamingModel:l,isCreatingProject:o,isProcessingThread:i,selectedThreadId:c,projects:d,onSelectThread:u,onCreateThread:f,onConnectRepo:g,onNewApp:h,error:p,onClearError:j}=s,v=m.useRef(null);let b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b=()=>{v.current&&(v.current.scrollTop=v.current.scrollHeight)},e[0]=b):b=e[0];let I;e[1]!==t||e[2]!==a?(I=[t,a],e[1]=t,e[2]=a,e[3]=I):I=e[3],m.useEffect(b,I);const C=t.length===0&&!r&&!o&&!c,x=C&&"flex flex-col items-center justify-center";let T;e[4]!==x?(T=U("flex-1 overflow-y-auto",x),e[4]=x,e[5]=T):T=e[5];let _;e[6]!==g||e[7]!==f||e[8]!==h||e[9]!==u||e[10]!==d||e[11]!==C?(_=C&&n.jsx(zi,{projects:d,onSelectProject:u,onCreateThread:f,onConnectRepo:g,onNewApp:h}),e[6]=g,e[7]=f,e[8]=h,e[9]=u,e[10]=d,e[11]=C,e[12]=_):_=e[12];let w;e[13]!==t?(w=t.map(qi),e[13]=t,e[14]=w):w=e[14];let R;e[15]!==o||e[16]!==i||e[17]!==r||e[18]!==l||e[19]!==a?(R=(r||o||i)&&n.jsx(Ui,{segments:a,model:l}),e[15]=o,e[16]=i,e[17]=r,e[18]=l,e[19]=a,e[20]=R):R=e[20];let N;e[21]!==p||e[22]!==j?(N=p&&n.jsxs("div",{className:"mx-4 my-2 rounded-lg border border-destructive/30 bg-destructive/5 px-4 py-3",children:[n.jsx("p",{className:"text-sm text-destructive",children:p}),n.jsx("button",{type:"button",className:"mt-1 text-xs text-destructive underline underline-offset-2 hover:text-destructive/80",onClick:j,children:"Dismiss"})]}),e[21]=p,e[22]=j,e[23]=N):N=e[23];let y;e[24]!==w||e[25]!==R||e[26]!==N?(y=n.jsxs("div",{className:"mx-auto max-w-3xl pb-4 w-full min-w-0",children:[w,R,N]}),e[24]=w,e[25]=R,e[26]=N,e[27]=y):y=e[27];let S;return e[28]!==T||e[29]!==_||e[30]!==y?(S=n.jsxs("div",{ref:v,className:T,children:[_,y]}),e[28]=T,e[29]=_,e[30]=y,e[31]=S):S=e[31],S}function qi(s){return n.jsx(Li,{message:s},s.messageId)}function Wi({branchName:s,threadId:e}){const[t,r]=m.useState(""),[a,l]=m.useState(!1);m.useEffect(()=>{let i=!0;if(s)return no().then(c=>{i&&r(c)}).catch(()=>{}),()=>{i=!1}},[s]);const o=async()=>{if(!(!e||a)){l(!0);try{const i=await mo(e);await navigator.clipboard.writeText(i)}finally{l(!1)}}};return n.jsxs("div",{className:"flex items-center justify-end gap-2 px-8 py-2 mt-[-1rem] min-h-[2.25rem]",children:[e&&n.jsxs(fe,{children:[n.jsx(pe,{asChild:!0,children:n.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6 opacity-50 hover:opacity-80",onClick:o,disabled:a,"aria-label":"Copy repository folder path",children:n.jsx(Ja,{className:"h-3 w-3"})})}),n.jsx(me,{side:"top",className:"bg-slate-900 text-white",children:"Copy path to repository history folder"})]}),s&&n.jsxs(fe,{children:[n.jsx(pe,{asChild:!0,children:n.jsxs("div",{className:"flex items-center gap-1.5 opacity-50 cursor-help",children:[n.jsx(gs,{className:"h-3 w-3"}),n.jsx("span",{className:"text-[11px] font-medium tracking-tight",children:s})]})}),t&&n.jsxs(me,{side:"top",className:"bg-slate-900 text-white",children:["User: ",t]})]})]})}function Vi(){const s=Se().state,{selectedProjectId:e,selectedThreadId:t}=s,{terminalState:r,dispatch:a}=ys(t),{open:l,queuedCommand:o,outputLines:i,height:c,history:d,historyIndex:u,cwd:f,isRunning:g}=r,[h,p]=m.useState(""),[j,v]=m.useState([]),[b,I]=m.useState(!1),[C,x]=m.useState(!1),T=s.projects.flatMap(L=>L.threads).find(L=>L.threadId===t)?.path??null,_=!f||f==="."||f==="./"?T:f,w=m.useCallback(()=>{navigator.clipboard.writeText("terminal").then(()=>{x(!0),setTimeout(()=>x(!1),1500)})},[]),R=!_||_===T,N=m.useRef(null),y=m.useRef(null),S=m.useRef(null),E=m.useRef(0),k=m.useCallback(L=>{L.preventDefault(),I(!0)},[]),A=m.useCallback(()=>{I(!1)},[]),D=m.useCallback(L=>{if(b&&S.current){const B=S.current.getBoundingClientRect().bottom-L.clientY;B>=150&&B<=window.innerHeight*.8&&a({type:P.SetTerminalHeight,height:B})}},[b,a]);m.useEffect(()=>(b?(window.addEventListener("mousemove",D),window.addEventListener("mouseup",A),document.body.style.cursor="ns-resize",document.body.style.userSelect="none"):(window.removeEventListener("mousemove",D),window.removeEventListener("mouseup",A),document.body.style.cursor="",document.body.style.userSelect=""),()=>{window.removeEventListener("mousemove",D),window.removeEventListener("mouseup",A)}),[b,D,A]),m.useEffect(()=>{N.current&&(N.current.scrollTop=N.current.scrollHeight)},[j]),m.useEffect(()=>{v(i),E.current=i.length},[t,i]),m.useEffect(()=>{if(i.length===0)v([]),E.current=0;else if(i.length>E.current){const L=i.slice(E.current);v(F=>[...F,...L]),E.current=i.length}},[i]),m.useEffect(()=>{l&&!g&&y.current?.focus()},[l,g]);const z=m.useCallback(async L=>{if(!(!e||!t||!L.trim())){a({type:P.AppendTerminalLine,line:{type:"input",content:L}}),a({type:P.SetTerminalHistory,history:[L,...d.filter(F=>F!==L)].slice(0,50)}),a({type:P.SetTerminalHistoryIndex,index:-1}),p(""),a({type:P.SetTerminalRunning,isRunning:!0});try{const F=await _o(e,t,L,f);if(!F){a({type:P.AppendTerminalLine,line:{type:"system",content:"Command started but no output stream received."}}),a({type:P.SetTerminalRunning,isRunning:!1});return}const B=F.getReader(),W=new TextDecoder;let Q="";for(;;){const{done:se,value:de}=await B.read();if(se)break;Q+=W.decode(de,{stream:!0});const ie=Q.split(`
|
|
10
|
+
`);Q=ie.pop()||"";for(const re of ie)if(re.trim())try{const ae=JSON.parse(re);typeof ae=="string"?a({type:P.AppendTerminalLine,line:{type:"output",content:ae}}):ae.type==="error"?a({type:P.AppendTerminalLine,line:{type:"error",content:ae.message}}):ae.type==="cwd"&&a({type:P.SetTerminalCwd,cwd:ae.path})}catch{a({type:P.AppendTerminalLine,line:{type:"output",content:re}})}}if(Q.trim())try{const se=JSON.parse(Q);typeof se=="string"?a({type:P.AppendTerminalLine,line:{type:"output",content:se}}):se.type==="error"?a({type:P.AppendTerminalLine,line:{type:"error",content:se.message}}):se.type==="cwd"&&a({type:P.SetTerminalCwd,cwd:se.path})}catch{a({type:P.AppendTerminalLine,line:{type:"output",content:Q}})}}catch(F){a({type:P.AppendTerminalLine,line:{type:"error",content:F instanceof Error?F.message:"Failed to run command"}})}finally{a({type:P.SetTerminalRunning,isRunning:!1})}}},[e,t,f,a,d]);m.useEffect(()=>{o&&!g&&(z(o),a({type:P.ClearQueuedTerminalCommand}))},[o,g,a,z]);const O=L=>{if(L.key==="Enter")z(h);else if(L.key==="ArrowUp"){L.preventDefault();const F=u+1;F<d.length&&(a({type:P.SetTerminalHistoryIndex,index:F}),p(d[F]))}else if(L.key==="ArrowDown"){L.preventDefault();const F=u-1;F>=0?(a({type:P.SetTerminalHistoryIndex,index:F}),p(d[F])):(a({type:P.SetTerminalHistoryIndex,index:-1}),p(""))}};return l?n.jsxs("div",{ref:S,className:"flex flex-col border-t border-border bg-neutral-950 text-neutral-200 font-mono text-sm overflow-hidden animate-in slide-in-from-bottom-2 relative",style:{height:`${c}px`},children:[n.jsx("div",{className:"absolute top-0 left-0 right-0 h-1 cursor-ns-resize hover:bg-primary/50 transition-colors z-50",onMouseDown:k}),n.jsxs("div",{className:"flex items-center justify-between px-4 py-1.5 border-b border-white/10 bg-white/5",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(ds,{className:"h-3.5 w-3.5 text-neutral-400"}),n.jsx(we,{children:n.jsxs(fe,{children:[n.jsx(pe,{asChild:!0,children:n.jsx("span",{className:"text-xs font-medium text-neutral-400 cursor-pointer hover:text-neutral-200 transition-colors select-none",onClick:w,children:C?"Copied!":"Terminal"})}),n.jsx(me,{side:"bottom",children:n.jsx("span",{className:"font-mono text-xs",children:_||"/"})})]})}),!R&&n.jsx("span",{className:"text-[10px] text-neutral-500 font-mono bg-white/5 px-1.5 py-0.5 rounded border border-white/5",children:_}),g&&n.jsxs("div",{className:"flex gap-1 items-center ml-2",children:[n.jsx("div",{className:"h-1 w-1 rounded-full bg-primary animate-pulse"}),n.jsx("span",{className:"text-[10px] text-neutral-500 italic",children:"processing..."})]})]}),n.jsx("div",{className:"flex items-center gap-1",children:n.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6 text-neutral-500 hover:text-neutral-200 hover:bg-white/10",onClick:()=>a({type:P.ToggleTerminal}),children:n.jsx(ut,{className:"h-3.5 w-3.5"})})})]}),n.jsxs("div",{ref:N,className:"flex-1 overflow-y-auto p-4 space-y-0.5 terminal-scrollbar",onClick:L=>{L.target===L.currentTarget&&y.current?.focus()},children:[j.length===0&&!g&&n.jsx("div",{className:"text-neutral-600 italic text-xs",children:"Enter your commands below..."}),j.map((L,F)=>n.jsxs("div",{className:`whitespace-pre-wrap break-all leading-6 ${L.type==="input"?"flex items-start gap-2 text-neutral-200":L.type==="error"?"text-red-400":L.type==="system"?"text-blue-400":""}`,children:[L.type==="input"&&n.jsx(Mt,{className:"h-4 w-4 mt-1 shrink-0 text-blue-400/70"}),n.jsx("span",{children:L.content})]},F))]}),n.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 border-t border-white/5 bg-white/5",children:[!R&&n.jsx("span",{className:"text-blue-400 text-xs font-bold whitespace-nowrap",children:_.split("/").pop()}),n.jsx(Mt,{className:`h-4 w-4 text-blue-400 ${R?"":"-ml-1"}`}),n.jsx("input",{ref:y,type:"text",className:"flex-1 bg-transparent border-none outline-none text-neutral-200 placeholder:text-neutral-700 h-6",placeholder:g?"Running...":"Type a command...",value:h,onChange:L=>p(L.target.value),onKeyDown:O,disabled:g}),n.jsxs("div",{className:"flex items-center gap-1 px-1.5 py-0.5 rounded border border-white/10 bg-white/5",children:[n.jsx(Qa,{className:"h-3 w-3 text-neutral-600"}),n.jsx("span",{className:"text-[10px] text-neutral-600 uppercase font-bold",children:"Enter"})]})]})]}):null}function Ki({threadId:s,onExit:e}){const{state:t}=Se(),[r,a]=m.useState([]),[l,o]=m.useState(!0),[i,c]=m.useState(null),[d,u]=m.useState(0),[f,g]=m.useState(!1),h=m.useCallback(async()=>{if(s){o(!0),c(null);try{const N=await Oo(s);a(N.files||[]),u(0)}catch(N){c(N instanceof Error?N.message:"Failed to load diff")}finally{o(!1)}}},[s]);m.useEffect(()=>{h()},[h]);const p=N=>{if(N.hunks.length===0)return null;let y=1/0,S=0;return N.hunks.forEach(E=>{const k=Math.min(E.oldStart,E.newStart),A=E.oldStart+E.oldLines,D=E.newStart+E.newLines,z=Math.max(A,D);y=Math.min(y,k),S=Math.max(S,z)}),y===1/0?null:{startLine:Math.max(1,y-2),endLine:S+2}},j=(N,y,S)=>N.split(`
|
|
11
|
+
`).slice(y-1,S).join(`
|
|
12
|
+
`),v=N=>{const y=p(N);return y?y.startLine<=1:!0},b=N=>{const y=N.split(".").pop()||"";return{ts:"typescript",tsx:"typescript",js:"javascript",jsx:"javascript",json:"json",md:"markdown",css:"css",scss:"scss",html:"html",py:"python",rb:"ruby",go:"go",rs:"rust",java:"java",kt:"kotlin",swift:"swift",c:"c",cpp:"cpp",h:"c",hpp:"cpp",sh:"shell",yaml:"yaml",yml:"yaml",xml:"xml",sql:"sql"}[y]||"plaintext"},I=N=>{switch(N){case"added":return n.jsx("span",{className:"status-badge font-mono text-xs font-semibold text-green-500",children:"A"});case"deleted":return n.jsx("span",{className:"status-badge font-mono text-xs font-semibold text-red-500",children:"D"});case"untracked":return n.jsx("span",{className:"status-badge font-mono text-xs font-semibold text-green-500",children:"U"});case"renamed":return n.jsx("span",{className:"status-badge font-mono text-xs font-semibold text-blue-500",children:"R"});default:return n.jsx("span",{className:"status-badge font-mono text-xs font-semibold text-orange-500",children:"M"})}},C=m.useMemo(()=>r.map(N=>{let y=0,S=0;return N.hunks.forEach(E=>{E.changes.forEach(k=>{k.type==="add"&&y++,k.type==="delete"&&S++})}),{additions:y,deletions:S}}),[r]),x=r[d],T=x?f?x.oldContent:(()=>{const N=p(x);return N?j(x.oldContent,N.startLine,N.endLine):x.oldContent})():"",_=x?f?x.newContent:(()=>{const N=p(x);return N?j(x.newContent,N.startLine,N.endLine):x.newContent})():"",w=m.useMemo(()=>C.reduce((N,y)=>N+y.additions,0),[C]),R=m.useMemo(()=>C.reduce((N,y)=>N+y.deletions,0),[C]);return l?n.jsx("div",{className:"flex h-full items-center justify-center",children:n.jsx(ve,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):i?n.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-4",children:[n.jsx("p",{className:"text-destructive",children:i}),n.jsx(K,{variant:"outline",onClick:e,children:"Go Back"})]}):r.length===0?n.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-4",children:[n.jsx("p",{className:"text-muted-foreground",children:"No changes to review"}),n.jsx(K,{variant:"outline",onClick:e,children:"Go Back"})]}):n.jsxs("div",{className:"diff-view-root flex h-full flex-col",children:[n.jsxs("div",{className:"diff-toolbar flex h-12 shrink-0 items-center justify-between border-b border-border bg-background px-4",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(K,{variant:"ghost",size:"icon",onClick:e,className:"h-8 w-8",children:n.jsx(ut,{className:"h-4 w-4"})}),n.jsx("span",{className:"text-sm font-medium",children:"Review Changes"}),n.jsxs("span",{className:"text-xs text-muted-foreground",children:[r.length," file",r.length!==1?"s":""]}),n.jsxs("span",{className:"text-xs text-green-500",children:["+",w]}),n.jsxs("span",{className:"text-xs text-red-500",children:["-",R]})]}),x&&n.jsx(K,{variant:"ghost",size:"sm",onClick:()=>g(N=>!N),className:"h-8 gap-1 px-2 text-xs",children:f?n.jsxs(n.Fragment,{children:[n.jsx(Ya,{className:"h-3 w-3"})," Show changes only"]}):n.jsxs(n.Fragment,{children:[n.jsx(Xa,{className:"h-3 w-3"})," Show full file"]})})]}),n.jsxs("div",{className:"diff-body flex flex-1 overflow-hidden",children:[n.jsx("div",{className:"diff-file-list flex w-64 shrink-0 flex-col border-r border-border",children:n.jsx(Ve,{className:"flex-1",children:n.jsx("div",{className:"p-2 space-y-0.5",children:r.map((N,y)=>n.jsx("button",{onClick:()=>u(y),className:U("file-list-item w-full rounded-md px-2 py-2 text-left transition-colors hover:bg-accent",d===y&&"bg-accent"),children:n.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[n.jsx("span",{className:"file-name truncate text-xs font-medium flex-1 min-w-0",children:N.path}),I(N.status)]})},N.path))})})}),n.jsx("div",{className:"diff-editor-panel flex flex-1 flex-col overflow-hidden",children:x?n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"diff-editor-header flex h-9 shrink-0 items-center border-b border-border bg-muted/40 px-4 gap-2",children:[I(x.status),n.jsx("span",{className:"text-xs font-medium truncate",children:x.path}),x.oldPath&&n.jsxs("span",{className:"text-xs text-muted-foreground truncate",children:["← ",x.oldPath]})]}),n.jsx("div",{className:"flex-1 overflow-hidden",children:n.jsx(Za,{original:T,modified:_,language:b(x.path),theme:t.sidebarOpen?"vs":"vs-dark",options:{readOnly:!0,renderSideBySide:!0,ignoreTrimWhitespace:!1,renderOverviewRuler:!0,scrollBeyondLastLine:!1,minimap:{enabled:!1},folding:!1,lineNumbers:f||v(x)?"on":"off",diffWordWrap:"on",originalEditable:!1,automaticLayout:!0}})})]}):null})]})]})}const us=m.forwardRef((s,e)=>{const t=$.c(9);let r,a;t[0]!==s?({className:r,...a}=s,t[0]=s,t[1]=r,t[2]=a):(r=t[1],a=t[2]);let l;t[3]!==r?(l=U("rounded-lg border bg-card text-card-foreground shadow-sm",r),t[3]=r,t[4]=l):l=t[4];let o;return t[5]!==a||t[6]!==e||t[7]!==l?(o=n.jsx("div",{ref:e,className:l,...a}),t[5]=a,t[6]=e,t[7]=l,t[8]=o):o=t[8],o});us.displayName="Card";const Zs=m.forwardRef((s,e)=>{const t=$.c(9);let r,a;t[0]!==s?({className:r,...a}=s,t[0]=s,t[1]=r,t[2]=a):(r=t[1],a=t[2]);let l;t[3]!==r?(l=U("flex flex-col space-y-1.5 p-6",r),t[3]=r,t[4]=l):l=t[4];let o;return t[5]!==a||t[6]!==e||t[7]!==l?(o=n.jsx("div",{ref:e,className:l,...a}),t[5]=a,t[6]=e,t[7]=l,t[8]=o):o=t[8],o});Zs.displayName="CardHeader";const en=m.forwardRef((s,e)=>{const t=$.c(9);let r,a;t[0]!==s?({className:r,...a}=s,t[0]=s,t[1]=r,t[2]=a):(r=t[1],a=t[2]);let l;t[3]!==r?(l=U("text-2xl font-semibold leading-none tracking-tight",r),t[3]=r,t[4]=l):l=t[4];let o;return t[5]!==a||t[6]!==e||t[7]!==l?(o=n.jsx("div",{ref:e,className:l,...a}),t[5]=a,t[6]=e,t[7]=l,t[8]=o):o=t[8],o});en.displayName="CardTitle";const Ji=m.forwardRef((s,e)=>{const t=$.c(9);let r,a;t[0]!==s?({className:r,...a}=s,t[0]=s,t[1]=r,t[2]=a):(r=t[1],a=t[2]);let l;t[3]!==r?(l=U("text-sm text-muted-foreground",r),t[3]=r,t[4]=l):l=t[4];let o;return t[5]!==a||t[6]!==e||t[7]!==l?(o=n.jsx("div",{ref:e,className:l,...a}),t[5]=a,t[6]=e,t[7]=l,t[8]=o):o=t[8],o});Ji.displayName="CardDescription";const ms=m.forwardRef((s,e)=>{const t=$.c(9);let r,a;t[0]!==s?({className:r,...a}=s,t[0]=s,t[1]=r,t[2]=a):(r=t[1],a=t[2]);let l;t[3]!==r?(l=U("p-6 pt-0",r),t[3]=r,t[4]=l):l=t[4];let o;return t[5]!==a||t[6]!==e||t[7]!==l?(o=n.jsx("div",{ref:e,className:l,...a}),t[5]=a,t[6]=e,t[7]=l,t[8]=o):o=t[8],o});ms.displayName="CardContent";const Qi=m.forwardRef((s,e)=>{const t=$.c(9);let r,a;t[0]!==s?({className:r,...a}=s,t[0]=s,t[1]=r,t[2]=a):(r=t[1],a=t[2]);let l;t[3]!==r?(l=U("flex items-center p-6 pt-0",r),t[3]=r,t[4]=l):l=t[4];let o;return t[5]!==a||t[6]!==e||t[7]!==l?(o=n.jsx("div",{ref:e,className:l,...a}),t[5]=a,t[6]=e,t[7]=l,t[8]=o):o=t[8],o});Qi.displayName="CardFooter";const Ke=m.forwardRef((s,e)=>{const t=$.c(11);let r,a,l;t[0]!==s?({className:r,type:l,...a}=s,t[0]=s,t[1]=r,t[2]=a,t[3]=l):(r=t[1],a=t[2],l=t[3]);let o;t[4]!==r?(o=U("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground 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 md:text-sm",r),t[4]=r,t[5]=o):o=t[5];let i;return t[6]!==a||t[7]!==e||t[8]!==o||t[9]!==l?(i=n.jsx("input",{type:l,className:o,ref:e,...a}),t[6]=a,t[7]=e,t[8]=o,t[9]=l,t[10]=i):i=t[10],i});Ke.displayName="Input";const mt=sl,Yi=el,sa=m.forwardRef((s,e)=>{const t=$.c(9);let r,a;t[0]!==s?({className:r,...a}=s,t[0]=s,t[1]=r,t[2]=a):(r=t[1],a=t[2]);let l;t[3]!==r?(l=U("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",r),t[3]=r,t[4]=l):l=t[4];let o;return t[5]!==a||t[6]!==e||t[7]!==l?(o=n.jsx(Qn,{ref:e,className:l,...a}),t[5]=a,t[6]=e,t[7]=l,t[8]=o):o=t[8],o});sa.displayName=Qn.displayName;const Je=m.forwardRef((s,e)=>{const t=$.c(13);let r,a,l;t[0]!==s?({className:a,children:r,...l}=s,t[0]=s,t[1]=r,t[2]=a,t[3]=l):(r=t[1],a=t[2],l=t[3]);let o;t[4]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx(sa,{}),t[4]=o):o=t[4];let i;t[5]!==a?(i=U("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 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-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",a),t[5]=a,t[6]=i):i=t[6];let c;t[7]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsxs(tl,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[n.jsx(ut,{className:"h-4 w-4"}),n.jsx("span",{className:"sr-only",children:"Close"})]}),t[7]=c):c=t[7];let d;return t[8]!==r||t[9]!==l||t[10]!==e||t[11]!==i?(d=n.jsxs(Yi,{children:[o,n.jsxs(Yn,{ref:e,className:i,...l,children:[r,c]})]}),t[8]=r,t[9]=l,t[10]=e,t[11]=i,t[12]=d):d=t[12],d});Je.displayName=Yn.displayName;const Qe=s=>{const e=$.c(8);let t,r;e[0]!==s?({className:t,...r}=s,e[0]=s,e[1]=t,e[2]=r):(t=e[1],r=e[2]);let a;e[3]!==t?(a=U("flex flex-col space-y-1.5 text-center sm:text-left",t),e[3]=t,e[4]=a):a=e[4];let l;return e[5]!==r||e[6]!==a?(l=n.jsx("div",{className:a,...r}),e[5]=r,e[6]=a,e[7]=l):l=e[7],l};Qe.displayName="DialogHeader";const Ye=s=>{const e=$.c(8);let t,r;e[0]!==s?({className:t,...r}=s,e[0]=s,e[1]=t,e[2]=r):(t=e[1],r=e[2]);let a;e[3]!==t?(a=U("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),e[3]=t,e[4]=a):a=e[4];let l;return e[5]!==r||e[6]!==a?(l=n.jsx("div",{className:a,...r}),e[5]=r,e[6]=a,e[7]=l):l=e[7],l};Ye.displayName="DialogFooter";const Ge=m.forwardRef((s,e)=>{const t=$.c(9);let r,a;t[0]!==s?({className:r,...a}=s,t[0]=s,t[1]=r,t[2]=a):(r=t[1],a=t[2]);let l;t[3]!==r?(l=U("text-lg font-semibold leading-none tracking-tight",r),t[3]=r,t[4]=l):l=t[4];let o;return t[5]!==a||t[6]!==e||t[7]!==l?(o=n.jsx(Xn,{ref:e,className:l,...a}),t[5]=a,t[6]=e,t[7]=l,t[8]=o):o=t[8],o});Ge.displayName=Xn.displayName;const He=m.forwardRef((s,e)=>{const t=$.c(9);let r,a;t[0]!==s?({className:r,...a}=s,t[0]=s,t[1]=r,t[2]=a):(r=t[1],a=t[2]);let l;t[3]!==r?(l=U("text-sm text-muted-foreground",r),t[3]=r,t[4]=l):l=t[4];let o;return t[5]!==a||t[6]!==e||t[7]!==l?(o=n.jsx(Zn,{ref:e,className:l,...a}),t[5]=a,t[6]=e,t[7]=l,t[8]=o):o=t[8],o});He.displayName=Zn.displayName;const Xi=js("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),be=m.forwardRef((s,e)=>{const t=$.c(9);let r,a;t[0]!==s?({className:r,...a}=s,t[0]=s,t[1]=r,t[2]=a):(r=t[1],a=t[2]);let l;t[3]!==r?(l=U(Xi(),r),t[3]=r,t[4]=l):l=t[4];let o;return t[5]!==a||t[6]!==e||t[7]!==l?(o=n.jsx(er,{ref:e,className:l,...a}),t[5]=a,t[6]=e,t[7]=l,t[8]=o):o=t[8],o});be.displayName=er.displayName;const na=js("inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors hover:bg-muted hover:text-muted-foreground 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=on]:bg-accent data-[state=on]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 gap-2",{variants:{variant:{default:"bg-transparent",outline:"border border-input bg-transparent hover:bg-accent hover:text-accent-foreground"},size:{default:"h-10 px-3 min-w-10",sm:"h-9 px-2.5 min-w-9",lg:"h-11 px-5 min-w-11"}},defaultVariants:{variant:"default",size:"default"}}),Zi=m.forwardRef((s,e)=>{const t=$.c(13);let r,a,l,o;t[0]!==s?({className:r,variant:o,size:l,...a}=s,t[0]=s,t[1]=r,t[2]=a,t[3]=l,t[4]=o):(r=t[1],a=t[2],l=t[3],o=t[4]);let i;t[5]!==r||t[6]!==l||t[7]!==o?(i=U(na({variant:o,size:l,className:r})),t[5]=r,t[6]=l,t[7]=o,t[8]=i):i=t[8];let c;return t[9]!==a||t[10]!==e||t[11]!==i?(c=n.jsx(tr,{ref:e,className:i,...a}),t[9]=a,t[10]=e,t[11]=i,t[12]=c):c=t[12],c});Zi.displayName=tr.displayName;const ra=m.createContext({size:"default",variant:"default"}),os=m.forwardRef((s,e)=>{const t=$.c(19);let r,a,l,o,i;t[0]!==s?({className:a,variant:i,size:o,children:r,...l}=s,t[0]=s,t[1]=r,t[2]=a,t[3]=l,t[4]=o,t[5]=i):(r=t[1],a=t[2],l=t[3],o=t[4],i=t[5]);let c;t[6]!==a?(c=U("flex items-center justify-center gap-1",a),t[6]=a,t[7]=c):c=t[7];let d;t[8]!==o||t[9]!==i?(d={variant:i,size:o},t[8]=o,t[9]=i,t[10]=d):d=t[10];let u;t[11]!==r||t[12]!==d?(u=n.jsx(ra.Provider,{value:d,children:r}),t[11]=r,t[12]=d,t[13]=u):u=t[13];let f;return t[14]!==l||t[15]!==e||t[16]!==c||t[17]!==u?(f=n.jsx(sr,{ref:e,className:c,...l,children:u}),t[14]=l,t[15]=e,t[16]=c,t[17]=u,t[18]=f):f=t[18],f});os.displayName=sr.displayName;const Pt=m.forwardRef((s,e)=>{const t=$.c(17);let r,a,l,o,i;t[0]!==s?({className:a,children:r,variant:i,size:o,...l}=s,t[0]=s,t[1]=r,t[2]=a,t[3]=l,t[4]=o,t[5]=i):(r=t[1],a=t[2],l=t[3],o=t[4],i=t[5]);const c=m.useContext(ra);let d;t[6]!==a||t[7]!==c.size||t[8]!==c.variant||t[9]!==o||t[10]!==i?(d=U(na({variant:c.variant||i,size:c.size||o}),a),t[6]=a,t[7]=c.size,t[8]=c.variant,t[9]=o,t[10]=i,t[11]=d):d=t[11];let u;return t[12]!==r||t[13]!==l||t[14]!==e||t[15]!==d?(u=n.jsx(nr,{ref:e,className:d,...l,children:r}),t[12]=r,t[13]=l,t[14]=e,t[15]=d,t[16]=u):u=t[16],u});Pt.displayName=nr.displayName;const ec={"VS Code":{name:"VS Code",appName:["Visual Studio Code","code"]},Cursor:{name:"Cursor",appName:["Cursor","cursor"]},Windsurf:{name:"Windsurf",appName:["Windsurf","windsurf"]},Xcode:{name:"Xcode",appName:"Xcode"},"Android Studio":{name:"Android Studio",appName:["Android Studio","studio"]},Kiro:{name:"Kiro",appName:["Kiro","kiro"]},Terminal:{name:"Terminal",appName:"Terminal"}};Object.entries(ec).reduce((s,[e,t])=>(s[e]=t.appName,s),{});var he;(function(s){s.PullRequest="pull-request",s.Direct="direct"})(he||(he={}));he.PullRequest+"",he.PullRequest,he.Direct+"",he.Direct;const tc={bun:{id:"bun",label:"bun"},npm:{id:"npm",label:"npm"},yarn:{id:"yarn",label:"yarn"},pnpm:{id:"pnpm",label:"pnpm"}},sc={"angular-standalone":"logo-angular.svg","custom-angular":"logo-angular.svg",react:"logo-react.svg","vite-react":"logo-react.svg",vue:"logo-vue.svg","vite-vue":"logo-vue.svg","custom-svelte":"logo-svelte.svg","custom-ionic-svelte":"logo-svelte.svg","vite-svelte":"logo-svelte.svg","vite-solid":"logo-solid.svg",astro:"logo-astro.svg",nextjs:"logo-nextjs.svg",nuxt:"logo-nuxt.svg","vite-qwik":"logo-qwik.svg","vite-preact":"logo-preact.svg","vite-lit":"logo-lit.svg","vite-web":"logo-web.svg","tanstack-start":"logo-vite.svg",waku:"logo-waku.svg",hydrogen:"logo-hydrogen.svg",plugin:"logo-capacitor.svg"};function aa(s){const e=$.c(184),{open:t,onOpenChange:r,initialMode:a,onSubmitClone:l,onSubmitWebApp:o}=s,[i,c]=m.useState(a||"choice"),[d,u]=m.useState(1),[f,g]=m.useState("");let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=Vo(he.PullRequest),e[0]=h):h=e[0];const[p,j]=m.useState(h),[v,b]=m.useState("My App"),[I,C]=m.useState(!1);let x;e[1]===Symbol.for("react.memo_cache_sentinel")?(x=Ko(),e[1]=x):x=e[1];const[T,_]=m.useState(x);let w;e[2]===Symbol.for("react.memo_cache_sentinel")?(w=qo(),e[2]=w):w=e[2];const[R,N]=m.useState(w);let y;e[3]===Symbol.for("react.memo_cache_sentinel")?(y=[],e[3]=y):y=e[3];const[S,E]=m.useState(y),[k,A]=m.useState(!1);let D;e[4]===Symbol.for("react.memo_cache_sentinel")?(D=new Set,e[4]=D):D=e[4];const[z,O]=m.useState(D);let L;e[5]===Symbol.for("react.memo_cache_sentinel")?(L=J=>{O(xe=>new Set(xe).add(J))},e[5]=L):L=e[5];const F=L;let B,W;if(e[6]!==S){if(B={},Array.isArray(S))for(const J of S){const xe=J.typeName;B[xe]||(B[xe]=[]),B[xe].push(J)}W=Object.keys(B).sort(),e[6]=S,e[7]=B,e[8]=W}else B=e[7],W=e[8];const Q=W;let se;e[9]!==B||e[10]!==Q?(se={typeNames:Q,templatesByTypeName:B},e[9]=B,e[10]=Q,e[11]=se):se=e[11];const{typeNames:de,templatesByTypeName:ie}=se;let re;if(e[12]!==ie){re={};for(const J of Object.keys(ie)){const xe=ie[J]??[];if(xe.length===0)continue;const Re=xe.find(fc),Nt=xe.filter(mc),Yt=Re?[Re,...Nt]:xe;re[J]=Yt[0].id}e[12]=ie,e[13]=re}else re=e[13];const ae=re;let le;e:{if(!Array.isArray(S)){le=T;break e}if(S.find(ba=>ba.id===T)){le=T;break e}if(S.length===0){le=T;break e}const xe=de[0];let Re;e[14]!==xe||e[15]!==ie?(Re=xe?ie[xe]??[]:[],e[14]=xe,e[15]=ie,e[16]=Re):Re=e[16];const Nt=Re;let Yt;e[17]!==Nt?(Yt=Nt.find(uc),e[17]=Nt,e[18]=Yt):Yt=e[18],le=(Yt??Nt[0])?.id??T}const ce=le;let ee;e:{if(!ce||!Array.isArray(S)||S.length===0){ee=null;break e}let J;e[19]!==ce||e[20]!==S?(J=S.find(xe=>xe.id===ce)?.typeName??null,e[19]=ce,e[20]=S,e[21]=J):J=e[21],ee=J}const te=ee;let M;if(e[22]!==te||e[23]!==ie){e:{const J=te?ie[te]??[]:[];if(J.length<=1){M=J;break e}const xe=J.find(dc),Re=J.filter(cc);M=xe?[xe,...Re]:J}e[22]=te,e[23]=ie,e[24]=M}else M=e[24];const H=M;let G,V;e[25]!==ce?(G=()=>{ce&&Jo(ce)},V=[ce],e[25]=ce,e[26]=G,e[27]=V):(G=e[26],V=e[27]),m.useEffect(G,V);let X,Z;e[28]!==a||e[29]!==t?(X=()=>{t&&a&&setTimeout(()=>{c(a),u(2),a==="webapp"&&(b("My App"),C(!1),O(new Set))},0)},Z=[t,a],e[28]=a,e[29]=t,e[30]=X,e[31]=Z):(X=e[30],Z=e[31]),m.useEffect(X,Z);let Y,q;e[32]!==i||e[33]!==t||e[34]!==S?(Y=()=>{i==="webapp"&&t&&(!Array.isArray(S)||S.length===0)&&setTimeout(()=>{A(!0),Sn().then(J=>E(J?.templates||[])).catch(()=>E([])).finally(()=>A(!1))},0)},q=[i,t,S],e[32]=i,e[33]=t,e[34]=S,e[35]=Y,e[36]=q):(Y=e[35],q=e[36]),m.useEffect(Y,q);const oe=I?v:te?`My ${te} App`:"My App";let Te;e[37]!==ce||e[38]!==S?(Te=ce&&Array.isArray(S)?S.find(J=>J.id===ce):null,e[37]=ce,e[38]=S,e[39]=Te):Te=e[39];const Ne=Te;let ze;e[40]!==S?(ze=()=>{c("webapp"),u(2),b("My App"),C(!1),O(new Set),(!Array.isArray(S)||S.length===0)&&(A(!0),Sn().then(J=>E(J?.templates||[])).catch(()=>E([])).finally(()=>A(!1)))},e[40]=S,e[41]=ze):ze=e[41];const Xe=ze;let gt;e[42]===Symbol.for("react.memo_cache_sentinel")?(gt=()=>{c("clone"),u(2)},e[42]=gt):gt=e[42];const Lt=gt;let xt;e[43]!==r?(xt=()=>{c("choice"),u(1),g(""),b("My App"),C(!1),O(new Set),r(!1)},e[43]=r,e[44]=xt):xt=e[44];const jt=xt;let ft;e[45]!==d?(ft=()=>{d===2?(c("choice"),u(1),g(""),b("My App"),C(!1)):u(ic)},e[45]=d,e[46]=ft):ft=e[46];const yt=ft;let bt;e[47]!==f||e[48]!==i||e[49]!==te?(bt=i==="clone"?f.trim().length>0:te!==null,e[47]=f,e[48]=i,e[49]=te,e[50]=bt):bt=e[50];const Ie=bt;let Be;e[51]!==p||e[52]!==f||e[53]!==r||e[54]!==l?(Be=()=>{if(!f.trim())return;const J=f.trim();g(""),u(1),r(!1),c("choice"),l(J,p).catch(oc)},e[51]=p,e[52]=f,e[53]=r,e[54]=l,e[55]=Be):Be=e[55];const Ze=Be;let Ee;if(e[56]!==ce||e[57]!==r||e[58]!==o||e[59]!==R||e[60]!==oe){Ee=()=>{if(!oe.trim()||!ce||!J(oe))return;const xe=oe.trim();b(""),C(!1),u(1),r(!1),c("choice"),o(xe,ce,R).catch(lc)};const J=ac;e[56]=ce,e[57]=r,e[58]=o,e[59]=R,e[60]=oe,e[61]=Ee}else Ee=e[61];const ne=i==="choice"?1:d;let qe;e[62]!==Ie||e[63]!==f||e[64]!==i||e[65]!==ne?(qe=J=>J===1?ne>1:J===2?ne>=2:J===3?ne>=2&&(i==="clone"?f.trim().length>0:Ie):!1,e[62]=Ie,e[63]=f,e[64]=i,e[65]=ne,e[66]=qe):qe=e[66];const ge=qe;let We;e[67]===Symbol.for("react.memo_cache_sentinel")?(We=J=>{J===1?(c("choice"),u(1),g(""),b("")):u(J)},e[67]=We):We=e[67];const et=We;let ke;e[68]!==jt?(ke=J=>!J&&jt(),e[68]=jt,e[69]=ke):ke=e[69];let _e;e[70]!==ge?(_e=()=>ge(1)&&et(1),e[70]=ge,e[71]=_e):_e=e[71];const kt=ne===1?"bg-primary text-primary-foreground scale-110":ne>1?"bg-brand text-brand-foreground":"bg-muted text-muted-foreground";let Pe;e[72]!==ge||e[73]!==kt?(Pe=U("flex items-center justify-center h-8 w-8 rounded-full text-sm font-medium shrink-0 transition-colors transition-transform duration-300 ease-out",kt,ge(1)&&"cursor-pointer hover:opacity-90"),e[72]=ge,e[73]=kt,e[74]=Pe):Pe=e[74];let Me;e[75]!==_e||e[76]!==Pe?(Me=n.jsx("button",{type:"button",onClick:_e,className:Pe,"aria-label":"Go to step 1",children:"1"}),e[75]=_e,e[76]=Pe,e[77]=Me):Me=e[77];const _t=ne>=2?"100%":"0%";let De;e[78]!==_t?(De=n.jsx("div",{className:"h-0.5 flex-1 min-w-0 relative rounded-full overflow-hidden bg-muted",children:n.jsx("div",{className:"absolute inset-y-0 left-0 bg-brand transition-[width] duration-300 ease-out rounded-full",style:{width:_t}})}),e[78]=_t,e[79]=De):De=e[79];let tt;e[80]!==ge?(tt=()=>ge(2)&&et(2),e[80]=ge,e[81]=tt):tt=e[81];const st=ne===2?"bg-primary text-primary-foreground scale-110":ne>2?"bg-brand text-brand-foreground":"bg-muted text-muted-foreground";let Ae;e[82]!==ge||e[83]!==st?(Ae=U("flex items-center justify-center h-8 w-8 rounded-full text-sm font-medium shrink-0 transition-colors transition-transform duration-300 ease-out",st,ge(2)&&"cursor-pointer hover:opacity-90"),e[82]=ge,e[83]=st,e[84]=Ae):Ae=e[84];let nt;e[85]!==tt||e[86]!==Ae?(nt=n.jsx("button",{type:"button",onClick:tt,className:Ae,"aria-label":"Go to step 2",children:"2"}),e[85]=tt,e[86]=Ae,e[87]=nt):nt=e[87];const rt=ne>=3?"100%":"0%";let Le;e[88]!==rt?(Le=n.jsx("div",{className:"h-0.5 flex-1 min-w-0 relative rounded-full overflow-hidden bg-muted",children:n.jsx("div",{className:"absolute inset-y-0 left-0 bg-brand transition-[width] duration-300 ease-out rounded-full",style:{width:rt}})}),e[88]=rt,e[89]=Le):Le=e[89];let at;e[90]!==ge?(at=()=>ge(3)&&et(3),e[90]=ge,e[91]=at):at=e[91];const lt=ne===3?"bg-primary text-primary-foreground scale-110":"bg-muted text-muted-foreground";let $e;e[92]!==ge||e[93]!==lt?($e=U("flex items-center justify-center h-8 w-8 rounded-full text-sm font-medium shrink-0 transition-colors transition-transform duration-300 ease-out",lt,ge(3)&&"cursor-pointer hover:opacity-90"),e[92]=ge,e[93]=lt,e[94]=$e):$e=e[94];let Oe;e[95]!==at||e[96]!==$e?(Oe=n.jsx("button",{type:"button",onClick:at,className:$e,"aria-label":"Go to step 3",children:"3"}),e[95]=at,e[96]=$e,e[97]=Oe):Oe=e[97];let Fe;e[98]!==Me||e[99]!==De||e[100]!==nt||e[101]!==Le||e[102]!==Oe?(Fe=n.jsxs("div",{className:"mx-auto flex items-center gap-1 mb-6 w-2/3",children:[Me,De,nt,Le,Oe]}),e[98]=Me,e[99]=De,e[100]=nt,e[101]=Le,e[102]=Oe,e[103]=Fe):Fe=e[103];const ot=ne===1&&"New Project",it=ne===2&&i==="clone"&&"Clone Repository",vt=ne===2&&i==="webapp"&&"Create App",ct=ne===3&&i==="clone"&&"Clone Repository",Ue=ne===3&&i==="webapp"&&(te==="Capacitor Plugin"?"Create Capacitor Plugin":te?`Create ${te} App`:"Create App");let pt;e[104]!==ot||e[105]!==it||e[106]!==vt||e[107]!==ct||e[108]!==Ue?(pt=n.jsxs(Ge,{children:[ot,it,vt,ct,Ue]}),e[104]=ot,e[105]=it,e[106]=vt,e[107]=ct,e[108]=Ue,e[109]=pt):pt=e[109];const as=ne===1&&"Choose how to add a new project.",Fs=ne===2&&i==="clone"&&"Enter a git repository URL to clone.",Gs=ne===2&&i==="webapp"&&"Choose a template type.",Hs=ne===3&&i==="clone"&&"Choose commit workflow.",Us=ne===3&&i==="webapp"&&"Name your project and choose variation, package manager, and commit workflow.";let $t;e[110]!==as||e[111]!==Fs||e[112]!==Gs||e[113]!==Hs||e[114]!==Us?($t=n.jsxs(He,{children:[as,Fs,Gs,Hs,Us]}),e[110]=as,e[111]=Fs,e[112]=Gs,e[113]=Hs,e[114]=Us,e[115]=$t):$t=e[115];let Ot;e[116]!==pt||e[117]!==$t?(Ot=n.jsxs(Qe,{children:[pt,$t]}),e[116]=pt,e[117]=$t,e[118]=Ot):Ot=e[118];let Ft;e[119]!==Fe||e[120]!==Ot?(Ft=n.jsxs("div",{className:"px-6 pt-6 pb-2",children:[Fe,Ot]}),e[119]=Fe,e[120]=Ot,e[121]=Ft):Ft=e[121];let Gt;e[122]!==Xe||e[123]!==ne?(Gt=ne===1&&n.jsx(Ve,{className:"flex-1 min-h-0 overflow-hidden",children:n.jsx("div",{className:"px-6 py-4",children:n.jsxs("div",{className:"flex flex-col gap-3",children:[n.jsx(us,{role:"button",tabIndex:0,className:"cursor-pointer transition-colors hover:border-primary/50 hover:bg-muted/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:Lt,onKeyDown:J=>J.key==="Enter"&&Lt(),children:n.jsxs(ms,{className:"flex items-start gap-4 p-4",children:[n.jsx("div",{className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-lg bg-brand text-brand-foreground",children:n.jsx(gs,{className:"h-6 w-6"})}),n.jsxs("div",{className:"min-w-0 flex-1 space-y-0.5",children:[n.jsx("p",{className:"font-semibold",children:"Clone repo"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"Connect an existing repository by URL"})]})]})}),n.jsx(us,{role:"button",tabIndex:0,className:"cursor-pointer transition-colors hover:border-primary/50 hover:bg-muted/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:Xe,onKeyDown:J=>J.key==="Enter"&&Xe(),children:n.jsxs(ms,{className:"flex items-start gap-4 p-4",children:[n.jsx("div",{className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-lg bg-brand text-brand-foreground",children:n.jsx(Jn,{className:"h-6 w-6"})}),n.jsxs("div",{className:"min-w-0 flex-1 space-y-0.5",children:[n.jsx("p",{className:"font-semibold",children:"Create App"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"Scaffold a new React, Vue, Next.js, or other template"})]})]})})]})})}),e[122]=Xe,e[123]=ne,e[124]=Gt):Gt=e[124];let Ht;e[125]!==Ie||e[126]!==f||e[127]!==i||e[128]!==ne?(Ht=ne===2&&i==="clone"&&n.jsx(Ve,{className:"flex-1 min-h-0 overflow-hidden",children:n.jsx("div",{className:"px-6 py-4",children:n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsx(be,{htmlFor:"gitUrl",children:"Repository URL"}),n.jsx(Ke,{id:"gitUrl",placeholder:"https://github.com/user/repo.git",value:f,onChange:J=>g(J.target.value),onKeyDown:J=>J.key==="Enter"&&Ie&&u(3)})]})})}),e[125]=Ie,e[126]=f,e[127]=i,e[128]=ne,e[129]=Ht):Ht=e[129];let Ut;e[130]!==ae||e[131]!==z||e[132]!==i||e[133]!==te||e[134]!==ne||e[135]!==ie||e[136]!==k||e[137]!==de?(Ut=ne===2&&i==="webapp"&&n.jsx("div",{className:"flex flex-col flex-1 min-h-0 px-6 pb-4",children:n.jsx("div",{className:"flex-1 min-h-0 flex flex-col py-2",children:n.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto -mx-1",children:n.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-2 p-1 mr-2",children:k?n.jsx("p",{className:"col-span-full p-4 text-sm text-muted-foreground",children:"Loading…"}):de.map(J=>{const xe=ie[J]?.[0]?.type,Re=xe?sc[xe]:null,Nt=te===J;return n.jsxs("button",{type:"button",onClick:()=>_(ae[J]??""),onDoubleClick:()=>{_(ae[J]??""),u(3)},className:U("flex flex-col items-center gap-2 rounded-lg border px-3 py-3 text-center transition-colors",Nt?"border-primary bg-accent text-accent-foreground":"border-border bg-card hover:bg-muted/50 hover:border-muted-foreground/30 shadow-sm"),children:[Re?n.jsx("img",{src:`/template-types/${Re}`,alt:"",className:U("size-8 shrink-0 transition-opacity duration-300",z.has(Re)?"opacity-100":"opacity-0"),onLoad:()=>F(Re),"aria-hidden":!0}):null,n.jsx("span",{className:"font-medium text-sm truncate w-full",children:J})]},J)})})})})}),e[130]=ae,e[131]=z,e[132]=i,e[133]=te,e[134]=ne,e[135]=ie,e[136]=k,e[137]=de,e[138]=Ut):Ut=e[138];let zt;e[139]!==p||e[140]!==ce||e[141]!==i||e[142]!==R||e[143]!==oe||e[144]!==Ne||e[145]!==ne||e[146]!==H?(zt=ne===3&&i==="webapp"&&n.jsx(Ve,{className:"flex-1 min-h-0 overflow-hidden",children:n.jsxs("div",{className:"px-6 py-4 flex flex-col gap-6",children:[n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsx(be,{htmlFor:"projectName",children:"Project name"}),n.jsx(Ke,{id:"projectName",placeholder:"My App",value:oe,onChange:J=>{b(J.target.value),C(!0)},className:"max-w-xs"})]}),n.jsxs("div",{className:"flex flex-col gap-3",children:[H.length>1&&n.jsxs(n.Fragment,{children:[n.jsx(be,{className:"text-sm font-medium",children:"Variation"}),n.jsx(os,{type:"single",value:ce,onValueChange:J=>J&&_(J),variant:"outline",className:"flex flex-wrap gap-0 justify-start [&>button]:rounded-none [&>button:first-child]:rounded-l-md [&>button:last-child]:rounded-r-md [&>button:not(:first-child)]:-ml-px",children:H.map(rc)})]}),n.jsxs("p",{className:"text-xs text-muted-foreground",children:[Ne?.description??H[0]?.description??"",Ne?.url&&n.jsxs(n.Fragment,{children:[" ",n.jsxs("a",{href:Ne.url,target:"_blank",rel:"noreferrer",className:"text-brand hover:underline hover:text-brand/80 inline-flex items-center gap-0.5",children:["Documentation ",n.jsx(xs,{className:"h-3 w-3"})]})]})]})]}),n.jsxs("div",{className:"flex flex-col gap-3",children:[n.jsx(be,{className:"text-sm font-medium",children:"Package manager"}),n.jsx(os,{type:"single",value:R,onValueChange:J=>{J&&(N(J),Wo(J))},variant:"outline",className:"flex flex-wrap gap-0 justify-start [&>button]:rounded-none [&>button:first-child]:rounded-l-md [&>button:last-child]:rounded-r-md [&>button:not(:first-child)]:-ml-px",children:Object.values(tc).map(nc)})]}),n.jsxs("div",{className:"flex flex-col gap-3",children:[n.jsx(be,{className:"text-sm font-medium",children:"Commit method"}),n.jsxs(os,{type:"single",value:p,onValueChange:J=>{(J===he.PullRequest||J===he.Direct)&&(j(J),Rn(J))},variant:"outline",className:"flex flex-wrap gap-0 justify-start [&>button]:rounded-none [&>button:first-child]:rounded-l-md [&>button:last-child]:rounded-r-md [&>button:not(:first-child)]:-ml-px",children:[n.jsx(Pt,{value:he.PullRequest,className:"text-sm",children:"Pull Requests"}),n.jsx(Pt,{value:he.Direct,className:"text-sm",children:"Direct Commits"})]}),n.jsx("p",{className:"text-xs text-slate-600 dark:text-slate-400",children:p===he.PullRequest?"Creates a feature branch and allows you to create pull requests.":"Commits directly to the main branch without creating feature branches."})]})]})}),e[139]=p,e[140]=ce,e[141]=i,e[142]=R,e[143]=oe,e[144]=Ne,e[145]=ne,e[146]=H,e[147]=zt):zt=e[147];let Bt;e[148]!==p||e[149]!==i||e[150]!==ne?(Bt=ne===3&&i==="clone"&&n.jsx(Ve,{className:"flex-1 min-h-0 overflow-hidden",children:n.jsx("div",{className:"px-6 py-4 flex flex-col gap-6",children:n.jsxs("div",{className:"flex flex-col gap-3",children:[n.jsx(be,{className:"text-sm font-medium",children:"Commit method"}),n.jsxs(os,{type:"single",value:p,onValueChange:J=>{(J===he.PullRequest||J===he.Direct)&&(j(J),Rn(J))},variant:"outline",className:"flex flex-wrap gap-0 justify-start [&>button]:rounded-none [&>button:first-child]:rounded-l-md [&>button:last-child]:rounded-r-md [&>button:not(:first-child)]:-ml-px",children:[n.jsx(Pt,{value:he.PullRequest,className:"text-sm",children:"Pull Requests"}),n.jsx(Pt,{value:he.Direct,className:"text-sm",children:"Direct Commits"})]}),n.jsx("p",{className:"text-xs text-slate-600 dark:text-slate-400",children:p===he.PullRequest?"Creates a feature branch and allows you to create pull requests.":"Commits directly to the main branch without creating feature branches."})]})})}),e[148]=p,e[149]=i,e[150]=ne,e[151]=Bt):Bt=e[151];let qt;e[152]!==yt||e[153]!==ne?(qt=ne>1&&n.jsx(K,{variant:"ghost",onClick:yt,children:"Back"}),e[152]=yt,e[153]=ne,e[154]=qt):qt=e[154];let Wt;e[155]!==Ie||e[156]!==ne?(Wt=ne===2&&n.jsx(K,{onClick:()=>u(3),disabled:!Ie,children:"Next"}),e[155]=Ie,e[156]=ne,e[157]=Wt):Wt=e[157];let Vt;e[158]!==Ze||e[159]!==i||e[160]!==ne?(Vt=ne===3&&i==="clone"&&n.jsx(K,{onClick:Ze,children:"Clone Repository"}),e[158]=Ze,e[159]=i,e[160]=ne,e[161]=Vt):Vt=e[161];let Kt;e[162]!==Ee||e[163]!==i||e[164]!==oe||e[165]!==ne?(Kt=ne===3&&i==="webapp"&&n.jsx(K,{onClick:Ee,disabled:!oe.trim(),children:"Create App"}),e[162]=Ee,e[163]=i,e[164]=oe,e[165]=ne,e[166]=Kt):Kt=e[166];let Jt;e[167]!==qt||e[168]!==Wt||e[169]!==Vt||e[170]!==Kt?(Jt=n.jsx("div",{className:"px-6 py-4 border-t border-border bg-muted/10 min-h-[4.5rem] flex flex-col justify-end",children:n.jsxs(Ye,{children:[qt,Wt,Vt,Kt]})}),e[167]=qt,e[168]=Wt,e[169]=Vt,e[170]=Kt,e[171]=Jt):Jt=e[171];let Qt;e[172]!==Ft||e[173]!==Gt||e[174]!==Ht||e[175]!==Ut||e[176]!==zt||e[177]!==Bt||e[178]!==Jt?(Qt=n.jsxs(Je,{className:"max-w-2xl h-[min(42rem,90dvh)] flex flex-col p-0 overflow-hidden",children:[Ft,Gt,Ht,Ut,zt,Bt,Jt]}),e[172]=Ft,e[173]=Gt,e[174]=Ht,e[175]=Ut,e[176]=zt,e[177]=Bt,e[178]=Jt,e[179]=Qt):Qt=e[179];let vs;return e[180]!==t||e[181]!==ke||e[182]!==Qt?(vs=n.jsx(mt,{open:t,onOpenChange:ke,children:Qt}),e[180]=t,e[181]=ke,e[182]=Qt,e[183]=vs):vs=e[183],vs}function nc(s){return n.jsx(Pt,{value:s.id,className:"text-sm",children:s.label},s.id)}function rc(s){return n.jsx(Pt,{value:s.id,className:"text-sm",children:s.variationName},s.id)}function ac(s){return s.trim().toLowerCase().replace(/\s+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function lc(){}function oc(){}function ic(s){return s-1}function cc(s){return s.variationName!=="Starter"}function dc(s){return s.variationName==="Starter"}function uc(s){return s.variationName==="Starter"}function mc(s){return s.variationName!=="Starter"}function fc(s){return s.variationName==="Starter"}function pc({onCreateThread:s}){const{state:e,dispatch:t}=Se(),[r,a]=m.useState(null),[l,o]=m.useState(!1),[i,c]=m.useState(null),d=m.useRef(""),u=m.useRef(""),f=m.useRef([]),g=m.useRef(!1),h=m.useRef(null),p=m.useRef(null),j=m.useRef(()=>{}),[v,b]=m.useState(null),I=m.useRef(!1),C=m.useRef(null),{selectedThreadId:x,selectedProjectId:T,messages:_,queuedChatMessages:w,isStreaming:R,streamingSegments:N,streamingModel:y,isCreatingProject:S,processingThreadIds:E,projects:k}=e,z=!!(x&&E.includes(x))&&!(v===x&&!R),O=T&&x?k.find(ee=>ee.projectId===T)?.threads.find(ee=>ee.threadId===x):void 0,L=m.useCallback(ee=>{h.current=null,p.current=null;const te=f.current,M=$l(te)||"...";if(C.current&&te.length===0){const G={messageId:`msg-${Date.now()}-error`,sender:"agent",content:`Error: ${C.current}`,contentType:"text",timestamp:new Date().toISOString(),model:e.streamingModel||ee,isThinking:!1};t({type:P.AddMessage,message:G}),t({type:P.ResetStream}),C.current=null;return}const H={messageId:`msg-${Date.now()}-agent`,sender:"agent",content:M,contentType:"markdown",timestamp:new Date().toISOString(),model:e.streamingModel||ee,isThinking:!1};d.current="",u.current="",f.current=[],C.current=null,t({type:P.AddMessage,message:H}),t({type:P.ResetStream}),x&&t({type:P.MarkThreadCompleted,threadId:x})},[e.streamingModel,t,x]);m.useEffect(()=>{j.current=L},[L]);const F=m.useCallback(()=>{x&&b(x),h.current&&(h.current.abort(),h.current=null),p.current&&(p.current(),p.current=null),L(e.streamingModel||"default")},[x,L,e.streamingModel]);m.useEffect(()=>{I.current&&!R&&h.current&&(h.current.abort(),h.current=null,p.current&&(p.current(),p.current=null),j.current(y||"default")),I.current=R},[R,y]),m.useEffect(()=>()=>{h.current&&(h.current.abort(),h.current=null),p.current&&(p.current(),p.current=null),t({type:P.ResetStream})},[x,t]),m.useEffect(()=>{if(!x)return;let ee=!1;async function te(){try{const M=await uo(x);ee||t({type:P.SetMessages,messages:M.messages})}catch(M){console.error("Failed to load chat history:",M),ee||t({type:P.SetMessages,messages:[]})}}return te(),()=>{ee=!0}},[x,T,t]);const B=m.useCallback(async(ee,te,M,H)=>{if(!x)return;a(null),b(null),h.current&&h.current.abort(),p.current&&p.current();const G={messageId:`msg-${Date.now()}`,sender:"user",content:ee,contentType:"text",timestamp:new Date().toISOString(),model:te,attachments:M.map(Z=>({fileName:Z.fileName,content:Z.content}))};t({type:P.AddMessage,message:G});const V=ee.trim().replace(/\n/g," ").slice(0,100);T&&x&&(io(x,{title:V}).catch(Z=>{console.error("Failed to update thread title:",Z)}),t({type:P.UpdateThreadTitle,projectId:T,threadId:x,title:V})),t({type:P.ResetStream}),t({type:P.SetStreaming,isStreaming:!0}),d.current="",g.current=!1;const X=new AbortController;h.current=X;try{const Z=await fo(x,ee,te,M,X.signal,H);Z&&(p.current=ho(Z,Y=>{if(Y.type!=="message"){if(Y.type==="toolcall_delta"){if(Y.partial?.content?.[0]?.id&&Y.delta){const q=Y.partial.content[0].id,oe=Y.partial.content[0].name;t({type:P.UpdateToolCallProgress,toolCallId:q,progress:{toolCallId:q,toolName:oe,delta:Y.delta,partial:Y.partial}})}return}if(Y.model&&t({type:P.SetStreamModel,model:Y.model}),Y.type==="thinking"||Y.isThinking){u.current+=Y.content||"";const q=zs(f.current,"thinking",Y.content||"");f.current=q,t({type:P.AppendStreamChunk,chunkType:"thinking",content:Y.content||"",segments:q})}else if(Y.type==="result"){g.current=!0,d.current=Y.content||"";const q=Ys(f.current,Y.content||"");f.current=q,t({type:P.SetStreamContent,content:Y.content||""})}else{if(g.current)return;d.current+=Y.content||"";const q=zs(f.current,"content",Y.content||"");f.current=q,t({type:P.AppendStreamChunk,chunkType:"content",content:Y.content||"",segments:q})}}},()=>{j.current(te)},Y=>{Y.includes("AbortError")||Y.includes("canceled")||Y.includes("BodyStreamBuffer was aborted")||(C.current=Y,a(Y))},Y=>{if(Y.role==="assistant"){const q=Y.content??"",oe=typeof q=="string"?q:JSON.stringify(q);let Te=!1;if(typeof q=="object"&&Array.isArray(q)&&q.length>0)Te=!0;else if(typeof oe=="string"&&oe.trim().startsWith("["))try{const Ne=JSON.parse(oe);Te=Array.isArray(Ne)&&Ne.length>0}catch{}if(Te)g.current=!0,d.current=oe,f.current=Ys(f.current,oe),t({type:P.SetStreamContent,content:oe});else{d.current+=oe;const Ne=zs(f.current,"content",oe);f.current=Ne,t({type:P.AppendStreamChunk,chunkType:"content",content:oe,segments:Ne})}}}))}catch(Z){if(Z instanceof Error&&Z.name==="AbortError"||Z instanceof Error&&Z.message.includes("BodyStreamBuffer was aborted"))return;a(Z instanceof Error?Z.message:"Failed to send message. Please ensure the CLI server is running on localhost:641"),C.current=Z instanceof Error?Z.message:"Failed to send message. Please ensure the CLI server is running on localhost:641",t({type:P.ResetStream})}},[x,T,t]),W=m.useMemo(()=>x?w.filter(ee=>ee.threadId===x):[],[x,w]),Q=m.useRef(!1);m.useEffect(()=>{if(R||!x||W.length===0||Q.current)return;const[ee]=W;Q.current=!0,t({type:P.RemoveQueuedChatMessage,queuedMessageId:ee.id});const te=setTimeout(()=>{B(ee.message,ee.model,ee.attachments,ee.provider),Q.current=!1},0);return()=>{clearTimeout(te),Q.current=!1}},[t,B,R,W,x]);const se=m.useCallback(ee=>{const te=W.find(M=>M.id===ee);t({type:P.RemoveQueuedChatMessage,queuedMessageId:ee}),!(!te||R||_.length>0||!x)&&B(te.message,te.model,te.attachments,te.provider)},[t,B,R,_.length,W,x]),de=()=>{c("clone"),o(!0)},ie=()=>{c("webapp"),o(!0)},re=async(ee,te)=>{try{await Jr(ee,te),o(!1),c(null)}catch(M){a(M instanceof Error?M.message:"Failed to clone repository")}},ae=async(ee,te,M)=>{try{await Kr(ee,te,M),o(!1),c(null)}catch(H){a(H instanceof Error?H.message:"Failed to create project")}},le=()=>{t({type:P.SetReviewMode,reviewMode:!1})},{reviewMode:ce}=e;return n.jsxs("div",{className:"flex h-full flex-col",children:[ce&&x?n.jsx(Ki,{threadId:x,onExit:le}):n.jsx(Bi,{messages:_,isStreaming:R,streamingSegments:N,streamingModel:y,isCreatingProject:S,isProcessingThread:z,selectedThreadId:x,projects:k,onSelectThread:(ee,te)=>{t({type:P.SelectThread,projectId:ee,threadId:te})},onCreateThread:s,onConnectRepo:de,onNewApp:ie,error:r,onClearError:()=>a(null)}),n.jsxs("div",{className:"relative mx-auto w-full max-w-3xl",children:[n.jsx(yi,{onSend:B,onStop:F,isStreaming:R,disabled:!x&&!S,initialValue:"",queuedMessages:W,onRemoveQueuedMessage:se}),n.jsx(Wi,{branchName:O?.currentBranch,threadId:x??void 0})]}),n.jsx(Vi,{}),n.jsx(aa,{open:l,onOpenChange:o,initialMode:i||void 0,onSubmitClone:re,onSubmitWebApp:ae})]})}const la=al,oa=ll,hc=m.forwardRef((s,e)=>{const t=$.c(14);let r,a,l,o;t[0]!==s?({className:a,inset:l,children:r,...o}=s,t[0]=s,t[1]=r,t[2]=a,t[3]=l,t[4]=o):(r=t[1],a=t[2],l=t[3],o=t[4]);const i=l&&"pl-8";let c;t[5]!==a||t[6]!==i?(c=U("flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",i,a),t[5]=a,t[6]=i,t[7]=c):c=t[7];let d;t[8]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(Mt,{className:"ml-auto"}),t[8]=d):d=t[8];let u;return t[9]!==r||t[10]!==o||t[11]!==e||t[12]!==c?(u=n.jsxs(rr,{ref:e,className:c,...o,children:[r,d]}),t[9]=r,t[10]=o,t[11]=e,t[12]=c,t[13]=u):u=t[13],u});hc.displayName=rr.displayName;const gc=m.forwardRef((s,e)=>{const t=$.c(9);let r,a;t[0]!==s?({className:r,...a}=s,t[0]=s,t[1]=r,t[2]=a):(r=t[1],a=t[2]);let l;t[3]!==r?(l=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),t[3]=r,t[4]=l):l=t[4];let o;return t[5]!==a||t[6]!==e||t[7]!==l?(o=n.jsx(ar,{ref:e,className:l,...a}),t[5]=a,t[6]=e,t[7]=l,t[8]=o):o=t[8],o});gc.displayName=ar.displayName;const gn=m.forwardRef((s,e)=>{const t=$.c(11);let r,a,l;t[0]!==s?({className:r,sideOffset:l,...a}=s,t[0]=s,t[1]=r,t[2]=a,t[3]=l):(r=t[1],a=t[2],l=t[3]);const o=l===void 0?4:l;let i;t[4]!==r?(i=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),t[4]=r,t[5]=i):i=t[5];let c;return t[6]!==a||t[7]!==e||t[8]!==o||t[9]!==i?(c=n.jsx(nl,{children:n.jsx(lr,{ref:e,sideOffset:o,className:i,...a})}),t[6]=a,t[7]=e,t[8]=o,t[9]=i,t[10]=c):c=t[10],c});gn.displayName=lr.displayName;const Ct=m.forwardRef((s,e)=>{const t=$.c(11);let r,a,l;t[0]!==s?({className:r,inset:a,...l}=s,t[0]=s,t[1]=r,t[2]=a,t[3]=l):(r=t[1],a=t[2],l=t[3]);const o=a&&"pl-8";let i;t[4]!==r||t[5]!==o?(i=U("relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm 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",o,r),t[4]=r,t[5]=o,t[6]=i):i=t[6];let c;return t[7]!==l||t[8]!==e||t[9]!==i?(c=n.jsx(or,{ref:e,className:i,...l}),t[7]=l,t[8]=e,t[9]=i,t[10]=c):c=t[10],c});Ct.displayName=or.displayName;const xc=m.forwardRef((s,e)=>{const t=$.c(14);let r,a,l,o;t[0]!==s?({className:l,children:a,checked:r,...o}=s,t[0]=s,t[1]=r,t[2]=a,t[3]=l,t[4]=o):(r=t[1],a=t[2],l=t[3],o=t[4]);let i;t[5]!==l?(i=U("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",l),t[5]=l,t[6]=i):i=t[6];let c;t[7]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:n.jsx(mr,{children:n.jsx(ht,{className:"h-4 w-4"})})}),t[7]=c):c=t[7];let d;return t[8]!==r||t[9]!==a||t[10]!==o||t[11]!==e||t[12]!==i?(d=n.jsxs(ir,{ref:e,className:i,checked:r,...o,children:[c,a]}),t[8]=r,t[9]=a,t[10]=o,t[11]=e,t[12]=i,t[13]=d):d=t[13],d});xc.displayName=ir.displayName;const jc=m.forwardRef((s,e)=>{const t=$.c(12);let r,a,l;t[0]!==s?({className:a,children:r,...l}=s,t[0]=s,t[1]=r,t[2]=a,t[3]=l):(r=t[1],a=t[2],l=t[3]);let o;t[4]!==a?(o=U("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",a),t[4]=a,t[5]=o):o=t[5];let i;t[6]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:n.jsx(mr,{children:n.jsx(rl,{className:"h-2 w-2 fill-current"})})}),t[6]=i):i=t[6];let c;return t[7]!==r||t[8]!==l||t[9]!==e||t[10]!==o?(c=n.jsxs(cr,{ref:e,className:o,...l,children:[i,r]}),t[7]=r,t[8]=l,t[9]=e,t[10]=o,t[11]=c):c=t[11],c});jc.displayName=cr.displayName;const yc=m.forwardRef((s,e)=>{const t=$.c(11);let r,a,l;t[0]!==s?({className:r,inset:a,...l}=s,t[0]=s,t[1]=r,t[2]=a,t[3]=l):(r=t[1],a=t[2],l=t[3]);const o=a&&"pl-8";let i;t[4]!==r||t[5]!==o?(i=U("px-2 py-1.5 text-sm font-semibold",o,r),t[4]=r,t[5]=o,t[6]=i):i=t[6];let c;return t[7]!==l||t[8]!==e||t[9]!==i?(c=n.jsx(dr,{ref:e,className:i,...l}),t[7]=l,t[8]=e,t[9]=i,t[10]=c):c=t[10],c});yc.displayName=dr.displayName;const bc=m.forwardRef((s,e)=>{const t=$.c(9);let r,a;t[0]!==s?({className:r,...a}=s,t[0]=s,t[1]=r,t[2]=a):(r=t[1],a=t[2]);let l;t[3]!==r?(l=U("-mx-1 my-1 h-px bg-muted",r),t[3]=r,t[4]=l):l=t[4];let o;return t[5]!==a||t[6]!==e||t[7]!==l?(o=n.jsx(ur,{ref:e,className:l,...a}),t[5]=a,t[6]=e,t[7]=l,t[8]=o):o=t[8],o});bc.displayName=ur.displayName;const vc=1,Nc=1e6;let Bs=0;function wc(){return Bs=(Bs+1)%Number.MAX_SAFE_INTEGER,Bs.toString()}const qs=new Map,kn=s=>{if(qs.has(s))return;const e=setTimeout(()=>{qs.delete(s),cs({type:"REMOVE_TOAST",toastId:s})},Nc);qs.set(s,e)},Sc=(s,e)=>{switch(e.type){case"ADD_TOAST":return{...s,toasts:[e.toast,...s.toasts].slice(0,vc)};case"UPDATE_TOAST":return{...s,toasts:s.toasts.map(t=>t.id===e.toast.id?{...t,...e.toast}:t)};case"DISMISS_TOAST":{const{toastId:t}=e;return t?kn(t):s.toasts.forEach(r=>{kn(r.id)}),{...s,toasts:s.toasts.map(r=>r.id===t||t===void 0?{...r,open:!1}:r)}}case"REMOVE_TOAST":return e.toastId===void 0?{...s,toasts:[]}:{...s,toasts:s.toasts.filter(t=>t.id!==e.toastId)}}},Is=[];let Rs={toasts:[]};function cs(s){Rs=Sc(Rs,s),Is.forEach(e=>{e(Rs)})}function je({...s}){const e=wc(),t=a=>cs({type:"UPDATE_TOAST",toast:{...a,id:e}}),r=()=>cs({type:"DISMISS_TOAST",toastId:e});return cs({type:"ADD_TOAST",toast:{...s,id:e,open:!0,onOpenChange:a=>{a||r()}}}),{id:e,dismiss:r,update:t}}function ia(){const s=$.c(5),[e,t]=m.useState(Rs);let r;s[0]===Symbol.for("react.memo_cache_sentinel")?(r=()=>(Is.push(t),()=>{const o=Is.indexOf(t);o>-1&&Is.splice(o,1)}),s[0]=r):r=s[0];let a;s[1]!==e?(a=[e],s[1]=e,s[2]=a):a=s[2],m.useEffect(r,a);let l;return s[3]!==e?(l={...e,toast:je,dismiss:Cc},s[3]=e,s[4]=l):l=s[4],l}function Cc(s){return cs({type:"DISMISS_TOAST",toastId:s})}const _n="VS Code";function Tc({projectId:s,threadId:e,openWith:t}){const[r,a]=m.useState(!1),[l,o]=m.useState([]),[i,c]=m.useState(t||_n),[d,u]=m.useState(!0);m.useEffect(()=>{(async()=>{try{const p=await to();o(p),!i&&p.length>0&&c(p[0])}catch(p){console.error("Failed to fetch available programs:",p),o([_n])}finally{u(!1)}})()},[]),m.useEffect(()=>{t&&l.includes(t)&&c(t)},[t,l,c]);const f=async h=>{try{a(!0),c(h),await jo(s,h),e?await xo(e,h):await go(s,h),je({title:"Success",description:`Opened project in ${h}`})}catch(p){console.error(`Failed to open project in ${h}:`,p);let j=`Failed to open project in ${h}`;if(p instanceof Error){const v=p;v.details?j=v.details:j=p.message}je({title:"Error",description:j,variant:"destructive"})}finally{a(!1)}},g=async()=>{await f(i)};return d?n.jsx(K,{variant:"outline",size:"sm",className:"h-8",disabled:!0,children:"Loading..."}):n.jsxs("div",{className:"flex items-center gap-0",children:[n.jsxs(K,{variant:"outline",size:"sm",className:"h-8 rounded-r-none border-r-0",disabled:r,onClick:g,children:["Open in ",i]}),n.jsxs(la,{children:[n.jsx(oa,{asChild:!0,children:n.jsx(K,{variant:"outline",size:"sm",className:"h-8 w-8 rounded-l-none px-1",disabled:r,children:n.jsx(It,{className:"h-3.5 w-3.5"})})}),n.jsx(gn,{align:"end",children:l.map(h=>n.jsx(Ct,{onClick:()=>f(h),disabled:r,children:h},h))})]})]})}const Ic=js("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function Rc(s){const e=$.c(10);let t,r,a;e[0]!==s?({className:t,variant:a,...r}=s,e[0]=s,e[1]=t,e[2]=r,e[3]=a):(t=e[1],r=e[2],a=e[3]);let l;e[4]!==t||e[5]!==a?(l=U(Ic({variant:a}),t),e[4]=t,e[5]=a,e[6]=l):l=e[6];let o;return e[7]!==r||e[8]!==l?(o=n.jsx("div",{className:l,...r}),e[7]=r,e[8]=l,e[9]=o):o=e[9],o}function Ec(){return{autoGenerateCommitMessage:Qo(),privateRepositoryDefault:Xo()}}function kc(s){s.autoGenerateCommitMessage!==void 0&&Yo(s.autoGenerateCommitMessage),s.privateRepositoryDefault!==void 0&&Zo(s.privateRepositoryDefault)}function Xt(s){return s?!0:(je({title:"Error",description:"No thread selected",variant:"destructive"}),!1)}const Dt=m.forwardRef((s,e)=>{const t=$.c(10);let r,a;t[0]!==s?({className:r,...a}=s,t[0]=s,t[1]=r,t[2]=a):(r=t[1],a=t[2]);let l;t[3]!==r?(l=U("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",r),t[3]=r,t[4]=l):l=t[4];let o;t[5]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx(ol,{className:U("flex items-center justify-center text-current"),children:n.jsx(ht,{className:"h-4 w-4"})}),t[5]=o):o=t[5];let i;return t[6]!==a||t[7]!==e||t[8]!==l?(i=n.jsx(fr,{ref:e,className:l,...a,children:o}),t[6]=a,t[7]=e,t[8]=l,t[9]=i):i=t[9],i});Dt.displayName=fr.displayName;const rs=m.forwardRef((s,e)=>{const t=$.c(9);let r,a;t[0]!==s?({className:r,...a}=s,t[0]=s,t[1]=r,t[2]=a):(r=t[1],a=t[2]);let l;t[3]!==r?(l=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 md:text-sm",r),t[3]=r,t[4]=l):l=t[4];let o;return t[5]!==a||t[6]!==e||t[7]!==l?(o=n.jsx("textarea",{className:l,ref:e,...a}),t[5]=a,t[6]=e,t[7]=l,t[8]=o):o=t[8],o});rs.displayName="Textarea";function _c(s){const e=$.c(57),{open:t,onOpenChange:r,commitMessage:a,onCommitMessageChange:l,autoGenerateCommitMessage:o,onAutoGenerateChange:i,isGeneratingMessage:c,isLoading:d,onGenerateMessage:u,onCommit:f,currentBranch:g}=s;let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(Ge,{children:"Commit Changes"}),e[0]=h):h=e[0];let p;e[1]!==g?(p=n.jsxs(Qe,{children:[h,n.jsxs(He,{children:["Enter a commit message for your changes on branch ",g]})]}),e[1]=g,e[2]=p):p=e[2];let j;e[3]===Symbol.for("react.memo_cache_sentinel")?(j=n.jsx(be,{htmlFor:"commit-message",children:"Commit Message"}),e[3]=j):j=e[3];let v;e[4]!==l?(v=Q=>l(Q.target.value),e[4]=l,e[5]=v):v=e[5];let b;e[6]!==a||e[7]!==v?(b=n.jsx(rs,{id:"commit-message",placeholder:"Enter commit message...",value:a,onChange:v,rows:4,className:"pr-10"}),e[6]=a,e[7]=v,e[8]=b):b=e[8];const I=c||d;let C;e[9]!==c?(C=c?n.jsx(ve,{className:"h-3.5 w-3.5 animate-spin"}):n.jsx(pr,{className:"h-3.5 w-3.5"}),e[9]=c,e[10]=C):C=e[10];let x;e[11]!==u||e[12]!==I||e[13]!==C?(x=n.jsx(pe,{asChild:!0,children:n.jsx(K,{type:"button",variant:"ghost",size:"icon",className:"absolute top-2 right-2 h-6 w-6",onClick:u,disabled:I,children:C})}),e[11]=u,e[12]=I,e[13]=C,e[14]=x):x=e[14];const T=c?"Generating commit message...":"Generate commit message with AI";let _;e[15]!==T?(_=n.jsx(me,{children:T}),e[15]=T,e[16]=_):_=e[16];let w;e[17]!==_||e[18]!==x?(w=n.jsx(we,{children:n.jsxs(fe,{children:[x,_]})}),e[17]=_,e[18]=x,e[19]=w):w=e[19];let R;e[20]!==w||e[21]!==b?(R=n.jsxs("div",{className:"grid gap-2",children:[j,n.jsxs("div",{className:"relative",children:[b,w]})]}),e[20]=w,e[21]=b,e[22]=R):R=e[22];let N;e[23]!==i?(N=Q=>i(Q===!0),e[23]=i,e[24]=N):N=e[24];let y;e[25]!==o||e[26]!==N?(y=n.jsx(Dt,{id:"auto-generate",checked:o,onCheckedChange:N}),e[25]=o,e[26]=N,e[27]=y):y=e[27];let S;e[28]===Symbol.for("react.memo_cache_sentinel")?(S=n.jsx(be,{htmlFor:"auto-generate",className:"text-sm font-normal",children:"Auto generate commit messages"}),e[28]=S):S=e[28];let E;e[29]!==y?(E=n.jsxs("div",{className:"flex items-center gap-2",children:[y,S]}),e[29]=y,e[30]=E):E=e[30];let k;e[31]!==R||e[32]!==E?(k=n.jsxs("div",{className:"grid gap-4 py-4",children:[R,E]}),e[31]=R,e[32]=E,e[33]=k):k=e[33];let A;e[34]!==r?(A=()=>r(!1),e[34]=r,e[35]=A):A=e[35];let D;e[36]!==d||e[37]!==A?(D=n.jsx(K,{variant:"outline",onClick:A,disabled:d,children:"Cancel"}),e[36]=d,e[37]=A,e[38]=D):D=e[38];let z;e[39]!==a||e[40]!==d?(z=d||!a.trim(),e[39]=a,e[40]=d,e[41]=z):z=e[41];const O=d?"Committing...":"Commit";let L;e[42]!==f||e[43]!==z||e[44]!==O?(L=n.jsx(K,{onClick:f,disabled:z,children:O}),e[42]=f,e[43]=z,e[44]=O,e[45]=L):L=e[45];let F;e[46]!==D||e[47]!==L?(F=n.jsxs(Ye,{children:[D,L]}),e[46]=D,e[47]=L,e[48]=F):F=e[48];let B;e[49]!==k||e[50]!==p||e[51]!==F?(B=n.jsxs(Je,{children:[p,k,F]}),e[49]=k,e[50]=p,e[51]=F,e[52]=B):B=e[52];let W;return e[53]!==r||e[54]!==t||e[55]!==B?(W=n.jsx(mt,{open:t,onOpenChange:r,children:B}),e[53]=r,e[54]=t,e[55]=B,e[56]=W):W=e[56],W}function Pc(s){const e=$.c(53),{open:t,onOpenChange:r,prTitle:a,onPrTitleChange:l,prDescription:o,onPrDescriptionChange:i,isGeneratingPRInfo:c,isLoading:d,onGeneratePRInfo:u,onCreatePR:f,currentBranch:g}=s;let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(Ge,{children:"Create Pull Request"}),e[0]=h):h=e[0];let p;e[1]!==g?(p=n.jsxs(Qe,{children:[h,n.jsxs(He,{children:["Create a pull request for branch ",g]})]}),e[1]=g,e[2]=p):p=e[2];let j;e[3]===Symbol.for("react.memo_cache_sentinel")?(j=n.jsx(be,{htmlFor:"pr-title",children:"Title (optional)"}),e[3]=j):j=e[3];const v=g||"Enter PR title...";let b;e[4]!==l?(b=W=>l(W.target.value),e[4]=l,e[5]=b):b=e[5];let I;e[6]!==a||e[7]!==v||e[8]!==b?(I=n.jsxs("div",{className:"grid gap-2",children:[j,n.jsx(Ke,{id:"pr-title",placeholder:v,value:a,onChange:b})]}),e[6]=a,e[7]=v,e[8]=b,e[9]=I):I=e[9];let C;e[10]===Symbol.for("react.memo_cache_sentinel")?(C=n.jsx(be,{htmlFor:"pr-description",children:"Description (optional)"}),e[10]=C):C=e[10];let x;e[11]!==i?(x=W=>i(W.target.value),e[11]=i,e[12]=x):x=e[12];let T;e[13]!==o||e[14]!==x?(T=n.jsx(rs,{id:"pr-description",placeholder:"Enter PR description...",value:o,onChange:x,rows:4,className:"pr-10"}),e[13]=o,e[14]=x,e[15]=T):T=e[15];const _=c||d;let w;e[16]!==c?(w=c?n.jsx(ve,{className:"h-3.5 w-3.5 animate-spin"}):n.jsx(pr,{className:"h-3.5 w-3.5"}),e[16]=c,e[17]=w):w=e[17];let R;e[18]!==u||e[19]!==_||e[20]!==w?(R=n.jsx(pe,{asChild:!0,children:n.jsx(K,{type:"button",variant:"ghost",size:"icon",className:"absolute top-2 right-2 h-6 w-6",onClick:u,disabled:_,children:w})}),e[18]=u,e[19]=_,e[20]=w,e[21]=R):R=e[21];const N=c?"Generating PR description...":"Generate PR title and description with AI";let y;e[22]!==N?(y=n.jsx(me,{children:N}),e[22]=N,e[23]=y):y=e[23];let S;e[24]!==R||e[25]!==y?(S=n.jsx(we,{children:n.jsxs(fe,{children:[R,y]})}),e[24]=R,e[25]=y,e[26]=S):S=e[26];let E;e[27]!==S||e[28]!==T?(E=n.jsxs("div",{className:"grid gap-2",children:[C,n.jsxs("div",{className:"relative",children:[T,S]})]}),e[27]=S,e[28]=T,e[29]=E):E=e[29];let k;e[30]!==E||e[31]!==I?(k=n.jsxs("div",{className:"grid gap-4 py-4",children:[I,E]}),e[30]=E,e[31]=I,e[32]=k):k=e[32];let A;e[33]!==r?(A=()=>r(!1),e[33]=r,e[34]=A):A=e[34];let D;e[35]!==d||e[36]!==A?(D=n.jsx(K,{variant:"outline",onClick:A,disabled:d,children:"Cancel"}),e[35]=d,e[36]=A,e[37]=D):D=e[37];const z=d?"Creating...":"Create PR";let O;e[38]!==d||e[39]!==f||e[40]!==z?(O=n.jsx(K,{onClick:f,disabled:d,children:z}),e[38]=d,e[39]=f,e[40]=z,e[41]=O):O=e[41];let L;e[42]!==D||e[43]!==O?(L=n.jsxs(Ye,{children:[D,O]}),e[42]=D,e[43]=O,e[44]=L):L=e[44];let F;e[45]!==k||e[46]!==p||e[47]!==L?(F=n.jsxs(Je,{children:[p,k,L]}),e[45]=k,e[46]=p,e[47]=L,e[48]=F):F=e[48];let B;return e[49]!==r||e[50]!==t||e[51]!==F?(B=n.jsx(mt,{open:t,onOpenChange:r,children:F}),e[49]=r,e[50]=t,e[51]=F,e[52]=B):B=e[52],B}function Mc(s){const e=$.c(48),{open:t,onOpenChange:r,repoName:a,onRepoNameChange:l,repoDescription:o,onRepoDescriptionChange:i,isPrivateRepo:c,onPrivateRepoChange:d,isLoading:u,onCreateRepo:f}=s;let g;e[0]!==r||e[1]!==i||e[2]!==l?(g=z=>{z||(l(""),i("")),r(z)},e[0]=r,e[1]=i,e[2]=l,e[3]=g):g=e[3];let h;e[4]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsxs(Qe,{children:[n.jsx(Ge,{children:"Create GitHub Repository"}),n.jsx(He,{children:"Create a new GitHub repository and push your local repository"})]}),e[4]=h):h=e[4];let p;e[5]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx(be,{htmlFor:"repo-name",children:"Repository Name (optional)"}),e[5]=p):p=e[5];let j;e[6]!==l?(j=z=>l(z.target.value),e[6]=l,e[7]=j):j=e[7];let v;e[8]!==a||e[9]!==j?(v=n.jsxs("div",{className:"grid gap-2",children:[p,n.jsx(Ke,{id:"repo-name",placeholder:"Leave empty to use current folder name",value:a,onChange:j})]}),e[8]=a,e[9]=j,e[10]=v):v=e[10];let b;e[11]===Symbol.for("react.memo_cache_sentinel")?(b=n.jsx(be,{htmlFor:"repo-description",children:"Description (optional)"}),e[11]=b):b=e[11];let I;e[12]!==i?(I=z=>i(z.target.value),e[12]=i,e[13]=I):I=e[13];let C;e[14]!==o||e[15]!==I?(C=n.jsxs("div",{className:"grid gap-2",children:[b,n.jsx(rs,{id:"repo-description",placeholder:"Enter repository description...",value:o,onChange:I,rows:3})]}),e[14]=o,e[15]=I,e[16]=C):C=e[16];let x;e[17]!==d?(x=z=>d(z===!0),e[17]=d,e[18]=x):x=e[18];let T;e[19]!==c||e[20]!==x?(T=n.jsx(Dt,{id:"repo-private",checked:c,onCheckedChange:x}),e[19]=c,e[20]=x,e[21]=T):T=e[21];let _;e[22]===Symbol.for("react.memo_cache_sentinel")?(_=n.jsx(be,{htmlFor:"repo-private",className:"text-sm font-normal",children:"Private repository"}),e[22]=_):_=e[22];let w;e[23]!==T?(w=n.jsxs("div",{className:"flex items-center gap-2",children:[T,_]}),e[23]=T,e[24]=w):w=e[24];let R;e[25]!==w||e[26]!==v||e[27]!==C?(R=n.jsxs("div",{className:"grid gap-4 py-4",children:[v,C,w]}),e[25]=w,e[26]=v,e[27]=C,e[28]=R):R=e[28];let N;e[29]!==r?(N=()=>r(!1),e[29]=r,e[30]=N):N=e[30];let y;e[31]!==u||e[32]!==N?(y=n.jsx(K,{variant:"outline",onClick:N,disabled:u,children:"Cancel"}),e[31]=u,e[32]=N,e[33]=y):y=e[33];const S=u?"Creating...":"Create & Push";let E;e[34]!==u||e[35]!==f||e[36]!==S?(E=n.jsx(K,{onClick:f,disabled:u,children:S}),e[34]=u,e[35]=f,e[36]=S,e[37]=E):E=e[37];let k;e[38]!==y||e[39]!==E?(k=n.jsxs(Ye,{children:[y,E]}),e[38]=y,e[39]=E,e[40]=k):k=e[40];let A;e[41]!==R||e[42]!==k?(A=n.jsxs(Je,{children:[h,R,k]}),e[41]=R,e[42]=k,e[43]=A):A=e[43];let D;return e[44]!==t||e[45]!==g||e[46]!==A?(D=n.jsx(mt,{open:t,onOpenChange:g,children:A}),e[44]=t,e[45]=g,e[46]=A,e[47]=D):D=e[47],D}function Dc(s){const e=$.c(28),{open:t,onOpenChange:r,commits:a,displayedCommits:l,isLoadingMore:o,onScroll:i,currentBranch:c}=s;let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(Ge,{children:"Commit History"}),e[0]=d):d=e[0];let u;e[1]!==c?(u=n.jsxs(Qe,{children:[d,n.jsxs(He,{children:["Recent commits on branch ",c]})]}),e[1]=c,e[2]=u):u=e[2];let f;e[3]!==l?(f=l.length>0?l.map(Ac):n.jsx("p",{className:"text-sm text-slate-500 text-center py-8",children:"No commits found"}),e[3]=l,e[4]=f):f=e[4];let g;e[5]!==o?(g=o&&n.jsx("div",{className:"p-3 text-center",children:n.jsx(ve,{className:"h-4 w-4 animate-spin inline"})}),e[5]=o,e[6]=g):g=e[6];let h;e[7]!==a.length||e[8]!==l.length||e[9]!==o?(h=l.length<a.length&&!o&&n.jsx("div",{className:"p-3 text-center text-xs text-slate-500",children:"Scroll to load more"}),e[7]=a.length,e[8]=l.length,e[9]=o,e[10]=h):h=e[10];let p;e[11]!==f||e[12]!==g||e[13]!==h?(p=n.jsxs("div",{className:"divide-y",children:[f,g,h]}),e[11]=f,e[12]=g,e[13]=h,e[14]=p):p=e[14];let j;e[15]!==i||e[16]!==p?(j=n.jsx("div",{className:"flex-1 overflow-y-auto border rounded-lg",onScroll:i,children:p}),e[15]=i,e[16]=p,e[17]=j):j=e[17];let v;e[18]!==r?(v=n.jsx(Ye,{children:n.jsx(K,{onClick:()=>r(!1),children:"Close"})}),e[18]=r,e[19]=v):v=e[19];let b;e[20]!==u||e[21]!==j||e[22]!==v?(b=n.jsxs(Je,{className:"max-w-2xl max-h-[80vh] flex flex-col",children:[u,j,v]}),e[20]=u,e[21]=j,e[22]=v,e[23]=b):b=e[23];let I;return e[24]!==r||e[25]!==t||e[26]!==b?(I=n.jsx(mt,{open:t,onOpenChange:r,children:b}),e[24]=r,e[25]=t,e[26]=b,e[27]=I):I=e[27],I}function Ac(s){return n.jsxs("div",{className:"p-3 hover:bg-slate-50 dark:hover:bg-slate-900 transition-colors",children:[n.jsx("p",{className:"text-sm font-medium break-words",children:s.message}),n.jsxs("p",{className:"text-xs text-slate-600 dark:text-slate-400 mt-1",children:[n.jsx("span",{className:"font-mono",children:s.hash.substring(0,7)})," • ",s.author," • ",new Date(s.date).toLocaleDateString()]})]},s.hash)}function Lc(s){const e=$.c(15),{open:t,onOpenChange:r,isLoading:a,onPushAndCreatePR:l,onCancel:o}=s;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsxs(Qe,{children:[n.jsx(Ge,{children:"Push Branch First"}),n.jsx(He,{children:"Your branch needs to be pushed to the remote before creating a pull request. Would you like to push it now?"})]}),e[0]=i):i=e[0];let c;e[1]!==a||e[2]!==o?(c=n.jsx(K,{variant:"outline",onClick:o,disabled:a,children:"Cancel"}),e[1]=a,e[2]=o,e[3]=c):c=e[3];const d=a?"Pushing...":"Push & Create PR";let u;e[4]!==a||e[5]!==l||e[6]!==d?(u=n.jsx(K,{onClick:l,disabled:a,children:d}),e[4]=a,e[5]=l,e[6]=d,e[7]=u):u=e[7];let f;e[8]!==c||e[9]!==u?(f=n.jsxs(Je,{children:[i,n.jsxs(Ye,{children:[c,u]})]}),e[8]=c,e[9]=u,e[10]=f):f=e[10];let g;return e[11]!==r||e[12]!==t||e[13]!==f?(g=n.jsx(mt,{open:t,onOpenChange:r,children:f}),e[11]=r,e[12]=t,e[13]=f,e[14]=g):g=e[14],g}function $c(s){const e=$.c(11),[t,r]=m.useState(!1),[a,l]=m.useState(0),[o,i]=m.useState(!1),[c,d]=m.useState("");let u;e[0]!==s?(u=async()=>{if(s)try{const j=await vo(s);r(j.hasChanges),l(j.changedFilesCount),i(j.hasUnpushedCommits),d(j.currentBranch)}catch(j){console.error("Failed to fetch git status:",j)}},e[0]=s,e[1]=u):u=e[1];const f=u;let g,h;e[2]!==f?(g=()=>{(async()=>await f())()},h=[f],e[2]=f,e[3]=g,e[4]=h):(g=e[3],h=e[4]),m.useEffect(g,h);let p;return e[5]!==a||e[6]!==c||e[7]!==f||e[8]!==t||e[9]!==o?(p={hasChanges:t,changedFilesCount:a,hasUnpushedCommits:o,currentBranch:c,fetchGitStatus:f},e[5]=a,e[6]=c,e[7]=f,e[8]=t,e[9]=o,e[10]=p):p=e[10],p}function Oc(s){const[e,t]=m.useState(!1),[r,a]=m.useState(null),l=m.useCallback(async()=>{if(s)try{const o=await Io(s);t(o.canCreateRepo),a(o.repoUrl||null)}catch(o){console.error("Failed to fetch GitHub status:",o)}},[s]);return m.useEffect(()=>{(async()=>await l())()},[l]),{canCreateRepo:e,gitHubUrl:r,fetchGitHubStatus:l}}function Fc(s){const e=s.split("/");return e.length>=2?{provider:e[0],model:e.slice(1).join("/")}:{provider:void 0,model:s}}function Gc(s,e,t){const[r,a]=m.useState(!1),[l,o]=m.useState(!1),i=()=>{const u=t[e];return u?Fc(u):{provider:void 0,model:void 0}};return{isGeneratingMessage:r,isGeneratingPRInfo:l,generateCommitMessageWithAI:async()=>{if(!s)return null;try{a(!0);const{provider:u,model:f}=i();return await No(s,f,u)}catch(u){console.error("Failed to generate commit message:",u);const f=u instanceof Error?u.message:"Failed to generate commit message";return je({title:"Error",description:f,variant:"destructive"}),null}finally{a(!1)}},generatePRInfoWithAI:async()=>{if(!s)return null;try{o(!0);const{provider:u,model:f}=i(),g=await So(s,f,u);return je({title:"Success",description:"PR title and description generated"}),g}catch(u){console.error("Failed to generate PR info:",u);const f=u instanceof Error?u.message:"Failed to generate PR info";return je({title:"Error",description:f,variant:"destructive"}),null}finally{o(!1)}}}}function Hc({projectId:s,threadId:e}){const{state:t,dispatch:r}=Se(),[a,l]=m.useState(!1),[o,i]=m.useState(!1),[c,d]=m.useState(!1),[u,f]=m.useState(""),[g,h]=m.useState(""),[p,j]=m.useState(""),[v,b]=m.useState(!1),[I,C]=m.useState(null),[x,T]=m.useState(!1),[_,w]=m.useState([]),[R,N]=m.useState(!1),[y,S]=m.useState([]),[E,k]=m.useState(!1),A=10,[D,z]=m.useState(!1),[O,L]=m.useState(""),[F,B]=m.useState(""),W=$c(e),Q=Oc(e),se=Gc(e,s,t.projectModelSelections),[de,ie]=m.useState(()=>Ec()),re=t.projects.find(q=>q.projectId===s),ae=re?.commitMethod===he.Direct;m.useEffect(()=>{D&&re?.name&&!O&&L(re.name)},[D,re?.name,O]),m.useEffect(()=>{kc(de)},[de]),m.useEffect(()=>{o&&de.autoGenerateCommitMessage&&!u.trim()&&e&&(async()=>{const oe=await se.generateCommitMessageWithAI();oe&&f(oe)})()},[o,de.autoGenerateCommitMessage,u,e,se]),m.useEffect(()=>{!t.isStreaming&&t.completedThreadIds.includes(t.selectedThreadId||"")&&(W.fetchGitStatus(),Q.fetchGitHubStatus(),r({type:P.ClearThreadCompleted,threadId:t.selectedThreadId||""}))},[t.isStreaming,t.completedThreadIds,t.selectedThreadId,W,Q,r]);const le=async()=>{if(u.trim()&&Xt(e))try{l(!0),await wo(e,u),f(""),i(!1),await W.fetchGitStatus()}catch(q){console.error("Failed to commit:",q)}finally{l(!1)}},ce=async()=>{const q=await se.generateCommitMessageWithAI();q&&f(q)},ee=async()=>{if(Xt(e))try{l(!0),await Co(e),await W.fetchGitStatus()}catch(q){console.error("Failed to fetch:",q)}finally{l(!1)}},te=async()=>{if(Xt(e))try{l(!0),await Cn(e),await W.fetchGitStatus()}catch(q){console.error("Failed to push:",q)}finally{l(!1)}},M=async()=>{if(Xt(e))try{l(!0);const q=await Tn(e,g,p);q.prUrl&&window.open(q.prUrl,"_blank"),h(""),j(""),d(!1),await W.fetchGitStatus()}catch(q){console.error("Failed to create PR:",q);const oe=q instanceof Error?q.message:"Failed to create PR";(oe.includes("push the current branch")||oe.includes("--head flag"))&&(C({title:g,description:p}),d(!1),b(!0))}finally{l(!1)}},H=async()=>{if(Xt(e))try{l(!0);const q=await Ro(e,O,F,de.privateRepositoryDefault);q.repoUrl&&setTimeout(()=>{window.open(q.repoUrl,"_blank")},3e3),L(""),B(""),z(!1),await Q.fetchGitHubStatus(),await W.fetchGitStatus()}catch(q){console.error("Failed to create repo:",q)}finally{l(!1)}},G=async()=>{const q=await se.generatePRInfoWithAI();q&&(h(q.title),j(q.description))},V=async()=>{if(!(!e||!I))try{l(!0),await Cn(e);const q=await Tn(e,I.title,I.description);q.prUrl&&window.open(q.prUrl,"_blank"),h(""),j(""),C(null),b(!1),await W.fetchGitStatus()}catch(q){console.error("Failed to push and create PR:",q)}finally{l(!1)}},X=async()=>{if(Xt(e))try{N(!0);const q=await To(e,100);w(q),S(q.slice(0,A)),T(!0)}catch(q){console.error("Failed to fetch git history:",q)}finally{N(!1)}},Z=()=>{E||(k(!0),setTimeout(()=>{const q=y.length+A,oe=_.slice(0,q);S(oe),k(!1)},300))},Y=q=>{const oe=q.currentTarget;oe.scrollHeight-oe.scrollTop-oe.clientHeight<100&&y.length<_.length&&!E&&Z()};return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"flex items-center gap-0",children:[n.jsx(we,{children:n.jsxs(fe,{children:[n.jsx(pe,{asChild:!0,children:n.jsxs(K,{variant:"outline",size:"sm",className:"h-8 rounded-r-none border-r-0 gap-1.5",disabled:!W.hasChanges||a,onClick:()=>i(!0),children:[n.jsx(il,{className:"h-3.5 w-3.5"}),"Commit",W.hasChanges&&W.changedFilesCount>0&&n.jsx(Rc,{variant:"secondary",className:"h-4 px-1 text-[10px] font-medium",children:W.changedFilesCount})]})}),n.jsx(me,{children:W.hasChanges?`Commit ${W.changedFilesCount} changed file${W.changedFilesCount!==1?"s":""}`:"No changes to commit"})]})}),n.jsxs(la,{children:[n.jsx(oa,{asChild:!0,children:n.jsx(K,{variant:"outline",size:"sm",className:"h-8 w-8 rounded-l-none px-1",disabled:a,children:n.jsx(It,{className:"h-3.5 w-3.5"})})}),n.jsxs(gn,{align:"end",children:[n.jsxs(Ct,{onClick:ee,disabled:a,children:[n.jsx(cl,{className:"h-3.5 w-3.5 mr-2"}),"Fetch"]}),n.jsxs(Ct,{onClick:te,disabled:!W.hasUnpushedCommits||a,children:[n.jsx(dl,{className:"h-3.5 w-3.5 mr-2"}),"Push Commits"]}),n.jsxs(Ct,{onClick:X,disabled:a||R,children:[n.jsx(ul,{className:"h-3.5 w-3.5 mr-2"}),"History"]}),!ae&&n.jsxs(Ct,{onClick:()=>d(!0),disabled:a,children:[n.jsx(ml,{className:"h-3.5 w-3.5 mr-2"}),"Create Pull Request"]}),Q.canCreateRepo&&n.jsxs(Ct,{onClick:()=>z(!0),disabled:a,children:[n.jsx(fl,{className:"h-3.5 w-3.5 mr-2"}),"Create Repo"]}),Q.gitHubUrl&&n.jsxs(Ct,{onClick:()=>Q.gitHubUrl&&window.open(Q.gitHubUrl,"_blank"),disabled:a,children:[n.jsx(xs,{className:"h-3.5 w-3.5 mr-2"}),"View in GitHub"]})]})]})]}),n.jsx(_c,{open:o,onOpenChange:i,commitMessage:u,onCommitMessageChange:f,autoGenerateCommitMessage:de.autoGenerateCommitMessage,onAutoGenerateChange:q=>ie(oe=>({...oe,autoGenerateCommitMessage:q})),isGeneratingMessage:se.isGeneratingMessage,isLoading:a,onGenerateMessage:ce,onCommit:le,currentBranch:W.currentBranch}),n.jsx(Pc,{open:c,onOpenChange:d,prTitle:g,onPrTitleChange:h,prDescription:p,onPrDescriptionChange:j,isGeneratingPRInfo:se.isGeneratingPRInfo,isLoading:a,onGeneratePRInfo:G,onCreatePR:M,currentBranch:W.currentBranch}),n.jsx(Lc,{open:v,onOpenChange:b,isLoading:a,onPushAndCreatePR:V,onCancel:()=>{b(!1),C(null)}}),n.jsx(Mc,{open:D,onOpenChange:z,repoName:O,onRepoNameChange:L,repoDescription:F,onRepoDescriptionChange:B,isPrivateRepo:de.privateRepositoryDefault,onPrivateRepoChange:q=>ie(oe=>({...oe,privateRepositoryDefault:q})),isLoading:a,onCreateRepo:H}),n.jsx(Dc,{open:x,onOpenChange:T,commits:_,displayedCommits:y,isLoadingMore:E,onScroll:Y,currentBranch:W.currentBranch})]})}const Uc=["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"];function zc({open:s,onOpenChange:e,projectId:t,commands:r,onRefresh:a}){const[l,o]=m.useState(null),[i,c]=m.useState(!1),d=()=>{o({id:crypto.randomUUID(),name:"",icon:"Play",commandLine:""})},u=h=>{o({...h})},f=async h=>{try{await ko(t,h),je({title:"Success",description:"Command deleted"}),a()}catch{je({title:"Error",description:"Failed to delete command",variant:"destructive"})}},g=async()=>{if(!l?.name||!l?.commandLine){je({title:"Error",description:"Name and Command Line are required",variant:"destructive"});return}try{c(!0),await Eo(t,l),je({title:"Success",description:"Command saved"}),o(null),a()}catch{je({title:"Error",description:"Failed to save command",variant:"destructive"})}finally{c(!1)}};return n.jsx(mt,{open:s,onOpenChange:e,children:n.jsxs(Je,{className:"sm:max-w-[500px]",children:[n.jsxs(Qe,{children:[n.jsx(Ge,{children:"Project Commands"}),n.jsx(He,{children:"Manage custom commands for this project. These commands will be available in the toolbar for all threads."})]}),n.jsx("div",{className:"py-4 flex flex-col gap-4",children:l?n.jsxs("div",{className:"p-4 border rounded-lg bg-muted/30 flex flex-col gap-4 animate-in slide-in-from-top-2",children:[n.jsxs("div",{className:"grid gap-2",children:[n.jsx(be,{htmlFor:"name",children:"Command Name"}),n.jsx(Ke,{id:"name",value:l.name,onChange:h=>o({...l,name:h.target.value}),placeholder:"e.g. Run Tests",autoComplete:"off"})]}),n.jsxs("div",{className:"grid gap-2",children:[n.jsx(be,{htmlFor:"commandLine",children:"Command Line"}),n.jsx(rs,{id:"commandLine",value:l.commandLine,onChange:h=>o({...l,commandLine:h.target.value}),placeholder:"e.g. npm test",className:"font-mono text-xs min-h-[100px] resize-none"})]}),n.jsxs("div",{className:"grid gap-2",children:[n.jsx(be,{children:"Icon"}),n.jsx("div",{className:"grid grid-cols-10 gap-1 p-2 bg-background rounded-md border border-border",children:Uc.map(h=>{const p=Qs[h]||pl,j=l.icon===h;return n.jsx(K,{variant:j?"default":"ghost",size:"icon",className:"h-8 w-8",onClick:()=>o({...l,icon:h}),title:h,children:n.jsx(p,{className:"h-4 w-4"})},h)})})]}),n.jsxs("div",{className:"flex justify-end gap-2 mt-2",children:[n.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>o(null),children:[n.jsx(ut,{className:"h-4 w-4 mr-2"})," Cancel"]}),n.jsxs(K,{size:"sm",onClick:g,disabled:i,children:[n.jsx(ht,{className:"h-4 w-4 mr-2"})," ",i?"Saving...":"Save Command"]})]})]}):n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"flex flex-col gap-2 max-h-[400px] overflow-y-auto pr-2",children:[r.length===0&&n.jsx("div",{className:"text-center py-8 text-muted-foreground border-2 border-dashed rounded-lg",children:"No commands defined yet."}),r.map(h=>n.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:()=>u(h),children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("div",{className:"p-2 bg-muted rounded",children:(()=>{const p=Qs[h.icon]||cn;return n.jsx(p,{className:"h-4 w-4"})})()}),n.jsxs("div",{className:"flex flex-col",children:[n.jsx("span",{className:"text-sm font-medium",children:h.name}),n.jsx("span",{className:"text-xs text-muted-foreground line-clamp-1 font-mono",children:h.commandLine})]})]}),n.jsx("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:n.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:text-destructive hover:bg-destructive/10",onClick:p=>{p.stopPropagation(),f(h.id)},children:n.jsx(Js,{className:"h-4 w-4"})})})]},h.id))]}),n.jsxs(K,{variant:"outline",className:"w-full border-dashed",onClick:d,children:[n.jsx(hs,{className:"h-4 w-4 mr-2"})," Add New Command"]})]})}),n.jsx(Ye,{children:n.jsx(K,{variant:"ghost",onClick:()=>e(!1),children:"Close"})})]})})}function Bc(){const s=$.c(27),{state:e}=Se(),{selectedProjectId:t,selectedThreadId:r,projects:a}=e,{dispatch:l}=ys(r),[o,i]=m.useState(!1);let c,d,u,f,g;if(s[0]!==l||s[1]!==a||s[2]!==t||s[3]!==r||s[4]!==e.isRunningCommand){g=Symbol.for("react.early_return_sentinel");e:{let j;s[10]!==t?(j=x=>x.projectId===t,s[10]=t,s[11]=j):j=s[11],c=a.find(j)?.commands||[];let b;s[12]!==l||s[13]!==t||s[14]!==r?(b=x=>{!t||!r||l({type:P.QueueTerminalCommand,command:x})},s[12]=l,s[13]=t,s[14]=r,s[15]=b):b=s[15];const I=b;let C;if(s[16]!==l?(C=async()=>{l({type:P.ConfigUpdated})},s[16]=l,s[17]=C):C=s[17],d=C,!t){g=null;break e}u="flex items-center gap-1 mr-2",f=c.length===0?n.jsx(we,{children:n.jsxs(fe,{children:[n.jsx(pe,{asChild:!0,children:n.jsxs(K,{variant:"ghost",size:"sm",className:"h-8 gap-1.5 text-muted-foreground hover:text-foreground",onClick:()=>i(!0),children:[n.jsx(Ks,{className:"h-4 w-4"}),n.jsx("span",{className:"text-xs font-medium",children:"Commands"})]})}),n.jsx(me,{children:"Manage project commands"})]})}):n.jsx(n.Fragment,{children:n.jsxs(we,{children:[c.map(x=>{const T=Qs[x.icon]||cn;return n.jsxs(fe,{children:[n.jsx(pe,{asChild:!0,children:n.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-foreground",onClick:()=>I(x.commandLine),disabled:e.isRunningCommand,children:n.jsx(T,{className:"h-4 w-4"})})}),n.jsx(me,{children:n.jsxs("div",{className:"flex flex-col gap-0.5",children:[n.jsx("span",{className:"font-medium",children:x.name}),n.jsx("span",{className:"text-[10px] opacity-70 font-mono whitespace-pre-wrap max-w-[300px] max-h-[100px] overflow-y-auto",children:x.commandLine})]})})]},x.id)}),n.jsxs(fe,{children:[n.jsx(pe,{asChild:!0,children:n.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-foreground ml-1",onClick:()=>i(!0),children:n.jsx(Ks,{className:"h-4 w-4"})})}),n.jsx(me,{children:"Manage commands"})]})]})})}s[0]=l,s[1]=a,s[2]=t,s[3]=r,s[4]=e.isRunningCommand,s[5]=c,s[6]=d,s[7]=u,s[8]=f,s[9]=g}else c=s[5],d=s[6],u=s[7],f=s[8],g=s[9];if(g!==Symbol.for("react.early_return_sentinel"))return g;let h;s[18]!==c||s[19]!==d||s[20]!==t||s[21]!==o?(h=n.jsx(zc,{open:o,onOpenChange:i,projectId:t,commands:c,onRefresh:d}),s[18]=c,s[19]=d,s[20]=t,s[21]=o,s[22]=h):h=s[22];let p;return s[23]!==u||s[24]!==f||s[25]!==h?(p=n.jsxs("div",{className:u,children:[f,h]}),s[23]=u,s[24]=f,s[25]=h,s[26]=p):p=s[26],p}function qc({projectId:s,runCommand:e}){const{state:t}=Se(),{selectedThreadId:r}=t,{dispatch:a}=ys(r),[l,o]=m.useState(!1),[i,c]=m.useState(!1);m.useEffect(()=>{(async()=>{try{const h=await Lo(s);o(h.isRunning)}catch{o(!1)}})()},[s]);const d=async()=>{if(!e)return;c(!0),a({type:P.ClearTerminalOutput}),a({type:P.SetTerminalOpen,open:!1}),a({type:P.AppendTerminalLine,line:{type:"system",content:`Starting dev server: ${e}`}});let g=!1;const h=setTimeout(()=>{g=!0,a({type:P.SetTerminalOpen,open:!0})},3e3);try{const p=await Do(s);if(!p){clearTimeout(h),je({title:"Error",description:"Failed to start dev server",variant:"destructive"}),a({type:P.AppendTerminalLine,line:{type:"error",content:"Failed to start dev server"}}),c(!1);return}const j=p.getReader(),v=new TextDecoder;o(!0);let b=!1,I=!1,C=null;for(C=setTimeout(()=>{I||c(!1)},3e3);;){const{done:x,value:T}=await j.read();if(x)break;const _=v.decode(T,{stream:!0});try{const w=_.split(`
|
|
13
|
+
`).filter(R=>R.trim());for(const R of w)try{const N=JSON.parse(R);I||(I=!0,c(!1),C&&clearTimeout(C)),(N.type==="stdout"||N.type==="stderr")&&a({type:P.AppendTerminalLine,line:{type:"output",content:N.content}}),N.type==="url"&&N.url&&(clearTimeout(h),a({type:P.AppendTerminalLine,line:{type:"system",content:`✓ Server running at: ${N.url}`}}),window.open(N.url,"_blank"),g&&setTimeout(()=>{a({type:P.SetTerminalOpen,open:!1})},100),je({title:"Dev server started",description:`Server running at ${N.url}`}),b=!0),N.type==="error"&&N.content&&a({type:P.AppendTerminalLine,line:{type:"error",content:N.content}})}catch{_.trim()&&a({type:P.AppendTerminalLine,line:{type:"output",content:_}})}}catch{_.trim()&&a({type:P.AppendTerminalLine,line:{type:"output",content:_}})}}clearTimeout(h),C&&clearTimeout(C),c(!1),b||(a({type:P.AppendTerminalLine,line:{type:"system",content:"Server is running but URL could not be detected"}}),je({title:"Dev server started",description:"Server is running but URL could not be detected"}))}catch(p){clearTimeout(h),o(!1),c(!1);const j=p instanceof Error?p.message:"Failed to start dev server";a({type:P.AppendTerminalLine,line:{type:"error",content:j}}),je({title:"Error",description:j,variant:"destructive"})}},u=async()=>{c(!0);try{await Ao(s),o(!1),a({type:P.AppendTerminalLine,line:{type:"system",content:"Server stopped"}})}catch(g){const h=g instanceof Error?g.message:"Failed to stop dev server";a({type:P.AppendTerminalLine,line:{type:"error",content:h}}),je({title:"Error",description:h,variant:"destructive"})}finally{c(!1)}},f=!!e;return n.jsx(n.Fragment,{children:n.jsx(we,{children:n.jsxs(fe,{children:[n.jsx(pe,{asChild:!0,children:n.jsxs(K,{variant:"ghost",size:"icon",className:`h-8 w-8 ${l?"text-orange-500 hover:text-orange-600 bg-orange-500/10":"text-muted-foreground hover:text-foreground"}`,onClick:l?u:d,disabled:i||!l&&!f,children:[i?n.jsx(ve,{className:"h-4 w-4 animate-spin"}):l?n.jsx(zn,{className:"h-4 w-4 fill-current"}):n.jsx(cn,{className:"h-4 w-4"}),n.jsx("span",{className:"sr-only",children:l?"Stop dev server":"Start dev server"})]})}),n.jsx(me,{children:l?"Stop dev server":f?`Start dev server: ${e}`:"Set run command in project settings"})]})})})}function Wc(){const s=$.c(10),{state:e}=Se(),{selectedThreadId:t}=e,{terminalState:r,dispatch:a}=ys(t),{open:l}=r,o=`h-8 w-8 ${l?"text-primary bg-primary/10":"text-muted-foreground"}`;let i;s[0]!==a?(i=()=>a({type:P.ToggleTerminal}),s[0]=a,s[1]=i):i=s[1];let c,d;s[2]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(ds,{className:"h-4 w-4"}),d=n.jsx("span",{className:"sr-only",children:"Toggle terminal"}),s[2]=c,s[3]=d):(c=s[2],d=s[3]);let u;s[4]!==o||s[5]!==i?(u=n.jsx(pe,{asChild:!0,children:n.jsxs(K,{variant:"ghost",size:"icon",className:o,onClick:i,children:[c,d]})}),s[4]=o,s[5]=i,s[6]=u):u=s[6];let f;s[7]===Symbol.for("react.memo_cache_sentinel")?(f=n.jsx(me,{children:"Show Terminal"}),s[7]=f):f=s[7];let g;return s[8]!==u?(g=n.jsx(we,{children:n.jsxs(fe,{children:[u,f]})}),s[8]=u,s[9]=g):g=s[9],g}function Vc(){const s=$.c(10),{state:e,dispatch:t}=Se(),r=`h-8 w-8 ${e.reviewMode?"text-primary bg-primary/10":"text-muted-foreground"}`;let a;s[0]!==t?(a=()=>t({type:P.ToggleReviewMode}),s[0]=t,s[1]=a):a=s[1];let l,o;s[2]===Symbol.for("react.memo_cache_sentinel")?(l=n.jsx(hl,{className:"h-4 w-4"}),o=n.jsx("span",{className:"sr-only",children:"Review changes"}),s[2]=l,s[3]=o):(l=s[2],o=s[3]);let i;s[4]!==r||s[5]!==a?(i=n.jsx(pe,{asChild:!0,children:n.jsxs(K,{variant:"ghost",size:"icon",className:r,onClick:a,children:[l,o]})}),s[4]=r,s[5]=a,s[6]=i):i=s[6];let c;s[7]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(me,{children:"Review Changes"}),s[7]=c):c=s[7];let d;return s[8]!==i?(d=n.jsx(we,{children:n.jsxs(fe,{children:[i,c]})}),s[8]=i,s[9]=d):d=s[9],d}function Kc(){const s=$.c(28),{state:e,dispatch:t}=Se(),{selectedThreadId:r,selectedProjectId:a,projects:l,sidebarOpen:o}=e;let i;if(s[0]!==l||s[1]!==a){let b;s[3]!==a?(b=I=>I.projectId===a,s[3]=a,s[4]=b):b=s[4],i=l.find(b),s[0]=l,s[1]=a,s[2]=i}else i=s[2];const c=i;let d;s[5]!==t?(d=()=>t({type:P.ToggleSidebar}),s[5]=t,s[6]=d):d=s[6];let u;s[7]!==o?(u=o?n.jsx(Fn,{className:"h-4 w-4"}):n.jsx(gl,{className:"h-4 w-4"}),s[7]=o,s[8]=u):u=s[8];let f;s[9]===Symbol.for("react.memo_cache_sentinel")?(f=n.jsx("span",{className:"sr-only",children:"Toggle sidebar"}),s[9]=f):f=s[9];let g;s[10]!==d||s[11]!==u?(g=n.jsxs(K,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground",onClick:d,children:[u,f]}),s[10]=d,s[11]=u,s[12]=g):g=s[12];let h;s[13]!==l||s[14]!==a||s[15]!==r?(h=r&&n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"text-sm font-medium text-foreground",children:Gl(l,r)}),n.jsx("span",{className:"text-xs text-muted-foreground",children:Hl(l,a)})]}),s[13]=l,s[14]=a,s[15]=r,s[16]=h):h=s[16];let p;s[17]!==c?.openWith||s[18]!==c?.runCommand||s[19]!==a||s[20]!==r?(p=a&&n.jsxs(n.Fragment,{children:[r&&n.jsxs(n.Fragment,{children:[n.jsx(Vc,{}),n.jsx(Wc,{})]}),n.jsx(qc,{projectId:a,runCommand:c?.runCommand}),r&&n.jsxs(n.Fragment,{children:[n.jsx(Bc,{}),n.jsx(Hc,{projectId:a,threadId:r}),n.jsx(Tc,{projectId:a,threadId:r,openWith:c?.openWith})]})]}),s[17]=c?.openWith,s[18]=c?.runCommand,s[19]=a,s[20]=r,s[21]=p):p=s[21];let j;s[22]!==p?(j=n.jsx("div",{className:"ml-auto flex items-center gap-2",children:p}),s[22]=p,s[23]=j):j=s[23];let v;return s[24]!==g||s[25]!==h||s[26]!==j?(v=n.jsxs("header",{className:"flex h-12 shrink-0 items-center gap-2 border-b border-border px-4",children:[g,h,j]}),s[24]=g,s[25]=h,s[26]=j,s[27]=v):v=s[27],v}const xn=jl,Jc=xl,ca=m.forwardRef((s,e)=>{const t=$.c(9);let r,a;t[0]!==s?({className:r,...a}=s,t[0]=s,t[1]=r,t[2]=a):(r=t[1],a=t[2]);let l;t[3]!==r?(l=U("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",r),t[3]=r,t[4]=l):l=t[4];let o;return t[5]!==a||t[6]!==e||t[7]!==l?(o=n.jsx(hr,{className:l,...a,ref:e}),t[5]=a,t[6]=e,t[7]=l,t[8]=o):o=t[8],o});ca.displayName=hr.displayName;const Ds=m.forwardRef((s,e)=>{const t=$.c(10);let r,a;t[0]!==s?({className:r,...a}=s,t[0]=s,t[1]=r,t[2]=a):(r=t[1],a=t[2]);let l;t[3]===Symbol.for("react.memo_cache_sentinel")?(l=n.jsx(ca,{}),t[3]=l):l=t[3];let o;t[4]!==r?(o=U("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 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-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",r),t[4]=r,t[5]=o):o=t[5];let i;return t[6]!==a||t[7]!==e||t[8]!==o?(i=n.jsxs(Jc,{children:[l,n.jsx(gr,{ref:e,className:o,...a})]}),t[6]=a,t[7]=e,t[8]=o,t[9]=i):i=t[9],i});Ds.displayName=gr.displayName;const As=s=>{const e=$.c(8);let t,r;e[0]!==s?({className:t,...r}=s,e[0]=s,e[1]=t,e[2]=r):(t=e[1],r=e[2]);let a;e[3]!==t?(a=U("flex flex-col space-y-2 text-center sm:text-left",t),e[3]=t,e[4]=a):a=e[4];let l;return e[5]!==r||e[6]!==a?(l=n.jsx("div",{className:a,...r}),e[5]=r,e[6]=a,e[7]=l):l=e[7],l};As.displayName="AlertDialogHeader";const Ls=s=>{const e=$.c(8);let t,r;e[0]!==s?({className:t,...r}=s,e[0]=s,e[1]=t,e[2]=r):(t=e[1],r=e[2]);let a;e[3]!==t?(a=U("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),e[3]=t,e[4]=a):a=e[4];let l;return e[5]!==r||e[6]!==a?(l=n.jsx("div",{className:a,...r}),e[5]=r,e[6]=a,e[7]=l):l=e[7],l};Ls.displayName="AlertDialogFooter";const $s=m.forwardRef((s,e)=>{const t=$.c(9);let r,a;t[0]!==s?({className:r,...a}=s,t[0]=s,t[1]=r,t[2]=a):(r=t[1],a=t[2]);let l;t[3]!==r?(l=U("text-lg font-semibold",r),t[3]=r,t[4]=l):l=t[4];let o;return t[5]!==a||t[6]!==e||t[7]!==l?(o=n.jsx(xr,{ref:e,className:l,...a}),t[5]=a,t[6]=e,t[7]=l,t[8]=o):o=t[8],o});$s.displayName=xr.displayName;const Os=m.forwardRef((s,e)=>{const t=$.c(9);let r,a;t[0]!==s?({className:r,...a}=s,t[0]=s,t[1]=r,t[2]=a):(r=t[1],a=t[2]);let l;t[3]!==r?(l=U("text-sm text-muted-foreground",r),t[3]=r,t[4]=l):l=t[4];let o;return t[5]!==a||t[6]!==e||t[7]!==l?(o=n.jsx(jr,{ref:e,className:l,...a}),t[5]=a,t[6]=e,t[7]=l,t[8]=o):o=t[8],o});Os.displayName=jr.displayName;const jn=m.forwardRef((s,e)=>{const t=$.c(9);let r,a;t[0]!==s?({className:r,...a}=s,t[0]=s,t[1]=r,t[2]=a):(r=t[1],a=t[2]);let l;t[3]!==r?(l=U(dn(),r),t[3]=r,t[4]=l):l=t[4];let o;return t[5]!==a||t[6]!==e||t[7]!==l?(o=n.jsx(yr,{ref:e,className:l,...a}),t[5]=a,t[6]=e,t[7]=l,t[8]=o):o=t[8],o});jn.displayName=yr.displayName;const yn=m.forwardRef((s,e)=>{const t=$.c(9);let r,a;t[0]!==s?({className:r,...a}=s,t[0]=s,t[1]=r,t[2]=a):(r=t[1],a=t[2]);let l;t[3]!==r?(l=U(dn({variant:"outline"}),"mt-2 sm:mt-0",r),t[3]=r,t[4]=l):l=t[4];let o;return t[5]!==a||t[6]!==e||t[7]!==l?(o=n.jsx(br,{ref:e,className:l,...a}),t[5]=a,t[6]=e,t[7]=l,t[8]=o):o=t[8],o});yn.displayName=br.displayName;function Qc(s){const e=$.c(13),{open:t,projectName:r,onOpenChange:a,onConfirm:l}=s;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx($s,{children:"Delete Project"}),e[0]=o):o=e[0];let i;e[1]!==r?(i=n.jsxs(As,{children:[o,n.jsxs(Os,{children:["Are you sure you want to delete ",n.jsxs("span",{className:"font-semibold text-foreground",children:['"',r,'"']}),"? This will remove the project and all its data. This action cannot be undone."]})]}),e[1]=r,e[2]=i):i=e[2];let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(yn,{children:"Cancel"}),e[3]=c):c=e[3];let d;e[4]!==l?(d=n.jsxs(Ls,{children:[c,n.jsx(jn,{onClick:l,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]}),e[4]=l,e[5]=d):d=e[5];let u;e[6]!==i||e[7]!==d?(u=n.jsxs(Ds,{children:[i,d]}),e[6]=i,e[7]=d,e[8]=u):u=e[8];let f;return e[9]!==a||e[10]!==t||e[11]!==u?(f=n.jsx(xn,{open:t,onOpenChange:a,children:u}),e[9]=a,e[10]=t,e[11]=u,e[12]=f):f=e[12],f}function Yc({open:s,onOpenChange:e,projectId:t,onRefresh:r}){const[a,l]=m.useState(""),[o,i]=m.useState(""),[c,d]=m.useState(""),[u,f]=m.useState(he.PullRequest),[g,h]=m.useState(!1),[p,j]=m.useState(!1),[v,b]=m.useState(!1),[I,C]=m.useState(""),[x,T]=m.useState(""),[_,w]=m.useState(""),[R,N]=m.useState(he.PullRequest),y=m.useCallback(async()=>{b(!0);try{const k=await ro(t),A=k.name||"",D=k.setupScript||"",z=k.runCommand||"",O=k.commitMethod||he.PullRequest;l(A),i(D),d(z),f(O),C(A),T(D),w(z),N(O)}catch(k){je({title:"Error",description:k instanceof Error?k.message:"Failed to load project settings",variant:"destructive"})}finally{b(!1)}},[t]);m.useEffect(()=>{s&&y()},[s,t,y]);const S=async()=>{j(!0);try{const k=await Mo(t);k.runCommand?(d(k.runCommand),je({title:"Success",description:`Suggested: ${k.runCommand}`})):je({title:"No command found",description:"Could not detect a dev script in package.json"})}catch(k){je({title:"Error",description:k instanceof Error?k.message:"Failed to suggest command",variant:"destructive"})}finally{j(!1)}},E=async()=>{h(!0);try{if(a!==I&&await yo(t,a),o!==x){const k=o.trim()||null;await Qr(t,k,!1)}if(c!==_){const k=c.trim()||null;await $o(t,k)}u!==R&&await bs(t,{commitMethod:u}),je({title:"Success",description:"Project settings saved"}),await r(),e(!1)}catch(k){je({title:"Error",description:k instanceof Error?k.message:"Failed to save settings",variant:"destructive"})}finally{h(!1)}};return n.jsx(mt,{open:s,onOpenChange:e,children:n.jsxs(Je,{className:"sm:max-w-[500px]",children:[n.jsxs(Qe,{children:[n.jsx(Ge,{children:"Project Settings"}),n.jsx(He,{children:"Configure settings for your project."})]}),n.jsxs("div",{className:"grid gap-4 py-4",children:[n.jsxs("div",{className:"grid gap-2",children:[n.jsx(be,{htmlFor:"projectName",children:"Project Name"}),n.jsx(Ke,{id:"projectName",value:a,onChange:k=>l(k.target.value),placeholder:"Enter project name",className:"text-sm",disabled:v})]}),n.jsxs("div",{className:"grid gap-2",children:[n.jsx(be,{htmlFor:"setupScript",children:"Setup Script"}),n.jsx(rs,{id:"setupScript",value:o,onChange:k=>i(k.target.value),placeholder:"e.g. npm install",className:"font-mono text-sm min-h-[80px] resize-none",disabled:v}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"This script runs automatically after cloning the repo for new threads."})]}),n.jsxs("div",{className:"grid gap-2",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx(be,{htmlFor:"runCommand",children:"Run Command"}),n.jsx(K,{variant:"ghost",size:"sm",onClick:S,disabled:p||v,className:"text-xs h-6 px-2 gap-1",children:p?n.jsxs(n.Fragment,{children:[n.jsx(ve,{className:"h-3 w-3 animate-spin"}),"Suggesting..."]}):n.jsxs(n.Fragment,{children:[n.jsx(nn,{className:"h-3 w-3"}),"Suggest"]})})]}),n.jsx(Ke,{id:"runCommand",value:c,onChange:k=>d(k.target.value),placeholder:"e.g. npm run dev",className:"font-mono text-sm",disabled:v}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"The command to start the dev server. Leave empty to disable run functionality."})]}),n.jsxs("div",{className:"grid gap-2",children:[n.jsx(be,{children:"Commit Method"}),n.jsxs("div",{className:"flex gap-4",children:[n.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[n.jsx("input",{type:"radio",name:"commitMethod",value:he.PullRequest,checked:u===he.PullRequest,onChange:k=>f(k.target.value),disabled:v}),n.jsx("span",{className:"text-sm",children:"Pull Requests"})]}),n.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[n.jsx("input",{type:"radio",name:"commitMethod",value:he.Direct,checked:u===he.Direct,onChange:k=>f(k.target.value),disabled:v}),n.jsx("span",{className:"text-sm",children:"Direct Commits"})]})]}),n.jsx("p",{className:"text-xs text-muted-foreground",children:u===he.PullRequest?"Feature branches are created and pull requests can be created.":"Commits are made directly to the main branch without feature branches."})]})]}),n.jsxs(Ye,{children:[n.jsx(K,{variant:"ghost",onClick:()=>e(!1),disabled:v||g,children:"Cancel"}),n.jsx(K,{onClick:E,disabled:g||v,children:g?n.jsxs(n.Fragment,{children:[n.jsx(ve,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]}):v?n.jsxs(n.Fragment,{children:[n.jsx(ve,{className:"mr-2 h-4 w-4 animate-spin"}),"Loading..."]}):"Save"})]})]})})}function Xc(s){const e=$.c(19),{open:t,suggestedCommand:r,onConfirm:a}=s;let l;e[0]!==a?(l=p=>{p||a(!1)},e[0]=a,e[1]=l):l=e[1];let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx($s,{children:"Install dependencies?"}),e[2]=o):o=e[2];const i=r??"";let c;e[3]!==i?(c=n.jsxs(As,{children:[o,n.jsxs(Os,{children:["Install dependencies with"," ",n.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-sm",children:i}),"?"]})]}),e[3]=i,e[4]=c):c=e[4];let d;e[5]!==a?(d=n.jsx(yn,{onClick:()=>a(!1),children:"No"}),e[5]=a,e[6]=d):d=e[6];let u;e[7]!==a?(u=n.jsx(jn,{onClick:()=>a(!0),children:"Yes"}),e[7]=a,e[8]=u):u=e[8];let f;e[9]!==d||e[10]!==u?(f=n.jsxs(Ls,{children:[d,u]}),e[9]=d,e[10]=u,e[11]=f):f=e[11];let g;e[12]!==c||e[13]!==f?(g=n.jsxs(Ds,{children:[c,f]}),e[12]=c,e[13]=f,e[14]=g):g=e[14];let h;return e[15]!==t||e[16]!==l||e[17]!==g?(h=n.jsx(xn,{open:t,onOpenChange:l,children:g}),e[15]=t,e[16]=l,e[17]=g,e[18]=h):h=e[18],h}const Ps=Sl,Pn=Cl,fs=m.forwardRef((s,e)=>{const t=$.c(12);let r,a,l;t[0]!==s?({className:a,children:r,...l}=s,t[0]=s,t[1]=r,t[2]=a,t[3]=l):(r=t[1],a=t[2],l=t[3]);let o;t[4]!==a?(o=U("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",a),t[4]=a,t[5]=o):o=t[5];let i;t[6]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(bl,{asChild:!0,children:n.jsx(It,{className:"h-4 w-4 opacity-50"})}),t[6]=i):i=t[6];let c;return t[7]!==r||t[8]!==l||t[9]!==e||t[10]!==o?(c=n.jsxs(vr,{ref:e,className:o,...l,children:[r,i]}),t[7]=r,t[8]=l,t[9]=e,t[10]=o,t[11]=c):c=t[11],c});fs.displayName=vr.displayName;const da=m.forwardRef((s,e)=>{const t=$.c(10);let r,a;t[0]!==s?({className:r,...a}=s,t[0]=s,t[1]=r,t[2]=a):(r=t[1],a=t[2]);let l;t[3]!==r?(l=U("flex cursor-default items-center justify-center py-1",r),t[3]=r,t[4]=l):l=t[4];let o;t[5]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx(Vn,{className:"h-4 w-4"}),t[5]=o):o=t[5];let i;return t[6]!==a||t[7]!==e||t[8]!==l?(i=n.jsx(Nr,{ref:e,className:l,...a,children:o}),t[6]=a,t[7]=e,t[8]=l,t[9]=i):i=t[9],i});da.displayName=Nr.displayName;const ua=m.forwardRef((s,e)=>{const t=$.c(10);let r,a;t[0]!==s?({className:r,...a}=s,t[0]=s,t[1]=r,t[2]=a):(r=t[1],a=t[2]);let l;t[3]!==r?(l=U("flex cursor-default items-center justify-center py-1",r),t[3]=r,t[4]=l):l=t[4];let o;t[5]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx(It,{className:"h-4 w-4"}),t[5]=o):o=t[5];let i;return t[6]!==a||t[7]!==e||t[8]!==l?(i=n.jsx(wr,{ref:e,className:l,...a,children:o}),t[6]=a,t[7]=e,t[8]=l,t[9]=i):i=t[9],i});ua.displayName=wr.displayName;const ps=m.forwardRef((s,e)=>{const t=$.c(21);let r,a,l,o;t[0]!==s?({className:a,children:r,position:o,...l}=s,t[0]=s,t[1]=r,t[2]=a,t[3]=l,t[4]=o):(r=t[1],a=t[2],l=t[3],o=t[4]);const i=o===void 0?"popper":o,c=i==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1";let d;t[5]!==a||t[6]!==c?(d=U("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover 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",c,a),t[5]=a,t[6]=c,t[7]=d):d=t[7];let u;t[8]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx(da,{}),t[8]=u):u=t[8];const f=i==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]";let g;t[9]!==f?(g=U("p-1",f),t[9]=f,t[10]=g):g=t[10];let h;t[11]!==r||t[12]!==g?(h=n.jsx(vl,{className:g,children:r}),t[11]=r,t[12]=g,t[13]=h):h=t[13];let p;t[14]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx(ua,{}),t[14]=p):p=t[14];let j;return t[15]!==i||t[16]!==l||t[17]!==e||t[18]!==d||t[19]!==h?(j=n.jsx(yl,{children:n.jsxs(Sr,{ref:e,className:d,position:i,...l,children:[u,h,p]})}),t[15]=i,t[16]=l,t[17]=e,t[18]=d,t[19]=h,t[20]=j):j=t[20],j});ps.displayName=Sr.displayName;const Zc=m.forwardRef((s,e)=>{const t=$.c(9);let r,a;t[0]!==s?({className:r,...a}=s,t[0]=s,t[1]=r,t[2]=a):(r=t[1],a=t[2]);let l;t[3]!==r?(l=U("py-1.5 pl-8 pr-2 text-sm font-semibold",r),t[3]=r,t[4]=l):l=t[4];let o;return t[5]!==a||t[6]!==e||t[7]!==l?(o=n.jsx(Cr,{ref:e,className:l,...a}),t[5]=a,t[6]=e,t[7]=l,t[8]=o):o=t[8],o});Zc.displayName=Cr.displayName;const dt=m.forwardRef((s,e)=>{const t=$.c(14);let r,a,l;t[0]!==s?({className:a,children:r,...l}=s,t[0]=s,t[1]=r,t[2]=a,t[3]=l):(r=t[1],a=t[2],l=t[3]);let o;t[4]!==a?(o=U("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",a),t[4]=a,t[5]=o):o=t[5];let i;t[6]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:n.jsx(Nl,{children:n.jsx(ht,{className:"h-4 w-4"})})}),t[6]=i):i=t[6];let c;t[7]!==r?(c=n.jsx(wl,{children:r}),t[7]=r,t[8]=c):c=t[8];let d;return t[9]!==l||t[10]!==e||t[11]!==o||t[12]!==c?(d=n.jsxs(Tr,{ref:e,className:o,...l,children:[i,c]}),t[9]=l,t[10]=e,t[11]=o,t[12]=c,t[13]=d):d=t[13],d});dt.displayName=Tr.displayName;const ed=m.forwardRef((s,e)=>{const t=$.c(9);let r,a;t[0]!==s?({className:r,...a}=s,t[0]=s,t[1]=r,t[2]=a):(r=t[1],a=t[2]);let l;t[3]!==r?(l=U("-mx-1 my-1 h-px bg-muted",r),t[3]=r,t[4]=l):l=t[4];let o;return t[5]!==a||t[6]!==e||t[7]!==l?(o=n.jsx(Ir,{ref:e,className:l,...a}),t[5]=a,t[6]=e,t[7]=l,t[8]=o):o=t[8],o});ed.displayName=Ir.displayName;function td({open:s,onOpenChange:e,onRestartOnboarding:t}){const[r,a]=m.useState([]),[l,o]=m.useState(null),[i,c]=m.useState(!1),[d,u]=m.useState(!1),[f,g]=m.useState(null),[h,p]=m.useState(!1),[j,v]=m.useState(""),[b,I]=m.useState([]),[C,x]=m.useState(new Set),[T,_]=m.useState(new Map),[w,R]=m.useState(""),[N,y]=m.useState("alphabetical"),[S,E]=m.useState("all"),[k,A]=m.useState(!1),D=m.useRef(0),z=m.useRef(null);m.useEffect(()=>{s&&O()},[s]),m.useEffect(()=>()=>{z.current&&clearTimeout(z.current)},[]),m.useEffect(()=>{s&&l&&(F(l),L(l))},[l,s]);const O=async()=>{c(!0),v("");try{const M=await un();a(M),M.length>0&&!l&&o(M[0].name)}catch(M){v(M instanceof Error?M.message:"Failed to load providers")}finally{c(!1)}},L=async M=>{g(null),p(!0);try{const H=await Xl(M);H.status==="success"&&g(H.balance)}catch(H){console.error(`Failed to load balance for ${M}:`,H)}finally{p(!1)}},F=async M=>{u(!0),R(""),y("alphabetical"),E("all");try{const H=await mn(M);console.log(`Loaded ${H.length} models for ${M}`),I(H);const G=await ks();console.log("Enabled models by provider:",G);const V=G[M]||[];console.log(`Found ${V.length} enabled models for ${M}:`,V.map(Z=>Z.id));const X=new Set(V.map(Z=>Z.id));x(X),_(new Map)}catch(H){console.error(`Failed to load models for ${M}:`,H),I([]),x(new Set)}finally{u(!1)}},B=(M,H)=>{a(G=>G.map(V=>V.name===M?{...V,apiKey:H}:V))},W=M=>{_(H=>{const G=new Map(H),V=C.has(M),X=G.has(M),Z=G.get(M),q=!(X?Z:V);return q===V?G.delete(M):G.set(M,q),G})},Q=M=>{_(H=>{const G=new Map(H);return b.forEach(V=>{const X=C.has(V.id);M?X?G.delete(V.id):G.set(V.id,!0):X?G.set(V.id,!1):G.delete(V.id)}),G})},se=async()=>{const M={};if(r.forEach(H=>{H.apiKey!==void 0&&(M[H.name]=H.apiKey)}),Object.keys(M).length!==0)try{await eo(M)}catch(H){console.error("Failed to save keys on close:",H)}},de=async()=>{if(!(T.size===0||!l))try{for(const[M,H]of T.entries())H?(await Yr(l,M),x(G=>new Set([...G,M]))):(await bo(l,M),x(G=>{const V=new Set(G);return V.delete(M),V}));_(new Map)}catch(M){console.error("Failed to save model changes:",M)}},ie=async M=>{M||(await de(),se()),e(M)},re=r.find(M=>M.name===l),ae=re?.apiKey&&re.apiKey.trim().length>0,le=(M,H)=>`${M==="all"?"All":"Free"} • ${H==="alphabetical"?"A-Z":H==="price-low"?"Price ↑":H==="price-high"?"Price ↓":H}`,ce=M=>At(M.id),ee=b.filter(M=>{const H=w.toLowerCase(),G=ce(M),V=M.name.toLowerCase().includes(H)||M.id.toLowerCase().includes(H)||G.toLowerCase().includes(H);if(S==="tools"){const X=M.supportedParameters?.tools===!0;return V&&X}if(S==="free"){const X=M.pricing?.prompt===0&&M.pricing?.completion===0;return V&&X}return V}).sort((M,H)=>{const G=C.has(M.id)?0:1,V=C.has(H.id)?0:1;if(G!==V)return G-V;if(N==="price-low"){const X=!!M.pricing,Z=!!H.pricing;if(X!==Z)return X?-1:1;if(!M.pricing||!H.pricing)return 0;const Y=(M.pricing.prompt+M.pricing.completion)/2,q=(H.pricing.prompt+H.pricing.completion)/2;return Y-q}if(N==="price-high"){const X=!!M.pricing,Z=!!H.pricing;if(X!==Z)return X?-1:1;if(!M.pricing||!H.pricing)return 0;const Y=(M.pricing.prompt+M.pricing.completion)/2;return(H.pricing.prompt+H.pricing.completion)/2-Y}return ce(M).localeCompare(ce(H))}),te=[...r].sort((M,H)=>{const G=!!M.apiKey,V=!!H.apiKey;return G&&!V?-1:!G&&V?1:M.name.localeCompare(H.name)});return n.jsx(mt,{open:s,onOpenChange:ie,children:n.jsxs(Je,{className:"max-w-3xl h-[600px] flex flex-col p-0 overflow-hidden",children:[n.jsx("div",{className:"p-6 pb-2",children:n.jsxs(Qe,{children:[n.jsx(Ge,{children:"Settings"}),n.jsx(He,{asChild:!0,children:n.jsx("span",{role:t?"button":void 0,tabIndex:t?0:void 0,onClick:t?()=>{z.current&&(clearTimeout(z.current),z.current=null),D.current+=1,D.current>=3?(D.current=0,t()):z.current=setTimeout(()=>{D.current=0,z.current=null},500)}:void 0,onKeyDown:t?M=>{(M.key==="Enter"||M.key===" ")&&M.currentTarget.click()}:void 0,className:t?"cursor-default select-none":void 0,children:"Manage your AI providers, API keys, and models."})})]})}),i?n.jsx("div",{className:"flex flex-1 items-center justify-center",children:n.jsx(ve,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):j?n.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-2",children:[n.jsx("p",{className:"text-sm text-destructive",children:j}),n.jsx(K,{variant:"outline",size:"sm",onClick:O,children:"Retry"})]}):n.jsxs("div",{className:"flex flex-1 overflow-hidden border-t border-border",children:[n.jsx("div",{className:"w-64 border-r border-border bg-muted/30",children:n.jsx(Ve,{className:"h-full",children:n.jsx("div",{className:"flex flex-col p-2 gap-1",children:te.map(M=>n.jsxs("button",{onClick:()=>o(M.name),className:U("flex items-center justify-between px-3 py-2 text-sm font-medium rounded-md transition-colors text-left",l===M.name?"bg-accent text-accent-foreground":"hover:bg-accent/50 text-muted-foreground hover:text-foreground"),children:[n.jsx("span",{className:U(M.apiKey&&"font-bold text-foreground"),children:M.name}),M.apiKey&&n.jsx(ht,{className:"h-3.5 w-3.5 text-green-500"})]},M.name))})})}),n.jsx("div",{className:"flex-1 flex flex-col overflow-hidden bg-background",children:re?n.jsx(Ve,{className:"flex-1",children:n.jsxs("div",{className:"p-6 flex flex-col gap-8",children:[n.jsx("div",{className:"flex flex-col gap-2",children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("h3",{className:"text-lg font-semibold",children:re.name}),f!==null&&n.jsxs("span",{className:"text-xs font-medium text-green-600 bg-green-50 px-2.5 py-1 rounded-full border border-green-100 flex items-center gap-1.5",children:[n.jsx("div",{className:"h-1.5 w-1.5 rounded-full bg-green-500"}),"$",is(f)," balance"]}),h&&n.jsx(ve,{className:"h-3.5 w-3.5 animate-spin text-muted-foreground"})]}),re.url&&n.jsxs("a",{href:re.url,target:"_blank",rel:"noreferrer",className:"flex items-center gap-1 text-xs text-brand hover:underline hover:text-brand/80",children:["Visit provider website ",n.jsx(xs,{className:"h-3 w-3"})]})]})}),n.jsxs("div",{className:"flex flex-col gap-3",children:[n.jsx("div",{className:"flex items-center justify-between",children:n.jsx(we,{children:n.jsxs(fe,{children:[n.jsx(pe,{asChild:!0,children:n.jsx("span",{className:"text-sm font-medium cursor-help",children:"API Key"})}),n.jsx(me,{children:"Your API key is stored locally and never shared."})]})})}),re.authType==="APIKey"?n.jsxs("div",{className:"relative",children:[n.jsx(Rr,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),n.jsx(Ke,{type:k?"text":"password",placeholder:re.keyName||"Enter API Key",className:"pl-10 pr-10",value:re.apiKey||"",onChange:M=>{B(re.name,M.target.value)}}),n.jsx(K,{type:"button",variant:"ghost",size:"sm",className:"absolute right-1 top-1/2 -translate-y-1/2 h-8 w-8 p-0",onClick:()=>A(!k),disabled:!re.apiKey,children:k?n.jsx(Er,{className:"h-4 w-4 text-muted-foreground"}):n.jsx(ln,{className:"h-4 w-4 text-muted-foreground"})})]}):n.jsxs("div",{className:"rounded-md bg-muted/30 p-4 text-center",children:[n.jsx("p",{className:"text-sm text-muted-foreground",children:"This provider uses OAuth for authentication."}),n.jsxs(K,{variant:"outline",size:"sm",className:"mt-2",disabled:!0,children:["Sign in with ",re.name]})]})]}),n.jsxs("div",{className:"flex flex-col gap-4",children:[!d&&b.length>0&&n.jsxs("div",{className:U("flex items-center justify-between",!ae&&"opacity-25"),children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Dt,{id:"select-all-models",disabled:!ae,checked:b.every(M=>{const H=T.has(M.id),G=T.get(M.id);return H?G:C.has(M.id)}),onCheckedChange:M=>Q(M===!0)}),n.jsx("label",{htmlFor:"select-all-models",className:"text-sm cursor-pointer",children:"Select all models"})]}),n.jsx(we,{children:n.jsxs("div",{className:"flex items-center rounded-md border border-border p-0.5",children:[n.jsxs(fe,{children:[n.jsx(pe,{asChild:!0,children:n.jsx(K,{type:"button",variant:N==="alphabetical"?"secondary":"ghost",size:"icon",className:"h-8 w-8",onClick:()=>y("alphabetical"),children:n.jsx(kr,{className:"h-4 w-4"})})}),n.jsx(me,{children:"Sort A–Z"})]}),n.jsxs(fe,{children:[n.jsx(pe,{asChild:!0,children:n.jsx(K,{type:"button",variant:N==="price-low"||N==="price-high"?"secondary":"ghost",size:"icon",className:"h-8 w-8",onClick:()=>y("price-low"),children:n.jsx(_r,{className:"h-4 w-4"})})}),n.jsx(me,{children:"Sort by price"})]})]})})]}),d?n.jsx("div",{className:"flex items-center justify-center py-8",children:n.jsx(ve,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):b.length===0?n.jsx("div",{className:"text-center py-8",children:n.jsx("p",{className:"text-sm text-muted-foreground",children:"No models available for this provider."})}):n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"flex gap-3 mb-2 hidden",children:[n.jsxs("div",{className:"flex-1 relative",children:[n.jsx(an,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),n.jsx(Ke,{placeholder:"Search models...",className:"pl-10",value:w,onChange:M=>R(M.target.value)})]}),n.jsxs(Ps,{value:`${S}:${N}`,onValueChange:M=>{const[H,G]=M.split(":");E(H),y(G)},children:[n.jsx(fs,{className:"w-48",children:n.jsx("span",{className:"text-sm",children:le(S,N)})}),n.jsxs(ps,{children:[n.jsxs("div",{className:"px-2 py-2",children:[n.jsx("div",{className:"text-xs font-medium text-muted-foreground px-2 py-1",children:"Filter"}),n.jsx(dt,{value:`all:${N}`,children:"All models"}),n.jsx(dt,{value:`free:${N}`,children:"Free"})]}),n.jsxs("div",{className:"px-2 py-2 border-t border-border",children:[n.jsx("div",{className:"text-xs font-medium text-muted-foreground px-2 py-1",children:"Sort by"}),n.jsx(dt,{value:`${S}:alphabetical`,children:"Alphabetical"}),n.jsx(dt,{value:`${S}:price-low`,children:"Price - Low to High"}),n.jsx(dt,{value:`${S}:price-high`,children:"Price - High to Low"})]})]})]})]}),n.jsx(we,{children:n.jsx("div",{className:"grid grid-cols-1 gap-0 border border-border rounded-md overflow-hidden",children:ee.length===0?n.jsx("div",{className:"text-center py-8",children:n.jsx("p",{className:"text-sm text-muted-foreground",children:"No models matching your filters. Try adjusting the filter or search criteria."})}):ee.map(M=>{const H=C.has(M.id),G=T.has(M.id),V=T.get(M.id),X=G?V:H,Z=M.pricing;return n.jsxs(fe,{children:[n.jsx(pe,{asChild:!0,children:n.jsxs("div",{className:`flex items-center space-x-3 p-3 hover:bg-muted/30 transition-colors cursor-default border-b border-border last:border-b-0 ${ae?"":"opacity-25"}`,children:[n.jsx(Dt,{id:M.id,disabled:!ae,checked:X??!1,onCheckedChange:()=>W(M.id),className:"mt-0"}),n.jsxs("div",{className:"flex-1 flex items-center justify-between gap-3 leading-none",children:[n.jsx("label",{htmlFor:M.id,className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70 cursor-pointer truncate flex-1 w-0",children:ce(M)}),Z&&n.jsx("span",{className:"text-xs text-muted-foreground whitespace-nowrap flex-shrink-0",children:Z.prompt<=0&&Z.completion<=0?"Free":`$${is(Z.prompt*1e6)} in | $${is(Z.completion*1e6)} out`})]})]})}),M.description&&n.jsx(me,{side:"left",className:"max-w-xs",children:n.jsx("p",{className:"text-sm",children:M.description})})]},M.id)})})})]})]})]})}):n.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:"Select a provider to configure"})})]}),n.jsx("div",{className:"p-4 border-t border-border bg-muted/10",children:n.jsx(Ye,{children:n.jsx(K,{onClick:()=>ie(!1),children:"Done"})})})]})})}function sd({selectedProvider:s,onProviderChange:e,showApiKeyInput:t=!0,onApiKeyChange:r,isLoading:a,error:l,variant:o="dropdown"}){const[i,c]=m.useState([]),[d,u]=m.useState(!1);return m.useEffect(()=>{(async()=>{u(!0);try{const g=await un();c(g),g.length>0&&!s&&e(g[0])}catch(g){console.error("Failed to load providers:",g)}finally{u(!1)}})()},[s,e]),d?n.jsx("div",{className:"flex items-center justify-center py-4",children:n.jsx(ve,{className:"h-4 w-4 animate-spin text-muted-foreground"})}):o==="dropdown"?n.jsxs("div",{className:"flex flex-col gap-4",children:[l&&n.jsx("p",{className:"text-sm text-destructive",children:l}),n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsx("label",{className:"text-sm font-medium",children:"AI Provider"}),n.jsxs(Ps,{value:s?.name||"",onValueChange:f=>{const g=i.find(h=>h.name===f);g&&e(g)},children:[n.jsx(fs,{children:s?s.name:"Select a provider"}),n.jsx(ps,{children:i.map(f=>n.jsx(dt,{value:f.name,children:f.name},f.name))})]})]}),s&&s.url&&n.jsxs("a",{href:s.url,target:"_blank",rel:"noreferrer",className:"flex items-center gap-1 text-sm text-brand hover:underline hover:text-brand/80",children:["Visit provider website ",n.jsx(xs,{className:"h-3.5 w-3.5"})]}),t&&s&&n.jsx(nd,{provider:s,value:s.apiKey||"",onChange:r,isLoading:a})]}):null}function nd(s){const e=$.c(24),{provider:t,value:r,onChange:a,isLoading:l}=s,[o,i]=m.useState(!1);if(t.authType!=="APIKey"){let C;e[0]===Symbol.for("react.memo_cache_sentinel")?(C=n.jsx("p",{className:"text-sm text-muted-foreground",children:"This provider uses OAuth for authentication."}),e[0]=C):C=e[0];let x;return e[1]!==t.name?(x=n.jsxs("div",{className:"rounded-md bg-muted/30 p-4 text-center",children:[C,n.jsxs(K,{variant:"outline",size:"sm",className:"mt-2",disabled:!0,children:["Sign in with ",t.name]})]}),e[1]=t.name,e[2]=x):x=e[2],x}let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx("div",{className:"flex items-center justify-between",children:n.jsx(we,{children:n.jsxs(fe,{children:[n.jsx(pe,{asChild:!0,children:n.jsx("label",{htmlFor:"api-key",className:"text-sm font-medium cursor-help",children:"API Key"})}),n.jsx(me,{children:"Your API key is stored locally and never shared."})]})})}),e[3]=c):c=e[3];let d;e[4]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(Rr,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e[4]=d):d=e[4];const u=o?"text":"password",f=t.keyName||"Enter API Key";let g;e[5]!==a?(g=C=>a?.(C.target.value),e[5]=a,e[6]=g):g=e[6];let h;e[7]!==l||e[8]!==u||e[9]!==f||e[10]!==g||e[11]!==r?(h=n.jsx(Ke,{id:"api-key",type:u,placeholder:f,className:"pl-10 pr-10",value:r,onChange:g,disabled:l}),e[7]=l,e[8]=u,e[9]=f,e[10]=g,e[11]=r,e[12]=h):h=e[12];let p;e[13]!==o?(p=()=>i(!o),e[13]=o,e[14]=p):p=e[14];const j=l||!r;let v;e[15]!==o?(v=o?n.jsx(Er,{className:"h-4 w-4 text-muted-foreground"}):n.jsx(ln,{className:"h-4 w-4 text-muted-foreground"}),e[15]=o,e[16]=v):v=e[16];let b;e[17]!==p||e[18]!==j||e[19]!==v?(b=n.jsx(K,{type:"button",variant:"ghost",size:"sm",className:"absolute right-1 top-1/2 -translate-y-1/2 h-8 w-8 p-0",onClick:p,disabled:j,children:v}),e[17]=p,e[18]=j,e[19]=v,e[20]=b):b=e[20];let I;return e[21]!==b||e[22]!==h?(I=n.jsxs("div",{className:"flex flex-col gap-3",children:[c,n.jsxs("div",{className:"relative",children:[d,h,b]})]}),e[21]=b,e[22]=h,e[23]=I):I=e[23],I}function rd({provider:s,onModelsChange:e,isLoading:t,disabled:r,displayMode:a="grid"}){const[l,o]=m.useState([]),[i,c]=m.useState(new Set),[d,u]=m.useState(new Map),[f,g]=m.useState(!1),[h,p]=m.useState(""),[j,v]=m.useState("alphabetical");m.useEffect(()=>{b()},[s]);const b=async()=>{g(!0),p(""),v("alphabetical");try{const w=await mn(s);o(w);const N=(await ks())[s]||[],y=new Set(N.map(S=>S.id));c(y),u(new Map)}catch(w){console.error(`Failed to load models for ${s}:`,w),o([]),c(new Set)}finally{g(!1)}},I=(w,R)=>{const N=new Set(w);l.forEach(y=>{R.has(y.id)&&(R.get(y.id)?N.add(y.id):N.delete(y.id))}),e?.(N)},C=w=>{u(R=>{const N=new Map(R),y=i.has(w),S=N.has(w),E=N.get(w),A=!(S?E:y);return A===y?N.delete(w):N.set(w,A),I(i,N),N})},x=w=>{u(R=>{const N=new Map(R);return l.forEach(y=>{const S=i.has(y.id);w?S?N.delete(y.id):N.set(y.id,!0):S?N.set(y.id,!1):N.delete(y.id)}),I(i,N),N})},T=w=>At(w.id),_=l.filter(w=>{const R=h.toLowerCase(),N=T(w);return w.name.toLowerCase().includes(R)||w.id.toLowerCase().includes(R)||N.toLowerCase().includes(R)}).sort((w,R)=>{const N=i.has(w.id)?0:1,y=i.has(R.id)?0:1;if(N!==y)return N-y;if(j==="price-low"){const S=!!w.pricing,E=!!R.pricing;if(S!==E)return S?-1:1;if(!w.pricing||!R.pricing)return 0;const k=(w.pricing.prompt+w.pricing.completion)/2,A=(R.pricing.prompt+R.pricing.completion)/2;return k-A}if(j==="price-high"){const S=!!w.pricing,E=!!R.pricing;if(S!==E)return S?-1:1;if(!w.pricing||!R.pricing)return 0;const k=(w.pricing.prompt+w.pricing.completion)/2;return(R.pricing.prompt+R.pricing.completion)/2-k}return T(w).localeCompare(T(R))});return f||t?n.jsx("div",{className:"flex items-center justify-center py-8",children:n.jsx(ve,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):l.length===0?n.jsx("div",{className:"text-center py-8",children:n.jsx("p",{className:"text-sm text-muted-foreground",children:"No models available for this provider."})}):a==="compact"?n.jsxs("div",{className:"flex flex-col gap-4",children:[n.jsxs("div",{className:U("flex items-center justify-between",r&&"opacity-25"),children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Dt,{id:"select-all-models",disabled:r,checked:l.every(w=>{const R=d.has(w.id),N=d.get(w.id);return R?N:i.has(w.id)}),onCheckedChange:w=>x(w===!0)}),n.jsx("label",{htmlFor:"select-all-models",className:"text-sm cursor-pointer",children:"Select all models"})]}),n.jsx(we,{children:n.jsxs("div",{className:"flex items-center rounded-md border border-border p-0.5",children:[n.jsxs(fe,{children:[n.jsx(pe,{asChild:!0,children:n.jsx(K,{type:"button",variant:j==="alphabetical"?"secondary":"ghost",size:"icon",className:"h-8 w-8",onClick:()=>v("alphabetical"),disabled:r,children:n.jsx(kr,{className:"h-4 w-4"})})}),n.jsx(me,{children:"Sort A–Z"})]}),n.jsxs(fe,{children:[n.jsx(pe,{asChild:!0,children:n.jsx(K,{type:"button",variant:j==="price-low"||j==="price-high"?"secondary":"ghost",size:"icon",className:"h-8 w-8",onClick:()=>{v(j==="price-low"?"price-high":"price-low")},disabled:r,children:n.jsx(_r,{className:"h-4 w-4"})})}),n.jsx(me,{children:"Sort by price"})]})]})})]}),n.jsx(we,{children:n.jsx("div",{className:"grid grid-cols-1 gap-0 border border-border rounded-md overflow-hidden",children:_.length===0?n.jsx("div",{className:"text-center py-4",children:n.jsx("p",{className:"text-sm text-muted-foreground",children:"No models available."})}):_.map(w=>{const R=i.has(w.id),N=d.has(w.id),y=d.get(w.id),S=N?y:R,E=w.pricing;return n.jsxs(fe,{children:[n.jsx(pe,{asChild:!0,children:n.jsxs("div",{className:U("flex items-center space-x-3 p-3 hover:bg-muted/30 transition-colors cursor-default border-b border-border last:border-b-0",r&&"opacity-25"),children:[n.jsx(Dt,{id:w.id,disabled:r,checked:S??!1,onCheckedChange:()=>C(w.id),className:"mt-0"}),n.jsxs("div",{className:"flex-1 flex items-center justify-between gap-3 leading-none",children:[n.jsx("label",{htmlFor:w.id,className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70 cursor-pointer truncate flex-1 w-0",children:T(w)}),E&&n.jsx("span",{className:"text-xs text-muted-foreground whitespace-nowrap flex-shrink-0",children:E.prompt<=0&&E.completion<=0?"Free":`${is(E.prompt*1e6)} in | ${is(E.completion*1e6)} out`})]})]})}),w.description&&n.jsx(me,{side:"left",className:"max-w-xs",children:n.jsx("p",{className:"text-sm",children:w.description})})]},w.id)})})})]}):null}function ad({open:s,onOpenChange:e,onComplete:t}){const[r,a]=m.useState("git-check"),[l,o]=m.useState(null),[i,c]=m.useState(!1),[d,u]=m.useState([]),[f,g]=m.useState(null),[h,p]=m.useState(""),[j,v]=m.useState(!1),[b,I]=m.useState(""),[C,x]=m.useState(new Set),[T,_]=m.useState(!1),[w,R]=m.useState(!1);m.useEffect(()=>{s&&r==="git-check"&&N()},[s,r]),m.useEffect(()=>{s&&r==="provider-selection"&&d.length===0&&y()},[s,r,d.length]),m.useEffect(()=>{s&&r==="model-selection"&&f&&S()},[s,r,f]);const N=async()=>{c(!0);try{const O=await Go();o(O.gitInstalled)}catch(O){console.error("Failed to check git installation:",O),o(!1)}finally{c(!1)}},y=async()=>{try{const O=await un();u(O),O.length>0&&!f&&g(O[0])}catch(O){console.error("Failed to load providers:",O)}},S=async()=>{if(f){_(!0);try{await mn(f.name),x(new Set)}catch(O){console.error("Failed to load models:",O)}finally{_(!1)}}},E=async()=>{if(!f||!h.trim()){I("Please enter an API key");return}v(!0),I("");try{await Zl(f.name,h),a("model-selection")}catch(O){I(O instanceof Error?O.message:"Failed to validate API key")}finally{v(!1)}},k=async()=>{if(f){R(!0);try{for(const O of C)await Yr(f.name,O);await In(),t?.(),e(!1)}catch(O){console.error("Failed to complete onboarding:",O)}finally{R(!1)}}},A=async()=>{R(!0);try{await In(),t?.(),e(!1)}catch(O){console.error("Failed to skip onboarding:",O)}finally{R(!1)}},D=O=>{g(O),p(O.apiKey||""),I("")},z=()=>{a("provider-selection")};return n.jsx(mt,{open:s,onOpenChange:e,children:n.jsxs(Je,{className:"max-w-2xl h-[min(42rem,90dvh)] flex flex-col p-0 overflow-hidden",children:[n.jsxs("div",{className:"px-6 pt-6 pb-2",children:[n.jsxs("div",{className:"w-1/2 mx-auto flex items-center gap-2 mb-6",children:[n.jsx("div",{className:U("flex items-center justify-center h-8 w-8 rounded-full text-sm font-medium",r==="git-check"?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground"),children:"1"}),n.jsx("div",{className:U("h-0.5 flex-1",r==="provider-selection"||r==="model-selection"?"bg-primary":"bg-muted")}),n.jsx("div",{className:U("flex items-center justify-center h-8 w-8 rounded-full text-sm font-medium",r==="provider-selection"?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground"),children:"2"}),n.jsx("div",{className:U("h-0.5 flex-1",r==="model-selection"?"bg-primary":"bg-muted")}),n.jsx("div",{className:U("flex items-center justify-center h-8 w-8 rounded-full text-sm font-medium",r==="model-selection"?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground"),children:"3"})]}),n.jsxs(Qe,{children:[r==="git-check"&&n.jsxs(n.Fragment,{children:[n.jsx(Ge,{children:"Let's get started"}),n.jsx(He,{children:"First, we need to check that Git is installed on your system."})]}),r==="provider-selection"&&n.jsxs(n.Fragment,{children:[n.jsx(Ge,{children:"Select an AI Provider"}),n.jsx(He,{children:"Choose your preferred AI provider and enter your API key."})]}),r==="model-selection"&&n.jsxs(n.Fragment,{children:[n.jsx(Ge,{children:"Select Models"}),n.jsx(He,{children:"Choose which models you want to use with this provider."})]})]})]}),n.jsx(Ve,{className:"flex-1 min-h-0 overflow-hidden",children:n.jsxs("div",{className:"px-6 py-4",children:[r==="git-check"&&n.jsx("div",{className:"space-y-4",children:i?n.jsx("div",{className:"flex items-center justify-center py-8",children:n.jsx(ve,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):l?n.jsxs("div",{className:"rounded-lg border border-green-200 bg-green-50 p-4 flex items-start gap-3",children:[n.jsx(ht,{className:"h-5 w-5 text-green-600 flex-shrink-0 mt-0.5"}),n.jsxs("div",{children:[n.jsx("h4",{className:"font-medium text-green-900",children:"Git is installed"}),n.jsx("p",{className:"text-sm text-green-800",children:"You're all set to use Git features in Tarsk."})]})]}):n.jsxs("div",{className:"rounded-lg border border-yellow-200 bg-yellow-50 p-4 flex items-start gap-3",children:[n.jsx(Wn,{className:"h-5 w-5 text-yellow-600 flex-shrink-0 mt-0.5"}),n.jsxs("div",{className:"flex-1",children:[n.jsx("h4",{className:"font-medium text-yellow-900",children:"Git is not installed"}),n.jsx("p",{className:"text-sm text-yellow-800 mt-1",children:"Git is required for some features in Tarsk. You can continue without it, but we recommend installing it."}),n.jsxs("a",{href:"https://git-scm.com/downloads",target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-sm text-blue-600 hover:underline mt-2",children:["Download Git ",n.jsx(xs,{className:"h-3 w-3"})]})]})]})}),r==="provider-selection"&&n.jsx("div",{className:"space-y-4",children:f&&n.jsxs(n.Fragment,{children:[n.jsx(sd,{selectedProvider:f,onProviderChange:D,showApiKeyInput:!0,variant:"dropdown",isLoading:j}),b&&n.jsx("div",{className:"rounded-md bg-destructive/10 p-3 text-sm text-destructive",children:b})]})}),r==="model-selection"&&f&&n.jsx("div",{className:"space-y-4",children:n.jsx(rd,{provider:f.name,isLoading:T,displayMode:"compact",disabled:!1,onModelsChange:x})})]})}),n.jsx("div",{className:"px-6 py-4 border-t border-border bg-muted/10",children:n.jsxs(Ye,{className:"flex items-center justify-between",children:[n.jsx("div",{children:r==="provider-selection"&&n.jsx(K,{variant:"ghost",onClick:()=>A(),disabled:w,children:"Skip for now"})}),n.jsxs("div",{className:"flex gap-3",children:[r!=="git-check"&&n.jsx(K,{variant:"outline",onClick:()=>{r==="provider-selection"?a("git-check"):r==="model-selection"&&a("provider-selection")},disabled:w,children:"Back"}),r==="git-check"&&n.jsxs(K,{onClick:z,disabled:i,className:"gap-2",children:["Continue ",n.jsx(bn,{className:"h-4 w-4"})]}),r==="provider-selection"&&n.jsx(K,{onClick:E,disabled:j||!h.trim()||!f,className:"gap-2",children:j?n.jsxs(n.Fragment,{children:[n.jsx(ve,{className:"h-4 w-4 animate-spin"}),"Validating..."]}):n.jsxs(n.Fragment,{children:["Next ",n.jsx(bn,{className:"h-4 w-4"})]})}),r==="model-selection"&&n.jsx(K,{onClick:k,disabled:w,className:"gap-2",children:w?n.jsxs(n.Fragment,{children:[n.jsx(ve,{className:"h-4 w-4 animate-spin"}),"Finishing..."]}):n.jsxs(n.Fragment,{children:["Finish ",n.jsx(ht,{className:"h-4 w-4"})]})})]})]})})]})})}const ma=m.forwardRef((s,e)=>{const t=$.c(9);let r,a;t[0]!==s?({className:r,...a}=s,t[0]=s,t[1]=r,t[2]=a):(r=t[1],a=t[2]);let l;t[3]!==r?(l=U("w-full caption-bottom text-sm",r),t[3]=r,t[4]=l):l=t[4];let o;return t[5]!==a||t[6]!==e||t[7]!==l?(o=n.jsx("div",{className:"relative w-full overflow-auto",children:n.jsx("table",{ref:e,className:l,...a})}),t[5]=a,t[6]=e,t[7]=l,t[8]=o):o=t[8],o});ma.displayName="Table";const fa=m.forwardRef((s,e)=>{const t=$.c(9);let r,a;t[0]!==s?({className:r,...a}=s,t[0]=s,t[1]=r,t[2]=a):(r=t[1],a=t[2]);let l;t[3]!==r?(l=U("[&_tr]:border-b",r),t[3]=r,t[4]=l):l=t[4];let o;return t[5]!==a||t[6]!==e||t[7]!==l?(o=n.jsx("thead",{ref:e,className:l,...a}),t[5]=a,t[6]=e,t[7]=l,t[8]=o):o=t[8],o});fa.displayName="TableHeader";const pa=m.forwardRef((s,e)=>{const t=$.c(9);let r,a;t[0]!==s?({className:r,...a}=s,t[0]=s,t[1]=r,t[2]=a):(r=t[1],a=t[2]);let l;t[3]!==r?(l=U("[&_tr:last-child]:border-0",r),t[3]=r,t[4]=l):l=t[4];let o;return t[5]!==a||t[6]!==e||t[7]!==l?(o=n.jsx("tbody",{ref:e,className:l,...a}),t[5]=a,t[6]=e,t[7]=l,t[8]=o):o=t[8],o});pa.displayName="TableBody";const ld=m.forwardRef((s,e)=>{const t=$.c(9);let r,a;t[0]!==s?({className:r,...a}=s,t[0]=s,t[1]=r,t[2]=a):(r=t[1],a=t[2]);let l;t[3]!==r?(l=U("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",r),t[3]=r,t[4]=l):l=t[4];let o;return t[5]!==a||t[6]!==e||t[7]!==l?(o=n.jsx("tfoot",{ref:e,className:l,...a}),t[5]=a,t[6]=e,t[7]=l,t[8]=o):o=t[8],o});ld.displayName="TableFooter";const tn=m.forwardRef((s,e)=>{const t=$.c(9);let r,a;t[0]!==s?({className:r,...a}=s,t[0]=s,t[1]=r,t[2]=a):(r=t[1],a=t[2]);let l;t[3]!==r?(l=U("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",r),t[3]=r,t[4]=l):l=t[4];let o;return t[5]!==a||t[6]!==e||t[7]!==l?(o=n.jsx("tr",{ref:e,className:l,...a}),t[5]=a,t[6]=e,t[7]=l,t[8]=o):o=t[8],o});tn.displayName="TableRow";const wt=m.forwardRef((s,e)=>{const t=$.c(9);let r,a;t[0]!==s?({className:r,...a}=s,t[0]=s,t[1]=r,t[2]=a):(r=t[1],a=t[2]);let l;t[3]!==r?(l=U("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",r),t[3]=r,t[4]=l):l=t[4];let o;return t[5]!==a||t[6]!==e||t[7]!==l?(o=n.jsx("th",{ref:e,className:l,...a}),t[5]=a,t[6]=e,t[7]=l,t[8]=o):o=t[8],o});wt.displayName="TableHead";const St=m.forwardRef((s,e)=>{const t=$.c(9);let r,a;t[0]!==s?({className:r,...a}=s,t[0]=s,t[1]=r,t[2]=a):(r=t[1],a=t[2]);let l;t[3]!==r?(l=U("p-4 align-middle [&:has([role=checkbox])]:pr-0",r),t[3]=r,t[4]=l):l=t[4];let o;return t[5]!==a||t[6]!==e||t[7]!==l?(o=n.jsx("td",{ref:e,className:l,...a}),t[5]=a,t[6]=e,t[7]=l,t[8]=o):o=t[8],o});St.displayName="TableCell";const od=m.forwardRef((s,e)=>{const t=$.c(9);let r,a;t[0]!==s?({className:r,...a}=s,t[0]=s,t[1]=r,t[2]=a):(r=t[1],a=t[2]);let l;t[3]!==r?(l=U("mt-4 text-sm text-muted-foreground",r),t[3]=r,t[4]=l):l=t[4];let o;return t[5]!==a||t[6]!==e||t[7]!==l?(o=n.jsx("caption",{ref:e,className:l,...a}),t[5]=a,t[6]=e,t[7]=l,t[8]=o):o=t[8],o});od.displayName="TableCaption";const Ws="__ALL_PROJECTS__";function Mn(s){const e=$.c(8),{text:t,maxLength:r}=s,a=r===void 0?100:r;if(t.length<=a){let c;return e[0]!==t?(c=n.jsx(n.Fragment,{children:t}),e[0]=t,e[1]=c):c=e[1],c}let l;e[2]!==a||e[3]!==t?(l=t.substring(0,a),e[2]=a,e[3]=t,e[4]=l):l=e[4];let o;e[5]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx("span",{className:"text-muted-foreground ml-2",children:"..."}),e[5]=o):o=e[5];let i;return e[6]!==l?(i=n.jsxs(n.Fragment,{children:[l,o]}),e[6]=l,e[7]=i):i=e[7],i}function id(s,e){const t=`${e} - `,r=s.title||s.threadId;return r.startsWith(t)?r.slice(t.length):r}async function Dn(s){const e=[],t=new Set;let r="";for(const a of s)try{const l=await Xr(a.threadId);l&&l.messages&&(e.push(...l.messages),l.conversationIds&&l.conversationIds.forEach(o=>t.add(o)),l.lastUpdated>r&&(r=l.lastUpdated))}catch(l){console.warn(`Failed to load history for thread ${a.threadId}:`,l)}return e.sort((a,l)=>new Date(l.timestamp).getTime()-new Date(a.timestamp).getTime()),{messages:e,conversationIds:Array.from(t),lastUpdated:r||new Date().toISOString()}}function cd({isOpen:s,onClose:e,initialFilter:t,projects:r}){const[a,l]=m.useState(null),[o,i]=m.useState(!1),[c,d]=m.useState(null),[u,f]=m.useState(0),[g,h]=m.useState(""),[p,j]=m.useState(""),v=m.useCallback(async y=>{i(!0),d(null);try{const S=await Xr(y);l(S)}catch(S){d(S instanceof Error?S.message:"Failed to load conversation history")}finally{i(!1)}},[]),b=m.useCallback(async y=>{if(y){i(!0),d(null);try{const S=r.find(k=>k.projectId===y);if(!S||S.threads.length===0){l({threadId:y,messages:[],lastUpdated:new Date().toISOString(),conversationIds:[]});return}const E=await Dn(S.threads);l({threadId:y,...E})}catch(S){d(S instanceof Error?S.message:"Failed to load project history")}finally{i(!1)}}},[r]),I=m.useCallback(async()=>{i(!0),d(null);try{const y=r.flatMap(E=>E.threads),S=await Dn(y);l({threadId:Ws,...S})}catch(y){d(y instanceof Error?y.message:"Failed to load all projects history")}finally{i(!1)}},[r]);m.useEffect(()=>{s&&t?t.type==="thread"?(j(t.id),h(""),f(0),v(t.id)):t.type==="project"&&(h(t.id),j(""),f(0),b(t.id)):s||(l(null),j(""),h(""),f(0),d(null))},[s,t,v,b]);const C=y=>{j(y),h(""),f(0),v(y)},x=y=>{h(y),j(""),f(0),y===Ws?I():b(y)},T=y=>new Date(y).toLocaleString(),_=(y,S)=>{const E=new Date(y),A=new Date(S).getTime()-E.getTime();if(A<0)return{display:"0:00",tooltip:"0 seconds"};const D=Math.floor(A/1e3),z=Math.floor(D/60),O=D%60,L=`${z}:${O.toString().padStart(2,"0")}`;let F;return z===0?F=`${O} second${O!==1?"s":""}`:O===0?F=`${z} minute${z!==1?"s":""}`:F=`${z} minute${z!==1?"s":""} ${O} second${O!==1?"s":""}`,{display:L,tooltip:F}},w=y=>({inputTokens:y.inputTokens||0,outputTokens:y.outputTokens||0}),R=()=>{a&&u<a.messages.length-1&&f(u+1)},N=()=>{u>0&&f(u-1)};return s?n.jsx("div",{className:"fixed inset-0 z-50 bg-background",children:n.jsxs("div",{className:"flex h-full flex-col",children:[n.jsxs("div",{className:"flex items-center justify-between border-b p-4",children:[n.jsxs("div",{className:"flex items-center gap-4",children:[n.jsx("h2",{className:"text-lg font-semibold",children:"Conversation History"}),t?.type==="thread"&&n.jsxs(Ps,{value:p,onValueChange:C,children:[n.jsx(fs,{className:"w-48",children:n.jsx(Pn,{placeholder:"Select thread"})}),n.jsx(ps,{children:r.flatMap(y=>y.threads.map(S=>n.jsx(dt,{value:S.threadId,children:id(S,y.name||y.projectId)},S.threadId)))})]}),n.jsxs(Ps,{value:g,onValueChange:x,children:[n.jsx(fs,{className:"w-48",children:n.jsx(Pn,{placeholder:"Select project"})}),n.jsxs(ps,{children:[n.jsx(dt,{value:Ws,children:"All Projects"}),r.map(y=>n.jsx(dt,{value:y.projectId,children:y.name||y.projectId},y.projectId))]})]})]}),n.jsx(K,{variant:"ghost",size:"icon",onClick:e,children:n.jsx(ut,{className:"h-4 w-4"})})]}),a&&a.messages.length>0&&n.jsxs("div",{className:"flex items-center justify-between border-b p-4",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(K,{variant:"outline",size:"sm",onClick:N,disabled:u===0,children:n.jsx(Tl,{className:"h-4 w-4 mr-1"})}),n.jsx(K,{variant:"outline",size:"sm",onClick:R,disabled:!a||u>=a.messages.length-1,children:n.jsx(Mt,{className:"h-4 w-4 ml-1"})})]}),n.jsxs("div",{className:"text-sm text-muted-foreground",children:[u+1," of ",a?.messages.length||0," messages"]})]}),n.jsx("div",{className:"flex-1 overflow-hidden",children:o?n.jsx("div",{className:"flex h-full items-center justify-center",children:n.jsxs("div",{className:"text-center",children:[n.jsx(sn,{className:"h-8 w-8 animate-spin mx-auto mb-2"}),n.jsx("p",{children:"Loading conversation history..."})]})}):c?n.jsx("div",{className:"flex h-full items-center justify-center",children:n.jsxs(us,{className:"max-w-md",children:[n.jsx(Zs,{children:n.jsx(en,{className:"text-destructive",children:"Error"})}),n.jsxs(ms,{children:[n.jsx("p",{children:c}),n.jsx(K,{onClick:e,className:"mt-4",children:"Close"})]})]})}):a&&a.messages&&a.messages.length>0?n.jsx(Ve,{className:"h-full",children:n.jsx("div",{className:"p-4",children:n.jsxs(ma,{children:[n.jsx(fa,{children:n.jsxs(tn,{children:[n.jsx(wt,{children:"Prompt"}),n.jsx(wt,{children:"Answer"}),n.jsx(wt,{className:"w-24",children:"Model"}),n.jsx(wt,{className:"w-24 text-right",children:"Duration"}),n.jsx(wt,{className:"w-20 text-right",children:"Input Tokens"}),n.jsx(wt,{className:"w-20 text-right",children:"Output Tokens"}),n.jsx(wt,{className:"w-32 text-right",children:"Timestamp"})]})}),n.jsx(pa,{children:a.messages.map((y,S)=>{const{inputTokens:E,outputTokens:k}=w(y);return n.jsxs(tn,{className:S===u?"bg-muted/50":"",children:[n.jsx(St,{className:"max-w-md",children:n.jsx("div",{className:"text-sm",children:n.jsx(Mn,{text:y.request.message})})}),n.jsx(St,{className:"max-w-md",children:y.response?n.jsx("div",{className:"text-sm",children:n.jsx(Mn,{text:y.response.content})}):n.jsx("span",{className:"text-muted-foreground italic",children:"No response"})}),n.jsx(St,{className:"text-sm",children:n.jsxs("div",{className:"flex items-center gap-1",children:[n.jsx(on,{className:"h-3 w-3 text-muted-foreground"}),n.jsx("span",{className:"text-muted-foreground",children:y.request.model})]})}),n.jsx(St,{className:"text-sm text-right",children:y.response?n.jsx(we,{children:n.jsxs(fe,{children:[n.jsx(pe,{asChild:!0,children:n.jsx("div",{className:"cursor-help",children:_(y.timestamp,y.response.completedAt).display})}),n.jsx(me,{children:n.jsx("p",{children:_(y.timestamp,y.response.completedAt).tooltip})})]})}):n.jsx("span",{className:"text-muted-foreground italic",children:"-"})}),n.jsx(St,{className:"text-sm text-muted-foreground text-right",children:E>0?E.toLocaleString():"-"}),n.jsx(St,{className:"text-sm text-muted-foreground text-right",children:k>0?k.toLocaleString():"-"}),n.jsx(St,{className:"text-sm text-muted-foreground text-right",children:T(y.timestamp)})]},y.id)})})]})})}):n.jsx("div",{className:"flex h-full items-center justify-center",children:n.jsxs(us,{className:"max-w-md",children:[n.jsx(Zs,{children:n.jsx(en,{children:"No History"})}),n.jsxs(ms,{children:[n.jsx("p",{children:"No conversation history found for this thread."}),n.jsx(K,{onClick:e,className:"mt-4",children:"Close"})]})]})})})]})}):null}function dd(){const s=$.c(6),[e,t]=m.useState(!0);let r,a;s[0]===Symbol.for("react.memo_cache_sentinel")?(r=()=>{let f=!0;return(async()=>{try{const h=await fetch(`${wn()}/health`,{method:"GET"});f&&t(h.ok)}catch{f&&t(!1)}})(),()=>{f=!1}},a=[],s[0]=r,s[1]=a):(r=s[0],a=s[1]),m.useEffect(r,a);const l=ud;if(e)return null;let o;s[2]===Symbol.for("react.memo_cache_sentinel")?(o=wn(),s[2]=o):o=s[2];const i=o;let c,d;s[3]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsxs(As,{children:[n.jsx($s,{children:"Service unavailable"}),n.jsx(Os,{children:"Service is not currently up. Please ensure the backend is running at the address below, then retry."})]}),d=n.jsx("div",{className:"rounded-md bg-muted px-3 py-2 text-xs font-mono text-muted-foreground",children:i}),s[3]=c,s[4]=d):(c=s[3],d=s[4]);let u;return s[5]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx(xn,{open:!0,children:n.jsxs(Ds,{children:[c,d,n.jsx(Ls,{children:n.jsx(K,{onClick:l,children:"Retry"})})]})}),s[5]=u):u=s[5],u}function ud(){window.location.assign(window.location.href)}const md=s=>{const e=$.c(8);let t,r;e[0]!==s?({className:t,...r}=s,e[0]=s,e[1]=t,e[2]=r):(t=e[1],r=e[2]);let a;e[3]!==t?(a=U("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",t),e[3]=t,e[4]=a):a=e[4];let l;return e[5]!==r||e[6]!==a?(l=n.jsx(Rl,{className:a,...r}),e[5]=r,e[6]=a,e[7]=l):l=e[7],l},An=Il,fd=s=>{const e=$.c(12);let t,r,a;e[0]!==s?({withHandle:a,className:t,...r}=s,e[0]=s,e[1]=t,e[2]=r,e[3]=a):(t=e[1],r=e[2],a=e[3]);let l;e[4]!==t?(l=U("relative flex w-px items-center justify-center bg-border 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",t),e[4]=t,e[5]=l):l=e[5];let o;e[6]!==a?(o=a&&n.jsx("div",{className:"z-10 flex h-4 w-3 items-center justify-center rounded-sm border bg-border",children:n.jsx(kl,{className:"h-2.5 w-2.5"})}),e[6]=a,e[7]=o):o=e[7];let i;return e[8]!==r||e[9]!==l||e[10]!==o?(i=n.jsx(El,{className:l,...r,children:o}),e[8]=r,e[9]=l,e[10]=o,e[11]=i):i=e[11],i},pd=_l,ha=m.forwardRef((s,e)=>{const t=$.c(9);let r,a;t[0]!==s?({className:r,...a}=s,t[0]=s,t[1]=r,t[2]=a):(r=t[1],a=t[2]);let l;t[3]!==r?(l=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),t[3]=r,t[4]=l):l=t[4];let o;return t[5]!==a||t[6]!==e||t[7]!==l?(o=n.jsx(Pr,{ref:e,className:l,...a}),t[5]=a,t[6]=e,t[7]=l,t[8]=o):o=t[8],o});ha.displayName=Pr.displayName;const hd=js("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"}}),ga=m.forwardRef((s,e)=>{const t=$.c(11);let r,a,l;t[0]!==s?({className:r,variant:l,...a}=s,t[0]=s,t[1]=r,t[2]=a,t[3]=l):(r=t[1],a=t[2],l=t[3]);let o;t[4]!==r||t[5]!==l?(o=U(hd({variant:l}),r),t[4]=r,t[5]=l,t[6]=o):o=t[6];let i;return t[7]!==a||t[8]!==e||t[9]!==o?(i=n.jsx(Mr,{ref:e,className:o,...a}),t[7]=a,t[8]=e,t[9]=o,t[10]=i):i=t[10],i});ga.displayName=Mr.displayName;const gd=m.forwardRef((s,e)=>{const t=$.c(9);let r,a;t[0]!==s?({className:r,...a}=s,t[0]=s,t[1]=r,t[2]=a):(r=t[1],a=t[2]);let l;t[3]!==r?(l=U("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors hover:bg-secondary focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive",r),t[3]=r,t[4]=l):l=t[4];let o;return t[5]!==a||t[6]!==e||t[7]!==l?(o=n.jsx(Dr,{ref:e,className:l,...a}),t[5]=a,t[6]=e,t[7]=l,t[8]=o):o=t[8],o});gd.displayName=Dr.displayName;const xa=m.forwardRef((s,e)=>{const t=$.c(10);let r,a;t[0]!==s?({className:r,...a}=s,t[0]=s,t[1]=r,t[2]=a):(r=t[1],a=t[2]);let l;t[3]!==r?(l=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),t[3]=r,t[4]=l):l=t[4];let o;t[5]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx(ut,{className:"h-4 w-4"}),t[5]=o):o=t[5];let i;return t[6]!==a||t[7]!==e||t[8]!==l?(i=n.jsx(Ar,{ref:e,className:l,"toast-close":"",...a,children:o}),t[6]=a,t[7]=e,t[8]=l,t[9]=i):i=t[9],i});xa.displayName=Ar.displayName;const ja=m.forwardRef((s,e)=>{const t=$.c(9);let r,a;t[0]!==s?({className:r,...a}=s,t[0]=s,t[1]=r,t[2]=a):(r=t[1],a=t[2]);let l;t[3]!==r?(l=U("text-sm font-semibold",r),t[3]=r,t[4]=l):l=t[4];let o;return t[5]!==a||t[6]!==e||t[7]!==l?(o=n.jsx(Lr,{ref:e,className:l,...a}),t[5]=a,t[6]=e,t[7]=l,t[8]=o):o=t[8],o});ja.displayName=Lr.displayName;const ya=m.forwardRef((s,e)=>{const t=$.c(9);let r,a;t[0]!==s?({className:r,...a}=s,t[0]=s,t[1]=r,t[2]=a):(r=t[1],a=t[2]);let l;t[3]!==r?(l=U("text-sm opacity-90",r),t[3]=r,t[4]=l):l=t[4];let o;return t[5]!==a||t[6]!==e||t[7]!==l?(o=n.jsx($r,{ref:e,className:l,...a}),t[5]=a,t[6]=e,t[7]=l,t[8]=o):o=t[8],o});ya.displayName=$r.displayName;function xd(){const s=$.c(5),{toasts:e}=ia();let t;s[0]!==e?(t=e.map(jd),s[0]=e,s[1]=t):t=s[1];let r;s[2]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx(ha,{}),s[2]=r):r=s[2];let a;return s[3]!==t?(a=n.jsxs(pd,{children:[t,r]}),s[3]=t,s[4]=a):a=s[4],a}function jd(s){const{id:e,title:t,description:r,action:a,...l}=s;return n.jsxs(ga,{...l,children:[n.jsxs("div",{className:"grid gap-1",children:[t&&n.jsx(ja,{children:t}),r&&n.jsx(ya,{children:r})]}),a,n.jsx(xa,{})]},e)}function yd(s){const e=$.c(6);let t,r;e[0]!==s?({children:t,...r}=s,e[0]=s,e[1]=t,e[2]=r):(t=e[1],r=e[2]);let a;return e[3]!==t||e[4]!==r?(a=n.jsx(Ll,{...r,children:t}),e[3]=t,e[4]=r,e[5]=a):a=e[5],a}function bd(){const{state:s,dispatch:e}=Se(),{toast:t}=ia(),r=ys("project-creation").dispatch,[a,l]=m.useState(null),o=m.useCallback(async()=>{try{const p=await Ns();e({type:P.SetProjects,projects:p.projects})}catch(p){console.error("Failed to refresh projects:",p)}},[e]),i=m.useCallback(async(p,j)=>{try{await co(p,j)}catch(v){console.error("Failed to select thread:",v)}(s.selectedThreadId!==j||s.selectedProjectId!==p)&&e({type:P.SelectThread,threadId:j,projectId:p})},[e,s.selectedThreadId,s.selectedProjectId]),c=m.useCallback(async(p,j)=>{e({type:P.SetCreatingProject,isCreating:!0});try{const v=await Jr(p,j);if(!v){e({type:P.SetCreatingProject,isCreating:!1}),await o();return}r({type:P.ClearTerminalOutput}),r({type:P.SetTerminalOpen,open:!0});const b=`Cloning repository: ${p}...
|
|
14
|
+
`;r({type:P.AppendTerminalLine,line:{type:"system",content:b.trim()}});const I=v.getReader(),C=new TextDecoder;let x="",T=null,_=!1,w=null,R=null;for(;;){const{done:y,value:S}=await I.read();if(y)break;x+=C.decode(S,{stream:!0});const E=x.split(`
|
|
15
|
+
`);x=E.pop()||"";for(const k of E){const A=k.trim();if(A)try{const D=JSON.parse(A);if(D.type==="progress"){if(!_&&D.threadId&&D.projectId){_=!0,w=D.projectId,R=D.threadId;const z=p.split("/").pop()?.replace(".git","")||"project";e({type:P.AddCreatingProject,projectId:D.projectId,threadId:D.threadId,projectName:z,gitUrl:p}),e({type:P.AddProcessingThread,threadId:D.threadId})}e({type:P.AppendTerminalLine,threadId:R||"project-creation",line:{type:"output",content:D.message}})}else if(D.type==="complete"){if(D.project){T=D.project.id;const z=D.project.threads&&D.project.threads.length>0?`${D.project.path}/${D.project.threads[0]}`:D.project.path;r({type:P.AppendTerminalLine,line:{type:"system",content:`Project created successfully at: ${z}`}}),e({type:P.SetTerminalOpen,open:!1}),D.suggestedSetupScript&&l({projectId:D.project.id,command:D.suggestedSetupScript})}}else D.type==="error"&&(_&&w&&(e({type:P.RemoveCreatingProject,projectId:w}),R&&e({type:P.RemoveProcessingThread,threadId:R})),e({type:P.AppendTerminalLine,threadId:R||"project-creation",line:{type:"error",content:`Error: ${D.message}`}}))}catch(D){console.error("Failed to parse project event",D)}}}e({type:P.SetCreatingProject,isCreating:!1}),_&&R&&e({type:P.RemoveProcessingThread,threadId:R});const N=await Ns();if(e({type:P.SetProjects,projects:N.projects}),T){const y=N.projects.find(S=>S.projectId===T);if(y&&y.threads.length>0){const S=y.threads[0].threadId;e({type:P.SelectThread,threadId:S,projectId:T,focusInput:!0})}}}catch(v){console.error("Failed to create project:",v),e({type:P.SetCreatingProject,isCreating:!1}),r({type:P.AppendTerminalLine,line:{type:"error",content:`Failed to create project: ${v instanceof Error?v.message:"Unknown error"}`}})}},[e,o,r]),d=m.useCallback(async(p,j,v)=>{e({type:P.SetCreatingProject,isCreating:!0});try{const b=await Kr(p,j,v);if(!b){e({type:P.SetCreatingProject,isCreating:!1}),await o();return}e({type:P.ClearTerminalOutput}),e({type:P.SetTerminalOpen,open:!0}),e({type:P.AppendTerminalLine,line:{type:"system",content:`Creating app "${p}"...`}});const I=b.getReader(),C=new TextDecoder;let x="",T=null,_=!1,w=null,R=null;for(;;){const{done:y,value:S}=await I.read();if(y)break;x+=C.decode(S,{stream:!0});const E=x.split(`
|
|
16
|
+
`);x=E.pop()||"";for(const k of E){const A=k.trim();if(A)try{const D=JSON.parse(A);D.type==="progress"?(!_&&D.threadId&&D.projectId&&(_=!0,w=D.projectId,R=D.threadId,e({type:P.AddCreatingProject,projectId:D.projectId,threadId:D.threadId,projectName:p,gitUrl:""}),e({type:P.AddProcessingThread,threadId:D.threadId})),e({type:P.AppendTerminalLine,line:{type:"output",content:D.message}})):D.type==="complete"?D.project&&(T=D.project.id,e({type:P.AppendTerminalLine,line:{type:"system",content:`Project created successfully at: ${D.project.path}`}}),e({type:P.SetTerminalOpen,open:!1})):D.type==="error"&&(_&&w&&(e({type:P.RemoveCreatingProject,projectId:w}),R&&e({type:P.RemoveProcessingThread,threadId:R})),e({type:P.AppendTerminalLine,line:{type:"error",content:`Error: ${D.message}`}}))}catch(D){console.error("Failed to parse scaffold event",D)}}}e({type:P.SetCreatingProject,isCreating:!1}),_&&R&&e({type:P.RemoveProcessingThread,threadId:R});const N=await Ns();if(e({type:P.SetProjects,projects:N.projects}),T){const y=N.projects.find(S=>S.projectId===T);if(y&&y.threads.length>0){const S=y.threads[0].threadId;e({type:P.SelectThread,threadId:S,projectId:T,focusInput:!0})}}}catch(b){console.error("Failed to create web app:",b),e({type:P.SetCreatingProject,isCreating:!1}),e({type:P.AppendTerminalLine,line:{type:"error",content:`Failed to create web app: ${b instanceof Error?b.message:"Unknown error"}`}})}},[e,o]),u=m.useCallback(async(p,j)=>{try{const v=j||(()=>{const y=s.projects.find(k=>k.projectId===p)?.threads.map(k=>k.title)||[],S=/^thread-(\d+)$/i;let E=0;for(const k of y){const A=k.match(S);A&&(E=Math.max(E,parseInt(A[1],10)))}return`thread-${E+1}`})(),b=await lo(p,j);if(!b){await o();return}const I=b.getReader(),C=new TextDecoder;let x="",T=!1,_=null,w=!0;const R=[{type:"system",content:`Creating thread "${v}"...`}];try{for(;;){const{done:N,value:y}=await I.read();if(N)break;x+=C.decode(y,{stream:!0});const S=x.split(`
|
|
17
|
+
`);x=S.pop()||"";for(const E of S){const k=E.trim();if(k)try{const A=JSON.parse(k);if(A.type==="progress"){if(!T&&A.threadId){T=!0,_=A.threadId,e({type:P.AddCreatingThread,projectId:p,threadId:A.threadId,title:v}),e({type:P.AddProcessingThread,threadId:A.threadId}),e({type:P.ClearTerminalOutput,threadId:_});for(const z of R)e({type:P.AppendTerminalLine,threadId:_,line:z});R.length=0}const D={type:"output",content:A.message};_?e({type:P.AppendTerminalLine,threadId:_,line:D}):R.push(D)}else if(A.type==="error"){T&&_&&(e({type:P.RemoveCreatingThread,projectId:p,threadId:_}),e({type:P.RemoveProcessingThread,threadId:_}));const D={type:"error",content:`Error: ${A.message}`};_?e({type:P.AppendTerminalLine,threadId:_,line:D}):R.push(D),console.error("Thread creation error:",A.message),t({title:"Thread Creation Failed",description:A.message,variant:"destructive"}),w=!1}}catch(A){console.error("Failed to parse thread event",A)}}}T&&_&&e({type:P.RemoveProcessingThread,threadId:_}),await o(),_&&w&&e({type:P.SelectThread,threadId:_,projectId:p,focusInput:!0})}catch(N){T&&_&&(e({type:P.RemoveCreatingThread,projectId:p,threadId:_}),e({type:P.RemoveProcessingThread,threadId:_}));const y=N instanceof Error?N.message:String(N);throw t({title:"Thread Creation Failed",description:y,variant:"destructive"}),N}}catch(v){console.error("Failed to create thread:",v);const b=`Failed to create thread: ${v instanceof Error?v.message:"Unknown error"}`;throw e({type:P.AppendTerminalLine,line:{type:"error",content:b}}),t({variant:"destructive",title:"Thread Creation Failed",description:b}),v}},[o,e,s.projects,t]),f=m.useCallback(async(p,j)=>{e({type:P.AddDeletingThread,threadId:j});try{await oo(p,j),await o(),s.selectedThreadId===j&&e({type:P.SelectThread,threadId:"",projectId:""})}catch(v){console.error("Failed to delete thread:",v)}finally{e({type:P.RemoveDeletingThread,threadId:j})}},[o,s.selectedThreadId,e]),g=m.useCallback(async p=>{e({type:P.AddDeletingProject,projectId:p});const v=s.projects.find(b=>b.projectId===p)?.threads.map(b=>b.threadId)||[];for(const b of v)e({type:P.AddDeletingThread,threadId:b});try{await ao(p),await o(),s.selectedProjectId===p&&e({type:P.SelectThread,threadId:"",projectId:""})}catch(b){console.error("Failed to delete project:",b)}finally{e({type:P.RemoveDeletingProject,projectId:p});for(const b of v)e({type:P.RemoveDeletingThread,threadId:b})}},[o,s.selectedProjectId,s.projects,e]),h=m.useCallback(async p=>{const j=a;if(l(null),!(!j||!p))try{e({type:P.SetCreatingProject,isCreating:!0}),e({type:P.AppendTerminalLine,line:{type:"system",content:`Running setup script: ${j.command}`}});const v=await Qr(j.projectId,j.command,!0);if(v){const b=v.getReader(),I=new TextDecoder;let C="";for(;;){const{done:x,value:T}=await b.read();if(x)break;C+=I.decode(T,{stream:!0});const _=C.split(`
|
|
18
|
+
`);C=_.pop()||"";for(const w of _)if(w.trim())try{const R=JSON.parse(w);typeof R=="string"?e({type:P.AppendTerminalLine,line:{type:"output",content:R}}):R.type==="error"&&e({type:P.AppendTerminalLine,line:{type:"error",content:R.message}})}catch{e({type:P.AppendTerminalLine,line:{type:"output",content:w}})}}if(C.trim())try{const x=JSON.parse(C);typeof x=="string"?e({type:P.AppendTerminalLine,line:{type:"output",content:x}}):x.type==="error"&&e({type:P.AppendTerminalLine,line:{type:"error",content:x.message}})}catch{e({type:P.AppendTerminalLine,line:{type:"output",content:C}})}}e({type:P.SetCreatingProject,isCreating:!1}),await o()}catch(v){e({type:P.SetCreatingProject,isCreating:!1}),console.error("Failed to run setup script:",v),e({type:P.AppendTerminalLine,line:{type:"error",content:`Failed to run setup script: ${v instanceof Error?v.message:"Unknown error"}`}})}},[a,e,o]);return m.useEffect(()=>{let p=!0;async function j(){try{const v=await Ns();if(!p)return;if(e({type:P.SetProjects,projects:v.projects}),!s.selectedThreadId)for(const b of v.projects){const I=b.threads.find(C=>C.isSelected);if(I){e({type:P.SelectThread,threadId:I.threadId,projectId:b.projectId});break}}}catch(v){console.error("Failed to load projects:",v)}}return j(),()=>{p=!1}},[e,s.selectedThreadId,s.configUpdatedAt]),{projects:s.projects,selectedProjectId:s.selectedProjectId,selectedThreadId:s.selectedThreadId,refreshProjects:o,handleSelectThread:i,handleCreateProject:c,handleCreateWebApp:d,handleCreateThread:u,handleDeleteThread:f,confirmDeleteProject:g,pendingSetupScriptConfirmation:a,resolveSetupScriptConfirmation:h}}function vd(){const s=$.c(2),[e,t]=m.useState(Nd);let r,a;return s[0]===Symbol.for("react.memo_cache_sentinel")?(r=()=>{const l=()=>t(!0),o=()=>t(!1);return window.addEventListener("focus",l),window.addEventListener("blur",o),()=>{window.removeEventListener("focus",l),window.removeEventListener("blur",o)}},a=[],s[0]=r,s[1]=a):(r=s[0],a=s[1]),m.useEffect(r,a),e}function Nd(){return document.hasFocus()}let ws=null;function wd(){ws||(ws=new Audio("/pop.wav")),ws.currentTime=0,ws.play().catch(s=>{console.debug("Could not play completion sound:",s)})}function Sd(){const{state:s,dispatch:e}=Se(),t=vd(),r=m.useRef(null),a=m.useRef(!1),l=m.useRef([]),o=m.useRef(s),i=m.useRef(t);m.useEffect(()=>{o.current=s},[s]),m.useEffect(()=>{i.current=t},[t]);const c=m.useCallback(async()=>{try{const u=await so(),f=l.current.filter(g=>!u.includes(g));for(const g of f)g!==o.current.selectedThreadId&&e({type:P.MarkThreadCompleted,threadId:g});return f.length>0&&!i.current&&wd(),l.current=u,e({type:P.SetProcessingThreads,threadIds:u}),u}catch(u){return console.error("Failed to fetch processing threads:",u),[]}},[e]);m.useEffect(()=>{const u=()=>{if(r.current||a.current)return;a.current=!0;const g=async()=>{(await c()).length>0||o.current.isStreaming||o.current.isCreatingProject?r.current=setTimeout(g,1e3):(r.current=null,a.current=!1)};g()},f=()=>{r.current&&(clearTimeout(r.current),r.current=null),a.current=!1};return(s.isStreaming||s.isCreatingProject||s.processingThreadIds.length>0)&&u(),()=>{f()}},[s.isStreaming,s.isCreatingProject,s.processingThreadIds.length,c]),m.useEffect(()=>{(s.isStreaming||s.isCreatingProject)&&c()},[s.isStreaming,s.isCreatingProject,c]);const d=m.useCallback(u=>{e({type:P.ClearThreadCompleted,threadId:u})},[e]);return{processingThreadIds:s.processingThreadIds,completedThreadIds:s.completedThreadIds,isThreadProcessing:u=>s.processingThreadIds.includes(u),isThreadCompleted:u=>s.completedThreadIds.includes(u),clearCompleted:d}}const Vs=768;function Cd(){const s=$.c(2),[e,t]=m.useState(void 0);let r,a;return s[0]===Symbol.for("react.memo_cache_sentinel")?(r=()=>{const l=window.matchMedia(`(max-width: ${Vs-1}px)`),o=()=>{t(window.innerWidth<Vs)};return l.addEventListener("change",o),t(window.innerWidth<Vs),()=>l.removeEventListener("change",o)},a=[],s[0]=r,s[1]=a):(r=s[0],a=s[1]),m.useEffect(r,a),!!e}function Td(){const{state:s,dispatch:e}=Se(),t=Cd(),{projects:r,handleSelectThread:a,handleCreateProject:l,handleCreateWebApp:o,handleCreateThread:i,handleDeleteThread:c,confirmDeleteProject:d,refreshProjects:u,pendingSetupScriptConfirmation:f,resolveSetupScriptConfirmation:g}=bd(),{processingThreadIds:h,completedThreadIds:p,clearCompleted:j}=Sd(),[v,b]=m.useState(!1),[I,C]=m.useState(!1),[x,T]=m.useState(!1),[_,w]=m.useState(!1),[R,N]=m.useState(null),[y,S]=m.useState(null),E=m.useRef(null);m.useEffect(()=>{_||(async()=>{try{(await Fo()).onboardingCompleted||T(!0)}catch(F){console.error("Failed to check onboarding status:",F)}finally{w(!0)}})()},[_]),m.useEffect(()=>{I||e({type:P.ConfigUpdated})},[I,e]),m.useEffect(()=>{x||e({type:P.ConfigUpdated})},[x,e]);const k=m.useCallback(L=>{const F=r.find(B=>B.projectId===L);F&&N({id:F.projectId,name:Es(F)})},[r]),A=m.useCallback(L=>{i(L,"")},[i]),D=m.useCallback(L=>{const F=r.find(B=>B.projectId===L);F&&S({id:F.projectId,name:Es(F),setupScript:F.setupScript,runCommand:F.runCommand})},[r]),z=m.useCallback(L=>{e({type:P.OpenHistoryView,initialFilter:L})},[e]),O=m.useCallback(async(L,F)=>{j(F),await a(L,F),t&&s.sidebarOpen&&e({type:P.ToggleSidebar})},[a,t,s.sidebarOpen,e,j]);return m.useEffect(()=>{s.sidebarOpen?E.current?.expand():E.current?.collapse()},[s.sidebarOpen]),n.jsxs(we,{delayDuration:200,children:[n.jsxs(md,{direction:"horizontal",className:"h-screen bg-background",children:[n.jsx(An,{ref:E,defaultSize:t?100:20,minSize:t?50:12,maxSize:t?100:32,collapsible:!0,collapsedSize:0,className:"border-r border-border",children:n.jsx("div",{className:"h-full overflow-hidden",children:n.jsx(Wl,{projects:r,selectedThreadId:s.selectedThreadId,processingThreadIds:h,completedThreadIds:p,deletingThreadIds:s.deletingThreadIds,deletingProjectIds:s.deletingProjectIds,onSelectThread:O,onCreateProject:()=>b(!0),onCreateThread:A,onDeleteThread:c,onDeleteProject:k,onOpenConfiguration:()=>C(!0),onProjectSettings:D,onViewHistory:z,onCollapseSidebar:()=>e({type:P.ToggleSidebar}),isMobile:t})})}),!t&&n.jsx(fd,{withHandle:!0}),n.jsx(An,{minSize:40,className:`overflow-hidden ${t&&s.sidebarOpen?"hidden":""}`,children:n.jsxs("div",{className:"flex h-full flex-col overflow-hidden",children:[n.jsx(Kc,{}),n.jsx("main",{className:"flex-1 overflow-hidden",children:n.jsx(pc,{onCreateThread:A})})]})}),n.jsx(aa,{open:v,onOpenChange:b,onSubmitClone:l,onSubmitWebApp:o}),n.jsx(Qc,{open:R!==null,projectName:R?.name,onOpenChange:L=>!L&&N(null),onConfirm:()=>{R&&(d(R.id),N(null))}}),n.jsx(Yc,{open:y!==null,onOpenChange:L=>!L&&S(null),projectId:y?.id??"",onRefresh:u}),n.jsx(Xc,{open:f!==null,suggestedCommand:f?.command??null,onConfirm:g}),n.jsx(td,{open:I,onOpenChange:C,onRestartOnboarding:async()=>{try{await Ho(),C(!1),T(!0)}catch(L){console.error("Failed to restart onboarding:",L)}}}),n.jsx(ad,{open:x,onOpenChange:T,onComplete:()=>{w(!0),u()}}),n.jsx(dd,{}),n.jsx(cd,{isOpen:s.historyView.isOpen,onClose:()=>e({type:P.CloseHistoryView}),initialFilter:s.historyView.initialFilter,projects:r})]}),n.jsx(xd,{})]})}function Id(){const s=$.c(5),[e,t]=m.useReducer(Ol,Hr);let r;s[0]!==e?(r={state:e,dispatch:t},s[0]=e,s[1]=r):r=s[1];let a;s[2]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx(Td,{}),s[2]=a):a=s[2];let l;return s[3]!==r?(l=n.jsx(yd,{attribute:"class",defaultTheme:"system",enableSystem:!0,storageKey:"tarsk-theme",children:n.jsx(Ur.Provider,{value:r,children:a})}),s[3]=r,s[4]=l):l=s[4],l}Pl.createRoot(document.getElementById("root")).render(n.jsx(m.StrictMode,{children:n.jsx(Id,{})}));
|