@townco/gui-template 0.1.28 → 0.1.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{acp-sdk-BiGbXeF1.js → acp-sdk-4ryhpmET.js} +1 -1
- package/dist/assets/{icons-B97fCJAR.js → icons-Cd_vS0Im.js} +1 -1
- package/dist/assets/index-BKwnhQCe.js +6 -0
- package/dist/assets/{markdown-DP5OEpQP.js → markdown-Bz1KRONC.js} +1 -1
- package/dist/assets/{radix-C1pEulHa.js → radix-R6uiGzM3.js} +1 -1
- package/dist/assets/{react-DWDN8s0r.js → react-CrKZJ-ak.js} +1 -1
- package/dist/assets/vendor-Ccy0WTO1.js +48 -0
- package/dist/index.html +7 -7
- package/package.json +4 -4
- package/src/App.tsx +8 -73
- package/dist/assets/index-EY7gwow8.js +0 -6
- package/dist/assets/vendor-BxtqxsLB.js +0 -48
- package/src/ChatView.tsx +0 -429
|
@@ -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-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
|
+
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-Ccy0WTO1.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 as s}from"./react-
|
|
1
|
+
import{r as s}from"./react-CrKZJ-ak.js";const _=o=>o.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),m=o=>o.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,a,c)=>c?c.toUpperCase():a.toLowerCase()),h=o=>{const t=m(o);return t.charAt(0).toUpperCase()+t.slice(1)},i=(...o)=>o.filter((t,a,c)=>!!t&&t.trim()!==""&&c.indexOf(t)===a).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=s.forwardRef(({color:o="currentColor",size:t=24,strokeWidth:a=2,absoluteStrokeWidth:c,className:r="",children:n,iconNode:l,...d},p)=>s.createElement("svg",{ref:p,...g,width:t,height:t,stroke:o,strokeWidth:c?Number(a)*24/Number(t):a,className:i("lucide",r),...!n&&!w(d)&&{"aria-hidden":"true"},...d},[...l.map(([y,k])=>s.createElement(y,k)),...Array.isArray(n)?n:[n]]));const e=(o,t)=>{const a=s.forwardRef(({className:c,...r},n)=>s.createElement(u,{ref:n,iconNode:t,className:i(`lucide-${_(h(o))}`,`lucide-${o}`,c),...r}));return a.displayName=h(o),a};const v=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],I=e("arrow-down",v);const x=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Z=e("arrow-up",x);const f=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],K=e("check",f);const $=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],O=e("chevron-down",$);const C=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],T=e("chevron-right",C);const M=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],X=e("chevron-up",M);const N=[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]],G=e("chevrons-up-down",N);const b=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],J=e("circle-check",b);const A=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Q=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"}]],Y=e("code",j);const q=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]],e1=e("database",q);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"}]],t1=e("file-text",z);const L=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],o1=e("link-2",L);const S=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],a1=e("loader-circle",S);const V=[["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"}]],c1=e("mic",V);const D=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}]],n1=e("panel-right",D);const H=[["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"}]],s1=e("paperclip",H);const P=[["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"}]],r1=e("settings",P);const U=[["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"}]],d1=e("sparkles",U);const E=[["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"}]],h1=e("square-check-big",E);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"}]],i1=e("square-slash",R);const W=[["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"}]],l1=e("wrench",W);const B=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],p1=e("x",B);export{I as A,T as C,e1 as D,t1 as F,o1 as L,c1 as M,s1 as P,i1 as S,l1 as W,p1 as X,h1 as a,d1 as b,r1 as c,Y as d,Z as e,X as f,n1 as g,K as h,Q as i,O as j,a1 as k,G as l,J as m};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{r as i,j as t,P as ns,e as os,f as rs,M as as,h as is,a as ls}from"./react-CrKZJ-ak.js";import{P as ve,a as cs}from"./acp-sdk-4ryhpmET.js";import{L as H,M as k,N as E,O as y,P as Re,Q as D,R,S as L,T as z,U as ds,W as X,X as ne,Y as us,Z as ps,$ as fs,a0 as ms,a1 as W,a2 as gs,a3 as Ne}from"./vendor-Ccy0WTO1.js";import{S as J,L as Ue,T as Me,C as Ae,R as hs,O as De,P as xs,a as _e,b as bs,c as Pe,D as Le,d as ze,e as Fe,f as ys,g as Oe,I as He,h as $e,i as Be,j as We,k as Ve,l as qe,m as Qe,n as Ge,o as ws,p as Ke,q as Xe,r as vs,s as Je,V as Ns,t as Ye,u as Ze,v as js,w as Ss,x as et}from"./radix-R6uiGzM3.js";import{C as tt,S as Cs,P as Ts,M as ks,A as Is,a as st,F as nt,D as ot,L as rt,b as je,c as Es,d as Rs,e as Us,f as me,g as at,X as Ms,h as it,i as lt,j as ge,W as As,k as ct,l as Ds,m as _s}from"./icons-Cd_vS0Im.js";import{r as Ps}from"./markdown-Bz1KRONC.js";(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))o(a);new MutationObserver(a=>{for(const l of a)if(l.type==="childList")for(const d of l.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&o(d)}).observe(document,{childList:!0,subtree:!0});function n(a){const l={};return a.integrity&&(l.integrity=a.integrity),a.referrerPolicy&&(l.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?l.credentials="include":a.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function o(a){if(a.ep)return;a.ep=!0;const l=n(a);fetch(a.href,l)}})();const ue=typeof process<"u"&&process.versions?.node;let Ls,zs=0;const Fs=new Set;function Os(s){for(const e of Fs)e(s)}const Se={trace:0,debug:1,info:2,warn:3,error:4,fatal:5};class Hs{service;minLevel;logFilePath;logsDir;writeQueue=[];isWriting=!1;constructor(e,n="debug"){this.service=e,this.minLevel=n,typeof process<"u"&&(this.minLevel="info")}setupFileLogging(){}async writeToFile(e){if(!(!this.logFilePath||!ue)&&(this.writeQueue.push(e),!this.isWriting)){for(this.isWriting=!0;this.writeQueue.length>0;){const o=`${this.writeQueue.splice(0,this.writeQueue.length).join(`
|
|
2
|
+
`)}
|
|
3
|
+
`;try{await require("node:fs").promises.appendFile(this.logFilePath,o,"utf-8")}catch{}}this.isWriting=!1}}shouldLog(e){return Se[e]>=Se[this.minLevel]}log(e,n,o){if(!this.shouldLog(e))return;const a={id:`log_${++zs}`,timestamp:new Date().toISOString(),level:e,service:this.service,message:n,...o&&{metadata:o}};if(Os(a),ue&&this.logFilePath,ue&&this.logFilePath){const l={timestamp:a.timestamp,level:a.level,service:a.service,message:a.message,...a.metadata&&{metadata:a.metadata}};this.writeToFile(JSON.stringify(l)).catch(()=>{})}}trace(e,n){this.log("trace",e,n)}debug(e,n){this.log("debug",e,n)}info(e,n){this.log("info",e,n)}warn(e,n){this.log("warn",e,n)}error(e,n){this.log("error",e,n)}fatal(e,n){this.log("fatal",e,n)}}function $(s,e="debug"){return new Hs(s,e)}const j=$("http-transport");class $s{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;isReceivingMessages=!1;constructor(e){this.options={...e,baseUrl:e.baseUrl.replace(/\/$/,"")}}async connect(){if(!this.connected)try{this.abortController=new AbortController;const e={protocolVersion:ve,clientCapabilities:{fs:{readTextFile:!0,writeTextFile:!0}}},n=await this.sendRpcRequest("initialize",e);j.info("ACP connection initialized",{initResponse:n});const o={cwd:"/",mcpServers:[]},a=await this.sendRpcRequest("session/new",o);this.currentSessionId=a.sessionId,j.info("Session created",{sessionId:this.currentSessionId}),await this.connectSSE(),this.connected=!0,this.reconnectAttempts=0}catch(e){this.connected=!1;const n=e instanceof Error?e:new Error(String(e));throw this.notifyError(n),n}}async loadSession(e){this.connected&&(j.warn("Transport already connected, disconnecting first",{sessionId:e}),await this.disconnect());try{this.abortController=new AbortController;const n={protocolVersion:ve,clientCapabilities:{fs:{readTextFile:!0,writeTextFile:!0}}};j.info("Loading session - initializing connection",{sessionId:e});const o=await this.sendRpcRequest("initialize",n);if(!o.agentCapabilities?.loadSession)throw j.error("Agent does not support loading sessions",{capabilities:o.agentCapabilities}),new Error("Agent does not support loading sessions");j.info("ACP connection initialized, loading session",{sessionId:e,capabilities:o.agentCapabilities}),this.currentSessionId=e,await this.connectSSE();const a={sessionId:e,cwd:"/",mcpServers:[]};j.info("Sending session/load request",{loadRequest:a});const l=await this.sendRpcRequest("session/load",a);j.info("Session loaded successfully",{sessionId:this.currentSessionId,loadResponse:l}),this.connected=!0,this.reconnectAttempts=0}catch(n){this.connected=!1;const o=n instanceof Error?n:new Error(String(n));throw j.error("Failed to load session",{sessionId:e,error:o.message,stack:o.stack}),this.notifyError(o),o}}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 n=e instanceof Error?e:new Error(String(e));throw this.notifyError(n),n}}async send(e){if(!this.connected||!this.currentSessionId)throw new Error("Transport not connected");try{this.streamComplete=!1,this.messageQueue=[];const n=e.content.filter(d=>d.type==="text").map(d=>d.text).join(`
|
|
4
|
+
`),o={sessionId:this.currentSessionId,prompt:[{type:"text",text:n}]},a=await this.sendRpcRequest("session/prompt",o);j.debug("Prompt sent",{promptResponse:a}),this.streamComplete=!0;const l=this.chunkResolvers.shift();l?l({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(n){this.streamComplete=!0;const o=n instanceof Error?n:new Error(String(n));throw this.notifyError(o),o}}async*receive(){this.isReceivingMessages=!0;try{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(n=>{this.chunkResolvers.push(n)});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}}finally{this.isReceivingMessages=!1}}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,n){const a={jsonrpc:"2.0",id:this.generateRequestId(),method:e,params:n};j.debug("Sending RPC request",{method:e,params:n,request:a});const l={"Content-Type":"application/json",...this.options.headers},d=this.options.timeout??600*1e3,p=new AbortController,u=setTimeout(()=>p.abort(),d);try{const r=await fetch(`${this.options.baseUrl}/rpc`,{method:"POST",headers:l,body:JSON.stringify(a),signal:p.signal});if(clearTimeout(u),!r.ok){const f=await r.text();throw new Error(`HTTP ${r.status}: ${f}`)}const c=await r.json();if(c.error)throw new Error(`ACP error: ${c.error.message||JSON.stringify(c.error)}`);return c.result||c}catch(r){throw clearTimeout(u),r instanceof Error&&r.name==="AbortError"?new Error(`Request timeout after ${d}ms`):r}}async connectSSE(){if(!this.currentSessionId)throw new Error("Cannot connect SSE without a session ID");const e=`${this.options.baseUrl}/events`,n={"X-Session-ID":this.currentSessionId,...this.options.headers};this.sseAbortController=new AbortController;try{const o=await fetch(e,{method:"GET",headers:n,signal:this.sseAbortController.signal});if(!o.ok)throw new Error(`SSE connection failed: HTTP ${o.status}`);if(!o.body)throw new Error("Response body is null");j.debug("SSE connection opened"),this.reconnectAttempts=0,this.reconnectDelay=1e3;const a=o.body.getReader(),l=new TextDecoder;let d="";(async()=>{try{for(;;){const{done:p,value:u}=await a.read();if(p){j.debug("SSE stream closed by server"),this.connected&&await this.handleSSEDisconnect();break}d+=l.decode(u,{stream:!0});const r=d.split(`
|
|
5
|
+
`);d=r.pop()||"";let c={event:"message",data:""};for(const f of r)f.startsWith("event:")?c.event=f.substring(6).trim():f.startsWith("data:")?c.data=f.substring(5).trim():f===""&&(c.event==="message"&&c.data&&this.handleSSEMessage(c.data),c={event:"message",data:""})}}catch(p){if(p instanceof Error&&p.name==="AbortError"){j.debug("SSE stream aborted");return}j.error("Error reading SSE stream",{error:p}),this.connected&&!this.reconnecting&&await this.handleSSEDisconnect()}})()}catch(o){throw j.error("SSE connection error",{error:o}),o}}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 n=new Error(`SSE reconnection failed after ${this.maxReconnectAttempts} attempts`);this.notifyError(n),this.connected=!1,this.reconnecting=!1;return}this.reconnectAttempts++;const e=Math.min(this.reconnectDelay*2**(this.reconnectAttempts-1),32e3);j.debug("SSE reconnecting",{delay:e,attempt:this.reconnectAttempts,maxAttempts:this.maxReconnectAttempts}),await new Promise(n=>setTimeout(n,e));try{await this.connectSSE(),j.info("SSE reconnected successfully"),this.reconnecting=!1}catch(n){j.error("SSE reconnection failed",{error:n}),this.reconnecting=!1}}handleSSEMessage(e){try{const n=JSON.parse(e);j.debug("Received SSE message",{message:n});const o=cs.safeParse(n);if(!o.success){j.error("Invalid ACP message from SSE",{issues:o.error.issues});return}const a=o.data;j.debug("Parsed ACP message",{method:"method"in a?a.method:"(no method)"}),"method"in a&&a.method==="session/update"&&(j.debug("Received session/update notification"),"params"in a&&a.params&&(j.debug("Calling handleSessionNotification",{params:a.params}),this.handleSessionNotification(a.params)))}catch(n){j.error("Error parsing SSE message",{error:n}),this.notifyError(n instanceof Error?n:new Error(String(n)))}}handleSessionNotification(e){j.debug("handleSessionNotification called",{params:e});const o=e.update,a=this.currentSessionId||e.sessionId;if(j.debug("Update session type",{sessionUpdate:o?.sessionUpdate}),o?.sessionUpdate==="tool_call"){j.debug("Tool call notification",{tokenUsage:o.tokenUsage});const l=o._meta&&typeof o._meta=="object"&&"messageId"in o._meta?String(o._meta.messageId):void 0,d={id:o.toolCallId??"",title:o.title??"",kind:o.kind||"other",status:o.status||"pending",locations:o.locations,rawInput:o.rawInput,tokenUsage:o.tokenUsage,content:o.content?.map(u=>{if(typeof u!="object"||u===null)return{type:"text",text:""};const r=u;if(r.type==="content"&&typeof r.content=="object"&&r.content!==null){const c=r.content;if(c.type==="text")return{type:"content",content:{type:"text",text:typeof c.text=="string"?c.text:""}}}return r.type==="text"?{type:"text",text:typeof r.text=="string"?r.text:""}:r.type==="diff"?{type:"diff",path:typeof r.path=="string"?r.path:"",oldText:typeof r.oldText=="string"?r.oldText:"",newText:typeof r.newText=="string"?r.newText:"",line:typeof r.line=="number"?r.line:null}:r.type==="terminal"?{type:"terminal",terminalId:typeof r.terminalId=="string"?r.terminalId:""}:{type:"text",text:""}}),startedAt:Date.now()},p={type:"tool_call",sessionId:a,status:"active",toolCall:d,messageId:l};this.notifySessionUpdate(p)}else if(o?.sessionUpdate==="tool_call_update"){const l=o._meta&&typeof o._meta=="object"&&"messageId"in o._meta?String(o._meta.messageId):void 0,d={id:o.toolCallId??"",status:o.status,locations:o.locations,rawOutput:o.rawOutput,tokenUsage:o.tokenUsage,content:o.content?.map(u=>{if(typeof u!="object"||u===null)return{type:"text",text:""};const r=u;if(r.type==="content"&&typeof r.content=="object"&&r.content!==null){const c=r.content;if(c.type==="text")return{type:"content",content:{type:"text",text:typeof c.text=="string"?c.text:""}}}return r.type==="text"?{type:"text",text:typeof r.text=="string"?r.text:""}:r.type==="diff"?{type:"diff",path:typeof r.path=="string"?r.path:"",oldText:typeof r.oldText=="string"?r.oldText:"",newText:typeof r.newText=="string"?r.newText:"",line:typeof r.line=="number"?r.line:null}:r.type==="terminal"?{type:"terminal",terminalId:typeof r.terminalId=="string"?r.terminalId:""}:{type:"text",text:""}}),error:o.error,completedAt:o.status==="completed"||o.status==="failed"?Date.now():void 0},p={type:"tool_call_update",sessionId:a,status:"active",toolCallUpdate:d,messageId:l};j.debug("Notifying tool_call_update session update",{sessionUpdate:p}),this.notifySessionUpdate(p)}else if(o&&"sessionUpdate"in o&&o.sessionUpdate==="tool_output"){const l=o,d=l._meta&&typeof l._meta=="object"&&"messageId"in l._meta?String(l._meta.messageId):void 0,p={id:l.toolCallId??"",rawOutput:l.rawOutput,content:l.content?.map(r=>{if(typeof r!="object"||r===null)return{type:"text",text:""};const c=r;if(c.type==="content"&&typeof c.content=="object"&&c.content!==null){const f=c.content;if(f.type==="text")return{type:"content",content:{type:"text",text:typeof f.text=="string"?f.text:""}}}return c.type==="text"?{type:"text",text:typeof c.text=="string"?c.text:""}:c.type==="diff"?{type:"diff",path:typeof c.path=="string"?c.path:"",oldText:typeof c.oldText=="string"?c.oldText:"",newText:typeof c.newText=="string"?c.newText:"",line:typeof c.line=="number"?c.line:null}:c.type==="terminal"?{type:"terminal",terminalId:typeof c.terminalId=="string"?c.terminalId:""}:{type:"text",text:""}})},u={type:"tool_call_update",sessionId:a,status:"active",toolCallUpdate:p,messageId:d};j.debug("Notifying tool_output as tool_call_update",{sessionUpdate:u}),this.notifySessionUpdate(u)}else if(o?.sessionUpdate==="agent_message_chunk"){const l={type:"generic",sessionId:a,status:"active"},d=o._meta&&typeof o._meta=="object"&&"tokenUsage"in o._meta?o._meta.tokenUsage:void 0;j.debug("Agent message chunk",{tokenUsage:d});const p=o.content;if(p&&typeof p=="object"){const u=p;let r=null;if(u.type==="text"&&typeof u.text=="string"&&(r={id:e.sessionId,role:"assistant",contentDelta:{type:"text",text:u.text},tokenUsage:d,isComplete:!1}),r){const c=this.chunkResolvers.shift();c?c(r):this.messageQueue.push(r)}if(r&&typeof u.text=="string"&&!this.isReceivingMessages){const c={type:"generic",sessionId:a,status:"active",message:{id:`msg_${Date.now()}_assistant`,role:"assistant",content:[{type:"text",text:u.text}],timestamp:new Date().toISOString()}};this.notifySessionUpdate(c)}}this.notifySessionUpdate(l)}else if(o?.sessionUpdate==="user_message_chunk"){j.debug("Received user_message_chunk",{update:o});const l=o.content;if(l&&typeof l=="object"){const d=l;if(d.type==="text"&&typeof d.text=="string"){const p={type:"generic",sessionId:a,status:"active",message:{id:`msg_${Date.now()}_user`,role:"user",content:[{type:"text",text:d.text}],timestamp:new Date().toISOString()}};j.debug("Notifying session update for user message"),this.notifySessionUpdate(p)}}}else{const l={type:"generic",sessionId:a,status:"active"};this.notifySessionUpdate(l)}}generateRequestId(){return`req-${Date.now()}-${Math.random().toString(36).substring(2,9)}`}notifySessionUpdate(e){for(const n of this.sessionUpdateCallbacks)try{n(e)}catch(o){j.error("Error in session update callback",{error:o})}}notifyError(e){for(const n of this.errorCallbacks)try{n(e)}catch(o){j.error("Error in error callback",{error:o})}}}class Bs{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 Ws{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)}}}const pe=$("acp-client","debug");class Vs{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(n=>{pe.error("Failed to auto-connect",{error:n instanceof Error?n.message:String(n)})})}async connect(){await this.transport.connect()}async disconnect(){await this.transport.disconnect(),this.currentSessionId=null}isConnected(){return this.transport.isConnected()}async startSession(e){const n="currentSessionId"in this.transport?this.transport.currentSessionId:void 0;if(n){const d=new Date().toISOString(),p={id:n,status:"connected",config:e?{...e,agentPath:e.agentPath||""}:{agentPath:""},messages:[],metadata:{startedAt:d}};return this.sessions.set(n,p),this.currentSessionId=n,n}const o=this.generateSessionId(),a=new Date().toISOString(),l={id:o,status:"connecting",config:e?{...e,agentPath:e.agentPath||""}:{agentPath:""},messages:[],metadata:{startedAt:a}};return this.sessions.set(o,l),this.currentSessionId=o,this.updateSessionStatus(o,"connected"),o}async loadSession(e,n){if(!this.transport.loadSession)throw new Error("Transport does not support loading sessions");const o=new Date().toISOString(),a={id:e,status:"connecting",config:n?{...n,agentPath:n.agentPath||""}:{agentPath:""},messages:[],metadata:{startedAt:o}};return this.sessions.set(e,a),this.currentSessionId=e,await this.transport.loadSession(e),this.updateSessionStatus(e,"connected"),e}async sendMessage(e,n){const o=n||this.currentSessionId;if(!o)throw new Error("No active session. Start a session first.");if(!this.transport.isConnected())throw new Error("Transport not connected");const a=this.sessions.get(o);if(!a)throw new Error(`Session ${o} not found`);const l={id:this.generateMessageId(),role:"user",content:[{type:"text",text:e}],timestamp:new Date().toISOString()};a.messages.push(l),this.updateSessionStatus(o,"active"),await this.transport.send(l)}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 Bs(this.config.options);case"http":return new $s(this.config.options);case"websocket":return new Ws(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 n=this.sessions.get(e.sessionId);n&&(e.status&&(n.status=e.status),e.message&&n.messages.push(e.message),e.error&&(n.error=e.error))}for(const n of this.sessionUpdateHandlers)try{n(e)}catch(o){pe.error("Error in session update handler",{error:o instanceof Error?o.message:String(o)})}}handleError(e){for(const n of this.errorHandlers)try{n(e)}catch(o){pe.error("Error in error handler",{error:o instanceof Error?o.message:String(o)})}}updateSessionStatus(e,n){const o=this.sessions.get(e);o&&(o.status=n,this.handleSessionUpdate({sessionId:e,status:n}))}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 V=$("acp-client-hook");function qs(s){const[e,n]=i.useState(null),[o,a]=i.useState(null),[l,d]=i.useState(null);return i.useEffect(()=>{const u=new URLSearchParams(window.location.search).get("session");u&&(V.info("Session ID found in URL",{sessionId:u}),d(u));try{V.info("Initializing ACP client",{serverUrl:s.serverUrl});const r=new Vs({type:"http",options:{baseUrl:s.serverUrl}});return n(r),V.info("ACP client initialized successfully"),()=>{V.debug("Disconnecting ACP client"),r.disconnect().catch(c=>{V.error("Failed to disconnect ACP client",{error:c instanceof Error?c.message:String(c)})})}}catch(r){const c=r instanceof Error?r.message:"Failed to initialize ACP client";a(c),V.error("Failed to initialize ACP client",{error:r instanceof Error?r.message:String(r),stack:r instanceof Error?r.stack:void 0});return}},[s.serverUrl]),{client:e,error:o,sessionId:l}}const dt=H(["pending","in_progress","completed","failed"]),Qs=H(["read","edit","delete","move","search","execute","think","fetch","switch_mode","other"]),ut=k({path:y(),line:E().nullable().optional()}),he=k({inputTokens:E().optional(),outputTokens:E().optional(),totalTokens:E().optional()}),pt=Re("type",[k({type:D("content"),content:k({type:D("text"),text:y()})}),k({type:D("text"),text:y()}),k({type:D("diff"),path:y(),oldText:y(),newText:y(),line:E().nullable().optional()}),k({type:D("terminal"),terminalId:y()})]),ft=k({id:y(),title:y(),kind:Qs,status:dt,contentPosition:E().optional(),locations:R(ut).optional(),rawInput:L(y(),z()).optional(),rawOutput:L(y(),z()).optional(),content:R(pt).optional(),error:y().optional(),startedAt:E().optional(),completedAt:E().optional(),tokenUsage:he.optional()}),Gs=k({id:y(),status:dt.optional(),locations:R(ut).optional(),rawOutput:L(y(),z()).optional(),content:R(pt).optional(),error:y().optional(),completedAt:E().optional(),tokenUsage:he.optional()});function Ce(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 q=$("chat-store","debug"),C=ds(s=>({connectionStatus:"disconnected",sessionId:null,error:null,messages:[],isStreaming:!1,streamingStartTime:null,toolCalls:{},totalBilled:{inputTokens:0,outputTokens:0,totalTokens:0},currentContext:{inputTokens:0,outputTokens:0,totalTokens:0},currentModel:"claude-sonnet-4-5-20250929",tokenDisplayMode:"context",logs:[],activeTab:"chat",input:{value:"",isSubmitting:!1,attachedFiles:[]},setConnectionStatus:e=>s({connectionStatus:e}),setSessionId:e=>s({sessionId:e}),setError:e=>s({error:e}),addMessage:e=>s(n=>({messages:[...n.messages,e]})),updateMessage:(e,n)=>s(o=>{const a=o.messages.find(r=>r.id===e);let l=o.totalBilled,d=o.currentContext,p=n;if(n.tokenUsage){const r=a?.tokenUsage;q.debug("updateMessage: incoming tokenUsage",{incoming:n.tokenUsage,existing:r});const c={inputTokens:Math.max(n.tokenUsage.inputTokens??0,r?.inputTokens??0),outputTokens:Math.max(n.tokenUsage.outputTokens??0,r?.outputTokens??0),totalTokens:Math.max(n.tokenUsage.inputTokens??0,r?.inputTokens??0)+Math.max(n.tokenUsage.outputTokens??0,r?.outputTokens??0)};q.debug("updateMessage: merged tokenUsage",{merged:c}),p={...n,tokenUsage:c};const f=c.inputTokens-(r?.inputTokens??0),x=c.outputTokens-(r?.outputTokens??0),w=c.totalTokens-(r?.totalTokens??0);l={inputTokens:o.totalBilled.inputTokens+f,outputTokens:o.totalBilled.outputTokens+x,totalTokens:o.totalBilled.totalTokens+w},d={inputTokens:c.inputTokens,outputTokens:o.currentContext.outputTokens+x,totalTokens:c.totalTokens}}const u=o.messages.map(r=>r.id===e?{...r,...p}:r);if(n.tokenUsage&&p.tokenUsage){const r=a?.tokenUsage,c=p.tokenUsage,f=(c.inputTokens??0)-(r?.inputTokens??0),x=(c.outputTokens??0)-(r?.outputTokens??0),w=(c.totalTokens??0)-(r?.totalTokens??0),g=u.filter(b=>b.tokenUsage).map(b=>({id:b.id,role:b.role,tokens:b.tokenUsage})),h=u.reduce((b,N)=>({inputTokens:b.inputTokens+(N.tokenUsage?.inputTokens??0),outputTokens:b.outputTokens+(N.tokenUsage?.outputTokens??0),totalTokens:b.totalTokens+(N.tokenUsage?.totalTokens??0)}),{inputTokens:0,outputTokens:0,totalTokens:0}),v=h.inputTokens===l.inputTokens&&h.outputTokens===l.outputTokens&&h.totalTokens===l.totalTokens;q.debug("updateMessage: tokenUsage update",{messageId:e,updates:n.tokenUsage,existing:r,messageMax:c,delta:{inputDelta:f,outputDelta:x,totalDelta:w},totalBilled:l,currentContext:d,actualSum:h,billedCorrect:v?"✅":"❌",messageCount:u.length,messagesWithTokens:g.length,breakdown:g})}return{messages:u,totalBilled:l,currentContext:d}}),clearMessages:()=>s({messages:[]}),setIsStreaming:e=>s({isStreaming:e}),setStreamingStartTime:e=>s({streamingStartTime:e}),addToolCall:(e,n)=>s(o=>({toolCalls:{...o.toolCalls,[e]:[...o.toolCalls[e]||[],n]}})),addToolCallToCurrentMessage:e=>s(n=>{const o=n.messages.findLastIndex(u=>u.role==="assistant");if(o===-1)return q.warn("No assistant message found to add tool call to"),n;const a=[...n.messages],l=a[o];if(!l)return n;const d=l.content.length,p={...e,contentPosition:d};return a[o]={...l,toolCalls:[...l.toolCalls||[],p]},{messages:a}}),updateToolCallInCurrentMessage:e=>s(n=>{const o=n.messages.findLastIndex(c=>c.role==="assistant");if(o===-1)return q.warn("No assistant message found to update tool call in"),n;const a=[...n.messages],l=a[o];if(!l)return n;const d=l.toolCalls||[],p=d.findIndex(c=>c.id===e.id);if(p===-1)return q.warn(`Tool call ${e.id} not found in message`),n;const u=d[p];if(!u)return n;const r=[...d];return r[p]=Ce(u,e),a[o]={...l,toolCalls:r},{messages:a}}),updateToolCall:(e,n)=>s(o=>{const a=o.toolCalls[e]||[],l=a.findIndex(u=>u.id===n.id);if(l===-1)return o;const d=a[l];if(!d)return o;const p=[...a];return p[l]=Ce(d,n),{toolCalls:{...o.toolCalls,[e]:p}}}),setInputValue:e=>s(n=>({input:{...n.input,value:e}})),setInputSubmitting:e=>s(n=>({input:{...n.input,isSubmitting:e}})),addFileAttachment:e=>s(n=>({input:{...n.input,attachedFiles:[...n.input.attachedFiles,e]}})),removeFileAttachment:e=>s(n=>({input:{...n.input,attachedFiles:n.input.attachedFiles.filter((o,a)=>a!==e)}})),clearInput:()=>s(e=>({input:{value:"",isSubmitting:!1,attachedFiles:[]}})),addTokenUsage:e=>s(n=>({totalBilled:{inputTokens:n.totalBilled.inputTokens+(e.inputTokens??0),outputTokens:n.totalBilled.outputTokens+(e.outputTokens??0),totalTokens:n.totalBilled.totalTokens+(e.totalTokens??0)},currentContext:{inputTokens:e.inputTokens??n.currentContext.inputTokens,outputTokens:n.currentContext.outputTokens+(e.outputTokens??0),totalTokens:(e.inputTokens??n.currentContext.inputTokens)+(n.currentContext.outputTokens+(e.outputTokens??0))}})),setCurrentModel:e=>s({currentModel:e}),resetTokens:()=>s({totalBilled:{inputTokens:0,outputTokens:0,totalTokens:0},currentContext:{inputTokens:0,outputTokens:0,totalTokens:0}}),cycleTokenDisplayMode:()=>s(e=>{const n=["context","input","output"],a=(n.indexOf(e.tokenDisplayMode)+1)%n.length,l=n[a];return l?{tokenDisplayMode:l}:e}),addLog:e=>s(n=>({logs:[...n.logs,e]})),clearLogs:()=>s({logs:[]}),setActiveTab:e=>s({activeTab:e})})),fe=$("use-chat-messages","debug");function mt(s){const e=C(c=>c.messages),n=C(c=>c.isStreaming),o=C(c=>c.sessionId),a=C(c=>c.setIsStreaming),l=C(c=>c.setStreamingStartTime),d=C(c=>c.addMessage),p=C(c=>c.updateMessage),u=C(c=>c.setError),r=i.useCallback(async c=>{if(!s){fe.error("No client available"),u("No client available");return}if(!o){fe.error("No active session"),u("No active session");return}try{const f=Date.now();a(!0),l(f);const x={id:`msg_${Date.now()}_user`,role:"user",content:c,timestamp:new Date().toISOString(),isStreaming:!1};d(x);const w=`msg_${Date.now()}_assistant`,g={id:w,role:"assistant",content:"",timestamp:new Date().toISOString(),isStreaming:!0,streamingStartTime:f};d(g);const h=s.receiveMessages();s.sendMessage(c,o).catch(b=>{const N=b instanceof Error?b.message:String(b);u(N),a(!1),l(null)});let v="";for await(const b of h)if(b.tokenUsage&&fe.debug("chunk.tokenUsage",{tokenUsage:b.tokenUsage}),b.isComplete){p(w,{content:v,isStreaming:!1,streamingStartTime:void 0,...b.tokenUsage?{tokenUsage:b.tokenUsage}:{}}),a(!1),l(null);break}else b.contentDelta.type==="text"&&(v+=b.contentDelta.text,p(w,{content:v,...b.tokenUsage?{tokenUsage:b.tokenUsage}:{}}),await new Promise(N=>setTimeout(N,16)))}catch(f){const x=f instanceof Error?f.message:String(f);u(x),a(!1),l(null)}},[s,o,d,p,a,l,u]);return{messages:e,isStreaming:n,sendMessage:r}}const Ks=$("use-chat-input","debug");function Xs(s){const e=C(f=>f.input),n=C(f=>f.setInputValue),o=C(f=>f.setInputSubmitting),a=C(f=>f.addFileAttachment),l=C(f=>f.removeFileAttachment),{sendMessage:d}=mt(s),p=i.useCallback(f=>{n(f)},[n]),u=i.useCallback(async()=>{if(!e.value.trim()||e.isSubmitting)return;const f=e.value;n(""),o(!0);try{await d(f)}catch(x){Ks.error("Failed to send message",{error:x instanceof Error?x.message:String(x)})}finally{o(!1)}},[e,n,o,d]),r=i.useCallback(f=>{a(f)},[a]),c=i.useCallback(f=>{l(f)},[l]);return{value:e.value,isSubmitting:e.isSubmitting,attachedFiles:e.attachedFiles,onChange:p,onSubmit:u,onAttachFile:r,onRemoveFile:c}}const Q=$("use-chat-session","debug");function Js(s,e){const n=C(g=>g.connectionStatus),o=C(g=>g.sessionId),a=C(g=>g.setConnectionStatus),l=C(g=>g.setSessionId),d=C(g=>g.setError),p=C(g=>g.clearMessages),u=C(g=>g.resetTokens),r=C(g=>g.addMessage);i.useEffect(()=>s?s.onSessionUpdate(h=>{if(h.message&&(Q.debug("Session update with message",{message:h.message}),h.message.role!=="tool")){const v={id:h.message.id,role:h.message.role,content:h.message.content.map(b=>b.type==="text"?b.text:"").join(""),timestamp:h.message.timestamp,isStreaming:!1};r(v)}}):void 0,[s,r]);const c=i.useCallback(async()=>{if(!s){d("No client available");return}try{a("connecting"),d(null),await s.connect(),a("connected")}catch(g){Q.error("Failed to connect",{error:g instanceof Error?g.message:String(g)});const h=g instanceof Error?g.message:String(g);d(h),a("error")}},[s,a,d]),f=i.useCallback(async g=>{if(!s){d("No client available");return}try{a("connecting"),d(null);const h=await s.loadSession(g);l(h),a("connected"),u(),Q.info("Session loaded successfully",{sessionId:h})}catch(h){Q.warn("Failed to load session, creating new one instead",{sessionId:g,error:h instanceof Error?h.message:String(h)});try{await c();const v=await s.startSession();if(l(v),p(),u(),typeof window<"u"){const b=new URL(window.location.href);b.searchParams.set("session",v),window.history.replaceState({},"",b.toString())}Q.info("Created new session after failed load",{sessionId:v})}catch(v){const b=v instanceof Error?v.message:String(v);d(`Failed to load or create session: ${b}`),a("error")}}},[s,a,l,d,p,u,c]),x=i.useCallback(async()=>{if(!s){d("No client available");return}try{const g=await s.startSession();if(l(g),p(),u(),typeof window<"u"){const h=new URL(window.location.href);h.searchParams.set("session",g),window.history.pushState({},"",h.toString())}}catch(g){const h=g instanceof Error?g.message:String(g);d(h)}},[s,l,d,p,u]),w=i.useCallback(async()=>{if(s)try{await s.disconnect(),a("disconnected"),l(null)}catch(g){const h=g instanceof Error?g.message:String(g);d(h)}},[s,a,l,d]);return i.useEffect(()=>{!s||n!=="disconnected"||(e?(Q.info("Loading initial session from URL",{sessionId:e}),f(e)):c())},[s,n,e,c,f]),i.useEffect(()=>{n==="connected"&&!o&&!e&&x()},[n,o,e,x]),{connectionStatus:n,sessionId:o,connect:c,loadSession:f,startSession:x,disconnect:w}}function Ys(s){const e=C(d=>d.toolCalls),n=C(d=>d.addToolCall),o=C(d=>d.updateToolCall),a=C(d=>d.addToolCallToCurrentMessage),l=C(d=>d.updateToolCallInCurrentMessage);return i.useEffect(()=>{if(!s)return;const d=s.onSessionUpdate(p=>{p.type==="tool_call"?(n(p.sessionId,p.toolCall),a(p.toolCall)):p.type==="tool_call_update"&&(o(p.sessionId,p.toolCallUpdate),l(p.toolCallUpdate))});return()=>{d()}},[s,n,o,a,l]),{toolCalls:e,getToolCallsForSession:d=>{const p=e[d];return p&&p.length>0?p:Object.values(e).flat()}}}const Zs=k({id:y(),role:H(["user","assistant","system"]),content:y(),timestamp:ne(),isStreaming:X().default(!1),streamingStartTime:E().optional(),metadata:L(y(),z()).optional(),toolCalls:R(ft).optional(),tokenUsage:he.optional()}),en=k({value:y(),isSubmitting:X(),attachedFiles:R(k({name:y(),path:y(),size:E(),mimeType:y()}))});k({sessionId:y().nullable(),isConnected:X(),isStreaming:X(),messages:R(Zs),input:en,error:y().nullable()});H(["disconnected","connecting","connected","error"]);const tn=k({name:y(),description:y().optional(),parameters:L(y(),z()).optional()}),sn=k({name:y(),description:y(),parameters:L(y(),z()),required:R(y()).optional()}),nn=k({name:y(),version:y().optional(),description:y().optional(),author:y().optional(),capabilities:R(tn).optional(),tools:R(sn).optional(),supportedFormats:R(y()).optional()}),on=H(["initializing","ready","busy","error","terminated"]);k({status:on,info:nn.optional(),pid:E().optional(),error:y().optional(),uptime:E().optional()});const gt=H(["user","assistant","system","tool"]),rn=H(["text","image","file","tool_call","tool_result"]),Y=k({type:rn}),an=Y.extend({type:D("text"),text:y()}),ln=Y.extend({type:D("image"),url:y().url().optional(),data:y().optional(),mimeType:y().optional()}),cn=Y.extend({type:D("file"),name:y(),path:y().optional(),url:y().url().optional(),mimeType:y(),size:E().optional()}),dn=Y.extend({type:D("tool_call"),id:y(),name:y(),arguments:L(y(),z())}),un=Y.extend({type:D("tool_result"),callId:y(),result:z(),error:y().optional()}),ht=Re("type",[an,ln,cn,dn,un]),xt=k({id:y(),role:gt,content:R(ht),timestamp:ne(),metadata:L(y(),z()).optional()});k({id:y(),role:gt,contentDelta:ht,isComplete:X(),tokenUsage:k({inputTokens:E().optional(),outputTokens:E().optional(),totalTokens:E().optional()}).optional()});const bt=H(["idle","connecting","connected","active","streaming","error","disconnected"]),pn=k({agentPath:y(),agentArgs:R(y()).optional(),environment:L(y(),y()).optional(),workingDirectory:y().optional(),timeout:E().optional()}),fn=k({agentName:y().optional(),agentVersion:y().optional(),capabilities:R(y()).optional(),startedAt:ne(),lastActivityAt:ne().optional()});k({id:y(),status:bt,config:pn,metadata:fn.optional(),messages:R(xt),error:y().optional()});const oe=k({sessionId:y(),status:bt.optional(),message:xt.optional(),error:y().optional()}),mn=oe.extend({type:D("tool_call"),toolCall:ft,messageId:y().optional()}),gn=oe.extend({type:D("tool_call_update"),toolCallUpdate:Gs,messageId:y().optional()}),hn=oe.extend({type:D("tool_output"),toolOutput:k({id:y(),content:R(us()).optional(),rawOutput:L(y(),z()).optional()}),messageId:y().optional()}),xn=oe.extend({type:D("generic").optional()});ps([mn,gn,hn,xn]);function m(...s){return fs(ms(s))}const bn=W("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 cursor-pointer",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary-hover",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive-hover",outline:"border border-input bg-background hover:bg-accent-hover hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary-hover",ghost:"hover:bg-accent-hover 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"}}),Z=i.forwardRef(({className:s,variant:e,size:n,asChild:o=!1,...a},l)=>{const d=o?J:"button";return t.jsx(d,{className:m(bn({variant:e,size:n,className:s})),ref:l,...a})});Z.displayName="Button";const yn=i.forwardRef(({className:s,...e},n)=>t.jsx("div",{ref:n,className:m("rounded-lg border bg-card text-card-foreground shadow-sm",s),...e}));yn.displayName="Card";const wn=i.forwardRef(({className:s,...e},n)=>t.jsx("div",{ref:n,className:m("flex flex-col space-y-1.5 p-6",s),...e}));wn.displayName="CardHeader";const vn=i.forwardRef(({className:s,...e},n)=>t.jsx("div",{ref:n,className:m("text-2xl font-semibold leading-none tracking-tight",s),...e}));vn.displayName="CardTitle";const Nn=i.forwardRef(({className:s,...e},n)=>t.jsx("div",{ref:n,className:m("text-sm text-muted-foreground",s),...e}));Nn.displayName="CardDescription";const jn=i.forwardRef(({className:s,...e},n)=>t.jsx("div",{ref:n,className:m("p-6 pt-0",s),...e}));jn.displayName="CardContent";const Sn=i.forwardRef(({className:s,...e},n)=>t.jsx("div",{ref:n,className:m("flex items-center p-6 pt-0",s),...e}));Sn.displayName="CardFooter";const yt=i.forwardRef(({title:s,description:e,guideUrl:n,guideText:o="Guide",suggestedPrompts:a=[],onPromptClick:l,onGuideClick:d,className:p,...u},r)=>{const c=w=>{l?.(w)},f=()=>{n&&window.open(n,"_blank","noopener,noreferrer"),d?.()},x=[];for(let w=0;w<a.length;w+=2)x.push(a.slice(w,w+2));return t.jsxs("div",{ref:r,className:m("flex flex-col items-start gap-6",p),...u,children:[t.jsx("h3",{className:"text-heading-3 text-text-primary hidden lg:block",children:s}),t.jsx("p",{className:"text-subheading text-text-secondary max-w-prose",children:e}),(n||d)&&t.jsxs("button",{type:"button",onClick:f,className:"flex items-center gap-2 px-3 py-1.5 rounded-lg hover:bg-accent transition-colors",children:[t.jsx("span",{className:"text-sm font-medium leading-normal text-text-primary",children:o}),t.jsx(tt,{className:"size-4 text-text-primary"})]}),a.length>0&&t.jsxs("div",{className:"flex flex-col gap-3 w-full max-w-prompt-container",children:[t.jsx("p",{className:"text-label text-text-tertiary",children:"Suggested Prompts"}),t.jsx("div",{className:"flex flex-col gap-2.5",children:x.map(w=>t.jsx("div",{className:"flex gap-2.5 items-center",children:w.map(g=>t.jsx("button",{type:"button",onClick:()=>c(g),className:"flex-1 flex items-start gap-2 p-3 bg-secondary hover:bg-secondary/80 rounded-2xl transition-colors min-w-0",children:t.jsx("span",{className:"text-base font-normal leading-normal text-text-tertiary truncate",children:g})},g))},w.join("-")))})]})]})});yt.displayName="ChatEmptyState";const wt=i.createContext(void 0),xe=()=>{const s=i.useContext(wt);if(!s)throw new Error("ChatHeader components must be used within ChatHeader.Root");return s},vt=i.forwardRef(({defaultExpanded:s=!1,expanded:e,onExpandedChange:n,className:o,children:a,...l},d)=>{const[p,u]=i.useState(s),r=e??p,c=i.useCallback(g=>{u(g),n?.(g)},[n]),f=i.Children.toArray(a),x=f.find(g=>i.isValidElement(g)&&typeof g.type=="function"&&g.type.displayName==="ChatHeader.ExpandablePanel"),w=f.filter(g=>g!==x);return t.jsxs(wt.Provider,{value:{isExpanded:r,setIsExpanded:c},children:[t.jsx("div",{ref:d,className:m("flex items-center justify-between px-6 py-4",o),...l,children:w}),x]})});vt.displayName="ChatHeader.Root";const Cn=i.forwardRef(({className:s,children:e,...n},o)=>t.jsx("h1",{ref:o,className:m("m-0 text-xl font-semibold",s),...n,children:e}));Cn.displayName="ChatHeader.Title";const Tn=i.forwardRef(({className:s,children:e,...n},o)=>t.jsx("div",{ref:o,className:m("flex items-center gap-3",s),...n,children:e}));Tn.displayName="ChatHeader.Actions";const kn=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"}},In=s=>{switch(s){case"connected":return"Connected";case"connecting":return"Connecting...";case"error":return"Connection Error";default:return"No Server"}},En=i.forwardRef(({status:s,statusText:e,className:n,...o},a)=>{const l=e??In(s),d=kn(s);return t.jsxs("div",{ref:a,className:m("flex items-center gap-2",n),...o,children:[t.jsx("div",{className:m("h-2 w-2 rounded-full",d)}),t.jsx("span",{className:"text-sm text-muted-foreground",children:l})]})});En.displayName="ChatHeader.StatusIndicator";const Rn=i.forwardRef(({icon:s,className:e,children:n,onClick:o,...a},l)=>{const{isExpanded:d,setIsExpanded:p}=xe(),u=r=>{p(!d),o?.(r)};return t.jsxs("button",{ref:l,type:"button",onClick:u,className:m("rounded p-1 transition-colors hover:bg-background lg:hidden",e),"aria-label":d?"Collapse header":"Expand header",...a,children:[s&&t.jsx("div",{className:m("transition-transform duration-200",d&&"rotate-180"),children:s}),n]})});Rn.displayName="ChatHeader.Toggle";const Nt=i.forwardRef(({className:s,children:e,...n},o)=>{const{isExpanded:a}=xe();return a?t.jsx("div",{ref:o,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),...n,children:e}):null});Nt.displayName="ChatHeader.ExpandablePanel";const jt=i.forwardRef(({commands:s=[],showCommandMenu:e,commandMenuQuery:n,selectedMenuIndex:o,setSelectedMenuIndex:a,setMenuItemCount:l,triggerCounter:d,onChange:p,className:u,...r},c)=>{const f=i.useCallback((w,g)=>{const h=w.toLowerCase(),v=g.toLowerCase();if(!g)return 1;if(h.includes(v))return 1-v.length/h.length;let b=0;for(let N=0;N<h.length&&b<v.length;N++)h[N]===v[b]&&b++;return b===v.length?.5-b/h.length:0},[]),x=i.useMemo(()=>s.map(w=>({...w,score:Math.max(f(w.label,n),w.description?f(w.description,n):0)})).filter(w=>w.score>0).sort((w,g)=>g.score-w.score),[s,n,f]);return i.useEffect(()=>{l(x.length)},[x.length,l]),i.useEffect(()=>{a(0)},[a]),i.useEffect(()=>{d>0&&x[o]&&(x[o].onSelect(),p(""))},[d,x,o,p]),!e||x.length===0?null:t.jsxs("div",{ref:c,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",u),...r,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:x.map((w,g)=>t.jsxs("button",{type:"button",onClick:()=>w.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",g===o&&"bg-muted"),children:[w.icon&&t.jsx("span",{className:"shrink-0 mt-0.5",children:w.icon}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"font-medium",children:w.label}),w.description&&t.jsx("div",{className:"text-xs text-muted-foreground truncate",children:w.description})]})]},w.id))})]})});jt.displayName="ChatInputCommandMenu";const St=i.createContext(void 0),re=()=>{const s=i.useContext(St);if(!s)throw new Error("ChatInput components must be used within ChatInput.Root");return s},Ct=i.forwardRef(({client:s,value:e,onChange:n,onSubmit:o,disabled:a=!1,isSubmitting:l,submitOnEnter:d=!0,className:p,children:u,...r},c)=>{const f=i.useRef(null),x=Xs(s??null),w=C(M=>M.isStreaming),g=x?x.value:e||"",h=x?x.onChange:n||(()=>{}),v=x?x.onSubmit:o||(async()=>{}),b=x?x.isSubmitting||w:l||!1,[N,T]=i.useState(!1),[U,I]=i.useState(""),[A,S]=i.useState(0),[_,F]=i.useState(0),[ce,de]=i.useState(0),Yt=i.useCallback(()=>{de(M=>M+1)},[]),Zt=async M=>{M.preventDefault(),g.trim()&&!b&&!a&&(await v(),setTimeout(()=>{f.current?.focus()},0))},es=M=>{const O=M.target;!(O.tagName==="BUTTON"||O.tagName==="INPUT"||O.tagName==="TEXTAREA"||O.closest("button"))&&f.current&&f.current.focus()},ts=M=>{const O=M.target;!(O.tagName==="BUTTON"||O.tagName==="INPUT"||O.tagName==="TEXTAREA"||O.closest("button"))&&M.key===" "&&(M.preventDefault(),f.current&&f.current.focus())};return i.useEffect(()=>{const M=document.querySelector('textarea[name="chat-input"]');M&&f.current!==M&&(f.current=M)},[]),i.useEffect(()=>{!g&&f.current&&(f.current.style.height="auto",f.current.style.overflowY="hidden")},[g]),t.jsx(St.Provider,{value:{value:g,onChange:h,onSubmit:v,disabled:a,isSubmitting:b,submitOnEnter:d,showCommandMenu:N,setShowCommandMenu:T,commandMenuQuery:U,setCommandMenuQuery:I,selectedMenuIndex:A,setSelectedMenuIndex:S,menuItemCount:_,setMenuItemCount:F,triggerMenuSelect:Yt,triggerCounter:ce},children:t.jsx("form",{ref:c,onSubmit:Zt,onClick:es,onKeyDown:ts,className:m("relative w-full divide-y rounded-xl border bg-background shadow-md",p),...r,children:u})})});Ct.displayName="ChatInput.Root";const Tt=i.forwardRef(({asChild:s=!1,className:e,onKeyDown:n,children:o,...a},l)=>{const{value:d,onChange:p,onSubmit:u,disabled:r,isSubmitting:c,submitOnEnter:f,showCommandMenu:x,setShowCommandMenu:w,setCommandMenuQuery:g,setSelectedMenuIndex:h,menuItemCount:v,triggerMenuSelect:b}=re(),N=i.useRef(null),A={ref:i.useCallback(S=>{N.current=S,typeof l=="function"?l(S):l&&(l.current=S)},[l]),name:"chat-input",value:d,onChange:S=>{const _=S.target.value;if(p(_),_.startsWith("/")&&!_.includes(`
|
|
6
|
+
`)){w(!0);const de=_.slice(1);g(de)}else w(!1),g("");const F=N.current;if(!F)return;F.style.height="auto";const ce=Math.min(F.scrollHeight,164);F.style.height=`${ce}px`,F.scrollHeight>164?F.style.overflowY="auto":F.style.overflowY="hidden"},onKeyDown:S=>{if(x&&v>0){if(S.key==="ArrowDown"){S.preventDefault(),h(_=>(_+1)%v);return}else if(S.key==="ArrowUp"){S.preventDefault(),h(_=>(_-1+v)%v);return}else if(S.key==="Enter"&&!S.shiftKey){S.preventDefault(),b();return}else if(S.key==="Escape"){S.preventDefault(),w(!1),g("");return}}f&&S.key==="Enter"&&!S.shiftKey&&(d.trim()&&!c&&!r?(S.preventDefault(),u()):(c||r)&&S.preventDefault()),n?.(S)},disabled:r,...a};return s&&i.isValidElement(o)?i.cloneElement(o,A):t.jsx("textarea",{...A,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)})});Tt.displayName="ChatInput.Field";const kt=i.forwardRef(({asChild:s=!1,className:e,disabled:n,children:o,...a},l)=>{const{value:d,disabled:p,isSubmitting:u}=re(),r=n||p||u||!d.trim(),c=s?J:Z;return t.jsx(c,{ref:l,type:"submit",disabled:r,variant:s?void 0:"default",size:"icon",className:m(!s&&"gap-1.5 rounded-full",e),...a,children:o})});kt.displayName="ChatInput.Submit";const It=i.forwardRef(({className:s,children:e,...n},o)=>t.jsx("div",{ref:o,className:m("flex items-center justify-between p-2",s),...n,children:e}));It.displayName="ChatInput.Toolbar";const Et=i.forwardRef(({asChild:s=!1,className:e,children:n,onClick:o,...a},l)=>{const{value:d,onChange:p,setShowCommandMenu:u,setCommandMenuQuery:r}=re(),c=x=>{d.startsWith("/")||(p("/"),u(!0),r("")),o?.(x)},f=s?J:Z;return t.jsx(f,{ref:l,type:"button",variant:"ghost",size:"icon",className:m("rounded-full",e),onClick:c,...a,children:n||t.jsx(Cs,{className:"size-4"})})});Et.displayName="ChatInput.Actions";const Rt=i.forwardRef(({asChild:s=!1,className:e,children:n,...o},a)=>{const l=s?J:Z;return t.jsx(l,{ref:a,type:"button",variant:"ghost",size:"icon",className:m("rounded-full",e),...o,children:n||t.jsx(Ts,{className:"size-4"})})});Rt.displayName="ChatInput.Attachment";const Ut=i.forwardRef(({asChild:s=!1,className:e,children:n,...o},a)=>{const l=s?J:Z;return t.jsx(l,{ref:a,type:"button",variant:"ghost",size:"icon",className:m("rounded-full",e),...o,children:n||t.jsx(ks,{className:"size-4"})})});Ut.displayName="ChatInput.VoiceInput";const Mt=i.forwardRef(({commands:s=[],className:e,onChange:n,...o},a)=>{const{showCommandMenu:l,commandMenuQuery:d,selectedMenuIndex:p,setSelectedMenuIndex:u,setMenuItemCount:r,triggerCounter:c,onChange:f}=re();return t.jsx(jt,{ref:a,commands:s,showCommandMenu:l,commandMenuQuery:d,selectedMenuIndex:p,setSelectedMenuIndex:u,setMenuItemCount:r,triggerCounter:c,onChange:f,className:e,...o})});Mt.displayName="ChatInput.CommandMenu";const Un=({className:s,...e})=>t.jsx(ns,{className:m("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",s),...e}),At=({className:s,...e})=>t.jsx(os,{className:m(s),...e}),Mn=({withHandle:s,className:e,...n})=>t.jsx(rs,{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),...n,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"})]})})}),An=({...s})=>t.jsx(gs,{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}),Dt=i.createContext(void 0),be=()=>{const s=i.useContext(Dt);if(!s)throw new Error("ChatLayout components must be used within ChatLayout.Root");return s},_t=i.forwardRef(({defaultSidebarOpen:s=!1,defaultPanelSize:e="hidden",defaultActiveTab:n="todo",className:o,children:a,...l},d)=>{const[p,u]=i.useState(s),[r,c]=i.useState(e),[f,x]=i.useState(n);return t.jsx(Dt.Provider,{value:{sidebarOpen:p,setSidebarOpen:u,panelSize:r,setPanelSize:c,activeTab:f,setActiveTab:x},children:t.jsx("div",{ref:d,className:m("flex h-screen flex-row bg-background text-foreground",o),...l,children:t.jsx(Un,{direction:"horizontal",className:"flex-1",children:a})})})});_t.displayName="ChatLayout.Root";const Dn=i.forwardRef(({className:s,children:e,...n},o)=>t.jsx("div",{ref:o,className:m("relative z-10 border-b border-border bg-card shrink-0",s),...n,children:e}));Dn.displayName="ChatLayout.Header";const Pt=i.forwardRef(({className:s,children:e,...n},o)=>t.jsx(At,{defaultSize:75,minSize:50,children:t.jsx("div",{ref:o,className:m("flex flex-1 flex-col overflow-hidden h-full",s),...n,children:e})}));Pt.displayName="ChatLayout.Main";const Lt=i.forwardRef(({showToaster:s=!0,className:e,children:n,...o},a)=>t.jsxs("div",{ref:a,className:m("relative flex flex-1 flex-col overflow-hidden",e),...o,children:[n,s&&t.jsx(An,{})]}));Lt.displayName="ChatLayout.Body";const zt=i.forwardRef(({className:s,children:e,onScrollChange:n,showScrollToBottom:o=!0,...a},l)=>{const[d,p]=i.useState(!1),u=i.useRef(null);i.useImperativeHandle(l,()=>u.current);const r=i.useCallback(()=>{const x=u.current;if(!x)return;const{scrollTop:w,scrollHeight:g,clientHeight:h}=x,b=g-w-h<100;p(!b&&o),n?.(b)},[n,o]),c=i.useCallback(()=>{r()},[r]),f=i.useCallback(()=>{const x=u.current;x&&x.scrollTo({top:x.scrollHeight,behavior:"smooth"})},[]);return i.useEffect(()=>{r()},[r]),t.jsxs("div",{className:"relative flex-1 overflow-hidden",children:[t.jsx("div",{ref:u,className:m("h-full overflow-y-auto",s),onScroll:c,...a,children:t.jsx("div",{className:"mx-auto max-w-chat min-h-full flex flex-col",children:e})}),d&&t.jsx("button",{type:"button",onClick:f,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(Is,{className:"size-4"})})]})});zt.displayName="ChatLayout.Messages";const Ft=i.forwardRef(({className:s,children:e,...n},o)=>t.jsx("div",{ref:o,className:m("bg-linear-to-t from-background to-transparent px-4 pb-4",s),...n,children:t.jsx("div",{className:"mx-auto max-w-chat",children:e})}));Ft.displayName="ChatLayout.Footer";const _n=i.forwardRef(({className:s,children:e,...n},o)=>{const{sidebarOpen:a}=be();return a?t.jsx("div",{ref:o,className:m("border-r border-border bg-card w-64 overflow-y-auto",s),...n,children:e}):null});_n.displayName="ChatLayout.Sidebar";const Ot=i.forwardRef(({breakpoint:s="lg",className:e,children:n,...o},a)=>{const{panelSize:l}=be();return l==="hidden"?null:t.jsxs(t.Fragment,{children:[t.jsx(Mn,{withHandle:!0}),t.jsx(At,{defaultSize:25,minSize:15,maxSize:50,children:t.jsx("div",{ref:a,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),...o,children:n})})]})});Ot.displayName="ChatLayout.Aside";const Ht=i.forwardRef(({source:s,isSelected:e,className:n,...o},a)=>t.jsxs("button",{ref:a,type:"button",className:m("flex w-full text-left gap-2 items-start p-3 rounded-lg transition-colors cursor-pointer border border-transparent","hover:bg-accent-hover hover:border-border/50",e&&"bg-accent-hover border-border/50",n),onClick:()=>window.open(s.url,"_blank"),...o,children:[t.jsx("div",{className:"flex gap-2 items-center py-[2px] shrink-0",children:t.jsx("div",{className:"relative rounded-[3px] shrink-0 size-4 overflow-hidden bg-muted",children:s.favicon?t.jsx("img",{alt:s.sourceName,className:"size-full object-cover",src:s.favicon}):t.jsx("div",{className:"size-full bg-muted"})})}),t.jsxs("div",{className:"flex flex-1 flex-col gap-1 min-w-0",children:[t.jsxs("div",{className:"text-xs leading-normal text-foreground",children:[t.jsx("span",{className:"font-medium",children:s.sourceName}),t.jsxs("span",{className:"text-muted-foreground",children:[" · ",s.title]})]}),t.jsx("p",{className:"text-xs leading-relaxed text-muted-foreground line-clamp-3",children:s.snippet})]})]}));Ht.displayName="SourceListItem";const ae=i.forwardRef(({todos:s,className:e,...n},o)=>t.jsx("div",{ref:o,className:m("space-y-2",e),...n,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(a=>t.jsx("div",{className:"text-sm",children:a.text},a.id))}));ae.displayName="TodoTabContent";const ie=i.forwardRef(({files:s=[],className:e,...n},o)=>t.jsx("div",{ref:o,className:m("space-y-2",e),...n,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(a=>t.jsx("div",{className:"text-sm",children:a},a))}));ie.displayName="FilesTabContent";const le=i.forwardRef(({sources:s=[],className:e,...n},o)=>t.jsx("div",{ref:o,className:m("space-y-2",e),...n,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 sources available"})}):s.map(a=>t.jsx(Ht,{source:a},a.id))}));le.displayName="SourcesTabContent";const Pn=i.forwardRef(({data:s,className:e,...n},o)=>t.jsxs("div",{ref:o,className:m("space-y-4",e),...n,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]})]})]}));Pn.displayName="DatabaseTabContent";const ye=hs,G=i.forwardRef(({className:s,...e},n)=>t.jsx(Ue,{ref:n,className:m("inline-flex h-10 items-center rounded-md bg-muted p-1 text-muted-foreground gap-1",s),...e}));G.displayName=Ue.displayName;const K=i.forwardRef(({className:s,...e},n)=>t.jsx(Me,{ref:n,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}));K.displayName=Me.displayName;const P=i.forwardRef(({className:s,...e},n)=>t.jsx(Ae,{ref:n,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}));P.displayName=Ae.displayName;const $t=i.forwardRef(({todo:s,className:e,...n},o)=>t.jsx("div",{ref:o,className:m("flex items-center gap-3 px-3 py-2 rounded-lg",e),...n,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})}));$t.displayName="TodoListItem";const Bt=i.forwardRef(({client:s,todos:e,className:n,...o},a)=>{const l=e||[];return t.jsx("div",{ref:a,className:m("space-y-2 max-h-64 overflow-y-auto",n),...o,children:l.length===0?t.jsx("p",{className:"text-sm text-foreground opacity-60 italic",children:"No tasks yet."}):l.map(d=>t.jsx($t,{todo:d},d.id))})});Bt.displayName="TodoList";const Ln=i.forwardRef(({client:s,todos:e,variant:n="animated",showIcons:o=!1,visibleTabs:a=["todo","files","database"],className:l,...d},p)=>{const u=e||[],[r,c]=i.useState(a[0]||"todo"),f=i.useRef(null),x=i.useRef(null);i.useEffect(()=>{const v=setTimeout(()=>{const b=f.current;if(r&&b){const N=x.current;if(N){const T=b.getBoundingClientRect(),U=N.getBoundingClientRect(),I=U.left-T.left,A=U.width,S=I/T.width*100,_=100-(I+A)/T.width*100;b.style.clipPath=`inset(0 ${_.toFixed(2)}% 0 ${S.toFixed(2)}% round 999px)`}}},0);return()=>clearTimeout(v)},[r]);const g=[{id:"todo",label:n==="pills"?"To-do":"To-Do List",icon:st},{id:"files",label:"Files",icon:nt},{id:"database",label:"Database",icon:ot},{id:"sources",label:"Sources",icon:rt}].filter(h=>a.includes(h.id));return t.jsx("div",{ref:p,className:m("select-none",l),...d,children:t.jsxs(ye,{value:r,onValueChange:c,className:"w-full",children:[n==="pills"?t.jsx(G,{className:m("w-full justify-start bg-transparent p-0 h-auto","gap-1"),children:g.map(h=>{const v=h.icon;return t.jsxs(K,{value:h.id,className:m("gap-2 px-3 py-1.5 rounded-lg text-sm font-medium","data-[state=active]:bg-zinc-100 data-[state=active]:text-foreground","data-[state=inactive]:text-muted-foreground"),children:[o&&v&&t.jsx(v,{className:"size-4"}),h.label]},h.id)})}):t.jsxs("div",{className:"relative mb-4 border-border",children:[t.jsx(G,{className:"bg-transparent p-0 h-auto rounded-none w-full border-none",children:g.map(h=>t.jsx(K,{value:h.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:h.label},h.id))}),t.jsx("div",{ref:f,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(G,{className:"bg-secondary p-0 h-auto rounded-none w-full border-none",children:g.map(h=>t.jsx(K,{value:h.id,ref:r===h.id?x: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:h.label},h.id))})})]}),t.jsx(P,{value:"todo",className:n==="pills"?"mt-0":"",children:n==="pills"?t.jsx(ae,{todos:u}):t.jsx(Bt,{todos:u})}),t.jsx(P,{value:"files",className:n==="pills"?"mt-0":"",children:t.jsx(ie,{})}),t.jsx(P,{value:"database",className:n==="pills"?"mt-0":"",children:t.jsx("div",{className:"text-sm text-foreground opacity-60 italic",children:"Database tab coming soon..."})}),t.jsx(P,{value:"sources",className:n==="pills"?"mt-0":"",children:t.jsx(le,{})})]})})});Ln.displayName="ChatSecondaryPanel";const zn=i.forwardRef(({className:s,children:e,...n},o)=>t.jsx("div",{ref:o,className:m("flex h-full flex-col",s),...n,children:e}));zn.displayName="ChatSidebar.Root";const Fn=i.forwardRef(({className:s,children:e,...n},o)=>t.jsx("div",{ref:o,className:m("border-b border-border px-4 py-3",s),...n,children:e}));Fn.displayName="ChatSidebar.Header";const On=i.forwardRef(({className:s,children:e,...n},o)=>t.jsx("div",{ref:o,className:m("flex-1 overflow-y-auto p-4",s),...n,children:e}));On.displayName="ChatSidebar.Content";const Hn=i.forwardRef(({className:s,children:e,...n},o)=>t.jsx("div",{ref:o,className:m("border-t border-border px-4 py-3",s),...n,children:e}));Hn.displayName="ChatSidebar.Footer";const $n=i.forwardRef(({children:s,className:e,...n},o)=>{const[a,l]=i.useState(s),[d,p]=i.useState(!1),u=i.useRef(s),r=i.useRef(!0);return i.useEffect(()=>{if(r.current){r.current=!1,u.current=s;return}if(u.current===s)return;p(!0);const c=setTimeout(()=>{l(s),u.current=s,requestAnimationFrame(()=>{p(!1)})},150);return()=>{clearTimeout(c)}},[s]),t.jsx("span",{ref:o,className:m("text-sm text-foreground opacity-60 transition-opacity duration-300",d?"opacity-0":"opacity-60",e),...n,children:a})});$n.displayName="ChatStatus";const B=$("gui");function Bn({agentName:s}){const{isExpanded:e,setIsExpanded:n}=xe();return t.jsxs("div",{className:"flex lg:hidden items-center gap-2 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[t.jsx("h1",{className:"text-[20px] font-semibold leading-[1.2] tracking-[-0.4px] text-foreground",children:s}),t.jsx("div",{className:"flex items-center justify-center shrink-0",children:t.jsx(me,{className:"size-4 rotate-180 text-muted-foreground"})})]}),t.jsx("button",{type:"button",className:"flex items-center justify-center shrink-0 cursor-pointer","aria-label":"Toggle menu",onClick:()=>n(!e),children:t.jsx(at,{className:"size-4 text-muted-foreground"})})]})}function Wn({agentName:s,todos:e,sources:n,showHeader:o}){const{panelSize:a,setPanelSize:l}=be();return t.jsxs(vt,{className:m("border-b border-border bg-card relative lg:p-0","[border-bottom-width:0.5px]"),children:[t.jsxs("div",{className:"hidden lg:flex items-center gap-2 w-full h-16 py-5 pl-6 pr-4",children:[o&&t.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[t.jsx("h1",{className:"text-[20px] font-semibold leading-[1.2] tracking-[-0.4px] text-foreground",children:s}),t.jsx("div",{className:"flex items-center justify-center shrink-0",children:t.jsx(me,{className:"size-4 rotate-180 text-muted-foreground"})})]}),!o&&t.jsx("div",{className:"flex-1"}),t.jsx("button",{type:"button",className:"flex items-center justify-center shrink-0 cursor-pointer","aria-label":"Toggle sidebar",onClick:()=>{l(a==="hidden"?"small":"hidden")},children:t.jsx(at,{className:"size-4 text-muted-foreground"})})]}),t.jsx(Bn,{agentName:s}),t.jsx(Nt,{className:m("pt-6 pb-8 px-6","border-b border-border bg-card","shadow-[0_4px_16px_0_rgba(0,0,0,0.04)]","[border-bottom-width:0.5px]"),children:t.jsxs(ye,{defaultValue:"todo",className:"w-full",children:[t.jsx(we,{showIcons:!0,visibleTabs:["todo","files","sources"],variant:"default"}),t.jsx(P,{value:"todo",className:"mt-4",children:t.jsx(ae,{todos:e})}),t.jsx(P,{value:"files",className:"mt-4",children:t.jsx(ie,{})}),t.jsx(P,{value:"sources",className:"mt-4",children:t.jsx(le,{sources:n})})]})})]})}function Vn({client:s,initialSessionId:e,error:n}){const{connectionStatus:o,connect:a,sessionId:l}=Js(s,e),{messages:d}=mt(s);Ys(s);const p=C(h=>h.error),[u,r]=i.useState("Agent"),[c,f]=i.useState(typeof window<"u"?window.innerWidth>=1024:!0);if(i.useEffect(()=>{B.debug("Connection status changed",{status:o}),o==="error"&&p&&B.error("Connection error occurred",{error:p})},[o,p]),i.useEffect(()=>{if(s&&l){const h=s.getCurrentSession();h?.metadata?.agentName&&r(h.metadata.agentName)}},[s,l]),i.useEffect(()=>{const h=window.matchMedia("(min-width: 1024px)"),v=b=>{f(b.matches)};return f(h.matches),h.addEventListener("change",v),()=>{h.removeEventListener("change",v)}},[]),n)return t.jsx("div",{className:"flex items-center justify-center h-screen bg-background",children:t.jsxs("div",{className:"text-center p-8 max-w-md",children:[t.jsx("h1",{className:"text-2xl font-bold text-destructive mb-4",children:"Initialization Error"}),t.jsx("p",{className:"text-foreground mb-4",children:n}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Failed to initialize the ACP client. Check the console for details."})]})});const x=[],w=[{id:"1",title:"Boeing Scores Early Wins at Dubai Airshow",sourceName:"Reuters",url:"https://www.reuters.com/markets/companies/BA.N",snippet:"DUBAI, Nov 17 (Reuters) - Boeing (BA.N), opens new tab took centre stage at day one of the Dubai Airshow on Monday, booking a $38 billion order from host carrier Emirates and clinching more deals with African carriers, while China displayed its C919 in the Middle East for the first time.",favicon:"https://www.google.com/s2/favicons?domain=reuters.com&sz=32"},{id:"2",title:"Boeing's Sustainable Aviation Goals Take Flight",sourceName:"Forbes",url:"https://www.forbes.com",snippet:"SEATTLE, Nov 18 (Reuters) - Boeing is making headway towards its sustainability targets, unveiling plans for a new eco-friendly aircraft design aimed at reducing emissions by 50% by 2030.",favicon:"https://www.google.com/s2/favicons?domain=forbes.com&sz=32"},{id:"3",title:"Boeing Faces Increased Competition in Global Aviation Market",sourceName:"Reuters",url:"https://www.reuters.com",snippet:"CHICAGO, Nov 19 (Reuters) - As the global aviation industry rebounds post-pandemic, Boeing is grappling with intensified competition from rival manufacturers, particularly in the Asian market.",favicon:"https://www.google.com/s2/favicons?domain=reuters.com&sz=32"},{id:"4",title:"Boeing's Starliner Successfully Completes Orbital Test Flight",sourceName:"The Verge",url:"https://www.theverge.com",snippet:"NASA, Nov 20 (Reuters) - Boeing's CST-100 Starliner spacecraft achieves a significant milestone, successfully completing its orbital test flight, paving the way for future crewed missions to the International Space Station.",favicon:"https://www.google.com/s2/favicons?domain=theverge.com&sz=32"}],g=[{id:"model-sonnet",label:"Use Sonnet 4.5",description:"Switch to Claude Sonnet 4.5 model",icon:t.jsx(je,{className:"h-4 w-4"}),category:"model",onSelect:()=>{B.info("User selected Sonnet 4.5 model")}},{id:"model-opus",label:"Use Opus",description:"Switch to Claude Opus model",icon:t.jsx(je,{className:"h-4 w-4"}),category:"model",onSelect:()=>{B.info("User selected Opus model")}},{id:"settings",label:"Open Settings",description:"Configure chat preferences",icon:t.jsx(Es,{className:"h-4 w-4"}),category:"action",onSelect:()=>{B.info("User opened settings")}},{id:"code-mode",label:"Code Mode",description:"Enable code-focused responses",icon:t.jsx(Rs,{className:"h-4 w-4"}),category:"mode",onSelect:()=>{B.info("User enabled code mode")}}];return t.jsxs(_t,{defaultPanelSize:"hidden",defaultActiveTab:"todo",children:[t.jsxs(Pt,{children:[t.jsx(Wn,{agentName:u,todos:x,sources:w,showHeader:d.length>0}),o==="error"&&p&&t.jsx("div",{className:"border-b border-destructive/20 bg-destructive/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-destructive",children:"Connection Error"}),t.jsx("p",{className:"whitespace-pre-line text-sm text-foreground",children:p})]}),t.jsx("button",{type:"button",onClick:a,className:"rounded-lg bg-destructive px-4 py-2 text-sm font-medium text-destructive-foreground transition-colors hover:bg-destructive-hover",children:"Retry"})]})}),t.jsxs(Lt,{children:[t.jsx(zt,{className:d.length>0?"pt-4":"",children:d.length===0?t.jsx("div",{className:"flex flex-1 items-center px-4",children:t.jsx(yt,{title:u,description:"This agent can help you with your tasks. Start a conversation by typing a message below.",suggestedPrompts:["Help me debug this code","Explain how this works","Create a new feature","Review my changes"],onPromptClick:h=>{B.info("Prompt clicked",{prompt:h})}})}):t.jsx("div",{className:"flex flex-col gap-4 px-4",children:d.map((h,v)=>t.jsx(Vt,{message:h,isLastMessage:v===d.length-1,children:t.jsx(Qt,{message:h,thinkingDisplayStyle:"collapsible"})},h.id))})}),t.jsx(Ft,{children:t.jsxs(Ct,{client:s,children:[t.jsx(Mt,{commands:g}),t.jsx(Tt,{placeholder:"Type a message or / for commands...",autoFocus:!0}),t.jsxs(It,{children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(Et,{}),t.jsx(Rt,{})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(Ut,{}),t.jsx(kt,{children:t.jsx(Us,{className:"size-4"})})]})]})]})})]})]}),c&&t.jsx(Ot,{breakpoint:"lg",children:t.jsxs(ye,{defaultValue:"todo",className:"flex flex-col h-full",children:[t.jsx("div",{className:m("border-b border-border bg-card","px-6 py-2 h-16","flex items-center","[border-bottom-width:0.5px]"),children:t.jsx(we,{showIcons:!0,visibleTabs:["todo","files","sources"],variant:"compact"})}),t.jsx(P,{value:"todo",className:"flex-1 p-4 mt-0",children:t.jsx(ae,{todos:x})}),t.jsx(P,{value:"files",className:"flex-1 p-4 mt-0",children:t.jsx(ie,{})}),t.jsx(P,{value:"sources",className:"flex-1 p-4 mt-0",children:t.jsx(le,{sources:w})})]})})]})}const qn=i.forwardRef(({autoScroll:s=!0,isStreaming:e=!1,scrollBehavior:n="smooth",scrollThreshold:o=100,showScrollButton:a=!0,scrollButton:l,className:d,children:p,...u},r)=>{const c=i.useRef(null),[f,x]=i.useState(!0),[w,g]=i.useState(!1),h=i.useRef(0);i.useImperativeHandle(r,()=>{if(!c.current)throw new Error("Container ref not initialized");return c.current});const v=i.useCallback(()=>{const N=c.current;if(!N)return;const{scrollTop:T,scrollHeight:U,clientHeight:I}=N,S=U-T-I<o;x(S),g(!S&&a),h.current=T},[o,a]),b=i.useCallback((N=n)=>{const T=c.current;T&&T.scrollTo({top:T.scrollHeight,behavior:N})},[n]);return i.useEffect(()=>{!s||!c.current||(e&&f?b("auto"):!e&&f&&b())},[s,e,f,b]),i.useEffect(()=>{const N=c.current;if(!N)return;const T=()=>{v()};return N.addEventListener("scroll",T,{passive:!0}),v(),()=>{N.removeEventListener("scroll",T)}},[v]),i.useEffect(()=>{const N=c.current;if(!N)return;const T=new ResizeObserver(()=>{f&&s&&b("auto")});return T.observe(N),()=>{T.disconnect()}},[f,s,b]),t.jsxs("div",{className:"relative flex-1",children:[t.jsx("div",{ref:c,className:m("h-full overflow-y-auto overflow-x-hidden","scrollbar-thin scrollbar-thumb-[border] scrollbar-track-transparent",d),...u,children:t.jsx("div",{className:"flex flex-col gap-4 px-4 py-4",children:p})}),w&&t.jsx("div",{className:"absolute bottom-4 left-1/2 -translate-x-1/2 z-10",children:l||t.jsxs("button",{type:"button",onClick:()=>b(),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"]})})]})});qn.displayName="Conversation";const Qn=xs,Wt=i.forwardRef(({className:s,...e},n)=>t.jsx(De,{ref:n,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=De.displayName;const Gn=i.forwardRef(({className:s,children:e,...n},o)=>t.jsxs(Qn,{children:[t.jsx(Wt,{}),t.jsxs(_e,{ref:o,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),...n,children:[e,t.jsxs(bs,{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(Ms,{className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Gn.displayName=_e.displayName;const Kn=i.forwardRef(({className:s,...e},n)=>t.jsx(Pe,{ref:n,className:m("text-lg font-semibold leading-none tracking-tight",s),...e}));Kn.displayName=Pe.displayName;const Xn=i.forwardRef(({className:s,...e},n)=>t.jsx(Le,{ref:n,className:m("text-sm text-muted-foreground",s),...e}));Xn.displayName=Le.displayName;const Jn=i.forwardRef(({className:s,inset:e,children:n,...o},a)=>t.jsxs(ze,{ref:a,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),...o,children:[n,t.jsx(tt,{className:"ml-auto h-4 w-4"})]}));Jn.displayName=ze.displayName;const Yn=i.forwardRef(({className:s,...e},n)=>t.jsx(Fe,{ref:n,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}));Yn.displayName=Fe.displayName;const Zn=i.forwardRef(({className:s,sideOffset:e=4,...n},o)=>t.jsx(ys,{children:t.jsx(Oe,{ref:o,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),...n})}));Zn.displayName=Oe.displayName;const eo=i.forwardRef(({className:s,inset:e,...n},o)=>t.jsx(He,{ref:o,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),...n}));eo.displayName=He.displayName;const to=i.forwardRef(({className:s,children:e,...n},o)=>t.jsxs($e,{ref:o,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),...n,children:[t.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:t.jsx(Be,{children:t.jsx(it,{className:"h-4 w-4"})})}),e]}));to.displayName=$e.displayName;const so=i.forwardRef(({className:s,children:e,...n},o)=>t.jsxs(We,{ref:o,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),...n,children:[t.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:t.jsx(Be,{children:t.jsx(lt,{className:"h-2 w-2 fill-current"})})}),e]}));so.displayName=We.displayName;const no=i.forwardRef(({className:s,inset:e,...n},o)=>t.jsx(Ve,{ref:o,className:m("px-2 py-1.5 text-sm font-semibold",e&&"pl-8",s),...n}));no.displayName=Ve.displayName;const oo=i.forwardRef(({className:s,...e},n)=>t.jsx(qe,{ref:n,className:m("-mx-1 my-1 h-px bg-border",s),...e}));oo.displayName=qe.displayName;const ro=W("flex h-10 w-full rounded-md border bg-input-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"}}),ao=i.forwardRef(({className:s,type:e,variant:n,...o},a)=>t.jsx("input",{type:e,className:m(ro({variant:n,className:s})),ref:a,...o}));ao.displayName="Input";const io=i.forwardRef(({className:s,...e},n)=>t.jsx(Qe,{ref:n,className:m("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",s),...e}));io.displayName=Qe.displayName;const lo=W("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:n,className:o,children:a,messageId:l,autoScroll:d,isLastMessage:p=!1,...u},r)=>{const c=s?s.role:e||"assistant",f=s?s.id:l,x=i.useRef(null),[w,g]=i.useState(void 0);return i.useImperativeHandle(r,()=>x.current),i.useEffect(()=>{if(!p||c!=="assistant"){g(void 0);return}const h=()=>{const b=x.current;if(!b)return;let N=b.parentElement;for(;N&&!N.classList.contains("overflow-y-auto");)N=N.parentElement;if(!N)return;const T=b.previousElementSibling;if(!T||T.getAttribute("aria-label")!=="user message"){g(void 0);return}const U=N.clientHeight,I=T.offsetHeight,S=Math.max(0,U-I-32);g(S)};h();const v=new ResizeObserver(h);if(x.current){v.observe(x.current);let b=x.current.parentElement;for(;b&&!b.classList.contains("overflow-y-auto");)b=b.parentElement;b&&v.observe(b)}return()=>v.disconnect()},[p,c]),i.useEffect(()=>{if((d!==void 0?d:c==="user")&&x.current){const v=setTimeout(()=>{x.current?.scrollIntoView({behavior:"smooth",block:"start",inline:"nearest"})},50);return()=>clearTimeout(v)}},[c,d]),t.jsx("article",{ref:x,"aria-label":`${c} message`,"data-message-id":f,className:m(lo({role:c,layout:n}),o),style:{minHeight:w!==void 0?`${w}px`:void 0},...u,children:a})});Vt.displayName="Message";const te=128e3,Te={"claude-sonnet-4-5-20250929":2e5,"claude-sonnet-4-20250514":2e5,"claude-3-5-sonnet-20241022":2e5,"claude-3-5-sonnet-20240620":2e5,"claude-3-opus-20240229":2e5,"claude-3-sonnet-20240229":2e5,"claude-3-haiku-20240307":2e5,"gpt-4-turbo":128e3,"gpt-4-turbo-preview":128e3,"gpt-4-0125-preview":128e3,"gpt-4-1106-preview":128e3,"gpt-4":8192,"gpt-4-32k":32768,"gpt-3.5-turbo":16385,"gpt-3.5-turbo-16k":16385,default:te};function co(s){if(!s)return te;if(s in Te)return Te[s]??te;const e=s.toLowerCase();return e.includes("claude")?2e5:e.includes("gpt-4-turbo")?128e3:e.includes("gpt-4-32k")?32768:e.includes("gpt-4")?8192:e.includes("gpt-3.5")?16385:te}function uo(s,e){const n=co(e);return s/n*100}function po(s,e,n=1){return`${uo(s,e).toFixed(n)}%`}const ke=W("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"}}),fo=W("w-4 h-4 text-foreground opacity-60 transition-transform duration-200",{variants:{expanded:{true:"rotate-180",false:""}},defaultVariants:{expanded:!1}}),qt=i.forwardRef(({content:s,isStreaming:e=!1,mode:n="collapsible",defaultExpanded:o=!1,autoExpand:a=!1,autoCollapse:l=!0,autoCollapseDelay:d=2e3,label:p="Thinking",variant:u,className:r},c)=>{const[f,x]=i.useState(n==="inline"?!0:o),[w,g]=i.useState(!1);return i.useEffect(()=>{if(l&&!e&&s&&n==="collapsible"){const h=setTimeout(()=>{g(!0),x(!1)},d);return()=>clearTimeout(h)}},[e,s,l,d,n]),i.useEffect(()=>{a&&e&&n==="collapsible"&&!w&&x(!0)},[a,e,n,w]),!s&&!e?null:n==="inline"?t.jsxs("div",{ref:c,className:m(ke({variant:u}),"p-3",r),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:p}),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:c,className:m("mb-3",r),children:[t.jsxs("button",{type:"button",onClick:()=>{x(!f),g(!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":f,"aria-label":`${f?"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:p}),e&&t.jsx("span",{className:"inline-block w-2 h-2 bg-primary rounded-full animate-pulse shrink-0"}),!f&&s&&t.jsxs("span",{className:"text-xs text-foreground opacity-50 truncate",children:[s.substring(0,60),s.length>60&&"..."]})]}),t.jsx(ge,{className:fo({expanded:f}),"aria-hidden":"true"})]}),f&&t.jsx("div",{className:m(ke({variant:u}),"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:"..."})]})})]})});qt.displayName="Reasoning";const se=i.forwardRef(({content:s,isStreaming:e=!1,showEmpty:n=!0,emptyMessage:o="",className:a,...l},d)=>{if(!s&&e&&n)return t.jsx("div",{ref:d,className:m("opacity-70 italic text-sm",a),...l,children:o});if(!s)return null;const p={table:({node:u,...r})=>t.jsx("div",{className:"overflow-x-auto my-4",children:t.jsx("table",{className:"min-w-full border-collapse border border-border rounded-md",...r})}),thead:({node:u,...r})=>t.jsx("thead",{className:"bg-card border-b border-border",...r}),tbody:({node:u,...r})=>t.jsx("tbody",{...r}),tr:({node:u,...r})=>t.jsx("tr",{className:"border-b border-border hover:bg-card transition-colors",...r}),th:({node:u,...r})=>t.jsx("th",{className:"px-4 py-2 text-left font-semibold text-foreground border-r border-border last:border-r-0",...r}),td:({node:u,...r})=>t.jsx("td",{className:"px-4 py-2 text-foreground border-r border-border last:border-r-0",...r}),input:({node:u,checked:r,...c})=>c.type==="checkbox"?t.jsx("input",{type:"checkbox",checked:r||!1,disabled:!0,readOnly:!0,className:"mr-2 w-4 h-4 accent-[primary] cursor-not-allowed",...c}):t.jsx("input",{...c}),code:({node:u,...r})=>r.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",...r}):t.jsx("code",{className:"px-1.5 py-0.5 bg-card border border-border rounded text-sm font-mono text-foreground",...r}),pre:({node:u,...r})=>t.jsx("pre",{className:"my-4 rounded-lg",...r}),h1:({node:u,...r})=>t.jsx("h1",{className:"text-2xl font-bold mt-6 mb-4 text-foreground border-b border-border pb-2",...r}),h2:({node:u,...r})=>t.jsx("h2",{className:"text-xl font-semibold mt-5 mb-3 text-foreground border-b border-border/50 pb-1.5",...r}),h3:({node:u,...r})=>t.jsx("h3",{className:"text-lg font-semibold mt-4 mb-2 text-foreground",...r}),h4:({node:u,...r})=>t.jsx("h4",{className:"text-base font-semibold mt-3 mb-2 text-foreground",...r}),ul:({node:u,...r})=>{const c=u?.children?.some(f=>typeof f=="object"&&f!==null&&"type"in f&&f.type==="element"&&"tagName"in f&&f.tagName==="li"&&"children"in f&&Array.isArray(f.children)&&f.children.some(x=>typeof x=="object"&&x!==null&&"type"in x&&x.type==="element"&&"tagName"in x&&x.tagName==="input"&&"properties"in x&&typeof x.properties=="object"&&x.properties!==null&&"type"in x.properties&&x.properties.type==="checkbox"));return t.jsx("ul",{className:m("my-2 space-y-1 text-foreground",c?"list-none space-y-2":"list-disc list-inside"),...r})},ol:({node:u,...r})=>t.jsx("ol",{className:"list-decimal list-inside my-2 space-y-1 text-foreground",...r}),li:({node:u,...r})=>{const c=u?.children?.some(f=>typeof f=="object"&&f!==null&&"type"in f&&f.type==="element"&&"tagName"in f&&f.tagName==="input"&&"properties"in f&&typeof f.properties=="object"&&f.properties!==null&&"type"in f.properties&&f.properties.type==="checkbox");return t.jsx("li",{className:m("flex items-start",c?"gap-2":"ml-2"),...r})},a:({node:u,...r})=>t.jsx("a",{className:"text-primary hover:underline decoration-2 underline-offset-2 transition-all",target:"_blank",rel:"noopener noreferrer",...r}),p:({node:u,...r})=>t.jsx("p",{className:"my-2 text-foreground leading-relaxed",...r}),blockquote:({node:u,...r})=>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",...r}),hr:({node:u,...r})=>t.jsx("hr",{className:"my-6 border-t border-border opacity-50",...r})};return t.jsxs("div",{ref:d,className:m("markdown-content prose prose-sm max-w-none dark:prose-invert",a),...l,children:[t.jsx(as,{remarkPlugins:[Ps],components:p,children:s}),e&&s&&t.jsx("span",{className:"inline-block ml-1 animate-typing text-primary",children:"..."})]})});se.displayName="Response";const mo={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 Ie({toolCall:s}){const[e,n]=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:()=>n(!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 ${mo[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-muted-foreground 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-border rounded-md p-3 bg-card 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-muted-foreground uppercase tracking-wide mb-1.5",children:"Files"}),t.jsx("ul",{className:"space-y-1",children:s.locations.map(o=>t.jsxs("li",{className:"font-mono text-xs text-foreground bg-muted px-2 py-1 rounded",children:[o.path,o.line!==null&&o.line!==void 0&&`:${o.line}`]},`${o.path}:${o.line??""}`))})]}),s.rawInput&&Object.keys(s.rawInput).length>0&&t.jsxs("div",{children:[t.jsx("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-1.5",children:"Input"}),t.jsx("div",{className:"bg-muted p-2 rounded border border-border",children:t.jsx(Ne,{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-muted-foreground uppercase tracking-wide mb-1.5",children:"Output"}),t.jsx("div",{className:"space-y-2",children:s.content.map((o,a)=>{const l=()=>o.type==="diff"&&"path"in o?`diff-${o.path}-${a}`:o.type==="terminal"&&"terminalId"in o?`terminal-${o.terminalId}`:o.type==="text"&&"text"in o?`text-${o.text.substring(0,20)}-${a}`:o.type==="content"&&"content"in o?`content-${o.content.text?.substring(0,20)}-${a}`:`block-${a}`,d=(p,u)=>{try{const r=JSON.parse(p);if(typeof r=="object"&&r!==null)return t.jsx("div",{className:"bg-muted p-2 rounded border border-border",children:t.jsx(Ne,{value:r,collapsed:!1,displayDataTypes:!1,displayObjectSize:!1,enableClipboard:!0,style:{fontSize:"11px",backgroundColor:"transparent"}})},u)}catch{}return t.jsx("pre",{className:"bg-muted p-2.5 rounded border border-border text-xs overflow-x-auto font-mono text-foreground",children:p},u)};if(o.type==="content"&&"content"in o){const p=o.content;if(p.type==="text"&&p.text)return d(p.text,l())}return o.type==="text"&&"text"in o?d(o.text,l()):o.type==="diff"&&"path"in o&&"oldText"in o&&"newText"in o?t.jsxs("div",{className:"border rounded",children:[t.jsxs("div",{className:"bg-muted px-2 py-1 text-xs font-mono",children:[o.path,"line"in o&&o.line!==null&&o.line!==void 0&&`:${o.line}`]}),t.jsxs("div",{className:"p-2 font-mono text-xs",children:[t.jsxs("div",{className:"text-red-600",children:["- ",o.oldText]}),t.jsxs("div",{className:"text-green-600",children:["+ ",o.newText]})]})]},l()):o.type==="terminal"&&"terminalId"in o?t.jsxs("div",{className:"bg-black text-green-400 p-2 rounded text-xs font-mono",children:["Terminal: ",o.terminalId]},l()):null})})]}),s.error&&t.jsxs("div",{className:"bg-destructive/10 border border-destructive/20 rounded p-2.5 text-destructive",children:[t.jsx("div",{className:"text-xs font-semibold text-destructive uppercase tracking-wide mb-1.5",children:"Error"}),t.jsx("div",{className:"text-xs",children:s.error})]}),s.tokenUsage&&t.jsxs("div",{className:"bg-muted border border-border rounded p-2.5",children:[t.jsx("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-2",children:"Token Usage"}),t.jsxs("div",{className:"grid grid-cols-3 gap-3 text-xs text-foreground",children:[s.tokenUsage.inputTokens!==void 0&&t.jsxs("div",{children:[t.jsx("div",{className:"text-muted-foreground 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-muted-foreground 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-muted-foreground 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-muted-foreground",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 ee=["Thinking","Pensando","Pensant","Denkend","Pensando","考えている","생각 중","思考中","Размышляя","Düşünüyor","Myślący","Tänkande","Pensando","Ajatellen","Σκεπτόμενος","חושב","सोच रहा है","Berpikir"],Ee=["...","·..",".·.","..·",".·.","·.."];function go({startTime:s}){const[e,n]=i.useState(0),[o,a]=i.useState(()=>ee[Math.floor(Math.random()*ee.length)]),[l,d]=i.useState(0);i.useEffect(()=>{const r=setInterval(()=>{const f=Date.now()-s;n(f)},100);return()=>clearInterval(r)},[s]),i.useEffect(()=>{const r=setInterval(()=>{const c=Math.floor(Math.random()*ee.length);a(ee[c])},1500);return()=>clearInterval(r)},[]),i.useEffect(()=>{const r=setInterval(()=>{d(c=>(c+1)%Ee.length)},100);return()=>clearInterval(r)},[]);const p=(e/1e3).toFixed(1),u=Ee[l];return t.jsxs("span",{className:"text-muted-foreground text-sm",children:[o,u," ",p,"s"]})}const ho=W("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"}}),Qt=i.forwardRef(({role:s,variant:e,isStreaming:n,message:o,thinkingDisplayStyle:a="collapsible",className:l,children:d,...p},u)=>{const r=C(h=>h.streamingStartTime),c=C(h=>h.currentModel),f=o&&!d,x=f?o.role:s||"assistant",w=f?o.isStreaming:n;let g=d;if(f){const h=o.metadata?.thinking,v=!!h,b=o.isStreaming&&!o.content&&o.role==="assistant";g=t.jsxs(t.Fragment,{children:[o.role==="assistant"&&v&&t.jsx(qt,{content:h,isStreaming:o.isStreaming,mode:a,autoCollapse:!0}),b&&r&&t.jsxs("div",{className:"flex items-center gap-2 opacity-50",children:[t.jsx(ct,{className:"size-4 animate-spin text-muted-foreground"}),t.jsx(go,{startTime:r})]}),o.role==="assistant"?(()=>{const N=(o.toolCalls||[]).slice().sort((I,A)=>(I.contentPosition??1/0)-(A.contentPosition??1/0));if(N.length===0||!N.some(I=>I.contentPosition!==void 0))return t.jsxs(t.Fragment,{children:[N.length>0&&t.jsx("div",{className:"flex flex-col gap-2 mb-3",children:N.map(I=>t.jsx(Ie,{toolCall:I},I.id))}),t.jsx(se,{content:o.content,isStreaming:o.isStreaming,showEmpty:!1})]});const T=[];let U=0;if(N.forEach(I=>{const A=I.contentPosition??o.content.length;if(A>U){const S=o.content.slice(U,A);S&&T.push(t.jsx(se,{content:S,isStreaming:!1,showEmpty:!1},`text-before-${I.id}`))}T.push(t.jsx("div",{className:"my-2",children:t.jsx(Ie,{toolCall:I})},`tool-${I.id}`)),U=A}),U<o.content.length){const I=o.content.slice(U);I&&T.push(t.jsx(se,{content:I,isStreaming:o.isStreaming,showEmpty:!1},"text-end"))}return t.jsx(t.Fragment,{children:T})})():t.jsx("div",{className:"whitespace-pre-wrap",children:o.content}),o.role==="assistant"&&o.tokenUsage&&t.jsx("div",{className:"mt-3 pt-2 border-t border-border/30 text-xs text-muted-foreground/60",children:t.jsxs("span",{children:["Context:"," ",po(o.tokenUsage.totalTokens??0,c??void 0)," ","(",(o.tokenUsage.totalTokens??0).toLocaleString()," ","tokens)"]})})]})}return t.jsx("div",{ref:u,className:m(ho({role:x,variant:e}),w&&"animate-pulse-subtle",l),...p,children:g})});Qt.displayName="MessageContent";const we=i.forwardRef(({showIcons:s=!0,visibleTabs:e=["todo","files"],variant:n="default",className:o,...a},l)=>{const p=[{id:"todo",label:"To-do",icon:st},{id:"files",label:"Files",icon:nt},{id:"database",label:"Database",icon:ot},{id:"sources",label:"Sources",icon:rt}].filter(r=>e.includes(r.id)),u=n==="compact"?"gap-[4px]":"gap-3";return t.jsx(G,{ref:l,className:m("w-full justify-start bg-transparent p-0 h-auto",u,o),...a,children:p.map(r=>{const c=r.icon;return t.jsxs(K,{value:r.id,className:m("gap-2 px-3 py-1.5 rounded-lg text-sm font-medium","data-[state=active]:bg-zinc-100 data-[state=active]:text-foreground","data-[state=inactive]:text-muted-foreground"),children:[s&&c&&t.jsx(c,{className:"size-4"}),r.label]},r.id)})})});we.displayName="PanelTabsHeader";const xo=i.forwardRef(({className:s,children:e,...n},o)=>t.jsxs(Ge,{ref:o,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),...n,children:[e,t.jsx(ws,{asChild:!0,children:t.jsx(Ds,{className:"h-4 w-4 opacity-50"})})]}));xo.displayName=Ge.displayName;const Gt=i.forwardRef(({className:s,...e},n)=>t.jsx(Ke,{ref:n,className:m("flex cursor-default items-center justify-center py-1",s),...e,children:t.jsx(me,{className:"h-4 w-4"})}));Gt.displayName=Ke.displayName;const Kt=i.forwardRef(({className:s,...e},n)=>t.jsx(Xe,{ref:n,className:m("flex cursor-default items-center justify-center py-1",s),...e,children:t.jsx(ge,{className:"h-4 w-4"})}));Kt.displayName=Xe.displayName;const bo=i.forwardRef(({className:s,children:e,position:n="popper",...o},a)=>t.jsx(vs,{children:t.jsxs(Je,{ref:a,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",n==="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:n,...o,children:[t.jsx(Gt,{}),t.jsx(Ns,{className:m("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:e}),t.jsx(Kt,{})]})}));bo.displayName=Je.displayName;const yo=i.forwardRef(({className:s,...e},n)=>t.jsx(Ye,{ref:n,className:m("py-1.5 pl-8 pr-2 text-sm font-semibold",s),...e}));yo.displayName=Ye.displayName;const wo=i.forwardRef(({className:s,children:e,...n},o)=>t.jsxs(Ze,{ref:o,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),...n,children:[t.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:t.jsx(js,{children:t.jsx(it,{className:"h-4 w-4"})})}),t.jsx(Ss,{children:e})]}));wo.displayName=Ze.displayName;const vo=i.forwardRef(({className:s,...e},n)=>t.jsx(et,{ref:n,className:m("-mx-1 my-1 h-px bg-muted",s),...e}));vo.displayName=et.displayName;const Xt=i.forwardRef(({task:s,collapsible:e=!0,defaultExpanded:n=!1,onTaskClick:o,className:a,...l},d)=>{const[p,u]=i.useState(n),r=!!(s.details||s.files&&s.files.length>0),c={pending:lt,in_progress:ct,completed:_s}[s.status],f=()=>{switch(s.status){case"completed":return"text-green-500";case"in_progress":return"text-primary";default:return"text-foreground opacity-40"}},x=()=>{r&&e&&u(!p),o?.(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",a),...l,children:[t.jsxs("button",{type:"button",onClick:x,className:m("w-full flex items-center gap-3 px-3 py-2.5 text-left",r&&e&&"cursor-pointer"),disabled:!r&&!e,children:[t.jsx(c,{className:m("w-4 h-4 shrink-0",f(),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}),r&&e&&t.jsx(ge,{className:m("w-4 h-4 text-foreground opacity-50 transition-transform duration-200 shrink-0",p&&"rotate-180"),"aria-hidden":"true"})]}),r&&p&&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(w=>t.jsx("div",{className:"text-xs font-mono text-foreground opacity-70 bg-background px-2 py-1 rounded border border-border/50",children:w},w))})]})]})]})});Xt.displayName="Task";const No=i.forwardRef(({tasks:s,collapsible:e=!0,onTaskClick:n,emptyMessage:o="No tasks yet.",className:a,...l},d)=>t.jsx("div",{ref:d,className:m("space-y-2 max-h-96 overflow-y-auto",a),...l,children:s.length===0?t.jsx("p",{className:"text-sm text-foreground opacity-60 italic py-4 text-center",children:o}):s.map(p=>t.jsx(Xt,{task:p,collapsible:e,...n?{onTaskClick:n}:{}},p.id))}));No.displayName="TaskList";const jo=W("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"}}),So=i.forwardRef(({className:s,autoResize:e=!1,maxHeight:n=200,variant:o,...a},l)=>{const d=i.useRef(null),p=i.useCallback(r=>{d.current=r,typeof l=="function"?l(r):l&&(l.current=r)},[l]),u=i.useCallback(()=>{const r=d.current;if(!r||!e)return;r.style.height="auto";const c=Math.min(r.scrollHeight,n);r.style.height=`${c}px`,r.scrollHeight>n?r.style.overflowY="auto":r.style.overflowY="hidden"},[e,n]);return i.useEffect(()=>{u()},[u]),t.jsx("textarea",{className:m(jo({variant:o}),e&&"overflow-y-hidden",s),ref:p,...a})});So.displayName="Textarea";function Co(){return"http://localhost:3100"}const To={agentServerUrl:Co()};function ko(){const{client:s,error:e,sessionId:n}=qs({serverUrl:To.agentServerUrl});return t.jsx(Vn,{client:s,initialSessionId:n,error:e})}const Jt=document.getElementById("root");if(!Jt)throw new Error("Root element not found");is.createRoot(Jt).render(t.jsx(ls.StrictMode,{children:t.jsx(ko,{})}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as i,e,f as k}from"./vendor-
|
|
1
|
+
import{g as i,e,f as k}from"./vendor-Ccy0WTO1.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,4 +1,4 @@
|
|
|
1
|
-
import{r as s,R as st,j as l,a as pe,b as at,c as zo,d as it}from"./react-DWDN8s0r.js";import{h as ct,i as Yo,j as Xo,k as qo,m as Zo,p as Jo,q as Qo,t as er,v as tr,w as nr}from"./vendor-BxtqxsLB.js";function Pt(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function be(...e){return t=>{let n=!1;const o=e.map(r=>{const a=Pt(r,t);return!n&&typeof a=="function"&&(n=!0),a});if(n)return()=>{for(let r=0;r<o.length;r++){const a=o[r];typeof a=="function"?a():Pt(e[r],null)}}}}function M(...e){return s.useCallback(be(...e),e)}var or=Symbol.for("react.lazy"),_e=st[" use ".trim().toString()];function rr(e){return typeof e=="object"&&e!==null&&"then"in e}function Lt(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===or&&"_payload"in e&&rr(e._payload)}function kt(e){const t=sr(e),n=s.forwardRef((o,r)=>{let{children:a,...c}=o;Lt(a)&&typeof _e=="function"&&(a=_e(a._payload));const i=s.Children.toArray(a),u=i.find(ir);if(u){const d=u.props.children,f=i.map(p=>p===u?s.Children.count(d)>1?s.Children.only(null):s.isValidElement(d)?d.props.children:null:p);return l.jsx(t,{...c,ref:r,children:s.isValidElement(d)?s.cloneElement(d,void 0,f):null})}return l.jsx(t,{...c,ref:r,children:a})});return n.displayName=`${e}.Slot`,n}var qa=kt("Slot");function sr(e){const t=s.forwardRef((n,o)=>{let{children:r,...a}=n;if(Lt(r)&&typeof _e=="function"&&(r=_e(r._payload)),s.isValidElement(r)){const c=lr(r),i=cr(a,r.props);return r.type!==s.Fragment&&(i.ref=o?be(o,c):c),s.cloneElement(r,i)}return s.Children.count(r)>1?s.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var ar=Symbol("radix.slottable");function ir(e){return s.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===ar}function cr(e,t){const n={...t};for(const o in t){const r=e[o],a=t[o];/^on[A-Z]/.test(o)?r&&a?n[o]=(...i)=>{const u=a(...i);return r(...i),u}:r&&(n[o]=r):o==="style"?n[o]={...r,...a}:o==="className"&&(n[o]=[r,a].filter(Boolean).join(" "))}return{...e,...n}}function lr(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function E(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),n===!1||!r.defaultPrevented)return t?.(r)}}function ur(e,t){const n=s.createContext(t),o=a=>{const{children:c,...i}=a,u=s.useMemo(()=>i,Object.values(i));return l.jsx(n.Provider,{value:u,children:c})};o.displayName=e+"Provider";function r(a){const c=s.useContext(n);if(c)return c;if(t!==void 0)return t;throw new Error(`\`${a}\` must be used within \`${e}\``)}return[o,r]}function le(e,t=[]){let n=[];function o(a,c){const i=s.createContext(c),u=n.length;n=[...n,c];const d=p=>{const{scope:v,children:y,...C}=p,m=v?.[e]?.[u]||i,h=s.useMemo(()=>C,Object.values(C));return l.jsx(m.Provider,{value:h,children:y})};d.displayName=a+"Provider";function f(p,v){const y=v?.[e]?.[u]||i,C=s.useContext(y);if(C)return C;if(c!==void 0)return c;throw new Error(`\`${p}\` must be used within \`${a}\``)}return[d,f]}const r=()=>{const a=n.map(c=>s.createContext(c));return function(i){const u=i?.[e]||a;return s.useMemo(()=>({[`__scope${e}`]:{...i,[e]:u}}),[i,u])}};return r.scopeName=e,[o,dr(r,...t)]}function dr(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const o=e.map(r=>({useScope:r(),scopeName:r.scopeName}));return function(a){const c=o.reduce((i,{useScope:u,scopeName:d})=>{const p=u(a)[`__scope${d}`];return{...i,...p}},{});return s.useMemo(()=>({[`__scope${t.scopeName}`]:c}),[c])}};return n.scopeName=t.scopeName,n}function xe(e){const t=fr(e),n=s.forwardRef((o,r)=>{const{children:a,...c}=o,i=s.Children.toArray(a),u=i.find(mr);if(u){const d=u.props.children,f=i.map(p=>p===u?s.Children.count(d)>1?s.Children.only(null):s.isValidElement(d)?d.props.children:null:p);return l.jsx(t,{...c,ref:r,children:s.isValidElement(d)?s.cloneElement(d,void 0,f):null})}return l.jsx(t,{...c,ref:r,children:a})});return n.displayName=`${e}.Slot`,n}function fr(e){const t=s.forwardRef((n,o)=>{const{children:r,...a}=n;if(s.isValidElement(r)){const c=hr(r),i=vr(a,r.props);return r.type!==s.Fragment&&(i.ref=o?be(o,c):c),s.cloneElement(r,i)}return s.Children.count(r)>1?s.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var pr=Symbol("radix.slottable");function mr(e){return s.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===pr}function vr(e,t){const n={...t};for(const o in t){const r=e[o],a=t[o];/^on[A-Z]/.test(o)?r&&a?n[o]=(...i)=>{const u=a(...i);return r(...i),u}:r&&(n[o]=r):o==="style"?n[o]={...r,...a}:o==="className"&&(n[o]=[r,a].filter(Boolean).join(" "))}return{...e,...n}}function hr(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function lt(e){const t=e+"CollectionProvider",[n,o]=le(t),[r,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),c=m=>{const{scope:h,children:x}=m,g=pe.useRef(null),w=pe.useRef(new Map).current;return l.jsx(r,{scope:h,itemMap:w,collectionRef:g,children:x})};c.displayName=t;const i=e+"CollectionSlot",u=xe(i),d=pe.forwardRef((m,h)=>{const{scope:x,children:g}=m,w=a(i,x),R=M(h,w.collectionRef);return l.jsx(u,{ref:R,children:g})});d.displayName=i;const f=e+"CollectionItemSlot",p="data-radix-collection-item",v=xe(f),y=pe.forwardRef((m,h)=>{const{scope:x,children:g,...w}=m,R=pe.useRef(null),T=M(h,R),F=a(f,x);return pe.useEffect(()=>(F.itemMap.set(R,{ref:R,...w}),()=>void F.itemMap.delete(R))),l.jsx(v,{[p]:"",ref:T,children:g})});y.displayName=f;function C(m){const h=a(e+"CollectionConsumer",m);return pe.useCallback(()=>{const g=h.collectionRef.current;if(!g)return[];const w=Array.from(g.querySelectorAll(`[${p}]`));return Array.from(h.itemMap.values()).sort((F,I)=>w.indexOf(F.ref.current)-w.indexOf(I.ref.current))},[h.collectionRef,h.itemMap])}return[{Provider:c,Slot:d,ItemSlot:y},C,o]}var U=globalThis?.document?s.useLayoutEffect:()=>{},gr=st[" useId ".trim().toString()]||(()=>{}),xr=0;function De(e){const[t,n]=s.useState(gr());return U(()=>{n(o=>o??String(xr++))},[e]),t?`radix-${t}`:""}var wr=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],P=wr.reduce((e,t)=>{const n=xe(`Primitive.${t}`),o=s.forwardRef((r,a)=>{const{asChild:c,...i}=r,u=c?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),l.jsx(u,{...i,ref:a})});return o.displayName=`Primitive.${t}`,{...e,[t]:o}},{});function $t(e,t){e&&at.flushSync(()=>e.dispatchEvent(t))}function ae(e){const t=s.useRef(e);return s.useEffect(()=>{t.current=e}),s.useMemo(()=>(...n)=>t.current?.(...n),[])}var yr=st[" useInsertionEffect ".trim().toString()]||U;function Bt({prop:e,defaultProp:t,onChange:n=()=>{},caller:o}){const[r,a,c]=Cr({defaultProp:t,onChange:n}),i=e!==void 0,u=i?e:r;{const f=s.useRef(e!==void 0);s.useEffect(()=>{const p=f.current;p!==i&&console.warn(`${o} is changing from ${p?"controlled":"uncontrolled"} to ${i?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),f.current=i},[i,o])}const d=s.useCallback(f=>{if(i){const p=Sr(f)?f(e):f;p!==e&&c.current?.(p)}else a(f)},[i,e,a,c]);return[u,d]}function Cr({defaultProp:e,onChange:t}){const[n,o]=s.useState(e),r=s.useRef(n),a=s.useRef(t);return yr(()=>{a.current=t},[t]),s.useEffect(()=>{r.current!==n&&(a.current?.(n),r.current=n)},[n,r]),[n,o,a]}function Sr(e){return typeof e=="function"}var Er=s.createContext(void 0);function Ut(e){const t=s.useContext(Er);return e||t||"ltr"}var ze="rovingFocusGroup.onEntryFocus",br={bubbles:!1,cancelable:!0},Re="RovingFocusGroup",[Ze,Kt,Rr]=lt(Re),[Ir,Oe]=le(Re,[Rr]),[Pr,_r]=Ir(Re),Wt=s.forwardRef((e,t)=>l.jsx(Ze.Provider,{scope:e.__scopeRovingFocusGroup,children:l.jsx(Ze.Slot,{scope:e.__scopeRovingFocusGroup,children:l.jsx(Mr,{...e,ref:t})})}));Wt.displayName=Re;var Mr=s.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:o,loop:r=!1,dir:a,currentTabStopId:c,defaultCurrentTabStopId:i,onCurrentTabStopIdChange:u,onEntryFocus:d,preventScrollOnEntryFocus:f=!1,...p}=e,v=s.useRef(null),y=M(t,v),C=Ut(a),[m,h]=Bt({prop:c,defaultProp:i??null,onChange:u,caller:Re}),[x,g]=s.useState(!1),w=ae(d),R=Kt(n),T=s.useRef(!1),[F,I]=s.useState(0);return s.useEffect(()=>{const _=v.current;if(_)return _.addEventListener(ze,w),()=>_.removeEventListener(ze,w)},[w]),l.jsx(Pr,{scope:n,orientation:o,dir:C,loop:r,currentTabStopId:m,onItemFocus:s.useCallback(_=>h(_),[h]),onItemShiftTab:s.useCallback(()=>g(!0),[]),onFocusableItemAdd:s.useCallback(()=>I(_=>_+1),[]),onFocusableItemRemove:s.useCallback(()=>I(_=>_-1),[]),children:l.jsx(P.div,{tabIndex:x||F===0?-1:0,"data-orientation":o,...p,ref:y,style:{outline:"none",...e.style},onMouseDown:E(e.onMouseDown,()=>{T.current=!0}),onFocus:E(e.onFocus,_=>{const $=!T.current;if(_.target===_.currentTarget&&$&&!x){const L=new CustomEvent(ze,br);if(_.currentTarget.dispatchEvent(L),!L.defaultPrevented){const B=R().filter(k=>k.focusable),K=B.find(k=>k.active),W=B.find(k=>k.id===m),H=[K,W,...B].filter(Boolean).map(k=>k.ref.current);Ht(H,f)}}T.current=!1}),onBlur:E(e.onBlur,()=>g(!1))})})}),Gt="RovingFocusGroupItem",Vt=s.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:o=!0,active:r=!1,tabStopId:a,children:c,...i}=e,u=De(),d=a||u,f=_r(Gt,n),p=f.currentTabStopId===d,v=Kt(n),{onFocusableItemAdd:y,onFocusableItemRemove:C,currentTabStopId:m}=f;return s.useEffect(()=>{if(o)return y(),()=>C()},[o,y,C]),l.jsx(Ze.ItemSlot,{scope:n,id:d,focusable:o,active:r,children:l.jsx(P.span,{tabIndex:p?0:-1,"data-orientation":f.orientation,...i,ref:t,onMouseDown:E(e.onMouseDown,h=>{o?f.onItemFocus(d):h.preventDefault()}),onFocus:E(e.onFocus,()=>f.onItemFocus(d)),onKeyDown:E(e.onKeyDown,h=>{if(h.key==="Tab"&&h.shiftKey){f.onItemShiftTab();return}if(h.target!==h.currentTarget)return;const x=Ar(h,f.orientation,f.dir);if(x!==void 0){if(h.metaKey||h.ctrlKey||h.altKey||h.shiftKey)return;h.preventDefault();let w=v().filter(R=>R.focusable).map(R=>R.ref.current);if(x==="last")w.reverse();else if(x==="prev"||x==="next"){x==="prev"&&w.reverse();const R=w.indexOf(h.currentTarget);w=f.loop?Dr(w,R+1):w.slice(R+1)}setTimeout(()=>Ht(w))}}),children:typeof c=="function"?c({isCurrentTabStop:p,hasTabStop:m!=null}):c})})});Vt.displayName=Gt;var Tr={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Nr(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Ar(e,t,n){const o=Nr(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(o))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(o)))return Tr[o]}function Ht(e,t=!1){const n=document.activeElement;for(const o of e)if(o===n||(o.focus({preventScroll:t}),document.activeElement!==n))return}function Dr(e,t){return e.map((n,o)=>e[(t+o)%e.length])}var zt=Wt,Yt=Vt;function Or(e,t){return s.useReducer((n,o)=>t[n][o]??n,e)}var ie=e=>{const{present:t,children:n}=e,o=jr(t),r=typeof n=="function"?n({present:o.isPresent}):s.Children.only(n),a=M(o.ref,Fr(r));return typeof n=="function"||o.isPresent?s.cloneElement(r,{ref:a}):null};ie.displayName="Presence";function jr(e){const[t,n]=s.useState(),o=s.useRef(null),r=s.useRef(e),a=s.useRef("none"),c=e?"mounted":"unmounted",[i,u]=Or(c,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return s.useEffect(()=>{const d=Pe(o.current);a.current=i==="mounted"?d:"none"},[i]),U(()=>{const d=o.current,f=r.current;if(f!==e){const v=a.current,y=Pe(d);e?u("MOUNT"):y==="none"||d?.display==="none"?u("UNMOUNT"):u(f&&v!==y?"ANIMATION_OUT":"UNMOUNT"),r.current=e}},[e,u]),U(()=>{if(t){let d;const f=t.ownerDocument.defaultView??window,p=y=>{const m=Pe(o.current).includes(CSS.escape(y.animationName));if(y.target===t&&m&&(u("ANIMATION_END"),!r.current)){const h=t.style.animationFillMode;t.style.animationFillMode="forwards",d=f.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=h)})}},v=y=>{y.target===t&&(a.current=Pe(o.current))};return t.addEventListener("animationstart",v),t.addEventListener("animationcancel",p),t.addEventListener("animationend",p),()=>{f.clearTimeout(d),t.removeEventListener("animationstart",v),t.removeEventListener("animationcancel",p),t.removeEventListener("animationend",p)}}else u("ANIMATION_END")},[t,u]),{isPresent:["mounted","unmountSuspended"].includes(i),ref:s.useCallback(d=>{o.current=d?getComputedStyle(d):null,n(d)},[])}}function Pe(e){return e?.animationName||"none"}function Fr(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var je="Tabs",[Lr]=le(je,[Oe]),Xt=Oe(),[kr,ut]=Lr(je),qt=s.forwardRef((e,t)=>{const{__scopeTabs:n,value:o,onValueChange:r,defaultValue:a,orientation:c="horizontal",dir:i,activationMode:u="automatic",...d}=e,f=Ut(i),[p,v]=Bt({prop:o,onChange:r,defaultProp:a??"",caller:je});return l.jsx(kr,{scope:n,baseId:De(),value:p,onValueChange:v,orientation:c,dir:f,activationMode:u,children:l.jsx(P.div,{dir:f,"data-orientation":c,...d,ref:t})})});qt.displayName=je;var Zt="TabsList",Jt=s.forwardRef((e,t)=>{const{__scopeTabs:n,loop:o=!0,...r}=e,a=ut(Zt,n),c=Xt(n);return l.jsx(zt,{asChild:!0,...c,orientation:a.orientation,dir:a.dir,loop:o,children:l.jsx(P.div,{role:"tablist","aria-orientation":a.orientation,...r,ref:t})})});Jt.displayName=Zt;var Qt="TabsTrigger",en=s.forwardRef((e,t)=>{const{__scopeTabs:n,value:o,disabled:r=!1,...a}=e,c=ut(Qt,n),i=Xt(n),u=on(c.baseId,o),d=rn(c.baseId,o),f=o===c.value;return l.jsx(Yt,{asChild:!0,...i,focusable:!r,active:f,children:l.jsx(P.button,{type:"button",role:"tab","aria-selected":f,"aria-controls":d,"data-state":f?"active":"inactive","data-disabled":r?"":void 0,disabled:r,id:u,...a,ref:t,onMouseDown:E(e.onMouseDown,p=>{!r&&p.button===0&&p.ctrlKey===!1?c.onValueChange(o):p.preventDefault()}),onKeyDown:E(e.onKeyDown,p=>{[" ","Enter"].includes(p.key)&&c.onValueChange(o)}),onFocus:E(e.onFocus,()=>{const p=c.activationMode!=="manual";!f&&!r&&p&&c.onValueChange(o)})})})});en.displayName=Qt;var tn="TabsContent",nn=s.forwardRef((e,t)=>{const{__scopeTabs:n,value:o,forceMount:r,children:a,...c}=e,i=ut(tn,n),u=on(i.baseId,o),d=rn(i.baseId,o),f=o===i.value,p=s.useRef(f);return s.useEffect(()=>{const v=requestAnimationFrame(()=>p.current=!1);return()=>cancelAnimationFrame(v)},[]),l.jsx(ie,{present:r||f,children:({present:v})=>l.jsx(P.div,{"data-state":f?"active":"inactive","data-orientation":i.orientation,role:"tabpanel","aria-labelledby":u,hidden:!v,id:d,tabIndex:0,...c,ref:t,style:{...e.style,animationDuration:p.current?"0s":void 0},children:v&&a})})});nn.displayName=tn;function on(e,t){return`${e}-trigger-${t}`}function rn(e,t){return`${e}-content-${t}`}var Za=qt,Ja=Jt,Qa=en,ei=nn;function $r(e,t=globalThis?.document){const n=ae(e);s.useEffect(()=>{const o=r=>{r.key==="Escape"&&n(r)};return t.addEventListener("keydown",o,{capture:!0}),()=>t.removeEventListener("keydown",o,{capture:!0})},[n,t])}var Br="DismissableLayer",Je="dismissableLayer.update",Ur="dismissableLayer.pointerDownOutside",Kr="dismissableLayer.focusOutside",_t,sn=s.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Fe=s.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:o,onPointerDownOutside:r,onFocusOutside:a,onInteractOutside:c,onDismiss:i,...u}=e,d=s.useContext(sn),[f,p]=s.useState(null),v=f?.ownerDocument??globalThis?.document,[,y]=s.useState({}),C=M(t,I=>p(I)),m=Array.from(d.layers),[h]=[...d.layersWithOutsidePointerEventsDisabled].slice(-1),x=m.indexOf(h),g=f?m.indexOf(f):-1,w=d.layersWithOutsidePointerEventsDisabled.size>0,R=g>=x,T=Vr(I=>{const _=I.target,$=[...d.branches].some(L=>L.contains(_));!R||$||(r?.(I),c?.(I),I.defaultPrevented||i?.())},v),F=Hr(I=>{const _=I.target;[...d.branches].some(L=>L.contains(_))||(a?.(I),c?.(I),I.defaultPrevented||i?.())},v);return $r(I=>{g===d.layers.size-1&&(o?.(I),!I.defaultPrevented&&i&&(I.preventDefault(),i()))},v),s.useEffect(()=>{if(f)return n&&(d.layersWithOutsidePointerEventsDisabled.size===0&&(_t=v.body.style.pointerEvents,v.body.style.pointerEvents="none"),d.layersWithOutsidePointerEventsDisabled.add(f)),d.layers.add(f),Mt(),()=>{n&&d.layersWithOutsidePointerEventsDisabled.size===1&&(v.body.style.pointerEvents=_t)}},[f,v,n,d]),s.useEffect(()=>()=>{f&&(d.layers.delete(f),d.layersWithOutsidePointerEventsDisabled.delete(f),Mt())},[f,d]),s.useEffect(()=>{const I=()=>y({});return document.addEventListener(Je,I),()=>document.removeEventListener(Je,I)},[]),l.jsx(P.div,{...u,ref:C,style:{pointerEvents:w?R?"auto":"none":void 0,...e.style},onFocusCapture:E(e.onFocusCapture,F.onFocusCapture),onBlurCapture:E(e.onBlurCapture,F.onBlurCapture),onPointerDownCapture:E(e.onPointerDownCapture,T.onPointerDownCapture)})});Fe.displayName=Br;var Wr="DismissableLayerBranch",Gr=s.forwardRef((e,t)=>{const n=s.useContext(sn),o=s.useRef(null),r=M(t,o);return s.useEffect(()=>{const a=o.current;if(a)return n.branches.add(a),()=>{n.branches.delete(a)}},[n.branches]),l.jsx(P.div,{...e,ref:r})});Gr.displayName=Wr;function Vr(e,t=globalThis?.document){const n=ae(e),o=s.useRef(!1),r=s.useRef(()=>{});return s.useEffect(()=>{const a=i=>{if(i.target&&!o.current){let u=function(){an(Ur,n,d,{discrete:!0})};const d={originalEvent:i};i.pointerType==="touch"?(t.removeEventListener("click",r.current),r.current=u,t.addEventListener("click",r.current,{once:!0})):u()}else t.removeEventListener("click",r.current);o.current=!1},c=window.setTimeout(()=>{t.addEventListener("pointerdown",a)},0);return()=>{window.clearTimeout(c),t.removeEventListener("pointerdown",a),t.removeEventListener("click",r.current)}},[t,n]),{onPointerDownCapture:()=>o.current=!0}}function Hr(e,t=globalThis?.document){const n=ae(e),o=s.useRef(!1);return s.useEffect(()=>{const r=a=>{a.target&&!o.current&&an(Kr,n,{originalEvent:a},{discrete:!1})};return t.addEventListener("focusin",r),()=>t.removeEventListener("focusin",r)},[t,n]),{onFocusCapture:()=>o.current=!0,onBlurCapture:()=>o.current=!1}}function Mt(){const e=new CustomEvent(Je);document.dispatchEvent(e)}function an(e,t,n,{discrete:o}){const r=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&r.addEventListener(e,t,{once:!0}),o?$t(r,a):r.dispatchEvent(a)}var Ye="focusScope.autoFocusOnMount",Xe="focusScope.autoFocusOnUnmount",Tt={bubbles:!1,cancelable:!0},zr="FocusScope",Le=s.forwardRef((e,t)=>{const{loop:n=!1,trapped:o=!1,onMountAutoFocus:r,onUnmountAutoFocus:a,...c}=e,[i,u]=s.useState(null),d=ae(r),f=ae(a),p=s.useRef(null),v=M(t,m=>u(m)),y=s.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;s.useEffect(()=>{if(o){let m=function(w){if(y.paused||!i)return;const R=w.target;i.contains(R)?p.current=R:ce(p.current,{select:!0})},h=function(w){if(y.paused||!i)return;const R=w.relatedTarget;R!==null&&(i.contains(R)||ce(p.current,{select:!0}))},x=function(w){if(document.activeElement===document.body)for(const T of w)T.removedNodes.length>0&&ce(i)};document.addEventListener("focusin",m),document.addEventListener("focusout",h);const g=new MutationObserver(x);return i&&g.observe(i,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",m),document.removeEventListener("focusout",h),g.disconnect()}}},[o,i,y.paused]),s.useEffect(()=>{if(i){At.add(y);const m=document.activeElement;if(!i.contains(m)){const x=new CustomEvent(Ye,Tt);i.addEventListener(Ye,d),i.dispatchEvent(x),x.defaultPrevented||(Yr(Qr(cn(i)),{select:!0}),document.activeElement===m&&ce(i))}return()=>{i.removeEventListener(Ye,d),setTimeout(()=>{const x=new CustomEvent(Xe,Tt);i.addEventListener(Xe,f),i.dispatchEvent(x),x.defaultPrevented||ce(m??document.body,{select:!0}),i.removeEventListener(Xe,f),At.remove(y)},0)}}},[i,d,f,y]);const C=s.useCallback(m=>{if(!n&&!o||y.paused)return;const h=m.key==="Tab"&&!m.altKey&&!m.ctrlKey&&!m.metaKey,x=document.activeElement;if(h&&x){const g=m.currentTarget,[w,R]=Xr(g);w&&R?!m.shiftKey&&x===R?(m.preventDefault(),n&&ce(w,{select:!0})):m.shiftKey&&x===w&&(m.preventDefault(),n&&ce(R,{select:!0})):x===g&&m.preventDefault()}},[n,o,y.paused]);return l.jsx(P.div,{tabIndex:-1,...c,ref:v,onKeyDown:C})});Le.displayName=zr;function Yr(e,{select:t=!1}={}){const n=document.activeElement;for(const o of e)if(ce(o,{select:t}),document.activeElement!==n)return}function Xr(e){const t=cn(e),n=Nt(t,e),o=Nt(t.reverse(),e);return[n,o]}function cn(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:o=>{const r=o.tagName==="INPUT"&&o.type==="hidden";return o.disabled||o.hidden||r?NodeFilter.FILTER_SKIP:o.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function Nt(e,t){for(const n of e)if(!qr(n,{upTo:t}))return n}function qr(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function Zr(e){return e instanceof HTMLInputElement&&"select"in e}function ce(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Zr(e)&&t&&e.select()}}var At=Jr();function Jr(){let e=[];return{add(t){const n=e[0];t!==n&&n?.pause(),e=Dt(e,t),e.unshift(t)},remove(t){e=Dt(e,t),e[0]?.resume()}}}function Dt(e,t){const n=[...e],o=n.indexOf(t);return o!==-1&&n.splice(o,1),n}function Qr(e){return e.filter(t=>t.tagName!=="A")}var es="Portal",ke=s.forwardRef((e,t)=>{const{container:n,...o}=e,[r,a]=s.useState(!1);U(()=>a(!0),[]);const c=n||r&&globalThis?.document?.body;return c?zo.createPortal(l.jsx(P.div,{...o,ref:t}),c):null});ke.displayName=es;var qe=0;function dt(){s.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Ot()),document.body.insertAdjacentElement("beforeend",e[1]??Ot()),qe++,()=>{qe===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),qe--}},[])}function Ot(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var ln="Dialog",[un]=le(ln),[ti,oe]=un(ln),dn="DialogTrigger",ts=s.forwardRef((e,t)=>{const{__scopeDialog:n,...o}=e,r=oe(dn,n),a=M(t,r.triggerRef);return l.jsx(P.button,{type:"button","aria-haspopup":"dialog","aria-expanded":r.open,"aria-controls":r.contentId,"data-state":mt(r.open),...o,ref:a,onClick:E(e.onClick,r.onOpenToggle)})});ts.displayName=dn;var ft="DialogPortal",[ns,fn]=un(ft,{forceMount:void 0}),pn=e=>{const{__scopeDialog:t,forceMount:n,children:o,container:r}=e,a=oe(ft,t);return l.jsx(ns,{scope:t,forceMount:n,children:s.Children.map(o,c=>l.jsx(ie,{present:n||a.open,children:l.jsx(ke,{asChild:!0,container:r,children:c})}))})};pn.displayName=ft;var Me="DialogOverlay",mn=s.forwardRef((e,t)=>{const n=fn(Me,e.__scopeDialog),{forceMount:o=n.forceMount,...r}=e,a=oe(Me,e.__scopeDialog);return a.modal?l.jsx(ie,{present:o||a.open,children:l.jsx(rs,{...r,ref:t})}):null});mn.displayName=Me;var os=xe("DialogOverlay.RemoveScroll"),rs=s.forwardRef((e,t)=>{const{__scopeDialog:n,...o}=e,r=oe(Me,n);return l.jsx(it,{as:os,allowPinchZoom:!0,shards:[r.contentRef],children:l.jsx(P.div,{"data-state":mt(r.open),...o,ref:t,style:{pointerEvents:"auto",...o.style}})})}),me="DialogContent",vn=s.forwardRef((e,t)=>{const n=fn(me,e.__scopeDialog),{forceMount:o=n.forceMount,...r}=e,a=oe(me,e.__scopeDialog);return l.jsx(ie,{present:o||a.open,children:a.modal?l.jsx(ss,{...r,ref:t}):l.jsx(as,{...r,ref:t})})});vn.displayName=me;var ss=s.forwardRef((e,t)=>{const n=oe(me,e.__scopeDialog),o=s.useRef(null),r=M(t,n.contentRef,o);return s.useEffect(()=>{const a=o.current;if(a)return ct(a)},[]),l.jsx(hn,{...e,ref:r,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:E(e.onCloseAutoFocus,a=>{a.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:E(e.onPointerDownOutside,a=>{const c=a.detail.originalEvent,i=c.button===0&&c.ctrlKey===!0;(c.button===2||i)&&a.preventDefault()}),onFocusOutside:E(e.onFocusOutside,a=>a.preventDefault())})}),as=s.forwardRef((e,t)=>{const n=oe(me,e.__scopeDialog),o=s.useRef(!1),r=s.useRef(!1);return l.jsx(hn,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{e.onCloseAutoFocus?.(a),a.defaultPrevented||(o.current||n.triggerRef.current?.focus(),a.preventDefault()),o.current=!1,r.current=!1},onInteractOutside:a=>{e.onInteractOutside?.(a),a.defaultPrevented||(o.current=!0,a.detail.originalEvent.type==="pointerdown"&&(r.current=!0));const c=a.target;n.triggerRef.current?.contains(c)&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&r.current&&a.preventDefault()}})}),hn=s.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:o,onOpenAutoFocus:r,onCloseAutoFocus:a,...c}=e,i=oe(me,n),u=s.useRef(null),d=M(t,u);return dt(),l.jsxs(l.Fragment,{children:[l.jsx(Le,{asChild:!0,loop:!0,trapped:o,onMountAutoFocus:r,onUnmountAutoFocus:a,children:l.jsx(Fe,{role:"dialog",id:i.contentId,"aria-describedby":i.descriptionId,"aria-labelledby":i.titleId,"data-state":mt(i.open),...c,ref:d,onDismiss:()=>i.onOpenChange(!1)})}),l.jsxs(l.Fragment,{children:[l.jsx(is,{titleId:i.titleId}),l.jsx(ls,{contentRef:u,descriptionId:i.descriptionId})]})]})}),pt="DialogTitle",gn=s.forwardRef((e,t)=>{const{__scopeDialog:n,...o}=e,r=oe(pt,n);return l.jsx(P.h2,{id:r.titleId,...o,ref:t})});gn.displayName=pt;var xn="DialogDescription",wn=s.forwardRef((e,t)=>{const{__scopeDialog:n,...o}=e,r=oe(xn,n);return l.jsx(P.p,{id:r.descriptionId,...o,ref:t})});wn.displayName=xn;var yn="DialogClose",Cn=s.forwardRef((e,t)=>{const{__scopeDialog:n,...o}=e,r=oe(yn,n);return l.jsx(P.button,{type:"button",...o,ref:t,onClick:E(e.onClick,()=>r.onOpenChange(!1))})});Cn.displayName=yn;function mt(e){return e?"open":"closed"}var Sn="DialogTitleWarning",[ni,En]=ur(Sn,{contentName:me,titleName:pt,docsSlug:"dialog"}),is=({titleId:e})=>{const t=En(Sn),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
1
|
+
import{r as s,R as st,j as l,a as pe,b as at,c as zo,d as it}from"./react-CrKZJ-ak.js";import{h as ct,i as Yo,j as Xo,k as qo,m as Zo,p as Jo,q as Qo,t as er,v as tr,w as nr}from"./vendor-Ccy0WTO1.js";function Pt(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function be(...e){return t=>{let n=!1;const o=e.map(r=>{const a=Pt(r,t);return!n&&typeof a=="function"&&(n=!0),a});if(n)return()=>{for(let r=0;r<o.length;r++){const a=o[r];typeof a=="function"?a():Pt(e[r],null)}}}}function M(...e){return s.useCallback(be(...e),e)}var or=Symbol.for("react.lazy"),_e=st[" use ".trim().toString()];function rr(e){return typeof e=="object"&&e!==null&&"then"in e}function Lt(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===or&&"_payload"in e&&rr(e._payload)}function kt(e){const t=sr(e),n=s.forwardRef((o,r)=>{let{children:a,...c}=o;Lt(a)&&typeof _e=="function"&&(a=_e(a._payload));const i=s.Children.toArray(a),u=i.find(ir);if(u){const d=u.props.children,f=i.map(p=>p===u?s.Children.count(d)>1?s.Children.only(null):s.isValidElement(d)?d.props.children:null:p);return l.jsx(t,{...c,ref:r,children:s.isValidElement(d)?s.cloneElement(d,void 0,f):null})}return l.jsx(t,{...c,ref:r,children:a})});return n.displayName=`${e}.Slot`,n}var qa=kt("Slot");function sr(e){const t=s.forwardRef((n,o)=>{let{children:r,...a}=n;if(Lt(r)&&typeof _e=="function"&&(r=_e(r._payload)),s.isValidElement(r)){const c=lr(r),i=cr(a,r.props);return r.type!==s.Fragment&&(i.ref=o?be(o,c):c),s.cloneElement(r,i)}return s.Children.count(r)>1?s.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var ar=Symbol("radix.slottable");function ir(e){return s.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===ar}function cr(e,t){const n={...t};for(const o in t){const r=e[o],a=t[o];/^on[A-Z]/.test(o)?r&&a?n[o]=(...i)=>{const u=a(...i);return r(...i),u}:r&&(n[o]=r):o==="style"?n[o]={...r,...a}:o==="className"&&(n[o]=[r,a].filter(Boolean).join(" "))}return{...e,...n}}function lr(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function E(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),n===!1||!r.defaultPrevented)return t?.(r)}}function ur(e,t){const n=s.createContext(t),o=a=>{const{children:c,...i}=a,u=s.useMemo(()=>i,Object.values(i));return l.jsx(n.Provider,{value:u,children:c})};o.displayName=e+"Provider";function r(a){const c=s.useContext(n);if(c)return c;if(t!==void 0)return t;throw new Error(`\`${a}\` must be used within \`${e}\``)}return[o,r]}function le(e,t=[]){let n=[];function o(a,c){const i=s.createContext(c),u=n.length;n=[...n,c];const d=p=>{const{scope:v,children:y,...C}=p,m=v?.[e]?.[u]||i,h=s.useMemo(()=>C,Object.values(C));return l.jsx(m.Provider,{value:h,children:y})};d.displayName=a+"Provider";function f(p,v){const y=v?.[e]?.[u]||i,C=s.useContext(y);if(C)return C;if(c!==void 0)return c;throw new Error(`\`${p}\` must be used within \`${a}\``)}return[d,f]}const r=()=>{const a=n.map(c=>s.createContext(c));return function(i){const u=i?.[e]||a;return s.useMemo(()=>({[`__scope${e}`]:{...i,[e]:u}}),[i,u])}};return r.scopeName=e,[o,dr(r,...t)]}function dr(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const o=e.map(r=>({useScope:r(),scopeName:r.scopeName}));return function(a){const c=o.reduce((i,{useScope:u,scopeName:d})=>{const p=u(a)[`__scope${d}`];return{...i,...p}},{});return s.useMemo(()=>({[`__scope${t.scopeName}`]:c}),[c])}};return n.scopeName=t.scopeName,n}function xe(e){const t=fr(e),n=s.forwardRef((o,r)=>{const{children:a,...c}=o,i=s.Children.toArray(a),u=i.find(mr);if(u){const d=u.props.children,f=i.map(p=>p===u?s.Children.count(d)>1?s.Children.only(null):s.isValidElement(d)?d.props.children:null:p);return l.jsx(t,{...c,ref:r,children:s.isValidElement(d)?s.cloneElement(d,void 0,f):null})}return l.jsx(t,{...c,ref:r,children:a})});return n.displayName=`${e}.Slot`,n}function fr(e){const t=s.forwardRef((n,o)=>{const{children:r,...a}=n;if(s.isValidElement(r)){const c=hr(r),i=vr(a,r.props);return r.type!==s.Fragment&&(i.ref=o?be(o,c):c),s.cloneElement(r,i)}return s.Children.count(r)>1?s.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var pr=Symbol("radix.slottable");function mr(e){return s.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===pr}function vr(e,t){const n={...t};for(const o in t){const r=e[o],a=t[o];/^on[A-Z]/.test(o)?r&&a?n[o]=(...i)=>{const u=a(...i);return r(...i),u}:r&&(n[o]=r):o==="style"?n[o]={...r,...a}:o==="className"&&(n[o]=[r,a].filter(Boolean).join(" "))}return{...e,...n}}function hr(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function lt(e){const t=e+"CollectionProvider",[n,o]=le(t),[r,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),c=m=>{const{scope:h,children:x}=m,g=pe.useRef(null),w=pe.useRef(new Map).current;return l.jsx(r,{scope:h,itemMap:w,collectionRef:g,children:x})};c.displayName=t;const i=e+"CollectionSlot",u=xe(i),d=pe.forwardRef((m,h)=>{const{scope:x,children:g}=m,w=a(i,x),R=M(h,w.collectionRef);return l.jsx(u,{ref:R,children:g})});d.displayName=i;const f=e+"CollectionItemSlot",p="data-radix-collection-item",v=xe(f),y=pe.forwardRef((m,h)=>{const{scope:x,children:g,...w}=m,R=pe.useRef(null),T=M(h,R),F=a(f,x);return pe.useEffect(()=>(F.itemMap.set(R,{ref:R,...w}),()=>void F.itemMap.delete(R))),l.jsx(v,{[p]:"",ref:T,children:g})});y.displayName=f;function C(m){const h=a(e+"CollectionConsumer",m);return pe.useCallback(()=>{const g=h.collectionRef.current;if(!g)return[];const w=Array.from(g.querySelectorAll(`[${p}]`));return Array.from(h.itemMap.values()).sort((F,I)=>w.indexOf(F.ref.current)-w.indexOf(I.ref.current))},[h.collectionRef,h.itemMap])}return[{Provider:c,Slot:d,ItemSlot:y},C,o]}var U=globalThis?.document?s.useLayoutEffect:()=>{},gr=st[" useId ".trim().toString()]||(()=>{}),xr=0;function De(e){const[t,n]=s.useState(gr());return U(()=>{n(o=>o??String(xr++))},[e]),t?`radix-${t}`:""}var wr=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],P=wr.reduce((e,t)=>{const n=xe(`Primitive.${t}`),o=s.forwardRef((r,a)=>{const{asChild:c,...i}=r,u=c?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),l.jsx(u,{...i,ref:a})});return o.displayName=`Primitive.${t}`,{...e,[t]:o}},{});function $t(e,t){e&&at.flushSync(()=>e.dispatchEvent(t))}function ae(e){const t=s.useRef(e);return s.useEffect(()=>{t.current=e}),s.useMemo(()=>(...n)=>t.current?.(...n),[])}var yr=st[" useInsertionEffect ".trim().toString()]||U;function Bt({prop:e,defaultProp:t,onChange:n=()=>{},caller:o}){const[r,a,c]=Cr({defaultProp:t,onChange:n}),i=e!==void 0,u=i?e:r;{const f=s.useRef(e!==void 0);s.useEffect(()=>{const p=f.current;p!==i&&console.warn(`${o} is changing from ${p?"controlled":"uncontrolled"} to ${i?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),f.current=i},[i,o])}const d=s.useCallback(f=>{if(i){const p=Sr(f)?f(e):f;p!==e&&c.current?.(p)}else a(f)},[i,e,a,c]);return[u,d]}function Cr({defaultProp:e,onChange:t}){const[n,o]=s.useState(e),r=s.useRef(n),a=s.useRef(t);return yr(()=>{a.current=t},[t]),s.useEffect(()=>{r.current!==n&&(a.current?.(n),r.current=n)},[n,r]),[n,o,a]}function Sr(e){return typeof e=="function"}var Er=s.createContext(void 0);function Ut(e){const t=s.useContext(Er);return e||t||"ltr"}var ze="rovingFocusGroup.onEntryFocus",br={bubbles:!1,cancelable:!0},Re="RovingFocusGroup",[Ze,Kt,Rr]=lt(Re),[Ir,Oe]=le(Re,[Rr]),[Pr,_r]=Ir(Re),Wt=s.forwardRef((e,t)=>l.jsx(Ze.Provider,{scope:e.__scopeRovingFocusGroup,children:l.jsx(Ze.Slot,{scope:e.__scopeRovingFocusGroup,children:l.jsx(Mr,{...e,ref:t})})}));Wt.displayName=Re;var Mr=s.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:o,loop:r=!1,dir:a,currentTabStopId:c,defaultCurrentTabStopId:i,onCurrentTabStopIdChange:u,onEntryFocus:d,preventScrollOnEntryFocus:f=!1,...p}=e,v=s.useRef(null),y=M(t,v),C=Ut(a),[m,h]=Bt({prop:c,defaultProp:i??null,onChange:u,caller:Re}),[x,g]=s.useState(!1),w=ae(d),R=Kt(n),T=s.useRef(!1),[F,I]=s.useState(0);return s.useEffect(()=>{const _=v.current;if(_)return _.addEventListener(ze,w),()=>_.removeEventListener(ze,w)},[w]),l.jsx(Pr,{scope:n,orientation:o,dir:C,loop:r,currentTabStopId:m,onItemFocus:s.useCallback(_=>h(_),[h]),onItemShiftTab:s.useCallback(()=>g(!0),[]),onFocusableItemAdd:s.useCallback(()=>I(_=>_+1),[]),onFocusableItemRemove:s.useCallback(()=>I(_=>_-1),[]),children:l.jsx(P.div,{tabIndex:x||F===0?-1:0,"data-orientation":o,...p,ref:y,style:{outline:"none",...e.style},onMouseDown:E(e.onMouseDown,()=>{T.current=!0}),onFocus:E(e.onFocus,_=>{const $=!T.current;if(_.target===_.currentTarget&&$&&!x){const L=new CustomEvent(ze,br);if(_.currentTarget.dispatchEvent(L),!L.defaultPrevented){const B=R().filter(k=>k.focusable),K=B.find(k=>k.active),W=B.find(k=>k.id===m),H=[K,W,...B].filter(Boolean).map(k=>k.ref.current);Ht(H,f)}}T.current=!1}),onBlur:E(e.onBlur,()=>g(!1))})})}),Gt="RovingFocusGroupItem",Vt=s.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:o=!0,active:r=!1,tabStopId:a,children:c,...i}=e,u=De(),d=a||u,f=_r(Gt,n),p=f.currentTabStopId===d,v=Kt(n),{onFocusableItemAdd:y,onFocusableItemRemove:C,currentTabStopId:m}=f;return s.useEffect(()=>{if(o)return y(),()=>C()},[o,y,C]),l.jsx(Ze.ItemSlot,{scope:n,id:d,focusable:o,active:r,children:l.jsx(P.span,{tabIndex:p?0:-1,"data-orientation":f.orientation,...i,ref:t,onMouseDown:E(e.onMouseDown,h=>{o?f.onItemFocus(d):h.preventDefault()}),onFocus:E(e.onFocus,()=>f.onItemFocus(d)),onKeyDown:E(e.onKeyDown,h=>{if(h.key==="Tab"&&h.shiftKey){f.onItemShiftTab();return}if(h.target!==h.currentTarget)return;const x=Ar(h,f.orientation,f.dir);if(x!==void 0){if(h.metaKey||h.ctrlKey||h.altKey||h.shiftKey)return;h.preventDefault();let w=v().filter(R=>R.focusable).map(R=>R.ref.current);if(x==="last")w.reverse();else if(x==="prev"||x==="next"){x==="prev"&&w.reverse();const R=w.indexOf(h.currentTarget);w=f.loop?Dr(w,R+1):w.slice(R+1)}setTimeout(()=>Ht(w))}}),children:typeof c=="function"?c({isCurrentTabStop:p,hasTabStop:m!=null}):c})})});Vt.displayName=Gt;var Tr={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Nr(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Ar(e,t,n){const o=Nr(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(o))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(o)))return Tr[o]}function Ht(e,t=!1){const n=document.activeElement;for(const o of e)if(o===n||(o.focus({preventScroll:t}),document.activeElement!==n))return}function Dr(e,t){return e.map((n,o)=>e[(t+o)%e.length])}var zt=Wt,Yt=Vt;function Or(e,t){return s.useReducer((n,o)=>t[n][o]??n,e)}var ie=e=>{const{present:t,children:n}=e,o=jr(t),r=typeof n=="function"?n({present:o.isPresent}):s.Children.only(n),a=M(o.ref,Fr(r));return typeof n=="function"||o.isPresent?s.cloneElement(r,{ref:a}):null};ie.displayName="Presence";function jr(e){const[t,n]=s.useState(),o=s.useRef(null),r=s.useRef(e),a=s.useRef("none"),c=e?"mounted":"unmounted",[i,u]=Or(c,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return s.useEffect(()=>{const d=Pe(o.current);a.current=i==="mounted"?d:"none"},[i]),U(()=>{const d=o.current,f=r.current;if(f!==e){const v=a.current,y=Pe(d);e?u("MOUNT"):y==="none"||d?.display==="none"?u("UNMOUNT"):u(f&&v!==y?"ANIMATION_OUT":"UNMOUNT"),r.current=e}},[e,u]),U(()=>{if(t){let d;const f=t.ownerDocument.defaultView??window,p=y=>{const m=Pe(o.current).includes(CSS.escape(y.animationName));if(y.target===t&&m&&(u("ANIMATION_END"),!r.current)){const h=t.style.animationFillMode;t.style.animationFillMode="forwards",d=f.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=h)})}},v=y=>{y.target===t&&(a.current=Pe(o.current))};return t.addEventListener("animationstart",v),t.addEventListener("animationcancel",p),t.addEventListener("animationend",p),()=>{f.clearTimeout(d),t.removeEventListener("animationstart",v),t.removeEventListener("animationcancel",p),t.removeEventListener("animationend",p)}}else u("ANIMATION_END")},[t,u]),{isPresent:["mounted","unmountSuspended"].includes(i),ref:s.useCallback(d=>{o.current=d?getComputedStyle(d):null,n(d)},[])}}function Pe(e){return e?.animationName||"none"}function Fr(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var je="Tabs",[Lr]=le(je,[Oe]),Xt=Oe(),[kr,ut]=Lr(je),qt=s.forwardRef((e,t)=>{const{__scopeTabs:n,value:o,onValueChange:r,defaultValue:a,orientation:c="horizontal",dir:i,activationMode:u="automatic",...d}=e,f=Ut(i),[p,v]=Bt({prop:o,onChange:r,defaultProp:a??"",caller:je});return l.jsx(kr,{scope:n,baseId:De(),value:p,onValueChange:v,orientation:c,dir:f,activationMode:u,children:l.jsx(P.div,{dir:f,"data-orientation":c,...d,ref:t})})});qt.displayName=je;var Zt="TabsList",Jt=s.forwardRef((e,t)=>{const{__scopeTabs:n,loop:o=!0,...r}=e,a=ut(Zt,n),c=Xt(n);return l.jsx(zt,{asChild:!0,...c,orientation:a.orientation,dir:a.dir,loop:o,children:l.jsx(P.div,{role:"tablist","aria-orientation":a.orientation,...r,ref:t})})});Jt.displayName=Zt;var Qt="TabsTrigger",en=s.forwardRef((e,t)=>{const{__scopeTabs:n,value:o,disabled:r=!1,...a}=e,c=ut(Qt,n),i=Xt(n),u=on(c.baseId,o),d=rn(c.baseId,o),f=o===c.value;return l.jsx(Yt,{asChild:!0,...i,focusable:!r,active:f,children:l.jsx(P.button,{type:"button",role:"tab","aria-selected":f,"aria-controls":d,"data-state":f?"active":"inactive","data-disabled":r?"":void 0,disabled:r,id:u,...a,ref:t,onMouseDown:E(e.onMouseDown,p=>{!r&&p.button===0&&p.ctrlKey===!1?c.onValueChange(o):p.preventDefault()}),onKeyDown:E(e.onKeyDown,p=>{[" ","Enter"].includes(p.key)&&c.onValueChange(o)}),onFocus:E(e.onFocus,()=>{const p=c.activationMode!=="manual";!f&&!r&&p&&c.onValueChange(o)})})})});en.displayName=Qt;var tn="TabsContent",nn=s.forwardRef((e,t)=>{const{__scopeTabs:n,value:o,forceMount:r,children:a,...c}=e,i=ut(tn,n),u=on(i.baseId,o),d=rn(i.baseId,o),f=o===i.value,p=s.useRef(f);return s.useEffect(()=>{const v=requestAnimationFrame(()=>p.current=!1);return()=>cancelAnimationFrame(v)},[]),l.jsx(ie,{present:r||f,children:({present:v})=>l.jsx(P.div,{"data-state":f?"active":"inactive","data-orientation":i.orientation,role:"tabpanel","aria-labelledby":u,hidden:!v,id:d,tabIndex:0,...c,ref:t,style:{...e.style,animationDuration:p.current?"0s":void 0},children:v&&a})})});nn.displayName=tn;function on(e,t){return`${e}-trigger-${t}`}function rn(e,t){return`${e}-content-${t}`}var Za=qt,Ja=Jt,Qa=en,ei=nn;function $r(e,t=globalThis?.document){const n=ae(e);s.useEffect(()=>{const o=r=>{r.key==="Escape"&&n(r)};return t.addEventListener("keydown",o,{capture:!0}),()=>t.removeEventListener("keydown",o,{capture:!0})},[n,t])}var Br="DismissableLayer",Je="dismissableLayer.update",Ur="dismissableLayer.pointerDownOutside",Kr="dismissableLayer.focusOutside",_t,sn=s.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Fe=s.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:o,onPointerDownOutside:r,onFocusOutside:a,onInteractOutside:c,onDismiss:i,...u}=e,d=s.useContext(sn),[f,p]=s.useState(null),v=f?.ownerDocument??globalThis?.document,[,y]=s.useState({}),C=M(t,I=>p(I)),m=Array.from(d.layers),[h]=[...d.layersWithOutsidePointerEventsDisabled].slice(-1),x=m.indexOf(h),g=f?m.indexOf(f):-1,w=d.layersWithOutsidePointerEventsDisabled.size>0,R=g>=x,T=Vr(I=>{const _=I.target,$=[...d.branches].some(L=>L.contains(_));!R||$||(r?.(I),c?.(I),I.defaultPrevented||i?.())},v),F=Hr(I=>{const _=I.target;[...d.branches].some(L=>L.contains(_))||(a?.(I),c?.(I),I.defaultPrevented||i?.())},v);return $r(I=>{g===d.layers.size-1&&(o?.(I),!I.defaultPrevented&&i&&(I.preventDefault(),i()))},v),s.useEffect(()=>{if(f)return n&&(d.layersWithOutsidePointerEventsDisabled.size===0&&(_t=v.body.style.pointerEvents,v.body.style.pointerEvents="none"),d.layersWithOutsidePointerEventsDisabled.add(f)),d.layers.add(f),Mt(),()=>{n&&d.layersWithOutsidePointerEventsDisabled.size===1&&(v.body.style.pointerEvents=_t)}},[f,v,n,d]),s.useEffect(()=>()=>{f&&(d.layers.delete(f),d.layersWithOutsidePointerEventsDisabled.delete(f),Mt())},[f,d]),s.useEffect(()=>{const I=()=>y({});return document.addEventListener(Je,I),()=>document.removeEventListener(Je,I)},[]),l.jsx(P.div,{...u,ref:C,style:{pointerEvents:w?R?"auto":"none":void 0,...e.style},onFocusCapture:E(e.onFocusCapture,F.onFocusCapture),onBlurCapture:E(e.onBlurCapture,F.onBlurCapture),onPointerDownCapture:E(e.onPointerDownCapture,T.onPointerDownCapture)})});Fe.displayName=Br;var Wr="DismissableLayerBranch",Gr=s.forwardRef((e,t)=>{const n=s.useContext(sn),o=s.useRef(null),r=M(t,o);return s.useEffect(()=>{const a=o.current;if(a)return n.branches.add(a),()=>{n.branches.delete(a)}},[n.branches]),l.jsx(P.div,{...e,ref:r})});Gr.displayName=Wr;function Vr(e,t=globalThis?.document){const n=ae(e),o=s.useRef(!1),r=s.useRef(()=>{});return s.useEffect(()=>{const a=i=>{if(i.target&&!o.current){let u=function(){an(Ur,n,d,{discrete:!0})};const d={originalEvent:i};i.pointerType==="touch"?(t.removeEventListener("click",r.current),r.current=u,t.addEventListener("click",r.current,{once:!0})):u()}else t.removeEventListener("click",r.current);o.current=!1},c=window.setTimeout(()=>{t.addEventListener("pointerdown",a)},0);return()=>{window.clearTimeout(c),t.removeEventListener("pointerdown",a),t.removeEventListener("click",r.current)}},[t,n]),{onPointerDownCapture:()=>o.current=!0}}function Hr(e,t=globalThis?.document){const n=ae(e),o=s.useRef(!1);return s.useEffect(()=>{const r=a=>{a.target&&!o.current&&an(Kr,n,{originalEvent:a},{discrete:!1})};return t.addEventListener("focusin",r),()=>t.removeEventListener("focusin",r)},[t,n]),{onFocusCapture:()=>o.current=!0,onBlurCapture:()=>o.current=!1}}function Mt(){const e=new CustomEvent(Je);document.dispatchEvent(e)}function an(e,t,n,{discrete:o}){const r=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&r.addEventListener(e,t,{once:!0}),o?$t(r,a):r.dispatchEvent(a)}var Ye="focusScope.autoFocusOnMount",Xe="focusScope.autoFocusOnUnmount",Tt={bubbles:!1,cancelable:!0},zr="FocusScope",Le=s.forwardRef((e,t)=>{const{loop:n=!1,trapped:o=!1,onMountAutoFocus:r,onUnmountAutoFocus:a,...c}=e,[i,u]=s.useState(null),d=ae(r),f=ae(a),p=s.useRef(null),v=M(t,m=>u(m)),y=s.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;s.useEffect(()=>{if(o){let m=function(w){if(y.paused||!i)return;const R=w.target;i.contains(R)?p.current=R:ce(p.current,{select:!0})},h=function(w){if(y.paused||!i)return;const R=w.relatedTarget;R!==null&&(i.contains(R)||ce(p.current,{select:!0}))},x=function(w){if(document.activeElement===document.body)for(const T of w)T.removedNodes.length>0&&ce(i)};document.addEventListener("focusin",m),document.addEventListener("focusout",h);const g=new MutationObserver(x);return i&&g.observe(i,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",m),document.removeEventListener("focusout",h),g.disconnect()}}},[o,i,y.paused]),s.useEffect(()=>{if(i){At.add(y);const m=document.activeElement;if(!i.contains(m)){const x=new CustomEvent(Ye,Tt);i.addEventListener(Ye,d),i.dispatchEvent(x),x.defaultPrevented||(Yr(Qr(cn(i)),{select:!0}),document.activeElement===m&&ce(i))}return()=>{i.removeEventListener(Ye,d),setTimeout(()=>{const x=new CustomEvent(Xe,Tt);i.addEventListener(Xe,f),i.dispatchEvent(x),x.defaultPrevented||ce(m??document.body,{select:!0}),i.removeEventListener(Xe,f),At.remove(y)},0)}}},[i,d,f,y]);const C=s.useCallback(m=>{if(!n&&!o||y.paused)return;const h=m.key==="Tab"&&!m.altKey&&!m.ctrlKey&&!m.metaKey,x=document.activeElement;if(h&&x){const g=m.currentTarget,[w,R]=Xr(g);w&&R?!m.shiftKey&&x===R?(m.preventDefault(),n&&ce(w,{select:!0})):m.shiftKey&&x===w&&(m.preventDefault(),n&&ce(R,{select:!0})):x===g&&m.preventDefault()}},[n,o,y.paused]);return l.jsx(P.div,{tabIndex:-1,...c,ref:v,onKeyDown:C})});Le.displayName=zr;function Yr(e,{select:t=!1}={}){const n=document.activeElement;for(const o of e)if(ce(o,{select:t}),document.activeElement!==n)return}function Xr(e){const t=cn(e),n=Nt(t,e),o=Nt(t.reverse(),e);return[n,o]}function cn(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:o=>{const r=o.tagName==="INPUT"&&o.type==="hidden";return o.disabled||o.hidden||r?NodeFilter.FILTER_SKIP:o.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function Nt(e,t){for(const n of e)if(!qr(n,{upTo:t}))return n}function qr(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function Zr(e){return e instanceof HTMLInputElement&&"select"in e}function ce(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Zr(e)&&t&&e.select()}}var At=Jr();function Jr(){let e=[];return{add(t){const n=e[0];t!==n&&n?.pause(),e=Dt(e,t),e.unshift(t)},remove(t){e=Dt(e,t),e[0]?.resume()}}}function Dt(e,t){const n=[...e],o=n.indexOf(t);return o!==-1&&n.splice(o,1),n}function Qr(e){return e.filter(t=>t.tagName!=="A")}var es="Portal",ke=s.forwardRef((e,t)=>{const{container:n,...o}=e,[r,a]=s.useState(!1);U(()=>a(!0),[]);const c=n||r&&globalThis?.document?.body;return c?zo.createPortal(l.jsx(P.div,{...o,ref:t}),c):null});ke.displayName=es;var qe=0;function dt(){s.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Ot()),document.body.insertAdjacentElement("beforeend",e[1]??Ot()),qe++,()=>{qe===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),qe--}},[])}function Ot(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var ln="Dialog",[un]=le(ln),[ti,oe]=un(ln),dn="DialogTrigger",ts=s.forwardRef((e,t)=>{const{__scopeDialog:n,...o}=e,r=oe(dn,n),a=M(t,r.triggerRef);return l.jsx(P.button,{type:"button","aria-haspopup":"dialog","aria-expanded":r.open,"aria-controls":r.contentId,"data-state":mt(r.open),...o,ref:a,onClick:E(e.onClick,r.onOpenToggle)})});ts.displayName=dn;var ft="DialogPortal",[ns,fn]=un(ft,{forceMount:void 0}),pn=e=>{const{__scopeDialog:t,forceMount:n,children:o,container:r}=e,a=oe(ft,t);return l.jsx(ns,{scope:t,forceMount:n,children:s.Children.map(o,c=>l.jsx(ie,{present:n||a.open,children:l.jsx(ke,{asChild:!0,container:r,children:c})}))})};pn.displayName=ft;var Me="DialogOverlay",mn=s.forwardRef((e,t)=>{const n=fn(Me,e.__scopeDialog),{forceMount:o=n.forceMount,...r}=e,a=oe(Me,e.__scopeDialog);return a.modal?l.jsx(ie,{present:o||a.open,children:l.jsx(rs,{...r,ref:t})}):null});mn.displayName=Me;var os=xe("DialogOverlay.RemoveScroll"),rs=s.forwardRef((e,t)=>{const{__scopeDialog:n,...o}=e,r=oe(Me,n);return l.jsx(it,{as:os,allowPinchZoom:!0,shards:[r.contentRef],children:l.jsx(P.div,{"data-state":mt(r.open),...o,ref:t,style:{pointerEvents:"auto",...o.style}})})}),me="DialogContent",vn=s.forwardRef((e,t)=>{const n=fn(me,e.__scopeDialog),{forceMount:o=n.forceMount,...r}=e,a=oe(me,e.__scopeDialog);return l.jsx(ie,{present:o||a.open,children:a.modal?l.jsx(ss,{...r,ref:t}):l.jsx(as,{...r,ref:t})})});vn.displayName=me;var ss=s.forwardRef((e,t)=>{const n=oe(me,e.__scopeDialog),o=s.useRef(null),r=M(t,n.contentRef,o);return s.useEffect(()=>{const a=o.current;if(a)return ct(a)},[]),l.jsx(hn,{...e,ref:r,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:E(e.onCloseAutoFocus,a=>{a.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:E(e.onPointerDownOutside,a=>{const c=a.detail.originalEvent,i=c.button===0&&c.ctrlKey===!0;(c.button===2||i)&&a.preventDefault()}),onFocusOutside:E(e.onFocusOutside,a=>a.preventDefault())})}),as=s.forwardRef((e,t)=>{const n=oe(me,e.__scopeDialog),o=s.useRef(!1),r=s.useRef(!1);return l.jsx(hn,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{e.onCloseAutoFocus?.(a),a.defaultPrevented||(o.current||n.triggerRef.current?.focus(),a.preventDefault()),o.current=!1,r.current=!1},onInteractOutside:a=>{e.onInteractOutside?.(a),a.defaultPrevented||(o.current=!0,a.detail.originalEvent.type==="pointerdown"&&(r.current=!0));const c=a.target;n.triggerRef.current?.contains(c)&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&r.current&&a.preventDefault()}})}),hn=s.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:o,onOpenAutoFocus:r,onCloseAutoFocus:a,...c}=e,i=oe(me,n),u=s.useRef(null),d=M(t,u);return dt(),l.jsxs(l.Fragment,{children:[l.jsx(Le,{asChild:!0,loop:!0,trapped:o,onMountAutoFocus:r,onUnmountAutoFocus:a,children:l.jsx(Fe,{role:"dialog",id:i.contentId,"aria-describedby":i.descriptionId,"aria-labelledby":i.titleId,"data-state":mt(i.open),...c,ref:d,onDismiss:()=>i.onOpenChange(!1)})}),l.jsxs(l.Fragment,{children:[l.jsx(is,{titleId:i.titleId}),l.jsx(ls,{contentRef:u,descriptionId:i.descriptionId})]})]})}),pt="DialogTitle",gn=s.forwardRef((e,t)=>{const{__scopeDialog:n,...o}=e,r=oe(pt,n);return l.jsx(P.h2,{id:r.titleId,...o,ref:t})});gn.displayName=pt;var xn="DialogDescription",wn=s.forwardRef((e,t)=>{const{__scopeDialog:n,...o}=e,r=oe(xn,n);return l.jsx(P.p,{id:r.descriptionId,...o,ref:t})});wn.displayName=xn;var yn="DialogClose",Cn=s.forwardRef((e,t)=>{const{__scopeDialog:n,...o}=e,r=oe(yn,n);return l.jsx(P.button,{type:"button",...o,ref:t,onClick:E(e.onClick,()=>r.onOpenChange(!1))})});Cn.displayName=yn;function mt(e){return e?"open":"closed"}var Sn="DialogTitleWarning",[ni,En]=ur(Sn,{contentName:me,titleName:pt,docsSlug:"dialog"}),is=({titleId:e})=>{const t=En(Sn),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
2
2
|
|
|
3
3
|
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
4
4
|
|