@miiflow/assistant-ui 0.10.0 → 0.13.0

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.
@@ -113,6 +113,10 @@ interface MessageProps {
113
113
  onReportIncorrect?: (reason?: string) => void;
114
114
  /** Confirm this assistant response was correct/helpful */
115
115
  onConfirmCorrect?: () => void;
116
+ /** Edit-and-resubmit for the viewer's own messages (ChatGPT-style). When
117
+ * provided, a pencil appears in the hover action bar; submitting replaces
118
+ * this message and everything after it with a fresh agent turn. */
119
+ onEditSubmit?: (newText: string) => void;
116
120
  }
117
121
  /**
118
122
  * Styled Message component with grid layout matching the main app.
@@ -165,17 +169,21 @@ declare const MessageComposer: react.ForwardRefExoticComponent<MessageComposerPr
165
169
  interface MessageListProps {
166
170
  /** Messages to render */
167
171
  children: ReactNode;
168
- /** Whether to auto-scroll to bottom */
172
+ /** Whether to auto-scroll to bottom while streaming (follows only when at the live edge) */
169
173
  autoScroll?: boolean;
170
174
  /** Whether to show the scroll-to-bottom button */
171
175
  showScrollToBottom?: boolean;
172
- /** Additional CSS classes */
176
+ /** Additional CSS classes applied to the transcript container (e.g. horizontal padding) */
173
177
  className?: string;
174
178
  }
175
179
  /**
176
- * Styled MessageList with scrolling, spacing, and scroll-to-bottom button.
177
- * Uses the enhanced useAutoScroll hook directly instead of going through
178
- * the primitive, since we need reactive isAtBottom for the button.
180
+ * Styled MessageList scroll container for a chat transcript.
181
+ *
182
+ * Scroll behavior is provided by shadcn's `@shadcn/react` message-scroller
183
+ * engine (auto-follow while at the live edge, position preservation, scroll
184
+ * anchoring) rather than the legacy `useAutoScroll` hook. The public API is
185
+ * unchanged: pass message rows as `children`; each direct child is wrapped in a
186
+ * `MessageScroller.Item` for measurement and anchoring.
179
187
  */
180
188
  declare const MessageList: react.ForwardRefExoticComponent<MessageListProps & react.RefAttributes<HTMLDivElement>>;
181
189
 
@@ -0,0 +1,133 @@
1
+ import {l,m,c,d,r}from'./chunk-6RN7SUWT.js';import {a as a$2}from'./chunk-D2PFIJNZ.js';import {a as a$1}from'./chunk-NKLA5PPB.js';import {b}from'./chunk-NG4HKXYB.js';import {a,i,g,b as b$1}from'./chunk-ZP4FGAAH.js';import {forwardRef,useState,useContext,useMemo,useRef,useEffect,useCallback,Children,isValidElement,Fragment as Fragment$1,cloneElement}from'react';import {X,Zap,ExternalLink,Search,Mail,Copy,Navigation,Send,Loader2,Square,ArrowUp,Image,FileText,File,User,Bot,Link,ArrowRight,AlertCircle,Check,ChevronDown,HelpCircle,ChevronLeft,ChevronRight,Plus,Download,Video,FileIcon,ChevronUp,MoreVertical,ArrowDown,Minus}from'lucide-react';import {jsxs,jsx,Fragment}from'react/jsx-runtime';import Yr from'react-markdown';import qr from'remark-gfm';import {Prism}from'react-syntax-highlighter';import {oneLight,oneDark}from'react-syntax-highlighter/dist/esm/styles/prism';import {createPortal}from'react-dom';import {AnimatePresence,motion}from'framer-motion';import {ResponsiveContainer,ScatterChart,CartesianGrid,XAxis,YAxis,Tooltip,Legend,Scatter,PieChart,Pie,Cell,AreaChart,Area,BarChart,Bar,LineChart,Line}from'recharts';import {z}from'zod';import {MessageScroller,useMessageScrollerScrollable,useMessageScroller}from'@shadcn/react/message-scroller';function Sr(e){return e.startsWith("image/")?Image:e==="application/pdf"||e.startsWith("text/")?FileText:File}function Tr(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}var rn=forwardRef(({attachment:e,onRemove:t,removable:a$1=true,className:n},r)=>{let o=Sr(e.mimeType),s=e.mimeType.startsWith("image/");return jsxs("div",{ref:r,className:a("relative group","flex items-center gap-2","p-2 rounded-lg","border border-chat-border","bg-chat-panel-bg",n),children:[jsx("div",{className:a("w-10 h-10 rounded","flex items-center justify-center","bg-gray-100 dark:bg-gray-800","overflow-hidden flex-shrink-0"),children:s&&e.previewUrl?jsx("img",{src:e.previewUrl,alt:e.filename,className:"w-full h-full object-cover"}):jsx(o,{className:"w-5 h-5 text-chat-subtle"})}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("p",{className:"text-sm font-medium truncate text-chat-text",children:e.filename}),jsx("p",{className:"text-xs text-chat-subtle",children:Tr(e.size)})]}),a$1&&t&&jsx("button",{type:"button",onClick:t,className:a("absolute -top-1.5 -right-1.5","w-5 h-5 rounded-full","flex items-center justify-center","bg-gray-500 text-white","opacity-0 group-hover:opacity-100","hover:bg-gray-600","transition-opacity duration-200"),"aria-label":`Remove ${e.filename}`,children:jsx(X,{className:"w-3 h-3"})})]})});rn.displayName="AttachmentPreview";var Er={sm:"w-6 h-6 text-xs",md:"w-8 h-8 text-sm",lg:"w-10 h-10 text-base"},Ar={sm:14,md:16,lg:20};function Mr(e,t){let a=Ar[t];switch(e){case "assistant":return jsx(Bot,{size:a});case "user":return jsx(User,{size:a});default:return jsx(User,{size:a})}}var Ie=forwardRef(({name:e,src:t,alt:a$1,role:n,size:r="md",className:o,...s},i)=>jsx(l,{ref:i,name:e,src:t,alt:a$1,role:n,className:a("rounded-full overflow-hidden flex-shrink-0","flex items-center justify-center","font-medium",n==="assistant"?"bg-primary/10 text-primary":"bg-gray-200 dark:bg-gray-700 text-gray-600 dark:text-gray-300",Er[r],o),fallback:Mr(n,r),...s}));Ie.displayName="Avatar";var sn=forwardRef(({children:e,className:t,...a$1},n)=>jsx("div",{ref:n,className:a("flex flex-col h-full","bg-white dark:bg-gray-900","font-sans text-chat-text",t),...a$1,children:e}));sn.displayName="ChatContainer";var Dr=a("flex-shrink-0 rounded-lg flex items-center justify-center","text-[var(--chat-text-subtle,rgba(0,0,0,0.5))]","hover:bg-[var(--chat-panel-bg,rgba(0,0,0,0.02))] hover:text-[var(--chat-text,#1d2033)]","disabled:opacity-40 disabled:cursor-not-allowed","transition-colors duration-150");function Ze({onAttachClick:e,disabled:t,hint:a$1="Enter to send",showHint:n=true,endSlot:r,className:o}){return jsxs("div",{className:a("flex items-center gap-1 min-w-0",o),children:[e&&jsx("button",{type:"button",title:"Attach files","aria-label":"Attach files",onClick:e,disabled:t,className:a(Dr,"w-7 h-7"),children:jsx(Plus,{size:16})}),jsx("div",{className:"flex-1 min-w-0"}),n&&jsx("span",{className:a("hidden sm:block flex-shrink-0 mr-1.5 text-[11px] select-none","text-[var(--chat-placeholder,rgba(0,0,0,0.4))]","opacity-0 group-focus-within:opacity-100 transition-opacity duration-200"),children:a$1}),r]})}var Br={small:"w-1.5 h-1.5",medium:"w-2 h-2",large:"w-2.5 h-2.5"},_r={small:"gap-1",medium:"gap-1.5",large:"gap-2"};function Qe({size:e="medium",className:t}){let a$1=Br[e];return jsxs("div",{className:a("flex items-center",_r[e],t),children:[jsx("div",{className:a(a$1,"rounded-full bg-[var(--chat-text-subtle)]","animate-loading-dot animate-loading-dot-1")}),jsx("div",{className:a(a$1,"rounded-full bg-[var(--chat-text-subtle)]","animate-loading-dot animate-loading-dot-2")}),jsx("div",{className:a(a$1,"rounded-full bg-[var(--chat-text-subtle)]","animate-loading-dot animate-loading-dot-3")})]})}var eo=new Set(["mode","skill"]);function to(e,t){let a=g(e);if(a.length===0)return [e];let n=[],r=0;return a.forEach((o,s)=>{if(o.index>r&&n.push(e.slice(r,o.index)),eo.has(o.kind)){r=o.endIndex,e[r]===" "&&(r+=1);return}let i=t?.(o.id,o.kind);n.push(jsx(b$1,{id:o.id,kind:o.kind,label:i?.label,tag:i?.tag,variant:"chip"},`tok-${s}`)),r=o.endIndex;}),r<e.length&&n.push(e.slice(r)),n}function Fe(e,t){return Children.map(e,(a,n)=>{if(typeof a=="string"){let r=to(a,t);return r.length===1&&r[0]===a?a:jsx(Fragment$1,{children:r},`text-${n}`)}if(isValidElement(a)){let r=a.type,o=typeof r=="string"?r:void 0;if(o==="code"||o==="pre")return a;let s=a.props.children;return s==null?a:cloneElement(a,void 0,Fe(s,t))}return a})}var ao={js:"javascript",ts:"typescript",jsx:"jsx",tsx:"tsx",py:"python",rb:"ruby",rs:"rust",go:"go",java:"java",cpp:"cpp",c:"c",cs:"csharp",swift:"swift",kt:"kotlin",php:"php",sql:"sql",sh:"bash",bash:"bash",zsh:"bash",shell:"bash",html:"html",css:"css",scss:"scss",json:"json",yaml:"yaml",yml:"yaml",xml:"xml",md:"markdown",graphql:"graphql",dockerfile:"docker",toml:"toml"};function no(e){return ao[e.toLowerCase()]||e.toLowerCase()}function Zt(e){return e.toLowerCase().replace(/[^\w\s-]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-").trim()}function ro({text:e}){let[t,a]=useState(false),n=useCallback(async()=>{try{await navigator.clipboard.writeText(e),a(!0),setTimeout(()=>a(!1),2e3);}catch{}},[e]);return jsxs("button",{onClick:n,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","aria-label":t?"Copied":"Copy code",children:[t?jsx(Check,{size:14}):jsx(Copy,{size:14}),t?"Copied":"Copy"]})}function le({children:e,className:t,baselineFontSize:a$2,darkCodeTheme:n}){let r=n??(typeof window<"u"&&window.matchMedia?.("(prefers-color-scheme: dark)").matches),o=a$2!=null?{fontSize:`${a$2}rem`}:void 0,s=useContext(a$1)?.resolveCommandToken;return jsx(Yr,{className:a("chat-prose",t),remarkPlugins:[qr],components:{h1:({children:i})=>{let l=String(i),d=Zt(l);return jsxs("h1",{id:d,className:"group text-xl font-semibold mt-4 mb-2 first:mt-0",style:o,children:[i,jsx("a",{href:`#${d}`,className:"ml-2 opacity-0 group-hover:opacity-50 transition-opacity","aria-label":"Link to heading",children:jsx(Link,{size:16,className:"inline"})})]})},h2:({children:i})=>{let l=String(i),d=Zt(l);return jsxs("h2",{id:d,className:"group text-lg font-semibold mt-3 mb-2 first:mt-0",style:o,children:[i,jsx("a",{href:`#${d}`,className:"ml-2 opacity-0 group-hover:opacity-50 transition-opacity","aria-label":"Link to heading",children:jsx(Link,{size:14,className:"inline"})})]})},h3:({children:i})=>{let l=String(i),d=Zt(l);return jsxs("h3",{id:d,className:"group text-base font-medium mt-2 mb-1 first:mt-0",style:o,children:[i,jsx("a",{href:`#${d}`,className:"ml-2 opacity-0 group-hover:opacity-50 transition-opacity","aria-label":"Link to heading",children:jsx(Link,{size:12,className:"inline"})})]})},h4:({children:i})=>jsx("h4",{className:"text-base font-medium mt-2 mb-1 first:mt-0",style:o,children:Fe(i,s)}),p:({children:i})=>jsx("p",{className:"mb-2 last:mb-0 leading-relaxed",style:o,children:Fe(i,s)}),a:({href:i,children:l})=>i&&/\.(png|jpe?g|gif|webp|svg)([?#]|$)/i.test(i)?jsx("img",{src:i,alt:typeof l=="string"?l:"",className:"max-w-full h-auto rounded-lg my-2",loading:"lazy"}):jsx("a",{href:i,target:"_blank",rel:"noopener noreferrer",className:"text-primary underline hover:opacity-80 transition-opacity",style:o,children:l}),ul:({children:i})=>jsx("ul",{className:"list-disc pl-4 mb-2 space-y-1",children:i}),ol:({children:i})=>jsx("ol",{className:"list-decimal pl-4 mb-2 space-y-1",children:i}),li:({children:i})=>jsx("li",{className:"leading-relaxed",style:o,children:Fe(i,s)}),blockquote:({children:i})=>jsx("blockquote",{className:"border-l-2 border-gray-300 dark:border-gray-600 pl-3 my-2 italic text-chat-subtle",style:o,children:Fe(i,s)}),code:({className:i,children:l})=>{let d=/language-(\w+)/.exec(i||""),p=String(l).replace(/\n$/,"");if(!d&&!p.includes(`
2
+ `))return jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1.5 py-0.5 rounded text-sm font-mono",style:o,children:l});let y=d?no(d[1]):"text";return jsxs("div",{className:"relative group my-2 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:[jsx("span",{className:"text-xs font-mono text-gray-400",children:y}),jsx(ro,{text:p})]}),jsx(Prism,{language:y,style:r===false?oneLight:oneDark,customStyle:{margin:0,borderRadius:0,fontSize:"0.8125rem",lineHeight:"1.6"},codeTagProps:{style:{fontFamily:"'Fira Code', 'JetBrains Mono', monospace"}},children:p})]})},pre:({children:i})=>jsx(Fragment,{children:i}),table:({children:i})=>jsx("div",{className:"overflow-x-auto my-2 rounded-lg border border-gray-200 dark:border-gray-700",children:jsx("table",{className:"min-w-full",children:i})}),thead:({children:i})=>jsx("thead",{className:"bg-gray-50 dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700",children:i}),th:({children:i})=>jsx("th",{className:"px-3 py-2 text-left text-sm font-medium",style:o,children:Fe(i,s)}),td:({children:i})=>jsx("td",{className:"px-3 py-2 text-sm border-t border-gray-100 dark:border-gray-700",style:o,children:Fe(i,s)}),hr:()=>jsx("hr",{className:"my-4 border-gray-200 dark:border-gray-700"}),strong:({children:i})=>jsx("strong",{className:"font-semibold",children:i}),em:({children:i})=>jsx("em",{className:"italic",children:i}),img:({src:i,alt:l})=>jsx("img",{src:i,alt:l??"",className:"max-w-full h-auto rounded-lg my-2",loading:"lazy"})},children:e})}var Ee=/(?:youtube\.com\/watch\?v=|youtu\.be\/|youtube\.com\/embed\/)([A-Za-z0-9_-]{11})/,co=e=>{let t=e.match(Ee);return t?t[1]:null};function Jt(e,t,a){if(typeof e=="string"){let n=e.trim();if(!n)return null;if(n.startsWith("media_ref:")&&a&&a.length>0){let s=n.slice(10),i=a.find(l=>l.id===s);return i?{id:i.id,url:i.url,mediaType:i.mediaType||(Ee.test(i.url)||/\.(mp4|mov|webm|m4v|mkv)(\?|$)/i.test(i.url)?"video":"image"),altText:i.altText}:null}let r=n,o=Ee.test(r)||/\.(mp4|mov|webm|m4v|mkv)(\?|$)/i.test(r);return {id:t,url:r,mediaType:o?"video":"image"}}if(e&&typeof e=="object"){let n=e,r=n.url||n.image_url||n.video_url;if(!r||typeof r!="string")return null;let o=n.media_type||n.mediaType||n.type,s=n.alt||n.alt_text||n.altText;return {id:n.id||t,url:r,mediaType:o||(Ee.test(r)||/\.(mp4|mov|webm|m4v|mkv)(\?|$)/i.test(r)?"video":"image"),altText:s}}return null}var Ke=({label:e})=>jsx("div",{className:a("absolute inset-0 flex cursor-pointer items-center justify-center","bg-black/20 transition-colors hover:bg-black/35"),"aria-label":e,children:jsx("div",{className:"flex h-14 w-14 items-center justify-center rounded-full bg-black/55 shadow-lg",children:jsx("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"white","aria-hidden":"true",children:jsx("path",{d:"M8 5v14l11-7z"})})})});function bt({items:e,index:t,onClose:a$1,onNavigate:n}){let r=e[t];if(useEffect(()=>{let l=p=>{p.key==="Escape"?a$1():p.key==="ArrowLeft"?n(-1):p.key==="ArrowRight"&&n(1);};window.addEventListener("keydown",l);let d=typeof document<"u"?document.body.style.overflow:"";return typeof document<"u"&&(document.body.style.overflow="hidden"),()=>{window.removeEventListener("keydown",l),typeof document<"u"&&(document.body.style.overflow=d);}},[a$1,n]),!r||typeof document>"u")return null;let o=r.mediaType==="video"?co(r.url):null,s=e.length>1,i=jsxs("div",{className:a("fixed inset-0 z-[9999] flex items-center justify-center","bg-black/85 backdrop-blur-sm"),role:"dialog","aria-modal":"true","aria-label":"Media viewer",onClick:a$1,children:[jsx("button",{type:"button",onClick:l=>{l.stopPropagation(),a$1();},className:a("absolute right-4 top-4 z-10 flex h-10 w-10 items-center justify-center","rounded-full bg-white/10 text-white hover:bg-white/20"),"aria-label":"Close",children:jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:jsx("path",{d:"M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"})})}),s&&jsxs("div",{className:"absolute left-4 top-4 z-10 rounded-full bg-white/10 px-3 py-1 text-sm text-white",onClick:l=>l.stopPropagation(),children:[t+1," / ",e.length]}),s&&jsx("button",{type:"button",onClick:l=>{l.stopPropagation(),n(-1);},className:a("absolute left-4 z-10 flex h-12 w-12 items-center justify-center","rounded-full bg-white/10 text-white hover:bg-white/20"),"aria-label":"Previous",children:jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:jsx("path",{d:"M15.41 7.41 14 6l-6 6 6 6 1.41-1.41L10.83 12z"})})}),s&&jsx("button",{type:"button",onClick:l=>{l.stopPropagation(),n(1);},className:a("absolute right-4 z-10 flex h-12 w-12 items-center justify-center","rounded-full bg-white/10 text-white hover:bg-white/20"),"aria-label":"Next",children:jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:jsx("path",{d:"M10 6 8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"})})}),jsxs("div",{className:"flex max-h-[90vh] max-w-[90vw] flex-col items-center",onClick:l=>l.stopPropagation(),children:[r.mediaType==="video"&&o?jsx("div",{className:"relative overflow-hidden rounded-lg bg-black",style:{width:"min(90vw, 1024px)",aspectRatio:"16 / 9"},children:jsx("iframe",{src:`https://www.youtube.com/embed/${o}?autoplay=1`,title:r.altText||"Video",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:true,className:"absolute inset-0 h-full w-full border-0"})}):r.mediaType==="video"?jsxs("video",{controls:true,autoPlay:true,preload:"metadata",className:"block max-h-[85vh] max-w-[90vw] rounded-lg",children:[jsx("source",{src:r.url}),"Your browser does not support the video tag."]}):jsx("img",{src:r.url,alt:r.altText||"Image",className:"block max-h-[85vh] max-w-[90vw] rounded-lg object-contain"}),r.altText&&jsx("div",{className:"mt-2 max-w-[90vw] text-center text-sm text-white/80",children:r.altText})]})]});return createPortal(i,document.body)}function xt(e){let[t,a]=useState(null),n=useCallback(s=>a(s),[]),r=useCallback(()=>a(null),[]),o=useCallback(s=>{a(i=>i===null||e.length===0?i:(i+s+e.length)%e.length);},[e.length]);return {index:t,open:n,close:r,navigate:o}}function dn(e){switch(e){case "knowledge_base":return {label:"Knowledge Base",color:"#4caf50"};case "api":return {label:"API",color:"#2196f3"};case "system_tool":return {label:"Tool",color:"#ff9800"};case "mcp_tool":return {label:"MCP",color:"#9c27b0"};case "workflow":return {label:"Workflow",color:"#00bcd4"};case "memory":return {label:"Memory",color:"#e91e63"};default:return {label:"Source",color:"#757575"}}}function ea({sources:e,className:t}){let[a$1,n]=useState(null),[r,o]=useState(false);if(!e||e.length===0)return null;let s=8,i=r?e:e.slice(0,s),l=e.length-s;return jsxs(Fragment,{children:[jsxs("div",{className:a("flex flex-wrap gap-1.5 mt-2",t),children:[i.map(d=>{let p=dn(d.source_type);return jsx("span",{className:"inline-flex items-center gap-0.5",children:jsxs("button",{onClick:()=>n(d),className:"inline-flex items-center h-6 px-2 text-[0.75rem] font-medium rounded-full border cursor-pointer transition-colors max-w-[280px] truncate",style:{backgroundColor:p.color+"1a",color:p.color,borderColor:p.color+"40"},children:["[",d.index,"] ",d.title]})},d.index)}),!r&&l>0&&jsxs("button",{onClick:()=>o(true),className:"inline-flex items-center h-6 px-2 text-[0.75rem] font-medium rounded-full border cursor-pointer transition-colors text-gray-500 border-gray-300 hover:bg-gray-50 dark:border-gray-600 dark:hover:bg-gray-800",children:["+",l," more"]})]}),jsx(pn,{source:a$1,onClose:()=>n(null)})]})}function pn({source:e,onClose:t}){if(useEffect(()=>{if(!e)return;let n=r=>{r.key==="Escape"&&t();};return document.addEventListener("keydown",n),()=>document.removeEventListener("keydown",n)},[e,t]),!e)return null;let a=dn(e.source_type);return jsx(AnimatePresence,{children:e&&jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[jsx(motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"absolute inset-0 bg-black/50",onClick:t}),jsxs(motion.div,{initial:{opacity:0,scale:.95,y:10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:10},transition:{duration:.15},className:"relative bg-white dark:bg-gray-900 rounded-xl shadow-xl border border-gray-200 dark:border-gray-700 w-full max-w-2xl max-h-[80vh] flex flex-col overflow-hidden",children:[jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",children:[jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[jsx("h3",{className:"text-lg font-semibold truncate",children:e.title}),jsx("span",{className:"text-[0.7rem] px-1.5 py-0.5 rounded font-medium shrink-0",style:{backgroundColor:a.color+"1a",color:a.color},children:a.label})]}),jsx("button",{onClick:t,className:"p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-800 ml-2",children:jsx(X,{size:16})})]}),jsxs("div",{className:"flex-1 overflow-y-auto p-4",children:[jsxs("div",{className:"flex flex-wrap gap-1.5 mb-4",children:[jsx("span",{className:"text-[0.7rem] px-1.5 py-0.5 rounded border border-gray-200 dark:border-gray-700",children:e.tool_name.replace(/_/g," ")}),e.query&&jsxs("span",{className:"text-[0.7rem] px-1.5 py-0.5 rounded border border-gray-200 dark:border-gray-700 max-w-[200px] truncate",title:e.query,children:["Query: ",e.query.slice(0,40),e.query.length>40?"...":""]})]}),e.url&&jsx("div",{className:"mb-4",children:jsxs("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-blue-500 hover:underline inline-flex items-center gap-1",children:[e.url.length>80?`${e.url.slice(0,80)}...`:e.url,jsx(ExternalLink,{size:12})]})}),e.description&&jsx("p",{className:"text-sm text-gray-500 mb-4",children:e.description}),e.full_content?jsx("div",{className:"whitespace-pre-wrap font-mono text-sm leading-relaxed p-4 rounded-lg bg-gray-50 dark:bg-gray-800/50 border border-gray-200 dark:border-gray-700 max-h-[400px] overflow-auto",children:e.full_content}):e.snippet?jsx("div",{className:"whitespace-pre-wrap font-mono text-sm leading-relaxed p-4 rounded-lg bg-gray-50 dark:bg-gray-800/50 border border-gray-200 dark:border-gray-700",children:e.snippet}):jsx("p",{className:"text-sm text-gray-400 italic",children:"No content available for this source."})]}),jsx("div",{className:"flex justify-end p-3 border-t border-gray-200 dark:border-gray-700",children:jsx("button",{onClick:t,className:"px-3 py-1.5 text-sm rounded-lg hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors",children:"Close"})})]})]})})}function go({index:e,source:t}){return jsx("span",{className:a("inline-flex items-center justify-center min-w-[16px] h-4 rounded-full","bg-blue-500 text-white text-[0.6rem] font-semibold","px-0.5 mx-0.5 align-super",t?.url?"cursor-pointer hover:opacity-85":"cursor-default"),title:t?`${t.title}${t.description?": "+t.description:""}`:void 0,onClick:a=>{t?.url&&(a.stopPropagation(),window.open(t.url,"_blank","noopener,noreferrer"));},children:e})}function No(e){return e.questions&&e.questions.length>0?e.questions.map(t=>({question:t.question,options:t.options||[],multiSelect:t.multiSelect??t.multi_select,key:t.key})):e.question?[{question:e.question,options:e.options||[],multiSelect:false}]:[]}function fn(e,t){let a=(t||"").trim();return a?[...e,a]:e}function So(e,t,a){return e.map((n,r)=>({key:n.key,question:n.question,selected:fn(t[r]||[],a[r])}))}function To(e,t,a){return e.map((n,r)=>{let o=fn(t[r]||[],a[r]),s=o.length>0?o.join(", "):"(no answer)";return `${e.length>1?`${r+1}. `:""}${n.question}
3
+ \u2192 ${s}`}).join(`
4
+
5
+ `)}function na({clarification:e,onSubmit:t,onOptionSelect:a$1,disabled:n=false,loading:r=false,className:o,answer:s}){let i=useMemo(()=>No(e),[e]),[l,d]=useState({}),[p,v]=useState({}),[y,T]=useState(0),x=typeof s=="string"&&s.length>0,b=useRef(null);useEffect(()=>()=>{b.current&&clearTimeout(b.current);},[]);let N=useCallback((k,u)=>{for(let w=k+1;w<i.length;w++)if((u[w]||[]).length===0){T(w);return}k+1<i.length&&T(k+1);},[i.length]),R=useCallback((k,u,w)=>{d(H=>{let $=H[k]||[],G;w?G=$.includes(u)?$.filter(A=>A!==u):[...$,u]:G=[u],G.includes(u)&&a$1?.(u);let ye={...H,[k]:G};return w||(b.current&&clearTimeout(b.current),b.current=setTimeout(()=>N(k,ye),250)),ye});},[a$1,N]),M=i.length>0&&i.every((k,u)=>(l[u]||[]).length>0||(p[u]||"").trim().length>0),C=useCallback(()=>{if(!t||!M)return;let k=To(i,l,p),u=So(i,l,p);d({}),v({}),T(0),t(k,u);},[t,M,i,l,p]);if(x)return jsx("div",{className:a("mx-4 mb-3 flex justify-end font-sans",o),children:jsxs("details",{className:"group max-w-[85%]",children:[jsxs("summary",{className:a("flex items-center justify-end gap-1.5 cursor-pointer select-none","text-xs text-gray-600 dark:text-gray-300","hover:text-gray-900 dark:hover:text-gray-100 transition-colors","list-none [&::-webkit-details-marker]:hidden"),children:[jsx(Check,{size:12,strokeWidth:2.75,className:"text-emerald-600 dark:text-emerald-500"}),jsx("span",{children:"Clarification answered"}),jsx(ChevronDown,{size:12,className:"text-gray-400 transition-transform group-open:rotate-180"})]}),jsx("div",{className:"mt-2 text-right",children:jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400 whitespace-pre-wrap break-words text-left",children:s})})]})});if(i.length===0)return null;let S="var(--chat-clarification-accent,#f97316)",f=i.length>1,g=Math.min(y,i.length-1),E=k=>{let u=i[k],w=!!u.multiSelect,H=l[k]||[];return jsxs("div",{children:[jsxs("div",{className:"flex items-start gap-2 mb-1.5",children:[!e.context&&!f?jsx("span",{className:"text-[var(--chat-clarification-accent,#f97316)] mt-0.5 flex-shrink-0",children:jsx(HelpCircle,{size:14})}):null,jsx("div",{className:"flex-1 min-w-0",children:jsx(le,{className:"text-sm font-medium",children:u.question})})]}),jsxs("div",{className:"ml-5 space-y-1",children:[u.options.map(($,G)=>{let ye=H.includes($);return jsxs("label",{className:a("flex items-center gap-2 py-0.5 cursor-pointer text-sm rounded px-1 -mx-1","hover:bg-[color-mix(in_oklab,var(--chat-clarification-accent,#f97316)_18%,transparent)]"),children:[jsx("input",{type:w?"checkbox":"radio",name:`clarification-q${k}`,value:$,checked:ye,onChange:()=>R(k,$,w),disabled:n||r,className:"w-3.5 h-3.5",style:{accentColor:S}}),$]},G)}),jsxs("div",{className:"flex items-center gap-2 py-0.5 px-1 -mx-1 text-sm",children:[jsx("span",{className:"flex-shrink-0 text-gray-500 dark:text-gray-400",children:"Other:"}),jsx("input",{type:"text",value:p[k]||"",placeholder:H.length>0?"Add anything else\u2026 (optional)":"Or type your own answer\u2026",onChange:$=>v(G=>({...G,[k]:$.target.value})),onKeyDown:$=>{$.key==="Enter"&&($.preventDefault(),((p[k]||"").trim()||(l[k]||[]).length>0)&&N(k,l));},disabled:n||r,className:a("flex-1 min-w-0 px-2 py-0.5 text-sm rounded border bg-transparent","border-[color-mix(in_oklab,var(--chat-clarification-accent,#f97316)_40%,transparent)]","focus:outline-none focus:border-[var(--chat-clarification-accent,#f97316)]","placeholder:text-gray-400 dark:placeholder:text-gray-500")})]})]})]})};return jsxs("div",{className:a("mx-4 mb-3 px-4 py-3 font-sans","bg-[color-mix(in_oklab,var(--chat-clarification-accent,#f97316)_12%,transparent)]","border-l-[3px] border-[var(--chat-clarification-accent,#f97316)]","rounded-r-lg",o),children:[e.context?jsxs("div",{className:"flex items-start gap-2 mb-2",children:[jsx("span",{className:"text-[var(--chat-clarification-accent,#f97316)] mt-0.5 flex-shrink-0",children:jsx(HelpCircle,{size:14})}),jsx("div",{className:"flex-1 min-w-0",children:jsx(le,{className:"text-sm text-gray-600 dark:text-gray-300",children:e.context})})]}):null,f?jsx("div",{role:"tablist","aria-label":"Clarification questions",className:"flex items-center gap-1 mb-2 border-b border-[color-mix(in_oklab,var(--chat-clarification-accent,#f97316)_30%,transparent)]",children:i.map((k,u)=>{let w=u===g,H=(l[u]||[]).length>0;return jsxs("button",{role:"tab","aria-selected":w,onClick:()=>{b.current&&clearTimeout(b.current),T(u);},className:a("flex items-center gap-1 px-2.5 py-1 text-xs rounded-t -mb-px border-b-2 transition-colors",w?"border-[var(--chat-clarification-accent,#f97316)] text-[var(--chat-clarification-accent,#f97316)] font-medium":"border-transparent text-gray-500 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200"),children:[H?jsx(Check,{size:11,strokeWidth:3,className:"text-emerald-600 dark:text-emerald-500"}):null,jsx("span",{children:u+1})]},u)})}):null,jsx("div",{className:"max-h-[50vh] overflow-y-auto pr-1",children:E(g)}),jsxs("div",{className:"mt-2 flex items-center justify-between gap-2",children:[f?jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:`${i.filter((u,w)=>(l[w]||[]).length>0).length} of ${i.length} answered`}):jsx("span",{}),jsxs("div",{className:"flex items-center gap-1",children:[f?jsxs(Fragment,{children:[jsx("button",{type:"button","aria-label":"Previous question",onClick:()=>{b.current&&clearTimeout(b.current),T(k=>Math.max(0,k-1));},disabled:g===0,className:a("flex items-center justify-center w-6 h-6 rounded transition-colors",g===0?"text-gray-300 dark:text-gray-600 cursor-default":"text-gray-500 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 hover:bg-[color-mix(in_oklab,var(--chat-clarification-accent,#f97316)_18%,transparent)]"),children:jsx(ChevronLeft,{size:16})}),jsx("button",{type:"button","aria-label":"Next question",onClick:()=>{b.current&&clearTimeout(b.current),T(k=>Math.min(i.length-1,k+1));},disabled:g===i.length-1,className:a("flex items-center justify-center w-6 h-6 rounded transition-colors mr-1",g===i.length-1?"text-gray-300 dark:text-gray-600 cursor-default":"text-gray-500 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 hover:bg-[color-mix(in_oklab,var(--chat-clarification-accent,#f97316)_18%,transparent)]"),children:jsx(ChevronRight,{size:16})})]}):null,jsxs("button",{onClick:C,disabled:!M||n||r,className:a("flex items-center gap-1 px-2 py-1 rounded text-sm transition-colors",M?"text-[var(--chat-clarification-accent,#f97316)] hover:text-[var(--chat-clarification-accent-soft,#fdba74)]":"text-gray-300 dark:text-gray-600"),children:[jsx("span",{className:"text-xs",children:"Submit"}),jsx(Send,{size:14})]})]})]})]})}var gn=140;function ra(e){return e==null?"\u2014":typeof e=="boolean"?e?"yes":"no":String(e)}function oa(e){return e==null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"}function Eo({value:e}){let[t,a]=useState(false);if(oa(e)){let r=ra(e);return r.length>gn||r.includes(`
6
+ `)?jsxs("div",{className:"flex flex-col gap-1 min-w-0",children:[t?jsx("pre",{className:"whitespace-pre-wrap break-words text-xs font-mono bg-black/5 dark:bg-white/5 rounded px-2 py-1.5 max-h-60 overflow-auto",children:r}):jsxs("span",{className:"break-words text-current/80",children:[r.slice(0,gn),"\u2026"]}),jsx("button",{type:"button",onClick:()=>a(s=>!s),className:"self-start text-[11px] underline-offset-2 hover:underline opacity-70 hover:opacity-100",children:t?"Show less":"Show more"})]}):jsx("span",{className:"break-words",children:r})}if(Array.isArray(e)&&e.every(oa)){let r=e.map(ra).join(", ")||"(empty)";return jsx("span",{className:"break-words",children:r})}let n="";try{n=JSON.stringify(e,null,2);}catch{n=String(e);}return jsxs("div",{className:"flex flex-col gap-1 min-w-0",children:[jsxs("button",{type:"button",onClick:()=>a(r=>!r),className:"self-start text-[11px] underline-offset-2 hover:underline opacity-70 hover:opacity-100",children:[t?"Hide":"Show"," ",Array.isArray(e)?"items":"details"]}),t&&jsx("pre",{className:"whitespace-pre-wrap break-words text-xs font-mono bg-black/5 dark:bg-white/5 rounded px-2 py-1.5 max-h-60 overflow-auto",children:n})]})}var xn=({onClick:e,disabled:t,children:a$1})=>jsx("button",{type:"button",onClick:e,disabled:t,className:a("px-4 py-1.5 rounded-full text-sm font-medium transition-colors","bg-[var(--chat-approve-bg,#1c1917)] hover:bg-[var(--chat-approve-bg-hover,#292524)] text-[var(--chat-approve-text,white)]","disabled:opacity-50 disabled:cursor-not-allowed"),children:a$1}),Ao=({onClick:e,disabled:t,children:a$1})=>jsx("button",{type:"button",onClick:e,disabled:t,className:a("px-4 py-1.5 rounded-full text-sm font-medium transition-colors","bg-[var(--chat-reject-bg,#f5f5f4)] text-[var(--chat-reject-text,#44403c)] hover:bg-[var(--chat-reject-bg-hover,#e7e5e4)] dark:bg-[var(--chat-reject-bg-dark,rgba(255,255,255,0.06))] dark:text-[var(--chat-reject-text-dark,#e7e5e4)] dark:hover:bg-[var(--chat-reject-bg-hover-dark,rgba(255,255,255,0.1))]","disabled:opacity-50 disabled:cursor-not-allowed"),children:a$1}),Mo=({onClick:e,disabled:t,children:a$1})=>jsx("button",{type:"button",onClick:e,disabled:t,className:a("text-sm underline-offset-4 transition-colors","text-[var(--chat-text-subtle,rgba(0,0,0,0.55))] hover:text-[var(--chat-text,#1c1917)] hover:underline","dark:text-[var(--chat-text-subtle-dark,rgba(255,255,255,0.55))] dark:hover:text-[var(--chat-text-dark,#fafaf9)]","disabled:opacity-50 disabled:cursor-not-allowed"),children:a$1}),Ro=xn,Io=({value:e,onChange:t,onSubmit:a,onCancel:n,placeholder:r,disabled:o,autoFocus:s})=>jsx("textarea",{value:e,onChange:i=>t(i.target.value),onKeyDown:i=>{i.key==="Enter"&&!i.shiftKey?(i.preventDefault(),a()):i.key==="Escape"&&(i.preventDefault(),n());},placeholder:r,disabled:o,autoFocus:s,rows:2,className:"w-full text-sm bg-transparent border-b border-[var(--chat-border,rgba(0,0,0,0.12))] dark:border-[var(--chat-border-dark,rgba(255,255,255,0.15))] focus:border-[var(--chat-text,#1c1917)] dark:focus:border-[var(--chat-text-dark,#fafaf9)] py-1.5 resize-y disabled:opacity-50 placeholder:text-[var(--chat-text-subtle,rgba(0,0,0,0.4))] outline-none transition-colors"}),Lo=3,hn=32;function Do(e){let t=ra(e);return t.length<=hn?t:`${t.slice(0,hn-1)}\u2026`}function ia({approval:e,onApprove:t,onReject:a$1,disabled:n=false,className:r,slots:o}){let[s,i]=useState("idle"),[l,d]=useState(""),[p,v]=useState(false),y=useCallback(()=>{t(e.toolInputs);},[t,e.toolInputs]),T=useCallback(()=>{a$1("User declined this action");},[a$1]),x=useCallback(()=>{let u=l.trim();u&&a$1(u);},[l,a$1]),b=useCallback(()=>{i("idle"),d("");},[]);useEffect(()=>{if(s!=="idle"||n)return;let u=w=>{let H=w.target,$=H?.tagName;$==="INPUT"||$==="TEXTAREA"||$==="SELECT"||(H?.isContentEditable??false)||(w.key==="Enter"&&!w.shiftKey&&!w.metaKey&&!w.ctrlKey&&!w.altKey?(w.preventDefault(),y()):w.key==="Escape"&&(w.preventDefault(),T()));};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[s,n,y,T]);let N=e.toolDescription?.trim()||`Run ${e.toolName}`,R=e.toolLabel?.trim()||e.toolName,M=Object.entries(e.toolInputs).filter(([u])=>u!=="__description"),C=M.filter(([,u])=>oa(u)).slice(0,Lo),S=o?.AllowButton??xn,f=o?.RejectButton??Ao,g=o?.SendButton??Ro,E=o?.CancelButton??Mo,k=o?.ChatInput??Io;return jsxs("div",{role:"group","aria-label":"Tool approval",className:a("mx-4 mb-4 font-sans","px-4 py-3.5 rounded-2xl","bg-[var(--chat-approval-panel-bg,oklch(0.995_0.003_70))]","border-[1.5px] border-[var(--chat-approval-panel-border,oklch(0.86_0.005_70))]","shadow-[var(--chat-approval-panel-shadow,0_1px_0_rgba(0,0,0,0.04),0_8px_24px_-12px_rgba(0,0,0,0.10))]","text-[var(--chat-text,#1c1917)] dark:text-[var(--chat-text-dark,#fafaf9)]",r),children:[s==="idle"&&jsxs("div",{className:"flex items-center gap-2 mb-2 min-w-0",children:[jsx("span",{"aria-hidden":true,className:"inline-block w-1.5 h-1.5 rounded-full bg-[var(--chat-activity,var(--chat-primary,#106997))] animate-pulse-subtle shrink-0"}),jsx("span",{className:"uppercase tracking-[0.08em] text-[11px] font-semibold opacity-70 shrink-0",children:"Approve action"}),R&&jsxs(Fragment,{children:[jsx("span",{"aria-hidden":true,className:"opacity-30 shrink-0",children:"\xB7"}),jsx("span",{className:"text-[11px] opacity-60 truncate",title:R,children:R})]})]}),jsx("div",{className:"max-h-[40vh] overflow-y-auto pr-1",children:jsx("p",{className:"text-base leading-relaxed",children:N})}),s==="idle"?jsxs(Fragment,{children:[C.length>0&&jsx("div",{className:"mt-2.5 flex flex-wrap gap-1.5",children:C.map(([u,w])=>jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-md text-[11px] font-mono bg-black/[0.04] dark:bg-white/[0.06]",children:[jsxs("span",{className:"opacity-60",children:[u,":"]}),jsx("span",{children:Do(w)})]},u))}),jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-x-3 gap-y-2",children:[jsx(S,{onClick:y,disabled:n,children:"Approve"}),jsx(f,{onClick:T,disabled:n,children:"Decline"}),!n&&jsxs("span",{"aria-hidden":true,className:"ml-auto text-[11px] opacity-50 select-none hidden sm:inline",children:[jsx("kbd",{className:"font-sans",children:"\u23CE"})," approve \xB7"," ",jsx("kbd",{className:"font-sans",children:"Esc"})," decline"]})]}),M.length>0&&jsxs("div",{className:"mt-3",children:[jsx("button",{type:"button",onClick:()=>v(u=>!u),className:"text-xs underline-offset-4 hover:underline opacity-60 hover:opacity-100 transition-opacity",children:p?"Hide all details":"Show all details"}),p&&jsx("dl",{className:"mt-2 grid grid-cols-[auto_1fr] gap-x-4 gap-y-1 text-xs opacity-70 max-h-[40vh] overflow-y-auto pr-1",children:M.map(([u,w])=>jsxs("div",{className:"contents",children:[jsx("dt",{className:"font-mono text-[11px] pt-0.5 self-start",children:u}),jsx("dd",{className:"min-w-0",children:jsx(Eo,{value:w})})]},u))})]})]}):jsxs("div",{className:"mt-3 flex flex-col gap-3",children:[jsx(k,{value:l,onChange:d,onSubmit:x,onCancel:b,placeholder:"Tell me what you want instead\u2026",disabled:n,autoFocus:true}),jsxs("div",{className:"flex items-center gap-x-3",children:[jsx(g,{onClick:x,disabled:n||!l.trim(),children:"Send"}),jsx(E,{onClick:b,disabled:n,children:"Cancel"})]})]})]})}var _o=["Incorrect or incomplete","Not what I asked for","Wrong data","Bad recommendation","Tone or style","Other"];function kt({textContent:e,onRegenerate:t,onEdit:a$1,onReportIncorrect:n,onConfirmCorrect:r,className:o}){let[s,i]=useState(false),[l,d]=useState("none"),[p,v]=useState(false),[y,T]=useState(null),[x,b]=useState(""),N=useCallback(()=>{v(false),T(null),b("");},[]),R=useCallback(()=>{if(l!=="none")return;let C=x.trim(),S=y&&C?`${y}: ${C}`:y||C;d("incorrect"),v(false),T(null),b(""),n?.(S||void 0);},[l,y,x,n]);useEffect(()=>{if(!p)return;let C=S=>{S.key==="Escape"&&N();};return document.addEventListener("keydown",C),()=>document.removeEventListener("keydown",C)},[p,N]);let M=useCallback(async()=>{try{await navigator.clipboard.writeText(e),i(!0),setTimeout(()=>i(!1),2e3);}catch{let C=document.createElement("textarea");C.value=e,C.style.position="fixed",C.style.opacity="0",document.body.appendChild(C),C.select(),document.execCommand("copy"),document.body.removeChild(C),i(true),setTimeout(()=>i(false),2e3);}},[e]);return jsxs("div",{className:a("relative flex items-center gap-1",p?"opacity-100":"opacity-0 group-hover:opacity-100 transition-opacity duration-150",o),children:[jsx("button",{type:"button",onClick:M,"aria-label":s?"Copied":"Copy message",className:a("flex items-center justify-center","w-7 h-7 rounded-md","text-[var(--chat-text-subtle)] hover:text-[var(--chat-text)]","hover:bg-[var(--chat-panel-bg)]","transition-colors duration-150"),children:s?jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("polyline",{points:"20 6 9 17 4 12"})}):jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2"}),jsx("path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"})]})}),t&&jsx("button",{type:"button",onClick:t,"aria-label":"Regenerate response",className:a("flex items-center justify-center","w-7 h-7 rounded-md","text-[var(--chat-text-subtle)] hover:text-[var(--chat-text)]","hover:bg-[var(--chat-panel-bg)]","transition-colors duration-150"),children:jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"}),jsx("path",{d:"M21 3v5h-5"}),jsx("path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"}),jsx("path",{d:"M8 16H3v5"})]})}),a$1&&jsx("button",{type:"button",onClick:a$1,"aria-label":"Edit message",className:a("flex items-center justify-center","w-7 h-7 rounded-md","text-[var(--chat-text-subtle)] hover:text-[var(--chat-text)]","hover:bg-[var(--chat-panel-bg)]","transition-colors duration-150"),children:jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z"}),jsx("path",{d:"m15 5 4 4"})]})}),(r||n)&&l==="none"&&jsx("div",{className:"w-px h-4 bg-[var(--chat-text-subtle)] opacity-20 mx-0.5"}),r&&l==="none"&&jsx("button",{type:"button",onClick:()=>{d("correct"),r();},"aria-label":"This response was helpful",className:a("flex items-center justify-center","w-7 h-7 rounded-md","text-[var(--chat-text-subtle)] hover:text-[var(--chat-text)]","hover:bg-[var(--chat-panel-bg)]","transition-colors duration-150"),children:jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M7 10v12"}),jsx("path",{d:"M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2h0a3.13 3.13 0 0 1 3 3.88Z"})]})}),n&&l==="none"&&jsx("button",{type:"button",onClick:()=>v(true),"aria-label":"This response was incorrect","aria-haspopup":"dialog","aria-expanded":p,className:a("flex items-center justify-center","w-7 h-7 rounded-md","text-[var(--chat-text-subtle)] hover:text-[var(--chat-text)]","hover:bg-[var(--chat-panel-bg)]",p&&"bg-[var(--chat-panel-bg)] text-[var(--chat-text)]","transition-colors duration-150"),children:jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M17 14V2"}),jsx("path",{d:"M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22h0a3.13 3.13 0 0 1-3-3.88Z"})]})}),l!=="none"&&jsx("span",{className:"text-xs text-[var(--chat-text-subtle)] px-1",children:l==="correct"?"Thanks!":"Reported"}),p&&typeof document<"u"&&createPortal(jsxs("div",{role:"presentation",onClick:N,style:{position:"fixed",inset:0,zIndex:2147483600,background:"rgba(0,0,0,0.5)",display:"flex",alignItems:"center",justifyContent:"center",padding:16,fontFamily:"Inter, system-ui, -apple-system, sans-serif"},children:[jsx("style",{children:Fo}),jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Share feedback",onClick:C=>C.stopPropagation(),className:"mf-fbm-card",children:[jsxs("div",{className:"mf-fbm-header",children:[jsx("span",{className:"mf-fbm-title",children:"Share feedback"}),jsx("button",{type:"button",onClick:N,"aria-label":"Close feedback",className:"mf-fbm-close",children:jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M18 6 6 18"}),jsx("path",{d:"m6 6 12 12"})]})})]}),jsx("div",{className:"mf-fbm-chips",children:_o.map(C=>{let S=y===C;return jsx("button",{type:"button",onClick:()=>T(S?null:C),className:a("mf-fbm-chip",S&&"mf-fbm-chip--active"),children:C},C)})}),jsx("textarea",{value:x,onChange:C=>b(C.target.value),placeholder:"What went wrong? (optional)",rows:3,className:"mf-fbm-textarea"}),jsx("div",{className:"mf-fbm-actions",children:jsx("button",{type:"button",onClick:R,disabled:!y&&!x.trim(),className:"mf-fbm-submit",children:"Submit"})})]})]}),document.body)]})}var Fo=`
7
+ .mf-fbm-card {
8
+ width: 420px;
9
+ max-width: 100%;
10
+ background: #ffffff;
11
+ color: #111827;
12
+ border-radius: 12px;
13
+ box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
14
+ padding: 20px;
15
+ box-sizing: border-box;
16
+ }
17
+ .mf-fbm-header {
18
+ display: flex;
19
+ align-items: center;
20
+ justify-content: space-between;
21
+ margin-bottom: 12px;
22
+ }
23
+ .mf-fbm-title {
24
+ font-size: 15px;
25
+ font-weight: 600;
26
+ color: #111827;
27
+ }
28
+ .mf-fbm-close {
29
+ width: 28px;
30
+ height: 28px;
31
+ display: inline-flex;
32
+ align-items: center;
33
+ justify-content: center;
34
+ background: transparent;
35
+ border: none;
36
+ border-radius: 6px;
37
+ color: #6b7280;
38
+ cursor: pointer;
39
+ padding: 0;
40
+ }
41
+ .mf-fbm-close:hover {
42
+ background: rgba(0, 0, 0, 0.05);
43
+ color: #111827;
44
+ }
45
+ .mf-fbm-chips {
46
+ display: flex;
47
+ flex-wrap: wrap;
48
+ gap: 6px;
49
+ margin-bottom: 14px;
50
+ }
51
+ .mf-fbm-chip {
52
+ font-size: 12px;
53
+ line-height: 1;
54
+ padding: 6px 10px;
55
+ border-radius: 9999px;
56
+ border: 1px solid rgba(0, 0, 0, 0.18);
57
+ background: #ffffff;
58
+ color: #111827;
59
+ cursor: pointer;
60
+ transition: background 120ms, color 120ms, border-color 120ms;
61
+ }
62
+ .mf-fbm-chip:hover {
63
+ background: rgba(0, 0, 0, 0.04);
64
+ }
65
+ .mf-fbm-chip--active,
66
+ .mf-fbm-chip--active:hover {
67
+ background: #111827;
68
+ color: #ffffff;
69
+ border-color: #111827;
70
+ }
71
+ .mf-fbm-textarea {
72
+ width: 100%;
73
+ box-sizing: border-box;
74
+ font-family: inherit;
75
+ font-size: 13px;
76
+ line-height: 1.5;
77
+ color: #111827;
78
+ background: #f9fafb;
79
+ border: 1px solid rgba(0, 0, 0, 0.18);
80
+ border-radius: 8px;
81
+ padding: 10px 12px;
82
+ resize: none;
83
+ outline: none;
84
+ }
85
+ .mf-fbm-textarea:focus {
86
+ border-color: #111827;
87
+ }
88
+ .mf-fbm-textarea::placeholder {
89
+ color: rgba(0, 0, 0, 0.45);
90
+ }
91
+ .mf-fbm-actions {
92
+ display: flex;
93
+ justify-content: flex-end;
94
+ margin-top: 14px;
95
+ }
96
+ .mf-fbm-submit {
97
+ font-size: 13px;
98
+ font-weight: 500;
99
+ padding: 7px 14px;
100
+ border-radius: 8px;
101
+ border: none;
102
+ background: #111827;
103
+ color: #ffffff;
104
+ cursor: pointer;
105
+ transition: opacity 120ms;
106
+ }
107
+ .mf-fbm-submit:hover {
108
+ opacity: 0.9;
109
+ }
110
+ .mf-fbm-submit:disabled {
111
+ opacity: 0.4;
112
+ cursor: not-allowed;
113
+ }
114
+ `;function ca({attachments:e,onDownload:t,onPreview:a$1,className:n}){let[r,o]=useState(null);if(!e||e.length===0)return null;let s=l=>{if(t){t(l);return}if(l.url){let d=document.createElement("a");d.href=l.url,d.download=l.filename,d.target="_blank",document.body.appendChild(d),d.click(),document.body.removeChild(d);}},i=l=>{if(a$1){a$1(l);return}l.isImage&&l.url&&o(l.url);};return jsxs("div",{className:a("flex flex-wrap gap-1.5",n),children:[e.map(l=>jsx(Yo,{attachment:l,onDownload:()=>s(l),onPreview:()=>i(l)},l.id)),r&&jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",onClick:()=>o(null),children:[jsx("button",{className:"absolute top-4 right-4 p-2 text-white hover:bg-white/20 rounded-full transition-colors",onClick:()=>o(null),"aria-label":"Close",children:jsx(X,{size:24})}),jsx("img",{src:r,alt:"Preview",className:"max-w-[90vw] max-h-[90vh] object-contain",onClick:l=>l.stopPropagation()})]})]})}function Yo({attachment:e,onDownload:t,onPreview:a$1}){let n=e.humanReadableSize||Go(e.size);return jsxs("div",{className:a("inline-flex items-center gap-2 px-2.5 py-1.5 rounded-lg max-w-full","border border-[var(--chat-border)] bg-[var(--chat-panel-bg)]",e.isImage&&e.url&&"cursor-pointer hover:bg-[var(--chat-border)]/30"),onClick:e.isImage&&e.url?a$1:void 0,children:[jsx(qo,{mimeType:e.mimeType,size:14}),jsx("span",{className:"text-xs text-[var(--chat-text)] truncate min-w-0",children:e.filename}),n&&n!=="0 Bytes"&&jsx("span",{className:"text-[10px] text-[var(--chat-text-subtle)] flex-shrink-0",children:n}),e.url&&jsx("button",{onClick:r=>{r.stopPropagation(),t();},className:"p-0.5 hover:bg-[var(--chat-border)] rounded transition-colors flex-shrink-0","aria-label":"Download",children:jsx(Download,{size:12,className:"text-[var(--chat-text-subtle)]"})})]})}function qo({mimeType:e,size:t=14}){return e.startsWith("image/")?jsx(Image,{size:t,className:"text-[var(--chat-primary)] flex-shrink-0"}):e.startsWith("video/")?jsx(Video,{size:t,className:"text-[var(--chat-primary)] flex-shrink-0"}):e==="application/pdf"?jsx(FileText,{size:t,className:"text-red-500 flex-shrink-0"}):jsx(FileIcon,{size:t,className:"text-gray-500 flex-shrink-0"})}function Go(e){if(e===0)return "0 Bytes";let t=1024,a=["Bytes","KB","MB","GB"],n=Math.floor(Math.log(e)/Math.log(t));return parseFloat((e/Math.pow(t,n)).toFixed(2))+" "+a[n]}var yn="miiflow-reasoning-keyframes",da=`
115
+ @keyframes beamer{0%{left:-30%}100%{left:100%}}
116
+ @keyframes mf-halo{0%,100%{opacity:0;transform:translate(-50%,-50%) scale(.65)}50%{opacity:.5;transform:translate(-50%,-50%) scale(1)}}
117
+ @keyframes mf-wave{0%,80%,100%{opacity:.25;transform:translateY(0)}40%{opacity:1;transform:translateY(-1.5px)}}
118
+ @keyframes mf-caret{0%,100%{opacity:.95}50%{opacity:.15}}
119
+ @keyframes mf-rail-flow{0%{transform:translateY(-110%)}100%{transform:translateY(220%)}}
120
+ @keyframes mf-text-shimmer{0%{background-position:100% 0}100%{background-position:-100% 0}}
121
+ @keyframes mf-bars{0%,100%{transform:scaleY(.28)}50%{transform:scaleY(1)}}
122
+ @keyframes mf-led{0%,100%{opacity:.5}50%{opacity:1}}
123
+ @keyframes mf-scanline{0%{transform:translateX(-110%)}100%{transform:translateX(220%)}}
124
+ @keyframes mf-mono-blink{0%,49%{opacity:1}50%,100%{opacity:.45}}
125
+ @keyframes mf-row-enter{0%{opacity:0;transform:translateY(3px)}100%{opacity:1;transform:translateY(0)}}
126
+ @keyframes mf-halo-once{0%{opacity:0;transform:scale(.4)}38%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(1.55)}}
127
+ .mf-row-enter{animation:mf-row-enter 360ms cubic-bezier(.16,1,.3,1) both}
128
+ .mf-tool-mark{transition:transform 220ms cubic-bezier(.16,1,.3,1);transform-origin:50% 62%;will-change:transform}
129
+ .mf-tool-row:hover .mf-tool-mark{transform:rotate(-9deg) scale(1.08)}
130
+ @media (prefers-reduced-motion:reduce){.mf-row-enter{animation:none}.mf-tool-mark{transition:none}.mf-tool-row:hover .mf-tool-mark{transform:none}}
131
+ `;function Ae(e){if(typeof document>"u")return;let t=e?.getRootNode?.(),a=t instanceof ShadowRoot?t:document.head,n=a.querySelector(`#${yn}`);if(n){n.textContent!==da&&(n.textContent=da);return}let r=document.createElement("style");r.id=yn,r.textContent=da,a.appendChild(r);}function wt({status:e,size:t=20,className:a$1,kind:n}){let r=useRef(null);useEffect(()=>{Ae(r.current);},[]);let o=Math.max(t,16),s=n==="subagent",i=n==="tool";return jsxs("div",{ref:r,className:a("relative flex-shrink-0 flex items-center justify-center",a$1),style:{width:t,height:t},children:[e==="pending"&&jsx("span",{"aria-hidden":true,style:{width:7,height:7,borderRadius:"50%",border:"1.25px solid var(--chat-text-subtle)",opacity:.35,background:"transparent"}}),e==="running"&&jsxs(Fragment,{children:[jsx("span",{"aria-hidden":true,style:{position:"absolute",left:"50%",top:"50%",width:o,height:o,borderRadius:"50%",background:"radial-gradient(closest-side, color-mix(in srgb, var(--chat-activity, var(--chat-primary)) 55%, transparent), transparent 70%)",transform:"translate(-50%, -50%) scale(.55)",animation:"mf-halo 1.5s cubic-bezier(.16,1,.3,1) infinite",pointerEvents:"none"}}),i?jsx("span",{"aria-hidden":true,style:{position:"relative",width:5,height:5,background:"var(--chat-activity, var(--chat-primary))",boxShadow:"0 0 0 1.5px color-mix(in srgb, var(--chat-activity, var(--chat-primary)) 26%, transparent), 0 0 0 2.5px color-mix(in srgb, var(--chat-text) 6%, transparent)"}}):s?jsx("span",{"aria-hidden":true,style:{position:"relative",width:8,height:8,borderRadius:1.5,background:"var(--chat-activity, var(--chat-primary))",boxShadow:"0 0 0 1.5px color-mix(in srgb, var(--chat-activity, var(--chat-primary)) 26%, transparent), 0 0 0 2.5px color-mix(in srgb, var(--chat-text) 6%, transparent)"}}):jsx("span",{"aria-hidden":true,style:{position:"relative",width:7,height:7,borderRadius:"50%",background:"var(--chat-activity, var(--chat-primary))",boxShadow:"0 0 0 1.5px color-mix(in srgb, var(--chat-activity, var(--chat-primary)) 24%, transparent), 0 0 0 2.5px color-mix(in srgb, var(--chat-text) 6%, transparent)"}})]}),e==="completed"&&(s?jsxs("span",{"aria-hidden":true,style:{position:"relative",display:"inline-block",width:7,height:7},children:[jsx("span",{style:{position:"absolute",inset:0,border:"1.25px solid color-mix(in srgb, var(--chat-text) 32%, transparent)",boxSizing:"border-box"}}),jsx("span",{style:{position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)",width:2,height:2,background:"color-mix(in srgb, var(--chat-text) 60%, transparent)"}})]}):i?jsx("span",{"aria-hidden":true,style:{width:4,height:4,background:"color-mix(in srgb, var(--chat-text) 38%, transparent)",boxShadow:"inset 0 0 0 0.5px color-mix(in srgb, var(--chat-text) 65%, transparent)"}}):jsx("span",{"aria-hidden":true,style:{width:4,height:4,borderRadius:"50%",background:"color-mix(in srgb, var(--chat-text) 55%, transparent)"}})),e==="failed"&&jsx("span",{"aria-hidden":true,style:{position:"relative",width:12,height:12,display:"flex",alignItems:"center",justifyContent:"center",color:"var(--chat-error)",fontSize:12,lineHeight:1,fontWeight:600,transform:"translateY(-0.5px)"},children:"\xD7"})]})}function Jo(e,t){return t?e==="subagent"||t==="subagent"?6:e==="observation"||t==="observation"?12:e===t?4:9:0}function je({items:e,badgeSize:t=20,className:a$1}){let n=useRef(null);if(useEffect(()=>{Ae(n.current);},[]),e.length===0)return null;let r=t/2;return jsx("div",{ref:n,className:a("max-w-full",a$1),children:jsxs("div",{style:{position:"relative"},children:[e.length>1&&jsx("div",{"aria-hidden":true,style:{position:"absolute",left:r-.5,top:6,bottom:6,width:1,background:"color-mix(in srgb, var(--chat-text) 10%, transparent)",pointerEvents:"none"}}),jsx("div",{className:"flex flex-col",children:e.map((o,s)=>{let i=s===e.length-1,d=o.status==="running"&&!i,p=i?0:Jo(o.kind,e[s+1]?.kind);return jsxs("div",{className:"mf-row-enter",style:{display:"grid",gridTemplateColumns:`${t}px 1fr`,columnGap:"0.625rem",paddingBottom:p,position:"relative"},children:[jsxs("div",{className:"relative flex flex-col items-center flex-shrink-0",style:{paddingTop:4},children:[jsx(wt,{status:o.status,size:t,kind:o.kind}),d&&jsx("div",{"aria-hidden":true,style:{position:"absolute",left:"50%",transform:"translateX(-50%)",top:t+4,width:1,height:`calc(100% - ${t}px + 4px)`,overflow:"hidden",pointerEvents:"none"},children:jsx("div",{style:{position:"absolute",left:0,top:0,width:"100%",height:"55%",background:"linear-gradient(180deg, transparent 0%, color-mix(in srgb, var(--chat-activity, var(--chat-primary)) 70%, transparent) 50%, transparent 100%)",animation:"mf-rail-flow 1.6s cubic-bezier(.16,1,.3,1) infinite",willChange:"transform"}})})]}),jsx("div",{style:{minWidth:0,flex:1,display:"flex",alignItems:"center",position:"relative",overflow:"hidden",paddingTop:2,paddingBottom:2},children:o.content})]},o.id)})})]})})}function ei({status:e,isLast:t=false,badgeSize:a$1=20,children:n,className:r}){let o=useRef(null);useEffect(()=>{Ae(o.current);},[]);let i=e==="running"&&!t;return jsxs("div",{ref:o,className:a("relative flex items-start gap-2.5 animate-fade-in",!t&&"pb-3",r),children:[jsxs("div",{className:"relative flex-shrink-0",style:{paddingTop:4},children:[!t&&jsx("div",{"aria-hidden":true,style:{position:"absolute",left:a$1/2-.5,top:a$1+4,width:1,height:"calc(100% + 8px)",background:"color-mix(in srgb, var(--chat-text) 10%, transparent)",pointerEvents:"none"}}),jsx(wt,{status:e,size:a$1}),i&&jsx("div",{"aria-hidden":true,style:{position:"absolute",left:a$1/2-.5,top:a$1+4,width:1,height:"calc(100% + 8px)",overflow:"hidden",pointerEvents:"none"},children:jsx("div",{style:{position:"absolute",left:0,top:0,width:"100%",height:"55%",background:"linear-gradient(180deg, transparent 0%, color-mix(in srgb, var(--chat-activity, var(--chat-primary)) 70%, transparent) 50%, transparent 100%)",animation:"mf-rail-flow 1.6s cubic-bezier(.16,1,.3,1) infinite",willChange:"transform"}})})]}),jsx("div",{style:{minWidth:0,flex:1,position:"relative",overflow:"hidden",borderRadius:4},children:n})]})}function ri(){return jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.25",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":true,style:{flexShrink:0,display:"block"},children:jsx("path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"})})}var ma="ui-monospace, 'SFMono-Regular', 'JetBrains Mono', 'Fira Code', Menlo, Consolas, monospace",wn={backgroundImage:"linear-gradient(90deg, var(--chat-text) 0%, var(--chat-text) 40%, color-mix(in srgb, var(--chat-text) 35%, transparent) 50%, var(--chat-text) 60%, var(--chat-text) 100%)",backgroundSize:"200% 100%",backgroundRepeat:"repeat-x",backgroundClip:"text",WebkitBackgroundClip:"text",WebkitTextFillColor:"transparent",color:"transparent",animation:"mf-text-shimmer 2.4s linear infinite"};function Cn({seconds:e,maxSeconds:t}){let a=t>0?Math.min(1,Math.max(.08,e/t)):.2;return jsxs("span",{"aria-label":`${e.toFixed(1)} seconds`,style:{display:"inline-flex",flexDirection:"column",alignItems:"flex-end",gap:2,marginLeft:8,flexShrink:0,paddingTop:2},children:[jsxs("span",{className:"tabular-nums",style:{fontSize:11,color:"color-mix(in srgb, var(--chat-text) 45%, transparent)",fontVariantNumeric:"tabular-nums",letterSpacing:"0.01em",lineHeight:1},children:[e.toFixed(1),"s"]}),jsx("span",{"aria-hidden":true,style:{width:24,height:1.5,background:"color-mix(in srgb, var(--chat-text) 8%, transparent)",borderRadius:1,position:"relative",overflow:"hidden"},children:jsx("span",{style:{position:"absolute",left:0,top:0,height:"100%",width:`${a*100}%`,background:"color-mix(in srgb, var(--chat-activity, var(--chat-primary)) 60%, transparent)",borderRadius:1}})})]})}function ua({event:e,className:t,isRunning:a$1,maxDurationSeconds:n}){let r=useRef(null);useEffect(()=>{Ae(r.current);},[]);let o=e.durationSeconds!=null&&e.durationSeconds>.05;if(e.type==="thinking"||e.type==="planning")return jsxs("div",{ref:r,className:a("min-w-0 max-w-full",t),style:{paddingTop:1,paddingBottom:1,display:"flex",alignItems:"flex-start",gap:8},children:[jsx("div",{style:{lineHeight:1.6,letterSpacing:"-0.005em",fontWeight:a$1?480:400,flex:1,minWidth:0,...a$1?wn:{color:"color-mix(in srgb, var(--chat-text) 78%, transparent)"}},children:jsx(le,{className:"text-[14px]",children:e.content})}),o&&jsx(Cn,{seconds:e.durationSeconds,maxSeconds:n??e.durationSeconds})]});if(e.type==="tool"){let s=e.toolDescription?.trim(),i=!!s&&s.length>0,l=i?s:e.toolName||"Tool call";return jsxs("div",{ref:r,className:a("mf-tool-row inline-flex items-center gap-2.5 min-w-0 max-w-full",t),style:{position:"relative"},title:e.toolName,children:[jsx("span",{"aria-hidden":true,className:"mf-tool-mark",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,width:14,height:14,color:"color-mix(in srgb, var(--chat-activity, var(--chat-primary)) 70%, var(--chat-text))",opacity:.82},children:jsx(ri,{})}),jsxs("span",{style:{display:"inline-flex",alignItems:"center",fontFamily:i?void 0:ma,fontVariantLigatures:i?void 0:"none",fontSize:i?14:12.5,lineHeight:1.5,letterSpacing:"-0.005em",fontWeight:i?450:500,fontVariantNumeric:"tabular-nums",flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",...a$1?wn:{color:"color-mix(in srgb, var(--chat-text) 86%, transparent)"}},children:[jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0},children:l}),a$1&&jsx("span",{"aria-hidden":true,style:{display:"inline-block",width:2,height:"0.95em",background:"var(--chat-activity, var(--chat-primary))",marginLeft:4,animation:"mf-caret 1.05s cubic-bezier(.4,0,.6,1) infinite",borderRadius:1,flexShrink:0,WebkitTextFillColor:"currentColor",color:"var(--chat-activity, var(--chat-primary))",backgroundImage:"none",backgroundClip:"border-box",WebkitBackgroundClip:"border-box"}})]}),o&&jsx(Cn,{seconds:e.durationSeconds,maxSeconds:n??e.durationSeconds})]})}if(e.type==="observation"){let i=e.success!==false?"--chat-secondary":"--chat-warning";return jsxs("div",{ref:r,className:a("max-w-full overflow-auto",t),style:{padding:"8px 12px",borderRadius:3,background:`color-mix(in srgb, var(${i}) 4%, transparent)`,boxShadow:`inset 0 0 0 0.5px color-mix(in srgb, var(${i}) 22%, transparent)`},children:[jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:6,marginBottom:4},children:[jsx("span",{"aria-hidden":true,style:{width:3,height:3,background:`var(${i})`}}),jsx("span",{style:{fontFamily:ma,fontSize:9.5,fontWeight:700,letterSpacing:"0.16em",textTransform:"uppercase",color:`var(${i})`,fontVariantLigatures:"none"},children:"response"})]}),jsx("div",{className:"text-[var(--chat-text)]",children:jsx(le,{className:"text-[14px]",children:e.content})})]})}if(e.type==="subagent"){let s=e.subagentData,i=(s.nestedChunks??[]).map((l,d)=>Le(l,d)).filter(l=>l!==null);return s.result&&s.result.trim().length>0&&i.push({id:`result-${s.subagentId}`,type:"thinking",status:s.status==="failed"?"failed":"completed",content:s.result}),jsx(oi,{slug:s.subagentType||"sub-assistant",durationSeconds:s.durationMs!=null?s.durationMs/1e3:void 0,isRunning:s.status==="running",isFailed:s.status==="failed",defaultExpanded:false,nestedEvents:i})}return null}function oi({slug:e,durationSeconds:t,isRunning:a$1,isFailed:n,defaultExpanded:r,nestedEvents:o}){let[s,i]=useState(r),l=o.length>0,d=l,p=n?"var(--chat-error)":a$1?"color-mix(in srgb, var(--chat-text) 92%, transparent)":"color-mix(in srgb, var(--chat-text) 78%, transparent)";return jsxs("div",{className:"flex-1 min-w-0",children:[jsxs("div",{onClick:l?()=>i(v=>!v):void 0,className:a("inline-flex items-center gap-2 min-w-0 max-w-full",l&&"cursor-pointer"),style:{paddingTop:1,paddingBottom:1},children:[jsxs("span",{style:{display:"inline-flex",alignItems:"baseline",fontFamily:ma,fontSize:13,lineHeight:1.35,fontWeight:500,letterSpacing:0,color:p,fontVariantLigatures:"none",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0},children:[jsx("span",{"aria-hidden":true,style:{opacity:.55,marginRight:1,fontWeight:400},children:"@"}),e]}),t!=null&&t>0?jsxs("span",{className:"shrink-0 tabular-nums",style:{fontSize:11,color:"color-mix(in srgb, var(--chat-text) 50%, transparent)",fontVariantNumeric:"tabular-nums",letterSpacing:"0.01em"},children:[t.toFixed(1),"s"]}):a$1?jsx("span",{className:"shrink-0",style:{fontSize:11,color:"color-mix(in srgb, var(--chat-activity, var(--chat-primary)) 85%, transparent)",fontStyle:"italic",letterSpacing:"0.01em"},children:"running\u2026"}):null,d&&jsx("span",{"aria-hidden":true,className:"shrink-0 inline-flex items-center justify-center",style:{width:14,height:14,color:"color-mix(in srgb, var(--chat-text) 40%, transparent)",fontSize:11,lineHeight:1,transform:s?"rotate(90deg)":"rotate(0deg)",transition:"transform 220ms cubic-bezier(.16,1,.3,1)"},children:"\u203A"})]}),l&&s&&jsx("div",{className:"animate-fade-in",style:{marginTop:6,paddingLeft:14},children:jsx(Me,{events:o})})]})}var ii=["create_plan","tool_search","unknown","dispatch_assistant"];function Sn(e){return e?ii.includes(e.toLowerCase().trim()):false}function Le(e,t){if(e.toolName&&Sn(e.toolName))return null;if(e.type==="thinking")return !e.content||e.content.trim().length===0?null:{id:`thinking-${t}`,type:"thinking",status:"completed",content:e.content};if(e.type==="planning"){if(!e.content||e.content.trim().length===0)return null;let a=e.planData!==void 0||e.content.includes("\u2713 Created plan");return {id:`planning-${t}`,type:"planning",status:a?"completed":"running",content:e.content,isComplete:a}}if(e.type==="tool"){let a=e.status==="executing"?"running":e.status==="completed"?"completed":"pending";return {id:`tool-${t}`,type:"tool",status:a,toolName:e.toolName||"Unknown Tool",toolDescription:e.toolDescription}}if(e.type==="subagent"&&e.subagentData){let a=e.subagentData.status==="running"?"running":e.subagentData.status==="completed"?"completed":e.subagentData.status==="failed"?"failed":"pending";return {id:`subagent-${e.subagentData.subagentId}-${t}`,type:"subagent",status:a,subagentData:e.subagentData}}return null}function si(e){let t=[],a=[];e.forEach((n,r)=>{let o=typeof n.timestamp=="number"?n.timestamp:void 0;if(n.type==="thought"){let s=n.thought;if(!s||s.trim().length===0)return;t.push({id:`thought-${r}`,type:"thinking",status:"completed",content:s,timestamp:o}),a.push(o??NaN);}else if(n.type==="tool"){let s=n.tool||"Unknown Tool";if(Sn(s))return;t.push({id:`tool-${r}`,type:"tool",status:"completed",toolName:s,toolDescription:n.tool_description,timestamp:o}),a.push(o??NaN);}});for(let n=0;n<t.length-1;n++){let r=a[n],o=a[n+1];if(Number.isFinite(r)&&Number.isFinite(o)&&o>r){let s=o-r,i=s>1e3?s/1e3:s;i>0&&i<3600&&(t[n].durationSeconds=i);}}return t}function li(e){switch(e.type){case "thinking":return "thinking";case "planning":return "planning";case "tool":return "tool";case "observation":return "observation";case "subagent":return "subagent";default:return}}function Me({events:e,className:t}){if(e.length===0)return null;let a=e.reduce((r,o)=>o.durationSeconds&&o.durationSeconds>r?o.durationSeconds:r,0),n=e.map(r=>({id:r.id,status:r.status,kind:li(r),content:jsx(ua,{event:r,isRunning:r.status==="running",maxDurationSeconds:a}),bare:r.type==="subagent"}));return jsx(je,{items:n,badgeSize:20,className:t})}function at({label:e,description:t,durationSeconds:a$1,isFailed:n=false,defaultExpanded:r=false,nestedEvents:o,hideChevron:s=false}){let[i,l]=useState(r),d=!!(o&&o.length>0),p=d&&!s;return jsxs("div",{className:"flex-1 min-w-0",children:[jsxs("div",{onClick:p?()=>l(!i):void 0,className:a("flex items-center gap-2 min-w-0",p&&"cursor-pointer"),children:[jsx("span",{className:a("text-sm truncate",n?"text-[var(--chat-error)]":"text-[var(--chat-text)]"),style:{fontWeight:500,letterSpacing:"-0.005em"},children:e}),t&&jsx("span",{className:a("text-sm truncate flex-1",n?"text-[var(--chat-error)]":"text-[var(--chat-text-subtle)]"),children:t}),a$1!=null&&a$1>0&&jsxs("span",{className:"shrink-0 tabular-nums",style:{fontSize:11,color:"color-mix(in srgb, var(--chat-text) 50%, transparent)",fontVariantNumeric:"tabular-nums",letterSpacing:"0.01em"},children:[a$1.toFixed(1),"s"]}),p&&jsx("span",{"aria-hidden":true,className:"shrink-0 inline-flex items-center justify-center",style:{width:14,height:14,color:"color-mix(in srgb, var(--chat-text) 40%, transparent)",fontSize:11,lineHeight:1,transform:i?"rotate(90deg)":"rotate(0deg)",transition:"transform 220ms cubic-bezier(.16,1,.3,1)"},children:"\u203A"})]}),d&&i&&jsx("div",{className:"mt-2 pl-2 animate-fade-in",children:jsx(Me,{events:o})})]})}var di=["create_plan","tool_search","unknown"];function pi(e){return e?di.includes(e.toLowerCase().trim()):false}function mi(e){let t=[];return e.forEach((a,n)=>{if(a.type==="thinking"){if(!a.content||a.content.trim().length===0)return;t.push({id:`thinking-${n}`,type:"thinking",status:"completed",content:a.content});}else if(a.type==="tool"){if(pi(a.toolName))return;let r=a.status==="executing"?"running":a.status==="completed"?"completed":"pending";t.push({id:`tool-${n}`,type:"tool",status:r,toolName:a.toolName||"Unknown Tool",toolDescription:a.toolDescription});}}),t}function ui({subtask:e,executionChunks:t=[]}){let a=e.status==="failed",n=e.status==="completed",r=mi(t);return jsx(at,{label:e.description,description:a?e.error:void 0,durationSeconds:n?e.execution_time:void 0,isFailed:a,defaultExpanded:e.status==="running",nestedEvents:r})}function ga({plan:e,streamingChunks:t=[],className:a$1}){let n=e.subtasks.map(r=>{let o=t.filter(i=>i.subtaskId===r.id),s=r.status==="running"?"running":r.status==="completed"?"completed":r.status==="failed"?"failed":"pending";return {id:String(r.id),status:s,content:jsx(ui,{subtask:r,executionChunks:o})}});return jsxs("div",{className:a("space-y-2",a$1),children:[jsx("span",{className:"text-sm text-[var(--chat-text-subtle)]",children:"Plan:"}),jsx(je,{items:n,badgeSize:20})]})}function hi(e){let t=useRef(null),[a,n]=useState(0),r=useRef(0);return useEffect(()=>{if(e){t.current===null&&(t.current=Date.now());let o=setInterval(()=>{if(t.current!==null){let s=Math.floor((Date.now()-t.current)/1e3);n(s),r.current=s;}},1e3);return ()=>clearInterval(o)}else t.current!==null&&(r.current=Math.floor((Date.now()-t.current)/1e3),n(r.current),t.current=null);},[e]),{display:`${a}`,finalSeconds:r.current}}function bi(e){return e.some(t=>t.type==="subagent")}var xa=new Set(["create_plan","tool_search","unknown","dispatch_assistant"]);function xi(e){let t=[];return e.forEach(a=>{if(a.type==="thought"&&a.thought)t.push({type:"thinking",content:a.thought,subtaskId:a.subtask_id});else if(a.type==="tool"){let n=(a.tool||"").toLowerCase().trim();if(xa.has(n))return;t.push({type:"tool",content:"",toolName:a.tool||"Unknown Tool",toolDescription:a.tool_description,status:"completed",subtaskId:a.subtask_id}),a.observation&&t.push({type:"observation",content:a.observation,toolName:a.tool||"Unknown Tool",success:true,subtaskId:a.subtask_id});}}),t}function yi(e){return e<1?`${Math.round(e*1e3)}ms`:`${e.toFixed(1)}s`}var Tn="ui-monospace, 'SFMono-Regular', 'JetBrains Mono', 'Fira Code', Menlo, Consolas, monospace";function vi({isStreaming:e,justCompleted:t}){return jsx("span",{"aria-hidden":true,style:{position:"relative",display:"inline-flex",alignItems:"center",justifyContent:"center",width:14,height:14,flexShrink:0},children:e?jsx("span",{style:{display:"inline-flex",alignItems:"flex-end",gap:1.5,height:10},children:[0,1,2].map(a=>jsx("span",{style:{width:1.5,height:10,background:"var(--chat-activity, var(--chat-primary))",transformOrigin:"bottom",animation:"mf-bars 0.95s cubic-bezier(.16,1,.3,1) infinite",animationDelay:`${a*.13}s`,display:"inline-block"}},a))}):jsxs(Fragment,{children:[jsx("span",{style:{width:5,height:5,background:t?"var(--chat-activity, var(--chat-primary))":"color-mix(in srgb, var(--chat-text) 42%, transparent)",boxShadow:"inset 0 0 0 0.5px color-mix(in srgb, var(--chat-text) 70%, transparent)",transform:t?"scale(1.18)":"scale(1)",transition:"background 820ms cubic-bezier(.16,1,.3,1), transform 540ms cubic-bezier(.16,1,.3,1)",display:"inline-block"}}),t&&jsx("span",{style:{position:"absolute",left:"50%",top:"50%",width:14,height:14,marginLeft:-7,marginTop:-7,borderRadius:"50%",background:"radial-gradient(closest-side, color-mix(in srgb, var(--chat-activity, var(--chat-primary)) 38%, transparent), transparent 70%)",animation:"mf-halo-once 720ms cubic-bezier(.16,1,.3,1) forwards",pointerEvents:"none"}})]})})}function ya({isStreaming:e=false,chunks:t=[],plan:a$1,executionTimeline:n=[],userMessageTimestamp:r,executionTime:o,defaultExpanded:s=false,expanded:i,onExpandedChange:l,className:d}){let[p,v]=useState(s),{display:y,finalSeconds:T}=hi(e),x=useRef(null);useEffect(()=>{Ae(x.current);},[]);let b=useRef(null),[N,R]=useState(false);useEffect(()=>{let A=b.current===true&&e===false;if(b.current=e,A){R(true);let V=setTimeout(()=>R(false),820);return ()=>clearTimeout(V)}},[e]);let M=a$2(x,300),C=i??p,S=useCallback(A=>{M(),v(A),l?.(A);},[M,l]),f=useMemo(()=>e?t.map((A,V)=>Le(A,V)).filter(A=>A!==null):[],[e,t]),g=useMemo(()=>!e&&(n.length>0||t.length>0)?t.map((A,V)=>Le(A,V)).filter(A=>A!==null):[],[e,n,t]),E=useMemo(()=>!e&&n.length>0?xi(n):[],[e,n]),k=useMemo(()=>{if(o&&o>0)return o;if(!e){if(a$1?.subtasks)return a$1.subtasks.reduce((A,V)=>A+(V.execution_time||0),0);if(n.length>0){let A=n[n.length-1];if(r&&A.timestamp){let V=A.timestamp-r;if(V>0)return V}if(n.length>1){let V=n[0];if(V.timestamp&&A.timestamp){let P=A.timestamp-V.timestamp;if(P>0)return P}}}}return 0},[e,a$1,n,r,o]),u=useMemo(()=>{if(e)return null;let A=0,V=P=>{if(!P)return;let ee=P.toLowerCase().trim();xa.has(ee)||(A+=1);};if(t.length>0)for(let P of t)P.type==="tool"&&V(P.toolName);else if(n.length>0)for(let P of n)P.type==="tool"&&V(P.tool);return A===0?null:`${A} ${A===1?"source":"sources"}`},[e,t,n]);if(!e){let A=a$1||n.length>0||t.length>0;if(!A||A&&g.length===0&&!a$1&&n.length===0)return null}let w=t.length>0?t[t.length-1]:null,H=bi(t),$=()=>{if(H&&w?.type==="subagent"&&w?.subagentData)return w.subagentData.subagentType;let A=w?.toolName?.toLowerCase().trim(),V=!!A&&xa.has(A);if(!V&&w?.toolDescription)return w.toolDescription;if(!V&&w?.toolName)return w.toolName;switch(w?.type){case "planning":return "Planning\u2026";case "thinking":return "Thinking\u2026";case "tool":return "Thinking\u2026";case "observation":return "Analyzing results\u2026";case "progress":return "Working\u2026";default:return "Thinking\u2026"}},G=k>0?k:T>0?T:0,ye=a$1?.subtasks&&a$1.subtasks.length>=2;return jsxs("div",{ref:x,className:a("max-w-full",d),children:[jsxs("div",{onClick:()=>S(!C),style:{position:"relative",display:"inline-flex",alignItems:"center",gap:8,padding:"3px 8px 3px 3px",borderRadius:4,cursor:"pointer",transition:"background-color 220ms cubic-bezier(.16,1,.3,1)",background:e?"color-mix(in srgb, var(--chat-activity, var(--chat-primary)) 6%, transparent)":"transparent"},children:[jsx(vi,{isStreaming:e,justCompleted:N}),e&&jsxs(Fragment,{children:[jsx("span",{style:{fontSize:13.5,lineHeight:1.35,fontWeight:500,letterSpacing:"-0.005em",color:"color-mix(in srgb, var(--chat-text) 86%, transparent)",maxWidth:520,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:$()}),parseInt(y)>0&&jsxs("span",{className:"tabular-nums",style:{fontFamily:Tn,fontSize:11,color:"color-mix(in srgb, var(--chat-activity, var(--chat-primary)) 75%, var(--chat-text))",fontVariantNumeric:"tabular-nums",letterSpacing:"0.02em",fontWeight:600},children:[y,"s"]})]}),!e&&(u||G>0)&&jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,fontFamily:Tn,fontSize:11.5,fontWeight:500,letterSpacing:"0.005em",color:"color-mix(in srgb, var(--chat-text) 55%, transparent)",fontVariantNumeric:"tabular-nums",fontVariantLigatures:"none"},children:[G>0&&jsxs("span",{children:["Thought for ",yi(G)]}),G>0&&u&&jsx("span",{"aria-hidden":true,style:{width:2,height:2,borderRadius:"50%",background:"color-mix(in srgb, var(--chat-text) 28%, transparent)",display:"inline-block"}}),u&&jsx("span",{children:u})]}),jsx("span",{"aria-hidden":true,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:12,height:12,marginLeft:1,color:"color-mix(in srgb, var(--chat-text) 38%, transparent)",fontSize:11,lineHeight:1,transform:C?"rotate(90deg)":"rotate(0deg)",transition:"transform 240ms cubic-bezier(.16,1,.3,1)"},children:"\u203A"})]}),C&&jsxs("div",{className:"animate-fade-in",style:{position:"relative",marginTop:6},children:[jsx("div",{"aria-hidden":true,style:{position:"absolute",left:9.5,top:-6,width:1,height:10,background:"color-mix(in srgb, var(--chat-text) 10%, transparent)",pointerEvents:"none"}}),e?jsx(Me,{events:f}):a$1?a$1.subtasks?.length===0?null:ye?jsx(ga,{plan:a$1,streamingChunks:E}):jsx(Me,{events:g}):jsx(Me,{events:g})]})]})}var rt=forwardRef(({content:e,isStreaming:t=false,renderMarkdown:a$1=true,className:n,baselineFontSize:r,markdownProps:o},s)=>jsx(m,{ref:s,content:e,isStreaming:t,showCursor:false,className:a("relative",n),children:a$1?jsx(le,{baselineFontSize:r,...o,children:e}):jsx("span",{className:"whitespace-pre-wrap",children:e})}));rt.displayName="StreamingText";var Li={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 Di(e){return e?Li[e]||jsx(ArrowRight,{size:14}):jsx(ArrowRight,{size:14})}var St=forwardRef(({actions:e,onSelect:t,className:a$1,showIcons:n=true,disabled:r=false},o)=>{let[s,i]=useState(null);if(e.length===0)return null;let l=async(d,p)=>{if(!(!t||s!==null)){i(p);try{await t(d);}finally{i(null);}}};return jsx("div",{ref:o,role:"group","aria-label":"Suggested actions",className:a("flex flex-wrap gap-2",a$1),children:jsx(AnimatePresence,{children:e.map((d,p)=>{let v=s===p,y=r||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:p*.05},disabled:y,onClick:()=>l(d,p),className:a("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:[v?jsx(Loader2,{size:14,className:"animate-spin"}):n&&jsx("span",{className:"text-gray-400 dark:text-gray-500",children:Di(d.type)}),d.label]},d.id)})})})});St.displayName="SuggestedActions";var Gi=["#3B82F6","#10B981","#F59E0B","#EF4444","#8B5CF6","#EC4899","#06B6D4","#F97316"];function Et({data:e,config:t,isStreaming:a=false}){let{chartType:n,series:r,xAxis:o,yAxis:s}=e,i=t?.colors||Gi,l=t?.height||300,d=t?.legend!==false,p=t?.grid!==false,v=t?.tooltip!==false,y=t?.animate!==false&&!a,T=t?.stacked||false,b=(()=>{if(n==="pie")return (r[0]?.data||[]).map((g,E)=>({name:g.name||g.x||`Item ${E+1}`,value:g.value??g.y??0}));let S=new Map;return r.forEach(f=>{f.data.forEach(g=>{let E=g.x??g.name;S.has(E)||S.set(E,{x:E}),S.get(E)[f.name]=g.y??g.value??0;});}),Array.from(S.values())})(),N={data:b,margin:{top:10,right:30,left:0,bottom:0}},R={fontSize:12},M={backgroundColor:"#fff",border:"1px solid #e5e7eb",borderRadius:8};return jsx("div",{className:"w-full",style:{height:l},children:jsx(ResponsiveContainer,{width:"100%",height:"100%",children:(()=>{switch(n){case "line":return jsxs(LineChart,{...N,children:[p&&jsx(CartesianGrid,{strokeDasharray:"3 3",stroke:"#e5e7eb"}),jsx(XAxis,{dataKey:"x",...R,tickLine:false,padding:{left:10,right:10}}),jsx(YAxis,{...R,tickLine:false,width:40}),v&&jsx(Tooltip,{contentStyle:M}),d&&jsx(Legend,{}),r.map((S,f)=>jsx(Line,{type:"monotone",dataKey:S.name,stroke:S.color||i[f%i.length],strokeWidth:2,dot:false,activeDot:{r:4},isAnimationActive:y},S.name))]});case "bar":return jsxs(BarChart,{...N,children:[p&&jsx(CartesianGrid,{strokeDasharray:"3 3",stroke:"#e5e7eb"}),jsx(XAxis,{dataKey:"x",...R,tickLine:false,padding:{left:10,right:10}}),jsx(YAxis,{...R,tickLine:false,width:40}),v&&jsx(Tooltip,{contentStyle:M}),d&&jsx(Legend,{}),r.map((S,f)=>jsx(Bar,{dataKey:S.name,fill:S.color||i[f%i.length],stackId:T?"stack":void 0,isAnimationActive:y,radius:[4,4,0,0]},S.name))]});case "area":return jsxs(AreaChart,{...N,children:[p&&jsx(CartesianGrid,{strokeDasharray:"3 3",stroke:"#e5e7eb"}),jsx(XAxis,{dataKey:"x",...R,tickLine:false,padding:{left:10,right:10}}),jsx(YAxis,{...R,tickLine:false,width:40}),v&&jsx(Tooltip,{contentStyle:M}),d&&jsx(Legend,{}),r.map((S,f)=>jsx(Area,{type:"monotone",dataKey:S.name,stroke:S.color||i[f%i.length],fill:S.color||i[f%i.length],fillOpacity:.3,stackId:T?"stack":void 0,isAnimationActive:y},S.name))]});case "pie":return jsxs(PieChart,{children:[v&&jsx(Tooltip,{contentStyle:M}),d&&jsx(Legend,{}),jsx(Pie,{data:b,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",outerRadius:Math.min(l,300)/3,isAnimationActive:y,label:({name:S,percent:f})=>`${S}: ${((f??0)*100).toFixed(0)}%`,labelLine:false,children:b.map((S,f)=>jsx(Cell,{fill:i[f%i.length]},`cell-${f}`))})]});case "scatter":return jsxs(ScatterChart,{...N,children:[p&&jsx(CartesianGrid,{strokeDasharray:"3 3",stroke:"#e5e7eb"}),jsx(XAxis,{dataKey:"x",type:"number",...R,tickLine:false,name:o?.label,padding:{left:10,right:10}}),jsx(YAxis,{...R,tickLine:false,name:s?.label,width:40}),v&&jsx(Tooltip,{contentStyle:M}),d&&jsx(Legend,{}),r.map((S,f)=>jsx(Scatter,{name:S.name,data:S.data.map(g=>({x:g.x,y:g.y})),fill:S.color||i[f%i.length],isAnimationActive:y},S.name))]});default:return null}})()||jsx(Fragment,{})})})}var as=new Set(["number","currency","date","badge","boolean","progress"]);function Rn(e){if(e==null)return "";if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e);try{return JSON.stringify(e)}catch{return String(e)}}function ns({text:e,anchorRect:t,onEnter:a$1,onLeave:n}){let[r,o]=useState(false);if(typeof document>"u")return null;let s=16,i=Math.min(360,window.innerWidth-2*s),l=window.innerHeight-t.bottom-s,d=l>=120||l>=t.top,p=t.left;p+i>window.innerWidth-s&&(p=Math.max(s,window.innerWidth-i-s));let v={position:"fixed",left:p,width:"max-content",maxWidth:i,maxHeight:"50vh",zIndex:9998,...d?{top:t.bottom+4}:{bottom:window.innerHeight-t.top+4}},y=async()=>{try{await navigator.clipboard.writeText(e),o(!0),window.setTimeout(()=>o(!1),1200);}catch{}};return createPortal(jsxs("div",{style:v,className:a("relative overflow-hidden rounded-md border border-gray-200 bg-white shadow-lg","dark:border-gray-700 dark:bg-gray-900"),role:"tooltip",onMouseEnter:a$1,onMouseLeave:n,children:[jsx("div",{className:a("select-text overflow-auto px-2.5 py-1.5 pr-8 text-sm text-gray-900 dark:text-gray-100","whitespace-pre-wrap break-words"),style:{maxHeight:"50vh"},children:e||jsx("span",{className:"text-gray-400",children:"\u2014"})}),jsx("button",{type:"button",onClick:y,"aria-label":r?"Copied":"Copy",title:r?"Copied":"Copy",className:a("absolute bottom-1 right-1 flex h-6 w-6 items-center justify-center","rounded text-gray-500 transition-colors","hover:bg-gray-100 hover:text-gray-800","dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-gray-100"),children:r?jsx(Check,{size:12}):jsx(Copy,{size:12})})]}),document.body)}function rs({item:e,onOpen:t}){if(e.mediaType==="video"){let a=e.url.match(Ee),n=a?a[1]:null,r=n?`https://i.ytimg.com/vi/${n}/hqdefault.jpg`:void 0;return jsxs("button",{type:"button",onClick:t,className:"relative block overflow-hidden rounded-md border-0 bg-black/5 p-0",style:{width:72,height:72},"aria-label":e.altText||"Open video",children:[r?jsx("img",{src:r,alt:e.altText||"Video preview",className:"h-full w-full object-cover",loading:"lazy"}):jsx("div",{className:"flex h-full w-full items-center justify-center bg-gray-900 text-[10px] text-gray-400",children:"Video"}),jsx(Ke,{label:e.altText||"Open video"})]})}return jsx("button",{type:"button",onClick:t,className:"block overflow-hidden rounded-md border-0 bg-transparent p-0 transition-opacity hover:opacity-80",style:{width:72,height:72},"aria-label":e.altText||"Open image",children:jsx("img",{src:e.url,alt:e.altText||"Image",className:"h-full w-full object-cover",loading:"lazy"})})}var os={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 In(e,t){if(e==null)return jsx("span",{className:"text-gray-400",children:"-"});switch(t.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 n=String(e).toLowerCase().replace(/\s+/g,"_"),r=os[n]||"bg-gray-100 text-gray-700";return jsx("span",{className:a("inline-block px-2 py-0.5 rounded-full text-xs font-medium",r),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 n=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,n))}%`}})}),jsxs("span",{className:"text-xs text-gray-500",children:[n.toFixed(0),"%"]})]})}default:return String(e)}}function Ln(e,t,a){let n=e[a],r=t[a];return n==null?1:r==null?-1:typeof n=="number"&&typeof r=="number"?r-n:String(r).localeCompare(String(n))}function At({data:e,config:t,medias:a$1}){let{columns:n,rows:r}=e,o=t?.sortable!==false,s=t?.paginated||false,i=t?.pageSize||10,[l,d]=useState("asc"),[p,v]=useState(n[0]?.key||""),[y,T]=useState(0),x=P=>{d(p===P&&l==="asc"?"desc":"asc"),v(P);},b=useMemo(()=>{let P=[...r];return o&&p&&P.sort((ee,U)=>l==="desc"?Ln(ee,U,p):-Ln(ee,U,p)),s&&(P=P.slice(y*i,(y+1)*i)),P},[r,l,p,y,i,o,s]),N=Math.ceil(r.length/i),R=useMemo(()=>{let P=[],ee={},U=n.filter(q=>q.type==="media");return U.length===0?{items:P,lookup:ee}:(b.forEach((q,Pe)=>{U.forEach(Y=>{let fe=q[Y.key],He=Jt(fe,`${Y.key}-${Pe}`,a$1);He&&(ee[`${Pe}::${Y.key}`]=P.length,P.push(He));});}),{items:P,lookup:ee})},[b,n,a$1]),{index:M,open:C,close:S,navigate:f}=xt(R.items),[g,E]=useState(null),k=useRef(null),u=useRef(null),w=()=>{k.current!==null&&(window.clearTimeout(k.current),k.current=null);},H=()=>{u.current!==null&&(window.clearTimeout(u.current),u.current=null);},$=(P,ee,U)=>{w(),H(),k.current=window.setTimeout(()=>{E({rowIdx:P,colKey:ee,rect:U}),k.current=null;},250);},G=()=>{w(),H(),u.current=window.setTimeout(()=>{E(null),u.current=null;},150);},ye=()=>{H();};useEffect(()=>()=>{w(),H();},[]),useEffect(()=>{M!==null&&(w(),H(),E(null));},[M]);let A=g&&n.find(P=>P.key===g.colKey),V=g&&A?Rn(b[g.rowIdx]?.[g.colKey]):"";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:n.map(P=>jsx("th",{className:a("px-3 py-2 font-semibold bg-gray-50 dark:bg-gray-800 whitespace-nowrap text-left",o&&P.type!=="media"&&"cursor-pointer select-none hover:bg-gray-100 dark:hover:bg-gray-700"),style:{width:P.width,textAlign:P.align||"left"},onClick:()=>o&&P.type!=="media"&&x(P.key),children:jsxs("span",{className:"inline-flex items-center gap-1",children:[P.label,o&&P.type!=="media"&&p===P.key&&(l==="asc"?jsx(ChevronUp,{size:14}):jsx(ChevronDown,{size:14}))]})},P.key))})}),jsxs("tbody",{children:[b.map((P,ee)=>jsx("tr",{className:"border-t border-gray-100 dark:border-gray-800 hover:bg-gray-50 dark:hover:bg-gray-800/50",children:n.map(U=>{if(U.type==="media"){let Y=Jt(P[U.key],`${U.key}-${ee}`,a$1);return jsx("td",{className:"px-3 py-2 align-middle",style:{textAlign:U.align||"left"},children:Y?jsx(rs,{item:Y,onOpen:()=>{let fe=R.lookup[`${ee}::${U.key}`];typeof fe=="number"&&C(fe);}}):jsx("span",{className:"text-gray-400",children:"-"})},U.key)}let q=as.has(U.type||"string"),Pe=Rn(P[U.key]);return jsx("td",{className:a("px-3 py-2 align-top",q?"max-w-[300px]":"max-w-[320px]"),style:{textAlign:U.align||"left"},onMouseEnter:Y=>{if(!Pe)return;let fe=Y.currentTarget.getBoundingClientRect();$(ee,U.key,fe);},onMouseLeave:()=>{G();},children:q?jsx("div",{className:"overflow-hidden whitespace-nowrap text-ellipsis",children:In(P[U.key],U)}):jsx("div",{className:"whitespace-normal break-words [display:-webkit-box] [-webkit-line-clamp:2] [-webkit-box-orient:vertical] overflow-hidden",children:In(P[U.key],U)})},U.key)})},ee)),b.length===0&&jsx("tr",{children:jsx("td",{colSpan:n.length,className:"px-3 py-8 text-center text-gray-400",children:"No data available"})})]})]}),g&&A&&M===null&&jsx(ns,{text:V,anchorRect:g.rect,onEnter:ye,onLeave:G}),M!==null&&jsx(bt,{items:R.items,index:M,onClose:S,onNavigate:f}),s&&r.length>i&&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:[y*i+1,"-",Math.min((y+1)*i,r.length)," of ",r.length]}),jsxs("div",{className:"flex gap-1",children:[jsx("button",{onClick:()=>T(Math.max(0,y-1)),disabled:y===0,className:"px-2 py-1 rounded hover:bg-gray-100 dark:hover:bg-gray-800 disabled:opacity-30",children:"Prev"}),jsx("button",{onClick:()=>T(Math.min(N-1,y+1)),disabled:y>=N-1,className:"px-2 py-1 rounded hover:bg-gray-100 dark:hover:bg-gray-800 disabled:opacity-30",children:"Next"})]})]})]})}function Mt({data:e,config:t,onAction:a$1}){let{subtitle:n,imageUrl:r,sections:o,actions:s}=e,i=t?.collapsible||false,l=t?.initiallyCollapsed||false,[d,p]=useState(!l),v=x=>{x.startsWith("http://")||x.startsWith("https://")||x.startsWith("/")?window.open(x,"_blank","noopener,noreferrer"):a$1?a$1({type:"card_action",action:x}):window.dispatchEvent(new CustomEvent("visualization-action",{detail:{action:x}}));},y=(x,b)=>jsxs("div",{className:a(b<o.length-1&&"mb-4"),children:[x.title&&jsx("h4",{className:"font-semibold text-sm mb-2",children:x.title}),x.items&&x.items.length>0&&jsx("div",{className:"space-y-1",children:x.items.map((N,R)=>jsxs("div",{className:"flex justify-between items-start gap-4",children:[jsx("span",{className:"text-sm text-gray-500 shrink-0",children:N.label}),jsx("span",{className:"text-sm font-medium text-right",children:N.value})]},R))}),x.content&&jsx(le,{children:x.content})]},b),T=jsxs(Fragment,{children:[r&&jsx("img",{src:r,alt:"",className:"w-full h-[140px] object-cover border-b border-gray-200 dark:border-gray-700"}),n&&jsx("p",{className:"text-sm text-gray-500 italic mb-4",children:n}),o.map((x,b)=>jsxs("div",{children:[y(x,b),b<o.length-1&&jsx("hr",{className:"my-4 border-gray-200 dark:border-gray-700"})]},b))]});return jsxs("div",{className:"w-full",children:[i&&jsxs("div",{className:"flex items-center justify-between mb-2 cursor-pointer",onClick:()=>p(!d),children:[jsx("span",{className:"text-sm text-gray-500",children:d?"Click to collapse":"Click to expand"}),jsx("button",{className:"p-1",children:d?jsx(ChevronUp,{size:18}):jsx(ChevronDown,{size:18})})]}),(!i||d)&&T,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((x,b)=>jsxs("button",{onClick:()=>v(x.action),className:a("px-3 py-1.5 text-sm rounded-lg transition-colors",x.variant==="primary"?"bg-blue-500 text-white hover:bg-blue-600":x.variant==="text"?"text-blue-500 hover:bg-blue-50":"border border-gray-300 hover:bg-gray-50"),children:[x.label,x.action.startsWith("http")&&jsx(ExternalLink,{size:14,className:"inline ml-1"})]},b))})]})}var ps=["#3B82F6","#10B981","#F59E0B","#8B5CF6"],Vn=[{label:"text-blue-700 dark:text-blue-300",stripeFrom:"#3b82f6",stripeTo:"#2563eb",tintFrom:"rgba(59,130,246,0.10)",tintMid:"rgba(59,130,246,0.025)",border:"border-blue-200 dark:border-blue-900",borderHover:"hover:border-blue-400 dark:hover:border-blue-700",spark:"#3b82f6",glow:"0 8px 24px rgba(59,130,246,0.18)"},{label:"text-emerald-700 dark:text-emerald-300",stripeFrom:"#10b981",stripeTo:"#059669",tintFrom:"rgba(16,185,129,0.10)",tintMid:"rgba(16,185,129,0.025)",border:"border-emerald-200 dark:border-emerald-900",borderHover:"hover:border-emerald-400 dark:hover:border-emerald-700",spark:"#10b981",glow:"0 8px 24px rgba(16,185,129,0.18)"},{label:"text-purple-700 dark:text-purple-300",stripeFrom:"#a855f7",stripeTo:"#9333ea",tintFrom:"rgba(168,85,247,0.10)",tintMid:"rgba(168,85,247,0.025)",border:"border-purple-200 dark:border-purple-900",borderHover:"hover:border-purple-400 dark:hover:border-purple-700",spark:"#a855f7",glow:"0 8px 24px rgba(168,85,247,0.18)"},{label:"text-orange-700 dark:text-orange-300",stripeFrom:"#f97316",stripeTo:"#ea580c",tintFrom:"rgba(249,115,22,0.10)",tintMid:"rgba(249,115,22,0.025)",border:"border-orange-200 dark:border-orange-900",borderHover:"hover:border-orange-400 dark:hover:border-orange-700",spark:"#f97316",glow:"0 8px 24px rgba(249,115,22,0.18)"},{label:"text-pink-700 dark:text-pink-300",stripeFrom:"#ec4899",stripeTo:"#db2777",tintFrom:"rgba(236,72,153,0.10)",tintMid:"rgba(236,72,153,0.025)",border:"border-pink-200 dark:border-pink-900",borderHover:"hover:border-pink-400 dark:hover:border-pink-700",spark:"#ec4899",glow:"0 8px 24px rgba(236,72,153,0.18)"},{label:"text-teal-700 dark:text-teal-300",stripeFrom:"#14b8a6",stripeTo:"#0d9488",tintFrom:"rgba(20,184,166,0.10)",tintMid:"rgba(20,184,166,0.025)",border:"border-teal-200 dark:border-teal-900",borderHover:"hover:border-teal-400 dark:hover:border-teal-700",spark:"#14b8a6",glow:"0 8px 24px rgba(20,184,166,0.18)"}];function ms(e){return Vn[e%Vn.length]}function us({metric:e,color:t,animate:a$1}){let n=e.trend==="up"?jsx(ArrowUp,{size:16,className:"text-green-500"}):e.trend==="down"?jsx(ArrowDown,{size:16,className:"text-red-500"}):e.trend==="neutral"?jsx(Minus,{size:14,className:"text-gray-400"}):null,r=e.trend==="up"?"text-green-500":e.trend==="down"?"text-red-500":"text-gray-500",o=e.sparkline?.map((s,i)=>({value:s,idx:i}));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||t,fill:e.color||t,strokeWidth:1,isAnimationActive:a$1})})})}),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!==void 0&&e.change!==null)&&jsxs("div",{className:"flex items-center gap-1 mt-2",children:[n,e.change!==void 0&&e.change!==null&&jsx("span",{className:a("text-sm font-medium",r),children:typeof e.change=="number"?`${e.change>0?"+":""}${e.change}`:e.change}),e.changeLabel&&jsx("span",{className:"text-xs text-gray-500",children:e.changeLabel})]})]})]})}function ka({metric:e,index:t,isHero:a$1,animate:n}){let r=ms(t),o=e.sparkline?.map((p,v)=>({value:p,idx:v})),s=a$1&&o&&o.length>1,i=e.trend==="up"?ArrowUp:e.trend==="down"?ArrowDown:Minus,l=e.trend==="up"?"bg-emerald-100 text-emerald-700 dark:bg-emerald-900/40 dark:text-emerald-300":e.trend==="down"?"bg-red-100 text-red-700 dark:bg-red-900/40 dark:text-red-300":"bg-gray-100 text-gray-600 dark:bg-gray-800 dark:text-gray-300",d=e.change!==void 0&&e.change!==null;return jsxs("div",{className:a("relative h-full rounded-xl border bg-white dark:bg-gray-900 overflow-hidden transition-all",r.border,r.borderHover,"hover:-translate-y-0.5",a$1?"p-5":"p-4"),style:{background:a$1?`linear-gradient(135deg, ${r.tintFrom} 0%, ${r.tintMid} 60%, transparent 100%), var(--kpi-bg, white)`:void 0},children:[jsx("div",{"aria-hidden":true,className:"absolute left-0 top-0 bottom-0",style:{width:a$1?4:3,background:`linear-gradient(180deg, ${r.stripeFrom}, ${r.stripeTo})`}}),s&&jsx("div",{"aria-hidden":true,className:"absolute left-0 right-0 bottom-0 pointer-events-none",style:{height:56,opacity:.35},children:jsx(ResponsiveContainer,{width:"100%",height:"100%",children:jsxs(AreaChart,{data:o,margin:{top:0,right:0,left:0,bottom:0},children:[jsx("defs",{children:jsxs("linearGradient",{id:`spark-${t}`,x1:"0",y1:"0",x2:"0",y2:"1",children:[jsx("stop",{offset:"0%",stopColor:r.spark,stopOpacity:.6}),jsx("stop",{offset:"100%",stopColor:r.spark,stopOpacity:0})]})}),jsx(Area,{type:"monotone",dataKey:"value",stroke:r.spark,fill:`url(#spark-${t})`,strokeWidth:1.5,isAnimationActive:n})]})})}),jsxs("div",{className:a("relative z-10",a$1?"pl-1":"pl-0.5"),children:[jsx("span",{className:a("block font-semibold uppercase tracking-wider",r.label,a$1?"text-xs":"text-[0.7rem]"),children:e.label}),jsxs("div",{className:a("flex items-baseline gap-1",a$1?"mt-2":"mt-1"),children:[jsx("span",{className:a("font-extrabold tabular-nums text-gray-900 dark:text-gray-100 leading-tight tracking-tight",a$1?"text-4xl sm:text-5xl":"text-2xl"),children:e.value}),e.unit&&jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400 font-medium",children:e.unit})]}),(d||e.changeLabel)&&jsxs("div",{className:a("flex items-center gap-1.5 flex-wrap",a$1?"mt-3":"mt-2"),children:[d&&jsxs("span",{className:a("inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-bold tabular-nums",l),children:[jsx(i,{size:a$1?14:12,strokeWidth:2.5}),typeof e.change=="number"?`${e.change>0?"+":""}${e.change}`:e.change]}),e.changeLabel&&jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:e.changeLabel})]})]})]})}function fs(e){let t=e.findIndex(a=>a.prominence==="primary");return t>=0?t:0}function gs({metrics:e,animate:t}){if(e.length===0)return null;if(e.length===1)return jsx("div",{className:"w-full",children:jsx(ka,{metric:e[0],index:0,isHero:true,animate:t})});let a$1=fs(e),n=e[a$1],r=e.map((l,d)=>({m:l,i:d})).filter(({i:l})=>l!==a$1),o=r.length,s=o<=3?Math.max(2,o):o>=7?3:2;return jsxs("div",{className:"w-full grid gap-4 md:[grid-template-columns:minmax(0,5fr)_minmax(0,7fr)] items-stretch",children:[jsx("div",{className:"md:min-h-[220px]",children:jsx(ka,{metric:n,index:a$1,isHero:true,animate:t})}),jsx("div",{className:a("grid gap-4 grid-cols-2",s===2?"sm:grid-cols-2":s===3?"sm:grid-cols-3":"sm:grid-cols-2"),children:r.map(({m:l,i:d})=>jsx(ka,{metric:l,index:d,isHero:false,animate:t},d))})]})}function Rt({data:e,config:t,isStreaming:a$1=false}){let{metrics:n,layout:r="row"}=e,o=t?.colors||ps,s=t?.animate!==false&&!a$1;if(r==="bento")return jsx("div",{className:"w-full",children:jsx(gs,{metrics:n,animate:s})});let i=r==="grid";return jsx("div",{className:a("w-full",i?"grid grid-cols-1 sm:grid-cols-2 gap-4":"flex gap-4 flex-wrap"),children:n.map((l,d)=>jsx("div",{className:a(!i&&"flex-1 min-w-[200px]"),children:jsx(us,{metric:l,color:l.color||o[d%o.length],animate:s})},d))})}var Cs={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 It({data:e}){let{code:t,language:a,lineNumbers:n=true,highlightLines:r=[],startLine:o=1}=e,[s,i]=useState(false),l=Cs[a.toLowerCase()]||a.toLowerCase(),d=async()=>{try{await navigator.clipboard.writeText(t),i(!0);}catch{}};return useEffect(()=>{if(s){let v=setTimeout(()=>i(false),2e3);return ()=>clearTimeout(v)}},[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:l})]}),jsx("button",{onClick:d,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:l,style:oneDark,showLineNumbers:n,startingLineNumber:o,wrapLines:true,lineProps:v=>{let y={};return r.includes(v)&&(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:t.trim()})]})}function Lt({data:e,config:t,isStreaming:a$1=false,onAction:n}){let{fields:r,submitAction:o}=e,s=t?.submitButtonText||"Submit",i=t?.cancelButtonText||"Cancel",[l,d]=useState(()=>{let f={};return r.forEach(g=>{g.defaultValue!==void 0?f[g.name]=g.defaultValue:g.type==="multiselect"?f[g.name]=[]:g.type==="checkbox"?f[g.name]=false:f[g.name]="";}),f}),[p,v]=useState({}),[y,T]=useState(false),x=(f,g)=>{d(E=>({...E,[f]:g})),p[f]&&v(E=>{let k={...E};return delete k[f],k});},b=()=>{let f={};return r.forEach(g=>{let E=l[g.name];if(g.required&&(E==null||E===""||Array.isArray(E)&&E.length===0)){f[g.name]=`${g.label} is required`;return}if(!(!E&&!g.required)){if(g.validation){let{min:k,max:u,pattern:w,message:H}=g.validation;k!==void 0&&typeof E=="number"&&E<k&&(f[g.name]=H||`Minimum value is ${k}`),u!==void 0&&typeof E=="number"&&E>u&&(f[g.name]=H||`Maximum value is ${u}`),w&&typeof E=="string"&&!new RegExp(w).test(E)&&(f[g.name]=H||"Invalid format");}g.type==="email"&&typeof E=="string"&&E&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(E)&&(f[g.name]="Invalid email address");}}),v(f),Object.keys(f).length===0},N=f=>{f.preventDefault(),b()&&(n?n({type:"form_submit",action:o||"",data:l}):window.dispatchEvent(new CustomEvent("visualization-form-submit",{detail:{action:o,data:l}})),T(true));},R=()=>{n?n({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 M="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",C="border-red-500 focus:ring-red-500/20 focus:border-red-500",S=f=>{let g=l[f.name],k=!!p[f.name];switch(f.type){case "text":case "email":case "number":return jsx("input",{type:f.type,placeholder:f.placeholder,required:f.required,value:String(g||""),onChange:u=>x(f.name,f.type==="number"?parseFloat(u.target.value)||"":u.target.value),className:a(M,k&&C),min:f.validation?.min,max:f.validation?.max});case "textarea":return jsx("textarea",{placeholder:f.placeholder,required:f.required,value:String(g||""),onChange:u=>x(f.name,u.target.value),className:a(M,"min-h-[100px] resize-y",k&&C),rows:4});case "select":return jsxs("select",{value:String(g||""),onChange:u=>x(f.name,u.target.value),className:a(M,k&&C),children:[jsx("option",{value:"",disabled:true,children:f.placeholder||"Select an option"}),f.options?.map(u=>jsx("option",{value:u.value,children:u.label},u.value))]});case "multiselect":return jsx("select",{multiple:true,value:g||[],onChange:u=>x(f.name,Array.from(u.target.selectedOptions,w=>w.value)),className:a(M,"min-h-[80px]",k&&C),children:f.options?.map(u=>jsx("option",{value:u.value,children:u.label},u.value))});case "checkbox":return jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[jsx("input",{type:"checkbox",checked:!!g,onChange:u=>x(f.name,u.target.checked),className:"w-4 h-4 accent-blue-500 rounded"}),jsx("span",{className:"text-sm",children:f.label})]});case "radio":return jsx("div",{className:"space-y-1",children:f.options?.map(u=>jsxs("label",{className:"flex items-center gap-2 cursor-pointer text-sm",children:[jsx("input",{type:"radio",name:f.name,value:u.value,checked:g===u.value,onChange:w=>x(f.name,w.target.value),className:"w-3.5 h-3.5 accent-blue-500"}),u.label]},u.value))});case "date":return jsx("input",{type:"date",value:String(g||""),onChange:u=>x(f.name,u.target.value),className:a(M,k&&C)});case "datetime":return jsx("input",{type:"datetime-local",value:String(g||""),onChange:u=>x(f.name,u.target.value),className:a(M,k&&C)});default:return null}};return jsxs("form",{onSubmit:N,className:"space-y-4",children:[r.map(f=>jsxs("div",{children:[f.type!=="checkbox"&&jsxs("label",{className:"block text-sm font-medium mb-1",children:[f.label,f.required&&jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]}),S(f),p[f.name]&&jsx("p",{className:"text-xs text-red-500 mt-1",children:p[f.name]})]},f.name)),jsxs("div",{className:"flex gap-2 pt-2",children:[jsx("button",{type:"submit",disabled:a$1,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:R,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:i})]})]})}var On="__miiflow_visualization_registry__",Dt=globalThis[On]??(globalThis[On]=new Map);function Be(e,t){Dt.set(e,t);}function Vt(e){return Dt.get(e)}function Wn(){return Array.from(Dt.keys())}Be("chart",{component:Et});Be("table",{component:At});Be("card",{component:Mt});Be("kpi",{component:Rt});Be("code_preview",{component:It});Be("form",{component:Lt});function Kn(e){for(let[t,a]of Object.entries(e)){let n=Dt.get(t);n&&(n.schema=a);}}var Ns=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().nullish()}),Un=z.object({label:z.string().nullish(),type:z.enum(["category","number","time"]).nullish(),min:z.number().nullish(),max:z.number().nullish()}),Na=z.object({chartType:z.enum(["line","bar","pie","area","scatter","composed"]),series:z.array(Ns),xAxis:Un.nullish(),yAxis:Un.nullish()}),Ss=z.object({key:z.string(),label:z.string(),type:z.enum(["string","number","currency","date","badge","link","boolean","progress","media"]).nullish(),align:z.enum(["left","center","right"]).nullish(),width:z.string().nullish()}),Sa=z.object({columns:z.array(Ss),rows:z.array(z.record(z.string(),z.unknown()))}),Ts=z.object({title:z.string().nullish(),items:z.array(z.object({label:z.string(),value:z.union([z.string(),z.number()])})).nullish(),content:z.string().nullish()}),Ps=z.object({label:z.string(),action:z.string(),variant:z.enum(["primary","secondary","text"]).nullish()}),Ta=z.object({subtitle:z.string().nullish(),imageUrl:z.string().nullish(),sections:z.array(Ts),actions:z.array(Ps).nullish()}),zs=z.object({label:z.string(),value:z.union([z.string(),z.number()]),unit:z.string().nullish(),trend:z.enum(["up","down","neutral"]).nullish(),change:z.union([z.string(),z.number()]).nullish(),changeLabel:z.string().nullish(),sparkline:z.array(z.number()).nullish(),color:z.string().nullish()}),Pa=z.object({metrics:z.array(zs),layout:z.enum(["row","grid","bento"]).nullish()}),za=z.object({code:z.string(),language:z.string(),lineNumbers:z.boolean().nullish(),highlightLines:z.array(z.number()).nullish(),startLine:z.number().nullish()}),Es=z.object({name:z.string(),type:z.enum(["text","number","email","select","multiselect","checkbox","radio","textarea","date","datetime"]),label:z.string(),required:z.boolean().nullish(),placeholder:z.string().nullish(),options:z.array(z.object({value:z.string(),label:z.string()})).nullish(),defaultValue:z.unknown().nullish(),validation:z.object({min:z.number().nullish(),max:z.number().nullish(),pattern:z.string().nullish(),message:z.string().nullish()}).nullish()}),Ea=z.object({fields:z.array(Es),submitAction:z.string().nullish()});Kn({chart:Na,table:Sa,card:Ta,kpi:Pa,code_preview:za,form:Ea});function ct({data:e,isStreaming:t=false,onAction:a,medias:n}){let{type:r,title:o,description:s,data:i,config:l}=e;return jsxs("div",{className:"my-3 overflow-hidden",children:[(o||s)&&jsxs("div",{className:"mb-2",children:[o&&jsx("p",{className:"text-sm font-semibold",children:o}),s&&jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:s})]}),jsx("div",{children:(()=>{let p=Vt(r);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: ",r]})]});if(p.schema){let y=p.schema.safeParse(i);if(!y.success){let T=y.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 ",r," visualization data"]})]}),jsxs("ul",{className:"text-xs text-red-500 dark:text-red-400 space-y-1 list-disc list-inside",children:[T.map((x,b)=>jsxs("li",{children:[x.path.join("."),": ",x.message]},b)),y.error.issues.length>3&&jsxs("li",{children:["...and ",y.error.issues.length-3," more"]})]})]})}}let v=p.component;return jsx(v,{data:i,config:l,isStreaming:t,onAction:a,medias:n})})()})]})}function Bt({artifact:e,isStreaming:t,onOpen:a}){let n=e.status??"ready",r=n==="pending"||t&&n!=="failed",o=n==="failed",s=r||o;return jsxs("button",{type:"button",onClick:()=>{s||a?.(e);},disabled:s,"aria-label":o?`Artifact failed: ${e.title}`:`Open ${e.kind.toUpperCase()} artifact: ${e.title}`,"data-artifact-id":e.id,"data-artifact-status":n,style:{display:"flex",alignItems:"center",gap:"12px",padding:"10px 14px",marginTop:"8px",background:o?"var(--miiflow-artifact-error-bg, #fdecea)":"var(--miiflow-artifact-bg, #f6f8fa)",border:"1px solid",borderColor:o?"var(--miiflow-artifact-error-border, #f1aeb5)":"var(--miiflow-artifact-border, #d0d7de)",borderRadius:"8px",font:"inherit",color:"inherit",textAlign:"left",cursor:s?o?"default":"progress":"pointer",width:"100%",maxWidth:"420px",opacity:r?.7:1},children:[jsx("span",{"aria-hidden":true,style:{fontSize:"22px",lineHeight:1,flex:"0 0 auto"},children:o?"\u26A0\uFE0F":"\u{1F4C4}"}),jsxs("span",{style:{flex:1,minWidth:0},children:[jsx("span",{style:{display:"block",fontWeight:600,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.title}),jsx("span",{style:{display:"block",fontSize:"12px",color:o?"var(--miiflow-artifact-error-text, #b42318)":"var(--miiflow-artifact-meta, #57606a)"},children:o?e.errorMessage||"Generation failed":[e.kind.toUpperCase(),e.pageCount?`${e.pageCount} pages`:null,r?"generating\u2026":null].filter(Boolean).join(" \xB7 ")})]})]})}var Gn="__miiflow_artifact_registry__",Ma=globalThis[Gn]??(globalThis[Gn]=new Map);function Xn(e,t){Ma.set(e,t);}function _t(e){return Ma.get(e)}function Zn(){return Array.from(Ma.keys())}function Ft({artifacts:e,isStreaming:t,onOpen:a}){return e?.length?jsx("div",{"data-artifact-list":true,style:{display:"flex",flexDirection:"column",gap:"4px"},children:e.map(n=>{let o=_t(n.kind)?.InlineCard??Bt;return jsx(o,{artifact:n,isStreaming:t,onOpen:a},n.id)})}):null}var Jn=/\[(VIZ|MEDIA|SA):([\w-]+)\]/gi;function er(e){let t=[],a=0,n;for(Jn.lastIndex=0;(n=Jn.exec(e))!==null;){if(n.index>a){let o=e.slice(a,n.index);o.trim()&&t.push({type:"text",content:o});}let r=n[1].toUpperCase();r==="VIZ"?t.push({type:"viz",id:n[2]}):r==="SA"?t.push({type:"sa",id:n[2]}):t.push({type:"media",id:n[2]}),a=n.index+n[0].length;}if(a<e.length){let r=e.slice(a);r.trim()&&t.push({type:"text",content:r});}return t}var Rs=[/```/,/\[VIZ:/,/\[SA:/,/\[MEDIA:/,/!\[/,/<img\b/i];function Is(e){for(let t of Rs)if(t.test(e))return false;return true}function tr(e,t,a){let[n,r]=useState(void 0);return useEffect(()=>{if(!a){r(void 0);return}let o=e.current;if(!o||!t||!Is(t))return;let s=false,i=()=>{if(s)return;let d=o.clientWidth;if(d<=0)return;let p=b(t,d);p&&r(v=>v===void 0||p.height>v?p.height:v);};i();let l=typeof ResizeObserver<"u"?new ResizeObserver(i):null;return l?.observe(o),()=>{s=true,l?.disconnect();}},[e,t,a]),n}var _s=({ytId:e,altText:t})=>{let[a,n]=useState(false),r=`https://i.ytimg.com/vi/${e}/hqdefault.jpg`;return jsxs("div",{className:"my-3",children:[jsx("div",{className:"relative w-full overflow-hidden rounded-lg",style:{maxWidth:640,aspectRatio:"16 / 9"},children:a?jsx("iframe",{src:`https://www.youtube.com/embed/${e}?autoplay=1`,title:t||"Video",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:true,className:"absolute inset-0 h-full w-full border-0"}):jsxs("button",{type:"button",onClick:()=>n(true),className:"absolute inset-0 block border-0 bg-transparent p-0","aria-label":t||"Play video",children:[jsx("img",{src:r,alt:t||"Video preview",className:"h-full w-full object-cover",loading:"lazy"}),jsx(Ke,{label:t||"Play video"})]})}),t&&jsx("div",{className:"mt-1 text-xs text-gray-500",children:t})]})},Fs=({url:e,posterUrl:t,altText:a})=>{let[n,r]=useState(false);return jsxs("div",{className:"my-3",children:[jsx("div",{className:"relative overflow-hidden rounded-lg",style:{maxWidth:640,maxHeight:512},children:n?jsxs("video",{controls:true,autoPlay:true,preload:"metadata",className:"block max-h-[512px] w-full rounded-lg",poster:t,children:[jsx("source",{src:e}),"Your browser does not support the video tag."]}):jsxs("button",{type:"button",onClick:()=>r(true),className:"block w-full border-0 bg-transparent p-0","aria-label":a||"Play video",children:[t?jsx("img",{src:t,alt:a||"Video preview",className:"block max-h-[512px] w-full object-cover",loading:"lazy"}):jsx("div",{className:"flex w-full items-center justify-center bg-gray-900 text-gray-400",style:{aspectRatio:"16 / 9"},children:jsx("span",{className:"text-sm",children:"Click to load video"})}),jsx(Ke,{label:a||"Play video"})]})}),a&&jsx("div",{className:"mt-1 text-xs text-gray-500",children:a})]})},js=({media:e,onOpen:t})=>{if(e.mediaType==="video"){let a$1=e.url.match(Ee),n=a$1?a$1[1]:null,r=n?`https://i.ytimg.com/vi/${n}/hqdefault.jpg`:void 0;return jsxs("button",{type:"button",onClick:t,className:a("relative block w-full overflow-hidden rounded-lg border-0 bg-black/5 p-0","aspect-square cursor-pointer transition-opacity hover:opacity-90"),style:{aspectRatio:"1 / 1"},"aria-label":e.altText||"Open video",children:[r?jsx("img",{src:r,alt:e.altText||"Video preview",className:"h-full w-full object-cover",loading:"lazy"}):jsx("div",{className:"flex h-full w-full items-center justify-center bg-gray-900 text-xs text-gray-400",children:"Video"}),jsx(Ke,{label:e.altText||"Open video"})]})}return jsx("button",{type:"button",onClick:t,className:a("block w-full overflow-hidden rounded-lg border-0 bg-transparent p-0","aspect-square cursor-pointer transition-opacity hover:opacity-90"),style:{aspectRatio:"1 / 1"},"aria-label":e.altText||"Open image",children:jsx("img",{src:e.url,alt:e.altText||"Image",className:"h-full w-full object-cover",loading:"lazy"})})},ar=forwardRef(({message:e,viewerRole:t="user",className:a$2,showAvatar:n=true,showTimestamp:r=true,renderMarkdown:o=true,reasoning:s,executionPlan:i,executionTimeline:l,suggestedActions:d$1,onSuggestedAction:p,reasoningExpanded:v,onReasoningExpandedChange:y,citations:T,visualizations:x,medias:b,artifacts:N,onArtifactOpen:R,baselineFontSize:M,executionTime:C,pendingClarification:S,onClarificationSubmit:f,pendingToolApproval:g,onToolApprove:E,onToolReject:k,renderInlineSuggestedAction:u,onReportIncorrect:w,onConfirmCorrect:H,onEditSubmit:$},G)=>{let A=useContext(a$1)?.onVisualizationAction,[V,P]=useState(false),ee=(e.participant?.role||"").toLowerCase(),U=(t||"").toLowerCase(),q=ee===U,Pe=ee==="assistant",Y=e.isStreaming,fe=s?.filter(B=>B.type==="thinking"||B.type==="tool"||B.type==="observation"||B.type==="planning"||B.type==="subtask"||B.type==="subagent"),He=fe&&fe.length>0,Ut=!Y&&(i||l&&l.length>0),z=He||Ut,X=Y&&!e.textContent&&!z,K=e.attachments,Z=K&&K.length>0,pe=useMemo(()=>{if(!x||x.length===0)return null;let B=new Map;return x.forEach(_=>B.set(_.id,_)),B},[x]),Yt=pe&&pe.size>0||e.textContent&&/\[SA:[\w-]+\]/i.test(e.textContent),qt=useMemo(()=>!Yt||!e.textContent?null:er(e.textContent),[Yt,e.textContent]),Xe=useMemo(()=>!b||b.length===0||!e.textContent?e.textContent:e.textContent.replace(/\[MEDIA:[a-f0-9-]+\]/gi,"").trim(),[e.textContent,b]),gr=()=>{if(!e.textContent)return null;if(qt&&qt.length>0&&Yt){let B=new Set;return jsx(Fragment,{children:qt.map((_,ze)=>{if(_.type==="text")return Y?jsx(rt,{content:_.content,isStreaming:true,baselineFontSize:M},ze):jsx(le,{baselineFontSize:M,className:q?"prose-invert":"",children:_.content},ze);if(_.type==="viz"){if(B.has(_.id))return null;let Ya=pe?.get(_.id);return Ya?(B.add(_.id),jsx(ct,{data:Ya,isStreaming:Y,onAction:A,medias:b},`viz-${_.id}`)):null}return _.type==="sa"&&u?jsx("div",{children:u(_.id)},`sa-${_.id}`):null})})}return Y&&o?jsx(rt,{content:Xe||"",isStreaming:true,baselineFontSize:M,className:q?"prose-invert":""}):o?jsx(le,{baselineFontSize:M,className:q?"prose-invert":"",children:Xe||""}):jsx("p",{className:"whitespace-pre-wrap",children:Xe})},Oe=useMemo(()=>{if(!b||b.length===0)return [];let B=Xe||"";return b.filter(_=>_.mediaType!=="image"?true:!B.includes(_.url)).map(_=>({id:_.id,url:_.url,mediaType:_.mediaType,altText:_.altText}))},[b,Xe]),{index:Ha,open:Oa,close:hr,navigate:br}=xt(Oe),xr=()=>{if(Oe.length===0)return null;if(Oe.length>=2)return jsx("div",{className:"my-3 grid gap-2",style:{gridTemplateColumns:"repeat(auto-fill, minmax(140px, 1fr))",maxWidth:640},children:Oe.map((_,ze)=>jsx(js,{media:_,onOpen:()=>Oa(ze)},`media-${_.id}`))});let B=Oe[0];if(B.mediaType==="image")return jsx("div",{className:"my-3",children:jsx("button",{type:"button",onClick:()=>Oa(0),className:"block cursor-zoom-in border-0 bg-transparent p-0","aria-label":B.altText||"Open image",children:jsx("img",{src:B.url,alt:B.altText||"Generated image",className:"max-w-full rounded-lg",loading:"lazy",style:{maxHeight:512,display:"block"}})})});if(B.mediaType==="video"){let _=B.url.match(Ee);return _?jsx(_s,{ytId:_[1],altText:B.altText},`media-${B.id}`):jsx(Fs,{url:B.url,posterUrl:B.posterUrl,altText:B.altText},`media-${B.id}`)}return null},Wa=useRef(Y);Y&&(Wa.current=true);let yr=!Y&&!Wa.current,Ka=useRef(null),Ua=tr(Ka,e.textContent,!!Y);return jsx(c,{ref:G,message:e,viewerRole:t,className:a("w-full",yr&&"animate-message-in",a$2),children:jsxs("div",{className:a("flex flex-col gap-1 w-full"),"data-is-viewer":q,children:[X&&jsxs("div",{className:a("flex items-start gap-2 w-full"),children:[n&&!q&&jsx("div",{className:"flex-shrink-0",children:jsx(Ie,{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(Qe,{size:"small"})})]}),z&&Pe&&jsx("div",{className:"w-full",children:jsx(ya,{isStreaming:Y,chunks:fe,plan:i,executionTimeline:l,userMessageTimestamp:e.createdAt?new Date((typeof e.createdAt=="string",e.createdAt)).getTime()/1e3:void 0,executionTime:C,expanded:v,onExpandedChange:y})}),e.textContent&&jsxs("div",{className:a("group flex items-start gap-2 w-full",q?"flex-row-reverse":"flex-row"),children:[n&&!q&&jsx("div",{className:"flex-shrink-0",children:jsx(Ie,{name:e.participant?.name,src:e.participant?.avatarUrl,role:e.participant?.role,className:"w-10 h-10 flex-shrink-0"})}),jsxs("div",{ref:Ka,className:a(q?V?"w-full":"max-w-[85%]":"min-w-0 flex-1","flex flex-col"),"data-message-role":q?"viewer":"other",style:Ua?{minHeight:Ua}:void 0,children:[q&&V&&$?jsx($s,{initialText:e.textContent||"",onCancel:()=>P(false),onSubmit:B=>{P(false),$(B);}}):jsxs("div",{className:a("rounded-2xl",q||n?"px-4 py-3":""),style:{backgroundColor:q?"var(--chat-user-message-bg)":"transparent",color:q?"var(--chat-user-message-text, #ffffff)":"var(--chat-text)"},children:[jsx(d,{children:gr()}),xr(),Ha!==null&&jsx(bt,{items:Oe,index:Ha,onClose:hr,onNavigate:br}),x&&x.length>0&&(()=>{let B=e.textContent||"",_=x.filter(ze=>!B.includes(`[VIZ:${ze.id}]`));return _.length===0?null:_.map(ze=>jsx("div",{className:"my-3",children:jsx(ct,{data:ze,isStreaming:Y,onAction:A,medias:b})},`viz-unreferenced-${ze.id}`))})(),N&&N.length>0&&jsx("div",{className:"mt-2",children:jsx(Ft,{artifacts:N,isStreaming:Y,onOpen:R})}),T&&T.length>0&&jsx("div",{className:"mt-2 pt-2 border-t border-[var(--chat-border)]",children:jsx(ea,{sources:T})})]}),Z&&jsx("div",{className:"mt-2",children:jsx(ca,{attachments:K})}),!Y&&!V&&(r&&e.createdAt||e.textContent)&&jsxs("div",{className:a("flex items-center gap-2 mt-1",q&&"flex-row-reverse"),children:[r&&e.createdAt&&jsx(Hs,{createdAt:typeof e.createdAt=="string"?e.createdAt:e.createdAt.toISOString(),isViewer:q}),Pe&&e.textContent&&jsx(kt,{textContent:e.textContent,onReportIncorrect:w,onConfirmCorrect:H}),q&&e.textContent&&jsx(kt,{textContent:e.textContent,onEdit:$?()=>P(true):void 0})]})]})]}),e.error&&jsxs("div",{className:a("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&&n&&!q&&z&&!X&&jsx("div",{className:"flex items-start gap-2 w-full",children:jsx("div",{className:"flex-shrink-0",children:jsx(Ie,{name:e.participant?.name,src:e.participant?.avatarUrl,role:e.participant?.role,className:"w-10 h-10 flex-shrink-0"})})}),S&&!Y&&f&&jsx("div",{className:"w-full max-w-[80%]",children:jsx(na,{clarification:S,onSubmit:f})}),g&&!Y&&E&&k&&jsx("div",{className:"w-full",children:jsx(ia,{approval:g,onApprove:E,onReject:k})}),d$1&&d$1.length>0&&!Y&&jsx("div",{className:"w-full max-w-[80%]",children:jsx(St,{actions:d$1,onSelect:p})})]})})});ar.displayName="Message";function $s({initialText:e,onCancel:t,onSubmit:a$1}){let[n,r]=useState(e),o=useRef(null),s=n.trim().length>0,i=()=>{let l=o.current;l&&(l.style.height="auto",l.style.height=`${Math.min(l.scrollHeight,320)}px`);};return useEffect(()=>{let l=o.current;l&&(l.focus(),l.setSelectionRange(l.value.length,l.value.length),i());},[]),jsxs("div",{className:"w-full rounded-2xl px-4 py-3",style:{backgroundColor:"var(--chat-panel-bg)",border:"1px solid var(--chat-border)"},children:[jsx("textarea",{ref:o,value:n,onChange:l=>{r(l.target.value),i();},onKeyDown:l=>{l.key==="Escape"?(l.preventDefault(),t()):l.key==="Enter"&&(l.metaKey||l.ctrlKey)&&(l.preventDefault(),s&&a$1(n.trim()));},rows:1,"aria-label":"Edit message",className:"w-full resize-none border-0 bg-transparent p-0 outline-none text-[var(--chat-text)]",style:{font:"inherit",lineHeight:"inherit",overflowY:"auto"}}),jsxs("div",{className:"mt-2 flex items-center justify-end gap-2",children:[jsx("button",{type:"button",onClick:t,className:a("rounded-full px-3.5 py-1.5 text-sm font-medium","text-[var(--chat-text)] hover:opacity-80 transition-opacity"),style:{border:"1px solid var(--chat-border)",backgroundColor:"transparent"},children:"Cancel"}),jsx("button",{type:"button",onClick:()=>s&&a$1(n.trim()),disabled:!s,className:a("rounded-full px-3.5 py-1.5 text-sm font-medium","transition-opacity",s?"hover:opacity-90":"opacity-40 cursor-not-allowed"),style:{backgroundColor:"var(--chat-user-message-bg)",color:"var(--chat-user-message-text, #ffffff)",border:"none"},children:"Send"})]})]})}function Hs({createdAt:e}){return jsx("span",{className:"text-xs text-[var(--chat-text-subtle)]",children:(a=>{try{return new Date(a).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}catch{return ""}})(e)})}var Js=100*1024*1024,el=["image/jpeg","image/jpg","image/png","image/gif","image/webp","image/svg+xml","image/bmp"],tl=["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"],al=["video/mp4","video/webm","video/ogg","video/avi","video/mov","video/wmv","video/flv","video/mkv"],nl=[...el,...tl,...al];function nr(e){if(e===0)return "0 Bytes";let t=1024,a=["Bytes","KB","MB","GB"],n=Math.floor(Math.log(e)/Math.log(t));return parseFloat((e/Math.pow(t,n)).toFixed(2))+" "+a[n]}function rl(e,t,a){return e.size>a?`File size (${nr(e.size)}) exceeds max (${nr(a)})`:t.includes(e.type)?null:`File type ${e.type||"unknown"} is not allowed`}function ol({attachments:e,onRemove:t,disabled:a$1}){return e.length===0?null:jsx("div",{className:"flex flex-wrap gap-2 px-3 pt-3 pb-0",children:e.map(n=>{let r=n.file.type.startsWith("image/"),o=n.status==="error",s=n.status==="uploading";return jsxs("div",{className:a("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"}):r&&n.previewUrl?jsx("img",{src:n.previewUrl,alt:n.file.name,className:"w-5 h-5 rounded object-cover"}):r?jsx(Image,{size:14,className:"flex-shrink-0"}):jsx(FileText,{size:14,className:"flex-shrink-0"}),jsx("span",{className:"truncate",title:o?n.error:n.file.name,children:o?n.error:n.file.name}),!a$1&&jsx("button",{type:"button",onClick:()=>t(n.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})})]},n.id)})})}var or=forwardRef(({onSubmit:e,onAttach:t,onUploadFile:a$1,onRemoveUploadedAttachment:n,disabled:r=false,supportsAttachments:o=true,allowedFileTypes:s=nl,maxFileSize:i$1=Js,placeholder:l="Type a message...",className:d,isSubmitting:p=false,centered:v=false,isStreaming:y=false,onStopStreaming:T,commandProvider:x,commandProviders:b},N)=>{let[R,M]=useState(false),[C,S]=useState([]),[f,g]=useState(false),E=useRef(null),k=useRef(null),u=useRef(0),w=useRef(false),H=r||p,$=C.some(z=>z.status==="uploading"),G=C.filter(z=>z.status==="uploaded"&&z.attachmentId).map(z=>z.attachmentId),ye=G.length>0||C.some(z=>z.status==="pending"),A=R||ye,V=useCallback(async z=>{let X=z.map(K=>{let Z=rl(K,s,i$1),pe={id:`${Date.now()}-${Math.random().toString(36).slice(2,9)}`,file:K,status:Z?"error":a$1?"uploading":"pending",error:Z||void 0};return !Z&&K.type.startsWith("image/")&&(pe.previewUrl=URL.createObjectURL(K)),pe});if(S(K=>[...K,...X]),t?.(z),a$1){for(let K of X)if(K.status==="uploading")try{let Z=await a$1(K.file);S(pe=>pe.map(Re=>Re.id===K.id?{...Re,status:"uploaded",attachmentId:Z}:Re));}catch(Z){S(pe=>pe.map(Re=>Re.id===K.id?{...Re,status:"error",error:Z instanceof Error?Z.message:"Upload failed"}:Re));}}},[s,i$1,a$1,t]),P=useCallback(async z=>{if(!A&&z.trim().length===0||H||$||w.current)return;w.current=true;let X=C.filter(Z=>Z.status!=="error").map(Z=>Z.file),K=C;k.current?.clear(),M(false),S([]);try{a$1&&G.length>0?await e(z,void 0,G):await e(z,X.length>0?X:void 0);}catch{S(K);}finally{w.current=false;}},[C,A,H,$,e,a$1,G]),ee=useCallback(()=>{k.current?.submit();},[]),U=useCallback(z=>{let X=z.target.files;!X||X.length===0||(V(Array.from(X)),z.target.value="");},[V]),q=useCallback(z=>{if(!o||p)return;let X=z.clipboardData;if(!X)return;let K=[];for(let Z of X.files)K.push(Z);if(K.length===0&&X.items){for(let Z of X.items)if(Z.kind==="file"){let pe=Z.getAsFile();pe&&K.push(pe);}}K.length>0&&(z.preventDefault(),V(K));},[o,p,V]),Pe=useCallback(z=>{S(X=>{let K=X.find(Z=>Z.id===z);return K?.previewUrl&&URL.revokeObjectURL(K.previewUrl),K?.attachmentId&&n&&n(K.attachmentId),X.filter(Z=>Z.id!==z)});},[n]),Y=useCallback(z=>{z.preventDefault(),z.stopPropagation(),!(!o||p)&&(u.current++,z.dataTransfer.types.includes("Files")&&g(true));},[o,p]),fe=useCallback(z=>{z.preventDefault(),z.stopPropagation(),u.current--,u.current===0&&g(false);},[]),He=useCallback(z=>{z.preventDefault(),z.stopPropagation();},[]),Ut=useCallback(z=>{if(z.preventDefault(),z.stopPropagation(),u.current=0,g(false),!o||p)return;let X=Array.from(z.dataTransfer.files);X.length>0&&V(X);},[o,p,V]);return useEffect(()=>()=>{C.forEach(z=>{z.previewUrl&&URL.revokeObjectURL(z.previewUrl);});},[]),jsx("div",{ref:N,className:a("flex-shrink-0",v?"p-0 bg-transparent":"px-3 pb-3",d),style:v?{padding:0,background:"transparent",border:"none"}:void 0,onDragEnter:Y,onDragLeave:fe,onDragOver:He,onDrop:Ut,children:jsxs("div",{className:a("mx-auto max-w-[900px]","chat-composer-shell group",v?"overflow-hidden":"rounded-xl",f&&"ring-2 ring-[var(--chat-primary,#106997)] border-[var(--chat-primary,#106997)]"),style:v?{borderRadius:"1rem",overflow:"hidden"}:void 0,children:[f&&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-[var(--chat-composer-border-focus,rgba(16,105,151,0.35))] bg-[var(--chat-panel-bg,rgba(0,0,0,0.02))] text-[var(--chat-primary,#106997)] text-sm",children:"Drop files here"})}),jsx(ol,{attachments:C,onRemove:Pe,disabled:p}),jsx("div",{className:a(v?"px-4 pt-3.5":"px-3 pt-2.5",C.length>0&&"pt-1.5"),onPaste:q,children:jsx(i,{ref:k,placeholder:l,disabled:H,commandProvider:x??null,commandProviders:b,inputClassName:a("text-sm leading-relaxed","text-gray-900 dark:text-zinc-100","placeholder:text-gray-400 dark:placeholder:text-zinc-500"),onChange:({text:z})=>M(z.trim().length>0),onSubmit:({text:z})=>P(z)})}),jsx(Ze,{className:v?"px-2.5 pb-2.5 pt-1":"px-2 pb-2 pt-1",onAttachClick:o?()=>E.current?.click():void 0,disabled:p,endSlot:y&&T?jsxs("div",{className:"relative flex-shrink-0 w-8 h-8",children:[jsx("span",{className:"absolute inset-0 rounded-lg bg-gray-400 dark:bg-zinc-400",style:{animation:"streaming-flash 3s ease-in-out infinite"}}),jsx("button",{type:"button",onClick:T,"aria-label":"Stop generating",className:a("relative w-full h-full rounded-lg","flex items-center justify-center","bg-gray-900 dark:bg-zinc-100 text-white dark:text-zinc-900","hover:bg-gray-700 dark:hover:bg-zinc-300","transition-colors duration-200"),children:jsx(Square,{size:14,fill:"currentColor"})})]}):jsx("button",{type:"button",onClick:ee,disabled:!A||H||$,"aria-label":"Send message",className:a("flex-shrink-0","w-8 h-8 rounded-lg","flex items-center justify-center","bg-gray-900 dark:bg-zinc-100 text-white dark:text-zinc-900","shadow-sm","hover:bg-gray-700 dark:hover:bg-zinc-300","active:scale-95","disabled:bg-gray-200 dark:disabled:bg-zinc-700 disabled:text-gray-400 dark:disabled:text-zinc-500 disabled:shadow-none disabled:cursor-not-allowed","transition-[background-color,color,transform] duration-150"),children:p||$?jsx(Loader2,{size:16,className:"animate-spin"}):jsx(ArrowUp,{size:16})})}),o&&jsx("input",{ref:E,type:"file",multiple:true,accept:s.join(","),onChange:U,className:"hidden"})]})})});or.displayName="MessageComposer";function Va({isAtBottom:e,onScrollToBottom:t,className:a$1}){return jsx("button",{type:"button",onClick:t,"aria-label":"Scroll to bottom",className:a("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",a$1),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 ir="linear-gradient(to bottom, black 0%, black calc(100% - 20px), transparent 100%)";function ml(){let{end:e}=useMessageScrollerScrollable(),{scrollToEnd:t}=useMessageScroller();return jsx(Va,{isAtBottom:!e,onScrollToBottom:()=>t({behavior:"smooth"})})}var sr=forwardRef(({children:e,autoScroll:t=true,showScrollToBottom:a$1=true,className:n},r)=>jsx(MessageScroller.Provider,{autoScroll:t,defaultScrollPosition:"end",children:jsxs(MessageScroller.Root,{className:"relative flex-1 overflow-hidden",style:{mask:ir,WebkitMask:ir},children:[jsx(MessageScroller.Viewport,{ref:r,className:"h-full overflow-y-auto chat-scrollbar",style:{overscrollBehavior:"contain"},children:jsx(MessageScroller.Content,{className:a("flex flex-col gap-4 p-4 pb-12",n),children:Children.map(e,o=>isValidElement(o)?jsx(MessageScroller.Item,{children:o}):o)})}),a$1&&jsx(ml,{})]})}));sr.displayName="MessageList";function fl({label:e,className:t}){return jsxs("div",{className:`flex items-center gap-3 py-6 select-none ${t??""}`,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 cr=forwardRef(({className:e},t)=>jsx(r,{ref:t,className:a("inline-flex items-center gap-1","px-4 py-3",e),children:jsx(Qe,{size:"small"})}));cr.displayName="TypingIndicator";function kl({title:e,subtitle:t,logo:a$1,actions:n,showClose:r,onClose:o,loading:s,className:i,style:l}){let[d,p]=useState(false),v=useRef(null),y=useRef(null);return useEffect(()=>{let T=x=>{let b=x.composedPath();v.current&&!b.includes(v.current)&&y.current&&!b.includes(y.current)&&p(false);};if(d)return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[d]),jsxs("header",{className:a("flex items-center justify-between gap-3","px-4 py-2.5","border-b border-[var(--chat-border)]","bg-[var(--chat-header-bg,#ffffff)]",i),style:l,children:[jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[a$1&&jsx("div",{className:"flex-shrink-0",children:typeof a$1=="string"?jsx("img",{src:a$1,alt:"",className:"w-10 h-10 rounded-lg object-contain"}):a$1}),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-base font-semibold text-[var(--chat-text)] truncate",children:e}),t&&jsx("p",{className:"text-sm text-[var(--chat-text-subtle)] truncate",children:t})]})]}),jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[n&&n.length>0&&jsxs("div",{className:"relative",children:[jsx("button",{ref:y,onClick:()=>p(!d),className:a("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":d,children:jsx(MoreVertical,{size:18})}),d&&jsx("div",{ref:v,className:a("absolute right-0 top-full mt-1 z-50","min-w-[180px]","bg-[var(--chat-composer-bg,#ffffff)] rounded-lg","shadow-[0_1px_2px_rgba(29,32,51,0.04),0_8px_24px_-12px_rgba(29,32,51,0.24)]","border border-[var(--chat-border)]","py-1","animate-fade-in"),children:n.map(T=>jsxs("button",{onClick:()=>{T.onClick(),p(false);},disabled:T.disabled,className:a("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:[T.icon&&jsx("span",{className:"flex-shrink-0 text-[var(--chat-text-subtle)]",children:T.icon}),T.label]},T.id))})]}),r&&o&&jsx("button",{onClick:o,className:a("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 wl({toolName:e,status:t,description:a$1,className:n}){return jsxs("div",{className:a("relative flex items-center gap-2 py-1 px-2 rounded-md text-sm overflow-hidden",t==="running"&&"animate-shimmer",n),children:[jsx(Cl,{status:t}),jsx("span",{className:"font-medium text-[var(--chat-text)]",children:e}),a$1&&jsx("span",{className:"text-[var(--chat-text-subtle)] truncate",children:a$1})]})}function Cl({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 pr=forwardRef(({isEmpty:e,header:t,welcomeScreen:a$1,messageList:n,composer:r,footer:o,className:s},i)=>jsx("div",{ref:i,"data-chat-ui":true,className:a("relative h-full overflow-hidden flex flex-col min-h-0",s),children:jsx(AnimatePresence,{mode:"wait",children:e&&a$1?jsxs(motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.2},className:"flex-1 flex flex-col overflow-hidden min-h-0",children:[t,a$1]},"welcome"):jsxs(motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.2},className:"flex-1 flex flex-col overflow-hidden min-h-0",children:[t,jsx(motion.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.2,delay:.05},className:"flex-1 overflow-hidden flex flex-col min-h-0",children:n}),jsxs(motion.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.2,delay:.1},className:"relative z-10",children:[o,r]})]},"active")})}));pr.displayName="ChatLayout";function Al(e,t=3e3){let[a,n]=useState(0),r=useRef(null);return useEffect(()=>{if(e.length<=1)return;let o=()=>{r.current=setInterval(()=>{n(i=>(i+1)%e.length);},t);},s=()=>{document.visibilityState!=="visible"?r.current&&(clearInterval(r.current),r.current=null):o();};return o(),document.addEventListener("visibilitychange",s),()=>{r.current&&clearInterval(r.current),document.removeEventListener("visibilitychange",s);}},[e,t]),e[a]??""}function Ml({placeholder:e,onSubmit:t,disabled:a$1,supportsAttachments:n,commandProvider:r,commandProviders:o}){let[s,i$1]=useState(false),[l,d]=useState([]),p=useRef(null),v=useRef(null),y=useCallback(N=>{!N.trim()&&l.length===0||a$1||(t(N.trim(),l.length>0?l:void 0),p.current?.clear(),i$1(false),d([]));},[a$1,l,t]),T=N=>{N.target.files&&d(R=>[...R,...Array.from(N.target.files)]),N.target.value="";},x=N=>{d(R=>R.filter((M,C)=>C!==N));},b=(s||l.length>0)&&!a$1;return jsxs("div",{className:a("w-full relative mx-auto","rounded-2xl overflow-hidden","chat-composer-shell group"),style:{borderRadius:"1rem",overflow:"hidden"},children:[l.length>0&&jsx("div",{className:"flex flex-wrap gap-2 px-4 pt-3",children:l.map((N,R)=>jsxs("div",{className:a("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:N.name}),jsx("button",{type:"button",onClick:()=>x(R),className:"flex-shrink-0 text-gray-400 hover:text-gray-600 dark:hover:text-zinc-200",children:jsx(X,{size:12})})]},`${N.name}-${R}`))}),jsx(i,{ref:p,placeholder:e,disabled:a$1,commandProvider:r??null,commandProviders:o,className:"px-4 sm:px-5 pt-3.5 sm:pt-4 pb-1",inputClassName:"text-sm sm:text-base text-gray-900 dark:text-white placeholder:text-gray-400 dark:placeholder:text-zinc-500",placeholderClassName:"text-sm sm:text-base",onChange:({text:N})=>i$1(N.trim().length>0),onSubmit:({text:N})=>y(N)}),jsx(Ze,{className:"px-2.5 pb-2.5 pt-1",onAttachClick:n?()=>v.current?.click():void 0,disabled:a$1,endSlot:jsx("button",{type:"button",onClick:()=>p.current?.submit(),disabled:!b,"aria-label":"Send message",className:a("flex-shrink-0","w-8 h-8 rounded-lg","flex items-center justify-center","bg-gray-900 dark:bg-zinc-600 text-zinc-50","shadow-sm","hover:bg-gray-700 dark:hover:bg-zinc-500","active:scale-95","disabled:bg-gray-300 dark:disabled:bg-zinc-700","disabled:text-gray-500 dark:disabled:text-zinc-400","disabled:shadow-none disabled:cursor-not-allowed","transition-[background-color,color,transform] duration-150"),children:jsx(ArrowUp,{size:16,strokeWidth:2})})}),n&&jsx("input",{ref:v,type:"file",multiple:true,onChange:T,className:"hidden"})]})}function Rl({text:e,onClick:t,index:a$1}){return jsx(motion.button,{type:"button",onClick:t,initial:{opacity:0},animate:{opacity:1},transition:{delay:.15+a$1*.03,duration:.2},className:a("inline-flex items-center rounded-full","border border-[var(--chat-border,rgba(29,32,51,0.08))]","px-3.5 py-1.5","text-sm leading-normal text-left","text-[var(--chat-text-subtle,rgba(0,0,0,0.5))]","cursor-pointer select-none","transition-colors duration-150","hover:bg-[var(--chat-panel-bg,rgba(0,0,0,0.02))]","hover:border-[var(--chat-border-hover,rgba(0,0,0,0.12))]","hover:text-[var(--chat-text,#1d2033)]","active:bg-[var(--chat-message-bg,rgba(0,0,0,0.03))]"),style:{borderRadius:"9999px"},children:e})}var ur=forwardRef(({placeholders:e=[],suggestions:t=[],onSubmit:a$1,onSuggestionClick:n,welcomeText:r="How can I help you today?",supportsAttachments:o,composerSlot:s,commandProvider:i,commandProviders:l,className:d,assistantAvatar:p,assistantName:v},y)=>{let T=Al(e),x=useCallback(b=>{n?.(b);},[n]);return jsxs("div",{ref:y,className:a("relative overflow-hidden","flex-1 flex items-center justify-center","px-4 sm:px-6",d),children:[jsx("div",{className:"pointer-events-none absolute inset-0",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:{y:8,opacity:0},animate:{y:0,opacity:1},transition:{duration:.22,ease:[.16,1,.3,1]},className:"relative w-full max-w-[800px] flex flex-col items-center gap-8",children:[r&&p?jsxs(motion.div,{initial:{opacity:0,y:-8},animate:{opacity:1,y:0},transition:{delay:.05,duration:.2,ease:[.4,0,.2,1]},className:"flex items-start gap-2 w-full",children:[jsx("div",{className:"flex-shrink-0",children:jsx(Ie,{name:v,src:p,role:"assistant",className:"w-10 h-10 flex-shrink-0"})}),jsx("div",{className:"rounded-2xl px-4 py-3",children:jsx("p",{style:{fontSize:"1rem",lineHeight:"1.5rem",color:"var(--chat-text, #1d2033)"},className:"text-base",children:r})})]}):r?jsx(motion.h2,{initial:{opacity:0,y:-8},animate:{opacity:1,y:0},transition:{delay:.05,duration:.2,ease:[.4,0,.2,1]},style:{fontSize:"1.5rem",lineHeight:"2rem",fontWeight:600,letterSpacing:"-0.01em",color:"var(--chat-text, #1d2033)"},className:"text-2xl font-semibold text-center",children:r}):null,jsx("div",{className:"w-full",children:s??jsx(Ml,{placeholder:T,onSubmit:(b,N)=>a$1?.(b,N),supportsAttachments:o,commandProvider:i??null,commandProviders:l})}),t.length>0&&jsx("div",{className:"flex flex-wrap justify-center gap-2 w-full max-w-[640px]",children:t.map((b,N)=>jsx(Rl,{text:b,onClick:()=>x(b),index:N},N))})]})]})});ur.displayName="WelcomeScreen";function Il(e){return e?e.split(/[_-]+/).filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" "):"Sub-assistant"}function Ll({chunk:e}){let t=e.subagentData;if(!t)return null;let a=t.status==="running"?"running":t.status==="completed"?"completed":t.status==="failed"?"failed":"pending",n=(t.nestedChunks??[]).map((o,s)=>Le(o,s)).filter(o=>o!==null);t.result&&t.result.trim().length>0&&n.push({id:`result-${t.subagentId}`,type:"thinking",status:t.status==="failed"?"failed":"completed",content:t.result});let r=[{id:t.subagentId,status:a,content:jsx(at,{label:Il(t.subagentType),durationSeconds:t.durationMs!=null?t.durationMs/1e3:void 0,isFailed:t.status==="failed",nestedEvents:n})}];return jsx(je,{items:r,badgeSize:20})}
132
+ export{kl as $,At as A,Mt as B,Rt as C,It as D,Lt as E,Be as F,Vt as G,Wn as H,Na as I,Sa as J,Ta as K,Pa as L,za as M,Ea as N,ct as O,Bt as P,Xn as Q,_t as R,Zn as S,Ft as T,er as U,ar as V,or as W,Va as X,sr as Y,fl as Z,cr as _,rn as a,wl as aa,Ie as b,pr as ba,sn as c,ur as ca,Ze as d,Ll as da,Qe as e,le as f,ea as g,pn as h,go as i,na as j,ia as k,kt as l,ca as m,wt as n,je as o,ei as p,ua as q,Le as r,si as s,Me as t,at as u,ga as v,ya as w,rt as x,St as y,Et as z};//# sourceMappingURL=chunk-HYFMOOLH.js.map
133
+ //# sourceMappingURL=chunk-HYFMOOLH.js.map