@miiflow/assistant-ui 0.3.1 → 0.3.2

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.
@@ -15,6 +15,6 @@ import {l,m,c,d,r}from'./chunk-W3HWTAF6.js';import {a as a$2}from'./chunk-D2PFIJ
15
15
  ... (truncated)`:t.content})]})]})]})}function lt({chunk:e}){let[a,r]=useState(true),t=e.terminalData;if(!t)return null;let n=()=>{switch(t.status){case "running":return jsx(Loader2,{size:14,className:"animate-spin text-blue-500"});case "completed":return jsx(CheckCircle2,{size:14,className:"text-green-500"});case "failed":return jsx(XCircle,{size:14,className:"text-red-500"});default:return null}},o=t.status==="running"?"border-blue-500/30":t.status==="failed"?"border-red-500/30":t.exitCode===0?"border-green-500/30":"border-yellow-500/30",s=t.status==="running"?"bg-blue-500/10":t.status==="failed"?"bg-red-500/10":"bg-green-500/10",l=t.status==="running"?"text-blue-500":t.status==="failed"?"text-red-500":"text-green-500",c=p=>p?p<1e3?p+"ms":(p/1e3).toFixed(1)+"s":null;return jsxs("div",{className:i("my-1 bg-[#1a1a1a] rounded border",o,"overflow-hidden"),children:[jsxs("div",{onClick:()=>r(!a),className:i("flex items-center gap-2 px-3 py-1.5 cursor-pointer",s,"hover:brightness-110"),children:[jsx("span",{className:"p-0.5 text-gray-500",children:a?jsx(ChevronDown,{size:16}):jsx(ChevronRight,{size:16})}),jsx(Terminal,{size:16,className:l}),jsxs("span",{className:"flex-1 font-mono text-[0.75rem] text-gray-300 truncate",children:[jsx("span",{className:"text-gray-500",children:"$ "}),t.command]}),t.durationMs!=null&&jsx("span",{className:"text-[0.7rem] text-gray-600",children:c(t.durationMs)}),n(),t.status!=="running"&&t.exitCode!==void 0&&jsxs("span",{className:i("text-[0.7rem] font-mono",t.exitCode===0?"text-green-500":"text-red-500"),children:["[",t.exitCode,"]"]})]}),a&&jsxs("div",{className:"p-3",children:[t.description&&jsx("p",{className:"text-gray-500 text-[0.75rem] italic mb-2",children:t.description}),t.stdout&&jsx("pre",{className:i("m-0 p-2 text-[0.7rem] font-mono bg-[#0d0d0d] rounded overflow-auto max-h-[300px]","text-green-400 whitespace-pre-wrap break-words",t.stderr&&"mb-2"),children:t.stdout}),t.stderr&&jsx("pre",{className:"m-0 p-2 text-[0.7rem] font-mono bg-red-500/10 rounded border border-red-500/30 overflow-auto max-h-[200px] text-red-400 whitespace-pre-wrap break-words",children:t.stderr}),t.status==="running"&&!t.stdout&&!t.stderr&&jsx("p",{className:"text-gray-500 text-[0.75rem] italic",children:"Running..."}),t.status==="completed"&&!t.stdout&&!t.stderr&&t.exitCode===0&&jsx("p",{className:"text-gray-600 text-[0.75rem] italic",children:"Command completed with no output"})]})]})}function ct({chunk:e}){let[a,r]=useState(false),t=e.fileOperationData;if(!t)return null;let n=t.operation==="read"?jsx(Eye,{size:16}):t.operation==="write"?jsx(Save,{size:16}):t.operation==="edit"?jsx(Pencil,{size:16}):jsx(FileText,{size:16}),o=t.operation==="read"?"text-blue-500 border-blue-500":t.operation==="write"?"text-green-500 border-green-500":t.operation==="edit"?"text-yellow-500 border-yellow-500":"text-gray-500 border-gray-500",s=t.operation==="read"?"bg-blue-500/5 hover:bg-blue-500/8":t.operation==="write"?"bg-green-500/5 hover:bg-green-500/8":t.operation==="edit"?"bg-yellow-500/5 hover:bg-yellow-500/8":"bg-gray-500/5",l=t.status==="pending"?jsx(Clock,{size:14,className:"text-gray-400"}):t.status==="completed"?jsx(CheckCircle2,{size:14,className:"text-green-500"}):jsx(XCircle,{size:14,className:"text-red-500"}),c=t.operation==="read"?"Read":t.operation==="write"?"Write":t.operation==="edit"?"Edit":"File",p=b=>{let x=b.split("/");return x.length<=3?b:".../"+x.slice(-3).join("/")};return jsxs("div",{className:i("my-1 border rounded overflow-hidden",o.split(" ")[1]+"/30"),children:[jsxs("div",{onClick:()=>r(!a),className:i("flex items-center gap-2 px-3 py-1.5 cursor-pointer",s),children:[jsx("span",{className:"p-0.5",children:a?jsx(ChevronDown,{size:16}):jsx(ChevronRight,{size:16})}),jsx("span",{className:o.split(" ")[0],children:n}),jsx("span",{className:i("font-medium text-[0.75rem]",o.split(" ")[0]),children:c}),jsx("span",{className:"flex-1 font-mono text-[0.75rem] text-gray-500 truncate",children:p(t.filePath)}),t.totalLines!=null&&jsxs("span",{className:"text-[0.7rem] text-gray-400",children:[t.totalLines," lines"]}),l]}),a&&jsxs("div",{className:"p-3 bg-gray-50 dark:bg-[#1e1e1e]",children:[t.operation==="read"&&t.content&&jsx(qn,{content:t.content}),t.operation==="edit"&&jsx(Gn,{oldString:t.oldString,newString:t.newString}),t.operation==="write"&&t.status==="completed"&&jsx("p",{className:"text-green-500 text-sm",children:"File written successfully"}),t.error&&jsxs("p",{className:"text-red-500 text-sm",children:["Error: ",t.error]})]})]})}function qn({content:e}){let a=useMemo(()=>e.split(`
16
16
  `).slice(0,50),[e]),r=e.split(`
17
17
  `).length,t=r>50;return jsxs("div",{children:[jsx("pre",{className:"m-0 p-2 text-[0.75rem] font-mono bg-gray-100 dark:bg-[#1a1a1a] rounded overflow-auto max-h-[300px]",children:a.map((n,o)=>jsxs("div",{className:"flex",children:[jsx("span",{className:"inline-block w-10 text-right pr-3 mr-3 border-r border-gray-200 dark:border-gray-700 text-gray-400 select-none",children:o+1}),jsx("span",{children:n||" "})]},o))}),t&&jsxs("p",{className:"text-[0.75rem] text-gray-400 mt-1",children:["... and ",r-50," more lines"]})]})}function Gn({oldString:e,newString:a}){return !e&&!a?jsx("p",{className:"text-gray-500 text-sm",children:"No changes to display"}):jsxs("div",{className:"flex gap-4",children:[jsxs("div",{className:"flex-1",children:[jsx("span",{className:"text-[0.75rem] font-medium text-red-500 block mb-1",children:"- Removed"}),jsx("pre",{className:"m-0 p-2 text-[0.7rem] font-mono bg-red-500/10 rounded border border-red-500/30 overflow-auto max-h-[200px] whitespace-pre-wrap break-words",children:e||"(empty)"})]}),jsxs("div",{className:"flex-1",children:[jsx("span",{className:"text-[0.75rem] font-medium text-green-500 block mb-1",children:"+ Added"}),jsx("pre",{className:"m-0 p-2 text-[0.7rem] font-mono bg-green-500/10 rounded border border-green-500/30 overflow-auto max-h-[200px] whitespace-pre-wrap break-words",children:a||"(empty)"})]})]})}function pt({chunk:e}){let[a,r]=useState(true),t=e.searchResultsData;if(!t)return null;let n=t.tool==="grep",o=n?"text-purple-500":"text-blue-500",s=n?"border-purple-500/30":"border-blue-500/30",l=n?"bg-purple-500/5 hover:bg-purple-500/8":"bg-blue-500/5 hover:bg-blue-500/8",c=n?"bg-purple-500/10 text-purple-500":"bg-blue-500/10 text-blue-500";return jsxs("div",{className:i("my-1 border rounded overflow-hidden",s),children:[jsxs("div",{onClick:()=>r(!a),className:i("flex items-center gap-2 px-3 py-1.5 cursor-pointer",l),children:[jsx("span",{className:"p-0.5",children:a?jsx(ChevronDown,{size:16}):jsx(ChevronRight,{size:16})}),jsx("span",{className:o,children:n?jsx(FileSearch,{size:16}):jsx(FolderSearch,{size:16})}),jsx("span",{className:i("text-[0.7rem] px-1.5 py-0.5 rounded font-medium",c),children:n?"Grep":"Glob"}),jsx("span",{className:"flex-1 font-mono text-[0.75rem] text-gray-500 truncate",children:t.pattern}),jsxs("span",{className:i("text-[0.7rem] px-1.5 py-0.5 rounded",t.totalCount>0?"bg-green-500/10 text-green-500":"bg-gray-500/10 text-gray-500"),children:[t.totalCount," results"]})]}),a&&jsxs("div",{className:"max-h-[300px] overflow-auto",children:[t.results.length>0?jsxs("div",{children:[t.results.slice(0,50).map((p,b)=>jsx(to,{result:p,isGrep:n},b)),t.results.length>50&&jsx("div",{className:"py-1 px-3",children:jsxs("span",{className:"text-[0.75rem] text-gray-400",children:["... and ",t.results.length-50," more results"]})})]}):jsx("div",{className:"p-3",children:jsx("p",{className:"text-gray-500 text-sm",children:"No results found"})}),t.error&&jsx("div",{className:"p-3",children:jsxs("p",{className:"text-red-500 text-sm",children:["Error: ",t.error]})})]})]})}function to({result:e,isGrep:a}){return jsxs("div",{className:"flex items-start gap-2 py-1 px-3 border-b border-gray-100 dark:border-gray-800 last:border-b-0 hover:bg-gray-50 dark:hover:bg-gray-800/50",children:[jsx(File,{size:14,className:"text-gray-400 mt-0.5 shrink-0"}),jsxs("div",{className:"min-w-0 flex-1",children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx("span",{className:"font-mono text-[0.75rem] truncate",children:(t=>{let n=t.split("/");return n.length<=4?t:".../"+n.slice(-4).join("/")})(e.filePath)}),a&&e.lineNumber!=null&&jsxs("span",{className:"font-mono text-[0.7rem] text-blue-500",children:[":",e.lineNumber]})]}),e.snippet&&jsx("p",{className:"font-mono text-[0.7rem] text-gray-500 truncate max-w-[400px]",children:e.snippet})]})]})}function dt({chunk:e}){let[a,r]=useState(false),t=e.webOperationData;if(!t)return null;let n=t.operation==="search",o=t.status==="pending",s=t.status==="error",l=t.status==="completed",c=()=>o?jsx(Loader2,{size:14,className:"animate-spin text-gray-400"}):s?jsx(XCircle,{size:14,className:"text-red-500"}):jsx(CheckCircle2,{size:14,className:"text-green-500"}),b=n?(()=>{if(!t.results||typeof t.results!="string")return [];let x=/\[([^\]]+)\]\(([^)]+)\)/g,y=[],v;for(;(v=x.exec(t.results))!==null;)y.push({title:v[1],url:v[2]});return y})():[];return jsxs("div",{className:"bg-gray-50 dark:bg-gray-800/50 rounded-lg border border-gray-200 dark:border-gray-700 overflow-hidden",children:[jsxs("div",{onClick:()=>r(!a),className:"flex items-center gap-2 px-3 py-2 cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-800",children:[n?jsx(Search,{size:16,className:"text-gray-400 shrink-0"}):jsx(Globe,{size:16,className:"text-gray-400 shrink-0"}),jsx("span",{className:"flex-1 text-sm truncate",children:n?jsxs(Fragment,{children:["Searching: ",jsx("span",{className:"font-medium",children:t.query})]}):jsxs(Fragment,{children:["Fetching: ",jsx("span",{className:"font-medium",children:t.url})]})}),c(),l&&t.durationMs!=null&&jsxs("span",{className:"text-[0.7rem] px-1.5 py-0.5 bg-black/5 dark:bg-white/5 rounded",children:[Math.round(t.durationMs),"ms"]}),jsx("span",{className:"p-0.5",children:a?jsx(ChevronDown,{size:14}):jsx(ChevronRight,{size:14})})]}),a&&jsxs("div",{className:"border-t border-gray-200 dark:border-gray-700 p-3",children:[s&&t.error&&jsx("p",{className:"text-sm text-red-500 font-mono",children:t.error}),o&&jsx("p",{className:"text-sm text-gray-400 italic",children:n?"Searching the web...":"Fetching content..."}),n&&l&&b.length>0&&jsxs("div",{className:"space-y-2",children:[jsxs("div",{className:"text-[0.75rem] text-gray-400 uppercase tracking-wider",children:[b.length," Results"]}),b.slice(0,5).map((x,y)=>jsxs("div",{className:i("flex items-center gap-2 py-1",y<Math.min(b.length,5)-1&&"border-b border-gray-200 dark:border-gray-700"),children:[jsx(ExternalLink,{size:12,className:"text-gray-400 shrink-0"}),jsx("a",{href:x.url,target:"_blank",rel:"noopener noreferrer",className:"text-sm truncate hover:underline",children:x.title})]},y)),b.length>5&&jsxs("p",{className:"text-[0.75rem] text-gray-400 italic",children:["+",b.length-5," more results"]})]}),n&&l&&b.length===0&&t.results&&jsxs("p",{className:"text-sm whitespace-pre-wrap max-h-[200px] overflow-auto",children:[typeof t.results=="string"?t.results.slice(0,1e3):JSON.stringify(t.results,null,2).slice(0,1e3),t.results.length>1e3&&"..."]}),!n&&l&&t.content&&jsx("div",{className:"max-h-[300px] overflow-auto bg-gray-100 dark:bg-gray-900 rounded p-2",children:jsxs("pre",{className:"text-[0.75rem] font-mono whitespace-pre-wrap break-words m-0",children:[t.content.slice(0,2e3),t.content.length>2e3&&`
18
- ... (truncated)`]})})]})]})}var yo={code_reviewer:"Code Review",researcher:"Research",data_analyst:"Data Analysis",Explore:"Explore",Plan:"Planning",Bash:"Command Execution"};function mt({chunk:e}){let[a,r]=useState(true),t=e.subagentData;if(!t)return null;let n=t.status==="running"?jsx(Loader2,{size:16,className:"animate-spin text-blue-500"}):t.status==="completed"?jsx(CheckCircle2,{size:16,className:"text-green-500"}):t.status==="failed"?jsx(XCircle,{size:16,className:"text-red-500"}):null,o=t.status==="running"?"border-blue-500":t.status==="completed"?"border-green-500":t.status==="failed"?"border-red-500":"border-gray-500",s=t.status==="running"?"bg-blue-500/3":t.status==="completed"?"bg-green-500/3":t.status==="failed"?"bg-red-500/3":"bg-gray-500/3",l=t.status==="running"?"bg-blue-500/10 text-blue-500":t.status==="completed"?"bg-green-500/10 text-green-500":t.status==="failed"?"bg-red-500/10 text-red-500":"bg-gray-500/10 text-gray-500",c=b=>b?b<1e3?b+"ms":(b/1e3).toFixed(1)+"s":null,p=yo[t.subagentType]||t.subagentType;return jsxs("div",{className:i("border border-dashed rounded ml-4 my-2 overflow-hidden",o+"/50",s),children:[jsxs("div",{onClick:()=>r(!a),className:i("flex items-center gap-2 px-3 py-1.5 cursor-pointer hover:brightness-95"),children:[jsx("span",{className:"p-0.5",children:a?jsx(ChevronDown,{size:18}):jsx(ChevronRight,{size:18})}),jsx(GitBranch,{size:16,className:o.replace("border-","text-")}),jsx("span",{className:i("text-[0.75rem] px-2 py-0.5 rounded font-medium",l),children:p}),jsx("span",{className:"flex-1 text-sm text-gray-500 truncate",children:t.description}),n,t.durationMs!=null&&jsx("span",{className:"text-[0.7rem] text-gray-400",children:c(t.durationMs)})]}),a&&jsxs("div",{className:"px-4 pb-3",children:[t.nestedChunks&&t.nestedChunks.length>0&&jsx("div",{className:"mt-2 space-y-1",children:t.nestedChunks.map((b,x)=>jsx(vo,{chunk:b},x))}),t.status==="completed"&&t.result&&jsxs("div",{className:"mt-2 p-2 rounded bg-green-500/5 border border-green-500/20",children:[jsx("span",{className:"text-[0.75rem] font-medium text-green-500",children:"Result"}),jsx("p",{className:"mt-1 text-sm text-gray-500 whitespace-pre-wrap",children:t.result.length>500?t.result.slice(0,500)+"...":t.result})]})]})]})}function vo({chunk:e}){return e.type==="tool"||e.type==="observation"?jsxs("div",{className:"py-1 px-2 my-1 rounded bg-blue-500/5 text-[0.75rem]",children:[jsxs("span",{className:"font-medium text-blue-500",children:[e.toolName||"Tool",":"]})," ",jsxs("span",{className:"text-gray-500",children:[e.content?.slice(0,200)||e.toolDescription||"Executing...",e.content&&e.content.length>200&&"..."]})]}):e.type==="thinking"||e.type==="claude_thinking"?jsxs("p",{className:"py-1 text-[0.75rem] text-gray-400 italic",children:[e.content?.slice(0,150),e.content&&e.content.length>150&&"..."]}):null}function Ro(e){let a=useRef(null),[r,t]=useState(0),n=useRef(0);return useEffect(()=>{if(e){a.current===null&&(a.current=Date.now());let o=setInterval(()=>{if(a.current!==null){let s=Math.floor((Date.now()-a.current)/1e3);t(s),n.current=s;}},1e3);return ()=>clearInterval(o)}else a.current!==null&&(n.current=Math.floor((Date.now()-a.current)/1e3),t(n.current),a.current=null);},[e]),{display:`${r}`,finalSeconds:n.current}}function Mo(e){return e.some(a=>a.orchestrator==="claude_agent_sdk"||a.type==="subagent"||a.type==="file_operation"||a.type==="terminal"||a.type==="search_results"||a.type==="web_operation"||a.type==="claude_text"||a.type==="claude_thinking")}function Ao(e){return e.some(a=>a.type==="wave_start"||a.type==="wave_complete"||a.type==="parallel_subtask_start"||a.type==="parallel_subtask_complete"||a.isParallel)}function Lo(e){let a=e.filter(c=>c.type==="wave_start"&&c.waveData);if(a.length===0)return null;let r=a[a.length-1],t=r.waveData?.waveNumber??0,n=r.waveData?.totalWaves??1,o=r.waveData?.parallelCount??0,s=[],l=[];return e.forEach(c=>{if(c.type==="parallel_subtask_start"&&c.waveNumber===t&&c.subtaskId!==void 0&&(l.includes(c.subtaskId)||s.push(c.subtaskId)),c.type==="parallel_subtask_complete"&&c.waveNumber===t&&c.subtaskId!==void 0){l.push(c.subtaskId);let p=s.indexOf(c.subtaskId);p>=0&&s.splice(p,1);}}),{currentWave:t,totalWaves:n,parallelCount:o,activeSubtasks:s,completedSubtasks:l}}function Io(e){return e.some(a=>a.type==="multi_agent_planning"||a.type==="multi_agent_planning_complete"||a.type==="subagent_start"||a.type==="subagent_complete"||a.type==="subagent_failed"||a.type==="synthesis"||a.isMultiAgent)}function Ia(e){return e.find(r=>(r.type==="multi_agent_planning"||r.type==="multi_agent_planning_complete")&&r.subagentAllocations)?.subagentAllocations||[]}function _a(e){let a=new Map,r=false;Ia(e).forEach(o=>{a.set(o.name,{name:o.name,task:o.query||o.focus,status:"pending"});});let t={pending:0,running:1,completed:2,failed:2};e.forEach(o=>{if(o.subagentInfo?.name){let s=o.subagentInfo.id||o.subagentInfo.name,l=a.get(s);(!l||(t[o.subagentInfo.status]??0)>=(t[l.status]??0))&&a.set(s,o.subagentInfo);}o.type==="synthesis"&&(r=true);});let n=[...a.values()];return {subagents:a,running:n.filter(o=>o.status==="running").length,completed:n.filter(o=>o.status==="completed").length,failed:n.filter(o=>o.status==="failed").length,pending:n.filter(o=>o.status==="pending").length,isSynthesizing:r}}function _o(e){let a=[];return e.forEach(r=>{r.type==="thought"&&r.thought?a.push({type:"thinking",content:r.thought,subtaskId:r.subtask_id}):r.type==="tool"&&(a.push({type:"tool",content:"",toolName:r.tool||"Unknown Tool",toolDescription:r.tool_description,status:"completed",subtaskId:r.subtask_id}),r.observation&&a.push({type:"observation",content:r.observation,toolName:r.tool||"Unknown Tool",success:true,subtaskId:r.subtask_id}));}),a}function Vo({chunks:e}){let a=_a(e),r=[...a.subagents.values()];if(r.length===0){let n=e.some(s=>s.type==="multi_agent_planning"),o=Ia(e);return o.length>0?jsxs("div",{className:"flex items-center gap-2",children:[jsx(Loader2,{size:14,className:"animate-spin text-gray-400"}),jsxs("span",{className:"text-sm text-gray-500",children:["Allocating agents: ",o.map(s=>s.name).join(", ")]})]}):n?jsxs("div",{className:"flex items-center gap-2",children:[jsx(Loader2,{size:14,className:"animate-spin text-gray-400"}),jsx("span",{className:"text-sm text-gray-500",children:"Planning agent allocation..."})]}):null}let t=r.map((n,o)=>({id:n.id||`agent-${o}`,status:n.status==="running"?"running":n.status==="completed"?"completed":n.status==="failed"?"failed":"pending",content:jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[jsx("span",{className:"text-sm font-medium",children:n.name}),jsx("span",{className:i("text-sm flex-1 truncate",n.status==="failed"?"text-red-500":"text-gray-500"),children:n.status==="failed"&&n.error?n.error:n.task}),n.status==="completed"&&n.executionTime!=null&&jsxs("span",{className:"text-xs text-gray-400 shrink-0",children:[n.executionTime.toFixed(1),"s"]})]})}));return jsxs("div",{className:"space-y-2",children:[jsx("span",{className:"text-sm text-gray-500",children:a.running===0?"Agents:":"Running agents:"}),jsx(Ae,{items:t,badgeSize:16}),a.isSynthesizing&&jsxs("div",{className:"flex items-center gap-2",children:[jsx(Sparkle,{size:14,className:"text-gray-500"}),jsx("span",{className:"text-sm text-gray-500",children:"Synthesizing results..."})]})]})}function Fo({chunks:e}){return jsx("div",{className:"space-y-2",children:e.map((a,r)=>a.type==="subagent"&&a.subagentData?jsx(mt,{chunk:a},`subagent-${a.subagentData.subagentId}-${r}`):a.type==="file_operation"&&a.fileOperationData?jsx(ct,{chunk:a},`file-op-${a.fileOperationData.toolUseId}-${r}`):a.type==="terminal"&&a.terminalData?jsx(lt,{chunk:a},`terminal-${a.terminalData.toolUseId}-${r}`):a.type==="search_results"&&a.searchResultsData?jsx(pt,{chunk:a},`search-${a.searchResultsData.toolUseId}-${r}`):a.type==="web_operation"&&a.webOperationData?jsx(dt,{chunk:a},`web-op-${a.webOperationData.toolUseId}-${r}`):a.claudeToolData?jsx(it,{chunk:a},`claude-tool-${a.claudeToolData.toolUseId}-${r}`):null)})}function Ma(e){return e<1?`${Math.round(e*1e3)}ms`:`${e.toFixed(1)}s`}function jt({isStreaming:e=false,chunks:a=[],plan:r,executionTimeline:t=[],userMessageTimestamp:n,executionTime:o,defaultExpanded:s=false,expanded:l,onExpandedChange:c,className:p}){let[b,x]=useState(s),{display:y,finalSeconds:v}=Ro(e),f=useRef(null);useEffect(()=>{Re(f.current);},[]);let N=a$2(f,300),T=l??b,I=useCallback(d=>{N(),x(d),c?.(d);},[N,c]),L=useMemo(()=>e?a.map((d,w)=>nt(d,w)).filter(d=>d!==null):[],[e,a]),U=useMemo(()=>!e&&(t.length>0||a.length>0)?a.map((d,w)=>nt(d,w)).filter(d=>d!==null):[],[e,t,a]),D=useMemo(()=>!e&&t.length>0?_o(t):[],[e,t]),g=useMemo(()=>{if(!e)return null;let d=a.find(S=>S.planData!==void 0);if(!d?.planData)return null;let w={...d.planData},P=[...w.subtasks||[]],_=0,k=0;return a.forEach(S=>{if(S.type==="parallel_subtask_start"&&S.subtaskId!==void 0){let Y=P.findIndex(O=>String(O.id)===String(S.subtaskId));Y!==-1&&(P[Y]={...P[Y],status:"running"});}else if(S.type==="parallel_subtask_complete"&&S.subtaskId!==void 0){let Y=P.findIndex(O=>String(O.id)===String(S.subtaskId));if(Y!==-1){let O={...P[Y]};S.parallelSubtaskData?.success===false||S.success===false?(O.status="failed",O.error=S.parallelSubtaskData?.error,k++):(O.status="completed",O.result=S.parallelSubtaskData?.result,O.execution_time=S.parallelSubtaskData?.executionTime,_++),P[Y]=O;}}else if(S.type==="subtask"&&S.subtaskId!==void 0){let Y=P.findIndex(O=>String(O.id)===String(S.subtaskId));if(Y!==-1){let O={...P[Y]};if(S.content.includes("\u2713 Completed"))O.status="completed",S.subtaskData?.execution_time&&(O.execution_time=S.subtaskData.execution_time),_++;else if(S.content.includes("\u2717 Failed")){O.status="failed";let la=S.content.match(/✗ Failed: (.*)/);la&&(O.error=la[1]),k++;}else S.content.includes("\u2192 **Subtask")&&(O.status="running");P[Y]=O;}}}),w.subtasks=P,w.completed_subtasks=_,w.failed_subtasks=k,w.progress_percentage=_/w.total_subtasks*100,w},[e,a]),h=useMemo(()=>{if(o&&o>0)return o;if(!e){if(r?.subtasks)return r.subtasks.reduce((d,w)=>d+(w.execution_time||0),0);if(t.length>0){let d=t[t.length-1];if(n&&d.timestamp){let w=d.timestamp-n;if(w>0)return w}if(t.length>1){let w=t[0];if(w.timestamp&&d.timestamp){let P=d.timestamp-w.timestamp;if(P>0)return P}}}}return 0},[e,r,t,n,o]);if(!e){let d=r||t.length>0||a.length>0;if(!d||d&&U.length===0&&!r&&t.length===0)return null}let u=a.length>0?a[a.length-1]:null,R=u?.type==="tool"||!!u?.toolName,C=u?.type==="planning",V=Ao(a),G=V?Lo(a):null,he=Mo(a),we=Io(a),ke=we?_a(a):null,Ve=()=>{if(!e)return h>0?`Thought for ${Ma(h)}`:v>0?`Thought for ${Ma(v)}`:(a.length>0,"Thought for a few seconds");if(we&&ke){let{running:d,completed:w,failed:P,isSynthesizing:_}=ke;if(_)return "Synthesizing results...";if(u?.type==="multi_agent_planning")return "Planning subagent allocation...";if(u?.type==="subagent_start"&&u?.subagentInfo)return `${u.subagentInfo.name}: ${u.subagentInfo.task?.slice(0,30)||"working"}...`;if(u?.type==="subagent_complete"&&u?.subagentInfo)return `${u.subagentInfo.name} complete`;if(u?.type==="subagent_failed"&&u?.subagentInfo)return `${u.subagentInfo.name} failed`;let k=d+w+P;if(d>0)return `${d} subagent${d>1?"s":""} running (${w}/${k} done)`;if(k>0)return `Multi-agent execution (${w}/${k} complete)`}if(he){if(u?.type==="subagent"&&u?.subagentData)return `${u.subagentData.subagentType}: ${u.subagentData.description}`;if(u?.type==="file_operation"&&u?.fileOperationData){let d=u.fileOperationData.operation,w=u.fileOperationData.filePath.split("/").pop();return `${d==="read"?"Reading":d==="edit"?"Editing":"Writing"} ${w}`}if(u?.type==="terminal"&&u?.terminalData){let d=u.terminalData.command;return d.length>40?`$ ${d.slice(0,37)}...`:`$ ${d}`}if(u?.type==="search_results"&&u?.searchResultsData)return `${u.searchResultsData.tool}: ${u.searchResultsData.pattern}`;if(u?.type==="web_operation"&&u?.webOperationData)return u.webOperationData.operation==="search"?`Searching: ${u.webOperationData.query}`:`Fetching: ${u.webOperationData.url?.slice(0,40)}...`}if(V&&G){let{currentWave:d,totalWaves:w,parallelCount:P,activeSubtasks:_,completedSubtasks:k}=G;if(u?.type==="wave_start")return `Wave ${d+1}/${w}: ${P} parallel subtasks`;if(u?.type==="wave_complete")return `Wave ${d+1} complete (${k.length} done)`;if(u?.type==="parallel_subtask_start"&&u?.parallelSubtaskData?.description){let S=u.parallelSubtaskData.description;return S.length>40?`${S.slice(0,37)}...`:S}return _.length>0?`Wave ${d+1}/${w}: ${_.length} running...`:`Parallel execution (Wave ${d+1}/${w})`}if(u?.toolDescription)return u.toolDescription;if(u?.toolName)return u.toolName;switch(u?.type){case "planning":return "Planning...";case "thinking":return "Thinking...";case "tool":return u.toolName||"Using tool...";case "subtask":return `Executing subtask ${u.subtaskId||""}...`;case "observation":return "Analyzing results...";case "progress":return "Working...";case "wave_start":return "Starting parallel execution...";case "wave_complete":return "Parallel wave complete";case "parallel_subtask_start":return "Running parallel subtask...";case "parallel_subtask_complete":return "Parallel subtask complete";default:return "Thinking..."}},De=()=>we?jsx(Users,{size:14}):he?u?.type==="subagent"?jsx(GitBranch,{size:14}):u?.type==="file_operation"?jsx(FileText,{size:14}):u?.type==="terminal"?jsx(Terminal,{size:14}):u?.type==="search_results"?jsx(Search,{size:14}):u?.type==="web_operation"?jsx(Globe,{size:14}):jsx(Sparkle,{size:14}):V?jsx(Zap,{size:14}):R?jsx(Wrench,{size:14}):C?jsx(ListTodo,{size:14}):jsx(Sparkle,{size:14}),Ue=d=>d?.subtasks&&d.subtasks.length>=2,de=e?g:r,Fe=Ue(de);return jsxs("div",{ref:f,className:i("max-w-full",p),children:[jsxs("div",{onClick:()=>I(!T),style:{position:"relative",display:"inline-flex",alignItems:"center",gap:6,padding:"4px 6px",overflow:"hidden",borderRadius:8,cursor:"pointer",transition:"opacity 0.2s",...!e&&{opacity:.6}},children:[e&&jsx("div",{style:Me}),jsx("span",{className:i("flex items-center text-gray-500"),children:e?De():jsx(Sparkle,{size:14})}),jsx("span",{className:i("text-sm font-normal text-gray-500 text-[var(--chat-text-subtle)]"),children:Ve()}),e&&parseInt(y)>0&&jsxs("span",{className:"text-gray-500 font-normal tabular-nums text-sm",children:[y,"s"]})]}),T&&jsx("div",{className:"mt-3 animate-fade-in",children:e?we?jsx(Vo,{chunks:a}):he?jsx(Fo,{chunks:a}):Fe&&de?jsx(st,{plan:de,streamingChunks:a}):g?.subtasks?.length===1?jsx(Ce,{events:L}):g?.subtasks?.length===0?null:jsx(Ce,{events:L}):r?r.subtasks?.length===0?null:r.subtasks?.length===1?jsx(Ce,{events:U}):jsx(st,{plan:r,streamingChunks:D}):jsx(Ce,{events:U})})]})}var Xe=forwardRef(({content:e,isStreaming:a=false,renderMarkdown:r=true,className:t,baselineFontSize:n,markdownProps:o},s)=>jsx(m,{ref:s,content:e,isStreaming:a,showCursor:false,className:i("relative",t),children:r?jsx(ne,{baselineFontSize:n,...o,children:e}):jsx("span",{className:"whitespace-pre-wrap",children:e})}));Xe.displayName="StreamingText";var Jo={send_message:jsx(Send,{size:14}),navigate:jsx(Navigation,{size:14}),copy_text:jsx(Copy,{size:14}),compose_email:jsx(Mail,{size:14}),search_emails:jsx(Search,{size:14}),open_modal:jsx(ExternalLink,{size:14}),api_call:jsx(Zap,{size:14})};function Qo(e){return e?Jo[e]||jsx(ArrowRight,{size:14}):jsx(ArrowRight,{size:14})}var gt=forwardRef(({actions:e,onSelect:a,className:r,showIcons:t=true,disabled:n=false},o)=>{let[s,l]=useState(null);if(e.length===0)return null;let c=async(p,b)=>{if(!(!a||s!==null)){l(b);try{await a(p);}finally{l(null);}}};return jsx("div",{ref:o,role:"group","aria-label":"Suggested actions",className:i("flex flex-wrap gap-2",r),children:jsx(AnimatePresence,{children:e.map((p,b)=>{let x=s===b,y=n||s!==null;return jsxs(motion.button,{type:"button",initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.2,delay:b*.05},disabled:y,onClick:()=>c(p,b),className:i("inline-flex items-center gap-1.5","px-3 py-1.5 rounded-lg","text-sm font-medium","border border-gray-200 dark:border-gray-700","bg-white dark:bg-gray-800","text-gray-700 dark:text-gray-300","opacity-80 hover:opacity-100","hover:border-gray-300 dark:hover:border-gray-600","hover:bg-gray-50 dark:hover:bg-gray-750","hover:-translate-y-px","active:translate-y-0","transition-all duration-200","focus:outline-none focus:ring-2 focus:ring-blue-500/20","disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:translate-y-0"),children:[x?jsx(Loader2,{size:14,className:"animate-spin"}):t&&jsx("span",{className:"text-gray-400 dark:text-gray-500",children:Qo(p.type)}),p.label]},p.id)})})})});gt.displayName="SuggestedActions";var us=["#3B82F6","#10B981","#F59E0B","#EF4444","#8B5CF6","#EC4899","#06B6D4","#F97316"];function ht({data:e,config:a,isStreaming:r=false}){let{chartType:t,series:n,xAxis:o,yAxis:s}=e,l=a?.colors||us,c=a?.height||300,p=a?.legend!==false,b=a?.grid!==false,x=a?.tooltip!==false,y=a?.animate!==false&&!r,v=a?.stacked||false,N=(()=>{if(t==="pie")return (n[0]?.data||[]).map((h,u)=>({name:h.name||h.x||`Item ${u+1}`,value:h.value??h.y??0}));let D=new Map;return n.forEach(g=>{g.data.forEach(h=>{let u=h.x??h.name;D.has(u)||D.set(u,{x:u}),D.get(u)[g.name]=h.y??h.value??0;});}),Array.from(D.values())})(),T={data:N,margin:{top:10,right:30,left:0,bottom:0}},I={fontSize:12},L={backgroundColor:"#fff",border:"1px solid #e5e7eb",borderRadius:8};return jsx("div",{className:"w-full",style:{height:c},children:jsx(ResponsiveContainer,{width:"100%",height:"100%",children:(()=>{switch(t){case "line":return jsxs(LineChart,{...T,children:[b&&jsx(CartesianGrid,{strokeDasharray:"3 3",stroke:"#e5e7eb"}),jsx(XAxis,{dataKey:"x",...I,tickLine:false,padding:{left:10,right:10}}),jsx(YAxis,{...I,tickLine:false,width:40}),x&&jsx(Tooltip,{contentStyle:L}),p&&jsx(Legend,{}),n.map((D,g)=>jsx(Line,{type:"monotone",dataKey:D.name,stroke:D.color||l[g%l.length],strokeWidth:2,dot:false,activeDot:{r:4},isAnimationActive:y},D.name))]});case "bar":return jsxs(BarChart,{...T,children:[b&&jsx(CartesianGrid,{strokeDasharray:"3 3",stroke:"#e5e7eb"}),jsx(XAxis,{dataKey:"x",...I,tickLine:false,padding:{left:10,right:10}}),jsx(YAxis,{...I,tickLine:false,width:40}),x&&jsx(Tooltip,{contentStyle:L}),p&&jsx(Legend,{}),n.map((D,g)=>jsx(Bar,{dataKey:D.name,fill:D.color||l[g%l.length],stackId:v?"stack":void 0,isAnimationActive:y,radius:[4,4,0,0]},D.name))]});case "area":return jsxs(AreaChart,{...T,children:[b&&jsx(CartesianGrid,{strokeDasharray:"3 3",stroke:"#e5e7eb"}),jsx(XAxis,{dataKey:"x",...I,tickLine:false,padding:{left:10,right:10}}),jsx(YAxis,{...I,tickLine:false,width:40}),x&&jsx(Tooltip,{contentStyle:L}),p&&jsx(Legend,{}),n.map((D,g)=>jsx(Area,{type:"monotone",dataKey:D.name,stroke:D.color||l[g%l.length],fill:D.color||l[g%l.length],fillOpacity:.3,stackId:v?"stack":void 0,isAnimationActive:y},D.name))]});case "pie":return jsxs(PieChart,{children:[x&&jsx(Tooltip,{contentStyle:L}),p&&jsx(Legend,{}),jsx(Pie,{data:N,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",outerRadius:Math.min(c,300)/3,isAnimationActive:y,label:({name:D,percent:g})=>`${D}: ${((g??0)*100).toFixed(0)}%`,labelLine:false,children:N.map((D,g)=>jsx(Cell,{fill:l[g%l.length]},`cell-${g}`))})]});case "scatter":return jsxs(ScatterChart,{...T,children:[b&&jsx(CartesianGrid,{strokeDasharray:"3 3",stroke:"#e5e7eb"}),jsx(XAxis,{dataKey:"x",type:"number",...I,tickLine:false,name:o?.label,padding:{left:10,right:10}}),jsx(YAxis,{...I,tickLine:false,name:s?.label,width:40}),x&&jsx(Tooltip,{contentStyle:L}),p&&jsx(Legend,{}),n.map((D,g)=>jsx(Scatter,{name:D.name,data:D.data.map(h=>({x:h.x,y:h.y})),fill:D.color||l[g%l.length],isAnimationActive:y},D.name))]});default:return null}})()||jsx(Fragment,{})})})}var vs={active:"bg-green-100 text-green-700",completed:"bg-green-100 text-green-700",success:"bg-green-100 text-green-700",enabled:"bg-green-100 text-green-700",pending:"bg-yellow-100 text-yellow-700",processing:"bg-yellow-100 text-yellow-700",in_progress:"bg-yellow-100 text-yellow-700",failed:"bg-red-100 text-red-700",error:"bg-red-100 text-red-700",disabled:"bg-red-100 text-red-700",inactive:"bg-gray-100 text-gray-700",draft:"bg-gray-100 text-gray-700"};function ws(e,a){if(e==null)return jsx("span",{className:"text-gray-400",children:"-"});switch(a.type||"string"){case "number":return typeof e=="number"?e.toLocaleString():String(e);case "currency":return typeof e=="number"?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format(e):String(e);case "date":try{return new Date(e).toLocaleDateString()}catch{return String(e)}case "badge":{let t=String(e).toLowerCase().replace(/\s+/g,"_"),n=vs[t]||"bg-gray-100 text-gray-700";return jsx("span",{className:i("inline-block px-2 py-0.5 rounded-full text-xs font-medium",n),children:String(e)})}case "link":return jsx("a",{href:String(e),target:"_blank",rel:"noopener noreferrer",className:"text-blue-500 hover:underline",children:String(e)});case "boolean":return e?jsx(Check,{size:18,className:"text-green-500"}):jsx(X,{size:18,className:"text-gray-400"});case "progress":{let t=typeof e=="number"?e:parseFloat(String(e));return jsxs("div",{className:"flex items-center gap-2",children:[jsx("div",{className:"flex-1 h-2 bg-gray-200 dark:bg-gray-700 rounded-full overflow-hidden",children:jsx("div",{className:"h-full bg-blue-500 rounded-full",style:{width:`${Math.min(100,Math.max(0,t))}%`}})}),jsxs("span",{className:"text-xs text-gray-500",children:[t.toFixed(0),"%"]})]})}default:return String(e)}}function Fa(e,a,r){let t=e[r],n=a[r];return t==null?1:n==null?-1:typeof t=="number"&&typeof n=="number"?n-t:String(n).localeCompare(String(t))}function yt({data:e,config:a}){let{columns:r,rows:t}=e,n=a?.sortable!==false,o=a?.paginated||false,s=a?.pageSize||10,[l,c]=useState("asc"),[p,b]=useState(r[0]?.key||""),[x,y]=useState(0),v=T=>{c(p===T&&l==="asc"?"desc":"asc"),b(T);},f=useMemo(()=>{let T=[...t];return n&&p&&T.sort((I,L)=>l==="desc"?Fa(I,L,p):-Fa(I,L,p)),o&&(T=T.slice(x*s,(x+1)*s)),T},[t,l,p,x,s,n,o]),N=Math.ceil(t.length/s);return jsxs("div",{className:"w-full overflow-x-auto",children:[jsxs("table",{className:"min-w-full text-sm",children:[jsx("thead",{children:jsx("tr",{children:r.map(T=>jsx("th",{className:i("px-3 py-2 font-semibold bg-gray-50 dark:bg-gray-800 whitespace-nowrap text-left",n&&"cursor-pointer select-none hover:bg-gray-100 dark:hover:bg-gray-700"),style:{width:T.width,textAlign:T.align||"left"},onClick:()=>n&&v(T.key),children:jsxs("span",{className:"inline-flex items-center gap-1",children:[T.label,n&&p===T.key&&(l==="asc"?jsx(ChevronUp,{size:14}):jsx(ChevronDown,{size:14}))]})},T.key))})}),jsxs("tbody",{children:[f.map((T,I)=>jsx("tr",{className:"border-t border-gray-100 dark:border-gray-800 hover:bg-gray-50 dark:hover:bg-gray-800/50",children:r.map(L=>jsx("td",{className:"px-3 py-2 whitespace-nowrap max-w-[300px] overflow-hidden text-ellipsis",style:{textAlign:L.align||"left"},children:ws(T[L.key],L)},L.key))},I)),f.length===0&&jsx("tr",{children:jsx("td",{colSpan:r.length,className:"px-3 py-8 text-center text-gray-400",children:"No data available"})})]})]}),o&&t.length>s&&jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-t border-gray-200 dark:border-gray-700 text-sm",children:[jsxs("span",{className:"text-gray-500",children:[x*s+1,"-",Math.min((x+1)*s,t.length)," of ",t.length]}),jsxs("div",{className:"flex gap-1",children:[jsx("button",{onClick:()=>y(Math.max(0,x-1)),disabled:x===0,className:"px-2 py-1 rounded hover:bg-gray-100 dark:hover:bg-gray-800 disabled:opacity-30",children:"Prev"}),jsx("button",{onClick:()=>y(Math.min(N-1,x+1)),disabled:x>=N-1,className:"px-2 py-1 rounded hover:bg-gray-100 dark:hover:bg-gray-800 disabled:opacity-30",children:"Next"})]})]})]})}function vt({data:e,config:a,onAction:r}){let{subtitle:t,imageUrl:n,sections:o,actions:s}=e,l=a?.collapsible||false,c=a?.initiallyCollapsed||false,[p,b]=useState(!c),x=f=>{f.startsWith("http://")||f.startsWith("https://")||f.startsWith("/")?window.open(f,"_blank","noopener,noreferrer"):r?r({type:"card_action",action:f}):window.dispatchEvent(new CustomEvent("visualization-action",{detail:{action:f}}));},y=(f,N)=>jsxs("div",{className:i(N<o.length-1&&"mb-4"),children:[f.title&&jsx("h4",{className:"font-semibold text-sm mb-2",children:f.title}),f.items&&f.items.length>0&&jsx("div",{className:"space-y-1",children:f.items.map((T,I)=>jsxs("div",{className:"flex justify-between items-start gap-4",children:[jsx("span",{className:"text-sm text-gray-500 shrink-0",children:T.label}),jsx("span",{className:"text-sm font-medium text-right",children:T.value})]},I))}),f.content&&jsx(ne,{children:f.content})]},N),v=jsxs(Fragment,{children:[n&&jsx("img",{src:n,alt:"",className:"w-full h-[140px] object-cover border-b border-gray-200 dark:border-gray-700"}),t&&jsx("p",{className:"text-sm text-gray-500 italic mb-4",children:t}),o.map((f,N)=>jsxs("div",{children:[y(f,N),N<o.length-1&&jsx("hr",{className:"my-4 border-gray-200 dark:border-gray-700"})]},N))]});return jsxs("div",{className:"w-full",children:[l&&jsxs("div",{className:"flex items-center justify-between mb-2 cursor-pointer",onClick:()=>b(!p),children:[jsx("span",{className:"text-sm text-gray-500",children:p?"Click to collapse":"Click to expand"}),jsx("button",{className:"p-1",children:p?jsx(ChevronUp,{size:18}):jsx(ChevronDown,{size:18})})]}),(!l||p)&&v,s&&s.length>0&&jsx("div",{className:"flex gap-2 mt-4 pt-4 border-t border-gray-200 dark:border-gray-700",children:s.map((f,N)=>jsxs("button",{onClick:()=>x(f.action),className:i("px-3 py-1.5 text-sm rounded-lg transition-colors",f.variant==="primary"?"bg-blue-500 text-white hover:bg-blue-600":f.variant==="text"?"text-blue-500 hover:bg-blue-50":"border border-gray-300 hover:bg-gray-50"),children:[f.label,f.action.startsWith("http")&&jsx(ExternalLink,{size:14,className:"inline ml-1"})]},N))})]})}var As=["#3B82F6","#10B981","#F59E0B","#8B5CF6"];function Ls({metric:e,color:a,animate:r}){let t=e.trend==="up"?jsx(ArrowUp,{size:16,className:"text-green-500"}):e.trend==="down"?jsx(ChevronDown,{size:16,className:"text-red-500"}):e.trend==="neutral"?jsx(Circle,{size:14,className:"text-gray-400"}):null,n=e.trend==="up"?"text-green-500":e.trend==="down"?"text-red-500":"text-gray-500",o=e.sparkline?.map((s,l)=>({value:s,idx:l}));return jsxs("div",{className:"p-4 rounded-lg border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-900 relative overflow-hidden",children:[o&&o.length>0&&jsx("div",{className:"absolute bottom-0 left-0 right-0 h-10 opacity-30",children:jsx(ResponsiveContainer,{width:"100%",height:"100%",children:jsx(AreaChart,{data:o,margin:{top:0,right:0,left:0,bottom:0},children:jsx(Area,{type:"monotone",dataKey:"value",stroke:e.color||a,fill:e.color||a,strokeWidth:1,isAnimationActive:r})})})}),jsxs("div",{className:"relative z-10",children:[jsx("span",{className:"text-xs text-gray-500 font-medium uppercase tracking-wider",children:e.label}),jsxs("div",{className:"flex items-baseline gap-1 mt-1",children:[jsx("span",{className:"text-2xl font-bold",children:e.value}),e.unit&&jsx("span",{className:"text-sm text-gray-500",children:e.unit})]}),(e.trend||e.change)&&jsxs("div",{className:"flex items-center gap-1 mt-2",children:[t,e.change&&jsx("span",{className:i("text-sm font-medium",n),children:e.change}),e.changeLabel&&jsx("span",{className:"text-xs text-gray-500",children:e.changeLabel})]})]})]})}function kt({data:e,config:a,isStreaming:r=false}){let{metrics:t,layout:n="row"}=e,o=a?.colors||As,s=a?.animate!==false&&!r,l=n==="grid";return jsx("div",{className:i("w-full",l?"grid grid-cols-1 sm:grid-cols-2 gap-4":"flex gap-4 flex-wrap"),children:t.map((c,p)=>jsx("div",{className:i(!l&&"flex-1 min-w-[200px]"),children:jsx(Ls,{metric:c,color:c.color||o[p%o.length],animate:s})},p))})}var Ws={js:"javascript",ts:"typescript",jsx:"jsx",tsx:"tsx",py:"python",rb:"ruby",rs:"rust",go:"go",java:"java",cpp:"cpp",c:"c",cs:"csharp",sh:"bash",bash:"bash",sql:"sql",html:"html",css:"css",json:"json",yaml:"yaml",yml:"yaml",xml:"xml",md:"markdown",graphql:"graphql"};function Nt({data:e}){let{code:a,language:r,lineNumbers:t=true,highlightLines:n=[],startLine:o=1}=e,[s,l]=useState(false),c=Ws[r.toLowerCase()]||r.toLowerCase(),p=async()=>{try{await navigator.clipboard.writeText(a),l(!0);}catch{}};return useEffect(()=>{if(s){let x=setTimeout(()=>l(false),2e3);return ()=>clearTimeout(x)}},[s]),jsxs("div",{className:"relative rounded-lg overflow-hidden border border-gray-200 dark:border-gray-700",children:[jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 bg-gray-800 dark:bg-gray-900 border-b border-gray-700",children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx(FileText,{size:16,className:"text-gray-400"}),jsx("span",{className:"text-xs font-mono text-gray-400 lowercase",children:c})]}),jsx("button",{onClick:p,className:"flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-white/10 transition-colors text-gray-400 hover:text-gray-200",title:s?"Copied!":"Copy code",children:s?jsx(Check,{size:14,className:"text-green-400"}):jsx(Copy,{size:14})})]}),jsx(Prism,{language:c,style:oneDark,showLineNumbers:t,startingLineNumber:o,wrapLines:true,lineProps:x=>{let y={};return n.includes(x)&&(y.backgroundColor="rgba(59, 130, 246, 0.1)",y.display="block",y.borderLeft="3px solid #3B82F6",y.paddingLeft="8px",y.marginLeft="-11px"),{style:y}},customStyle:{margin:0,borderRadius:0,fontSize:"0.8125rem",lineHeight:"1.6",background:"#1e1e1e"},codeTagProps:{style:{fontFamily:"'Fira Code', 'JetBrains Mono', monospace"}},children:a.trim()})]})}function Ct({data:e,config:a,isStreaming:r=false,onAction:t}){let{fields:n,submitAction:o}=e,s=a?.submitButtonText||"Submit",l=a?.cancelButtonText||"Cancel",[c,p]=useState(()=>{let g={};return n.forEach(h=>{h.defaultValue!==void 0?g[h.name]=h.defaultValue:h.type==="multiselect"?g[h.name]=[]:h.type==="checkbox"?g[h.name]=false:g[h.name]="";}),g}),[b,x]=useState({}),[y,v]=useState(false),f=(g,h)=>{p(u=>({...u,[g]:h})),b[g]&&x(u=>{let R={...u};return delete R[g],R});},N=()=>{let g={};return n.forEach(h=>{let u=c[h.name];if(h.required&&(u==null||u===""||Array.isArray(u)&&u.length===0)){g[h.name]=`${h.label} is required`;return}if(!(!u&&!h.required)){if(h.validation){let{min:R,max:C,pattern:V,message:G}=h.validation;R!==void 0&&typeof u=="number"&&u<R&&(g[h.name]=G||`Minimum value is ${R}`),C!==void 0&&typeof u=="number"&&u>C&&(g[h.name]=G||`Maximum value is ${C}`),V&&typeof u=="string"&&!new RegExp(V).test(u)&&(g[h.name]=G||"Invalid format");}h.type==="email"&&typeof u=="string"&&u&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(u)&&(g[h.name]="Invalid email address");}}),x(g),Object.keys(g).length===0},T=g=>{g.preventDefault(),N()&&(t?t({type:"form_submit",action:o||"",data:c}):window.dispatchEvent(new CustomEvent("visualization-form-submit",{detail:{action:o,data:c}})),v(true));},I=()=>{t?t({type:"form_cancel",action:o||""}):window.dispatchEvent(new CustomEvent("visualization-form-cancel",{detail:{action:o}}));};if(y)return jsxs("div",{className:"text-center py-8",children:[jsx("p",{className:"text-lg font-semibold text-green-500 mb-1",children:"Form Submitted"}),jsx("p",{className:"text-sm text-gray-500",children:"Your response has been recorded."})]});let L="w-full px-3 py-2 text-sm rounded-lg border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-900 focus:ring-2 focus:ring-blue-500/20 focus:border-blue-500 outline-none transition-colors",U="border-red-500 focus:ring-red-500/20 focus:border-red-500",D=g=>{let h=c[g.name],R=!!b[g.name];switch(g.type){case "text":case "email":case "number":return jsx("input",{type:g.type,placeholder:g.placeholder,required:g.required,value:String(h||""),onChange:C=>f(g.name,g.type==="number"?parseFloat(C.target.value)||"":C.target.value),className:i(L,R&&U),min:g.validation?.min,max:g.validation?.max});case "textarea":return jsx("textarea",{placeholder:g.placeholder,required:g.required,value:String(h||""),onChange:C=>f(g.name,C.target.value),className:i(L,"min-h-[100px] resize-y",R&&U),rows:4});case "select":return jsxs("select",{value:String(h||""),onChange:C=>f(g.name,C.target.value),className:i(L,R&&U),children:[jsx("option",{value:"",disabled:true,children:g.placeholder||"Select an option"}),g.options?.map(C=>jsx("option",{value:C.value,children:C.label},C.value))]});case "multiselect":return jsx("select",{multiple:true,value:h||[],onChange:C=>f(g.name,Array.from(C.target.selectedOptions,V=>V.value)),className:i(L,"min-h-[80px]",R&&U),children:g.options?.map(C=>jsx("option",{value:C.value,children:C.label},C.value))});case "checkbox":return jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[jsx("input",{type:"checkbox",checked:!!h,onChange:C=>f(g.name,C.target.checked),className:"w-4 h-4 accent-blue-500 rounded"}),jsx("span",{className:"text-sm",children:g.label})]});case "radio":return jsx("div",{className:"space-y-1",children:g.options?.map(C=>jsxs("label",{className:"flex items-center gap-2 cursor-pointer text-sm",children:[jsx("input",{type:"radio",name:g.name,value:C.value,checked:h===C.value,onChange:V=>f(g.name,V.target.value),className:"w-3.5 h-3.5 accent-blue-500"}),C.label]},C.value))});case "date":return jsx("input",{type:"date",value:String(h||""),onChange:C=>f(g.name,C.target.value),className:i(L,R&&U)});case "datetime":return jsx("input",{type:"datetime-local",value:String(h||""),onChange:C=>f(g.name,C.target.value),className:i(L,R&&U)});default:return null}};return jsxs("form",{onSubmit:T,className:"space-y-4",children:[n.map(g=>jsxs("div",{children:[g.type!=="checkbox"&&jsxs("label",{className:"block text-sm font-medium mb-1",children:[g.label,g.required&&jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]}),D(g),b[g.name]&&jsx("p",{className:"text-xs text-red-500 mt-1",children:b[g.name]})]},g.name)),jsxs("div",{className:"flex gap-2 pt-2",children:[jsx("button",{type:"submit",disabled:r,className:"px-4 py-2 text-sm rounded-lg bg-blue-500 text-white hover:bg-blue-600 disabled:opacity-50 transition-colors",children:s}),jsx("button",{type:"button",onClick:I,className:"px-4 py-2 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors",children:l})]})]})}var St=new Map;function Pe(e,a){St.set(e,a);}function zt(e){return St.get(e)}function Ba(){return Array.from(St.keys())}Pe("chart",{component:ht});Pe("table",{component:yt});Pe("card",{component:vt});Pe("kpi",{component:kt});Pe("code_preview",{component:Nt});Pe("form",{component:Ct});function $a(e){for(let[a,r]of Object.entries(e)){let t=St.get(a);t&&(t.schema=r);}}var js=z.object({name:z.string(),data:z.array(z.union([z.object({x:z.union([z.string(),z.number()]),y:z.number()}),z.object({name:z.string(),value:z.number()})])),color:z.string().optional()}),Oa=z.object({label:z.string().optional(),type:z.enum(["category","number","time"]).optional(),min:z.number().optional(),max:z.number().optional()}),Gt=z.object({chartType:z.enum(["line","bar","pie","area","scatter","composed"]),series:z.array(js),xAxis:Oa.optional(),yAxis:Oa.optional()}),Hs=z.object({key:z.string(),label:z.string(),type:z.enum(["string","number","currency","date","badge","link","boolean","progress"]).optional(),align:z.enum(["left","center","right"]).optional(),width:z.string().optional()}),Xt=z.object({columns:z.array(Hs),rows:z.array(z.record(z.string(),z.unknown()))}),Us=z.object({title:z.string().optional(),items:z.array(z.object({label:z.string(),value:z.union([z.string(),z.number()])})).optional(),content:z.string().optional()}),Ks=z.object({label:z.string(),action:z.string(),variant:z.enum(["primary","secondary","text"]).optional()}),Zt=z.object({subtitle:z.string().optional(),imageUrl:z.string().optional(),sections:z.array(Us),actions:z.array(Ks).optional()}),qs=z.object({label:z.string(),value:z.union([z.string(),z.number()]),unit:z.string().optional(),trend:z.enum(["up","down","neutral"]).optional(),change:z.string().optional(),changeLabel:z.string().optional(),sparkline:z.array(z.number()).optional(),color:z.string().optional()}),Yt=z.object({metrics:z.array(qs),layout:z.enum(["row","grid"]).optional()}),Jt=z.object({code:z.string(),language:z.string(),lineNumbers:z.boolean().optional(),highlightLines:z.array(z.number()).optional(),startLine:z.number().optional()}),Gs=z.object({name:z.string(),type:z.enum(["text","number","email","select","multiselect","checkbox","radio","textarea","date","datetime"]),label:z.string(),required:z.boolean().optional(),placeholder:z.string().optional(),options:z.array(z.object({value:z.string(),label:z.string()})).optional(),defaultValue:z.unknown().optional(),validation:z.object({min:z.number().optional(),max:z.number().optional(),pattern:z.string().optional(),message:z.string().optional()}).optional()}),Qt=z.object({fields:z.array(Gs),submitAction:z.string().optional()});$a({chart:Gt,table:Xt,card:Zt,kpi:Yt,code_preview:Jt,form:Qt});function Pt({data:e,isStreaming:a=false,onAction:r}){let{type:t,title:n,description:o,data:s,config:l}=e;return jsxs("div",{className:"my-3 overflow-hidden",children:[(n||o)&&jsxs("div",{className:"mb-2",children:[n&&jsx("p",{className:"text-sm font-semibold",children:n}),o&&jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:o})]}),jsx("div",{children:(()=>{let p=zt(t);if(!p)return jsxs("div",{className:"flex items-center gap-2 p-4 text-yellow-500",children:[jsx(AlertCircle,{size:20}),jsxs("span",{className:"text-sm",children:["Unknown visualization type: ",t]})]});if(p.schema){let x=p.schema.safeParse(s);if(!x.success){let y=x.error.issues.slice(0,3);return jsxs("div",{className:"p-4 rounded-lg border border-red-200 dark:border-red-800 bg-red-50 dark:bg-red-950/30",children:[jsxs("div",{className:"flex items-center gap-2 text-red-600 dark:text-red-400 mb-2",children:[jsx(AlertCircle,{size:18}),jsxs("span",{className:"text-sm font-medium",children:["Invalid ",t," visualization data"]})]}),jsxs("ul",{className:"text-xs text-red-500 dark:text-red-400 space-y-1 list-disc list-inside",children:[y.map((v,f)=>jsxs("li",{children:[v.path.join("."),": ",v.message]},f)),x.error.issues.length>3&&jsxs("li",{children:["...and ",x.error.issues.length-3," more"]})]})]})}}let b=p.component;return jsx(b,{data:s,config:l,isStreaming:a,onAction:r})})()})]})}var Ha=/\[VIZ:([a-f0-9-]+)\]/gi;function Qs(e){let a=[],r=0,t;for(Ha.lastIndex=0;(t=Ha.exec(e))!==null;){if(t.index>r){let n=e.slice(r,t.index);n.trim()&&a.push({type:"text",content:n});}a.push({type:"viz",id:t[1]}),r=t.index+t[0].length;}if(r<e.length){let n=e.slice(r);n.trim()&&a.push({type:"text",content:n});}return a}var Ua=forwardRef(({message:e,viewerRole:a$1="user",className:r,showAvatar:t=true,showTimestamp:n=true,renderMarkdown:o=true,reasoning:s,executionPlan:l,executionTimeline:c$1,suggestedActions:p,onSuggestedAction:b,reasoningExpanded:x,onReasoningExpandedChange:y,citations:v,visualizations:f,baselineFontSize:N,executionTime:T,pendingClarification:I,onClarificationSubmit:L},U)=>{let g=useContext(a)?.onVisualizationAction,h=(e.participant?.role||"").toLowerCase(),u=(a$1||"").toLowerCase(),R=h===u,C=h==="assistant",V=e.isStreaming,G=s?.filter(k=>k.type==="thinking"||k.type==="tool"||k.type==="observation"||k.type==="planning"||k.type==="subtask"||k.type==="wave_start"||k.type==="wave_complete"||k.type==="parallel_subtask_start"||k.type==="parallel_subtask_complete"||k.type==="multi_agent_planning"||k.type==="subagent_start"||k.type==="subagent_complete"||k.type==="subagent_failed"||k.type==="synthesis"||k.type==="claude_thinking"||k.type==="subagent"||k.type==="file_operation"||k.type==="terminal"||k.type==="search_results"||k.type==="web_operation"||k.claudeToolData!=null),he=G&&G.length>0,we=!V&&(l||c$1&&c$1.length>0),ke=he||we,Ve=V&&!e.textContent&&!ke,De=e.attachments,Ue=De&&De.length>0,de=useMemo(()=>{if(!f||f.length===0)return null;let k=new Map;return f.forEach(S=>k.set(S.id,S)),k},[f]),Fe=de&&de.size>0,d$1=useMemo(()=>!Fe||!e.textContent?null:Qs(e.textContent),[Fe,e.textContent]),w=()=>e.textContent?d$1&&d$1.length>0&&de?jsx(Fragment,{children:d$1.map((k,S)=>{if(k.type==="text")return V?jsx(Xe,{content:k.content,isStreaming:true,baselineFontSize:N},S):jsx(ne,{baselineFontSize:N,className:R?"prose-invert":"",children:k.content},S);let Y=de.get(k.id);return Y?jsx(Pt,{data:Y,isStreaming:V,onAction:g},`viz-${k.id}`):null})}):V&&o?jsx(Xe,{content:e.textContent,isStreaming:true,baselineFontSize:N,className:R?"prose-invert":""}):o?jsx(ne,{baselineFontSize:N,className:R?"prose-invert":"",children:e.textContent}):jsx("p",{className:"whitespace-pre-wrap",children:e.textContent}):null,P=useRef(V);V&&(P.current=true);let _=!V&&!P.current;return jsx(c,{ref:U,message:e,viewerRole:a$1,className:i("w-full",_&&"animate-message-in",r),children:jsxs("div",{className:i("flex flex-col gap-1 w-full"),"data-is-viewer":R,children:[Ve&&jsxs("div",{className:i("flex items-start gap-2 w-full"),children:[t&&!R&&jsx("div",{className:"flex-shrink-0",children:jsx(Be,{name:e.participant?.name,src:e.participant?.avatarUrl,role:e.participant?.role,className:"w-10 h-10 flex-shrink-0"})}),jsx("div",{className:"px-4 py-3",children:jsx(Ke,{size:"small"})})]}),ke&&C&&jsx("div",{className:"w-full max-w-[80%]",children:jsx(jt,{isStreaming:V,chunks:G,plan:l,executionTimeline:c$1,userMessageTimestamp:e.createdAt?new Date((typeof e.createdAt=="string",e.createdAt)).getTime()/1e3:void 0,executionTime:T,expanded:x,onExpandedChange:y})}),e.textContent&&jsxs("div",{className:i("group flex items-start gap-2 w-full",R?"flex-row-reverse":"flex-row"),children:[t&&!R&&jsx("div",{className:"flex-shrink-0",children:jsx(Be,{name:e.participant?.name,src:e.participant?.avatarUrl,role:e.participant?.role,className:"w-10 h-10 flex-shrink-0"})}),jsxs("div",{className:i("max-w-[85%]","flex flex-col"),"data-message-role":R?"viewer":"other",children:[jsxs("div",{className:i("rounded-2xl",R||t?"px-4 py-3":""),style:{backgroundColor:R?"var(--chat-user-message-bg)":"transparent",color:R?"var(--chat-user-message-text, #ffffff)":"var(--chat-text)"},children:[jsx(d,{children:w()}),v&&v.length>0&&jsx("div",{className:"mt-2 pt-2 border-t border-[var(--chat-border)]",children:jsx(It,{sources:v})})]}),Ue&&jsx("div",{className:"mt-2",children:jsx(Bt,{attachments:De})}),!V&&(n&&e.createdAt||C&&e.textContent)&&jsxs("div",{className:i("flex items-center gap-2 mt-1",R&&"flex-row-reverse"),children:[n&&e.createdAt&&jsx(ei,{createdAt:typeof e.createdAt=="string"?e.createdAt:e.createdAt.toISOString(),isViewer:R}),C&&e.textContent&&jsx(Vt,{textContent:e.textContent})]})]})]}),e.error&&jsxs("div",{className:i("flex items-start gap-2 w-full max-w-[85%]","rounded-lg border px-3 py-2 mt-1"),style:{borderColor:"var(--chat-error, #B1001B)",backgroundColor:"color-mix(in srgb, var(--chat-error, #B1001B) 6%, transparent)",color:"var(--chat-error, #B1001B)"},children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"flex-shrink-0 mt-0.5",children:[jsx("path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z"}),jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}),jsx("span",{className:"text-sm",children:e.error.message})]}),!e.textContent&&t&&!R&&ke&&!Ve&&jsx("div",{className:"flex items-start gap-2 w-full",children:jsx("div",{className:"flex-shrink-0",children:jsx(Be,{name:e.participant?.name,src:e.participant?.avatarUrl,role:e.participant?.role,className:"w-10 h-10 flex-shrink-0"})})}),I&&!V&&L&&jsx("div",{className:"w-full max-w-[80%]",children:jsx(_t,{clarification:I,onSubmit:L})}),p&&p.length>0&&!V&&jsx("div",{className:"w-full max-w-[80%]",children:jsx(gt,{actions:p,onSelect:b})})]})})});Ua.displayName="Message";function ei({createdAt:e}){return jsx("span",{className:"text-xs text-[var(--chat-text-subtle)]",children:(r=>{try{return new Date(r).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}catch{return ""}})(e)})}var pi=100*1024*1024,di=["image/jpeg","image/jpg","image/png","image/gif","image/webp","image/svg+xml","image/bmp"],mi=["application/pdf","text/plain","text/csv","text/markdown","application/json","text/json","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],ui=["video/mp4","video/webm","video/ogg","video/avi","video/mov","video/wmv","video/flv","video/mkv"],gi=[...di,...mi,...ui];function qa(e){if(e===0)return "0 Bytes";let a=1024,r=["Bytes","KB","MB","GB"],t=Math.floor(Math.log(e)/Math.log(a));return parseFloat((e/Math.pow(a,t)).toFixed(2))+" "+r[t]}function fi(e,a,r){return e.size>r?`File size (${qa(e.size)}) exceeds max (${qa(r)})`:a.includes(e.type)?null:`File type ${e.type||"unknown"} is not allowed`}function bi({attachments:e,onRemove:a,disabled:r}){return e.length===0?null:jsx("div",{className:"flex flex-wrap gap-2 px-3 pt-3 pb-0",children:e.map(t=>{let n=t.file.type.startsWith("image/"),o=t.status==="error",s=t.status==="uploading";return jsxs("div",{className:i("relative flex items-center gap-1.5 px-2 py-1.5 rounded-lg text-xs max-w-[200px]",o?"bg-red-50 dark:bg-red-900/30 text-red-600 dark:text-red-400":"bg-gray-100 dark:bg-zinc-700 text-gray-600 dark:text-zinc-300"),children:[s?jsx(Loader2,{size:14,className:"flex-shrink-0 animate-spin"}):o?jsx(AlertCircle,{size:14,className:"flex-shrink-0"}):n&&t.previewUrl?jsx("img",{src:t.previewUrl,alt:t.file.name,className:"w-5 h-5 rounded object-cover"}):n?jsx(Image,{size:14,className:"flex-shrink-0"}):jsx(FileText,{size:14,className:"flex-shrink-0"}),jsx("span",{className:"truncate",title:o?t.error:t.file.name,children:o?t.error:t.file.name}),!r&&jsx("button",{type:"button",onClick:()=>a(t.id),className:"flex-shrink-0 ml-0.5 p-0.5 rounded-full hover:bg-gray-200 dark:hover:bg-zinc-600 transition-colors",children:jsx(X,{size:12})})]},t.id)})})}var Xa=forwardRef(({onSubmit:e,onAttach:a,onUploadFile:r,onRemoveUploadedAttachment:t,disabled:n=false,supportsAttachments:o=true,allowedFileTypes:s=gi,maxFileSize:l=pi,placeholder:c="Type a message...",className:p,isSubmitting:b=false},x)=>{let[y,v]=useState(""),[f,N]=useState([]),[T,I]=useState(false),L=useRef(null),U=useRef(null),D=useRef(0),g=n||b,h=f.some(d=>d.status==="uploading"),u=f.filter(d=>d.status==="uploaded"&&d.attachmentId).map(d=>d.attachmentId),R=u.length>0||f.some(d=>d.status==="pending"),C=y.trim().length>0||R,V=useCallback(()=>{let d=U.current;d&&(d.style.height="auto",d.style.height=Math.min(d.scrollHeight,200)+"px");},[]);useEffect(()=>{V();},[y,V]);let G=useCallback(async d=>{let w=d.map(P=>{let _=fi(P,s,l),k={id:`${Date.now()}-${Math.random().toString(36).slice(2,9)}`,file:P,status:_?"error":r?"uploading":"pending",error:_||void 0};return !_&&P.type.startsWith("image/")&&(k.previewUrl=URL.createObjectURL(P)),k});if(N(P=>[...P,...w]),a?.(d),r){for(let P of w)if(P.status==="uploading")try{let _=await r(P.file);N(k=>k.map(S=>S.id===P.id?{...S,status:"uploaded",attachmentId:_}:S));}catch(_){N(k=>k.map(S=>S.id===P.id?{...S,status:"error",error:_ instanceof Error?_.message:"Upload failed"}:S));}}},[s,l,r,a]),he=useCallback(async()=>{if(!C||g||h)return;let d=y,w=f.filter(_=>_.status!=="error").map(_=>_.file),P=f;v(""),N([]);try{r&&u.length>0?await e(d,void 0,u):await e(d,w.length>0?w:void 0);}catch{v(d),N(P);}},[y,f,C,g,h,e,r,u]),we=useCallback(d=>{d.key==="Enter"&&!d.shiftKey&&(d.preventDefault(),!g&&!h&&he());},[he,g,h]),ke=useCallback(d=>{let w=d.target.files;!w||w.length===0||(G(Array.from(w)),d.target.value="");},[G]),Ve=useCallback(d=>{N(w=>{let P=w.find(_=>_.id===d);return P?.previewUrl&&URL.revokeObjectURL(P.previewUrl),P?.attachmentId&&t&&t(P.attachmentId),w.filter(_=>_.id!==d)});},[t]),De=useCallback(d=>{d.preventDefault(),d.stopPropagation(),!(!o||b)&&(D.current++,d.dataTransfer.types.includes("Files")&&I(true));},[o,b]),Ue=useCallback(d=>{d.preventDefault(),d.stopPropagation(),D.current--,D.current===0&&I(false);},[]),de=useCallback(d=>{d.preventDefault(),d.stopPropagation();},[]),Fe=useCallback(d=>{if(d.preventDefault(),d.stopPropagation(),D.current=0,I(false),!o||b)return;let w=Array.from(d.dataTransfer.files);w.length>0&&G(w);},[o,b,G]);return useEffect(()=>()=>{f.forEach(d=>{d.previewUrl&&URL.revokeObjectURL(d.previewUrl);});},[]),jsx("div",{ref:x,className:i("flex-shrink-0 px-3 pt-2 pb-3","border-t border-gray-200 dark:border-zinc-700","bg-white/95 dark:bg-zinc-900/95 backdrop-blur-sm",p),onDragEnter:De,onDragLeave:Ue,onDragOver:de,onDrop:Fe,children:jsxs("div",{className:i("mx-auto max-w-[900px]","rounded-xl","bg-white dark:bg-zinc-800","border border-gray-200 dark:border-zinc-700","shadow-sm","transition-all duration-200","focus-within:shadow-md focus-within:border-gray-300 dark:focus-within:border-zinc-600",T&&"ring-2 ring-blue-400 border-blue-400"),children:[T&&jsx("div",{className:"px-3 pt-3 pb-0",children:jsx("div",{className:"flex items-center justify-center py-4 rounded-lg border-2 border-dashed border-blue-300 bg-blue-50 dark:bg-blue-900/20 text-blue-500 text-sm",children:"Drop files here"})}),jsx(bi,{attachments:f,onRemove:Ve,disabled:b}),jsxs("div",{className:i("flex items-center gap-2 p-3",f.length>0&&"pt-1.5"),children:[o&&jsx("button",{type:"button",onClick:()=>L.current?.click(),disabled:b,className:i("flex-shrink-0","w-8 h-8 rounded-lg","flex items-center justify-center","border border-gray-200 dark:border-zinc-600","text-gray-500 dark:text-zinc-400","hover:bg-gray-50 dark:hover:bg-zinc-700","disabled:opacity-40 disabled:cursor-not-allowed","transition-colors"),children:jsx(Paperclip,{size:16})}),jsx("div",{className:"flex-1 min-w-0",children:jsx("textarea",{ref:U,value:y,onChange:d=>v(d.target.value),onKeyDown:we,disabled:g,placeholder:c,rows:1,className:i("w-full resize-none outline-none","min-h-[24px] max-h-[200px]","text-sm leading-relaxed","text-gray-900 dark:text-zinc-100","placeholder:text-gray-400 dark:placeholder:text-zinc-500","bg-transparent","disabled:opacity-50 disabled:cursor-not-allowed")})}),jsx("button",{type:"button",onClick:he,disabled:!C||g||h,className:i("flex-shrink-0","w-9 h-9 rounded-lg","flex items-center justify-center","bg-blue-500 text-white","shadow-sm","hover:bg-blue-600 hover:shadow-md hover:-translate-y-px","active:translate-y-0 active:shadow-sm","disabled:bg-gray-300 dark:disabled:bg-zinc-600 disabled:shadow-none disabled:translate-y-0 disabled:cursor-not-allowed","transition-all duration-200"),children:b||h?jsx(Loader2,{size:16,className:"animate-spin"}):jsx(ArrowUp,{size:16})})]}),o&&jsx("input",{ref:L,type:"file",multiple:true,accept:s.join(","),onChange:ke,className:"hidden"})]})})});Xa.displayName="MessageComposer";function na({isAtBottom:e,onScrollToBottom:a,className:r}){return jsx("button",{type:"button",onClick:a,"aria-label":"Scroll to bottom",className:i("absolute bottom-4 left-1/2 -translate-x-1/2 z-10","flex items-center justify-center","w-8 h-8 rounded-full","bg-[var(--chat-bg,#ffffff)] border border-[var(--chat-border)]","shadow-subtle hover:shadow-button-hover","text-[var(--chat-text-subtle)] hover:text-[var(--chat-text)]","transition-all duration-200",e?"opacity-0 pointer-events-none translate-y-2":"opacity-100 translate-y-0",r),children:jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M12 5v14"}),jsx("path",{d:"m19 12-7 7-7-7"})]})})}var Ya=forwardRef(({children:e,autoScroll:a=true,showScrollToBottom:r=true,className:t},n)=>{let{containerRef:o,scrollToBottom:s,isAtBottom:l}=a$1({enabled:a});return jsxs("div",{className:"relative flex-1 overflow-hidden",children:[jsx("div",{ref:p=>{o.current=p,typeof n=="function"?n(p):n&&(n.current=p);},className:i("h-full overflow-y-auto","flex flex-col gap-4 p-4","chat-scrollbar",t),children:e}),r&&jsx(na,{isAtBottom:l,onScrollToBottom:()=>s("smooth")})]})});Ya.displayName="MessageList";function vi({label:e,className:a}){return jsxs("div",{className:`flex items-center gap-3 py-6 select-none ${a??""}`,role:"separator",children:[jsx("div",{className:"flex-1 h-px bg-[var(--chat-border)]"}),jsx("span",{className:"text-xs font-medium text-[var(--chat-text-subtle)] whitespace-nowrap",children:e}),jsx("div",{className:"flex-1 h-px bg-[var(--chat-border)]"})]})}var Qa=forwardRef(({className:e},a)=>jsx(r,{ref:a,className:i("inline-flex items-center gap-1","px-4 py-3",e),children:jsx(Ke,{size:"small"})}));Qa.displayName="TypingIndicator";function Pi({title:e,subtitle:a,logo:r,actions:t,showClose:n,onClose:o,loading:s,className:l,style:c}){let[p,b]=useState(false),x=useRef(null),y=useRef(null);return useEffect(()=>{let v=f=>{let N=f.composedPath();x.current&&!N.includes(x.current)&&y.current&&!N.includes(y.current)&&b(false);};if(p)return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[p]),jsxs("header",{className:i("flex items-center justify-between gap-3","px-4 py-3","border-b border-[var(--chat-border)]","bg-[var(--chat-header-bg,#ffffff)]",l),style:c,children:[jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[r&&jsx("div",{className:"flex-shrink-0",children:typeof r=="string"?jsx("img",{src:r,alt:"",className:"w-10 h-10 rounded-lg object-contain"}):r}),jsxs("div",{className:"flex flex-col min-w-0",children:[s?jsx("div",{className:"h-5 w-24 bg-gray-200 rounded animate-pulse"}):jsx("h1",{className:"text-lg font-semibold text-[var(--chat-text)] truncate",children:e}),a&&jsx("p",{className:"text-sm text-[var(--chat-text-subtle)] truncate",children:a})]})]}),jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[t&&t.length>0&&jsxs("div",{className:"relative",children:[jsx("button",{ref:y,onClick:()=>b(!p),className:i("p-2 rounded-lg","text-[var(--chat-text-subtle)]","hover:bg-[var(--chat-panel-bg)] hover:text-[var(--chat-text)]","transition-colors duration-200"),"aria-label":"Menu","aria-expanded":p,children:jsx(MoreVertical,{size:18})}),p&&jsx("div",{ref:x,className:i("absolute right-0 top-full mt-1 z-50","min-w-[180px]","bg-white rounded-lg shadow-lg","border border-[var(--chat-border)]","py-1","animate-fade-in"),children:t.map(v=>jsxs("button",{onClick:()=>{v.onClick(),b(false);},disabled:v.disabled,className:i("w-full flex items-center gap-2 px-3 py-2","text-sm text-left","text-[var(--chat-text)]","hover:bg-[var(--chat-panel-bg)]","disabled:opacity-50 disabled:cursor-not-allowed","transition-colors duration-150"),children:[v.icon&&jsx("span",{className:"flex-shrink-0 text-[var(--chat-text-subtle)]",children:v.icon}),v.label]},v.id))})]}),n&&o&&jsx("button",{onClick:o,className:i("p-2 rounded-lg","text-[var(--chat-text-subtle)]","hover:bg-[var(--chat-panel-bg)] hover:text-[var(--chat-text)]","transition-colors duration-200"),"aria-label":"Close",children:jsx(X,{size:18})})]})]})}function Ti({toolName:e,status:a,description:r,className:t}){return jsxs("div",{className:i("relative flex items-center gap-2 py-1 px-2 rounded-md text-sm overflow-hidden",a==="running"&&"animate-shimmer",t),children:[jsx(Di,{status:a}),jsx("span",{className:"font-medium text-[var(--chat-text)]",children:e}),r&&jsx("span",{className:"text-[var(--chat-text-subtle)] truncate",children:r})]})}function Di({status:e}){switch(e){case "running":return jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"animate-spin text-[var(--chat-primary)]",children:jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})});case "complete":return jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-[var(--chat-secondary,#56C18A)]",children:[jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]});case "failed":return jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-[var(--chat-error,#B1001B)]",children:[jsx("circle",{cx:"12",cy:"12",r:"10"}),jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]});case "pending":return jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-[var(--chat-text-subtle)]",children:[jsx("circle",{cx:"12",cy:"12",r:"10"}),jsx("polyline",{points:"12 6 12 12 16 14"})]})}}var ar=forwardRef(({isEmpty:e,header:a,welcomeScreen:r,messageList:t,composer:n,footer:o,className:s},l)=>jsx("div",{ref:l,"data-chat-ui":true,className:i("relative h-full overflow-hidden flex flex-col min-h-0",s),children:jsx(AnimatePresence,{mode:"wait",children:e&&r?jsxs(motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.3},className:"flex-1 flex flex-col overflow-hidden min-h-0",children:[a,r]},"welcome"):jsxs(motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.4},className:"flex-1 flex flex-col overflow-hidden min-h-0",children:[a,jsx(motion.div,{initial:{opacity:0,y:-20},animate:{opacity:1,y:0},transition:{duration:.4,delay:.1},className:"flex-1 overflow-hidden flex flex-col min-h-0",children:t}),o,jsx(motion.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.4,delay:.2},children:n})]},"active")})}));ar.displayName="ChatLayout";function _i(e,a=3e3){let[r,t]=useState(0),n=useRef(null);return useEffect(()=>{if(e.length<=1)return;let o=()=>{n.current=setInterval(()=>{t(l=>(l+1)%e.length);},a);},s=()=>{document.visibilityState!=="visible"?n.current&&(clearInterval(n.current),n.current=null):o();};return o(),document.addEventListener("visibilitychange",s),()=>{n.current&&clearInterval(n.current),document.removeEventListener("visibilitychange",s);}},[e,a]),e[r]??""}function Vi({placeholder:e,onSubmit:a,disabled:r,supportsAttachments:t}){let[n,o]=useState(""),[s,l]=useState([]),c=useRef(null),p=useRef(null);useEffect(()=>{c.current&&(c.current.style.height="auto",c.current.style.height=c.current.scrollHeight+"px");},[n]);let b=f=>{f.key==="Enter"&&!f.shiftKey&&(f.preventDefault(),x());},x=()=>{!n.trim()&&s.length===0||r||(a(n.trim(),s.length>0?s:void 0),o(""),l([]));},y=f=>{f.target.files&&l(N=>[...N,...Array.from(f.target.files)]),f.target.value="";},v=f=>{l(N=>N.filter((T,I)=>I!==f));};return jsxs("form",{className:i("w-full relative mx-auto","bg-white dark:bg-zinc-800","rounded-2xl overflow-hidden","shadow-[0_8px_30px_rgba(0,0,0,0.08)]","border border-gray-100 dark:border-zinc-700/50","transition duration-200","focus-within:shadow-[0_8px_30px_rgba(0,0,0,0.12)] focus-within:border-gray-200 dark:focus-within:border-zinc-600"),onSubmit:f=>{f.preventDefault(),x();},children:[s.length>0&&jsx("div",{className:"flex flex-wrap gap-2 px-4 pt-3",children:s.map((f,N)=>jsxs("div",{className:i("flex items-center gap-1.5 px-2.5 py-1 rounded-lg text-xs","bg-gray-100 dark:bg-zinc-700 text-gray-600 dark:text-zinc-300"),children:[jsx("span",{className:"max-w-[120px] truncate",children:f.name}),jsx("button",{type:"button",onClick:()=>v(N),className:"flex-shrink-0 text-gray-400 hover:text-gray-600 dark:hover:text-zinc-200",children:jsx(X,{size:12})})]},`${f.name}-${N}`))}),jsxs("div",{className:"flex items-center gap-2",children:[t&&jsx("button",{type:"button",onClick:()=>p.current?.click(),disabled:r,className:i("ml-3 flex-shrink-0","w-8 h-8 rounded-lg","flex items-center justify-center","text-gray-400 dark:text-zinc-500","hover:bg-gray-100 dark:hover:bg-zinc-700","hover:text-gray-600 dark:hover:text-zinc-300","disabled:opacity-40 disabled:cursor-not-allowed","transition-colors"),children:jsx(Paperclip,{size:16})}),jsx("textarea",{ref:c,value:n,onChange:f=>o(f.target.value),onKeyDown:b,disabled:r,rows:1,placeholder:e,className:i("flex-1 text-sm sm:text-base","border-none bg-transparent","text-gray-900 dark:text-white","focus:outline-none focus:ring-0 resize-none","py-4 sm:py-5",t?"pl-1":"pl-4 sm:pl-6","placeholder:text-gray-400 dark:placeholder:text-zinc-500","disabled:opacity-50 disabled:cursor-not-allowed","max-h-[200px] overflow-y-auto")}),jsx("button",{type:"submit",disabled:!n.trim()&&s.length===0||!!r,className:i("mr-3 flex-shrink-0","w-9 h-9 rounded-lg","flex items-center justify-center","bg-gray-900 dark:bg-zinc-600 text-white dark:text-zinc-100","shadow-sm","hover:bg-gray-700 dark:hover:bg-zinc-500","hover:shadow-md hover:-translate-y-px","active:translate-y-0 active:shadow-sm","disabled:bg-gray-300 dark:disabled:bg-zinc-700","disabled:text-gray-500 dark:disabled:text-zinc-400","disabled:shadow-none disabled:translate-y-0 disabled:cursor-not-allowed","transition-all duration-200"),children:jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M12 19V5M5 12l7-7 7 7"})})})]}),t&&jsx("input",{ref:p,type:"file",multiple:true,onChange:y,className:"hidden"})]})}function Fi({text:e,onClick:a,index:r}){let t=useRef(null),n=useRef(typeof window<"u"?window.matchMedia("(prefers-reduced-motion: reduce)").matches:false),[o,s]=useState(null),l=useCallback(p=>{if(n.current)return;let b=p.currentTarget.getBoundingClientRect();s({x:p.clientX-b.left,y:p.clientY-b.top});},[]),c=useCallback(()=>{s(null);},[]);return jsx(motion.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.2+r*.1,duration:.4},children:jsxs("button",{ref:t,type:"button",onClick:a,onMouseMove:l,onMouseLeave:c,className:i("relative overflow-hidden","w-full text-left","p-3","cursor-pointer","border border-gray-200 dark:border-zinc-700","rounded-lg","transition-all duration-200 ease-out","bg-white dark:bg-zinc-800","hover:border-gray-300 dark:hover:border-zinc-600","hover:bg-gray-50 dark:hover:bg-zinc-750","hover:shadow-sm","active:bg-gray-100 dark:active:bg-zinc-700"),children:[o&&jsx("div",{className:"pointer-events-none absolute inset-0 z-0",style:{background:`radial-gradient(120px circle at ${o.x}px ${o.y}px, var(--chat-halo-primary, rgba(16,105,151,0.06)), transparent)`}}),jsxs("div",{className:"relative z-10 flex items-start gap-2.5",children:[jsx(MessageCircleQuestion,{size:16,strokeWidth:2,className:"mt-0.5 text-gray-400 dark:text-zinc-500 flex-shrink-0"}),jsx("span",{className:"text-sm text-gray-600 dark:text-zinc-300 leading-relaxed flex-1",children:e})]})]})})}var nr=forwardRef(({placeholders:e=[],suggestions:a=[],onSubmit:r,onSuggestionClick:t,welcomeText:n="How can I help you today?",supportsAttachments:o,composerSlot:s,className:l},c)=>{let p=_i(e),b=useCallback(x=>{t?.(x);},[t]);return jsxs("div",{ref:c,className:i("relative overflow-hidden","flex-1 flex items-center justify-center","px-4 sm:px-6",l),children:[jsx("div",{className:"pointer-events-none absolute inset-0 animate-welcome-halo",style:{background:"radial-gradient(ellipse 60% 50% at 50% 45%, var(--chat-halo-primary, rgba(16,105,151,0.06)), var(--chat-halo-secondary, rgba(86,193,138,0.03)) 60%, transparent 100%)"}}),jsxs(motion.div,{layout:true,initial:{scale:.95,y:20,opacity:0},animate:{scale:1,y:0,opacity:1},transition:{type:"spring",stiffness:200,damping:25},className:"relative w-full max-w-[800px] flex flex-col items-center gap-8",children:[n&&jsx(motion.h2,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},transition:{delay:.1,duration:.4},className:"text-2xl font-semibold text-gray-800 dark:text-gray-300 text-center",children:n}),jsx("div",{className:i("w-full rounded-2xl","transition-shadow duration-500","shadow-[0_0_15px_rgba(16,105,151,0.08)]","focus-within:shadow-[0_0_20px_rgba(16,105,151,0.15),0_0_40px_rgba(86,193,138,0.08)]","dark:shadow-[0_0_15px_rgba(255,255,255,0.04)]","dark:focus-within:shadow-[0_0_20px_rgba(255,255,255,0.08),0_0_40px_rgba(255,255,255,0.03)]"),children:s??jsx(Vi,{placeholder:p,onSubmit:(x,y)=>r?.(x,y),supportsAttachments:o})}),a.length>0&&jsx("div",{className:i("grid gap-3 w-full max-w-[900px]","grid-cols-1 sm:grid-cols-[repeat(auto-fit,minmax(250px,1fr))]"),children:a.map((x,y)=>jsx(Fi,{text:x,onClick:()=>b(x),index:y},y))})]})]})});nr.displayName="WelcomeScreen";
19
- export{ar as $,jt as A,Xe as B,gt as C,ht as D,yt as E,vt as F,kt as G,Nt as H,Ct as I,Pe as J,zt as K,Ba as L,Gt as M,Xt as N,Zt as O,Yt as P,Jt as Q,Qt as R,Pt as S,Ua as T,Xa as U,na as V,Ya as W,vi as X,Qa as Y,Pi as Z,Ti as _,i as a,nr as aa,ha as b,Be as c,va as d,Ke as e,ne as f,It as g,Na as h,Wr as i,_t as j,Vt as k,Bt as l,rt as m,Ae as n,dn as o,Ot as p,nt as q,bn as r,Ce as s,st as t,it as u,lt as v,ct as w,pt as x,dt as y,mt as z};//# sourceMappingURL=chunk-QFKEGVG6.js.map
20
- //# sourceMappingURL=chunk-QFKEGVG6.js.map
18
+ ... (truncated)`]})})]})]})}var yo={code_reviewer:"Code Review",researcher:"Research",data_analyst:"Data Analysis",Explore:"Explore",Plan:"Planning",Bash:"Command Execution"};function mt({chunk:e}){let[a,r]=useState(true),t=e.subagentData;if(!t)return null;let n=t.status==="running"?jsx(Loader2,{size:16,className:"animate-spin text-blue-500"}):t.status==="completed"?jsx(CheckCircle2,{size:16,className:"text-green-500"}):t.status==="failed"?jsx(XCircle,{size:16,className:"text-red-500"}):null,o=t.status==="running"?"border-blue-500":t.status==="completed"?"border-green-500":t.status==="failed"?"border-red-500":"border-gray-500",s=t.status==="running"?"bg-blue-500/3":t.status==="completed"?"bg-green-500/3":t.status==="failed"?"bg-red-500/3":"bg-gray-500/3",l=t.status==="running"?"bg-blue-500/10 text-blue-500":t.status==="completed"?"bg-green-500/10 text-green-500":t.status==="failed"?"bg-red-500/10 text-red-500":"bg-gray-500/10 text-gray-500",c=b=>b?b<1e3?b+"ms":(b/1e3).toFixed(1)+"s":null,p=yo[t.subagentType]||t.subagentType;return jsxs("div",{className:i("border border-dashed rounded ml-4 my-2 overflow-hidden",o+"/50",s),children:[jsxs("div",{onClick:()=>r(!a),className:i("flex items-center gap-2 px-3 py-1.5 cursor-pointer hover:brightness-95"),children:[jsx("span",{className:"p-0.5",children:a?jsx(ChevronDown,{size:18}):jsx(ChevronRight,{size:18})}),jsx(GitBranch,{size:16,className:o.replace("border-","text-")}),jsx("span",{className:i("text-[0.75rem] px-2 py-0.5 rounded font-medium",l),children:p}),jsx("span",{className:"flex-1 text-sm text-gray-500 truncate",children:t.description}),n,t.durationMs!=null&&jsx("span",{className:"text-[0.7rem] text-gray-400",children:c(t.durationMs)})]}),a&&jsxs("div",{className:"px-4 pb-3",children:[t.nestedChunks&&t.nestedChunks.length>0&&jsx("div",{className:"mt-2 space-y-1",children:t.nestedChunks.map((b,x)=>jsx(vo,{chunk:b},x))}),t.status==="completed"&&t.result&&jsxs("div",{className:"mt-2 p-2 rounded bg-green-500/5 border border-green-500/20",children:[jsx("span",{className:"text-[0.75rem] font-medium text-green-500",children:"Result"}),jsx("p",{className:"mt-1 text-sm text-gray-500 whitespace-pre-wrap",children:t.result.length>500?t.result.slice(0,500)+"...":t.result})]})]})]})}function vo({chunk:e}){return e.type==="tool"||e.type==="observation"?jsxs("div",{className:"py-1 px-2 my-1 rounded bg-blue-500/5 text-[0.75rem]",children:[jsxs("span",{className:"font-medium text-blue-500",children:[e.toolName||"Tool",":"]})," ",jsxs("span",{className:"text-gray-500",children:[e.content?.slice(0,200)||e.toolDescription||"Executing...",e.content&&e.content.length>200&&"..."]})]}):e.type==="thinking"||e.type==="claude_thinking"?jsxs("p",{className:"py-1 text-[0.75rem] text-gray-400 italic",children:[e.content?.slice(0,150),e.content&&e.content.length>150&&"..."]}):null}function Ro(e){let a=useRef(null),[r,t]=useState(0),n=useRef(0);return useEffect(()=>{if(e){a.current===null&&(a.current=Date.now());let o=setInterval(()=>{if(a.current!==null){let s=Math.floor((Date.now()-a.current)/1e3);t(s),n.current=s;}},1e3);return ()=>clearInterval(o)}else a.current!==null&&(n.current=Math.floor((Date.now()-a.current)/1e3),t(n.current),a.current=null);},[e]),{display:`${r}`,finalSeconds:n.current}}function Mo(e){return e.some(a=>a.orchestrator==="claude_agent_sdk"||a.type==="subagent"||a.type==="file_operation"||a.type==="terminal"||a.type==="search_results"||a.type==="web_operation"||a.type==="claude_text"||a.type==="claude_thinking")}function Ao(e){return e.some(a=>a.type==="wave_start"||a.type==="wave_complete"||a.type==="parallel_subtask_start"||a.type==="parallel_subtask_complete"||a.isParallel)}function Lo(e){let a=e.filter(c=>c.type==="wave_start"&&c.waveData);if(a.length===0)return null;let r=a[a.length-1],t=r.waveData?.waveNumber??0,n=r.waveData?.totalWaves??1,o=r.waveData?.parallelCount??0,s=[],l=[];return e.forEach(c=>{if(c.type==="parallel_subtask_start"&&c.waveNumber===t&&c.subtaskId!==void 0&&(l.includes(c.subtaskId)||s.push(c.subtaskId)),c.type==="parallel_subtask_complete"&&c.waveNumber===t&&c.subtaskId!==void 0){l.push(c.subtaskId);let p=s.indexOf(c.subtaskId);p>=0&&s.splice(p,1);}}),{currentWave:t,totalWaves:n,parallelCount:o,activeSubtasks:s,completedSubtasks:l}}function Io(e){return e.some(a=>a.type==="multi_agent_planning"||a.type==="multi_agent_planning_complete"||a.type==="subagent_start"||a.type==="subagent_complete"||a.type==="subagent_failed"||a.type==="synthesis"||a.isMultiAgent)}function Ia(e){return e.find(r=>(r.type==="multi_agent_planning"||r.type==="multi_agent_planning_complete")&&r.subagentAllocations)?.subagentAllocations||[]}function _a(e){let a=new Map,r=false;Ia(e).forEach(o=>{a.set(o.name,{name:o.name,task:o.query||o.focus,status:"pending"});});let t={pending:0,running:1,completed:2,failed:2};e.forEach(o=>{if(o.subagentInfo?.name){let s=o.subagentInfo.id||o.subagentInfo.name,l=a.get(s);(!l||(t[o.subagentInfo.status]??0)>=(t[l.status]??0))&&a.set(s,o.subagentInfo);}o.type==="synthesis"&&(r=true);});let n=[...a.values()];return {subagents:a,running:n.filter(o=>o.status==="running").length,completed:n.filter(o=>o.status==="completed").length,failed:n.filter(o=>o.status==="failed").length,pending:n.filter(o=>o.status==="pending").length,isSynthesizing:r}}function _o(e){let a=[];return e.forEach(r=>{r.type==="thought"&&r.thought?a.push({type:"thinking",content:r.thought,subtaskId:r.subtask_id}):r.type==="tool"&&(a.push({type:"tool",content:"",toolName:r.tool||"Unknown Tool",toolDescription:r.tool_description,status:"completed",subtaskId:r.subtask_id}),r.observation&&a.push({type:"observation",content:r.observation,toolName:r.tool||"Unknown Tool",success:true,subtaskId:r.subtask_id}));}),a}function Vo({chunks:e}){let a=_a(e),r=[...a.subagents.values()];if(r.length===0){let n=e.some(s=>s.type==="multi_agent_planning"),o=Ia(e);return o.length>0?jsxs("div",{className:"flex items-center gap-2",children:[jsx(Loader2,{size:14,className:"animate-spin text-gray-400"}),jsxs("span",{className:"text-sm text-gray-500",children:["Allocating agents: ",o.map(s=>s.name).join(", ")]})]}):n?jsxs("div",{className:"flex items-center gap-2",children:[jsx(Loader2,{size:14,className:"animate-spin text-gray-400"}),jsx("span",{className:"text-sm text-gray-500",children:"Planning agent allocation..."})]}):null}let t=r.map((n,o)=>({id:n.id||`agent-${o}`,status:n.status==="running"?"running":n.status==="completed"?"completed":n.status==="failed"?"failed":"pending",content:jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[jsx("span",{className:"text-sm font-medium",children:n.name}),jsx("span",{className:i("text-sm flex-1 truncate",n.status==="failed"?"text-red-500":"text-gray-500"),children:n.status==="failed"&&n.error?n.error:n.task}),n.status==="completed"&&n.executionTime!=null&&jsxs("span",{className:"text-xs text-gray-400 shrink-0",children:[n.executionTime.toFixed(1),"s"]})]})}));return jsxs("div",{className:"space-y-2",children:[jsx("span",{className:"text-sm text-gray-500",children:a.running===0?"Agents:":"Running agents:"}),jsx(Ae,{items:t,badgeSize:16}),a.isSynthesizing&&jsxs("div",{className:"flex items-center gap-2",children:[jsx(Sparkle,{size:14,className:"text-gray-500"}),jsx("span",{className:"text-sm text-gray-500",children:"Synthesizing results..."})]})]})}function Fo({chunks:e}){return jsx("div",{className:"space-y-2",children:e.map((a,r)=>a.type==="subagent"&&a.subagentData?jsx(mt,{chunk:a},`subagent-${a.subagentData.subagentId}-${r}`):a.type==="file_operation"&&a.fileOperationData?jsx(ct,{chunk:a},`file-op-${a.fileOperationData.toolUseId}-${r}`):a.type==="terminal"&&a.terminalData?jsx(lt,{chunk:a},`terminal-${a.terminalData.toolUseId}-${r}`):a.type==="search_results"&&a.searchResultsData?jsx(pt,{chunk:a},`search-${a.searchResultsData.toolUseId}-${r}`):a.type==="web_operation"&&a.webOperationData?jsx(dt,{chunk:a},`web-op-${a.webOperationData.toolUseId}-${r}`):a.claudeToolData?jsx(it,{chunk:a},`claude-tool-${a.claudeToolData.toolUseId}-${r}`):null)})}function Ma(e){return e<1?`${Math.round(e*1e3)}ms`:`${e.toFixed(1)}s`}function jt({isStreaming:e=false,chunks:a=[],plan:r,executionTimeline:t=[],userMessageTimestamp:n,executionTime:o,defaultExpanded:s=false,expanded:l,onExpandedChange:c,className:p}){let[b,x]=useState(s),{display:y,finalSeconds:v}=Ro(e),f=useRef(null);useEffect(()=>{Re(f.current);},[]);let N=a$2(f,300),T=l??b,I=useCallback(d=>{N(),x(d),c?.(d);},[N,c]),L=useMemo(()=>e?a.map((d,w)=>nt(d,w)).filter(d=>d!==null):[],[e,a]),U=useMemo(()=>!e&&(t.length>0||a.length>0)?a.map((d,w)=>nt(d,w)).filter(d=>d!==null):[],[e,t,a]),D=useMemo(()=>!e&&t.length>0?_o(t):[],[e,t]),g=useMemo(()=>{if(!e)return null;let d=a.find(S=>S.planData!==void 0);if(!d?.planData)return null;let w={...d.planData},P=[...w.subtasks||[]],_=0,k=0;return a.forEach(S=>{if(S.type==="parallel_subtask_start"&&S.subtaskId!==void 0){let Y=P.findIndex(O=>String(O.id)===String(S.subtaskId));Y!==-1&&(P[Y]={...P[Y],status:"running"});}else if(S.type==="parallel_subtask_complete"&&S.subtaskId!==void 0){let Y=P.findIndex(O=>String(O.id)===String(S.subtaskId));if(Y!==-1){let O={...P[Y]};S.parallelSubtaskData?.success===false||S.success===false?(O.status="failed",O.error=S.parallelSubtaskData?.error,k++):(O.status="completed",O.result=S.parallelSubtaskData?.result,O.execution_time=S.parallelSubtaskData?.executionTime,_++),P[Y]=O;}}else if(S.type==="subtask"&&S.subtaskId!==void 0){let Y=P.findIndex(O=>String(O.id)===String(S.subtaskId));if(Y!==-1){let O={...P[Y]};if(S.content.includes("\u2713 Completed"))O.status="completed",S.subtaskData?.execution_time&&(O.execution_time=S.subtaskData.execution_time),_++;else if(S.content.includes("\u2717 Failed")){O.status="failed";let la=S.content.match(/✗ Failed: (.*)/);la&&(O.error=la[1]),k++;}else S.content.includes("\u2192 **Subtask")&&(O.status="running");P[Y]=O;}}}),w.subtasks=P,w.completed_subtasks=_,w.failed_subtasks=k,w.progress_percentage=_/w.total_subtasks*100,w},[e,a]),h=useMemo(()=>{if(o&&o>0)return o;if(!e){if(r?.subtasks)return r.subtasks.reduce((d,w)=>d+(w.execution_time||0),0);if(t.length>0){let d=t[t.length-1];if(n&&d.timestamp){let w=d.timestamp-n;if(w>0)return w}if(t.length>1){let w=t[0];if(w.timestamp&&d.timestamp){let P=d.timestamp-w.timestamp;if(P>0)return P}}}}return 0},[e,r,t,n,o]);if(!e){let d=r||t.length>0||a.length>0;if(!d||d&&U.length===0&&!r&&t.length===0)return null}let u=a.length>0?a[a.length-1]:null,R=u?.type==="tool"||!!u?.toolName,C=u?.type==="planning",V=Ao(a),G=V?Lo(a):null,he=Mo(a),we=Io(a),ke=we?_a(a):null,Ve=()=>{if(!e)return h>0?`Thought for ${Ma(h)}`:v>0?`Thought for ${Ma(v)}`:(a.length>0,"Thought for a few seconds");if(we&&ke){let{running:d,completed:w,failed:P,isSynthesizing:_}=ke;if(_)return "Synthesizing results...";if(u?.type==="multi_agent_planning")return "Planning subagent allocation...";if(u?.type==="subagent_start"&&u?.subagentInfo)return `${u.subagentInfo.name}: ${u.subagentInfo.task?.slice(0,30)||"working"}...`;if(u?.type==="subagent_complete"&&u?.subagentInfo)return `${u.subagentInfo.name} complete`;if(u?.type==="subagent_failed"&&u?.subagentInfo)return `${u.subagentInfo.name} failed`;let k=d+w+P;if(d>0)return `${d} subagent${d>1?"s":""} running (${w}/${k} done)`;if(k>0)return `Multi-agent execution (${w}/${k} complete)`}if(he){if(u?.type==="subagent"&&u?.subagentData)return `${u.subagentData.subagentType}: ${u.subagentData.description}`;if(u?.type==="file_operation"&&u?.fileOperationData){let d=u.fileOperationData.operation,w=u.fileOperationData.filePath.split("/").pop();return `${d==="read"?"Reading":d==="edit"?"Editing":"Writing"} ${w}`}if(u?.type==="terminal"&&u?.terminalData){let d=u.terminalData.command;return d.length>40?`$ ${d.slice(0,37)}...`:`$ ${d}`}if(u?.type==="search_results"&&u?.searchResultsData)return `${u.searchResultsData.tool}: ${u.searchResultsData.pattern}`;if(u?.type==="web_operation"&&u?.webOperationData)return u.webOperationData.operation==="search"?`Searching: ${u.webOperationData.query}`:`Fetching: ${u.webOperationData.url?.slice(0,40)}...`}if(V&&G){let{currentWave:d,totalWaves:w,parallelCount:P,activeSubtasks:_,completedSubtasks:k}=G;if(u?.type==="wave_start")return `Wave ${d+1}/${w}: ${P} parallel subtasks`;if(u?.type==="wave_complete")return `Wave ${d+1} complete (${k.length} done)`;if(u?.type==="parallel_subtask_start"&&u?.parallelSubtaskData?.description){let S=u.parallelSubtaskData.description;return S.length>40?`${S.slice(0,37)}...`:S}return _.length>0?`Wave ${d+1}/${w}: ${_.length} running...`:`Parallel execution (Wave ${d+1}/${w})`}if(u?.toolDescription)return u.toolDescription;if(u?.toolName)return u.toolName;switch(u?.type){case "planning":return "Planning...";case "thinking":return "Thinking...";case "tool":return u.toolName||"Using tool...";case "subtask":return `Executing subtask ${u.subtaskId||""}...`;case "observation":return "Analyzing results...";case "progress":return "Working...";case "wave_start":return "Starting parallel execution...";case "wave_complete":return "Parallel wave complete";case "parallel_subtask_start":return "Running parallel subtask...";case "parallel_subtask_complete":return "Parallel subtask complete";default:return "Thinking..."}},De=()=>we?jsx(Users,{size:14}):he?u?.type==="subagent"?jsx(GitBranch,{size:14}):u?.type==="file_operation"?jsx(FileText,{size:14}):u?.type==="terminal"?jsx(Terminal,{size:14}):u?.type==="search_results"?jsx(Search,{size:14}):u?.type==="web_operation"?jsx(Globe,{size:14}):jsx(Sparkle,{size:14}):V?jsx(Zap,{size:14}):R?jsx(Wrench,{size:14}):C?jsx(ListTodo,{size:14}):jsx(Sparkle,{size:14}),Ue=d=>d?.subtasks&&d.subtasks.length>=2,de=e?g:r,Fe=Ue(de);return jsxs("div",{ref:f,className:i("max-w-full",p),children:[jsxs("div",{onClick:()=>I(!T),style:{position:"relative",display:"inline-flex",alignItems:"center",gap:6,padding:"4px 6px",overflow:"hidden",borderRadius:8,cursor:"pointer",transition:"opacity 0.2s",...!e&&{opacity:.6}},children:[e&&jsx("div",{style:Me}),jsx("span",{className:i("flex items-center text-gray-500"),children:e?De():jsx(Sparkle,{size:14})}),jsx("span",{className:i("text-sm font-normal text-gray-500 text-[var(--chat-text-subtle)]"),children:Ve()}),e&&parseInt(y)>0&&jsxs("span",{className:"text-gray-500 font-normal tabular-nums text-sm",children:[y,"s"]})]}),T&&jsx("div",{className:"mt-3 animate-fade-in",children:e?we?jsx(Vo,{chunks:a}):he?jsx(Fo,{chunks:a}):Fe&&de?jsx(st,{plan:de,streamingChunks:a}):g?.subtasks?.length===1?jsx(Ce,{events:L}):g?.subtasks?.length===0?null:jsx(Ce,{events:L}):r?r.subtasks?.length===0?null:r.subtasks?.length===1?jsx(Ce,{events:U}):jsx(st,{plan:r,streamingChunks:D}):jsx(Ce,{events:U})})]})}var Xe=forwardRef(({content:e,isStreaming:a=false,renderMarkdown:r=true,className:t,baselineFontSize:n,markdownProps:o},s)=>jsx(m,{ref:s,content:e,isStreaming:a,showCursor:false,className:i("relative",t),children:r?jsx(ne,{baselineFontSize:n,...o,children:e}):jsx("span",{className:"whitespace-pre-wrap",children:e})}));Xe.displayName="StreamingText";var Jo={send_message:jsx(Send,{size:14}),navigate:jsx(Navigation,{size:14}),copy_text:jsx(Copy,{size:14}),compose_email:jsx(Mail,{size:14}),search_emails:jsx(Search,{size:14}),open_modal:jsx(ExternalLink,{size:14}),api_call:jsx(Zap,{size:14})};function Qo(e){return e?Jo[e]||jsx(ArrowRight,{size:14}):jsx(ArrowRight,{size:14})}var gt=forwardRef(({actions:e,onSelect:a,className:r,showIcons:t=true,disabled:n=false},o)=>{let[s,l]=useState(null);if(e.length===0)return null;let c=async(p,b)=>{if(!(!a||s!==null)){l(b);try{await a(p);}finally{l(null);}}};return jsx("div",{ref:o,role:"group","aria-label":"Suggested actions",className:i("flex flex-wrap gap-2",r),children:jsx(AnimatePresence,{children:e.map((p,b)=>{let x=s===b,y=n||s!==null;return jsxs(motion.button,{type:"button",initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.2,delay:b*.05},disabled:y,onClick:()=>c(p,b),className:i("inline-flex items-center gap-1.5","px-3 py-1.5 rounded-lg","text-sm font-medium","border border-gray-200 dark:border-gray-700","bg-white dark:bg-gray-800","text-gray-700 dark:text-gray-300","opacity-80 hover:opacity-100","hover:border-gray-300 dark:hover:border-gray-600","hover:bg-gray-50 dark:hover:bg-gray-750","hover:-translate-y-px","active:translate-y-0","transition-all duration-200","focus:outline-none focus:ring-2 focus:ring-blue-500/20","disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:translate-y-0"),children:[x?jsx(Loader2,{size:14,className:"animate-spin"}):t&&jsx("span",{className:"text-gray-400 dark:text-gray-500",children:Qo(p.type)}),p.label]},p.id)})})})});gt.displayName="SuggestedActions";var us=["#3B82F6","#10B981","#F59E0B","#EF4444","#8B5CF6","#EC4899","#06B6D4","#F97316"];function ht({data:e,config:a,isStreaming:r=false}){let{chartType:t,series:n,xAxis:o,yAxis:s}=e,l=a?.colors||us,c=a?.height||300,p=a?.legend!==false,b=a?.grid!==false,x=a?.tooltip!==false,y=a?.animate!==false&&!r,v=a?.stacked||false,N=(()=>{if(t==="pie")return (n[0]?.data||[]).map((h,u)=>({name:h.name||h.x||`Item ${u+1}`,value:h.value??h.y??0}));let D=new Map;return n.forEach(g=>{g.data.forEach(h=>{let u=h.x??h.name;D.has(u)||D.set(u,{x:u}),D.get(u)[g.name]=h.y??h.value??0;});}),Array.from(D.values())})(),T={data:N,margin:{top:10,right:30,left:0,bottom:0}},I={fontSize:12},L={backgroundColor:"#fff",border:"1px solid #e5e7eb",borderRadius:8};return jsx("div",{className:"w-full",style:{height:c},children:jsx(ResponsiveContainer,{width:"100%",height:"100%",children:(()=>{switch(t){case "line":return jsxs(LineChart,{...T,children:[b&&jsx(CartesianGrid,{strokeDasharray:"3 3",stroke:"#e5e7eb"}),jsx(XAxis,{dataKey:"x",...I,tickLine:false,padding:{left:10,right:10}}),jsx(YAxis,{...I,tickLine:false,width:40}),x&&jsx(Tooltip,{contentStyle:L}),p&&jsx(Legend,{}),n.map((D,g)=>jsx(Line,{type:"monotone",dataKey:D.name,stroke:D.color||l[g%l.length],strokeWidth:2,dot:false,activeDot:{r:4},isAnimationActive:y},D.name))]});case "bar":return jsxs(BarChart,{...T,children:[b&&jsx(CartesianGrid,{strokeDasharray:"3 3",stroke:"#e5e7eb"}),jsx(XAxis,{dataKey:"x",...I,tickLine:false,padding:{left:10,right:10}}),jsx(YAxis,{...I,tickLine:false,width:40}),x&&jsx(Tooltip,{contentStyle:L}),p&&jsx(Legend,{}),n.map((D,g)=>jsx(Bar,{dataKey:D.name,fill:D.color||l[g%l.length],stackId:v?"stack":void 0,isAnimationActive:y,radius:[4,4,0,0]},D.name))]});case "area":return jsxs(AreaChart,{...T,children:[b&&jsx(CartesianGrid,{strokeDasharray:"3 3",stroke:"#e5e7eb"}),jsx(XAxis,{dataKey:"x",...I,tickLine:false,padding:{left:10,right:10}}),jsx(YAxis,{...I,tickLine:false,width:40}),x&&jsx(Tooltip,{contentStyle:L}),p&&jsx(Legend,{}),n.map((D,g)=>jsx(Area,{type:"monotone",dataKey:D.name,stroke:D.color||l[g%l.length],fill:D.color||l[g%l.length],fillOpacity:.3,stackId:v?"stack":void 0,isAnimationActive:y},D.name))]});case "pie":return jsxs(PieChart,{children:[x&&jsx(Tooltip,{contentStyle:L}),p&&jsx(Legend,{}),jsx(Pie,{data:N,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",outerRadius:Math.min(c,300)/3,isAnimationActive:y,label:({name:D,percent:g})=>`${D}: ${((g??0)*100).toFixed(0)}%`,labelLine:false,children:N.map((D,g)=>jsx(Cell,{fill:l[g%l.length]},`cell-${g}`))})]});case "scatter":return jsxs(ScatterChart,{...T,children:[b&&jsx(CartesianGrid,{strokeDasharray:"3 3",stroke:"#e5e7eb"}),jsx(XAxis,{dataKey:"x",type:"number",...I,tickLine:false,name:o?.label,padding:{left:10,right:10}}),jsx(YAxis,{...I,tickLine:false,name:s?.label,width:40}),x&&jsx(Tooltip,{contentStyle:L}),p&&jsx(Legend,{}),n.map((D,g)=>jsx(Scatter,{name:D.name,data:D.data.map(h=>({x:h.x,y:h.y})),fill:D.color||l[g%l.length],isAnimationActive:y},D.name))]});default:return null}})()||jsx(Fragment,{})})})}var vs={active:"bg-green-100 text-green-700",completed:"bg-green-100 text-green-700",success:"bg-green-100 text-green-700",enabled:"bg-green-100 text-green-700",pending:"bg-yellow-100 text-yellow-700",processing:"bg-yellow-100 text-yellow-700",in_progress:"bg-yellow-100 text-yellow-700",failed:"bg-red-100 text-red-700",error:"bg-red-100 text-red-700",disabled:"bg-red-100 text-red-700",inactive:"bg-gray-100 text-gray-700",draft:"bg-gray-100 text-gray-700"};function ws(e,a){if(e==null)return jsx("span",{className:"text-gray-400",children:"-"});switch(a.type||"string"){case "number":return typeof e=="number"?e.toLocaleString():String(e);case "currency":return typeof e=="number"?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format(e):String(e);case "date":try{return new Date(e).toLocaleDateString()}catch{return String(e)}case "badge":{let t=String(e).toLowerCase().replace(/\s+/g,"_"),n=vs[t]||"bg-gray-100 text-gray-700";return jsx("span",{className:i("inline-block px-2 py-0.5 rounded-full text-xs font-medium",n),children:String(e)})}case "link":return jsx("a",{href:String(e),target:"_blank",rel:"noopener noreferrer",className:"text-blue-500 hover:underline",children:String(e)});case "boolean":return e?jsx(Check,{size:18,className:"text-green-500"}):jsx(X,{size:18,className:"text-gray-400"});case "progress":{let t=typeof e=="number"?e:parseFloat(String(e));return jsxs("div",{className:"flex items-center gap-2",children:[jsx("div",{className:"flex-1 h-2 bg-gray-200 dark:bg-gray-700 rounded-full overflow-hidden",children:jsx("div",{className:"h-full bg-blue-500 rounded-full",style:{width:`${Math.min(100,Math.max(0,t))}%`}})}),jsxs("span",{className:"text-xs text-gray-500",children:[t.toFixed(0),"%"]})]})}default:return String(e)}}function Fa(e,a,r){let t=e[r],n=a[r];return t==null?1:n==null?-1:typeof t=="number"&&typeof n=="number"?n-t:String(n).localeCompare(String(t))}function yt({data:e,config:a}){let{columns:r,rows:t}=e,n=a?.sortable!==false,o=a?.paginated||false,s=a?.pageSize||10,[l,c]=useState("asc"),[p,b]=useState(r[0]?.key||""),[x,y]=useState(0),v=T=>{c(p===T&&l==="asc"?"desc":"asc"),b(T);},f=useMemo(()=>{let T=[...t];return n&&p&&T.sort((I,L)=>l==="desc"?Fa(I,L,p):-Fa(I,L,p)),o&&(T=T.slice(x*s,(x+1)*s)),T},[t,l,p,x,s,n,o]),N=Math.ceil(t.length/s);return jsxs("div",{className:"w-full overflow-x-auto",children:[jsxs("table",{className:"min-w-full text-sm",children:[jsx("thead",{children:jsx("tr",{children:r.map(T=>jsx("th",{className:i("px-3 py-2 font-semibold bg-gray-50 dark:bg-gray-800 whitespace-nowrap text-left",n&&"cursor-pointer select-none hover:bg-gray-100 dark:hover:bg-gray-700"),style:{width:T.width,textAlign:T.align||"left"},onClick:()=>n&&v(T.key),children:jsxs("span",{className:"inline-flex items-center gap-1",children:[T.label,n&&p===T.key&&(l==="asc"?jsx(ChevronUp,{size:14}):jsx(ChevronDown,{size:14}))]})},T.key))})}),jsxs("tbody",{children:[f.map((T,I)=>jsx("tr",{className:"border-t border-gray-100 dark:border-gray-800 hover:bg-gray-50 dark:hover:bg-gray-800/50",children:r.map(L=>jsx("td",{className:"px-3 py-2 whitespace-nowrap max-w-[300px] overflow-hidden text-ellipsis",style:{textAlign:L.align||"left"},children:ws(T[L.key],L)},L.key))},I)),f.length===0&&jsx("tr",{children:jsx("td",{colSpan:r.length,className:"px-3 py-8 text-center text-gray-400",children:"No data available"})})]})]}),o&&t.length>s&&jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-t border-gray-200 dark:border-gray-700 text-sm",children:[jsxs("span",{className:"text-gray-500",children:[x*s+1,"-",Math.min((x+1)*s,t.length)," of ",t.length]}),jsxs("div",{className:"flex gap-1",children:[jsx("button",{onClick:()=>y(Math.max(0,x-1)),disabled:x===0,className:"px-2 py-1 rounded hover:bg-gray-100 dark:hover:bg-gray-800 disabled:opacity-30",children:"Prev"}),jsx("button",{onClick:()=>y(Math.min(N-1,x+1)),disabled:x>=N-1,className:"px-2 py-1 rounded hover:bg-gray-100 dark:hover:bg-gray-800 disabled:opacity-30",children:"Next"})]})]})]})}function vt({data:e,config:a,onAction:r}){let{subtitle:t,imageUrl:n,sections:o,actions:s}=e,l=a?.collapsible||false,c=a?.initiallyCollapsed||false,[p,b]=useState(!c),x=f=>{f.startsWith("http://")||f.startsWith("https://")||f.startsWith("/")?window.open(f,"_blank","noopener,noreferrer"):r?r({type:"card_action",action:f}):window.dispatchEvent(new CustomEvent("visualization-action",{detail:{action:f}}));},y=(f,N)=>jsxs("div",{className:i(N<o.length-1&&"mb-4"),children:[f.title&&jsx("h4",{className:"font-semibold text-sm mb-2",children:f.title}),f.items&&f.items.length>0&&jsx("div",{className:"space-y-1",children:f.items.map((T,I)=>jsxs("div",{className:"flex justify-between items-start gap-4",children:[jsx("span",{className:"text-sm text-gray-500 shrink-0",children:T.label}),jsx("span",{className:"text-sm font-medium text-right",children:T.value})]},I))}),f.content&&jsx(ne,{children:f.content})]},N),v=jsxs(Fragment,{children:[n&&jsx("img",{src:n,alt:"",className:"w-full h-[140px] object-cover border-b border-gray-200 dark:border-gray-700"}),t&&jsx("p",{className:"text-sm text-gray-500 italic mb-4",children:t}),o.map((f,N)=>jsxs("div",{children:[y(f,N),N<o.length-1&&jsx("hr",{className:"my-4 border-gray-200 dark:border-gray-700"})]},N))]});return jsxs("div",{className:"w-full",children:[l&&jsxs("div",{className:"flex items-center justify-between mb-2 cursor-pointer",onClick:()=>b(!p),children:[jsx("span",{className:"text-sm text-gray-500",children:p?"Click to collapse":"Click to expand"}),jsx("button",{className:"p-1",children:p?jsx(ChevronUp,{size:18}):jsx(ChevronDown,{size:18})})]}),(!l||p)&&v,s&&s.length>0&&jsx("div",{className:"flex gap-2 mt-4 pt-4 border-t border-gray-200 dark:border-gray-700",children:s.map((f,N)=>jsxs("button",{onClick:()=>x(f.action),className:i("px-3 py-1.5 text-sm rounded-lg transition-colors",f.variant==="primary"?"bg-blue-500 text-white hover:bg-blue-600":f.variant==="text"?"text-blue-500 hover:bg-blue-50":"border border-gray-300 hover:bg-gray-50"),children:[f.label,f.action.startsWith("http")&&jsx(ExternalLink,{size:14,className:"inline ml-1"})]},N))})]})}var As=["#3B82F6","#10B981","#F59E0B","#8B5CF6"];function Ls({metric:e,color:a,animate:r}){let t=e.trend==="up"?jsx(ArrowUp,{size:16,className:"text-green-500"}):e.trend==="down"?jsx(ChevronDown,{size:16,className:"text-red-500"}):e.trend==="neutral"?jsx(Circle,{size:14,className:"text-gray-400"}):null,n=e.trend==="up"?"text-green-500":e.trend==="down"?"text-red-500":"text-gray-500",o=e.sparkline?.map((s,l)=>({value:s,idx:l}));return jsxs("div",{className:"p-4 rounded-lg border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-900 relative overflow-hidden",children:[o&&o.length>0&&jsx("div",{className:"absolute bottom-0 left-0 right-0 h-10 opacity-30",children:jsx(ResponsiveContainer,{width:"100%",height:"100%",children:jsx(AreaChart,{data:o,margin:{top:0,right:0,left:0,bottom:0},children:jsx(Area,{type:"monotone",dataKey:"value",stroke:e.color||a,fill:e.color||a,strokeWidth:1,isAnimationActive:r})})})}),jsxs("div",{className:"relative z-10",children:[jsx("span",{className:"text-xs text-gray-500 font-medium uppercase tracking-wider",children:e.label}),jsxs("div",{className:"flex items-baseline gap-1 mt-1",children:[jsx("span",{className:"text-2xl font-bold",children:e.value}),e.unit&&jsx("span",{className:"text-sm text-gray-500",children:e.unit})]}),(e.trend||e.change)&&jsxs("div",{className:"flex items-center gap-1 mt-2",children:[t,e.change&&jsx("span",{className:i("text-sm font-medium",n),children:e.change}),e.changeLabel&&jsx("span",{className:"text-xs text-gray-500",children:e.changeLabel})]})]})]})}function kt({data:e,config:a,isStreaming:r=false}){let{metrics:t,layout:n="row"}=e,o=a?.colors||As,s=a?.animate!==false&&!r,l=n==="grid";return jsx("div",{className:i("w-full",l?"grid grid-cols-1 sm:grid-cols-2 gap-4":"flex gap-4 flex-wrap"),children:t.map((c,p)=>jsx("div",{className:i(!l&&"flex-1 min-w-[200px]"),children:jsx(Ls,{metric:c,color:c.color||o[p%o.length],animate:s})},p))})}var Ws={js:"javascript",ts:"typescript",jsx:"jsx",tsx:"tsx",py:"python",rb:"ruby",rs:"rust",go:"go",java:"java",cpp:"cpp",c:"c",cs:"csharp",sh:"bash",bash:"bash",sql:"sql",html:"html",css:"css",json:"json",yaml:"yaml",yml:"yaml",xml:"xml",md:"markdown",graphql:"graphql"};function Nt({data:e}){let{code:a,language:r,lineNumbers:t=true,highlightLines:n=[],startLine:o=1}=e,[s,l]=useState(false),c=Ws[r.toLowerCase()]||r.toLowerCase(),p=async()=>{try{await navigator.clipboard.writeText(a),l(!0);}catch{}};return useEffect(()=>{if(s){let x=setTimeout(()=>l(false),2e3);return ()=>clearTimeout(x)}},[s]),jsxs("div",{className:"relative rounded-lg overflow-hidden border border-gray-200 dark:border-gray-700",children:[jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 bg-gray-800 dark:bg-gray-900 border-b border-gray-700",children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx(FileText,{size:16,className:"text-gray-400"}),jsx("span",{className:"text-xs font-mono text-gray-400 lowercase",children:c})]}),jsx("button",{onClick:p,className:"flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-white/10 transition-colors text-gray-400 hover:text-gray-200",title:s?"Copied!":"Copy code",children:s?jsx(Check,{size:14,className:"text-green-400"}):jsx(Copy,{size:14})})]}),jsx(Prism,{language:c,style:oneDark,showLineNumbers:t,startingLineNumber:o,wrapLines:true,lineProps:x=>{let y={};return n.includes(x)&&(y.backgroundColor="rgba(59, 130, 246, 0.1)",y.display="block",y.borderLeft="3px solid #3B82F6",y.paddingLeft="8px",y.marginLeft="-11px"),{style:y}},customStyle:{margin:0,borderRadius:0,fontSize:"0.8125rem",lineHeight:"1.6",background:"#1e1e1e"},codeTagProps:{style:{fontFamily:"'Fira Code', 'JetBrains Mono', monospace"}},children:a.trim()})]})}function Ct({data:e,config:a,isStreaming:r=false,onAction:t}){let{fields:n,submitAction:o}=e,s=a?.submitButtonText||"Submit",l=a?.cancelButtonText||"Cancel",[c,p]=useState(()=>{let g={};return n.forEach(h=>{h.defaultValue!==void 0?g[h.name]=h.defaultValue:h.type==="multiselect"?g[h.name]=[]:h.type==="checkbox"?g[h.name]=false:g[h.name]="";}),g}),[b,x]=useState({}),[y,v]=useState(false),f=(g,h)=>{p(u=>({...u,[g]:h})),b[g]&&x(u=>{let R={...u};return delete R[g],R});},N=()=>{let g={};return n.forEach(h=>{let u=c[h.name];if(h.required&&(u==null||u===""||Array.isArray(u)&&u.length===0)){g[h.name]=`${h.label} is required`;return}if(!(!u&&!h.required)){if(h.validation){let{min:R,max:C,pattern:V,message:G}=h.validation;R!==void 0&&typeof u=="number"&&u<R&&(g[h.name]=G||`Minimum value is ${R}`),C!==void 0&&typeof u=="number"&&u>C&&(g[h.name]=G||`Maximum value is ${C}`),V&&typeof u=="string"&&!new RegExp(V).test(u)&&(g[h.name]=G||"Invalid format");}h.type==="email"&&typeof u=="string"&&u&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(u)&&(g[h.name]="Invalid email address");}}),x(g),Object.keys(g).length===0},T=g=>{g.preventDefault(),N()&&(t?t({type:"form_submit",action:o||"",data:c}):window.dispatchEvent(new CustomEvent("visualization-form-submit",{detail:{action:o,data:c}})),v(true));},I=()=>{t?t({type:"form_cancel",action:o||""}):window.dispatchEvent(new CustomEvent("visualization-form-cancel",{detail:{action:o}}));};if(y)return jsxs("div",{className:"text-center py-8",children:[jsx("p",{className:"text-lg font-semibold text-green-500 mb-1",children:"Form Submitted"}),jsx("p",{className:"text-sm text-gray-500",children:"Your response has been recorded."})]});let L="w-full px-3 py-2 text-sm rounded-lg border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-900 focus:ring-2 focus:ring-blue-500/20 focus:border-blue-500 outline-none transition-colors",U="border-red-500 focus:ring-red-500/20 focus:border-red-500",D=g=>{let h=c[g.name],R=!!b[g.name];switch(g.type){case "text":case "email":case "number":return jsx("input",{type:g.type,placeholder:g.placeholder,required:g.required,value:String(h||""),onChange:C=>f(g.name,g.type==="number"?parseFloat(C.target.value)||"":C.target.value),className:i(L,R&&U),min:g.validation?.min,max:g.validation?.max});case "textarea":return jsx("textarea",{placeholder:g.placeholder,required:g.required,value:String(h||""),onChange:C=>f(g.name,C.target.value),className:i(L,"min-h-[100px] resize-y",R&&U),rows:4});case "select":return jsxs("select",{value:String(h||""),onChange:C=>f(g.name,C.target.value),className:i(L,R&&U),children:[jsx("option",{value:"",disabled:true,children:g.placeholder||"Select an option"}),g.options?.map(C=>jsx("option",{value:C.value,children:C.label},C.value))]});case "multiselect":return jsx("select",{multiple:true,value:h||[],onChange:C=>f(g.name,Array.from(C.target.selectedOptions,V=>V.value)),className:i(L,"min-h-[80px]",R&&U),children:g.options?.map(C=>jsx("option",{value:C.value,children:C.label},C.value))});case "checkbox":return jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[jsx("input",{type:"checkbox",checked:!!h,onChange:C=>f(g.name,C.target.checked),className:"w-4 h-4 accent-blue-500 rounded"}),jsx("span",{className:"text-sm",children:g.label})]});case "radio":return jsx("div",{className:"space-y-1",children:g.options?.map(C=>jsxs("label",{className:"flex items-center gap-2 cursor-pointer text-sm",children:[jsx("input",{type:"radio",name:g.name,value:C.value,checked:h===C.value,onChange:V=>f(g.name,V.target.value),className:"w-3.5 h-3.5 accent-blue-500"}),C.label]},C.value))});case "date":return jsx("input",{type:"date",value:String(h||""),onChange:C=>f(g.name,C.target.value),className:i(L,R&&U)});case "datetime":return jsx("input",{type:"datetime-local",value:String(h||""),onChange:C=>f(g.name,C.target.value),className:i(L,R&&U)});default:return null}};return jsxs("form",{onSubmit:T,className:"space-y-4",children:[n.map(g=>jsxs("div",{children:[g.type!=="checkbox"&&jsxs("label",{className:"block text-sm font-medium mb-1",children:[g.label,g.required&&jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]}),D(g),b[g.name]&&jsx("p",{className:"text-xs text-red-500 mt-1",children:b[g.name]})]},g.name)),jsxs("div",{className:"flex gap-2 pt-2",children:[jsx("button",{type:"submit",disabled:r,className:"px-4 py-2 text-sm rounded-lg bg-blue-500 text-white hover:bg-blue-600 disabled:opacity-50 transition-colors",children:s}),jsx("button",{type:"button",onClick:I,className:"px-4 py-2 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors",children:l})]})]})}var St=new Map;function Pe(e,a){St.set(e,a);}function zt(e){return St.get(e)}function Ba(){return Array.from(St.keys())}Pe("chart",{component:ht});Pe("table",{component:yt});Pe("card",{component:vt});Pe("kpi",{component:kt});Pe("code_preview",{component:Nt});Pe("form",{component:Ct});function $a(e){for(let[a,r]of Object.entries(e)){let t=St.get(a);t&&(t.schema=r);}}var js=z.object({name:z.string(),data:z.array(z.union([z.object({x:z.union([z.string(),z.number()]),y:z.number()}),z.object({name:z.string(),value:z.number()})])),color:z.string().optional()}),Oa=z.object({label:z.string().optional(),type:z.enum(["category","number","time"]).optional(),min:z.number().optional(),max:z.number().optional()}),Gt=z.object({chartType:z.enum(["line","bar","pie","area","scatter","composed"]),series:z.array(js),xAxis:Oa.optional(),yAxis:Oa.optional()}),Hs=z.object({key:z.string(),label:z.string(),type:z.enum(["string","number","currency","date","badge","link","boolean","progress"]).optional(),align:z.enum(["left","center","right"]).optional(),width:z.string().optional()}),Xt=z.object({columns:z.array(Hs),rows:z.array(z.record(z.string(),z.unknown()))}),Us=z.object({title:z.string().optional(),items:z.array(z.object({label:z.string(),value:z.union([z.string(),z.number()])})).optional(),content:z.string().optional()}),Ks=z.object({label:z.string(),action:z.string(),variant:z.enum(["primary","secondary","text"]).optional()}),Zt=z.object({subtitle:z.string().optional(),imageUrl:z.string().optional(),sections:z.array(Us),actions:z.array(Ks).optional()}),qs=z.object({label:z.string(),value:z.union([z.string(),z.number()]),unit:z.string().optional(),trend:z.enum(["up","down","neutral"]).optional(),change:z.string().optional(),changeLabel:z.string().optional(),sparkline:z.array(z.number()).optional(),color:z.string().optional()}),Yt=z.object({metrics:z.array(qs),layout:z.enum(["row","grid"]).optional()}),Jt=z.object({code:z.string(),language:z.string(),lineNumbers:z.boolean().optional(),highlightLines:z.array(z.number()).optional(),startLine:z.number().optional()}),Gs=z.object({name:z.string(),type:z.enum(["text","number","email","select","multiselect","checkbox","radio","textarea","date","datetime"]),label:z.string(),required:z.boolean().optional(),placeholder:z.string().optional(),options:z.array(z.object({value:z.string(),label:z.string()})).optional(),defaultValue:z.unknown().optional(),validation:z.object({min:z.number().optional(),max:z.number().optional(),pattern:z.string().optional(),message:z.string().optional()}).optional()}),Qt=z.object({fields:z.array(Gs),submitAction:z.string().optional()});$a({chart:Gt,table:Xt,card:Zt,kpi:Yt,code_preview:Jt,form:Qt});function Pt({data:e,isStreaming:a=false,onAction:r}){let{type:t,title:n,description:o,data:s,config:l}=e;return jsxs("div",{className:"my-3 overflow-hidden",children:[(n||o)&&jsxs("div",{className:"mb-2",children:[n&&jsx("p",{className:"text-sm font-semibold",children:n}),o&&jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:o})]}),jsx("div",{children:(()=>{let p=zt(t);if(!p)return jsxs("div",{className:"flex items-center gap-2 p-4 text-yellow-500",children:[jsx(AlertCircle,{size:20}),jsxs("span",{className:"text-sm",children:["Unknown visualization type: ",t]})]});if(p.schema){let x=p.schema.safeParse(s);if(!x.success){let y=x.error.issues.slice(0,3);return jsxs("div",{className:"p-4 rounded-lg border border-red-200 dark:border-red-800 bg-red-50 dark:bg-red-950/30",children:[jsxs("div",{className:"flex items-center gap-2 text-red-600 dark:text-red-400 mb-2",children:[jsx(AlertCircle,{size:18}),jsxs("span",{className:"text-sm font-medium",children:["Invalid ",t," visualization data"]})]}),jsxs("ul",{className:"text-xs text-red-500 dark:text-red-400 space-y-1 list-disc list-inside",children:[y.map((v,f)=>jsxs("li",{children:[v.path.join("."),": ",v.message]},f)),x.error.issues.length>3&&jsxs("li",{children:["...and ",x.error.issues.length-3," more"]})]})]})}}let b=p.component;return jsx(b,{data:s,config:l,isStreaming:a,onAction:r})})()})]})}var Ha=/\[VIZ:([a-f0-9-]+)\]/gi;function Qs(e){let a=[],r=0,t;for(Ha.lastIndex=0;(t=Ha.exec(e))!==null;){if(t.index>r){let n=e.slice(r,t.index);n.trim()&&a.push({type:"text",content:n});}a.push({type:"viz",id:t[1]}),r=t.index+t[0].length;}if(r<e.length){let n=e.slice(r);n.trim()&&a.push({type:"text",content:n});}return a}var Ua=forwardRef(({message:e,viewerRole:a$1="user",className:r,showAvatar:t=true,showTimestamp:n=true,renderMarkdown:o=true,reasoning:s,executionPlan:l,executionTimeline:c$1,suggestedActions:p,onSuggestedAction:b,reasoningExpanded:x,onReasoningExpandedChange:y,citations:v,visualizations:f,baselineFontSize:N,executionTime:T,pendingClarification:I,onClarificationSubmit:L},U)=>{let g=useContext(a)?.onVisualizationAction,h=(e.participant?.role||"").toLowerCase(),u=(a$1||"").toLowerCase(),R=h===u,C=h==="assistant",V=e.isStreaming,G=s?.filter(k=>k.type==="thinking"||k.type==="tool"||k.type==="observation"||k.type==="planning"||k.type==="subtask"||k.type==="wave_start"||k.type==="wave_complete"||k.type==="parallel_subtask_start"||k.type==="parallel_subtask_complete"||k.type==="multi_agent_planning"||k.type==="subagent_start"||k.type==="subagent_complete"||k.type==="subagent_failed"||k.type==="synthesis"||k.type==="claude_thinking"||k.type==="subagent"||k.type==="file_operation"||k.type==="terminal"||k.type==="search_results"||k.type==="web_operation"||k.claudeToolData!=null),he=G&&G.length>0,we=!V&&(l||c$1&&c$1.length>0),ke=he||we,Ve=V&&!e.textContent&&!ke,De=e.attachments,Ue=De&&De.length>0,de=useMemo(()=>{if(!f||f.length===0)return null;let k=new Map;return f.forEach(S=>k.set(S.id,S)),k},[f]),Fe=de&&de.size>0,d$1=useMemo(()=>!Fe||!e.textContent?null:Qs(e.textContent),[Fe,e.textContent]),w=()=>e.textContent?d$1&&d$1.length>0&&de?jsx(Fragment,{children:d$1.map((k,S)=>{if(k.type==="text")return V?jsx(Xe,{content:k.content,isStreaming:true,baselineFontSize:N},S):jsx(ne,{baselineFontSize:N,className:R?"prose-invert":"",children:k.content},S);let Y=de.get(k.id);return Y?jsx(Pt,{data:Y,isStreaming:V,onAction:g},`viz-${k.id}`):null})}):V&&o?jsx(Xe,{content:e.textContent,isStreaming:true,baselineFontSize:N,className:R?"prose-invert":""}):o?jsx(ne,{baselineFontSize:N,className:R?"prose-invert":"",children:e.textContent}):jsx("p",{className:"whitespace-pre-wrap",children:e.textContent}):null,P=useRef(V);V&&(P.current=true);let _=!V&&!P.current;return jsx(c,{ref:U,message:e,viewerRole:a$1,className:i("w-full",_&&"animate-message-in",r),children:jsxs("div",{className:i("flex flex-col gap-1 w-full"),"data-is-viewer":R,children:[Ve&&jsxs("div",{className:i("flex items-start gap-2 w-full"),children:[t&&!R&&jsx("div",{className:"flex-shrink-0",children:jsx(Be,{name:e.participant?.name,src:e.participant?.avatarUrl,role:e.participant?.role,className:"w-10 h-10 flex-shrink-0"})}),jsx("div",{className:"px-4 py-3",children:jsx(Ke,{size:"small"})})]}),ke&&C&&jsx("div",{className:"w-full max-w-[80%]",children:jsx(jt,{isStreaming:V,chunks:G,plan:l,executionTimeline:c$1,userMessageTimestamp:e.createdAt?new Date((typeof e.createdAt=="string",e.createdAt)).getTime()/1e3:void 0,executionTime:T,expanded:x,onExpandedChange:y})}),e.textContent&&jsxs("div",{className:i("group flex items-start gap-2 w-full",R?"flex-row-reverse":"flex-row"),children:[t&&!R&&jsx("div",{className:"flex-shrink-0",children:jsx(Be,{name:e.participant?.name,src:e.participant?.avatarUrl,role:e.participant?.role,className:"w-10 h-10 flex-shrink-0"})}),jsxs("div",{className:i("max-w-[85%]","flex flex-col"),"data-message-role":R?"viewer":"other",children:[jsxs("div",{className:i("rounded-2xl",R||t?"px-4 py-3":""),style:{backgroundColor:R?"var(--chat-user-message-bg)":"transparent",color:R?"var(--chat-user-message-text, #ffffff)":"var(--chat-text)"},children:[jsx(d,{children:w()}),v&&v.length>0&&jsx("div",{className:"mt-2 pt-2 border-t border-[var(--chat-border)]",children:jsx(It,{sources:v})})]}),Ue&&jsx("div",{className:"mt-2",children:jsx(Bt,{attachments:De})}),!V&&(n&&e.createdAt||C&&e.textContent)&&jsxs("div",{className:i("flex items-center gap-2 mt-1",R&&"flex-row-reverse"),children:[n&&e.createdAt&&jsx(ei,{createdAt:typeof e.createdAt=="string"?e.createdAt:e.createdAt.toISOString(),isViewer:R}),C&&e.textContent&&jsx(Vt,{textContent:e.textContent})]})]})]}),e.error&&jsxs("div",{className:i("flex items-start gap-2 w-full max-w-[85%]","rounded-lg border px-3 py-2 mt-1"),style:{borderColor:"var(--chat-error, #B1001B)",backgroundColor:"color-mix(in srgb, var(--chat-error, #B1001B) 6%, transparent)",color:"var(--chat-error, #B1001B)"},children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"flex-shrink-0 mt-0.5",children:[jsx("path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z"}),jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}),jsx("span",{className:"text-sm",children:e.error.message})]}),!e.textContent&&t&&!R&&ke&&!Ve&&jsx("div",{className:"flex items-start gap-2 w-full",children:jsx("div",{className:"flex-shrink-0",children:jsx(Be,{name:e.participant?.name,src:e.participant?.avatarUrl,role:e.participant?.role,className:"w-10 h-10 flex-shrink-0"})})}),I&&!V&&L&&jsx("div",{className:"w-full max-w-[80%]",children:jsx(_t,{clarification:I,onSubmit:L})}),p&&p.length>0&&!V&&jsx("div",{className:"w-full max-w-[80%]",children:jsx(gt,{actions:p,onSelect:b})})]})})});Ua.displayName="Message";function ei({createdAt:e}){return jsx("span",{className:"text-xs text-[var(--chat-text-subtle)]",children:(r=>{try{return new Date(r).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}catch{return ""}})(e)})}var pi=100*1024*1024,di=["image/jpeg","image/jpg","image/png","image/gif","image/webp","image/svg+xml","image/bmp"],mi=["application/pdf","text/plain","text/csv","text/markdown","application/json","text/json","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],ui=["video/mp4","video/webm","video/ogg","video/avi","video/mov","video/wmv","video/flv","video/mkv"],gi=[...di,...mi,...ui];function qa(e){if(e===0)return "0 Bytes";let a=1024,r=["Bytes","KB","MB","GB"],t=Math.floor(Math.log(e)/Math.log(a));return parseFloat((e/Math.pow(a,t)).toFixed(2))+" "+r[t]}function fi(e,a,r){return e.size>r?`File size (${qa(e.size)}) exceeds max (${qa(r)})`:a.includes(e.type)?null:`File type ${e.type||"unknown"} is not allowed`}function bi({attachments:e,onRemove:a,disabled:r}){return e.length===0?null:jsx("div",{className:"flex flex-wrap gap-2 px-3 pt-3 pb-0",children:e.map(t=>{let n=t.file.type.startsWith("image/"),o=t.status==="error",s=t.status==="uploading";return jsxs("div",{className:i("relative flex items-center gap-1.5 px-2 py-1.5 rounded-lg text-xs max-w-[200px]",o?"bg-red-50 dark:bg-red-900/30 text-red-600 dark:text-red-400":"bg-gray-100 dark:bg-zinc-700 text-gray-600 dark:text-zinc-300"),children:[s?jsx(Loader2,{size:14,className:"flex-shrink-0 animate-spin"}):o?jsx(AlertCircle,{size:14,className:"flex-shrink-0"}):n&&t.previewUrl?jsx("img",{src:t.previewUrl,alt:t.file.name,className:"w-5 h-5 rounded object-cover"}):n?jsx(Image,{size:14,className:"flex-shrink-0"}):jsx(FileText,{size:14,className:"flex-shrink-0"}),jsx("span",{className:"truncate",title:o?t.error:t.file.name,children:o?t.error:t.file.name}),!r&&jsx("button",{type:"button",onClick:()=>a(t.id),className:"flex-shrink-0 ml-0.5 p-0.5 rounded-full hover:bg-gray-200 dark:hover:bg-zinc-600 transition-colors",children:jsx(X,{size:12})})]},t.id)})})}var Xa=forwardRef(({onSubmit:e,onAttach:a,onUploadFile:r,onRemoveUploadedAttachment:t,disabled:n=false,supportsAttachments:o=true,allowedFileTypes:s=gi,maxFileSize:l=pi,placeholder:c="Type a message...",className:p,isSubmitting:b=false},x)=>{let[y,v]=useState(""),[f,N]=useState([]),[T,I]=useState(false),L=useRef(null),U=useRef(null),D=useRef(0),g=n||b,h=f.some(d=>d.status==="uploading"),u=f.filter(d=>d.status==="uploaded"&&d.attachmentId).map(d=>d.attachmentId),R=u.length>0||f.some(d=>d.status==="pending"),C=y.trim().length>0||R,V=useCallback(()=>{let d=U.current;d&&(d.style.height="auto",d.style.height=Math.min(d.scrollHeight,200)+"px");},[]);useEffect(()=>{V();},[y,V]);let G=useCallback(async d=>{let w=d.map(P=>{let _=fi(P,s,l),k={id:`${Date.now()}-${Math.random().toString(36).slice(2,9)}`,file:P,status:_?"error":r?"uploading":"pending",error:_||void 0};return !_&&P.type.startsWith("image/")&&(k.previewUrl=URL.createObjectURL(P)),k});if(N(P=>[...P,...w]),a?.(d),r){for(let P of w)if(P.status==="uploading")try{let _=await r(P.file);N(k=>k.map(S=>S.id===P.id?{...S,status:"uploaded",attachmentId:_}:S));}catch(_){N(k=>k.map(S=>S.id===P.id?{...S,status:"error",error:_ instanceof Error?_.message:"Upload failed"}:S));}}},[s,l,r,a]),he=useCallback(async()=>{if(!C||g||h)return;let d=y,w=f.filter(_=>_.status!=="error").map(_=>_.file),P=f;v(""),N([]);try{r&&u.length>0?await e(d,void 0,u):await e(d,w.length>0?w:void 0);}catch{v(d),N(P);}},[y,f,C,g,h,e,r,u]),we=useCallback(d=>{d.key==="Enter"&&!d.shiftKey&&(d.preventDefault(),!g&&!h&&he());},[he,g,h]),ke=useCallback(d=>{let w=d.target.files;!w||w.length===0||(G(Array.from(w)),d.target.value="");},[G]),Ve=useCallback(d=>{N(w=>{let P=w.find(_=>_.id===d);return P?.previewUrl&&URL.revokeObjectURL(P.previewUrl),P?.attachmentId&&t&&t(P.attachmentId),w.filter(_=>_.id!==d)});},[t]),De=useCallback(d=>{d.preventDefault(),d.stopPropagation(),!(!o||b)&&(D.current++,d.dataTransfer.types.includes("Files")&&I(true));},[o,b]),Ue=useCallback(d=>{d.preventDefault(),d.stopPropagation(),D.current--,D.current===0&&I(false);},[]),de=useCallback(d=>{d.preventDefault(),d.stopPropagation();},[]),Fe=useCallback(d=>{if(d.preventDefault(),d.stopPropagation(),D.current=0,I(false),!o||b)return;let w=Array.from(d.dataTransfer.files);w.length>0&&G(w);},[o,b,G]);return useEffect(()=>()=>{f.forEach(d=>{d.previewUrl&&URL.revokeObjectURL(d.previewUrl);});},[]),jsx("div",{ref:x,className:i("flex-shrink-0 px-3 pt-2 pb-3","border-t border-gray-200 dark:border-zinc-700","bg-white/95 dark:bg-zinc-900/95 backdrop-blur-sm",p),onDragEnter:De,onDragLeave:Ue,onDragOver:de,onDrop:Fe,children:jsxs("div",{className:i("mx-auto max-w-[900px]","rounded-xl","bg-white dark:bg-zinc-800","border border-gray-200 dark:border-zinc-700","shadow-sm","transition-all duration-200","focus-within:shadow-md focus-within:border-gray-300 dark:focus-within:border-zinc-600",T&&"ring-2 ring-blue-400 border-blue-400"),children:[T&&jsx("div",{className:"px-3 pt-3 pb-0",children:jsx("div",{className:"flex items-center justify-center py-4 rounded-lg border-2 border-dashed border-blue-300 bg-blue-50 dark:bg-blue-900/20 text-blue-500 text-sm",children:"Drop files here"})}),jsx(bi,{attachments:f,onRemove:Ve,disabled:b}),jsxs("div",{className:i("flex items-center gap-2 p-3",f.length>0&&"pt-1.5"),children:[o&&jsx("button",{type:"button",onClick:()=>L.current?.click(),disabled:b,className:i("flex-shrink-0","w-8 h-8 rounded-lg","flex items-center justify-center","border border-gray-200 dark:border-zinc-600","text-gray-500 dark:text-zinc-400","hover:bg-gray-50 dark:hover:bg-zinc-700","disabled:opacity-40 disabled:cursor-not-allowed","transition-colors"),children:jsx(Paperclip,{size:16})}),jsx("div",{className:"flex-1 min-w-0 flex items-center",children:jsx("textarea",{ref:U,value:y,onChange:d=>v(d.target.value),onKeyDown:we,disabled:g,placeholder:c,rows:1,className:i("w-full resize-none outline-none","p-0 border-0 shadow-none","min-h-[24px] max-h-[200px]","text-sm leading-relaxed","text-gray-900 dark:text-zinc-100","placeholder:text-gray-400 dark:placeholder:text-zinc-500","bg-transparent","disabled:opacity-50 disabled:cursor-not-allowed")})}),jsx("button",{type:"button",onClick:he,disabled:!C||g||h,className:i("flex-shrink-0","w-9 h-9 rounded-lg","flex items-center justify-center","bg-blue-500 text-white","shadow-sm","hover:bg-blue-600 hover:shadow-md hover:-translate-y-px","active:translate-y-0 active:shadow-sm","disabled:bg-gray-300 dark:disabled:bg-zinc-600 disabled:shadow-none disabled:translate-y-0 disabled:cursor-not-allowed","transition-all duration-200"),children:b||h?jsx(Loader2,{size:16,className:"animate-spin"}):jsx(ArrowUp,{size:16})})]}),o&&jsx("input",{ref:L,type:"file",multiple:true,accept:s.join(","),onChange:ke,className:"hidden"})]})})});Xa.displayName="MessageComposer";function na({isAtBottom:e,onScrollToBottom:a,className:r}){return jsx("button",{type:"button",onClick:a,"aria-label":"Scroll to bottom",className:i("absolute bottom-4 left-1/2 -translate-x-1/2 z-10","flex items-center justify-center","w-8 h-8 rounded-full","bg-[var(--chat-bg,#ffffff)] border border-[var(--chat-border)]","shadow-subtle hover:shadow-button-hover","text-[var(--chat-text-subtle)] hover:text-[var(--chat-text)]","transition-all duration-200",e?"opacity-0 pointer-events-none translate-y-2":"opacity-100 translate-y-0",r),children:jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M12 5v14"}),jsx("path",{d:"m19 12-7 7-7-7"})]})})}var Ya=forwardRef(({children:e,autoScroll:a=true,showScrollToBottom:r=true,className:t},n)=>{let{containerRef:o,scrollToBottom:s,isAtBottom:l}=a$1({enabled:a});return jsxs("div",{className:"relative flex-1 overflow-hidden",children:[jsx("div",{ref:p=>{o.current=p,typeof n=="function"?n(p):n&&(n.current=p);},className:i("h-full overflow-y-auto","flex flex-col gap-4 p-4","chat-scrollbar",t),children:e}),r&&jsx(na,{isAtBottom:l,onScrollToBottom:()=>s("smooth")})]})});Ya.displayName="MessageList";function vi({label:e,className:a}){return jsxs("div",{className:`flex items-center gap-3 py-6 select-none ${a??""}`,role:"separator",children:[jsx("div",{className:"flex-1 h-px bg-[var(--chat-border)]"}),jsx("span",{className:"text-xs font-medium text-[var(--chat-text-subtle)] whitespace-nowrap",children:e}),jsx("div",{className:"flex-1 h-px bg-[var(--chat-border)]"})]})}var Qa=forwardRef(({className:e},a)=>jsx(r,{ref:a,className:i("inline-flex items-center gap-1","px-4 py-3",e),children:jsx(Ke,{size:"small"})}));Qa.displayName="TypingIndicator";function Pi({title:e,subtitle:a,logo:r,actions:t,showClose:n,onClose:o,loading:s,className:l,style:c}){let[p,b]=useState(false),x=useRef(null),y=useRef(null);return useEffect(()=>{let v=f=>{let N=f.composedPath();x.current&&!N.includes(x.current)&&y.current&&!N.includes(y.current)&&b(false);};if(p)return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[p]),jsxs("header",{className:i("flex items-center justify-between gap-3","px-4 py-3","border-b border-[var(--chat-border)]","bg-[var(--chat-header-bg,#ffffff)]",l),style:c,children:[jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[r&&jsx("div",{className:"flex-shrink-0",children:typeof r=="string"?jsx("img",{src:r,alt:"",className:"w-10 h-10 rounded-lg object-contain"}):r}),jsxs("div",{className:"flex flex-col min-w-0",children:[s?jsx("div",{className:"h-5 w-24 bg-gray-200 rounded animate-pulse"}):jsx("h1",{className:"text-lg font-semibold text-[var(--chat-text)] truncate",children:e}),a&&jsx("p",{className:"text-sm text-[var(--chat-text-subtle)] truncate",children:a})]})]}),jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[t&&t.length>0&&jsxs("div",{className:"relative",children:[jsx("button",{ref:y,onClick:()=>b(!p),className:i("p-2 rounded-lg","text-[var(--chat-text-subtle)]","hover:bg-[var(--chat-panel-bg)] hover:text-[var(--chat-text)]","transition-colors duration-200"),"aria-label":"Menu","aria-expanded":p,children:jsx(MoreVertical,{size:18})}),p&&jsx("div",{ref:x,className:i("absolute right-0 top-full mt-1 z-50","min-w-[180px]","bg-white rounded-lg shadow-lg","border border-[var(--chat-border)]","py-1","animate-fade-in"),children:t.map(v=>jsxs("button",{onClick:()=>{v.onClick(),b(false);},disabled:v.disabled,className:i("w-full flex items-center gap-2 px-3 py-2","text-sm text-left","text-[var(--chat-text)]","hover:bg-[var(--chat-panel-bg)]","disabled:opacity-50 disabled:cursor-not-allowed","transition-colors duration-150"),children:[v.icon&&jsx("span",{className:"flex-shrink-0 text-[var(--chat-text-subtle)]",children:v.icon}),v.label]},v.id))})]}),n&&o&&jsx("button",{onClick:o,className:i("p-2 rounded-lg","text-[var(--chat-text-subtle)]","hover:bg-[var(--chat-panel-bg)] hover:text-[var(--chat-text)]","transition-colors duration-200"),"aria-label":"Close",children:jsx(X,{size:18})})]})]})}function Ti({toolName:e,status:a,description:r,className:t}){return jsxs("div",{className:i("relative flex items-center gap-2 py-1 px-2 rounded-md text-sm overflow-hidden",a==="running"&&"animate-shimmer",t),children:[jsx(Di,{status:a}),jsx("span",{className:"font-medium text-[var(--chat-text)]",children:e}),r&&jsx("span",{className:"text-[var(--chat-text-subtle)] truncate",children:r})]})}function Di({status:e}){switch(e){case "running":return jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"animate-spin text-[var(--chat-primary)]",children:jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})});case "complete":return jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-[var(--chat-secondary,#56C18A)]",children:[jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]});case "failed":return jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-[var(--chat-error,#B1001B)]",children:[jsx("circle",{cx:"12",cy:"12",r:"10"}),jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]});case "pending":return jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-[var(--chat-text-subtle)]",children:[jsx("circle",{cx:"12",cy:"12",r:"10"}),jsx("polyline",{points:"12 6 12 12 16 14"})]})}}var ar=forwardRef(({isEmpty:e,header:a,welcomeScreen:r,messageList:t,composer:n,footer:o,className:s},l)=>jsx("div",{ref:l,"data-chat-ui":true,className:i("relative h-full overflow-hidden flex flex-col min-h-0",s),children:jsx(AnimatePresence,{mode:"wait",children:e&&r?jsxs(motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.3},className:"flex-1 flex flex-col overflow-hidden min-h-0",children:[a,r]},"welcome"):jsxs(motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.4},className:"flex-1 flex flex-col overflow-hidden min-h-0",children:[a,jsx(motion.div,{initial:{opacity:0,y:-20},animate:{opacity:1,y:0},transition:{duration:.4,delay:.1},className:"flex-1 overflow-hidden flex flex-col min-h-0",children:t}),o,jsx(motion.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.4,delay:.2},children:n})]},"active")})}));ar.displayName="ChatLayout";function _i(e,a=3e3){let[r,t]=useState(0),n=useRef(null);return useEffect(()=>{if(e.length<=1)return;let o=()=>{n.current=setInterval(()=>{t(l=>(l+1)%e.length);},a);},s=()=>{document.visibilityState!=="visible"?n.current&&(clearInterval(n.current),n.current=null):o();};return o(),document.addEventListener("visibilitychange",s),()=>{n.current&&clearInterval(n.current),document.removeEventListener("visibilitychange",s);}},[e,a]),e[r]??""}function Vi({placeholder:e,onSubmit:a,disabled:r,supportsAttachments:t}){let[n,o]=useState(""),[s,l]=useState([]),c=useRef(null),p=useRef(null);useEffect(()=>{c.current&&(c.current.style.height="auto",c.current.style.height=c.current.scrollHeight+"px");},[n]);let b=f=>{f.key==="Enter"&&!f.shiftKey&&(f.preventDefault(),x());},x=()=>{!n.trim()&&s.length===0||r||(a(n.trim(),s.length>0?s:void 0),o(""),l([]));},y=f=>{f.target.files&&l(N=>[...N,...Array.from(f.target.files)]),f.target.value="";},v=f=>{l(N=>N.filter((T,I)=>I!==f));};return jsxs("form",{className:i("w-full relative mx-auto","bg-white dark:bg-zinc-800","rounded-2xl overflow-hidden","shadow-[0_8px_30px_rgba(0,0,0,0.08)]","border border-gray-100 dark:border-zinc-700/50","transition duration-200","focus-within:shadow-[0_8px_30px_rgba(0,0,0,0.12)] focus-within:border-gray-200 dark:focus-within:border-zinc-600"),onSubmit:f=>{f.preventDefault(),x();},children:[s.length>0&&jsx("div",{className:"flex flex-wrap gap-2 px-4 pt-3",children:s.map((f,N)=>jsxs("div",{className:i("flex items-center gap-1.5 px-2.5 py-1 rounded-lg text-xs","bg-gray-100 dark:bg-zinc-700 text-gray-600 dark:text-zinc-300"),children:[jsx("span",{className:"max-w-[120px] truncate",children:f.name}),jsx("button",{type:"button",onClick:()=>v(N),className:"flex-shrink-0 text-gray-400 hover:text-gray-600 dark:hover:text-zinc-200",children:jsx(X,{size:12})})]},`${f.name}-${N}`))}),jsxs("div",{className:"flex items-center gap-2",children:[t&&jsx("button",{type:"button",onClick:()=>p.current?.click(),disabled:r,className:i("ml-3 flex-shrink-0","w-8 h-8 rounded-lg","flex items-center justify-center","text-gray-400 dark:text-zinc-500","hover:bg-gray-100 dark:hover:bg-zinc-700","hover:text-gray-600 dark:hover:text-zinc-300","disabled:opacity-40 disabled:cursor-not-allowed","transition-colors"),children:jsx(Paperclip,{size:16})}),jsx("textarea",{ref:c,value:n,onChange:f=>o(f.target.value),onKeyDown:b,disabled:r,rows:1,placeholder:e,className:i("flex-1 text-sm sm:text-base","border-none bg-transparent","text-gray-900 dark:text-white","focus:outline-none focus:ring-0 resize-none","py-4 sm:py-5",t?"pl-1":"pl-4 sm:pl-6","placeholder:text-gray-400 dark:placeholder:text-zinc-500","disabled:opacity-50 disabled:cursor-not-allowed","max-h-[200px] overflow-y-auto")}),jsx("button",{type:"submit",disabled:!n.trim()&&s.length===0||!!r,className:i("mr-3 flex-shrink-0","w-9 h-9 rounded-lg","flex items-center justify-center","bg-gray-900 dark:bg-zinc-600 text-white dark:text-zinc-100","shadow-sm","hover:bg-gray-700 dark:hover:bg-zinc-500","hover:shadow-md hover:-translate-y-px","active:translate-y-0 active:shadow-sm","disabled:bg-gray-300 dark:disabled:bg-zinc-700","disabled:text-gray-500 dark:disabled:text-zinc-400","disabled:shadow-none disabled:translate-y-0 disabled:cursor-not-allowed","transition-all duration-200"),children:jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M12 19V5M5 12l7-7 7 7"})})})]}),t&&jsx("input",{ref:p,type:"file",multiple:true,onChange:y,className:"hidden"})]})}function Fi({text:e,onClick:a,index:r}){let t=useRef(null),n=useRef(typeof window<"u"?window.matchMedia("(prefers-reduced-motion: reduce)").matches:false),[o,s]=useState(null),l=useCallback(p=>{if(n.current)return;let b=p.currentTarget.getBoundingClientRect();s({x:p.clientX-b.left,y:p.clientY-b.top});},[]),c=useCallback(()=>{s(null);},[]);return jsx(motion.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.2+r*.1,duration:.4},children:jsxs("button",{ref:t,type:"button",onClick:a,onMouseMove:l,onMouseLeave:c,className:i("relative overflow-hidden","w-full text-left","p-3","cursor-pointer","border border-gray-200 dark:border-zinc-700","rounded-lg","transition-all duration-200 ease-out","bg-white dark:bg-zinc-800","hover:border-gray-300 dark:hover:border-zinc-600","hover:bg-gray-50 dark:hover:bg-zinc-750","hover:shadow-sm","active:bg-gray-100 dark:active:bg-zinc-700"),children:[o&&jsx("div",{className:"pointer-events-none absolute inset-0 z-0",style:{background:`radial-gradient(120px circle at ${o.x}px ${o.y}px, var(--chat-halo-primary, rgba(16,105,151,0.06)), transparent)`}}),jsxs("div",{className:"relative z-10 flex items-start gap-2.5",children:[jsx(MessageCircleQuestion,{size:16,strokeWidth:2,className:"mt-0.5 text-gray-400 dark:text-zinc-500 flex-shrink-0"}),jsx("span",{className:"text-sm text-gray-600 dark:text-zinc-300 leading-relaxed flex-1",children:e})]})]})})}var nr=forwardRef(({placeholders:e=[],suggestions:a=[],onSubmit:r,onSuggestionClick:t,welcomeText:n="How can I help you today?",supportsAttachments:o,composerSlot:s,className:l},c)=>{let p=_i(e),b=useCallback(x=>{t?.(x);},[t]);return jsxs("div",{ref:c,className:i("relative overflow-hidden","flex-1 flex items-center justify-center","px-4 sm:px-6",l),children:[jsx("div",{className:"pointer-events-none absolute inset-0 animate-welcome-halo",style:{background:"radial-gradient(ellipse 60% 50% at 50% 45%, var(--chat-halo-primary, rgba(16,105,151,0.06)), var(--chat-halo-secondary, rgba(86,193,138,0.03)) 60%, transparent 100%)"}}),jsxs(motion.div,{layout:true,initial:{scale:.95,y:20,opacity:0},animate:{scale:1,y:0,opacity:1},transition:{type:"spring",stiffness:200,damping:25},className:"relative w-full max-w-[800px] flex flex-col items-center gap-8",children:[n&&jsx(motion.h2,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},transition:{delay:.1,duration:.4},className:"text-2xl font-semibold text-gray-800 dark:text-gray-300 text-center",children:n}),jsx("div",{className:i("w-full rounded-2xl","transition-shadow duration-500","shadow-[0_0_15px_rgba(16,105,151,0.08)]","focus-within:shadow-[0_0_20px_rgba(16,105,151,0.15),0_0_40px_rgba(86,193,138,0.08)]","dark:shadow-[0_0_15px_rgba(255,255,255,0.04)]","dark:focus-within:shadow-[0_0_20px_rgba(255,255,255,0.08),0_0_40px_rgba(255,255,255,0.03)]"),children:s??jsx(Vi,{placeholder:p,onSubmit:(x,y)=>r?.(x,y),supportsAttachments:o})}),a.length>0&&jsx("div",{className:i("grid gap-3 w-full max-w-[900px]","grid-cols-1 sm:grid-cols-[repeat(auto-fit,minmax(250px,1fr))]"),children:a.map((x,y)=>jsx(Fi,{text:x,onClick:()=>b(x),index:y},y))})]})]})});nr.displayName="WelcomeScreen";
19
+ export{ar as $,jt as A,Xe as B,gt as C,ht as D,yt as E,vt as F,kt as G,Nt as H,Ct as I,Pe as J,zt as K,Ba as L,Gt as M,Xt as N,Zt as O,Yt as P,Jt as Q,Qt as R,Pt as S,Ua as T,Xa as U,na as V,Ya as W,vi as X,Qa as Y,Pi as Z,Ti as _,i as a,nr as aa,ha as b,Be as c,va as d,Ke as e,ne as f,It as g,Na as h,Wr as i,_t as j,Vt as k,Bt as l,rt as m,Ae as n,dn as o,Ot as p,nt as q,bn as r,Ce as s,st as t,it as u,lt as v,ct as w,pt as x,dt as y,mt as z};//# sourceMappingURL=chunk-SDMQ6AEH.js.map
20
+ //# sourceMappingURL=chunk-SDMQ6AEH.js.map