@townco/gui-template 0.1.13 → 0.1.14

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.
@@ -1 +1 @@
1
- import{n as h,a as p,s as e,o,r as a,u as t,b as l,l as n,c as s,d as m}from"./vendor--IKG6KWl.js";const Qe=1,x=h(),C=p(),w=e(),q=o({_meta:a(t()).optional(),content:e(),path:e(),sessionId:e()}),f=o({_meta:a(t()).optional(),limit:p().optional().nullable(),line:p().optional().nullable(),path:e(),sessionId:e()}),M=o({_meta:a(t()).optional(),sessionId:e(),terminalId:e()}),k=o({_meta:a(t()).optional(),sessionId:e(),terminalId:e()}),v=o({_meta:a(t()).optional(),sessionId:e(),terminalId:e()}),O=o({_meta:a(t()).optional(),sessionId:e(),terminalId:e()}),F=a(t()),U=l([n("assistant"),n("user")]),z=o({_meta:a(t()).optional(),mimeType:e().optional().nullable(),text:e(),uri:e()}),N=o({_meta:a(t()).optional(),blob:e(),mimeType:e().optional().nullable(),uri:e()}),b=l([n("read"),n("edit"),n("delete"),n("move"),n("search"),n("execute"),n("think"),n("fetch"),n("switch_mode"),n("other")]),_=l([n("pending"),n("in_progress"),n("completed"),n("failed")]),S=o({code:p(),data:a(t()).optional(),message:e()}),E=o({_meta:a(t()).optional()}),P=o({_meta:t().optional()}),V=o({_meta:a(t()).optional(),stopReason:l([n("end_turn"),n("max_tokens"),n("max_turn_requests"),n("refusal"),n("cancelled")])}),j=o({_meta:a(t()).optional()}),L=a(t()),B=e(),H=a(t()),K=o({hint:e()}),A=h(),D=p(),G=e(),J=o({_meta:a(t()).optional(),methodId:e()}),Q=o({_meta:a(t()).optional(),modeId:e(),sessionId:e()}),W=o({_meta:a(t()).optional(),modelId:e(),sessionId:e()}),X=a(t()),d=o({_meta:a(t()).optional(),name:e(),value:e()}),i=o({_meta:a(t()).optional(),audience:s(U).optional().nullable(),lastModified:e().optional().nullable(),priority:p().optional().nullable()}),c=l([z,N]),Y=o({_meta:a(t()).optional()}),Z=o({_meta:a(t()).optional(),content:e()}),$=o({_meta:a(t()).optional(),outcome:l([o({outcome:n("cancelled")}),o({optionId:e(),outcome:n("selected")})])}),ee=o({_meta:a(t()).optional(),terminalId:e()}),oe=o({_meta:a(t()).optional()}),te=o({_meta:a(t()).optional(),exitCode:p().optional().nullable(),signal:e().optional().nullable()}),ae=o({_meta:a(t()).optional()}),ne=a(t()),le=o({_meta:a(t()).optional(),sessionId:e()}),ie=a(t()),se=o({_meta:a(t()).optional(),kind:l([n("allow_once"),n("allow_always"),n("reject_once"),n("reject_always")]),name:e(),optionId:e()}),u=l([o({content:l([o({_meta:a(t()).optional(),annotations:i.optional().nullable(),text:e(),type:n("text")}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),data:e(),mimeType:e(),type:n("image"),uri:e().optional().nullable()}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),data:e(),mimeType:e(),type:n("audio")}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),description:e().optional().nullable(),mimeType:e().optional().nullable(),name:e(),size:p().optional().nullable(),title:e().optional().nullable(),type:n("resource_link"),uri:e()}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),resource:c,type:n("resource")})]),type:n("content")}),o({_meta:a(t()).optional(),newText:e(),oldText:e().optional().nullable(),path:e(),type:n("diff")}),o({terminalId:e(),type:n("terminal")})]),r=o({_meta:a(t()).optional(),line:p().optional().nullable(),path:e()}),y=o({_meta:a(t()).optional(),name:e(),value:e()}),R=o({name:e(),title:e().optional().nullable(),version:e()}),pe=o({_meta:a(t()).optional(),description:e().optional().nullable(),id:e(),name:e()}),me=o({_meta:a(t()).optional(),http:m().optional(),sse:m().optional()}),ce=o({_meta:a(t()).optional(),audio:m().optional(),embeddedContext:m().optional(),image:m().optional()}),ue=o({_meta:a(t()).optional(),description:e().optional().nullable(),modelId:e(),name:e()}),re=o({_meta:a(t()).optional(),description:e().optional().nullable(),id:B,name:e()}),T=o({_meta:a(t()).optional(),availableModels:s(ue),currentModelId:e()}),I=o({_meta:a(t()).optional(),availableModes:s(re),currentModeId:e()}),de=o({_meta:a(t()).optional(),content:e(),priority:l([n("high"),n("medium"),n("low")]),status:l([n("pending"),n("in_progress"),n("completed")])}),he=K,be=o({_meta:a(t()).optional(),readTextFile:m().optional(),writeTextFile:m().optional()}),_e=o({args:s(e()),command:e(),env:s(y),name:e()}),g=l([o({headers:s(d),name:e(),type:n("http"),url:e()}),o({headers:s(d),name:e(),type:n("sse"),url:e()}),_e]),Se=l([o({_meta:a(t()).optional(),annotations:i.optional().nullable(),text:e(),type:n("text")}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),data:e(),mimeType:e(),type:n("image"),uri:e().optional().nullable()}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),data:e(),mimeType:e(),type:n("audio")}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),description:e().optional().nullable(),mimeType:e().optional().nullable(),name:e(),size:p().optional().nullable(),title:e().optional().nullable(),type:n("resource_link"),uri:e()}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),resource:c,type:n("resource")})]),ye=o({_meta:a(t()).optional(),exitCode:p().optional().nullable(),signal:e().optional().nullable()}),Re=l([le,ie]),Te=o({_meta:a(t()).optional(),options:s(se),sessionId:e(),toolCall:o({_meta:a(t()).optional(),content:s(u).optional().nullable(),kind:b.optional().nullable(),locations:s(r).optional().nullable(),rawInput:a(t()).optional(),rawOutput:a(t()).optional(),status:_.optional().nullable(),title:e().optional().nullable(),toolCallId:e()})}),Ie=o({_meta:a(t()).optional(),args:s(e()).optional(),command:e(),cwd:e().optional().nullable(),env:s(y).optional(),outputByteLimit:p().optional().nullable(),sessionId:e()}),ge=o({_meta:a(t()).optional(),models:T.optional().nullable(),modes:I.optional().nullable(),sessionId:e()}),xe=o({_meta:a(t()).optional(),models:T.optional().nullable(),modes:I.optional().nullable()}),Ce=o({method:e(),params:Re.optional().nullable()}),we=o({_meta:a(t()).optional(),cwd:e(),mcpServers:s(g)}),qe=o({_meta:a(t()).optional(),cwd:e(),mcpServers:s(g),sessionId:e()}),fe=o({_meta:a(t()).optional(),prompt:s(Se),sessionId:e()}),Me=o({_meta:a(t()).optional(),exitStatus:ye.optional().nullable(),output:e(),truncated:m()}),ke=l([q,f,Te,Ie,M,k,v,O,F]),ve=o({_meta:a(t()).optional(),loadSession:m().optional(),mcpCapabilities:me.optional(),promptCapabilities:ce.optional()}),Oe=o({_meta:a(t()).optional(),description:e(),input:he.optional().nullable(),name:e()}),Fe=o({_meta:a(t()).optional(),fs:be.optional(),terminal:m().optional()}),Ue=o({id:l([x,C,w]),method:e(),params:ke.optional().nullable()}),ze=o({_meta:a(t()).optional(),agentCapabilities:ve.optional(),agentInfo:R.optional().nullable(),authMethods:s(pe).optional(),protocolVersion:p()}),Ne=o({_meta:a(t()).optional(),sessionId:e(),update:l([o({_meta:a(t()).optional(),content:l([o({_meta:a(t()).optional(),annotations:i.optional().nullable(),text:e(),type:n("text")}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),data:e(),mimeType:e(),type:n("image"),uri:e().optional().nullable()}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),data:e(),mimeType:e(),type:n("audio")}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),description:e().optional().nullable(),mimeType:e().optional().nullable(),name:e(),size:p().optional().nullable(),title:e().optional().nullable(),type:n("resource_link"),uri:e()}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),resource:c,type:n("resource")})]),sessionUpdate:n("user_message_chunk")}),o({_meta:a(t()).optional(),content:l([o({_meta:a(t()).optional(),annotations:i.optional().nullable(),text:e(),type:n("text")}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),data:e(),mimeType:e(),type:n("image"),uri:e().optional().nullable()}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),data:e(),mimeType:e(),type:n("audio")}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),description:e().optional().nullable(),mimeType:e().optional().nullable(),name:e(),size:p().optional().nullable(),title:e().optional().nullable(),type:n("resource_link"),uri:e()}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),resource:c,type:n("resource")})]),sessionUpdate:n("agent_message_chunk")}),o({_meta:a(t()).optional(),content:l([o({_meta:a(t()).optional(),annotations:i.optional().nullable(),text:e(),type:n("text")}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),data:e(),mimeType:e(),type:n("image"),uri:e().optional().nullable()}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),data:e(),mimeType:e(),type:n("audio")}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),description:e().optional().nullable(),mimeType:e().optional().nullable(),name:e(),size:p().optional().nullable(),title:e().optional().nullable(),type:n("resource_link"),uri:e()}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),resource:c,type:n("resource")})]),sessionUpdate:n("agent_thought_chunk")}),o({_meta:a(t()).optional(),content:s(u).optional(),kind:l([n("read"),n("edit"),n("delete"),n("move"),n("search"),n("execute"),n("think"),n("fetch"),n("switch_mode"),n("other")]).optional(),locations:s(r).optional(),rawInput:a(t()).optional(),rawOutput:a(t()).optional(),sessionUpdate:n("tool_call"),status:l([n("pending"),n("in_progress"),n("completed"),n("failed")]).optional(),title:e(),toolCallId:e()}),o({_meta:a(t()).optional(),content:s(u).optional().nullable(),kind:b.optional().nullable(),locations:s(r).optional().nullable(),rawInput:a(t()).optional(),rawOutput:a(t()).optional(),sessionUpdate:n("tool_call_update"),status:_.optional().nullable(),title:e().optional().nullable(),toolCallId:e()}),o({_meta:a(t()).optional(),entries:s(de),sessionUpdate:n("plan")}),o({_meta:a(t()).optional(),availableCommands:s(Oe),sessionUpdate:n("available_commands_update")}),o({_meta:a(t()).optional(),currentModeId:e(),sessionUpdate:n("current_mode_update")})])}),Ee=o({_meta:a(t()).optional(),clientCapabilities:Fe.optional(),clientInfo:R.optional().nullable(),protocolVersion:p()}),Pe=l([Y,Z,$,ee,Me,oe,te,ae,ne]),Ve=l([Ne,H]),je=l([Ee,J,we,qe,Q,fe,W,X]),Le=o({method:e(),params:Ve.optional().nullable()}),Be=l([ze,E,ge,xe,P,V,j,L]),He=o({id:l([A,D,G]),method:e(),params:je.optional().nullable()}),Ke=l([o({result:Pe}),o({error:S})]),Ae=l([He,Ke,Ce]),De=l([o({result:Be}),o({error:S})]),Ge=l([Ue,De,Le]);l([Ge,Ae]);export{Qe as P,Ge as a};
1
+ import{n as h,a as p,s as e,o,r as a,u as t,b as l,l as n,c as s,d as m}from"./vendor-BxtqxsLB.js";const Qe=1,x=h(),C=p(),w=e(),q=o({_meta:a(t()).optional(),content:e(),path:e(),sessionId:e()}),f=o({_meta:a(t()).optional(),limit:p().optional().nullable(),line:p().optional().nullable(),path:e(),sessionId:e()}),M=o({_meta:a(t()).optional(),sessionId:e(),terminalId:e()}),k=o({_meta:a(t()).optional(),sessionId:e(),terminalId:e()}),v=o({_meta:a(t()).optional(),sessionId:e(),terminalId:e()}),O=o({_meta:a(t()).optional(),sessionId:e(),terminalId:e()}),F=a(t()),U=l([n("assistant"),n("user")]),z=o({_meta:a(t()).optional(),mimeType:e().optional().nullable(),text:e(),uri:e()}),N=o({_meta:a(t()).optional(),blob:e(),mimeType:e().optional().nullable(),uri:e()}),b=l([n("read"),n("edit"),n("delete"),n("move"),n("search"),n("execute"),n("think"),n("fetch"),n("switch_mode"),n("other")]),_=l([n("pending"),n("in_progress"),n("completed"),n("failed")]),S=o({code:p(),data:a(t()).optional(),message:e()}),E=o({_meta:a(t()).optional()}),P=o({_meta:t().optional()}),V=o({_meta:a(t()).optional(),stopReason:l([n("end_turn"),n("max_tokens"),n("max_turn_requests"),n("refusal"),n("cancelled")])}),j=o({_meta:a(t()).optional()}),L=a(t()),B=e(),H=a(t()),K=o({hint:e()}),A=h(),D=p(),G=e(),J=o({_meta:a(t()).optional(),methodId:e()}),Q=o({_meta:a(t()).optional(),modeId:e(),sessionId:e()}),W=o({_meta:a(t()).optional(),modelId:e(),sessionId:e()}),X=a(t()),d=o({_meta:a(t()).optional(),name:e(),value:e()}),i=o({_meta:a(t()).optional(),audience:s(U).optional().nullable(),lastModified:e().optional().nullable(),priority:p().optional().nullable()}),c=l([z,N]),Y=o({_meta:a(t()).optional()}),Z=o({_meta:a(t()).optional(),content:e()}),$=o({_meta:a(t()).optional(),outcome:l([o({outcome:n("cancelled")}),o({optionId:e(),outcome:n("selected")})])}),ee=o({_meta:a(t()).optional(),terminalId:e()}),oe=o({_meta:a(t()).optional()}),te=o({_meta:a(t()).optional(),exitCode:p().optional().nullable(),signal:e().optional().nullable()}),ae=o({_meta:a(t()).optional()}),ne=a(t()),le=o({_meta:a(t()).optional(),sessionId:e()}),ie=a(t()),se=o({_meta:a(t()).optional(),kind:l([n("allow_once"),n("allow_always"),n("reject_once"),n("reject_always")]),name:e(),optionId:e()}),u=l([o({content:l([o({_meta:a(t()).optional(),annotations:i.optional().nullable(),text:e(),type:n("text")}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),data:e(),mimeType:e(),type:n("image"),uri:e().optional().nullable()}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),data:e(),mimeType:e(),type:n("audio")}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),description:e().optional().nullable(),mimeType:e().optional().nullable(),name:e(),size:p().optional().nullable(),title:e().optional().nullable(),type:n("resource_link"),uri:e()}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),resource:c,type:n("resource")})]),type:n("content")}),o({_meta:a(t()).optional(),newText:e(),oldText:e().optional().nullable(),path:e(),type:n("diff")}),o({terminalId:e(),type:n("terminal")})]),r=o({_meta:a(t()).optional(),line:p().optional().nullable(),path:e()}),y=o({_meta:a(t()).optional(),name:e(),value:e()}),R=o({name:e(),title:e().optional().nullable(),version:e()}),pe=o({_meta:a(t()).optional(),description:e().optional().nullable(),id:e(),name:e()}),me=o({_meta:a(t()).optional(),http:m().optional(),sse:m().optional()}),ce=o({_meta:a(t()).optional(),audio:m().optional(),embeddedContext:m().optional(),image:m().optional()}),ue=o({_meta:a(t()).optional(),description:e().optional().nullable(),modelId:e(),name:e()}),re=o({_meta:a(t()).optional(),description:e().optional().nullable(),id:B,name:e()}),T=o({_meta:a(t()).optional(),availableModels:s(ue),currentModelId:e()}),I=o({_meta:a(t()).optional(),availableModes:s(re),currentModeId:e()}),de=o({_meta:a(t()).optional(),content:e(),priority:l([n("high"),n("medium"),n("low")]),status:l([n("pending"),n("in_progress"),n("completed")])}),he=K,be=o({_meta:a(t()).optional(),readTextFile:m().optional(),writeTextFile:m().optional()}),_e=o({args:s(e()),command:e(),env:s(y),name:e()}),g=l([o({headers:s(d),name:e(),type:n("http"),url:e()}),o({headers:s(d),name:e(),type:n("sse"),url:e()}),_e]),Se=l([o({_meta:a(t()).optional(),annotations:i.optional().nullable(),text:e(),type:n("text")}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),data:e(),mimeType:e(),type:n("image"),uri:e().optional().nullable()}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),data:e(),mimeType:e(),type:n("audio")}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),description:e().optional().nullable(),mimeType:e().optional().nullable(),name:e(),size:p().optional().nullable(),title:e().optional().nullable(),type:n("resource_link"),uri:e()}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),resource:c,type:n("resource")})]),ye=o({_meta:a(t()).optional(),exitCode:p().optional().nullable(),signal:e().optional().nullable()}),Re=l([le,ie]),Te=o({_meta:a(t()).optional(),options:s(se),sessionId:e(),toolCall:o({_meta:a(t()).optional(),content:s(u).optional().nullable(),kind:b.optional().nullable(),locations:s(r).optional().nullable(),rawInput:a(t()).optional(),rawOutput:a(t()).optional(),status:_.optional().nullable(),title:e().optional().nullable(),toolCallId:e()})}),Ie=o({_meta:a(t()).optional(),args:s(e()).optional(),command:e(),cwd:e().optional().nullable(),env:s(y).optional(),outputByteLimit:p().optional().nullable(),sessionId:e()}),ge=o({_meta:a(t()).optional(),models:T.optional().nullable(),modes:I.optional().nullable(),sessionId:e()}),xe=o({_meta:a(t()).optional(),models:T.optional().nullable(),modes:I.optional().nullable()}),Ce=o({method:e(),params:Re.optional().nullable()}),we=o({_meta:a(t()).optional(),cwd:e(),mcpServers:s(g)}),qe=o({_meta:a(t()).optional(),cwd:e(),mcpServers:s(g),sessionId:e()}),fe=o({_meta:a(t()).optional(),prompt:s(Se),sessionId:e()}),Me=o({_meta:a(t()).optional(),exitStatus:ye.optional().nullable(),output:e(),truncated:m()}),ke=l([q,f,Te,Ie,M,k,v,O,F]),ve=o({_meta:a(t()).optional(),loadSession:m().optional(),mcpCapabilities:me.optional(),promptCapabilities:ce.optional()}),Oe=o({_meta:a(t()).optional(),description:e(),input:he.optional().nullable(),name:e()}),Fe=o({_meta:a(t()).optional(),fs:be.optional(),terminal:m().optional()}),Ue=o({id:l([x,C,w]),method:e(),params:ke.optional().nullable()}),ze=o({_meta:a(t()).optional(),agentCapabilities:ve.optional(),agentInfo:R.optional().nullable(),authMethods:s(pe).optional(),protocolVersion:p()}),Ne=o({_meta:a(t()).optional(),sessionId:e(),update:l([o({_meta:a(t()).optional(),content:l([o({_meta:a(t()).optional(),annotations:i.optional().nullable(),text:e(),type:n("text")}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),data:e(),mimeType:e(),type:n("image"),uri:e().optional().nullable()}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),data:e(),mimeType:e(),type:n("audio")}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),description:e().optional().nullable(),mimeType:e().optional().nullable(),name:e(),size:p().optional().nullable(),title:e().optional().nullable(),type:n("resource_link"),uri:e()}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),resource:c,type:n("resource")})]),sessionUpdate:n("user_message_chunk")}),o({_meta:a(t()).optional(),content:l([o({_meta:a(t()).optional(),annotations:i.optional().nullable(),text:e(),type:n("text")}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),data:e(),mimeType:e(),type:n("image"),uri:e().optional().nullable()}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),data:e(),mimeType:e(),type:n("audio")}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),description:e().optional().nullable(),mimeType:e().optional().nullable(),name:e(),size:p().optional().nullable(),title:e().optional().nullable(),type:n("resource_link"),uri:e()}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),resource:c,type:n("resource")})]),sessionUpdate:n("agent_message_chunk")}),o({_meta:a(t()).optional(),content:l([o({_meta:a(t()).optional(),annotations:i.optional().nullable(),text:e(),type:n("text")}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),data:e(),mimeType:e(),type:n("image"),uri:e().optional().nullable()}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),data:e(),mimeType:e(),type:n("audio")}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),description:e().optional().nullable(),mimeType:e().optional().nullable(),name:e(),size:p().optional().nullable(),title:e().optional().nullable(),type:n("resource_link"),uri:e()}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),resource:c,type:n("resource")})]),sessionUpdate:n("agent_thought_chunk")}),o({_meta:a(t()).optional(),content:s(u).optional(),kind:l([n("read"),n("edit"),n("delete"),n("move"),n("search"),n("execute"),n("think"),n("fetch"),n("switch_mode"),n("other")]).optional(),locations:s(r).optional(),rawInput:a(t()).optional(),rawOutput:a(t()).optional(),sessionUpdate:n("tool_call"),status:l([n("pending"),n("in_progress"),n("completed"),n("failed")]).optional(),title:e(),toolCallId:e()}),o({_meta:a(t()).optional(),content:s(u).optional().nullable(),kind:b.optional().nullable(),locations:s(r).optional().nullable(),rawInput:a(t()).optional(),rawOutput:a(t()).optional(),sessionUpdate:n("tool_call_update"),status:_.optional().nullable(),title:e().optional().nullable(),toolCallId:e()}),o({_meta:a(t()).optional(),entries:s(de),sessionUpdate:n("plan")}),o({_meta:a(t()).optional(),availableCommands:s(Oe),sessionUpdate:n("available_commands_update")}),o({_meta:a(t()).optional(),currentModeId:e(),sessionUpdate:n("current_mode_update")})])}),Ee=o({_meta:a(t()).optional(),clientCapabilities:Fe.optional(),clientInfo:R.optional().nullable(),protocolVersion:p()}),Pe=l([Y,Z,$,ee,Me,oe,te,ae,ne]),Ve=l([Ne,H]),je=l([Ee,J,we,qe,Q,fe,W,X]),Le=o({method:e(),params:Ve.optional().nullable()}),Be=l([ze,E,ge,xe,P,V,j,L]),He=o({id:l([A,D,G]),method:e(),params:je.optional().nullable()}),Ke=l([o({result:Pe}),o({error:S})]),Ae=l([He,Ke,Ce]),De=l([o({result:Be}),o({error:S})]),Ge=l([Ue,De,Le]);l([Ge,Ae]);export{Qe as P,Ge as a};
@@ -1 +1 @@
1
- import{r}from"./react-CIcriR6k.js";const _=o=>o.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),m=o=>o.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,c,a)=>a?a.toUpperCase():c.toLowerCase()),h=o=>{const t=m(o);return t.charAt(0).toUpperCase()+t.slice(1)},i=(...o)=>o.filter((t,c,a)=>!!t&&t.trim()!==""&&a.indexOf(t)===c).join(" ").trim(),w=o=>{for(const t in o)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};var g={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const u=r.forwardRef(({color:o="currentColor",size:t=24,strokeWidth:c=2,absoluteStrokeWidth:a,className:n="",children:s,iconNode:l,...d},p)=>r.createElement("svg",{ref:p,...g,width:t,height:t,stroke:o,strokeWidth:a?Number(c)*24/Number(t):c,className:i("lucide",n),...!s&&!w(d)&&{"aria-hidden":"true"},...d},[...l.map(([y,k])=>r.createElement(y,k)),...Array.isArray(s)?s:[s]]));const e=(o,t)=>{const c=r.forwardRef(({className:a,...n},s)=>r.createElement(u,{ref:s,iconNode:t,className:i(`lucide-${_(h(o))}`,`lucide-${o}`,a),...n}));return c.displayName=h(o),c};const f=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],D=e("arrow-down",f);const C=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],V=e("arrow-right",C);const v=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],F=e("check",v);const $=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],I=e("chevron-down",$);const x=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Z=e("chevron-right",x);const N=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],K=e("chevron-up",N);const M=[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]],O=e("chevrons-up-down",M);const b=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],T=e("circle-check",b);const A=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],X=e("circle",A);const j=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],G=e("code",j);const z=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],J=e("file-text",z);const q=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Q=e("loader-circle",q);const L=[["path",{d:"M12 19v3",key:"npa21l"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["rect",{x:"9",y:"2",width:"6",height:"13",rx:"3",key:"s6n7sd"}]],Y=e("mic",L);const S=[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551",key:"1miecu"}]],e1=e("paperclip",S);const E=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],t1=e("settings",E);const H=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],o1=e("sparkles",H);const P=[["path",{d:"M21 10.656V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.344",key:"2acyp4"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],c1=e("square-check-big",P);const R=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["line",{x1:"9",x2:"15",y1:"15",y2:"9",key:"1dfufj"}]],a1=e("square-slash",R);const U=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]],s1=e("wrench",U);const W=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],r1=e("x",W);export{D as A,Z as C,J as F,Q as L,Y as M,e1 as P,a1 as S,s1 as W,r1 as X,F as a,X as b,I as c,O as d,K as e,T as f,V as g,c1 as h,o1 as i,t1 as j,G as k};
1
+ import{r}from"./react-DWDN8s0r.js";const _=o=>o.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),m=o=>o.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,c,a)=>a?a.toUpperCase():c.toLowerCase()),h=o=>{const t=m(o);return t.charAt(0).toUpperCase()+t.slice(1)},i=(...o)=>o.filter((t,c,a)=>!!t&&t.trim()!==""&&a.indexOf(t)===c).join(" ").trim(),w=o=>{for(const t in o)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};var g={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const u=r.forwardRef(({color:o="currentColor",size:t=24,strokeWidth:c=2,absoluteStrokeWidth:a,className:n="",children:s,iconNode:l,...d},p)=>r.createElement("svg",{ref:p,...g,width:t,height:t,stroke:o,strokeWidth:a?Number(c)*24/Number(t):c,className:i("lucide",n),...!s&&!w(d)&&{"aria-hidden":"true"},...d},[...l.map(([y,k])=>r.createElement(y,k)),...Array.isArray(s)?s:[s]]));const e=(o,t)=>{const c=r.forwardRef(({className:a,...n},s)=>r.createElement(u,{ref:s,iconNode:t,className:i(`lucide-${_(h(o))}`,`lucide-${o}`,a),...n}));return c.displayName=h(o),c};const f=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],D=e("arrow-down",f);const C=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],V=e("arrow-right",C);const v=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],F=e("check",v);const $=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],I=e("chevron-down",$);const x=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Z=e("chevron-right",x);const N=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],K=e("chevron-up",N);const M=[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]],O=e("chevrons-up-down",M);const b=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],T=e("circle-check",b);const A=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],X=e("circle",A);const j=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],G=e("code",j);const z=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],J=e("file-text",z);const q=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Q=e("loader-circle",q);const L=[["path",{d:"M12 19v3",key:"npa21l"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["rect",{x:"9",y:"2",width:"6",height:"13",rx:"3",key:"s6n7sd"}]],Y=e("mic",L);const S=[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551",key:"1miecu"}]],e1=e("paperclip",S);const E=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],t1=e("settings",E);const H=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],o1=e("sparkles",H);const P=[["path",{d:"M21 10.656V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.344",key:"2acyp4"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],c1=e("square-check-big",P);const R=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["line",{x1:"9",x2:"15",y1:"15",y2:"9",key:"1dfufj"}]],a1=e("square-slash",R);const U=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]],s1=e("wrench",U);const W=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],r1=e("x",W);export{D as A,Z as C,J as F,Q as L,Y as M,e1 as P,a1 as S,s1 as W,r1 as X,F as a,X as b,I as c,O as d,K as e,T as f,V as g,c1 as h,o1 as i,t1 as j,G as k};
@@ -1,8 +1,8 @@
1
- import{r as i,j as t,P as Mt,e as At,f as Ut,M as Dt,h as se,i as Pt,a as Lt}from"./react-CIcriR6k.js";import{L,M as T,N as R,O as x,P as ce,Q as E,R as I,S as A,T as U,U as Ht,W as B,X as G,Y as zt,Z as _t,$ as Ot,a0 as Ft,a1 as H,a2 as $t}from"./vendor--IKG6KWl.js";import{P as Bt,a as Vt}from"./acp-sdk-CrAUv_2m.js";import{S as q,L as de,T as ue,C as fe,R as qt,O as pe,P as Wt,a as me,b as Qt,c as he,D as xe,d as ge,e as be,f as Kt,g as ye,I as we,h as ve,i as Ne,j as je,k as Ce,l as Se,m as Te,n as Ie,o as Gt,p as Ee,q as Re,r as Yt,s as ke,V as Jt,t as Me,u as Ae,v as Xt,w as Zt,x as Ue}from"./radix-BPjk4-Jl.js";import{S as es,P as ts,M as ss,A as ns,X as rs,C as os,a as De,b as Pe,c as te,W as as,L as Le,d as is,e as ls,f as cs,g as ds,h as us,F as fs,i as ne,j as ps,k as ms}from"./icons-Dn0pjvgj.js";import{r as hs}from"./markdown-CwEbCfit.js";(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))n(o);new MutationObserver(o=>{for(const c of o)if(c.type==="childList")for(const d of c.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&n(d)}).observe(document,{childList:!0,subtree:!0});function r(o){const c={};return o.integrity&&(c.integrity=o.integrity),o.referrerPolicy&&(c.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?c.credentials="include":o.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function n(o){if(o.ep)return;o.ep=!0;const c=r(o);fetch(o.href,c)}})();const He=L(["pending","in_progress","completed","failed"]),xs=L(["read","edit","delete","move","search","execute","think","fetch","switch_mode","other"]),ze=T({path:x(),line:R().nullable().optional()}),_e=T({inputTokens:R().optional(),outputTokens:R().optional(),totalTokens:R().optional()}),Oe=ce("type",[T({type:E("content"),content:T({type:E("text"),text:x()})}),T({type:E("text"),text:x()}),T({type:E("diff"),path:x(),oldText:x(),newText:x(),line:R().nullable().optional()}),T({type:E("terminal"),terminalId:x()})]),Fe=T({id:x(),title:x(),kind:xs,status:He,locations:I(ze).optional(),rawInput:A(x(),U()).optional(),rawOutput:A(x(),U()).optional(),content:I(Oe).optional(),error:x().optional(),startedAt:R().optional(),completedAt:R().optional(),tokenUsage:_e.optional()}),gs=T({id:x(),status:He.optional(),locations:I(ze).optional(),rawOutput:A(x(),U()).optional(),content:I(Oe).optional(),error:x().optional(),completedAt:R().optional(),tokenUsage:_e.optional()});function re(s,e){return{...s,status:e.status??s.status,locations:e.locations??s.locations,rawOutput:e.rawOutput??s.rawOutput,content:e.content?[...s.content??[],...e.content]:s.content,error:e.error??s.error,completedAt:e.completedAt??s.completedAt,tokenUsage:e.tokenUsage??s.tokenUsage}}const S=Ht(s=>({connectionStatus:"disconnected",sessionId:null,error:null,messages:[],isStreaming:!1,streamingStartTime:null,toolCalls:{},input:{value:"",isSubmitting:!1,attachedFiles:[]},setConnectionStatus:e=>s({connectionStatus:e}),setSessionId:e=>s({sessionId:e}),setError:e=>s({error:e}),addMessage:e=>s(r=>({messages:[...r.messages,e]})),updateMessage:(e,r)=>s(n=>({messages:n.messages.map(o=>o.id===e?{...o,...r}:o)})),clearMessages:()=>s({messages:[]}),setIsStreaming:e=>s({isStreaming:e}),setStreamingStartTime:e=>s({streamingStartTime:e}),addToolCall:(e,r)=>s(n=>({toolCalls:{...n.toolCalls,[e]:[...n.toolCalls[e]||[],r]}})),addToolCallToCurrentMessage:e=>s(r=>{const n=r.messages.findLastIndex(d=>d.role==="assistant");if(n===-1)return console.warn("No assistant message found to add tool call to"),r;const o=[...r.messages],c=o[n];return c?(o[n]={...c,toolCalls:[...c.toolCalls||[],e]},{messages:o}):r}),updateToolCallInCurrentMessage:e=>s(r=>{const n=r.messages.findLastIndex(l=>l.role==="assistant");if(n===-1)return console.warn("No assistant message found to update tool call in"),r;const o=[...r.messages],c=o[n];if(!c)return r;const d=c.toolCalls||[],f=d.findIndex(l=>l.id===e.id);if(f===-1)return console.warn(`Tool call ${e.id} not found in message`),r;const p=d[f];if(!p)return r;const a=[...d];return a[f]=re(p,e),o[n]={...c,toolCalls:a},{messages:o}}),updateToolCall:(e,r)=>s(n=>{const o=n.toolCalls[e]||[],c=o.findIndex(p=>p.id===r.id);if(c===-1)return n;const d=o[c];if(!d)return n;const f=[...o];return f[c]=re(d,r),{toolCalls:{...n.toolCalls,[e]:f}}}),setInputValue:e=>s(r=>({input:{...r.input,value:e}})),setInputSubmitting:e=>s(r=>({input:{...r.input,isSubmitting:e}})),addFileAttachment:e=>s(r=>({input:{...r.input,attachedFiles:[...r.input.attachedFiles,e]}})),removeFileAttachment:e=>s(r=>({input:{...r.input,attachedFiles:r.input.attachedFiles.filter((n,o)=>o!==e)}})),clearInput:()=>s(e=>({input:{value:"",isSubmitting:!1,attachedFiles:[]}}))}));function $e(s){const e=S(l=>l.messages),r=S(l=>l.isStreaming),n=S(l=>l.sessionId),o=S(l=>l.setIsStreaming),c=S(l=>l.setStreamingStartTime),d=S(l=>l.addMessage),f=S(l=>l.updateMessage),p=S(l=>l.setError),a=i.useCallback(async l=>{if(!s){console.error("❌ No client available"),p("No client available");return}if(!n){console.error("❌ No active session"),p("No active session");return}try{const u=Date.now();o(!0),c(u);const h={id:`msg_${Date.now()}_user`,role:"user",content:l,timestamp:new Date().toISOString(),isStreaming:!1};d(h);const g=`msg_${Date.now()}_assistant`,b={id:g,role:"assistant",content:"",timestamp:new Date().toISOString(),isStreaming:!0,streamingStartTime:u};d(b);const j=e.filter(v=>v.role!=="system").map(v=>`${v.role==="user"?"Human":"Assistant"}: ${v.content}`).join(`
1
+ import{r as i,j as t,P as Mt,e as At,f as Ut,M as Dt,h as Pt,a as Lt}from"./react-DWDN8s0r.js";import{L,M as T,N as R,O as x,P as ce,Q as E,R as I,S as A,T as U,U as Ht,W as B,X as G,Y as zt,Z as _t,$ as Ot,a0 as Ft,a1 as H,a2 as $t,a3 as se}from"./vendor-BxtqxsLB.js";import{P as Bt,a as Vt}from"./acp-sdk-BiGbXeF1.js";import{S as q,L as de,T as ue,C as fe,R as qt,O as pe,P as Wt,a as me,b as Qt,c as he,D as xe,d as ge,e as be,f as Kt,g as ye,I as we,h as ve,i as Ne,j as je,k as Ce,l as Se,m as Te,n as Ie,o as Gt,p as Ee,q as Re,r as Yt,s as ke,V as Jt,t as Me,u as Ae,v as Xt,w as Zt,x as Ue}from"./radix-C1pEulHa.js";import{S as es,P as ts,M as ss,A as ns,X as rs,C as os,a as De,b as Pe,c as te,W as as,L as Le,d as is,e as ls,f as cs,g as ds,h as us,F as fs,i as ne,j as ps,k as ms}from"./icons-BtPq83UA.js";import{r as hs}from"./markdown-DP5OEpQP.js";(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))n(o);new MutationObserver(o=>{for(const c of o)if(c.type==="childList")for(const d of c.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&n(d)}).observe(document,{childList:!0,subtree:!0});function r(o){const c={};return o.integrity&&(c.integrity=o.integrity),o.referrerPolicy&&(c.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?c.credentials="include":o.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function n(o){if(o.ep)return;o.ep=!0;const c=r(o);fetch(o.href,c)}})();const He=L(["pending","in_progress","completed","failed"]),xs=L(["read","edit","delete","move","search","execute","think","fetch","switch_mode","other"]),ze=T({path:x(),line:R().nullable().optional()}),_e=T({inputTokens:R().optional(),outputTokens:R().optional(),totalTokens:R().optional()}),Oe=ce("type",[T({type:E("content"),content:T({type:E("text"),text:x()})}),T({type:E("text"),text:x()}),T({type:E("diff"),path:x(),oldText:x(),newText:x(),line:R().nullable().optional()}),T({type:E("terminal"),terminalId:x()})]),Fe=T({id:x(),title:x(),kind:xs,status:He,locations:I(ze).optional(),rawInput:A(x(),U()).optional(),rawOutput:A(x(),U()).optional(),content:I(Oe).optional(),error:x().optional(),startedAt:R().optional(),completedAt:R().optional(),tokenUsage:_e.optional()}),gs=T({id:x(),status:He.optional(),locations:I(ze).optional(),rawOutput:A(x(),U()).optional(),content:I(Oe).optional(),error:x().optional(),completedAt:R().optional(),tokenUsage:_e.optional()});function re(s,e){return{...s,status:e.status??s.status,locations:e.locations??s.locations,rawOutput:e.rawOutput??s.rawOutput,content:e.content?[...s.content??[],...e.content]:s.content,error:e.error??s.error,completedAt:e.completedAt??s.completedAt,tokenUsage:e.tokenUsage??s.tokenUsage}}const S=Ht(s=>({connectionStatus:"disconnected",sessionId:null,error:null,messages:[],isStreaming:!1,streamingStartTime:null,toolCalls:{},input:{value:"",isSubmitting:!1,attachedFiles:[]},setConnectionStatus:e=>s({connectionStatus:e}),setSessionId:e=>s({sessionId:e}),setError:e=>s({error:e}),addMessage:e=>s(r=>({messages:[...r.messages,e]})),updateMessage:(e,r)=>s(n=>({messages:n.messages.map(o=>o.id===e?{...o,...r}:o)})),clearMessages:()=>s({messages:[]}),setIsStreaming:e=>s({isStreaming:e}),setStreamingStartTime:e=>s({streamingStartTime:e}),addToolCall:(e,r)=>s(n=>({toolCalls:{...n.toolCalls,[e]:[...n.toolCalls[e]||[],r]}})),addToolCallToCurrentMessage:e=>s(r=>{const n=r.messages.findLastIndex(d=>d.role==="assistant");if(n===-1)return console.warn("No assistant message found to add tool call to"),r;const o=[...r.messages],c=o[n];return c?(o[n]={...c,toolCalls:[...c.toolCalls||[],e]},{messages:o}):r}),updateToolCallInCurrentMessage:e=>s(r=>{const n=r.messages.findLastIndex(l=>l.role==="assistant");if(n===-1)return console.warn("No assistant message found to update tool call in"),r;const o=[...r.messages],c=o[n];if(!c)return r;const d=c.toolCalls||[],f=d.findIndex(l=>l.id===e.id);if(f===-1)return console.warn(`Tool call ${e.id} not found in message`),r;const p=d[f];if(!p)return r;const a=[...d];return a[f]=re(p,e),o[n]={...c,toolCalls:a},{messages:o}}),updateToolCall:(e,r)=>s(n=>{const o=n.toolCalls[e]||[],c=o.findIndex(p=>p.id===r.id);if(c===-1)return n;const d=o[c];if(!d)return n;const f=[...o];return f[c]=re(d,r),{toolCalls:{...n.toolCalls,[e]:f}}}),setInputValue:e=>s(r=>({input:{...r.input,value:e}})),setInputSubmitting:e=>s(r=>({input:{...r.input,isSubmitting:e}})),addFileAttachment:e=>s(r=>({input:{...r.input,attachedFiles:[...r.input.attachedFiles,e]}})),removeFileAttachment:e=>s(r=>({input:{...r.input,attachedFiles:r.input.attachedFiles.filter((n,o)=>o!==e)}})),clearInput:()=>s(e=>({input:{value:"",isSubmitting:!1,attachedFiles:[]}}))}));function $e(s){const e=S(l=>l.messages),r=S(l=>l.isStreaming),n=S(l=>l.sessionId),o=S(l=>l.setIsStreaming),c=S(l=>l.setStreamingStartTime),d=S(l=>l.addMessage),f=S(l=>l.updateMessage),p=S(l=>l.setError),a=i.useCallback(async l=>{if(!s){console.error("❌ No client available"),p("No client available");return}if(!n){console.error("❌ No active session"),p("No active session");return}try{const u=Date.now();o(!0),c(u);const h={id:`msg_${Date.now()}_user`,role:"user",content:l,timestamp:new Date().toISOString(),isStreaming:!1};d(h);const g=`msg_${Date.now()}_assistant`,b={id:g,role:"assistant",content:"",timestamp:new Date().toISOString(),isStreaming:!0,streamingStartTime:u};d(b);const j=e.filter(v=>v.role!=="system").map(v=>`${v.role==="user"?"Human":"Assistant"}: ${v.content}`).join(`
2
2
 
3
3
  `),N=j?`${j}
4
4
 
5
5
  Human: ${l}`:l,y=s.receiveMessages();s.sendMessage(N,n).catch(v=>{const k=v instanceof Error?v.message:String(v);p(k),o(!1),c(null)});let w="";for await(const v of y)if(v.isComplete){f(g,{content:w,isStreaming:!1,streamingStartTime:void 0}),o(!1),c(null);break}else v.contentDelta.type==="text"&&(w+=v.contentDelta.text,f(g,{content:w}),await new Promise(k=>setTimeout(k,16)))}catch(u){const h=u instanceof Error?u.message:String(u);p(h),o(!1),c(null)}},[s,n,e,d,f,o,c,p]);return{messages:e,isStreaming:r,sendMessage:a}}function bs(s){const e=S(u=>u.input),r=S(u=>u.setInputValue),n=S(u=>u.setInputSubmitting),o=S(u=>u.addFileAttachment),c=S(u=>u.removeFileAttachment),{sendMessage:d}=$e(s),f=i.useCallback(u=>{r(u)},[r]),p=i.useCallback(async()=>{if(!e.value.trim()||e.isSubmitting)return;const u=e.value;r(""),n(!0);try{await d(u)}catch(h){console.error("Failed to send message:",h)}finally{n(!1)}},[e,r,n,d]),a=i.useCallback(u=>{o(u)},[o]),l=i.useCallback(u=>{c(u)},[c]);return{value:e.value,isSubmitting:e.isSubmitting,attachedFiles:e.attachedFiles,onChange:f,onSubmit:p,onAttachFile:a,onRemoveFile:l}}function ys(s){const e=S(l=>l.connectionStatus),r=S(l=>l.sessionId),n=S(l=>l.setConnectionStatus),o=S(l=>l.setSessionId),c=S(l=>l.setError),d=S(l=>l.clearMessages),f=i.useCallback(async()=>{if(!s){c("No client available");return}try{n("connecting"),c(null),await s.connect(),n("connected")}catch(l){console.log(l);const u=l instanceof Error?l.message:String(l);c(u),n("error")}},[s,n,c]),p=i.useCallback(async()=>{if(!s){c("No client available");return}try{const l=await s.startSession();o(l),d()}catch(l){const u=l instanceof Error?l.message:String(l);c(u)}},[s,o,c,d]),a=i.useCallback(async()=>{if(s)try{await s.disconnect(),n("disconnected"),o(null)}catch(l){const u=l instanceof Error?l.message:String(l);c(u)}},[s,n,o,c]);return i.useEffect(()=>{s&&e==="disconnected"&&f()},[s,e,f]),i.useEffect(()=>{e==="connected"&&!r&&p()},[e,r,p]),{connectionStatus:e,sessionId:r,connect:f,startSession:p,disconnect:a}}function ws(s){const e=S(d=>d.toolCalls),r=S(d=>d.addToolCall),n=S(d=>d.updateToolCall),o=S(d=>d.addToolCallToCurrentMessage),c=S(d=>d.updateToolCallInCurrentMessage);return i.useEffect(()=>{if(!s)return;const d=s.onSessionUpdate(f=>{f.type==="tool_call"?(r(f.sessionId,f.toolCall),o(f.toolCall)):f.type==="tool_call_update"&&(n(f.sessionId,f.toolCallUpdate),c(f.toolCallUpdate))});return()=>{d()}},[s,r,n,o,c]),{toolCalls:e,getToolCallsForSession:d=>{const f=e[d];return f&&f.length>0?f:Object.values(e).flat()}}}const oe={trace:0,debug:1,info:2,warn:3,error:4,fatal:5},vs={trace:"color: #6B7280",debug:"color: #3B82F6; font-weight: bold",info:"color: #10B981; font-weight: bold",warn:"color: #F59E0B; font-weight: bold",error:"color: #EF4444; font-weight: bold",fatal:"color: #DC2626; font-weight: bold; background: #FEE2E2"};class Ns{service;minLevel;constructor(e,r="debug"){this.service=e,this.minLevel=r,typeof process<"u"&&(this.minLevel="info")}shouldLog(e){return oe[e]>=oe[this.minLevel]}log(e,r,n){if(!this.shouldLog(e))return;const o={timestamp:new Date().toISOString(),level:e,service:this.service,message:r,...n&&{metadata:n}},c=vs[e],d=e.toUpperCase().padEnd(5);if(typeof console<"u"){const f=`%c[${o.timestamp}] [${this.service}] [${d}]`,p=n?`${r} %o`:r;switch(e){case"trace":case"debug":case"info":console.log(f,c,p,...n?[n]:[]);break;case"warn":console.warn(f,c,p,...n?[n]:[]);break;case"error":case"fatal":console.error(f,c,p,...n?[n]:[]);break}}(e==="fatal"||e==="error")&&console.debug("Structured log:",JSON.stringify(o))}trace(e,r){this.log("trace",e,r)}debug(e,r){this.log("debug",e,r)}info(e,r){this.log("info",e,r)}warn(e,r){this.log("warn",e,r)}error(e,r){this.log("error",e,r)}fatal(e,r){this.log("fatal",e,r)}}function Be(s,e="debug"){return new Ns(s,e)}const js=T({id:x(),role:L(["user","assistant","system"]),content:x(),timestamp:G(),isStreaming:B().default(!1),streamingStartTime:R().optional(),metadata:A(x(),U()).optional(),toolCalls:I(Fe).optional()}),Cs=T({value:x(),isSubmitting:B(),attachedFiles:I(T({name:x(),path:x(),size:R(),mimeType:x()}))});T({sessionId:x().nullable(),isConnected:B(),isStreaming:B(),messages:I(js),input:Cs,error:x().nullable()});L(["disconnected","connecting","connected","error"]);class Ss{connected=!1;sessionUpdateCallbacks=new Set;errorCallbacks=new Set;messageQueue=[];currentSessionId=null;chunkResolvers=[];streamComplete=!1;sseAbortController=null;reconnectAttempts=0;maxReconnectAttempts=5;reconnectDelay=1e3;reconnecting=!1;abortController=null;options;constructor(e){this.options={...e,baseUrl:e.baseUrl.replace(/\/$/,"")}}async connect(){if(!this.connected)try{this.abortController=new AbortController;const e={protocolVersion:Bt,clientCapabilities:{fs:{readTextFile:!0,writeTextFile:!0}}},r=await this.sendRpcRequest("initialize",e);console.log("ACP connection initialized:",r);const n={cwd:"/",mcpServers:[]},o=await this.sendRpcRequest("session/new",n);this.currentSessionId=o.sessionId,console.log("Session created:",this.currentSessionId),await this.connectSSE(),this.connected=!0,this.reconnectAttempts=0}catch(e){this.connected=!1;const r=e instanceof Error?e:new Error(String(e));throw this.notifyError(r),r}}async disconnect(){if(this.connected)try{this.abortController&&(this.abortController.abort(),this.abortController=null),this.sseAbortController&&(this.sseAbortController.abort(),this.sseAbortController=null),this.connected=!1,this.currentSessionId=null,this.messageQueue=[],this.chunkResolvers=[],this.streamComplete=!1,this.reconnecting=!1,this.reconnectAttempts=0}catch(e){const r=e instanceof Error?e:new Error(String(e));throw this.notifyError(r),r}}async send(e){if(!this.connected||!this.currentSessionId)throw new Error("Transport not connected");try{this.streamComplete=!1,this.messageQueue=[];const r=e.content.filter(d=>d.type==="text").map(d=>d.text).join(`
6
6
  `),n={sessionId:this.currentSessionId,prompt:[{type:"text",text:r}]},o=await this.sendRpcRequest("session/prompt",n);console.log("Prompt sent:",o),this.streamComplete=!0;const c=this.chunkResolvers.shift();c?c({id:this.currentSessionId||"unknown",role:"assistant",contentDelta:{type:"text",text:""},isComplete:!0}):this.messageQueue.push({id:this.currentSessionId||"unknown",role:"assistant",contentDelta:{type:"text",text:""},isComplete:!0})}catch(r){this.streamComplete=!0;const n=r instanceof Error?r:new Error(String(r));throw this.notifyError(n),n}}async*receive(){for(;!this.streamComplete;)if(this.messageQueue.length>0){const e=this.messageQueue.shift();if(e&&(yield e,e.isComplete))return}else{const e=await new Promise(r=>{this.chunkResolvers.push(r)});if(e.isComplete){yield e;return}else yield e}for(;this.messageQueue.length>0;){const e=this.messageQueue.shift();e&&(yield e)}yield{id:this.currentSessionId||"unknown",role:"assistant",contentDelta:{type:"text",text:""},isComplete:!0}}isConnected(){return this.connected}onSessionUpdate(e){return this.sessionUpdateCallbacks.add(e),()=>{this.sessionUpdateCallbacks.delete(e)}}onError(e){return this.errorCallbacks.add(e),()=>{this.errorCallbacks.delete(e)}}async sendRpcRequest(e,r){const o={jsonrpc:"2.0",id:this.generateRequestId(),method:e,params:r},c={"Content-Type":"application/json",...this.options.headers},d=this.options.timeout||3e4,f=new AbortController,p=setTimeout(()=>f.abort(),d);try{const a=await fetch(`${this.options.baseUrl}/rpc`,{method:"POST",headers:c,body:JSON.stringify(o),signal:f.signal});if(clearTimeout(p),!a.ok){const u=await a.text();throw new Error(`HTTP ${a.status}: ${u}`)}const l=await a.json();if(l.error)throw new Error(`ACP error: ${l.error.message||JSON.stringify(l.error)}`);return l.result||l}catch(a){throw clearTimeout(p),a instanceof Error&&a.name==="AbortError"?new Error(`Request timeout after ${d}ms`):a}}async connectSSE(){if(!this.currentSessionId)throw new Error("Cannot connect SSE without a session ID");const e=`${this.options.baseUrl}/events`,r={"X-Session-ID":this.currentSessionId,...this.options.headers};this.sseAbortController=new AbortController;try{const n=await fetch(e,{method:"GET",headers:r,signal:this.sseAbortController.signal});if(!n.ok)throw new Error(`SSE connection failed: HTTP ${n.status}`);if(!n.body)throw new Error("Response body is null");console.log("SSE connection opened"),this.reconnectAttempts=0,this.reconnectDelay=1e3;const o=n.body.getReader(),c=new TextDecoder;let d="";(async()=>{try{for(;;){const{done:f,value:p}=await o.read();if(f){console.log("SSE stream closed by server"),this.connected&&await this.handleSSEDisconnect();break}d+=c.decode(p,{stream:!0});const a=d.split(`
7
7
  `);d=a.pop()||"";let l={event:"message",data:""};for(const u of a)u.startsWith("event:")?l.event=u.substring(6).trim():u.startsWith("data:")?l.data=u.substring(5).trim():u===""&&(l.event==="message"&&l.data&&this.handleSSEMessage(l.data),l={event:"message",data:""})}}catch(f){if(f instanceof Error&&f.name==="AbortError"){console.log("SSE stream aborted");return}console.error("Error reading SSE stream:",f),this.connected&&!this.reconnecting&&await this.handleSSEDisconnect()}})()}catch(n){throw console.error("SSE connection error:",n),n}}async handleSSEDisconnect(){if(this.reconnecting||!this.connected)return;if(this.reconnecting=!0,this.sseAbortController&&(this.sseAbortController.abort(),this.sseAbortController=null),this.reconnectAttempts>=this.maxReconnectAttempts){const r=new Error(`SSE reconnection failed after ${this.maxReconnectAttempts} attempts`);this.notifyError(r),this.connected=!1,this.reconnecting=!1;return}this.reconnectAttempts++;const e=Math.min(this.reconnectDelay*2**(this.reconnectAttempts-1),32e3);console.log(`SSE reconnecting in ${e}ms (attempt ${this.reconnectAttempts}/${this.maxReconnectAttempts})`),await new Promise(r=>setTimeout(r,e));try{await this.connectSSE(),console.log("SSE reconnected successfully"),this.reconnecting=!1}catch(r){console.error("SSE reconnection failed:",r),this.reconnecting=!1}}handleSSEMessage(e){try{const r=JSON.parse(e);console.log("[HTTP Transport] Received SSE message:",r);const n=Vt.safeParse(r);if(!n.success){console.error("Invalid ACP message from SSE:",n.error.issues);return}const o=n.data;console.log("[HTTP Transport] Parsed ACP message, method:","method"in o?o.method:"(no method)"),"method"in o&&o.method==="session/update"&&(console.log("[HTTP Transport] This is a session/update notification"),"params"in o&&o.params&&(console.log("[HTTP Transport] Calling handleSessionNotification with params:",o.params),this.handleSessionNotification(o.params)))}catch(r){console.error("Error parsing SSE message:",r),this.notifyError(r instanceof Error?r:new Error(String(r)))}}handleSessionNotification(e){console.log("[HTTP Transport] handleSessionNotification called with:",e);const n=e.update,o=this.currentSessionId||e.sessionId;if(console.log("[HTTP Transport] update.sessionUpdate type:",n?.sessionUpdate),n?.sessionUpdate==="tool_call"){console.log("[HTTP Transport] tool_call - tokenUsage:",n.tokenUsage);const c=n._meta&&typeof n._meta=="object"&&"messageId"in n._meta?String(n._meta.messageId):void 0,d={id:n.toolCallId??"",title:n.title??"",kind:n.kind||"other",status:n.status||"pending",locations:n.locations,rawInput:n.rawInput,tokenUsage:n.tokenUsage,content:n.content?.map(p=>{if(typeof p!="object"||p===null)return{type:"text",text:""};const a=p;if(a.type==="content"&&typeof a.content=="object"&&a.content!==null){const l=a.content;if(l.type==="text")return{type:"content",content:{type:"text",text:typeof l.text=="string"?l.text:""}}}return a.type==="text"?{type:"text",text:typeof a.text=="string"?a.text:""}:a.type==="diff"?{type:"diff",path:typeof a.path=="string"?a.path:"",oldText:typeof a.oldText=="string"?a.oldText:"",newText:typeof a.newText=="string"?a.newText:"",line:typeof a.line=="number"?a.line:null}:a.type==="terminal"?{type:"terminal",terminalId:typeof a.terminalId=="string"?a.terminalId:""}:{type:"text",text:""}}),startedAt:Date.now()},f={type:"tool_call",sessionId:o,status:"active",toolCall:d,messageId:c};this.notifySessionUpdate(f)}else if(n?.sessionUpdate==="tool_call_update"){const c=n._meta&&typeof n._meta=="object"&&"messageId"in n._meta?String(n._meta.messageId):void 0,d={id:n.toolCallId??"",status:n.status,locations:n.locations,rawOutput:n.rawOutput,tokenUsage:n.tokenUsage,content:n.content?.map(p=>{if(typeof p!="object"||p===null)return{type:"text",text:""};const a=p;if(a.type==="content"&&typeof a.content=="object"&&a.content!==null){const l=a.content;if(l.type==="text")return{type:"content",content:{type:"text",text:typeof l.text=="string"?l.text:""}}}return a.type==="text"?{type:"text",text:typeof a.text=="string"?a.text:""}:a.type==="diff"?{type:"diff",path:typeof a.path=="string"?a.path:"",oldText:typeof a.oldText=="string"?a.oldText:"",newText:typeof a.newText=="string"?a.newText:"",line:typeof a.line=="number"?a.line:null}:a.type==="terminal"?{type:"terminal",terminalId:typeof a.terminalId=="string"?a.terminalId:""}:{type:"text",text:""}}),error:n.error,completedAt:n.status==="completed"||n.status==="failed"?Date.now():void 0},f={type:"tool_call_update",sessionId:o,status:"active",toolCallUpdate:d,messageId:c};console.log("[HTTP Transport] Notifying tool_call_update session update:",f),this.notifySessionUpdate(f)}else if(n&&"sessionUpdate"in n&&n.sessionUpdate==="tool_output"){const c=n,d=c._meta&&typeof c._meta=="object"&&"messageId"in c._meta?String(c._meta.messageId):void 0,f={id:c.toolCallId??"",rawOutput:c.rawOutput,content:c.content?.map(a=>{if(typeof a!="object"||a===null)return{type:"text",text:""};const l=a;if(l.type==="content"&&typeof l.content=="object"&&l.content!==null){const u=l.content;if(u.type==="text")return{type:"content",content:{type:"text",text:typeof u.text=="string"?u.text:""}}}return l.type==="text"?{type:"text",text:typeof l.text=="string"?l.text:""}:l.type==="diff"?{type:"diff",path:typeof l.path=="string"?l.path:"",oldText:typeof l.oldText=="string"?l.oldText:"",newText:typeof l.newText=="string"?l.newText:"",line:typeof l.line=="number"?l.line:null}:l.type==="terminal"?{type:"terminal",terminalId:typeof l.terminalId=="string"?l.terminalId:""}:{type:"text",text:""}})},p={type:"tool_call_update",sessionId:o,status:"active",toolCallUpdate:f,messageId:d};console.log("[HTTP Transport] Notifying tool_output as tool_call_update:",p),this.notifySessionUpdate(p)}else if(n?.sessionUpdate==="agent_message_chunk"){const c={type:"generic",sessionId:o,status:"active"},d=n.content;if(d&&typeof d=="object"){const f=d;let p=null;if(f.type==="text"&&typeof f.text=="string"&&(p={id:e.sessionId,role:"assistant",contentDelta:{type:"text",text:f.text},isComplete:!1}),p){const a=this.chunkResolvers.shift();a?a(p):this.messageQueue.push(p)}}this.notifySessionUpdate(c)}else{const c={type:"generic",sessionId:o,status:"active"};this.notifySessionUpdate(c)}}generateRequestId(){return`req-${Date.now()}-${Math.random().toString(36).substring(2,9)}`}notifySessionUpdate(e){for(const r of this.sessionUpdateCallbacks)try{r(e)}catch(n){console.error("Error in session update callback:",n)}}notifyError(e){for(const r of this.errorCallbacks)try{r(e)}catch(n){console.error("Error in error callback:",n)}}}class Ts{constructor(){throw new Error("StdioTransport is not available in the browser. Use HttpTransport or WebSocketTransport instead.")}async connect(){throw new Error("StdioTransport not available in browser")}async disconnect(){}async send(){throw new Error("StdioTransport not available in browser")}async*receive(){throw new Error("StdioTransport not available in browser")}isConnected(){return!1}onSessionUpdate(){return()=>{}}onError(){return()=>{}}}class Is{ws=null;connected=!1;sessionUpdateCallbacks=new Set;errorCallbacks=new Set;constructor(e){}async connect(){throw new Error("WebSocketTransport not yet implemented. Waiting for HTTP ACP server.")}async disconnect(){this.ws&&(this.ws.close(),this.ws=null),this.connected=!1}async send(e){throw!this.connected||!this.ws?new Error("Transport not connected"):new Error("WebSocketTransport not yet implemented. Waiting for HTTP ACP server.")}async*receive(){throw new Error("WebSocketTransport not yet implemented. Waiting for HTTP ACP server.")}isConnected(){return this.connected}onSessionUpdate(e){return this.sessionUpdateCallbacks.add(e),()=>{this.sessionUpdateCallbacks.delete(e)}}onError(e){return this.errorCallbacks.add(e),()=>{this.errorCallbacks.delete(e)}}}class Es{config;transport;sessions=new Map;currentSessionId=null;sessionUpdateHandlers=new Set;errorHandlers=new Set;constructor(e){this.config=e,this.transport=this.createTransport(),this.setupTransportListeners(),e.autoConnect&&this.connect().catch(r=>{console.error("Failed to auto-connect:",r)})}async connect(){await this.transport.connect()}async disconnect(){await this.transport.disconnect(),this.currentSessionId=null}isConnected(){return this.transport.isConnected()}async startSession(e){const r=this.generateSessionId(),n=new Date().toISOString(),o={id:r,status:"connecting",config:e?{...e,agentPath:e.agentPath||""}:{agentPath:""},messages:[],metadata:{startedAt:n}};return this.sessions.set(r,o),this.currentSessionId=r,this.updateSessionStatus(r,"connected"),r}async sendMessage(e,r){const n=r||this.currentSessionId;if(!n)throw new Error("No active session. Start a session first.");if(!this.transport.isConnected())throw new Error("Transport not connected");const o=this.sessions.get(n);if(!o)throw new Error(`Session ${n} not found`);const c={id:this.generateMessageId(),role:"user",content:[{type:"text",text:e}],timestamp:new Date().toISOString()};o.messages.push(c),this.updateSessionStatus(n,"active"),await this.transport.send(c)}async*receiveMessages(){if(!this.transport.isConnected())throw new Error("Transport not connected");yield*this.transport.receive()}getSession(e){return this.sessions.get(e)}getCurrentSession(){return this.currentSessionId?this.sessions.get(this.currentSessionId):void 0}getAllSessions(){return Array.from(this.sessions.values())}onSessionUpdate(e){return this.sessionUpdateHandlers.add(e),()=>{this.sessionUpdateHandlers.delete(e)}}onError(e){return this.errorHandlers.add(e),()=>{this.errorHandlers.delete(e)}}createTransport(){switch(this.config.type){case"stdio":return new Ts(this.config.options);case"http":return new Ss(this.config.options);case"websocket":return new Is(this.config.options);default:throw new Error(`Unknown transport type: ${this.config.type}`)}}setupTransportListeners(){this.transport.onSessionUpdate(e=>{this.handleSessionUpdate(e)}),this.transport.onError(e=>{this.handleError(e)})}handleSessionUpdate(e){if(e.sessionId){const r=this.sessions.get(e.sessionId);r&&(e.status&&(r.status=e.status),e.message&&r.messages.push(e.message),e.error&&(r.error=e.error))}for(const r of this.sessionUpdateHandlers)try{r(e)}catch(n){console.error("Error in session update handler:",n)}}handleError(e){for(const r of this.errorHandlers)try{r(e)}catch(n){console.error("Error in error handler:",n)}}updateSessionStatus(e,r){const n=this.sessions.get(e);n&&(n.status=r,this.handleSessionUpdate({sessionId:e,status:r}))}generateSessionId(){return`session_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}generateMessageId(){return`msg_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}}const Rs=T({name:x(),description:x().optional(),parameters:A(x(),U()).optional()}),ks=T({name:x(),description:x(),parameters:A(x(),U()),required:I(x()).optional()}),Ms=T({name:x(),version:x().optional(),description:x().optional(),author:x().optional(),capabilities:I(Rs).optional(),tools:I(ks).optional(),supportedFormats:I(x()).optional()}),As=L(["initializing","ready","busy","error","terminated"]);T({status:As,info:Ms.optional(),pid:R().optional(),error:x().optional(),uptime:R().optional()});const Ve=L(["user","assistant","system","tool"]),Us=L(["text","image","file","tool_call","tool_result"]),W=T({type:Us}),Ds=W.extend({type:E("text"),text:x()}),Ps=W.extend({type:E("image"),url:x().url().optional(),data:x().optional(),mimeType:x().optional()}),Ls=W.extend({type:E("file"),name:x(),path:x().optional(),url:x().url().optional(),mimeType:x(),size:R().optional()}),Hs=W.extend({type:E("tool_call"),id:x(),name:x(),arguments:A(x(),U())}),zs=W.extend({type:E("tool_result"),callId:x(),result:U(),error:x().optional()}),qe=ce("type",[Ds,Ps,Ls,Hs,zs]),We=T({id:x(),role:Ve,content:I(qe),timestamp:G(),metadata:A(x(),U()).optional()});T({id:x(),role:Ve,contentDelta:qe,isComplete:B()});const Qe=L(["idle","connecting","connected","active","streaming","error","disconnected"]),_s=T({agentPath:x(),agentArgs:I(x()).optional(),environment:A(x(),x()).optional(),workingDirectory:x().optional(),timeout:R().optional()}),Os=T({agentName:x().optional(),agentVersion:x().optional(),capabilities:I(x()).optional(),startedAt:G(),lastActivityAt:G().optional()});T({id:x(),status:Qe,config:_s,metadata:Os.optional(),messages:I(We),error:x().optional()});const J=T({sessionId:x(),status:Qe.optional(),message:We.optional(),error:x().optional()}),Fs=J.extend({type:E("tool_call"),toolCall:Fe,messageId:x().optional()}),$s=J.extend({type:E("tool_call_update"),toolCallUpdate:gs,messageId:x().optional()}),Bs=J.extend({type:E("tool_output"),toolOutput:T({id:x(),content:I(zt()).optional(),rawOutput:A(x(),U()).optional()}),messageId:x().optional()}),Vs=J.extend({type:E("generic").optional()});_t([Fs,$s,Bs,Vs]);function m(...s){return Ot(Ft(s))}const qs=H("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"}}),Q=i.forwardRef(({className:s,variant:e,size:r,asChild:n=!1,...o},c)=>{const d=n?q:"button";return t.jsx(d,{className:m(qs({variant:e,size:r,className:s})),ref:c,...o})});Q.displayName="Button";const Ws=i.forwardRef(({className:s,...e},r)=>t.jsx("div",{ref:r,className:m("rounded-lg border bg-card text-card-foreground shadow-sm",s),...e}));Ws.displayName="Card";const Qs=i.forwardRef(({className:s,...e},r)=>t.jsx("div",{ref:r,className:m("flex flex-col space-y-1.5 p-6",s),...e}));Qs.displayName="CardHeader";const Ks=i.forwardRef(({className:s,...e},r)=>t.jsx("div",{ref:r,className:m("text-2xl font-semibold leading-none tracking-tight",s),...e}));Ks.displayName="CardTitle";const Gs=i.forwardRef(({className:s,...e},r)=>t.jsx("div",{ref:r,className:m("text-sm text-muted-foreground",s),...e}));Gs.displayName="CardDescription";const Ys=i.forwardRef(({className:s,...e},r)=>t.jsx("div",{ref:r,className:m("p-6 pt-0",s),...e}));Ys.displayName="CardContent";const Js=i.forwardRef(({className:s,...e},r)=>t.jsx("div",{ref:r,className:m("flex items-center p-6 pt-0",s),...e}));Js.displayName="CardFooter";const Ke=i.createContext(void 0),Ge=()=>{const s=i.useContext(Ke);if(!s)throw new Error("ChatHeader components must be used within ChatHeader.Root");return s},Xs=i.forwardRef(({defaultExpanded:s=!1,expanded:e,onExpandedChange:r,className:n,children:o,...c},d)=>{const[f,p]=i.useState(s),a=e??f,l=i.useCallback(b=>{p(b),r?.(b)},[r]),u=i.Children.toArray(o),h=u.find(b=>i.isValidElement(b)&&typeof b.type=="function"&&b.type.displayName==="ChatHeader.ExpandablePanel"),g=u.filter(b=>b!==h);return t.jsxs(Ke.Provider,{value:{isExpanded:a,setIsExpanded:l},children:[t.jsx("div",{ref:d,className:m("flex items-center justify-between px-6 py-4",n),...c,children:g}),h]})});Xs.displayName="ChatHeader.Root";const Zs=i.forwardRef(({className:s,children:e,...r},n)=>t.jsx("h1",{ref:n,className:m("m-0 text-xl font-semibold",s),...r,children:e}));Zs.displayName="ChatHeader.Title";const en=i.forwardRef(({className:s,children:e,...r},n)=>t.jsx("div",{ref:n,className:m("flex items-center gap-3",s),...r,children:e}));en.displayName="ChatHeader.Actions";const tn=s=>{switch(s){case"connected":return"bg-green-500";case"connecting":return"bg-yellow-500";case"error":return"bg-red-500";default:return"bg-gray-500"}},sn=s=>{switch(s){case"connected":return"Connected";case"connecting":return"Connecting...";case"error":return"Connection Error";default:return"No Server"}},nn=i.forwardRef(({status:s,statusText:e,className:r,...n},o)=>{const c=e??sn(s),d=tn(s);return t.jsxs("div",{ref:o,className:m("flex items-center gap-2",r),...n,children:[t.jsx("div",{className:m("h-2 w-2 rounded-full",d)}),t.jsx("span",{className:"text-sm text-muted-foreground",children:c})]})});nn.displayName="ChatHeader.StatusIndicator";const rn=i.forwardRef(({icon:s,className:e,children:r,onClick:n,...o},c)=>{const{isExpanded:d,setIsExpanded:f}=Ge(),p=a=>{f(!d),n?.(a)};return t.jsxs("button",{ref:c,type:"button",onClick:p,className:m("rounded p-1 transition-colors hover:bg-background lg:hidden",e),"aria-label":d?"Collapse header":"Expand header",...o,children:[s&&t.jsx("div",{className:m("transition-transform duration-200",d&&"rotate-180"),children:s}),r]})});rn.displayName="ChatHeader.Toggle";const on=i.forwardRef(({className:s,children:e,...r},n)=>{const{isExpanded:o}=Ge();return o?t.jsx("div",{ref:n,className:m("absolute top-full left-0 right-0 z-50 border-b border-border bg-card px-6 py-4 shadow-lg lg:hidden",s),...r,children:e}):null});on.displayName="ChatHeader.ExpandablePanel";const Ye=i.forwardRef(({commands:s=[],showCommandMenu:e,commandMenuQuery:r,selectedMenuIndex:n,setSelectedMenuIndex:o,setMenuItemCount:c,triggerCounter:d,onChange:f,className:p,...a},l)=>{const u=i.useCallback((g,b)=>{const j=g.toLowerCase(),N=b.toLowerCase();if(!b)return 1;if(j.includes(N))return 1-N.length/j.length;let y=0;for(let w=0;w<j.length&&y<N.length;w++)j[w]===N[y]&&y++;return y===N.length?.5-y/j.length:0},[]),h=i.useMemo(()=>s.map(g=>({...g,score:Math.max(u(g.label,r),g.description?u(g.description,r):0)})).filter(g=>g.score>0).sort((g,b)=>b.score-g.score),[s,r,u]);return i.useEffect(()=>{c(h.length)},[h.length,c]),i.useEffect(()=>{o(0)},[o]),i.useEffect(()=>{d>0&&h[n]&&(h[n].onSelect(),f(""))},[d,h,n,f]),!e||h.length===0?null:t.jsxs("div",{ref:l,className:m("absolute bottom-full left-0 z-50 mb-2 w-full max-w-md","rounded-md border border-border bg-card p-2 shadow-lg",p),...a,children:[t.jsx("div",{className:"text-xs font-semibold text-muted-foreground px-2 py-1",children:"Commands"}),t.jsx("div",{className:"max-h-64 overflow-y-auto",children:h.map((g,b)=>t.jsxs("button",{type:"button",onClick:()=>g.onSelect(),className:m("w-full rounded-sm px-2 py-2 text-left text-sm transition-colors","flex items-start gap-2","hover:bg-muted",b===n&&"bg-muted"),children:[g.icon&&t.jsx("span",{className:"shrink-0 mt-0.5",children:g.icon}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"font-medium",children:g.label}),g.description&&t.jsx("div",{className:"text-xs text-muted-foreground truncate",children:g.description})]})]},g.id))})]})});Ye.displayName="ChatInputCommandMenu";const Je=i.createContext(void 0),X=()=>{const s=i.useContext(Je);if(!s)throw new Error("ChatInput components must be used within ChatInput.Root");return s},Xe=i.forwardRef(({client:s,value:e,onChange:r,onSubmit:n,disabled:o=!1,isSubmitting:c,submitOnEnter:d=!0,className:f,children:p,...a},l)=>{const u=i.useRef(null),h=bs(s??null),g=S(P=>P.isStreaming),b=h?h.value:e||"",j=h?h.onChange:r||(()=>{}),N=h?h.onSubmit:n||(async()=>{}),y=h?h.isSubmitting||g:c||!1,[w,v]=i.useState(!1),[k,z]=i.useState(""),[_,C]=i.useState(0),[M,D]=i.useState(0),[Z,ee]=i.useState(0),Rt=i.useCallback(()=>{ee(P=>P+1)},[]),kt=async P=>{P.preventDefault(),b.trim()&&!y&&!o&&(await N(),setTimeout(()=>{u.current?.focus()},0))};return i.useEffect(()=>{const P=document.querySelector('textarea[name="chat-input"]');P&&u.current!==P&&(u.current=P)},[]),i.useEffect(()=>{!b&&u.current&&(u.current.style.height="auto",u.current.style.overflowY="hidden")},[b]),t.jsx(Je.Provider,{value:{value:b,onChange:j,onSubmit:N,disabled:o,isSubmitting:y,submitOnEnter:d,showCommandMenu:w,setShowCommandMenu:v,commandMenuQuery:k,setCommandMenuQuery:z,selectedMenuIndex:_,setSelectedMenuIndex:C,menuItemCount:M,setMenuItemCount:D,triggerMenuSelect:Rt,triggerCounter:Z},children:t.jsx("form",{ref:l,onSubmit:kt,className:m("relative w-full divide-y rounded-xl border bg-background shadow-md",f),...a,children:p})})});Xe.displayName="ChatInput.Root";const Ze=i.forwardRef(({asChild:s=!1,className:e,onKeyDown:r,children:n,...o},c)=>{const{value:d,onChange:f,onSubmit:p,disabled:a,isSubmitting:l,submitOnEnter:u,showCommandMenu:h,setShowCommandMenu:g,setCommandMenuQuery:b,setSelectedMenuIndex:j,menuItemCount:N,triggerMenuSelect:y}=X(),w=i.useRef(null),_={ref:i.useCallback(C=>{w.current=C,typeof c=="function"?c(C):c&&(c.current=C)},[c]),name:"chat-input",value:d,onChange:C=>{const M=C.target.value;if(f(M),M.startsWith("/")&&!M.includes(`
8
- `)){g(!0);const ee=M.slice(1);b(ee)}else g(!1),b("");const D=w.current;if(!D)return;D.style.height="auto";const Z=Math.min(D.scrollHeight,164);D.style.height=`${Z}px`,D.scrollHeight>164?D.style.overflowY="auto":D.style.overflowY="hidden"},onKeyDown:C=>{if(h&&N>0){if(C.key==="ArrowDown"){C.preventDefault(),j(M=>(M+1)%N);return}else if(C.key==="ArrowUp"){C.preventDefault(),j(M=>(M-1+N)%N);return}else if(C.key==="Enter"&&!C.shiftKey){C.preventDefault(),y();return}else if(C.key==="Escape"){C.preventDefault(),g(!1),b("");return}}u&&C.key==="Enter"&&!C.shiftKey&&(d.trim()&&!l&&!a?(C.preventDefault(),p()):(l||a)&&C.preventDefault()),r?.(C)},disabled:a,...o};return s&&i.isValidElement(n)?i.cloneElement(n,_):t.jsx("textarea",{..._,className:m("w-full resize-none rounded-none border-none p-4 shadow-none","outline-none ring-0 field-sizing-content max-h-[6lh]","bg-transparent dark:bg-transparent focus-visible:ring-0","text-sm placeholder:text-muted-foreground","disabled:cursor-not-allowed disabled:opacity-50",e)})});Ze.displayName="ChatInput.Field";const et=i.forwardRef(({asChild:s=!1,className:e,disabled:r,children:n,...o},c)=>{const{value:d,disabled:f,isSubmitting:p}=X(),a=r||f||p||!d.trim(),l=s?q:Q;return t.jsx(l,{ref:c,type:"submit",disabled:a,variant:s?void 0:"default",size:"icon",className:m(!s&&"gap-1.5 rounded-full",e),...o,children:n})});et.displayName="ChatInput.Submit";const tt=i.forwardRef(({className:s,children:e,...r},n)=>t.jsx("div",{ref:n,className:m("flex items-center justify-between p-2",s),...r,children:e}));tt.displayName="ChatInput.Toolbar";const st=i.forwardRef(({asChild:s=!1,className:e,children:r,onClick:n,...o},c)=>{const{value:d,onChange:f,setShowCommandMenu:p,setCommandMenuQuery:a}=X(),l=h=>{d.startsWith("/")||(f("/"),p(!0),a("")),n?.(h)},u=s?q:Q;return t.jsx(u,{ref:c,type:"button",variant:"ghost",size:"icon",className:m("rounded-full",e),onClick:l,...o,children:r||t.jsx(es,{className:"size-4"})})});st.displayName="ChatInput.Actions";const nt=i.forwardRef(({asChild:s=!1,className:e,children:r,...n},o)=>{const c=s?q:Q;return t.jsx(c,{ref:o,type:"button",variant:"ghost",size:"icon",className:m("rounded-full",e),...n,children:r||t.jsx(ts,{className:"size-4"})})});nt.displayName="ChatInput.Attachment";const rt=i.forwardRef(({asChild:s=!1,className:e,children:r,...n},o)=>{const c=s?q:Q;return t.jsx(c,{ref:o,type:"button",variant:"ghost",size:"icon",className:m("rounded-full",e),...n,children:r||t.jsx(ss,{className:"size-4"})})});rt.displayName="ChatInput.VoiceInput";const ot=i.forwardRef(({commands:s=[],className:e,onChange:r,...n},o)=>{const{showCommandMenu:c,commandMenuQuery:d,selectedMenuIndex:f,setSelectedMenuIndex:p,setMenuItemCount:a,triggerCounter:l,onChange:u}=X();return t.jsx(Ye,{ref:o,commands:s,showCommandMenu:c,commandMenuQuery:d,selectedMenuIndex:f,setSelectedMenuIndex:p,setMenuItemCount:a,triggerCounter:l,onChange:u,className:e,...n})});ot.displayName="ChatInput.CommandMenu";const an=({className:s,...e})=>t.jsx(Mt,{className:m("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",s),...e}),at=({className:s,...e})=>t.jsx(At,{className:m(s),...e}),ln=({withHandle:s,className:e,...r})=>t.jsx(Ut,{className:m("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",e),...r,children:s&&t.jsx("div",{className:"z-10 flex h-4 w-3 items-center justify-center rounded-sm border bg-border",children:t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"h-2.5 w-2.5",children:[t.jsx("title",{children:"Resize Handle"}),t.jsx("circle",{cx:"9",cy:"12",r:"1"}),t.jsx("circle",{cx:"9",cy:"5",r:"1"}),t.jsx("circle",{cx:"9",cy:"19",r:"1"}),t.jsx("circle",{cx:"15",cy:"12",r:"1"}),t.jsx("circle",{cx:"15",cy:"5",r:"1"}),t.jsx("circle",{cx:"15",cy:"19",r:"1"})]})})}),cn=({...s})=>t.jsx($t,{position:"top-center",className:"toaster group",style:{"--top-offset":"16px","--width:":"calc(100% - 2 * var(--top-offset))",position:"absolute",zIndex:5,top:"var(--top-offset)",left:"50%",transform:"translateX(-50%)",width:"calc(100% - 2 * var(--top-offset))",maxWidth:"480px"},offset:0,toastOptions:{classNames:{toast:"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground"}},...s}),it=i.createContext(void 0),lt=()=>{const s=i.useContext(it);if(!s)throw new Error("ChatLayout components must be used within ChatLayout.Root");return s},ct=i.forwardRef(({defaultSidebarOpen:s=!1,defaultPanelSize:e="hidden",defaultActiveTab:r="todo",className:n,children:o,...c},d)=>{const[f,p]=i.useState(s),[a,l]=i.useState(e),[u,h]=i.useState(r);return t.jsx(it.Provider,{value:{sidebarOpen:f,setSidebarOpen:p,panelSize:a,setPanelSize:l,activeTab:u,setActiveTab:h},children:t.jsx("div",{ref:d,className:m("flex h-screen flex-row bg-background text-foreground",n),...c,children:t.jsx(an,{direction:"horizontal",className:"flex-1",children:o})})})});ct.displayName="ChatLayout.Root";const dn=i.forwardRef(({className:s,children:e,...r},n)=>t.jsx("div",{ref:n,className:m("relative z-10 border-b border-border bg-card shrink-0",s),...r,children:e}));dn.displayName="ChatLayout.Header";const dt=i.forwardRef(({className:s,children:e,...r},n)=>t.jsx(at,{defaultSize:75,minSize:50,children:t.jsx("div",{ref:n,className:m("flex flex-1 flex-col overflow-hidden h-full",s),...r,children:e})}));dt.displayName="ChatLayout.Main";const ut=i.forwardRef(({showToaster:s=!0,className:e,children:r,...n},o)=>t.jsxs("div",{ref:o,className:m("relative flex flex-1 flex-col overflow-hidden",e),...n,children:[r,s&&t.jsx(cn,{})]}));ut.displayName="ChatLayout.Body";const ft=i.forwardRef(({className:s,children:e,onScrollChange:r,showScrollToBottom:n=!0,...o},c)=>{const[d,f]=i.useState(!1),p=i.useRef(null);i.useImperativeHandle(c,()=>p.current);const a=i.useCallback(()=>{const h=p.current;if(!h)return;const{scrollTop:g,scrollHeight:b,clientHeight:j}=h,y=b-g-j<100;f(!y&&n),r?.(y)},[r,n]),l=i.useCallback(()=>{a()},[a]),u=i.useCallback(()=>{const h=p.current;h&&h.scrollTo({top:h.scrollHeight,behavior:"smooth"})},[]);return i.useEffect(()=>{a()},[a]),t.jsxs("div",{className:"relative flex-1 overflow-hidden",children:[t.jsx("div",{ref:p,className:m("h-full overflow-y-auto",s),onScroll:l,...o,children:e}),d&&t.jsx("button",{type:"button",onClick:u,className:m("absolute bottom-4 left-1/2 -translate-x-1/2 z-10","flex items-center justify-center p-2 rounded-full","bg-card border border-border shadow-lg","text-foreground","hover:bg-accent hover:text-accent-foreground","transition-all duration-200 ease-in-out","animate-in fade-in slide-in-from-bottom-2"),"aria-label":"Scroll to bottom",children:t.jsx(ns,{className:"h-4 w-4"})})]})});ft.displayName="ChatLayout.Messages";const pt=i.forwardRef(({className:s,children:e,...r},n)=>t.jsx("div",{ref:n,className:m("bg-linear-to-t from-background to-transparent px-4 pb-4",s),...r,children:e}));pt.displayName="ChatLayout.Footer";const un=i.forwardRef(({className:s,children:e,...r},n)=>{const{sidebarOpen:o}=lt();return o?t.jsx("div",{ref:n,className:m("border-r border-border bg-card w-64 overflow-y-auto",s),...r,children:e}):null});un.displayName="ChatLayout.Sidebar";const mt=i.forwardRef(({breakpoint:s="lg",className:e,children:r,...n},o)=>{const{panelSize:c}=lt();return c==="hidden"?null:t.jsxs(t.Fragment,{children:[t.jsx(ln,{withHandle:!0}),t.jsx(at,{defaultSize:25,minSize:15,maxSize:50,children:t.jsx("div",{ref:o,className:m("hidden h-full border-l border-border bg-card overflow-y-auto transition-all duration-300",s==="md"&&"md:block",s==="lg"&&"lg:block",s==="xl"&&"xl:block",s==="2xl"&&"2xl:block",e),...n,children:r})})]})});mt.displayName="ChatLayout.Aside";const ht=i.forwardRef(({todos:s,className:e,...r},n)=>t.jsx("div",{ref:n,className:m("space-y-2",e),...r,children:s.length===0?t.jsx("div",{className:"flex items-center justify-center h-full min-h-[200px]",children:t.jsx("p",{className:"text-sm text-muted-foreground",children:"No todos yet"})}):s.map(o=>t.jsx("div",{className:"text-sm",children:o.text},o.id))}));ht.displayName="TodoTabContent";const xt=i.forwardRef(({files:s=[],className:e,...r},n)=>t.jsx("div",{ref:n,className:m("space-y-2",e),...r,children:s.length===0?t.jsx("div",{className:"flex items-center justify-center h-full min-h-[200px]",children:t.jsx("p",{className:"text-sm text-muted-foreground",children:"No files attached"})}):s.map(o=>t.jsx("div",{className:"text-sm",children:o},o))}));xt.displayName="FilesTabContent";const fn=i.forwardRef(({data:s,className:e,...r},n)=>t.jsxs("div",{ref:n,className:m("space-y-4",e),...r,children:[t.jsx("h3",{className:"font-semibold text-lg",children:"Database"}),t.jsxs("div",{className:"text-sm text-muted-foreground",children:[t.jsx("p",{children:"Database viewer - panel automatically expanded to large size"}),t.jsxs("div",{className:"mt-4 p-4 border border-border rounded",children:[t.jsx("p",{children:"Your large data table would go here"}),s&&typeof s=="object"?t.jsx("pre",{className:"mt-2 text-xs overflow-auto",children:JSON.stringify(s,null,2)}):null]})]})]}));fn.displayName="DatabaseTabContent";const gt=qt,Y=i.forwardRef(({className:s,...e},r)=>t.jsx(de,{ref:r,className:m("inline-flex h-10 items-center rounded-md bg-muted p-1 text-muted-foreground gap-1",s),...e}));Y.displayName=de.displayName;const V=i.forwardRef(({className:s,...e},r)=>t.jsx(ue,{ref:r,className:m("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",s),...e}));V.displayName=ue.displayName;const F=i.forwardRef(({className:s,...e},r)=>t.jsx(fe,{ref:r,className:m("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",s),...e}));F.displayName=fe.displayName;const bt=i.forwardRef(({todo:s,className:e,...r},n)=>t.jsx("div",{ref:n,className:m("flex items-center gap-3 px-3 py-2 rounded-lg",e),...r,children:t.jsx("span",{className:m("flex-1 text-[var(--font-size)] font-[var(--font-family)]",s.status==="completed"&&"line-through opacity-60",s.status==="in_progress"&&"shimmer-animation"),children:s.text})}));bt.displayName="TodoListItem";const yt=i.forwardRef(({client:s,todos:e,className:r,...n},o)=>{const c=e||[];return t.jsx("div",{ref:o,className:m("space-y-2 max-h-64 overflow-y-auto",r),...n,children:c.length===0?t.jsx("p",{className:"text-sm text-foreground opacity-60 italic",children:"No tasks yet."}):c.map(d=>t.jsx(bt,{todo:d},d.id))})});yt.displayName="TodoList";const pn=i.forwardRef(({client:s,todos:e,className:r,...n},o)=>{const c=e||[],[d,f]=i.useState("todo"),p=i.useRef(null),a=i.useRef(null);i.useEffect(()=>{const h=setTimeout(()=>{const g=p.current;if(d&&g){const b=a.current;if(b){const j=g.getBoundingClientRect(),N=b.getBoundingClientRect(),y=N.left-j.left,w=N.width,v=y/j.width*100,k=100-(y+w)/j.width*100;g.style.clipPath=`inset(0 ${k.toFixed(2)}% 0 ${v.toFixed(2)}% round 999px)`}}},0);return()=>clearTimeout(h)},[d]);const l=[{id:"todo",label:"To-Do List"},{id:"files",label:"Files"},{id:"database",label:"Database"}];return t.jsx("div",{ref:o,className:m("select-none",r),...n,children:t.jsxs(gt,{value:d,onValueChange:f,className:"w-full",children:[t.jsxs("div",{className:"relative mb-4 border-border",children:[t.jsx(Y,{className:"bg-transparent p-0 h-auto rounded-none w-full border-none",children:l.map(u=>t.jsx(V,{value:u.id,className:"px-3 py-1 text-sm font-[var(--font-family)] font-medium rounded-none text-foreground opacity-60 data-[state=active]:opacity-100 data-[state=active]:bg-transparent data-[state=active]:shadow-none",children:u.label},u.id))}),t.jsx("div",{ref:p,className:"absolute top-0 left-0 w-full overflow-hidden z-10 pointer-events-none",style:{clipPath:"inset(0 100% 0 0% round 999px)",transition:"clip-path 0.25s ease-out"},children:t.jsx(Y,{className:"bg-secondary p-0 h-auto rounded-none w-full border-none",children:l.map(u=>t.jsx(V,{value:u.id,ref:d===u.id?a:null,className:"px-3 py-1 text-sm font-[var(--font-family)] font-medium rounded-none text-primary bg-transparent data-[state=active]:shadow-none shadow-none",tabIndex:-1,children:u.label},u.id))})})]}),t.jsx(F,{value:"todo",children:t.jsx(yt,{todos:c})}),t.jsx(F,{value:"files",children:t.jsx("div",{className:"text-sm text-foreground opacity-60 italic",children:"Files tab coming soon..."})}),t.jsx(F,{value:"database",children:t.jsx("div",{className:"text-sm text-foreground opacity-60 italic",children:"Database tab coming soon..."})})]})})});pn.displayName="ChatSecondaryPanel";const mn=i.forwardRef(({className:s,children:e,...r},n)=>t.jsx("div",{ref:n,className:m("flex h-full flex-col",s),...r,children:e}));mn.displayName="ChatSidebar.Root";const hn=i.forwardRef(({className:s,children:e,...r},n)=>t.jsx("div",{ref:n,className:m("border-b border-border px-4 py-3",s),...r,children:e}));hn.displayName="ChatSidebar.Header";const xn=i.forwardRef(({className:s,children:e,...r},n)=>t.jsx("div",{ref:n,className:m("flex-1 overflow-y-auto p-4",s),...r,children:e}));xn.displayName="ChatSidebar.Content";const gn=i.forwardRef(({className:s,children:e,...r},n)=>t.jsx("div",{ref:n,className:m("border-t border-border px-4 py-3",s),...r,children:e}));gn.displayName="ChatSidebar.Footer";const bn=i.forwardRef(({children:s,className:e,...r},n)=>{const[o,c]=i.useState(s),[d,f]=i.useState(!1),p=i.useRef(s),a=i.useRef(!0);return i.useEffect(()=>{if(a.current){a.current=!1,p.current=s;return}if(p.current===s)return;f(!0);const l=setTimeout(()=>{c(s),p.current=s,requestAnimationFrame(()=>{f(!1)})},150);return()=>{clearTimeout(l)}},[s]),t.jsx("span",{ref:n,className:m("text-sm text-foreground opacity-60 transition-opacity duration-300",d?"opacity-0":"opacity-60",e),...r,children:o})});bn.displayName="ChatStatus";const yn=i.forwardRef(({autoScroll:s=!0,isStreaming:e=!1,scrollBehavior:r="smooth",scrollThreshold:n=100,showScrollButton:o=!0,scrollButton:c,className:d,children:f,...p},a)=>{const l=i.useRef(null),[u,h]=i.useState(!0),[g,b]=i.useState(!1),j=i.useRef(0);i.useImperativeHandle(a,()=>{if(!l.current)throw new Error("Container ref not initialized");return l.current});const N=i.useCallback(()=>{const w=l.current;if(!w)return;const{scrollTop:v,scrollHeight:k,clientHeight:z}=w,C=k-v-z<n;h(C),b(!C&&o),j.current=v},[n,o]),y=i.useCallback((w=r)=>{const v=l.current;v&&v.scrollTo({top:v.scrollHeight,behavior:w})},[r]);return i.useEffect(()=>{!s||!l.current||(e&&u?y("auto"):!e&&u&&y())},[s,e,u,y]),i.useEffect(()=>{const w=l.current;if(!w)return;const v=()=>{N()};return w.addEventListener("scroll",v,{passive:!0}),N(),()=>{w.removeEventListener("scroll",v)}},[N]),i.useEffect(()=>{const w=l.current;if(!w)return;const v=new ResizeObserver(()=>{u&&s&&y("auto")});return v.observe(w),()=>{v.disconnect()}},[u,s,y]),t.jsxs("div",{className:"relative flex-1",children:[t.jsx("div",{ref:l,className:m("h-full overflow-y-auto overflow-x-hidden","scrollbar-thin scrollbar-thumb-[border] scrollbar-track-transparent",d),...p,children:t.jsx("div",{className:"flex flex-col gap-4 px-4 py-4",children:f})}),g&&t.jsx("div",{className:"absolute bottom-4 left-1/2 -translate-x-1/2 z-10",children:c||t.jsxs("button",{type:"button",onClick:()=>y(),className:"px-4 py-2 rounded-full bg-card border border-border shadow-lg hover:shadow-xl hover:bg-card/90 transition-all text-sm font-medium text-foreground flex items-center gap-2","aria-label":"Scroll to bottom",children:[t.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",role:"img","aria-label":"Down arrow",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 14l-7 7m0 0l-7-7m7 7V3"})}),"Scroll to bottom"]})})]})});yn.displayName="Conversation";const wn=Wt,wt=i.forwardRef(({className:s,...e},r)=>t.jsx(pe,{ref:r,className:m("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",s),...e}));wt.displayName=pe.displayName;const vn=i.forwardRef(({className:s,children:e,...r},n)=>t.jsxs(wn,{children:[t.jsx(wt,{}),t.jsxs(me,{ref:n,className:m("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",s),...r,children:[e,t.jsxs(Qt,{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:[t.jsx(rs,{className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));vn.displayName=me.displayName;const Nn=i.forwardRef(({className:s,...e},r)=>t.jsx(he,{ref:r,className:m("text-lg font-semibold leading-none tracking-tight",s),...e}));Nn.displayName=he.displayName;const jn=i.forwardRef(({className:s,...e},r)=>t.jsx(xe,{ref:r,className:m("text-sm text-muted-foreground",s),...e}));jn.displayName=xe.displayName;const Cn=i.forwardRef(({className:s,inset:e,children:r,...n},o)=>t.jsxs(ge,{ref:o,className:m("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none","focus:bg-muted data-[state=open]:bg-muted",e&&"pl-8",s),...n,children:[r,t.jsx(os,{className:"ml-auto h-4 w-4"})]}));Cn.displayName=ge.displayName;const Sn=i.forwardRef(({className:s,...e},r)=>t.jsx(be,{ref:r,className:m("z-50 min-w-[8rem] overflow-hidden rounded-md border border-border bg-card p-1 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",s),...e}));Sn.displayName=be.displayName;const Tn=i.forwardRef(({className:s,sideOffset:e=4,...r},n)=>t.jsx(Kt,{children:t.jsx(ye,{ref:n,sideOffset:e,className:m("z-50 min-w-[8rem] overflow-hidden rounded-md border border-border bg-card p-1 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",s),...r})}));Tn.displayName=ye.displayName;const In=i.forwardRef(({className:s,inset:e,...r},n)=>t.jsx(we,{ref:n,className:m("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors","focus:bg-muted focus:text-foreground","data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e&&"pl-8",s),...r}));In.displayName=we.displayName;const En=i.forwardRef(({className:s,children:e,...r},n)=>t.jsxs(ve,{ref:n,className:m("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-muted focus:text-foreground","data-[disabled]:pointer-events-none data-[disabled]:opacity-50",s),...r,children:[t.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:t.jsx(Ne,{children:t.jsx(De,{className:"h-4 w-4"})})}),e]}));En.displayName=ve.displayName;const Rn=i.forwardRef(({className:s,children:e,...r},n)=>t.jsxs(je,{ref:n,className:m("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-muted focus:text-foreground","data-[disabled]:pointer-events-none data-[disabled]:opacity-50",s),...r,children:[t.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:t.jsx(Ne,{children:t.jsx(Pe,{className:"h-2 w-2 fill-current"})})}),e]}));Rn.displayName=je.displayName;const kn=i.forwardRef(({className:s,inset:e,...r},n)=>t.jsx(Ce,{ref:n,className:m("px-2 py-1.5 text-sm font-semibold",e&&"pl-8",s),...r}));kn.displayName=Ce.displayName;const Mn=i.forwardRef(({className:s,...e},r)=>t.jsx(Se,{ref:r,className:m("-mx-1 my-1 h-px bg-border",s),...e}));Mn.displayName=Se.displayName;const An=H("flex h-10 w-full rounded-md border bg-background px-3 py-2 text-sm 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-offset-2 disabled:cursor-not-allowed disabled:opacity-50",{variants:{variant:{default:"border-input focus-visible:ring-ring",error:"border-destructive focus-visible:ring-destructive",success:"border-green-500 focus-visible:ring-green-500"}},defaultVariants:{variant:"default"}}),Un=i.forwardRef(({className:s,type:e,variant:r,...n},o)=>t.jsx("input",{type:e,className:m(An({variant:r,className:s})),ref:o,...n}));Un.displayName="Input";const Dn=i.forwardRef(({className:s,...e},r)=>t.jsx(Te,{ref:r,className:m("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",s),...e}));Dn.displayName=Te.displayName;const Pn=H("flex animate-fadeIn",{variants:{role:{user:"max-w-[80%] self-end ml-auto mr-2",assistant:"self-start mr-auto",system:"self-start mr-auto max-w-full"},layout:{default:"",full:"max-w-full",compact:"max-w-[90%]"}},defaultVariants:{role:"assistant",layout:"default"}}),vt=i.forwardRef(({message:s,role:e,layout:r,className:n,children:o,messageId:c,autoScroll:d,isLastMessage:f=!1,...p},a)=>{const l=s?s.role:e||"assistant",u=s?s.id:c,h=i.useRef(null),[g,b]=i.useState(void 0);return i.useImperativeHandle(a,()=>h.current),i.useEffect(()=>{if(!f||l!=="assistant"){b(void 0);return}const j=()=>{const y=h.current;if(!y)return;let w=y.parentElement;for(;w&&!w.classList.contains("overflow-y-auto");)w=w.parentElement;if(!w)return;const v=y.previousElementSibling;if(!v||v.getAttribute("aria-label")!=="user message"){b(void 0);return}const k=w.clientHeight,z=v.offsetHeight,C=Math.max(0,k-z-32);b(C)};j();const N=new ResizeObserver(j);if(h.current){N.observe(h.current);let y=h.current.parentElement;for(;y&&!y.classList.contains("overflow-y-auto");)y=y.parentElement;y&&N.observe(y)}return()=>N.disconnect()},[f,l]),i.useEffect(()=>{if((d!==void 0?d:l==="user")&&h.current){const N=setTimeout(()=>{h.current?.scrollIntoView({behavior:"smooth",block:"start",inline:"nearest"})},50);return()=>clearTimeout(N)}},[l,d]),t.jsx("article",{ref:h,"aria-label":`${l} message`,"data-message-id":u,className:m(Pn({role:l,layout:r}),n),style:{minHeight:g!==void 0?`${g}px`:void 0},...p,children:o})});vt.displayName="Message";const ae=H("mb-3 rounded-lg bg-card border border-border transition-all",{variants:{variant:{default:"opacity-70",subtle:"opacity-50",prominent:"opacity-90 shadow-sm"}},defaultVariants:{variant:"default"}}),Ln=H("w-4 h-4 text-foreground opacity-60 transition-transform duration-200",{variants:{expanded:{true:"rotate-180",false:""}},defaultVariants:{expanded:!1}}),Nt=i.forwardRef(({content:s,isStreaming:e=!1,mode:r="collapsible",defaultExpanded:n=!1,autoExpand:o=!1,autoCollapse:c=!0,autoCollapseDelay:d=2e3,label:f="Thinking",variant:p,className:a},l)=>{const[u,h]=i.useState(r==="inline"?!0:n),[g,b]=i.useState(!1);return i.useEffect(()=>{if(c&&!e&&s&&r==="collapsible"){const j=setTimeout(()=>{b(!0),h(!1)},d);return()=>clearTimeout(j)}},[e,s,c,d,r]),i.useEffect(()=>{o&&e&&r==="collapsible"&&!g&&h(!0)},[o,e,r,g]),!s&&!e?null:r==="inline"?t.jsxs("div",{ref:l,className:m(ae({variant:p}),"p-3",a),children:[t.jsxs("div",{className:"flex items-start gap-2 mb-2",children:[t.jsx("span",{className:"text-xs font-medium text-foreground opacity-60 uppercase tracking-wide",children:f}),e&&t.jsx("span",{className:"inline-block w-2 h-2 bg-primary rounded-full animate-pulse"})]}),t.jsxs("div",{className:"text-sm italic text-foreground opacity-80 leading-relaxed whitespace-pre-wrap",children:[s,e&&s&&t.jsx("span",{className:"inline-block animate-typing text-primary",children:"..."})]})]}):t.jsxs("div",{ref:l,className:m("mb-3",a),children:[t.jsxs("button",{type:"button",onClick:()=>{h(!u),b(!1)},className:"w-full flex items-center justify-between p-2.5 rounded-lg bg-card border border-border hover:bg-card/80 hover:shadow-sm transition-all text-left","aria-expanded":u,"aria-label":`${u?"Collapse":"Expand"} reasoning`,children:[t.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[t.jsx("span",{className:"text-xs font-medium text-foreground opacity-60 uppercase tracking-wide shrink-0",children:f}),e&&t.jsx("span",{className:"inline-block w-2 h-2 bg-primary rounded-full animate-pulse shrink-0"}),!u&&s&&t.jsxs("span",{className:"text-xs text-foreground opacity-50 truncate",children:[s.substring(0,60),s.length>60&&"..."]})]}),t.jsx(te,{className:Ln({expanded:u}),"aria-hidden":"true"})]}),u&&t.jsx("div",{className:m(ae({variant:p}),"mt-2 p-3 animate-fadeIn"),children:t.jsxs("div",{className:"text-sm italic text-foreground opacity-80 leading-relaxed whitespace-pre-wrap",children:[s,e&&s&&t.jsx("span",{className:"inline-block animate-typing text-primary",children:"..."})]})})]})});Nt.displayName="Reasoning";const jt=i.forwardRef(({content:s,isStreaming:e=!1,showEmpty:r=!0,emptyMessage:n="",className:o,...c},d)=>{if(!s&&e&&r)return t.jsx("div",{ref:d,className:m("opacity-70 italic text-sm",o),...c,children:n});if(!s)return null;const f={table:({node:p,...a})=>t.jsx("div",{className:"overflow-x-auto my-4",children:t.jsx("table",{className:"min-w-full border-collapse border border-border rounded-md",...a})}),thead:({node:p,...a})=>t.jsx("thead",{className:"bg-card border-b border-border",...a}),tbody:({node:p,...a})=>t.jsx("tbody",{...a}),tr:({node:p,...a})=>t.jsx("tr",{className:"border-b border-border hover:bg-card transition-colors",...a}),th:({node:p,...a})=>t.jsx("th",{className:"px-4 py-2 text-left font-semibold text-foreground border-r border-border last:border-r-0",...a}),td:({node:p,...a})=>t.jsx("td",{className:"px-4 py-2 text-foreground border-r border-border last:border-r-0",...a}),input:({node:p,checked:a,...l})=>l.type==="checkbox"?t.jsx("input",{type:"checkbox",checked:a||!1,disabled:!0,readOnly:!0,className:"mr-2 w-4 h-4 accent-[primary] cursor-not-allowed",...l}):t.jsx("input",{...l}),code:({node:p,...a})=>a.className?.includes("language-")?t.jsx("code",{className:"block p-4 bg-card border border-border rounded-md overflow-x-auto text-sm font-mono text-foreground shadow-sm",...a}):t.jsx("code",{className:"px-1.5 py-0.5 bg-card border border-border rounded text-sm font-mono text-foreground",...a}),pre:({node:p,...a})=>t.jsx("pre",{className:"my-4 rounded-lg",...a}),h1:({node:p,...a})=>t.jsx("h1",{className:"text-2xl font-bold mt-6 mb-4 text-foreground border-b border-border pb-2",...a}),h2:({node:p,...a})=>t.jsx("h2",{className:"text-xl font-semibold mt-5 mb-3 text-foreground border-b border-border/50 pb-1.5",...a}),h3:({node:p,...a})=>t.jsx("h3",{className:"text-lg font-semibold mt-4 mb-2 text-foreground",...a}),h4:({node:p,...a})=>t.jsx("h4",{className:"text-base font-semibold mt-3 mb-2 text-foreground",...a}),ul:({node:p,...a})=>{const l=p?.children?.some(u=>typeof u=="object"&&u!==null&&"type"in u&&u.type==="element"&&"tagName"in u&&u.tagName==="li"&&"children"in u&&Array.isArray(u.children)&&u.children.some(h=>typeof h=="object"&&h!==null&&"type"in h&&h.type==="element"&&"tagName"in h&&h.tagName==="input"&&"properties"in h&&typeof h.properties=="object"&&h.properties!==null&&"type"in h.properties&&h.properties.type==="checkbox"));return t.jsx("ul",{className:m("my-2 space-y-1 text-foreground",l?"list-none space-y-2":"list-disc list-inside"),...a})},ol:({node:p,...a})=>t.jsx("ol",{className:"list-decimal list-inside my-2 space-y-1 text-foreground",...a}),li:({node:p,...a})=>{const l=p?.children?.some(u=>typeof u=="object"&&u!==null&&"type"in u&&u.type==="element"&&"tagName"in u&&u.tagName==="input"&&"properties"in u&&typeof u.properties=="object"&&u.properties!==null&&"type"in u.properties&&u.properties.type==="checkbox");return t.jsx("li",{className:m("flex items-start",l?"gap-2":"ml-2"),...a})},a:({node:p,...a})=>t.jsx("a",{className:"text-primary hover:underline decoration-2 underline-offset-2 transition-all",target:"_blank",rel:"noopener noreferrer",...a}),p:({node:p,...a})=>t.jsx("p",{className:"my-2 text-foreground leading-relaxed",...a}),blockquote:({node:p,...a})=>t.jsx("blockquote",{className:"border-l-4 border-[primary] pl-4 italic my-4 text-foreground bg-card py-2 rounded-r-md shadow-sm",...a}),hr:({node:p,...a})=>t.jsx("hr",{className:"my-6 border-t border-border opacity-50",...a})};return t.jsxs("div",{ref:d,className:m("markdown-content prose prose-sm max-w-none dark:prose-invert",o),...c,children:[t.jsx(Dt,{remarkPlugins:[hs],components:f,children:s}),e&&s&&t.jsx("span",{className:"inline-block ml-1 animate-typing text-primary",children:"..."})]})});jt.displayName="Response";const Hn={pending:"bg-transparent text-muted-foreground",in_progress:"bg-transparent text-muted-foreground",completed:"bg-transparent text-muted-foreground",failed:"bg-transparent text-muted-foreground"};function zn({toolCall:s}){const[e,r]=i.useState(!1);return t.jsxs("div",{className:"flex flex-col",children:[t.jsxs("button",{type:"button",className:"flex items-center gap-1.5 cursor-pointer bg-transparent border-none p-0 text-left group w-fit",onClick:()=>r(!e),"aria-expanded":e,children:[t.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2 py-1 text-xs font-medium rounded ${Hn[s.status]}`,children:[t.jsx(as,{className:"h-3 w-3"}),t.jsx("span",{children:s.title}),s.status==="completed"&&t.jsx("span",{children:"✓"})]}),t.jsx("span",{className:"text-gray-400 text-xs opacity-0 group-hover:opacity-100 transition-opacity",children:e?"▲":"▼"})]}),e&&t.jsxs("div",{className:"mt-2 space-y-3 text-sm border border-gray-200 rounded-md p-3 bg-white shadow-sm max-w-full",children:[s.locations&&s.locations.length>0&&t.jsxs("div",{children:[t.jsx("div",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wide mb-1.5",children:"Files"}),t.jsx("ul",{className:"space-y-1",children:s.locations.map(n=>t.jsxs("li",{className:"font-mono text-xs text-gray-700 bg-gray-50 px-2 py-1 rounded",children:[n.path,n.line!==null&&n.line!==void 0&&`:${n.line}`]},`${n.path}:${n.line??""}`))})]}),s.rawInput&&Object.keys(s.rawInput).length>0&&t.jsxs("div",{children:[t.jsx("div",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wide mb-1.5",children:"Input"}),t.jsx("div",{className:"bg-gray-50 p-2 rounded border border-gray-200",children:t.jsx(se,{src:s.rawInput,name:!1,collapsed:1,displayDataTypes:!1,displayObjectSize:!1,enableClipboard:!0,style:{fontSize:"11px",backgroundColor:"transparent"},theme:"rjv-default"})})]}),s.content&&s.content.length>0&&t.jsxs("div",{children:[t.jsx("div",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wide mb-1.5",children:"Output"}),t.jsx("div",{className:"space-y-2",children:s.content.map((n,o)=>{const c=()=>n.type==="diff"&&"path"in n?`diff-${n.path}-${o}`:n.type==="terminal"&&"terminalId"in n?`terminal-${n.terminalId}`:n.type==="text"&&"text"in n?`text-${n.text.substring(0,20)}-${o}`:n.type==="content"&&"content"in n?`content-${n.content.text?.substring(0,20)}-${o}`:`block-${o}`,d=(f,p)=>{try{const a=JSON.parse(f);if(typeof a=="object"&&a!==null)return t.jsx("div",{className:"bg-gray-50 p-2 rounded border border-gray-200",children:t.jsx(se,{src:a,name:!1,collapsed:1,displayDataTypes:!1,displayObjectSize:!1,enableClipboard:!0,style:{fontSize:"11px",backgroundColor:"transparent"},theme:"rjv-default"})},p)}catch{}return t.jsx("pre",{className:"bg-gray-50 p-2.5 rounded border border-gray-200 text-xs overflow-x-auto font-mono text-gray-800",children:f},p)};if(n.type==="content"&&"content"in n){const f=n.content;if(f.type==="text"&&f.text)return d(f.text,c())}return n.type==="text"&&"text"in n?d(n.text,c()):n.type==="diff"&&"path"in n&&"oldText"in n&&"newText"in n?t.jsxs("div",{className:"border rounded",children:[t.jsxs("div",{className:"bg-gray-100 px-2 py-1 text-xs font-mono",children:[n.path,"line"in n&&n.line!==null&&n.line!==void 0&&`:${n.line}`]}),t.jsxs("div",{className:"p-2 font-mono text-xs",children:[t.jsxs("div",{className:"text-red-600",children:["- ",n.oldText]}),t.jsxs("div",{className:"text-green-600",children:["+ ",n.newText]})]})]},c()):n.type==="terminal"&&"terminalId"in n?t.jsxs("div",{className:"bg-black text-green-400 p-2 rounded text-xs font-mono",children:["Terminal: ",n.terminalId]},c()):null})})]}),s.error&&t.jsxs("div",{className:"bg-red-50 border border-red-200 rounded p-2.5 text-red-700",children:[t.jsx("div",{className:"text-xs font-semibold text-red-600 uppercase tracking-wide mb-1.5",children:"Error"}),t.jsx("div",{className:"text-xs",children:s.error})]}),s.tokenUsage&&t.jsxs("div",{className:"bg-gray-50 border border-gray-200 rounded p-2.5",children:[t.jsx("div",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wide mb-2",children:"Token Usage"}),t.jsxs("div",{className:"grid grid-cols-3 gap-3 text-xs text-gray-700",children:[s.tokenUsage.inputTokens!==void 0&&t.jsxs("div",{children:[t.jsx("div",{className:"text-gray-500 text-[10px] uppercase tracking-wide mb-0.5",children:"Input"}),t.jsx("div",{className:"font-medium",children:s.tokenUsage.inputTokens.toLocaleString()})]}),s.tokenUsage.outputTokens!==void 0&&t.jsxs("div",{children:[t.jsx("div",{className:"text-gray-500 text-[10px] uppercase tracking-wide mb-0.5",children:"Output"}),t.jsx("div",{className:"font-medium",children:s.tokenUsage.outputTokens.toLocaleString()})]}),s.tokenUsage.totalTokens!==void 0&&t.jsxs("div",{children:[t.jsx("div",{className:"text-gray-500 text-[10px] uppercase tracking-wide mb-0.5",children:"Total"}),t.jsx("div",{className:"font-medium",children:s.tokenUsage.totalTokens.toLocaleString()})]})]})]}),s.startedAt&&t.jsxs("div",{className:"text-xs text-gray-500",children:["Started: ",new Date(s.startedAt).toLocaleTimeString(),s.completedAt&&t.jsxs(t.Fragment,{children:[" ","| Completed:"," ",new Date(s.completedAt).toLocaleTimeString()," (",Math.round((s.completedAt-s.startedAt)/1e3),"s)"]})]})]})]})}const K=["Thinking","Pensando","Pensant","Denkend","Pensando","考えている","생각 중","思考中","Размышляя","Düşünüyor","Myślący","Tänkande","Pensando","Ajatellen","Σκεπτόμενος","חושב","सोच रहा है","Berpikir"],ie=["...","·..",".·.","..·",".·.","·.."];function _n({startTime:s}){const[e,r]=i.useState(0),[n,o]=i.useState(()=>K[Math.floor(Math.random()*K.length)]),[c,d]=i.useState(0);i.useEffect(()=>{const a=setInterval(()=>{const u=Date.now()-s;r(u)},100);return()=>clearInterval(a)},[s]),i.useEffect(()=>{const a=setInterval(()=>{const l=Math.floor(Math.random()*K.length);o(K[l])},1500);return()=>clearInterval(a)},[]),i.useEffect(()=>{const a=setInterval(()=>{d(l=>(l+1)%ie.length)},100);return()=>clearInterval(a)},[]);const f=(e/1e3).toFixed(1),p=ie[c];return t.jsxs("span",{className:"text-muted-foreground text-sm",children:[n,p," ",f,"s"]})}const On=H("w-full px-4 py-3 rounded-xl text-[var(--font-size)] font-[var(--font-family)] leading-relaxed break-words transition-colors",{variants:{role:{user:"bg-primary text-primary-foreground shadow-sm",assistant:"text-foreground",system:"bg-card border border-border text-foreground opacity-80 text-sm"},variant:{default:"",outline:"border border-border",ghost:"bg-transparent"}},defaultVariants:{role:"assistant",variant:"default"}}),Ct=i.forwardRef(({role:s,variant:e,isStreaming:r,message:n,thinkingDisplayStyle:o="collapsible",className:c,children:d,...f},p)=>{const a=S(b=>b.streamingStartTime),l=n&&!d,u=l?n.role:s||"assistant",h=l?n.isStreaming:r;let g=d;if(l){const b=n.metadata?.thinking,j=!!b,N=n.isStreaming&&!n.content&&n.role==="assistant";g=t.jsxs(t.Fragment,{children:[n.role==="assistant"&&j&&t.jsx(Nt,{content:b,isStreaming:n.isStreaming,mode:o,autoCollapse:!0}),N&&a&&t.jsxs("div",{className:"flex items-center gap-2 opacity-50",children:[t.jsx(Le,{className:"size-4 animate-spin text-muted-foreground"}),t.jsx(_n,{startTime:a})]}),n.role==="assistant"&&n.toolCalls&&n.toolCalls.length>0&&t.jsx("div",{className:"flex flex-col gap-2 mb-3",children:n.toolCalls.map(y=>t.jsx(zn,{toolCall:y},y.id))}),n.role==="user"?t.jsx("div",{className:"whitespace-pre-wrap",children:n.content}):t.jsx(jt,{content:n.content,isStreaming:n.isStreaming,showEmpty:!1})]})}return t.jsx("div",{ref:p,className:m(On({role:u,variant:e}),h&&"animate-pulse-subtle",c),...f,children:g})});Ct.displayName="MessageContent";const Fn=i.forwardRef(({className:s,children:e,...r},n)=>t.jsxs(Ie,{ref:n,className:m("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",s),...r,children:[e,t.jsx(Gt,{asChild:!0,children:t.jsx(is,{className:"h-4 w-4 opacity-50"})})]}));Fn.displayName=Ie.displayName;const St=i.forwardRef(({className:s,...e},r)=>t.jsx(Ee,{ref:r,className:m("flex cursor-default items-center justify-center py-1",s),...e,children:t.jsx(ls,{className:"h-4 w-4"})}));St.displayName=Ee.displayName;const Tt=i.forwardRef(({className:s,...e},r)=>t.jsx(Re,{ref:r,className:m("flex cursor-default items-center justify-center py-1",s),...e,children:t.jsx(te,{className:"h-4 w-4"})}));Tt.displayName=Re.displayName;const $n=i.forwardRef(({className:s,children:e,position:r="popper",...n},o)=>t.jsx(Yt,{children:t.jsxs(ke,{ref:o,className:m("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",r==="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",s),position:r,...n,children:[t.jsx(St,{}),t.jsx(Jt,{className:m("p-1",r==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:e}),t.jsx(Tt,{})]})}));$n.displayName=ke.displayName;const Bn=i.forwardRef(({className:s,...e},r)=>t.jsx(Me,{ref:r,className:m("py-1.5 pl-8 pr-2 text-sm font-semibold",s),...e}));Bn.displayName=Me.displayName;const Vn=i.forwardRef(({className:s,children:e,...r},n)=>t.jsxs(Ae,{ref:n,className:m("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",s),...r,children:[t.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:t.jsx(Xt,{children:t.jsx(De,{className:"h-4 w-4"})})}),t.jsx(Zt,{children:e})]}));Vn.displayName=Ae.displayName;const qn=i.forwardRef(({className:s,...e},r)=>t.jsx(Ue,{ref:r,className:m("-mx-1 my-1 h-px bg-muted",s),...e}));qn.displayName=Ue.displayName;const It=i.forwardRef(({task:s,collapsible:e=!0,defaultExpanded:r=!1,onTaskClick:n,className:o,...c},d)=>{const[f,p]=i.useState(r),a=!!(s.details||s.files&&s.files.length>0),l={pending:Pe,in_progress:Le,completed:cs}[s.status],u=()=>{switch(s.status){case"completed":return"text-green-500";case"in_progress":return"text-primary";default:return"text-foreground opacity-40"}},h=()=>{a&&e&&p(!f),n?.(s)};return t.jsxs("div",{ref:d,className:m("rounded-lg border border-border bg-card transition-all","hover:shadow-sm hover:border-border/80",o),...c,children:[t.jsxs("button",{type:"button",onClick:h,className:m("w-full flex items-center gap-3 px-3 py-2.5 text-left",a&&e&&"cursor-pointer"),disabled:!a&&!e,children:[t.jsx(l,{className:m("w-4 h-4 shrink-0",u(),s.status==="in_progress"&&"animate-spin")}),t.jsx("span",{className:m("flex-1 text-sm font-[var(--font-family)]",s.status==="completed"&&"line-through opacity-60",s.status==="in_progress"&&"font-medium"),children:s.text}),a&&e&&t.jsx(te,{className:m("w-4 h-4 text-foreground opacity-50 transition-transform duration-200 shrink-0",f&&"rotate-180"),"aria-hidden":"true"})]}),a&&f&&t.jsxs("div",{className:"px-3 pb-3 pt-1 border-t border-border/50 animate-fadeIn",children:[s.details&&t.jsx("p",{className:"text-sm text-foreground opacity-80 leading-relaxed mb-2",children:s.details}),s.files&&s.files.length>0&&t.jsxs("div",{className:"space-y-1",children:[t.jsx("span",{className:"text-xs font-medium text-foreground opacity-60 uppercase tracking-wide",children:"Files:"}),t.jsx("div",{className:"space-y-1",children:s.files.map(g=>t.jsx("div",{className:"text-xs font-mono text-foreground opacity-70 bg-background px-2 py-1 rounded border border-border/50",children:g},g))})]})]})]})});It.displayName="Task";const Wn=i.forwardRef(({tasks:s,collapsible:e=!0,onTaskClick:r,emptyMessage:n="No tasks yet.",className:o,...c},d)=>t.jsx("div",{ref:d,className:m("space-y-2 max-h-96 overflow-y-auto",o),...c,children:s.length===0?t.jsx("p",{className:"text-sm text-foreground opacity-60 italic py-4 text-center",children:n}):s.map(f=>t.jsx(It,{task:f,collapsible:e,...r?{onTaskClick:r}:{}},f.id))}));Wn.displayName="TaskList";const Qn=H("flex min-h-[80px] w-full rounded-md border bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 resize-none",{variants:{variant:{default:"border-input focus-visible:ring-ring",error:"border-destructive focus-visible:ring-destructive",success:"border-green-500 focus-visible:ring-green-500"}},defaultVariants:{variant:"default"}}),Kn=i.forwardRef(({className:s,autoResize:e=!1,maxHeight:r=200,variant:n,...o},c)=>{const d=i.useRef(null),f=i.useCallback(a=>{d.current=a,typeof c=="function"?c(a):c&&(c.current=a)},[c]),p=i.useCallback(()=>{const a=d.current;if(!a||!e)return;a.style.height="auto";const l=Math.min(a.scrollHeight,r);a.style.height=`${l}px`,a.scrollHeight>r?a.style.overflowY="auto":a.style.overflowY="hidden"},[e,r]);return i.useEffect(()=>{p()},[p]),t.jsx("textarea",{className:m(Qn({variant:n}),e&&"overflow-y-hidden",s),ref:f,...o})});Kn.displayName="Textarea";const O=Be("gui");function Gn({client:s}){const{connectionStatus:e,connect:r}=ys(s),{messages:n}=$e(s);ws(s);const o=S(f=>f.error);i.useEffect(()=>{O.debug("Connection status changed",{status:e}),e==="error"&&o&&O.error("Connection error occurred",{error:o})},[e,o]);const c=[],d=[{id:"model-sonnet",label:"Use Sonnet 4.5",description:"Switch to Claude Sonnet 4.5 model",icon:t.jsx(ne,{className:"h-4 w-4"}),category:"model",onSelect:()=>{O.info("User selected Sonnet 4.5 model")}},{id:"model-opus",label:"Use Opus",description:"Switch to Claude Opus model",icon:t.jsx(ne,{className:"h-4 w-4"}),category:"model",onSelect:()=>{O.info("User selected Opus model")}},{id:"settings",label:"Open Settings",description:"Configure chat preferences",icon:t.jsx(ps,{className:"h-4 w-4"}),category:"action",onSelect:()=>{O.info("User opened settings")}},{id:"code-mode",label:"Code Mode",description:"Enable code-focused responses",icon:t.jsx(ms,{className:"h-4 w-4"}),category:"mode",onSelect:()=>{O.info("User enabled code mode")}}];return t.jsxs(ct,{defaultPanelSize:"small",defaultActiveTab:"todo",children:[t.jsxs(dt,{children:[e==="error"&&o&&t.jsx("div",{className:"border-b border-red-500/20 bg-red-500/10 px-6 py-4",children:t.jsxs("div",{className:"flex items-start justify-between gap-4",children:[t.jsxs("div",{className:"flex-1",children:[t.jsx("h3",{className:"mb-1 text-sm font-semibold text-red-500",children:"Connection Error"}),t.jsx("p",{className:"whitespace-pre-line text-sm text-foreground",children:o})]}),t.jsx("button",{type:"button",onClick:r,className:"rounded-lg bg-red-500 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-red-600",children:"Retry"})]})}),t.jsxs(ut,{children:[t.jsx(ft,{className:"pt-4",children:n.length===0?t.jsx("div",{className:"flex h-full items-center justify-center",children:t.jsx("div",{className:"text-center text-muted-foreground",children:t.jsx("p",{className:"mb-2 text-lg",children:"No messages yet"})})}):t.jsx("div",{className:"flex flex-col gap-4 px-4",children:n.map((f,p)=>t.jsx(vt,{message:f,isLastMessage:p===n.length-1,children:t.jsx(Ct,{message:f,thinkingDisplayStyle:"collapsible"})},f.id))})}),t.jsx(pt,{children:t.jsxs(Xe,{client:s,children:[t.jsx(ot,{commands:d}),t.jsx(Ze,{placeholder:"Type a message or / for commands...",autoFocus:!0}),t.jsxs(tt,{children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(st,{}),t.jsx(nt,{})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(rt,{}),t.jsx(et,{children:t.jsx(ds,{className:"size-4"})})]})]})]})})]})]}),t.jsx(mt,{breakpoint:"lg",children:t.jsxs(gt,{defaultValue:"todo",className:"flex flex-col h-full",children:[t.jsxs(Y,{className:"w-full justify-start rounded-none border-b border-border bg-card px-4",children:[t.jsxs(V,{value:"todo",children:[t.jsx(us,{className:"h-4 w-4 mr-2"}),"To-Do"]}),t.jsxs(V,{value:"files",children:[t.jsx(fs,{className:"h-4 w-4 mr-2"}),"Files"]})]}),t.jsx(F,{value:"todo",className:"flex-1 p-4 mt-0",children:t.jsx(ht,{todos:c})}),t.jsx(F,{value:"files",className:"flex-1 p-4 mt-0",children:t.jsx(xt,{})})]})})]})}function Yn(){return"http://localhost:3100"}const le={agentServerUrl:Yn()},$=Be("gui");function Jn(){const[s,e]=i.useState(null),[r,n]=i.useState(null);return i.useEffect(()=>{try{$.info("Initializing ACP client",{serverUrl:le.agentServerUrl});const o=new Es({type:"http",options:{baseUrl:le.agentServerUrl}});return e(o),$.info("ACP client initialized successfully"),()=>{$.debug("Disconnecting ACP client"),o.disconnect().catch(c=>{$.error("Failed to disconnect ACP client",{error:c instanceof Error?c.message:String(c)})})}}catch(o){const c=o instanceof Error?o.message:"Failed to initialize ACP client";n(c),$.error("Failed to initialize ACP client",{error:o instanceof Error?o.message:String(o),stack:o instanceof Error?o.stack:void 0});return}},[]),r?t.jsx("div",{className:"flex items-center justify-center h-screen bg-[var(--color-bg)]",children:t.jsxs("div",{className:"text-center p-8 max-w-md",children:[t.jsx("h1",{className:"text-2xl font-bold text-red-500 mb-4",children:"Initialization Error"}),t.jsx("p",{className:"text-[var(--color-text)] mb-4",children:r}),t.jsx("p",{className:"text-sm text-[var(--color-text-secondary)]",children:"Failed to initialize the ACP client. Check the console for details."})]})}):t.jsx(Gn,{client:s})}const Et=document.getElementById("root");if(!Et)throw new Error("Root element not found");Pt.createRoot(Et).render(t.jsx(Lt.StrictMode,{children:t.jsx(Jn,{})}));
8
+ `)){g(!0);const ee=M.slice(1);b(ee)}else g(!1),b("");const D=w.current;if(!D)return;D.style.height="auto";const Z=Math.min(D.scrollHeight,164);D.style.height=`${Z}px`,D.scrollHeight>164?D.style.overflowY="auto":D.style.overflowY="hidden"},onKeyDown:C=>{if(h&&N>0){if(C.key==="ArrowDown"){C.preventDefault(),j(M=>(M+1)%N);return}else if(C.key==="ArrowUp"){C.preventDefault(),j(M=>(M-1+N)%N);return}else if(C.key==="Enter"&&!C.shiftKey){C.preventDefault(),y();return}else if(C.key==="Escape"){C.preventDefault(),g(!1),b("");return}}u&&C.key==="Enter"&&!C.shiftKey&&(d.trim()&&!l&&!a?(C.preventDefault(),p()):(l||a)&&C.preventDefault()),r?.(C)},disabled:a,...o};return s&&i.isValidElement(n)?i.cloneElement(n,_):t.jsx("textarea",{..._,className:m("w-full resize-none rounded-none border-none p-4 shadow-none","outline-none ring-0 field-sizing-content max-h-[6lh]","bg-transparent dark:bg-transparent focus-visible:ring-0","text-sm placeholder:text-muted-foreground","disabled:cursor-not-allowed disabled:opacity-50",e)})});Ze.displayName="ChatInput.Field";const et=i.forwardRef(({asChild:s=!1,className:e,disabled:r,children:n,...o},c)=>{const{value:d,disabled:f,isSubmitting:p}=X(),a=r||f||p||!d.trim(),l=s?q:Q;return t.jsx(l,{ref:c,type:"submit",disabled:a,variant:s?void 0:"default",size:"icon",className:m(!s&&"gap-1.5 rounded-full",e),...o,children:n})});et.displayName="ChatInput.Submit";const tt=i.forwardRef(({className:s,children:e,...r},n)=>t.jsx("div",{ref:n,className:m("flex items-center justify-between p-2",s),...r,children:e}));tt.displayName="ChatInput.Toolbar";const st=i.forwardRef(({asChild:s=!1,className:e,children:r,onClick:n,...o},c)=>{const{value:d,onChange:f,setShowCommandMenu:p,setCommandMenuQuery:a}=X(),l=h=>{d.startsWith("/")||(f("/"),p(!0),a("")),n?.(h)},u=s?q:Q;return t.jsx(u,{ref:c,type:"button",variant:"ghost",size:"icon",className:m("rounded-full",e),onClick:l,...o,children:r||t.jsx(es,{className:"size-4"})})});st.displayName="ChatInput.Actions";const nt=i.forwardRef(({asChild:s=!1,className:e,children:r,...n},o)=>{const c=s?q:Q;return t.jsx(c,{ref:o,type:"button",variant:"ghost",size:"icon",className:m("rounded-full",e),...n,children:r||t.jsx(ts,{className:"size-4"})})});nt.displayName="ChatInput.Attachment";const rt=i.forwardRef(({asChild:s=!1,className:e,children:r,...n},o)=>{const c=s?q:Q;return t.jsx(c,{ref:o,type:"button",variant:"ghost",size:"icon",className:m("rounded-full",e),...n,children:r||t.jsx(ss,{className:"size-4"})})});rt.displayName="ChatInput.VoiceInput";const ot=i.forwardRef(({commands:s=[],className:e,onChange:r,...n},o)=>{const{showCommandMenu:c,commandMenuQuery:d,selectedMenuIndex:f,setSelectedMenuIndex:p,setMenuItemCount:a,triggerCounter:l,onChange:u}=X();return t.jsx(Ye,{ref:o,commands:s,showCommandMenu:c,commandMenuQuery:d,selectedMenuIndex:f,setSelectedMenuIndex:p,setMenuItemCount:a,triggerCounter:l,onChange:u,className:e,...n})});ot.displayName="ChatInput.CommandMenu";const an=({className:s,...e})=>t.jsx(Mt,{className:m("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",s),...e}),at=({className:s,...e})=>t.jsx(At,{className:m(s),...e}),ln=({withHandle:s,className:e,...r})=>t.jsx(Ut,{className:m("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",e),...r,children:s&&t.jsx("div",{className:"z-10 flex h-4 w-3 items-center justify-center rounded-sm border bg-border",children:t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"h-2.5 w-2.5",children:[t.jsx("title",{children:"Resize Handle"}),t.jsx("circle",{cx:"9",cy:"12",r:"1"}),t.jsx("circle",{cx:"9",cy:"5",r:"1"}),t.jsx("circle",{cx:"9",cy:"19",r:"1"}),t.jsx("circle",{cx:"15",cy:"12",r:"1"}),t.jsx("circle",{cx:"15",cy:"5",r:"1"}),t.jsx("circle",{cx:"15",cy:"19",r:"1"})]})})}),cn=({...s})=>t.jsx($t,{position:"top-center",className:"toaster group",style:{"--top-offset":"16px","--width:":"calc(100% - 2 * var(--top-offset))",position:"absolute",zIndex:5,top:"var(--top-offset)",left:"50%",transform:"translateX(-50%)",width:"calc(100% - 2 * var(--top-offset))",maxWidth:"480px"},offset:0,toastOptions:{classNames:{toast:"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground"}},...s}),it=i.createContext(void 0),lt=()=>{const s=i.useContext(it);if(!s)throw new Error("ChatLayout components must be used within ChatLayout.Root");return s},ct=i.forwardRef(({defaultSidebarOpen:s=!1,defaultPanelSize:e="hidden",defaultActiveTab:r="todo",className:n,children:o,...c},d)=>{const[f,p]=i.useState(s),[a,l]=i.useState(e),[u,h]=i.useState(r);return t.jsx(it.Provider,{value:{sidebarOpen:f,setSidebarOpen:p,panelSize:a,setPanelSize:l,activeTab:u,setActiveTab:h},children:t.jsx("div",{ref:d,className:m("flex h-screen flex-row bg-background text-foreground",n),...c,children:t.jsx(an,{direction:"horizontal",className:"flex-1",children:o})})})});ct.displayName="ChatLayout.Root";const dn=i.forwardRef(({className:s,children:e,...r},n)=>t.jsx("div",{ref:n,className:m("relative z-10 border-b border-border bg-card shrink-0",s),...r,children:e}));dn.displayName="ChatLayout.Header";const dt=i.forwardRef(({className:s,children:e,...r},n)=>t.jsx(at,{defaultSize:75,minSize:50,children:t.jsx("div",{ref:n,className:m("flex flex-1 flex-col overflow-hidden h-full",s),...r,children:e})}));dt.displayName="ChatLayout.Main";const ut=i.forwardRef(({showToaster:s=!0,className:e,children:r,...n},o)=>t.jsxs("div",{ref:o,className:m("relative flex flex-1 flex-col overflow-hidden",e),...n,children:[r,s&&t.jsx(cn,{})]}));ut.displayName="ChatLayout.Body";const ft=i.forwardRef(({className:s,children:e,onScrollChange:r,showScrollToBottom:n=!0,...o},c)=>{const[d,f]=i.useState(!1),p=i.useRef(null);i.useImperativeHandle(c,()=>p.current);const a=i.useCallback(()=>{const h=p.current;if(!h)return;const{scrollTop:g,scrollHeight:b,clientHeight:j}=h,y=b-g-j<100;f(!y&&n),r?.(y)},[r,n]),l=i.useCallback(()=>{a()},[a]),u=i.useCallback(()=>{const h=p.current;h&&h.scrollTo({top:h.scrollHeight,behavior:"smooth"})},[]);return i.useEffect(()=>{a()},[a]),t.jsxs("div",{className:"relative flex-1 overflow-hidden",children:[t.jsx("div",{ref:p,className:m("h-full overflow-y-auto",s),onScroll:l,...o,children:e}),d&&t.jsx("button",{type:"button",onClick:u,className:m("absolute bottom-4 left-1/2 -translate-x-1/2 z-10","flex items-center justify-center p-2 rounded-full","bg-card border border-border shadow-lg","text-foreground","hover:bg-accent hover:text-accent-foreground","transition-all duration-200 ease-in-out","animate-in fade-in slide-in-from-bottom-2"),"aria-label":"Scroll to bottom",children:t.jsx(ns,{className:"h-4 w-4"})})]})});ft.displayName="ChatLayout.Messages";const pt=i.forwardRef(({className:s,children:e,...r},n)=>t.jsx("div",{ref:n,className:m("bg-linear-to-t from-background to-transparent px-4 pb-4",s),...r,children:e}));pt.displayName="ChatLayout.Footer";const un=i.forwardRef(({className:s,children:e,...r},n)=>{const{sidebarOpen:o}=lt();return o?t.jsx("div",{ref:n,className:m("border-r border-border bg-card w-64 overflow-y-auto",s),...r,children:e}):null});un.displayName="ChatLayout.Sidebar";const mt=i.forwardRef(({breakpoint:s="lg",className:e,children:r,...n},o)=>{const{panelSize:c}=lt();return c==="hidden"?null:t.jsxs(t.Fragment,{children:[t.jsx(ln,{withHandle:!0}),t.jsx(at,{defaultSize:25,minSize:15,maxSize:50,children:t.jsx("div",{ref:o,className:m("hidden h-full border-l border-border bg-card overflow-y-auto transition-all duration-300",s==="md"&&"md:block",s==="lg"&&"lg:block",s==="xl"&&"xl:block",s==="2xl"&&"2xl:block",e),...n,children:r})})]})});mt.displayName="ChatLayout.Aside";const ht=i.forwardRef(({todos:s,className:e,...r},n)=>t.jsx("div",{ref:n,className:m("space-y-2",e),...r,children:s.length===0?t.jsx("div",{className:"flex items-center justify-center h-full min-h-[200px]",children:t.jsx("p",{className:"text-sm text-muted-foreground",children:"No todos yet"})}):s.map(o=>t.jsx("div",{className:"text-sm",children:o.text},o.id))}));ht.displayName="TodoTabContent";const xt=i.forwardRef(({files:s=[],className:e,...r},n)=>t.jsx("div",{ref:n,className:m("space-y-2",e),...r,children:s.length===0?t.jsx("div",{className:"flex items-center justify-center h-full min-h-[200px]",children:t.jsx("p",{className:"text-sm text-muted-foreground",children:"No files attached"})}):s.map(o=>t.jsx("div",{className:"text-sm",children:o},o))}));xt.displayName="FilesTabContent";const fn=i.forwardRef(({data:s,className:e,...r},n)=>t.jsxs("div",{ref:n,className:m("space-y-4",e),...r,children:[t.jsx("h3",{className:"font-semibold text-lg",children:"Database"}),t.jsxs("div",{className:"text-sm text-muted-foreground",children:[t.jsx("p",{children:"Database viewer - panel automatically expanded to large size"}),t.jsxs("div",{className:"mt-4 p-4 border border-border rounded",children:[t.jsx("p",{children:"Your large data table would go here"}),s&&typeof s=="object"?t.jsx("pre",{className:"mt-2 text-xs overflow-auto",children:JSON.stringify(s,null,2)}):null]})]})]}));fn.displayName="DatabaseTabContent";const gt=qt,Y=i.forwardRef(({className:s,...e},r)=>t.jsx(de,{ref:r,className:m("inline-flex h-10 items-center rounded-md bg-muted p-1 text-muted-foreground gap-1",s),...e}));Y.displayName=de.displayName;const V=i.forwardRef(({className:s,...e},r)=>t.jsx(ue,{ref:r,className:m("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",s),...e}));V.displayName=ue.displayName;const F=i.forwardRef(({className:s,...e},r)=>t.jsx(fe,{ref:r,className:m("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",s),...e}));F.displayName=fe.displayName;const bt=i.forwardRef(({todo:s,className:e,...r},n)=>t.jsx("div",{ref:n,className:m("flex items-center gap-3 px-3 py-2 rounded-lg",e),...r,children:t.jsx("span",{className:m("flex-1 text-[var(--font-size)] font-[var(--font-family)]",s.status==="completed"&&"line-through opacity-60",s.status==="in_progress"&&"shimmer-animation"),children:s.text})}));bt.displayName="TodoListItem";const yt=i.forwardRef(({client:s,todos:e,className:r,...n},o)=>{const c=e||[];return t.jsx("div",{ref:o,className:m("space-y-2 max-h-64 overflow-y-auto",r),...n,children:c.length===0?t.jsx("p",{className:"text-sm text-foreground opacity-60 italic",children:"No tasks yet."}):c.map(d=>t.jsx(bt,{todo:d},d.id))})});yt.displayName="TodoList";const pn=i.forwardRef(({client:s,todos:e,className:r,...n},o)=>{const c=e||[],[d,f]=i.useState("todo"),p=i.useRef(null),a=i.useRef(null);i.useEffect(()=>{const h=setTimeout(()=>{const g=p.current;if(d&&g){const b=a.current;if(b){const j=g.getBoundingClientRect(),N=b.getBoundingClientRect(),y=N.left-j.left,w=N.width,v=y/j.width*100,k=100-(y+w)/j.width*100;g.style.clipPath=`inset(0 ${k.toFixed(2)}% 0 ${v.toFixed(2)}% round 999px)`}}},0);return()=>clearTimeout(h)},[d]);const l=[{id:"todo",label:"To-Do List"},{id:"files",label:"Files"},{id:"database",label:"Database"}];return t.jsx("div",{ref:o,className:m("select-none",r),...n,children:t.jsxs(gt,{value:d,onValueChange:f,className:"w-full",children:[t.jsxs("div",{className:"relative mb-4 border-border",children:[t.jsx(Y,{className:"bg-transparent p-0 h-auto rounded-none w-full border-none",children:l.map(u=>t.jsx(V,{value:u.id,className:"px-3 py-1 text-sm font-[var(--font-family)] font-medium rounded-none text-foreground opacity-60 data-[state=active]:opacity-100 data-[state=active]:bg-transparent data-[state=active]:shadow-none",children:u.label},u.id))}),t.jsx("div",{ref:p,className:"absolute top-0 left-0 w-full overflow-hidden z-10 pointer-events-none",style:{clipPath:"inset(0 100% 0 0% round 999px)",transition:"clip-path 0.25s ease-out"},children:t.jsx(Y,{className:"bg-secondary p-0 h-auto rounded-none w-full border-none",children:l.map(u=>t.jsx(V,{value:u.id,ref:d===u.id?a:null,className:"px-3 py-1 text-sm font-[var(--font-family)] font-medium rounded-none text-primary bg-transparent data-[state=active]:shadow-none shadow-none",tabIndex:-1,children:u.label},u.id))})})]}),t.jsx(F,{value:"todo",children:t.jsx(yt,{todos:c})}),t.jsx(F,{value:"files",children:t.jsx("div",{className:"text-sm text-foreground opacity-60 italic",children:"Files tab coming soon..."})}),t.jsx(F,{value:"database",children:t.jsx("div",{className:"text-sm text-foreground opacity-60 italic",children:"Database tab coming soon..."})})]})})});pn.displayName="ChatSecondaryPanel";const mn=i.forwardRef(({className:s,children:e,...r},n)=>t.jsx("div",{ref:n,className:m("flex h-full flex-col",s),...r,children:e}));mn.displayName="ChatSidebar.Root";const hn=i.forwardRef(({className:s,children:e,...r},n)=>t.jsx("div",{ref:n,className:m("border-b border-border px-4 py-3",s),...r,children:e}));hn.displayName="ChatSidebar.Header";const xn=i.forwardRef(({className:s,children:e,...r},n)=>t.jsx("div",{ref:n,className:m("flex-1 overflow-y-auto p-4",s),...r,children:e}));xn.displayName="ChatSidebar.Content";const gn=i.forwardRef(({className:s,children:e,...r},n)=>t.jsx("div",{ref:n,className:m("border-t border-border px-4 py-3",s),...r,children:e}));gn.displayName="ChatSidebar.Footer";const bn=i.forwardRef(({children:s,className:e,...r},n)=>{const[o,c]=i.useState(s),[d,f]=i.useState(!1),p=i.useRef(s),a=i.useRef(!0);return i.useEffect(()=>{if(a.current){a.current=!1,p.current=s;return}if(p.current===s)return;f(!0);const l=setTimeout(()=>{c(s),p.current=s,requestAnimationFrame(()=>{f(!1)})},150);return()=>{clearTimeout(l)}},[s]),t.jsx("span",{ref:n,className:m("text-sm text-foreground opacity-60 transition-opacity duration-300",d?"opacity-0":"opacity-60",e),...r,children:o})});bn.displayName="ChatStatus";const yn=i.forwardRef(({autoScroll:s=!0,isStreaming:e=!1,scrollBehavior:r="smooth",scrollThreshold:n=100,showScrollButton:o=!0,scrollButton:c,className:d,children:f,...p},a)=>{const l=i.useRef(null),[u,h]=i.useState(!0),[g,b]=i.useState(!1),j=i.useRef(0);i.useImperativeHandle(a,()=>{if(!l.current)throw new Error("Container ref not initialized");return l.current});const N=i.useCallback(()=>{const w=l.current;if(!w)return;const{scrollTop:v,scrollHeight:k,clientHeight:z}=w,C=k-v-z<n;h(C),b(!C&&o),j.current=v},[n,o]),y=i.useCallback((w=r)=>{const v=l.current;v&&v.scrollTo({top:v.scrollHeight,behavior:w})},[r]);return i.useEffect(()=>{!s||!l.current||(e&&u?y("auto"):!e&&u&&y())},[s,e,u,y]),i.useEffect(()=>{const w=l.current;if(!w)return;const v=()=>{N()};return w.addEventListener("scroll",v,{passive:!0}),N(),()=>{w.removeEventListener("scroll",v)}},[N]),i.useEffect(()=>{const w=l.current;if(!w)return;const v=new ResizeObserver(()=>{u&&s&&y("auto")});return v.observe(w),()=>{v.disconnect()}},[u,s,y]),t.jsxs("div",{className:"relative flex-1",children:[t.jsx("div",{ref:l,className:m("h-full overflow-y-auto overflow-x-hidden","scrollbar-thin scrollbar-thumb-[border] scrollbar-track-transparent",d),...p,children:t.jsx("div",{className:"flex flex-col gap-4 px-4 py-4",children:f})}),g&&t.jsx("div",{className:"absolute bottom-4 left-1/2 -translate-x-1/2 z-10",children:c||t.jsxs("button",{type:"button",onClick:()=>y(),className:"px-4 py-2 rounded-full bg-card border border-border shadow-lg hover:shadow-xl hover:bg-card/90 transition-all text-sm font-medium text-foreground flex items-center gap-2","aria-label":"Scroll to bottom",children:[t.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",role:"img","aria-label":"Down arrow",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 14l-7 7m0 0l-7-7m7 7V3"})}),"Scroll to bottom"]})})]})});yn.displayName="Conversation";const wn=Wt,wt=i.forwardRef(({className:s,...e},r)=>t.jsx(pe,{ref:r,className:m("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",s),...e}));wt.displayName=pe.displayName;const vn=i.forwardRef(({className:s,children:e,...r},n)=>t.jsxs(wn,{children:[t.jsx(wt,{}),t.jsxs(me,{ref:n,className:m("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",s),...r,children:[e,t.jsxs(Qt,{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:[t.jsx(rs,{className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));vn.displayName=me.displayName;const Nn=i.forwardRef(({className:s,...e},r)=>t.jsx(he,{ref:r,className:m("text-lg font-semibold leading-none tracking-tight",s),...e}));Nn.displayName=he.displayName;const jn=i.forwardRef(({className:s,...e},r)=>t.jsx(xe,{ref:r,className:m("text-sm text-muted-foreground",s),...e}));jn.displayName=xe.displayName;const Cn=i.forwardRef(({className:s,inset:e,children:r,...n},o)=>t.jsxs(ge,{ref:o,className:m("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none","focus:bg-muted data-[state=open]:bg-muted",e&&"pl-8",s),...n,children:[r,t.jsx(os,{className:"ml-auto h-4 w-4"})]}));Cn.displayName=ge.displayName;const Sn=i.forwardRef(({className:s,...e},r)=>t.jsx(be,{ref:r,className:m("z-50 min-w-[8rem] overflow-hidden rounded-md border border-border bg-card p-1 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",s),...e}));Sn.displayName=be.displayName;const Tn=i.forwardRef(({className:s,sideOffset:e=4,...r},n)=>t.jsx(Kt,{children:t.jsx(ye,{ref:n,sideOffset:e,className:m("z-50 min-w-[8rem] overflow-hidden rounded-md border border-border bg-card p-1 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",s),...r})}));Tn.displayName=ye.displayName;const In=i.forwardRef(({className:s,inset:e,...r},n)=>t.jsx(we,{ref:n,className:m("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors","focus:bg-muted focus:text-foreground","data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e&&"pl-8",s),...r}));In.displayName=we.displayName;const En=i.forwardRef(({className:s,children:e,...r},n)=>t.jsxs(ve,{ref:n,className:m("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-muted focus:text-foreground","data-[disabled]:pointer-events-none data-[disabled]:opacity-50",s),...r,children:[t.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:t.jsx(Ne,{children:t.jsx(De,{className:"h-4 w-4"})})}),e]}));En.displayName=ve.displayName;const Rn=i.forwardRef(({className:s,children:e,...r},n)=>t.jsxs(je,{ref:n,className:m("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-muted focus:text-foreground","data-[disabled]:pointer-events-none data-[disabled]:opacity-50",s),...r,children:[t.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:t.jsx(Ne,{children:t.jsx(Pe,{className:"h-2 w-2 fill-current"})})}),e]}));Rn.displayName=je.displayName;const kn=i.forwardRef(({className:s,inset:e,...r},n)=>t.jsx(Ce,{ref:n,className:m("px-2 py-1.5 text-sm font-semibold",e&&"pl-8",s),...r}));kn.displayName=Ce.displayName;const Mn=i.forwardRef(({className:s,...e},r)=>t.jsx(Se,{ref:r,className:m("-mx-1 my-1 h-px bg-border",s),...e}));Mn.displayName=Se.displayName;const An=H("flex h-10 w-full rounded-md border bg-background px-3 py-2 text-sm 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-offset-2 disabled:cursor-not-allowed disabled:opacity-50",{variants:{variant:{default:"border-input focus-visible:ring-ring",error:"border-destructive focus-visible:ring-destructive",success:"border-green-500 focus-visible:ring-green-500"}},defaultVariants:{variant:"default"}}),Un=i.forwardRef(({className:s,type:e,variant:r,...n},o)=>t.jsx("input",{type:e,className:m(An({variant:r,className:s})),ref:o,...n}));Un.displayName="Input";const Dn=i.forwardRef(({className:s,...e},r)=>t.jsx(Te,{ref:r,className:m("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",s),...e}));Dn.displayName=Te.displayName;const Pn=H("flex animate-fadeIn",{variants:{role:{user:"max-w-[80%] self-end ml-auto mr-2",assistant:"self-start mr-auto",system:"self-start mr-auto max-w-full"},layout:{default:"",full:"max-w-full",compact:"max-w-[90%]"}},defaultVariants:{role:"assistant",layout:"default"}}),vt=i.forwardRef(({message:s,role:e,layout:r,className:n,children:o,messageId:c,autoScroll:d,isLastMessage:f=!1,...p},a)=>{const l=s?s.role:e||"assistant",u=s?s.id:c,h=i.useRef(null),[g,b]=i.useState(void 0);return i.useImperativeHandle(a,()=>h.current),i.useEffect(()=>{if(!f||l!=="assistant"){b(void 0);return}const j=()=>{const y=h.current;if(!y)return;let w=y.parentElement;for(;w&&!w.classList.contains("overflow-y-auto");)w=w.parentElement;if(!w)return;const v=y.previousElementSibling;if(!v||v.getAttribute("aria-label")!=="user message"){b(void 0);return}const k=w.clientHeight,z=v.offsetHeight,C=Math.max(0,k-z-32);b(C)};j();const N=new ResizeObserver(j);if(h.current){N.observe(h.current);let y=h.current.parentElement;for(;y&&!y.classList.contains("overflow-y-auto");)y=y.parentElement;y&&N.observe(y)}return()=>N.disconnect()},[f,l]),i.useEffect(()=>{if((d!==void 0?d:l==="user")&&h.current){const N=setTimeout(()=>{h.current?.scrollIntoView({behavior:"smooth",block:"start",inline:"nearest"})},50);return()=>clearTimeout(N)}},[l,d]),t.jsx("article",{ref:h,"aria-label":`${l} message`,"data-message-id":u,className:m(Pn({role:l,layout:r}),n),style:{minHeight:g!==void 0?`${g}px`:void 0},...p,children:o})});vt.displayName="Message";const ae=H("mb-3 rounded-lg bg-card border border-border transition-all",{variants:{variant:{default:"opacity-70",subtle:"opacity-50",prominent:"opacity-90 shadow-sm"}},defaultVariants:{variant:"default"}}),Ln=H("w-4 h-4 text-foreground opacity-60 transition-transform duration-200",{variants:{expanded:{true:"rotate-180",false:""}},defaultVariants:{expanded:!1}}),Nt=i.forwardRef(({content:s,isStreaming:e=!1,mode:r="collapsible",defaultExpanded:n=!1,autoExpand:o=!1,autoCollapse:c=!0,autoCollapseDelay:d=2e3,label:f="Thinking",variant:p,className:a},l)=>{const[u,h]=i.useState(r==="inline"?!0:n),[g,b]=i.useState(!1);return i.useEffect(()=>{if(c&&!e&&s&&r==="collapsible"){const j=setTimeout(()=>{b(!0),h(!1)},d);return()=>clearTimeout(j)}},[e,s,c,d,r]),i.useEffect(()=>{o&&e&&r==="collapsible"&&!g&&h(!0)},[o,e,r,g]),!s&&!e?null:r==="inline"?t.jsxs("div",{ref:l,className:m(ae({variant:p}),"p-3",a),children:[t.jsxs("div",{className:"flex items-start gap-2 mb-2",children:[t.jsx("span",{className:"text-xs font-medium text-foreground opacity-60 uppercase tracking-wide",children:f}),e&&t.jsx("span",{className:"inline-block w-2 h-2 bg-primary rounded-full animate-pulse"})]}),t.jsxs("div",{className:"text-sm italic text-foreground opacity-80 leading-relaxed whitespace-pre-wrap",children:[s,e&&s&&t.jsx("span",{className:"inline-block animate-typing text-primary",children:"..."})]})]}):t.jsxs("div",{ref:l,className:m("mb-3",a),children:[t.jsxs("button",{type:"button",onClick:()=>{h(!u),b(!1)},className:"w-full flex items-center justify-between p-2.5 rounded-lg bg-card border border-border hover:bg-card/80 hover:shadow-sm transition-all text-left","aria-expanded":u,"aria-label":`${u?"Collapse":"Expand"} reasoning`,children:[t.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[t.jsx("span",{className:"text-xs font-medium text-foreground opacity-60 uppercase tracking-wide shrink-0",children:f}),e&&t.jsx("span",{className:"inline-block w-2 h-2 bg-primary rounded-full animate-pulse shrink-0"}),!u&&s&&t.jsxs("span",{className:"text-xs text-foreground opacity-50 truncate",children:[s.substring(0,60),s.length>60&&"..."]})]}),t.jsx(te,{className:Ln({expanded:u}),"aria-hidden":"true"})]}),u&&t.jsx("div",{className:m(ae({variant:p}),"mt-2 p-3 animate-fadeIn"),children:t.jsxs("div",{className:"text-sm italic text-foreground opacity-80 leading-relaxed whitespace-pre-wrap",children:[s,e&&s&&t.jsx("span",{className:"inline-block animate-typing text-primary",children:"..."})]})})]})});Nt.displayName="Reasoning";const jt=i.forwardRef(({content:s,isStreaming:e=!1,showEmpty:r=!0,emptyMessage:n="",className:o,...c},d)=>{if(!s&&e&&r)return t.jsx("div",{ref:d,className:m("opacity-70 italic text-sm",o),...c,children:n});if(!s)return null;const f={table:({node:p,...a})=>t.jsx("div",{className:"overflow-x-auto my-4",children:t.jsx("table",{className:"min-w-full border-collapse border border-border rounded-md",...a})}),thead:({node:p,...a})=>t.jsx("thead",{className:"bg-card border-b border-border",...a}),tbody:({node:p,...a})=>t.jsx("tbody",{...a}),tr:({node:p,...a})=>t.jsx("tr",{className:"border-b border-border hover:bg-card transition-colors",...a}),th:({node:p,...a})=>t.jsx("th",{className:"px-4 py-2 text-left font-semibold text-foreground border-r border-border last:border-r-0",...a}),td:({node:p,...a})=>t.jsx("td",{className:"px-4 py-2 text-foreground border-r border-border last:border-r-0",...a}),input:({node:p,checked:a,...l})=>l.type==="checkbox"?t.jsx("input",{type:"checkbox",checked:a||!1,disabled:!0,readOnly:!0,className:"mr-2 w-4 h-4 accent-[primary] cursor-not-allowed",...l}):t.jsx("input",{...l}),code:({node:p,...a})=>a.className?.includes("language-")?t.jsx("code",{className:"block p-4 bg-card border border-border rounded-md overflow-x-auto text-sm font-mono text-foreground shadow-sm",...a}):t.jsx("code",{className:"px-1.5 py-0.5 bg-card border border-border rounded text-sm font-mono text-foreground",...a}),pre:({node:p,...a})=>t.jsx("pre",{className:"my-4 rounded-lg",...a}),h1:({node:p,...a})=>t.jsx("h1",{className:"text-2xl font-bold mt-6 mb-4 text-foreground border-b border-border pb-2",...a}),h2:({node:p,...a})=>t.jsx("h2",{className:"text-xl font-semibold mt-5 mb-3 text-foreground border-b border-border/50 pb-1.5",...a}),h3:({node:p,...a})=>t.jsx("h3",{className:"text-lg font-semibold mt-4 mb-2 text-foreground",...a}),h4:({node:p,...a})=>t.jsx("h4",{className:"text-base font-semibold mt-3 mb-2 text-foreground",...a}),ul:({node:p,...a})=>{const l=p?.children?.some(u=>typeof u=="object"&&u!==null&&"type"in u&&u.type==="element"&&"tagName"in u&&u.tagName==="li"&&"children"in u&&Array.isArray(u.children)&&u.children.some(h=>typeof h=="object"&&h!==null&&"type"in h&&h.type==="element"&&"tagName"in h&&h.tagName==="input"&&"properties"in h&&typeof h.properties=="object"&&h.properties!==null&&"type"in h.properties&&h.properties.type==="checkbox"));return t.jsx("ul",{className:m("my-2 space-y-1 text-foreground",l?"list-none space-y-2":"list-disc list-inside"),...a})},ol:({node:p,...a})=>t.jsx("ol",{className:"list-decimal list-inside my-2 space-y-1 text-foreground",...a}),li:({node:p,...a})=>{const l=p?.children?.some(u=>typeof u=="object"&&u!==null&&"type"in u&&u.type==="element"&&"tagName"in u&&u.tagName==="input"&&"properties"in u&&typeof u.properties=="object"&&u.properties!==null&&"type"in u.properties&&u.properties.type==="checkbox");return t.jsx("li",{className:m("flex items-start",l?"gap-2":"ml-2"),...a})},a:({node:p,...a})=>t.jsx("a",{className:"text-primary hover:underline decoration-2 underline-offset-2 transition-all",target:"_blank",rel:"noopener noreferrer",...a}),p:({node:p,...a})=>t.jsx("p",{className:"my-2 text-foreground leading-relaxed",...a}),blockquote:({node:p,...a})=>t.jsx("blockquote",{className:"border-l-4 border-[primary] pl-4 italic my-4 text-foreground bg-card py-2 rounded-r-md shadow-sm",...a}),hr:({node:p,...a})=>t.jsx("hr",{className:"my-6 border-t border-border opacity-50",...a})};return t.jsxs("div",{ref:d,className:m("markdown-content prose prose-sm max-w-none dark:prose-invert",o),...c,children:[t.jsx(Dt,{remarkPlugins:[hs],components:f,children:s}),e&&s&&t.jsx("span",{className:"inline-block ml-1 animate-typing text-primary",children:"..."})]})});jt.displayName="Response";const Hn={pending:"bg-transparent text-muted-foreground",in_progress:"bg-transparent text-muted-foreground",completed:"bg-transparent text-muted-foreground",failed:"bg-transparent text-muted-foreground"};function zn({toolCall:s}){const[e,r]=i.useState(!1);return t.jsxs("div",{className:"flex flex-col",children:[t.jsxs("button",{type:"button",className:"flex items-center gap-1.5 cursor-pointer bg-transparent border-none p-0 text-left group w-fit",onClick:()=>r(!e),"aria-expanded":e,children:[t.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2 py-1 text-xs font-medium rounded ${Hn[s.status]}`,children:[t.jsx(as,{className:"h-3 w-3"}),t.jsx("span",{children:s.title}),s.status==="completed"&&t.jsx("span",{children:"✓"})]}),t.jsx("span",{className:"text-gray-400 text-xs opacity-0 group-hover:opacity-100 transition-opacity",children:e?"▲":"▼"})]}),e&&t.jsxs("div",{className:"mt-2 space-y-3 text-sm border border-gray-200 rounded-md p-3 bg-white shadow-sm max-w-full",children:[s.locations&&s.locations.length>0&&t.jsxs("div",{children:[t.jsx("div",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wide mb-1.5",children:"Files"}),t.jsx("ul",{className:"space-y-1",children:s.locations.map(n=>t.jsxs("li",{className:"font-mono text-xs text-gray-700 bg-gray-50 px-2 py-1 rounded",children:[n.path,n.line!==null&&n.line!==void 0&&`:${n.line}`]},`${n.path}:${n.line??""}`))})]}),s.rawInput&&Object.keys(s.rawInput).length>0&&t.jsxs("div",{children:[t.jsx("div",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wide mb-1.5",children:"Input"}),t.jsx("div",{className:"bg-gray-50 p-2 rounded border border-gray-200",children:t.jsx(se,{value:s.rawInput,collapsed:!1,displayDataTypes:!1,displayObjectSize:!1,enableClipboard:!0,style:{fontSize:"11px",backgroundColor:"transparent"}})})]}),s.content&&s.content.length>0&&t.jsxs("div",{children:[t.jsx("div",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wide mb-1.5",children:"Output"}),t.jsx("div",{className:"space-y-2",children:s.content.map((n,o)=>{const c=()=>n.type==="diff"&&"path"in n?`diff-${n.path}-${o}`:n.type==="terminal"&&"terminalId"in n?`terminal-${n.terminalId}`:n.type==="text"&&"text"in n?`text-${n.text.substring(0,20)}-${o}`:n.type==="content"&&"content"in n?`content-${n.content.text?.substring(0,20)}-${o}`:`block-${o}`,d=(f,p)=>{try{const a=JSON.parse(f);if(typeof a=="object"&&a!==null)return t.jsx("div",{className:"bg-gray-50 p-2 rounded border border-gray-200",children:t.jsx(se,{value:a,collapsed:!1,displayDataTypes:!1,displayObjectSize:!1,enableClipboard:!0,style:{fontSize:"11px",backgroundColor:"transparent"}})},p)}catch{}return t.jsx("pre",{className:"bg-gray-50 p-2.5 rounded border border-gray-200 text-xs overflow-x-auto font-mono text-gray-800",children:f},p)};if(n.type==="content"&&"content"in n){const f=n.content;if(f.type==="text"&&f.text)return d(f.text,c())}return n.type==="text"&&"text"in n?d(n.text,c()):n.type==="diff"&&"path"in n&&"oldText"in n&&"newText"in n?t.jsxs("div",{className:"border rounded",children:[t.jsxs("div",{className:"bg-gray-100 px-2 py-1 text-xs font-mono",children:[n.path,"line"in n&&n.line!==null&&n.line!==void 0&&`:${n.line}`]}),t.jsxs("div",{className:"p-2 font-mono text-xs",children:[t.jsxs("div",{className:"text-red-600",children:["- ",n.oldText]}),t.jsxs("div",{className:"text-green-600",children:["+ ",n.newText]})]})]},c()):n.type==="terminal"&&"terminalId"in n?t.jsxs("div",{className:"bg-black text-green-400 p-2 rounded text-xs font-mono",children:["Terminal: ",n.terminalId]},c()):null})})]}),s.error&&t.jsxs("div",{className:"bg-red-50 border border-red-200 rounded p-2.5 text-red-700",children:[t.jsx("div",{className:"text-xs font-semibold text-red-600 uppercase tracking-wide mb-1.5",children:"Error"}),t.jsx("div",{className:"text-xs",children:s.error})]}),s.tokenUsage&&t.jsxs("div",{className:"bg-gray-50 border border-gray-200 rounded p-2.5",children:[t.jsx("div",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wide mb-2",children:"Token Usage"}),t.jsxs("div",{className:"grid grid-cols-3 gap-3 text-xs text-gray-700",children:[s.tokenUsage.inputTokens!==void 0&&t.jsxs("div",{children:[t.jsx("div",{className:"text-gray-500 text-[10px] uppercase tracking-wide mb-0.5",children:"Input"}),t.jsx("div",{className:"font-medium",children:s.tokenUsage.inputTokens.toLocaleString()})]}),s.tokenUsage.outputTokens!==void 0&&t.jsxs("div",{children:[t.jsx("div",{className:"text-gray-500 text-[10px] uppercase tracking-wide mb-0.5",children:"Output"}),t.jsx("div",{className:"font-medium",children:s.tokenUsage.outputTokens.toLocaleString()})]}),s.tokenUsage.totalTokens!==void 0&&t.jsxs("div",{children:[t.jsx("div",{className:"text-gray-500 text-[10px] uppercase tracking-wide mb-0.5",children:"Total"}),t.jsx("div",{className:"font-medium",children:s.tokenUsage.totalTokens.toLocaleString()})]})]})]}),s.startedAt&&t.jsxs("div",{className:"text-xs text-gray-500",children:["Started: ",new Date(s.startedAt).toLocaleTimeString(),s.completedAt&&t.jsxs(t.Fragment,{children:[" ","| Completed:"," ",new Date(s.completedAt).toLocaleTimeString()," (",Math.round((s.completedAt-s.startedAt)/1e3),"s)"]})]})]})]})}const K=["Thinking","Pensando","Pensant","Denkend","Pensando","考えている","생각 중","思考中","Размышляя","Düşünüyor","Myślący","Tänkande","Pensando","Ajatellen","Σκεπτόμενος","חושב","सोच रहा है","Berpikir"],ie=["...","·..",".·.","..·",".·.","·.."];function _n({startTime:s}){const[e,r]=i.useState(0),[n,o]=i.useState(()=>K[Math.floor(Math.random()*K.length)]),[c,d]=i.useState(0);i.useEffect(()=>{const a=setInterval(()=>{const u=Date.now()-s;r(u)},100);return()=>clearInterval(a)},[s]),i.useEffect(()=>{const a=setInterval(()=>{const l=Math.floor(Math.random()*K.length);o(K[l])},1500);return()=>clearInterval(a)},[]),i.useEffect(()=>{const a=setInterval(()=>{d(l=>(l+1)%ie.length)},100);return()=>clearInterval(a)},[]);const f=(e/1e3).toFixed(1),p=ie[c];return t.jsxs("span",{className:"text-muted-foreground text-sm",children:[n,p," ",f,"s"]})}const On=H("w-full px-4 py-3 rounded-xl text-[var(--font-size)] font-[var(--font-family)] leading-relaxed break-words transition-colors",{variants:{role:{user:"bg-primary text-primary-foreground shadow-sm",assistant:"text-foreground",system:"bg-card border border-border text-foreground opacity-80 text-sm"},variant:{default:"",outline:"border border-border",ghost:"bg-transparent"}},defaultVariants:{role:"assistant",variant:"default"}}),Ct=i.forwardRef(({role:s,variant:e,isStreaming:r,message:n,thinkingDisplayStyle:o="collapsible",className:c,children:d,...f},p)=>{const a=S(b=>b.streamingStartTime),l=n&&!d,u=l?n.role:s||"assistant",h=l?n.isStreaming:r;let g=d;if(l){const b=n.metadata?.thinking,j=!!b,N=n.isStreaming&&!n.content&&n.role==="assistant";g=t.jsxs(t.Fragment,{children:[n.role==="assistant"&&j&&t.jsx(Nt,{content:b,isStreaming:n.isStreaming,mode:o,autoCollapse:!0}),N&&a&&t.jsxs("div",{className:"flex items-center gap-2 opacity-50",children:[t.jsx(Le,{className:"size-4 animate-spin text-muted-foreground"}),t.jsx(_n,{startTime:a})]}),n.role==="assistant"&&n.toolCalls&&n.toolCalls.length>0&&t.jsx("div",{className:"flex flex-col gap-2 mb-3",children:n.toolCalls.map(y=>t.jsx(zn,{toolCall:y},y.id))}),n.role==="user"?t.jsx("div",{className:"whitespace-pre-wrap",children:n.content}):t.jsx(jt,{content:n.content,isStreaming:n.isStreaming,showEmpty:!1})]})}return t.jsx("div",{ref:p,className:m(On({role:u,variant:e}),h&&"animate-pulse-subtle",c),...f,children:g})});Ct.displayName="MessageContent";const Fn=i.forwardRef(({className:s,children:e,...r},n)=>t.jsxs(Ie,{ref:n,className:m("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",s),...r,children:[e,t.jsx(Gt,{asChild:!0,children:t.jsx(is,{className:"h-4 w-4 opacity-50"})})]}));Fn.displayName=Ie.displayName;const St=i.forwardRef(({className:s,...e},r)=>t.jsx(Ee,{ref:r,className:m("flex cursor-default items-center justify-center py-1",s),...e,children:t.jsx(ls,{className:"h-4 w-4"})}));St.displayName=Ee.displayName;const Tt=i.forwardRef(({className:s,...e},r)=>t.jsx(Re,{ref:r,className:m("flex cursor-default items-center justify-center py-1",s),...e,children:t.jsx(te,{className:"h-4 w-4"})}));Tt.displayName=Re.displayName;const $n=i.forwardRef(({className:s,children:e,position:r="popper",...n},o)=>t.jsx(Yt,{children:t.jsxs(ke,{ref:o,className:m("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",r==="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",s),position:r,...n,children:[t.jsx(St,{}),t.jsx(Jt,{className:m("p-1",r==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:e}),t.jsx(Tt,{})]})}));$n.displayName=ke.displayName;const Bn=i.forwardRef(({className:s,...e},r)=>t.jsx(Me,{ref:r,className:m("py-1.5 pl-8 pr-2 text-sm font-semibold",s),...e}));Bn.displayName=Me.displayName;const Vn=i.forwardRef(({className:s,children:e,...r},n)=>t.jsxs(Ae,{ref:n,className:m("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",s),...r,children:[t.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:t.jsx(Xt,{children:t.jsx(De,{className:"h-4 w-4"})})}),t.jsx(Zt,{children:e})]}));Vn.displayName=Ae.displayName;const qn=i.forwardRef(({className:s,...e},r)=>t.jsx(Ue,{ref:r,className:m("-mx-1 my-1 h-px bg-muted",s),...e}));qn.displayName=Ue.displayName;const It=i.forwardRef(({task:s,collapsible:e=!0,defaultExpanded:r=!1,onTaskClick:n,className:o,...c},d)=>{const[f,p]=i.useState(r),a=!!(s.details||s.files&&s.files.length>0),l={pending:Pe,in_progress:Le,completed:cs}[s.status],u=()=>{switch(s.status){case"completed":return"text-green-500";case"in_progress":return"text-primary";default:return"text-foreground opacity-40"}},h=()=>{a&&e&&p(!f),n?.(s)};return t.jsxs("div",{ref:d,className:m("rounded-lg border border-border bg-card transition-all","hover:shadow-sm hover:border-border/80",o),...c,children:[t.jsxs("button",{type:"button",onClick:h,className:m("w-full flex items-center gap-3 px-3 py-2.5 text-left",a&&e&&"cursor-pointer"),disabled:!a&&!e,children:[t.jsx(l,{className:m("w-4 h-4 shrink-0",u(),s.status==="in_progress"&&"animate-spin")}),t.jsx("span",{className:m("flex-1 text-sm font-[var(--font-family)]",s.status==="completed"&&"line-through opacity-60",s.status==="in_progress"&&"font-medium"),children:s.text}),a&&e&&t.jsx(te,{className:m("w-4 h-4 text-foreground opacity-50 transition-transform duration-200 shrink-0",f&&"rotate-180"),"aria-hidden":"true"})]}),a&&f&&t.jsxs("div",{className:"px-3 pb-3 pt-1 border-t border-border/50 animate-fadeIn",children:[s.details&&t.jsx("p",{className:"text-sm text-foreground opacity-80 leading-relaxed mb-2",children:s.details}),s.files&&s.files.length>0&&t.jsxs("div",{className:"space-y-1",children:[t.jsx("span",{className:"text-xs font-medium text-foreground opacity-60 uppercase tracking-wide",children:"Files:"}),t.jsx("div",{className:"space-y-1",children:s.files.map(g=>t.jsx("div",{className:"text-xs font-mono text-foreground opacity-70 bg-background px-2 py-1 rounded border border-border/50",children:g},g))})]})]})]})});It.displayName="Task";const Wn=i.forwardRef(({tasks:s,collapsible:e=!0,onTaskClick:r,emptyMessage:n="No tasks yet.",className:o,...c},d)=>t.jsx("div",{ref:d,className:m("space-y-2 max-h-96 overflow-y-auto",o),...c,children:s.length===0?t.jsx("p",{className:"text-sm text-foreground opacity-60 italic py-4 text-center",children:n}):s.map(f=>t.jsx(It,{task:f,collapsible:e,...r?{onTaskClick:r}:{}},f.id))}));Wn.displayName="TaskList";const Qn=H("flex min-h-[80px] w-full rounded-md border bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 resize-none",{variants:{variant:{default:"border-input focus-visible:ring-ring",error:"border-destructive focus-visible:ring-destructive",success:"border-green-500 focus-visible:ring-green-500"}},defaultVariants:{variant:"default"}}),Kn=i.forwardRef(({className:s,autoResize:e=!1,maxHeight:r=200,variant:n,...o},c)=>{const d=i.useRef(null),f=i.useCallback(a=>{d.current=a,typeof c=="function"?c(a):c&&(c.current=a)},[c]),p=i.useCallback(()=>{const a=d.current;if(!a||!e)return;a.style.height="auto";const l=Math.min(a.scrollHeight,r);a.style.height=`${l}px`,a.scrollHeight>r?a.style.overflowY="auto":a.style.overflowY="hidden"},[e,r]);return i.useEffect(()=>{p()},[p]),t.jsx("textarea",{className:m(Qn({variant:n}),e&&"overflow-y-hidden",s),ref:f,...o})});Kn.displayName="Textarea";const O=Be("gui");function Gn({client:s}){const{connectionStatus:e,connect:r}=ys(s),{messages:n}=$e(s);ws(s);const o=S(f=>f.error);i.useEffect(()=>{O.debug("Connection status changed",{status:e}),e==="error"&&o&&O.error("Connection error occurred",{error:o})},[e,o]);const c=[],d=[{id:"model-sonnet",label:"Use Sonnet 4.5",description:"Switch to Claude Sonnet 4.5 model",icon:t.jsx(ne,{className:"h-4 w-4"}),category:"model",onSelect:()=>{O.info("User selected Sonnet 4.5 model")}},{id:"model-opus",label:"Use Opus",description:"Switch to Claude Opus model",icon:t.jsx(ne,{className:"h-4 w-4"}),category:"model",onSelect:()=>{O.info("User selected Opus model")}},{id:"settings",label:"Open Settings",description:"Configure chat preferences",icon:t.jsx(ps,{className:"h-4 w-4"}),category:"action",onSelect:()=>{O.info("User opened settings")}},{id:"code-mode",label:"Code Mode",description:"Enable code-focused responses",icon:t.jsx(ms,{className:"h-4 w-4"}),category:"mode",onSelect:()=>{O.info("User enabled code mode")}}];return t.jsxs(ct,{defaultPanelSize:"small",defaultActiveTab:"todo",children:[t.jsxs(dt,{children:[e==="error"&&o&&t.jsx("div",{className:"border-b border-red-500/20 bg-red-500/10 px-6 py-4",children:t.jsxs("div",{className:"flex items-start justify-between gap-4",children:[t.jsxs("div",{className:"flex-1",children:[t.jsx("h3",{className:"mb-1 text-sm font-semibold text-red-500",children:"Connection Error"}),t.jsx("p",{className:"whitespace-pre-line text-sm text-foreground",children:o})]}),t.jsx("button",{type:"button",onClick:r,className:"rounded-lg bg-red-500 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-red-600",children:"Retry"})]})}),t.jsxs(ut,{children:[t.jsx(ft,{className:"pt-4",children:n.length===0?t.jsx("div",{className:"flex h-full items-center justify-center",children:t.jsx("div",{className:"text-center text-muted-foreground",children:t.jsx("p",{className:"mb-2 text-lg",children:"No messages yet"})})}):t.jsx("div",{className:"flex flex-col gap-4 px-4",children:n.map((f,p)=>t.jsx(vt,{message:f,isLastMessage:p===n.length-1,children:t.jsx(Ct,{message:f,thinkingDisplayStyle:"collapsible"})},f.id))})}),t.jsx(pt,{children:t.jsxs(Xe,{client:s,children:[t.jsx(ot,{commands:d}),t.jsx(Ze,{placeholder:"Type a message or / for commands...",autoFocus:!0}),t.jsxs(tt,{children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(st,{}),t.jsx(nt,{})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(rt,{}),t.jsx(et,{children:t.jsx(ds,{className:"size-4"})})]})]})]})})]})]}),t.jsx(mt,{breakpoint:"lg",children:t.jsxs(gt,{defaultValue:"todo",className:"flex flex-col h-full",children:[t.jsxs(Y,{className:"w-full justify-start rounded-none border-b border-border bg-card px-4",children:[t.jsxs(V,{value:"todo",children:[t.jsx(us,{className:"h-4 w-4 mr-2"}),"To-Do"]}),t.jsxs(V,{value:"files",children:[t.jsx(fs,{className:"h-4 w-4 mr-2"}),"Files"]})]}),t.jsx(F,{value:"todo",className:"flex-1 p-4 mt-0",children:t.jsx(ht,{todos:c})}),t.jsx(F,{value:"files",className:"flex-1 p-4 mt-0",children:t.jsx(xt,{})})]})})]})}function Yn(){return"http://localhost:3100"}const le={agentServerUrl:Yn()},$=Be("gui");function Jn(){const[s,e]=i.useState(null),[r,n]=i.useState(null);return i.useEffect(()=>{try{$.info("Initializing ACP client",{serverUrl:le.agentServerUrl});const o=new Es({type:"http",options:{baseUrl:le.agentServerUrl}});return e(o),$.info("ACP client initialized successfully"),()=>{$.debug("Disconnecting ACP client"),o.disconnect().catch(c=>{$.error("Failed to disconnect ACP client",{error:c instanceof Error?c.message:String(c)})})}}catch(o){const c=o instanceof Error?o.message:"Failed to initialize ACP client";n(c),$.error("Failed to initialize ACP client",{error:o instanceof Error?o.message:String(o),stack:o instanceof Error?o.stack:void 0});return}},[]),r?t.jsx("div",{className:"flex items-center justify-center h-screen bg-[var(--color-bg)]",children:t.jsxs("div",{className:"text-center p-8 max-w-md",children:[t.jsx("h1",{className:"text-2xl font-bold text-red-500 mb-4",children:"Initialization Error"}),t.jsx("p",{className:"text-[var(--color-text)] mb-4",children:r}),t.jsx("p",{className:"text-sm text-[var(--color-text-secondary)]",children:"Failed to initialize the ACP client. Check the console for details."})]})}):t.jsx(Gn,{client:s})}const Et=document.getElementById("root");if(!Et)throw new Error("Root element not found");Pt.createRoot(Et).render(t.jsx(Lt.StrictMode,{children:t.jsx(Jn,{})}));
@@ -1 +1 @@
1
- import{g as i,e,f as k}from"./vendor--IKG6KWl.js";const c={};function d(s){const t=this,n=s||c,o=t.data(),r=o.micromarkExtensions||(o.micromarkExtensions=[]),a=o.fromMarkdownExtensions||(o.fromMarkdownExtensions=[]),m=o.toMarkdownExtensions||(o.toMarkdownExtensions=[]);r.push(i(n)),a.push(e()),m.push(k(n))}export{d as r};
1
+ import{g as i,e,f as k}from"./vendor-BxtqxsLB.js";const c={};function d(s){const t=this,n=s||c,o=t.data(),r=o.micromarkExtensions||(o.micromarkExtensions=[]),a=o.fromMarkdownExtensions||(o.fromMarkdownExtensions=[]),m=o.toMarkdownExtensions||(o.toMarkdownExtensions=[]);r.push(i(n)),a.push(e()),m.push(k(n))}export{d as r};