@miiflow/assistant-ui 0.3.3 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,8 @@
1
1
  import * as react from 'react';
2
2
  import { HTMLAttributes, ReactNode } from 'react';
3
- import { A as Attachment, M as MessageData, P as ParticipantRole, d as SuggestedAction, S as SourceReference } from './message-4-BaKes3.js';
4
- import { h as AvatarProps$1 } from './avatar-BgjqLv1r.js';
5
- import { S as StreamingChunk, V as VisualizationChunkData, C as ClarificationData } from './streaming-CF63E6iS.js';
3
+ import { A as Attachment, M as MessageData, P as ParticipantRole, d as SuggestedAction, S as SourceReference } from './message-BnGtSz1P.js';
4
+ import { h as AvatarProps$1 } from './avatar-B6YLvJt3.js';
5
+ import { S as StreamingChunk, V as VisualizationChunkData, M as MediaChunkData, C as ClarificationData } from './streaming-DrnCgnnh.js';
6
6
  import * as react_jsx_runtime from 'react/jsx-runtime';
7
7
 
8
8
  interface AttachmentPreviewProps {
@@ -86,6 +86,8 @@ interface MessageProps {
86
86
  citations?: SourceReference[];
87
87
  /** Inline visualizations to render within message content */
88
88
  visualizations?: VisualizationChunkData[];
89
+ /** Inline media (images/videos) to render within message content */
90
+ medias?: MediaChunkData[];
89
91
  /** Base font size multiplier for markdown rendering */
90
92
  baselineFontSize?: number;
91
93
  /** Total execution time in seconds (persisted from streaming wall-clock) */
@@ -125,6 +127,8 @@ interface MessageComposerProps {
125
127
  className?: string;
126
128
  /** Whether a message is currently being submitted */
127
129
  isSubmitting?: boolean;
130
+ /** Centered/welcome mode: bigger radius, more padding, nicer shadow (used inside WelcomeScreen) */
131
+ centered?: boolean;
128
132
  }
129
133
  /**
130
134
  * MessageComposer with textarea, attachment support,
@@ -1,6 +1,6 @@
1
1
  import * as react from 'react';
2
2
  import { HTMLAttributes, ReactNode, TextareaHTMLAttributes, ButtonHTMLAttributes } from 'react';
3
- import { M as MessageData, P as ParticipantRole } from './message-4-BaKes3.js';
3
+ import { M as MessageData, P as ParticipantRole } from './message-BnGtSz1P.js';
4
4
 
5
5
  interface MessageContextValue {
6
6
  message: MessageData;
@@ -0,0 +1,2 @@
1
+ import {useRef,useState,useCallback,useEffect}from'react';function U({enabled:s=true,smooth:h=true,scrollToBottomOnMount:g=true}={}){let o=useRef(null),[p,d]=useState(true),l=useRef(0),c=useRef(null),i=useCallback(t=>{let e=o.current;if(!e)return;let f=t??(h?"smooth":"instant");c.current=f,e.scrollTo({top:e.scrollHeight,behavior:f});},[h]),a=useCallback(t=>Math.abs(t.scrollHeight-t.scrollTop-t.clientHeight)<1||t.scrollHeight<=t.clientHeight,[]),m=useCallback(()=>{let t=o.current;if(!t)return;let e=a(t);!e&&l.current<t.scrollTop||(e&&(c.current=null),(e||c.current===null)&&d(e)),l.current=t.scrollTop;},[a]),r=useCallback(()=>{let t=c.current;if(t)i(t);else if(s){let e=o.current;e&&a(e)&&i("instant");}m();},[s,i,a,m]);return useEffect(()=>{let t=o.current;if(!t||!s)return;let e=new ResizeObserver(()=>{r();});return e.observe(t),()=>e.disconnect()},[s,r]),useEffect(()=>{let t=o.current;if(!t||!s)return;let e=new MutationObserver(f=>{f.some(T=>T.type!=="attributes"||T.attributeName!=="style")&&r();});return e.observe(t,{childList:true,subtree:true,attributes:true,characterData:true}),()=>e.disconnect()},[s,r]),useEffect(()=>{let t=o.current;if(t)return t.addEventListener("scroll",m,{passive:true}),()=>t.removeEventListener("scroll",m)},[m]),useEffect(()=>{s&&g&&(c.current="instant",requestAnimationFrame(()=>{i("instant");}));},[]),{containerRef:o,scrollToBottom:i,isAtBottom:p}}function I({onSubmit:s,disabled:h=false,maxFileSize:g=10*1024*1024,allowedFileTypes:o}){let[p,d]=useState(""),[l,c]=useState([]),[i,a]=useState(false),[m,r]=useState(null),t=useRef(null),e=useRef(false),f=useCallback(n=>{d(n),r(null);},[]),M=useCallback(n=>{let b=Array.from(n),B=[];for(let u of b){if(u.size>g){r(`File "${u.name}" exceeds maximum size`);continue}if(o&&!o.includes(u.type)){r(`File type "${u.type}" is not allowed`);continue}B.push(u);}c(u=>[...u,...B]);},[g,o]),T=useCallback(n=>{c(b=>b.filter((B,u)=>u!==n));},[]),y=useCallback(async()=>{let n=p.trim();if(!(!n&&l.length===0||h||i||e.current)){e.current=true,a(true),r(null);try{await s(n,l.length>0?l:void 0),d(""),c([]),t.current?.focus();}catch(b){r(b instanceof Error?b.message:"Failed to send message");}finally{a(false),e.current=false;}}},[p,l,h,i,s]),C=useCallback(n=>{n.key==="Enter"&&!n.shiftKey&&(n.preventDefault(),y());},[y]),H=useCallback(()=>{d(""),c([]),r(null);},[]),O=(p.trim()||l.length>0)&&!h&&!i;return {content:p,attachments:l,isSubmitting:i,error:m,canSubmit:O,inputRef:t,handleContentChange:f,handleAddAttachment:M,handleRemoveAttachment:T,handleSubmit:y,handleKeyDown:C,clear:H}}export{U as a,I as b};//# sourceMappingURL=chunk-4WWJTYYA.js.map
2
+ //# sourceMappingURL=chunk-4WWJTYYA.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/hooks/use-auto-scroll.ts","../src/hooks/use-message-composer.ts"],"names":["useAutoScroll","enabled","smooth","scrollToBottomOnMount","containerRef","useRef","isAtBottom","setIsAtBottom","useState","lastScrollTopRef","scrollingToBottomBehaviorRef","scrollToBottom","useCallback","behavior","container","b","computeIsAtBottom","el","handleScroll","newIsAtBottom","handleContentResize","scrollBehavior","useEffect","resizeObserver","mutationObserver","mutations","m","useMessageComposer","onSubmit","disabled","maxFileSize","allowedFileTypes","content","setContent","attachments","setAttachments","isSubmitting","setIsSubmitting","error","setError","inputRef","isSubmittingRef","handleContentChange","value","handleAddAttachment","files","fileArray","validFiles","file","prev","handleRemoveAttachment","index","_","i","handleSubmit","trimmedContent","err","handleKeyDown","e","clear","canSubmit"],"mappings":"0DA+BO,SAASA,EAAqC,CACnD,OAAA,CAAAC,CAAAA,CAAU,IAAA,CACV,OAAAC,CAAAA,CAAS,IAAA,CACT,qBAAA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,CACA,oBAAAE,CAAAA,CACA,mBAAA,CAAAE,CAAAA,CACA,sBAAA,CAAAM,EACA,YAAA,CAAAI,CAAAA,CACA,cAAAG,CAAAA,CACA,KAAA,CAAAE,CACF,CACF","file":"chunk-4WWJTYYA.js","sourcesContent":["import { useEffect, useRef, useCallback, useState } from \"react\";\n\nexport interface UseAutoScrollOptions {\n /** Whether auto-scroll is enabled */\n enabled?: boolean;\n /** Smooth scroll behavior */\n smooth?: boolean;\n /** Scroll to bottom when component mounts */\n scrollToBottomOnMount?: boolean;\n}\n\nexport interface UseAutoScrollReturn<T extends HTMLElement> {\n /** Ref to attach to the scrollable container */\n containerRef: React.RefObject<T | null>;\n /** Scroll to bottom programmatically (always forces scroll) */\n scrollToBottom: (behavior?: ScrollBehavior) => void;\n /** Whether the viewport is currently at the bottom */\n isAtBottom: boolean;\n}\n\n/**\n * Hook to automatically scroll to the bottom of a container\n * when new content is added, unless the user has scrolled up.\n *\n * Combines ResizeObserver + MutationObserver to catch all height changes\n * (image loads, panel expansion, streaming text, new messages).\n *\n * Uses a 1px tolerance for isAtBottom (matches assistant-ui) and\n * persists scroll behavior across content resize to prevent\n * the \"content outraces scroll\" bug.\n */\nexport function useAutoScroll<T extends HTMLElement>({\n enabled = true,\n smooth = true,\n scrollToBottomOnMount = true,\n}: UseAutoScrollOptions = {}): UseAutoScrollReturn<T> {\n const containerRef = useRef<T>(null);\n const [isAtBottom, setIsAtBottom] = useState(true);\n const lastScrollTopRef = useRef(0);\n\n // When scrollToBottom() is called, store the behavior.\n // On subsequent resize/mutation callbacks, re-scroll with the same behavior\n // until the bottom is actually reached. This prevents the \"content outraces\n // scroll\" bug where new content pushes the bottom away faster than smooth\n // scrolling can reach it.\n const scrollingToBottomBehaviorRef = useRef<ScrollBehavior | null>(null);\n\n const scrollToBottom = useCallback(\n (behavior?: ScrollBehavior) => {\n const container = containerRef.current;\n if (!container) return;\n\n const b = behavior ?? (smooth ? \"smooth\" : \"instant\");\n scrollingToBottomBehaviorRef.current = b;\n container.scrollTo({ top: container.scrollHeight, behavior: b });\n },\n [smooth],\n );\n\n // Determine if we're at the bottom (1px tolerance, or content fits without scroll)\n const computeIsAtBottom = useCallback((el: HTMLElement): boolean => {\n return (\n Math.abs(el.scrollHeight - el.scrollTop - el.clientHeight) < 1 ||\n el.scrollHeight <= el.clientHeight\n );\n }, []);\n\n // Scroll event handler — updates isAtBottom state\n const handleScroll = useCallback(() => {\n const container = containerRef.current;\n if (!container) return;\n\n const newIsAtBottom = computeIsAtBottom(container);\n\n // If user is scrolling UP while we're in the middle of a scrollToBottom,\n // don't flip isAtBottom to false (ignore scroll-down momentum).\n if (!newIsAtBottom && lastScrollTopRef.current < container.scrollTop) {\n // Scroll is moving down — likely from our scrollToBottom call, ignore\n } else {\n if (newIsAtBottom) {\n scrollingToBottomBehaviorRef.current = null;\n }\n\n // Only update state when behavior ref is cleared (i.e. not mid-scroll)\n // or when we actually reached the bottom\n const shouldUpdate =\n newIsAtBottom || scrollingToBottomBehaviorRef.current === null;\n\n if (shouldUpdate) {\n setIsAtBottom(newIsAtBottom);\n }\n }\n\n lastScrollTopRef.current = container.scrollTop;\n }, [computeIsAtBottom]);\n\n // Content resize handler — called by both ResizeObserver and MutationObserver\n const handleContentResize = useCallback(() => {\n const scrollBehavior = scrollingToBottomBehaviorRef.current;\n if (scrollBehavior) {\n // We're in the middle of a scrollToBottom — keep chasing the bottom\n scrollToBottom(scrollBehavior);\n } else if (enabled) {\n // Auto-scroll only if already at bottom\n const container = containerRef.current;\n if (container && computeIsAtBottom(container)) {\n scrollToBottom(\"instant\");\n }\n }\n\n handleScroll();\n }, [enabled, scrollToBottom, computeIsAtBottom, handleScroll]);\n\n // ResizeObserver — catches height changes from image loads, layout shifts, etc.\n useEffect(() => {\n const container = containerRef.current;\n if (!container || !enabled) return;\n\n const resizeObserver = new ResizeObserver(() => {\n handleContentResize();\n });\n\n resizeObserver.observe(container);\n return () => resizeObserver.disconnect();\n }, [enabled, handleContentResize]);\n\n // MutationObserver — catches new messages, streaming text, DOM changes\n useEffect(() => {\n const container = containerRef.current;\n if (!container || !enabled) return;\n\n const mutationObserver = new MutationObserver((mutations) => {\n // Filter out style-only attribute mutations to prevent feedback loops\n // (e.g. components that write styles in response to viewport changes)\n const hasRelevantMutation = mutations.some(\n (m) => m.type !== \"attributes\" || m.attributeName !== \"style\",\n );\n if (hasRelevantMutation) {\n handleContentResize();\n }\n });\n\n mutationObserver.observe(container, {\n childList: true,\n subtree: true,\n attributes: true,\n characterData: true,\n });\n\n return () => mutationObserver.disconnect();\n }, [enabled, handleContentResize]);\n\n // Scroll listener\n useEffect(() => {\n const container = containerRef.current;\n if (!container) return;\n\n container.addEventListener(\"scroll\", handleScroll, { passive: true });\n return () => container.removeEventListener(\"scroll\", handleScroll);\n }, [handleScroll]);\n\n // Scroll to bottom on mount\n useEffect(() => {\n if (enabled && scrollToBottomOnMount) {\n // Use instant on mount — no need for smooth animation on initial load\n scrollingToBottomBehaviorRef.current = \"instant\";\n requestAnimationFrame(() => {\n scrollToBottom(\"instant\");\n });\n }\n // Only run on mount\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n return {\n containerRef,\n scrollToBottom,\n isAtBottom,\n };\n}\n","import { useState, useCallback, useRef, type KeyboardEvent } from \"react\";\n\ninterface UseMessageComposerOptions {\n /** Callback when message is submitted */\n onSubmit: (content: string, attachments?: File[]) => Promise<void>;\n /** Whether submission is disabled */\n disabled?: boolean;\n /** Maximum file size in bytes */\n maxFileSize?: number;\n /** Allowed file types (MIME types) */\n allowedFileTypes?: string[];\n}\n\n/**\n * Hook to manage message composer state and behavior.\n */\nexport function useMessageComposer({\n onSubmit,\n disabled = false,\n maxFileSize = 10 * 1024 * 1024, // 10MB\n allowedFileTypes,\n}: UseMessageComposerOptions) {\n const [content, setContent] = useState(\"\");\n const [attachments, setAttachments] = useState<File[]>([]);\n const [isSubmitting, setIsSubmitting] = useState(false);\n const [error, setError] = useState<string | null>(null);\n\n const inputRef = useRef<HTMLTextAreaElement>(null);\n const isSubmittingRef = useRef(false);\n\n const handleContentChange = useCallback((value: string) => {\n setContent(value);\n setError(null);\n }, []);\n\n const handleAddAttachment = useCallback(\n (files: FileList | File[]) => {\n const fileArray = Array.from(files);\n const validFiles: File[] = [];\n\n for (const file of fileArray) {\n // Check file size\n if (file.size > maxFileSize) {\n setError(`File \"${file.name}\" exceeds maximum size`);\n continue;\n }\n\n // Check file type\n if (allowedFileTypes && !allowedFileTypes.includes(file.type)) {\n setError(`File type \"${file.type}\" is not allowed`);\n continue;\n }\n\n validFiles.push(file);\n }\n\n setAttachments((prev) => [...prev, ...validFiles]);\n },\n [maxFileSize, allowedFileTypes]\n );\n\n const handleRemoveAttachment = useCallback((index: number) => {\n setAttachments((prev) => prev.filter((_, i) => i !== index));\n }, []);\n\n const handleSubmit = useCallback(async () => {\n const trimmedContent = content.trim();\n if ((!trimmedContent && attachments.length === 0) || disabled || isSubmitting || isSubmittingRef.current) {\n return;\n }\n\n // Lock immediately to prevent double-send race condition\n isSubmittingRef.current = true;\n setIsSubmitting(true);\n setError(null);\n\n try {\n await onSubmit(trimmedContent, attachments.length > 0 ? attachments : undefined);\n setContent(\"\");\n setAttachments([]);\n inputRef.current?.focus();\n } catch (err) {\n setError(err instanceof Error ? err.message : \"Failed to send message\");\n } finally {\n setIsSubmitting(false);\n isSubmittingRef.current = false;\n }\n }, [content, attachments, disabled, isSubmitting, onSubmit]);\n\n const handleKeyDown = useCallback(\n (e: KeyboardEvent<HTMLTextAreaElement>) => {\n // Submit on Enter without Shift\n if (e.key === \"Enter\" && !e.shiftKey) {\n e.preventDefault();\n handleSubmit();\n }\n },\n [handleSubmit]\n );\n\n const clear = useCallback(() => {\n setContent(\"\");\n setAttachments([]);\n setError(null);\n }, []);\n\n const canSubmit = (content.trim() || attachments.length > 0) && !disabled && !isSubmitting;\n\n return {\n content,\n attachments,\n isSubmitting,\n error,\n canSubmit,\n inputRef,\n handleContentChange,\n handleAddAttachment,\n handleRemoveAttachment,\n handleSubmit,\n handleKeyDown,\n clear,\n };\n}\n"]}
@@ -1,2 +1,2 @@
1
- import {a,b}from'./chunk-65VDOUZG.js';import {createContext,forwardRef,useContext}from'react';import {jsx,Fragment,jsxs}from'react/jsx-runtime';var d=createContext(null);function g(){let e=useContext(d);if(!e)throw new Error("useMessage must be used within a Message component");return e}var S=forwardRef(({message:e,viewerRole:t="user",children:r,...n},s)=>{let o=(e.participant?.role||"").toLowerCase()===(t||"").toLowerCase(),i=e.isStreaming??false;return jsx(d.Provider,{value:{message:e,isViewer:o,isStreaming:i},children:jsx("div",{ref:s,"data-role":e.participant?.role,"data-viewer":o,"data-streaming":i,...n,children:r})})});S.displayName="Message";var L=forwardRef(({children:e,...t},r)=>{let{message:n}=g();return jsx("div",{ref:r,...t,children:e??n.textContent})});L.displayName="MessageContent";var h=forwardRef(({format:e,...t},r)=>{let{message:n}=g(),s=typeof n.createdAt=="string"?new Date(n.createdAt):n.createdAt,o=e?e(s):s.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:true});return jsx("span",{ref:r,...t,children:o})});h.displayName="MessageTimestamp";var R=forwardRef(({children:e,autoScroll:t=true,onIsAtBottomChange:r,onScrollToBottomRef:n,...s},o)=>{let{containerRef:i,scrollToBottom:a$1,isAtBottom:p}=a({enabled:t});return {current:p}.current!==p&&r?.(p),n?.(a$1),jsx("div",{ref:c=>{i.current=c,typeof o=="function"?o(c):o&&(o.current=c);},...s,children:e})});R.displayName="MessageList";var M=createContext(null);function x(){let e=useContext(M);if(!e)throw new Error("useComposer must be used within a MessageComposer component");return e}var P=forwardRef(({onSubmit:e,disabled:t=false,children:r,className:n},s)=>{let o=b({onSubmit:e,disabled:t}),i=p=>{p.preventDefault(),o.handleSubmit();},a={...o,canSubmit:!!o.canSubmit};return jsx(M.Provider,{value:a,children:jsx("form",{ref:s,className:n,onSubmit:i,"data-submitting":o.isSubmitting,"data-can-submit":o.canSubmit,children:r})})});P.displayName="MessageComposer";var H=forwardRef((e,t)=>{let{content:r,handleContentChange:n,handleKeyDown:s,inputRef:o}=x();return jsx("textarea",{ref:a=>{o.current=a,typeof t=="function"?t(a):t&&(t.current=a);},value:r,onChange:a=>n(a.target.value),onKeyDown:s,...e})});H.displayName="ComposerInput";var E=forwardRef(({children:e,disabled:t,...r},n)=>{let{canSubmit:s,isSubmitting:o}=x();return jsx("button",{ref:n,type:"submit",disabled:t||!s,"data-submitting":o,...r,children:e})});E.displayName="ComposerSubmit";function G(e){let t=e.trim().split(/\s+/);return t.length===1?t[0].charAt(0).toUpperCase():(t[0].charAt(0)+t[t.length-1].charAt(0)).toUpperCase()}var N=forwardRef(({name:e,src:t,alt:r,role:n,fallback:s,children:o,...i},a)=>{let p=e?G(e):null;return jsx("div",{ref:a,"data-role":n,...i,children:o??jsx(Fragment,{children:t?jsx("img",{src:t,alt:r??e??n??"Avatar",style:{width:"100%",height:"100%"}}):s??p??n?.charAt(0).toUpperCase()})})});N.displayName="Avatar";var w=forwardRef(({content:e,isStreaming:t=false,showCursor:r=true,cursor:n,children:s,...o},i)=>jsxs("div",{ref:i,"data-streaming":t,...o,children:[s??e,t&&r&&(n??jsx("span",{"aria-hidden":"true",style:{display:"inline-block",width:"2px",height:"1em",backgroundColor:"currentColor",marginLeft:"2px",verticalAlign:"text-bottom",animation:"blink 1s step-end infinite"}}))]}));w.displayName="StreamingText";var T=createContext(null);function D(){let e=useContext(T);if(!e)throw new Error("useSuggestedActions must be used within a SuggestedActions component");return e}var I=forwardRef(({actions:e,onSelect:t,children:r,className:n},s)=>e.length===0?null:jsx(T.Provider,{value:{actions:e,onSelect:t},children:jsx("div",{ref:s,role:"group","aria-label":"Suggested actions",className:n,children:r})}));I.displayName="SuggestedActions";var k=forwardRef(({action:e,children:t,onClick:r,...n},s)=>{let{onSelect:o}=D();return jsx("button",{ref:s,type:"button",onClick:a=>{r?.(a),a.defaultPrevented||o(e);},...n,children:t??e.label})});k.displayName="ActionButton";var V=forwardRef(({children:e,dotCount:t=3,...r},n)=>jsx("div",{ref:n,role:"status","aria-label":"Assistant is typing",...r,children:e??jsx("span",{"aria-hidden":"true",children:Array.from({length:t}).map((s,o)=>jsx("span",{style:{display:"inline-block",width:"6px",height:"6px",borderRadius:"50%",backgroundColor:"currentColor",marginRight:o<t-1?"4px":0,animation:"typing 1.4s infinite ease-in-out",animationDelay:`${o*.2}s`}},o))})}));V.displayName="TypingIndicator";export{d as a,g as b,S as c,L as d,h as e,R as f,M as g,x as h,P as i,H as j,E as k,N as l,w as m,T as n,D as o,I as p,k as q,V as r};//# sourceMappingURL=chunk-W3HWTAF6.js.map
2
- //# sourceMappingURL=chunk-W3HWTAF6.js.map
1
+ import {a,b}from'./chunk-4WWJTYYA.js';import {createContext,forwardRef,useContext}from'react';import {jsx,Fragment,jsxs}from'react/jsx-runtime';var d=createContext(null);function g(){let e=useContext(d);if(!e)throw new Error("useMessage must be used within a Message component");return e}var S=forwardRef(({message:e,viewerRole:t="user",children:r,...n},s)=>{let o=(e.participant?.role||"").toLowerCase()===(t||"").toLowerCase(),i=e.isStreaming??false;return jsx(d.Provider,{value:{message:e,isViewer:o,isStreaming:i},children:jsx("div",{ref:s,"data-role":e.participant?.role,"data-viewer":o,"data-streaming":i,...n,children:r})})});S.displayName="Message";var L=forwardRef(({children:e,...t},r)=>{let{message:n}=g();return jsx("div",{ref:r,...t,children:e??n.textContent})});L.displayName="MessageContent";var h=forwardRef(({format:e,...t},r)=>{let{message:n}=g(),s=typeof n.createdAt=="string"?new Date(n.createdAt):n.createdAt,o=e?e(s):s.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:true});return jsx("span",{ref:r,...t,children:o})});h.displayName="MessageTimestamp";var R=forwardRef(({children:e,autoScroll:t=true,onIsAtBottomChange:r,onScrollToBottomRef:n,...s},o)=>{let{containerRef:i,scrollToBottom:a$1,isAtBottom:p}=a({enabled:t});return {current:p}.current!==p&&r?.(p),n?.(a$1),jsx("div",{ref:c=>{i.current=c,typeof o=="function"?o(c):o&&(o.current=c);},...s,children:e})});R.displayName="MessageList";var M=createContext(null);function x(){let e=useContext(M);if(!e)throw new Error("useComposer must be used within a MessageComposer component");return e}var P=forwardRef(({onSubmit:e,disabled:t=false,children:r,className:n},s)=>{let o=b({onSubmit:e,disabled:t}),i=p=>{p.preventDefault(),o.handleSubmit();},a={...o,canSubmit:!!o.canSubmit};return jsx(M.Provider,{value:a,children:jsx("form",{ref:s,className:n,onSubmit:i,"data-submitting":o.isSubmitting,"data-can-submit":o.canSubmit,children:r})})});P.displayName="MessageComposer";var H=forwardRef((e,t)=>{let{content:r,handleContentChange:n,handleKeyDown:s,inputRef:o}=x();return jsx("textarea",{ref:a=>{o.current=a,typeof t=="function"?t(a):t&&(t.current=a);},value:r,onChange:a=>n(a.target.value),onKeyDown:s,...e})});H.displayName="ComposerInput";var E=forwardRef(({children:e,disabled:t,...r},n)=>{let{canSubmit:s,isSubmitting:o}=x();return jsx("button",{ref:n,type:"submit",disabled:t||!s,"data-submitting":o,...r,children:e})});E.displayName="ComposerSubmit";function G(e){let t=e.trim().split(/\s+/);return t.length===1?t[0].charAt(0).toUpperCase():(t[0].charAt(0)+t[t.length-1].charAt(0)).toUpperCase()}var N=forwardRef(({name:e,src:t,alt:r,role:n,fallback:s,children:o,...i},a)=>{let p=e?G(e):null;return jsx("div",{ref:a,"data-role":n,...i,children:o??jsx(Fragment,{children:t?jsx("img",{src:t,alt:r??e??n??"Avatar",style:{width:"100%",height:"100%"}}):s??p??n?.charAt(0).toUpperCase()})})});N.displayName="Avatar";var w=forwardRef(({content:e,isStreaming:t=false,showCursor:r=true,cursor:n,children:s,...o},i)=>jsxs("div",{ref:i,"data-streaming":t,...o,children:[s??e,t&&r&&(n??jsx("span",{"aria-hidden":"true",style:{display:"inline-block",width:"2px",height:"1em",backgroundColor:"currentColor",marginLeft:"2px",verticalAlign:"text-bottom",animation:"blink 1s step-end infinite"}}))]}));w.displayName="StreamingText";var T=createContext(null);function D(){let e=useContext(T);if(!e)throw new Error("useSuggestedActions must be used within a SuggestedActions component");return e}var I=forwardRef(({actions:e,onSelect:t,children:r,className:n},s)=>e.length===0?null:jsx(T.Provider,{value:{actions:e,onSelect:t},children:jsx("div",{ref:s,role:"group","aria-label":"Suggested actions",className:n,children:r})}));I.displayName="SuggestedActions";var k=forwardRef(({action:e,children:t,onClick:r,...n},s)=>{let{onSelect:o}=D();return jsx("button",{ref:s,type:"button",onClick:a=>{r?.(a),a.defaultPrevented||o(e);},...n,children:t??e.label})});k.displayName="ActionButton";var V=forwardRef(({children:e,dotCount:t=3,...r},n)=>jsx("div",{ref:n,role:"status","aria-label":"Assistant is typing",...r,children:e??jsx("span",{"aria-hidden":"true",children:Array.from({length:t}).map((s,o)=>jsx("span",{style:{display:"inline-block",width:"6px",height:"6px",borderRadius:"50%",backgroundColor:"currentColor",marginRight:o<t-1?"4px":0,animation:"typing 1.4s infinite ease-in-out",animationDelay:`${o*.2}s`}},o))})}));V.displayName="TypingIndicator";export{d as a,g as b,S as c,L as d,h as e,R as f,M as g,x as h,P as i,H as j,E as k,N as l,w as m,T as n,D as o,I as p,k as q,V as r};//# sourceMappingURL=chunk-6RN7SUWT.js.map
2
+ //# sourceMappingURL=chunk-6RN7SUWT.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/primitives/message.tsx","../src/primitives/message-list.tsx","../src/primitives/message-composer.tsx","../src/primitives/avatar.tsx","../src/primitives/streaming-text.tsx","../src/primitives/suggested-actions.tsx","../src/primitives/typing-indicator.tsx"],"names":["MessageContext","createContext","useMessage","context","useContext","Message","forwardRef","message","viewerRole","children","props","ref","isViewer","isStreaming","jsx","MessageContent","MessageTimestamp","format","date","formatted","MessageList","autoScroll","onIsAtBottomChange","onScrollToBottomRef","containerRef","scrollToBottom","isAtBottom","useAutoScroll","node","ComposerContext","useComposer","MessageComposer","onSubmit","disabled","className","composer","useMessageComposer","handleFormSubmit","e","contextValue","ComposerInput","content","handleContentChange","handleKeyDown","inputRef","ComposerSubmit","canSubmit","isSubmitting","getInitials","name","parts","Avatar","src","alt","role","fallback","initials","Fragment","StreamingText","showCursor","cursor","jsxs","SuggestedActionsContext","useSuggestedActions","SuggestedActions","actions","onSelect","ActionButton","action","onClick","TypingIndicator","dotCount","_","i"],"mappings":"gJASA,IAAMA,CAAAA,CAAiBC,cAA0C,IAAI,EAM9D,SAASC,CAAAA,EAAa,CAC5B,IAAMC,EAAUC,UAAAA,CAAWJ,CAAc,CAAA,CACzC,GAAI,CAACG,CAAAA,CACJ,MAAM,IAAI,KAAA,CAAM,oDAAoD,CAAA,CAErE,OAAOA,CACR,CAeO,IAAME,CAAAA,CAAUC,UAAAA,CACtB,CAAC,CAAE,OAAA,CAAAC,EAAS,UAAA,CAAAC,CAAAA,CAAa,MAAA,CAAQ,QAAA,CAAAC,CAAAA,CAAU,GAAGC,CAAM,CAAA,CAAGC,CAAAA,GAAQ,CAE9D,IAAMC,CAAAA,CAAAA,CAAYL,CAAAA,CAAQ,WAAA,EAAa,MAAQ,EAAA,EAAI,WAAA,EAAY,GAAA,CAAOC,CAAAA,EAAc,EAAA,EAAI,WAAA,GAClFK,CAAAA,CAAcN,CAAAA,CAAQ,WAAA,EAAe,KAAA,CAE3C,OACCO,GAAAA,CAACd,EAAe,QAAA,CAAf,CAAwB,KAAA,CAAO,CAAE,OAAA,CAAAO,CAAAA,CAAS,QAAA,CAAAK,CAAAA,CAAU,WAAA,CAAAC,CAAY,CAAA,CAChE,QAAA,CAAAC,GAAAA,CAAC,KAAA,CAAA,CACA,IAAKH,CAAAA,CACL,WAAA,CAAWJ,CAAAA,CAAQ,WAAA,EAAa,IAAA,CAChC,aAAA,CAAaK,EACb,gBAAA,CAAgBC,CAAAA,CACf,GAAGH,CAAAA,CACH,QAAA,CAAAD,CAAAA,CACF,EACD,CAEF,CACD,EAEAJ,CAAAA,CAAQ,WAAA,CAAc,SAAA,CAWf,IAAMU,CAAAA,CAAiBT,UAAAA,CAAgD,CAAC,CAAE,QAAA,CAAAG,CAAAA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AA,CAAO,KAAA,CACtB,CAEJ,CACF,EAEAD,CAAAA,CAAa,YAAc,cAAA,CC9EpB,IAAMG,CAAAA,CAAkBhE,UAAAA,CAC7B,CAAC,CAAE,SAAAG,CAAAA,CAAU,QAAA,CAAA8D,CAAAA,CAAW,CAAA,CAAG,GAAG7D,CAAM,CAAA,CAAGC,CAAAA,GAEnCG,GAAAA,CAAC,KAAA,CAAA,CAAI,GAAA,CAAKH,CAAAA,CAAK,IAAA,CAAK,QAAA,CAAS,aAAW,qBAAA,CAAuB,GAAGD,CAAAA,CAC/D,QAAA,CAAAD,CAAAA,EACCK,GAAAA,CAAC,QAAK,aAAA,CAAY,MAAA,CACf,QAAA,CAAA,KAAA,CAAM,IAAA,CAAK,CAAE,MAAA,CAAQyD,CAAS,CAAC,CAAA,CAAE,GAAA,CAAI,CAACC,CAAAA,CAAGC,CAAAA,GACxC3D,GAAAA,CAAC,MAAA,CAAA,CAEC,KAAA,CAAO,CACL,OAAA,CAAS,cAAA,CACT,KAAA,CAAO,KAAA,CACP,OAAQ,KAAA,CACR,YAAA,CAAc,KAAA,CACd,eAAA,CAAiB,cAAA,CACjB,WAAA,CAAa2D,EAAIF,CAAAA,CAAW,CAAA,CAAI,KAAA,CAAQ,CAAA,CACxC,SAAA,CAAW,kCAAA,CACX,eAAgB,CAAA,EAAGE,CAAAA,CAAI,EAAG,CAAA,CAAA,CAC5B,CAAA,CAAA,CAVKA,CAWP,CACD,CAAA,CACH,CAAA,CAEJ,CAGN,EAEAH,CAAAA,CAAgB,WAAA,CAAc,iBAAA","file":"chunk-W3HWTAF6.js","sourcesContent":["import { createContext, forwardRef, useContext, type HTMLAttributes, type ReactNode } from \"react\";\nimport type { MessageData, ParticipantRole } from \"../types\";\n\ninterface MessageContextValue {\n\tmessage: MessageData;\n\tisViewer: boolean;\n\tisStreaming: boolean;\n}\n\nconst MessageContext = createContext<MessageContextValue | null>(null);\n\n/**\n * Hook to access the current message context.\n * Must be used within a Message component.\n */\nexport function useMessage() {\n\tconst context = useContext(MessageContext);\n\tif (!context) {\n\t\tthrow new Error(\"useMessage must be used within a Message component\");\n\t}\n\treturn context;\n}\n\nexport interface MessageProps extends HTMLAttributes<HTMLDivElement> {\n\t/** The message data */\n\tmessage: MessageData;\n\t/** The viewer's role (used to determine alignment) */\n\tviewerRole?: ParticipantRole;\n\t/** Children to render inside the message */\n\tchildren: ReactNode;\n}\n\n/**\n * Headless Message primitive.\n * Provides message context to children and data attributes for styling.\n */\nexport const Message = forwardRef<HTMLDivElement, MessageProps>(\n\t({ message, viewerRole = \"user\", children, ...props }, ref) => {\n\t\t// Case-insensitive comparison for role matching\n\t\tconst isViewer = (message.participant?.role || \"\").toLowerCase() === (viewerRole || \"\").toLowerCase();\n\t\tconst isStreaming = message.isStreaming ?? false;\n\n\t\treturn (\n\t\t\t<MessageContext.Provider value={{ message, isViewer, isStreaming }}>\n\t\t\t\t<div\n\t\t\t\t\tref={ref}\n\t\t\t\t\tdata-role={message.participant?.role}\n\t\t\t\t\tdata-viewer={isViewer}\n\t\t\t\t\tdata-streaming={isStreaming}\n\t\t\t\t\t{...props}>\n\t\t\t\t\t{children}\n\t\t\t\t</div>\n\t\t\t</MessageContext.Provider>\n\t\t);\n\t},\n);\n\nMessage.displayName = \"Message\";\n\nexport interface MessageContentProps extends HTMLAttributes<HTMLDivElement> {\n\t/** Custom content to render instead of message text */\n\tchildren?: ReactNode;\n}\n\n/**\n * Renders the message content.\n * By default renders the message's textContent.\n */\nexport const MessageContent = forwardRef<HTMLDivElement, MessageContentProps>(({ children, ...props }, ref) => {\n\tconst { message } = useMessage();\n\n\treturn (\n\t\t<div ref={ref} {...props}>\n\t\t\t{children ?? message.textContent}\n\t\t</div>\n\t);\n});\n\nMessageContent.displayName = \"MessageContent\";\n\nexport interface MessageTimestampProps extends HTMLAttributes<HTMLSpanElement> {\n\t/** Custom date formatter */\n\tformat?: (date: Date) => string;\n}\n\n/**\n * Renders the message timestamp.\n */\nexport const MessageTimestamp = forwardRef<HTMLSpanElement, MessageTimestampProps>(({ format, ...props }, ref) => {\n\tconst { message } = useMessage();\n\tconst date = typeof message.createdAt === \"string\" ? new Date(message.createdAt) : message.createdAt;\n\n\tconst formatted = format\n\t\t? format(date)\n\t\t: date.toLocaleTimeString(\"en-US\", {\n\t\t\t\thour: \"numeric\",\n\t\t\t\tminute: \"2-digit\",\n\t\t\t\thour12: true,\n\t\t\t});\n\n\treturn (\n\t\t<span ref={ref} {...props}>\n\t\t\t{formatted}\n\t\t</span>\n\t);\n});\n\nMessageTimestamp.displayName = \"MessageTimestamp\";\n\nexport { MessageContext };\n","import { forwardRef, type HTMLAttributes, type ReactNode } from \"react\";\nimport { useAutoScroll } from \"../hooks/use-auto-scroll\";\n\nexport interface MessageListProps extends HTMLAttributes<HTMLDivElement> {\n\t/** Messages to render */\n\tchildren: ReactNode;\n\t/** Whether to auto-scroll to bottom on new messages */\n\tautoScroll?: boolean;\n\t/** Whether the viewport is currently at the bottom (exposed for scroll-to-bottom button) */\n\tisAtBottom?: boolean;\n\t/** Callback to receive scroll state updates */\n\tonIsAtBottomChange?: (isAtBottom: boolean) => void;\n\t/** Callback to receive scrollToBottom function */\n\tonScrollToBottomRef?: (scrollToBottom: (behavior?: ScrollBehavior) => void) => void;\n}\n\n/**\n * Headless MessageList primitive.\n * Provides a scrollable container with auto-scroll behavior.\n * Exposes isAtBottom and scrollToBottom for scroll-to-bottom button integration.\n */\nexport const MessageList = forwardRef<HTMLDivElement, MessageListProps>(\n\t({ children, autoScroll = true, onIsAtBottomChange, onScrollToBottomRef, ...props }, ref) => {\n\t\tconst { containerRef, scrollToBottom, isAtBottom } = useAutoScroll<HTMLDivElement>({\n\t\t\tenabled: autoScroll,\n\t\t});\n\n\t\t// Notify parent of scroll state changes\n\t\tconst prevIsAtBottomRef = { current: isAtBottom };\n\t\tif (prevIsAtBottomRef.current !== isAtBottom) {\n\t\t\tonIsAtBottomChange?.(isAtBottom);\n\t\t}\n\n\t\t// Expose scrollToBottom to parent\n\t\tonScrollToBottomRef?.(scrollToBottom);\n\n\t\t// Merge refs\n\t\tconst mergedRef = (node: HTMLDivElement | null) => {\n\t\t\t(containerRef as React.MutableRefObject<HTMLDivElement | null>).current = node;\n\t\t\tif (typeof ref === \"function\") {\n\t\t\t\tref(node);\n\t\t\t} else if (ref) {\n\t\t\t\tref.current = node;\n\t\t\t}\n\t\t};\n\n\t\treturn (\n\t\t\t<div ref={mergedRef} {...props}>\n\t\t\t\t{children}\n\t\t\t</div>\n\t\t);\n\t},\n);\n\nMessageList.displayName = \"MessageList\";\n","import {\n createContext,\n useContext,\n forwardRef,\n type ReactNode,\n type TextareaHTMLAttributes,\n type ButtonHTMLAttributes,\n} from \"react\";\nimport { useMessageComposer } from \"../hooks/use-message-composer\";\n\ninterface ComposerContextValue {\n content: string;\n isSubmitting: boolean;\n canSubmit: boolean;\n error: string | null;\n handleContentChange: (value: string) => void;\n handleSubmit: () => Promise<void>;\n handleKeyDown: (e: React.KeyboardEvent<HTMLTextAreaElement>) => void;\n inputRef: React.RefObject<HTMLTextAreaElement | null>;\n}\n\nconst ComposerContext = createContext<ComposerContextValue | null>(null);\n\n/**\n * Hook to access the composer context.\n * Must be used within a MessageComposer component.\n */\nexport function useComposer() {\n const context = useContext(ComposerContext);\n if (!context) {\n throw new Error(\"useComposer must be used within a MessageComposer component\");\n }\n return context;\n}\n\nexport interface MessageComposerProps {\n /** Callback when message is submitted */\n onSubmit: (content: string, attachments?: File[]) => Promise<void>;\n /** Whether the composer is disabled */\n disabled?: boolean;\n /** Children to render inside the composer */\n children: ReactNode;\n /** Additional CSS classes */\n className?: string;\n}\n\n/**\n * Headless MessageComposer primitive.\n * Provides composer state and behavior to children.\n */\nexport const MessageComposer = forwardRef<HTMLFormElement, MessageComposerProps>(\n ({ onSubmit, disabled = false, children, className }, ref) => {\n const composer = useMessageComposer({ onSubmit, disabled });\n\n const handleFormSubmit = (e: React.FormEvent) => {\n e.preventDefault();\n composer.handleSubmit();\n };\n\n const contextValue: ComposerContextValue = {\n ...composer,\n canSubmit: Boolean(composer.canSubmit),\n };\n\n return (\n <ComposerContext.Provider value={contextValue}>\n <form\n ref={ref}\n className={className}\n onSubmit={handleFormSubmit}\n data-submitting={composer.isSubmitting}\n data-can-submit={composer.canSubmit}\n >\n {children}\n </form>\n </ComposerContext.Provider>\n );\n }\n);\n\nMessageComposer.displayName = \"MessageComposer\";\n\nexport interface ComposerInputProps\n extends Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, \"onChange\" | \"value\"> {}\n\n/**\n * Text input for the message composer.\n */\nexport const ComposerInput = forwardRef<HTMLTextAreaElement, ComposerInputProps>(\n (props, ref) => {\n const { content, handleContentChange, handleKeyDown, inputRef } = useComposer();\n\n // Merge refs\n const mergedRef = (node: HTMLTextAreaElement | null) => {\n (inputRef as React.MutableRefObject<HTMLTextAreaElement | null>).current = node;\n if (typeof ref === \"function\") {\n ref(node);\n } else if (ref) {\n ref.current = node;\n }\n };\n\n return (\n <textarea\n ref={mergedRef}\n value={content}\n onChange={(e) => handleContentChange(e.target.value)}\n onKeyDown={handleKeyDown}\n {...props}\n />\n );\n }\n);\n\nComposerInput.displayName = \"ComposerInput\";\n\nexport interface ComposerSubmitProps extends ButtonHTMLAttributes<HTMLButtonElement> {}\n\n/**\n * Submit button for the message composer.\n */\nexport const ComposerSubmit = forwardRef<HTMLButtonElement, ComposerSubmitProps>(\n ({ children, disabled, ...props }, ref) => {\n const { canSubmit, isSubmitting } = useComposer();\n\n return (\n <button\n ref={ref}\n type=\"submit\"\n disabled={disabled || !canSubmit}\n data-submitting={isSubmitting}\n {...props}\n >\n {children}\n </button>\n );\n }\n);\n\nComposerSubmit.displayName = \"ComposerSubmit\";\n\nexport { ComposerContext };\n","import { forwardRef, type HTMLAttributes } from \"react\";\nimport type { ParticipantRole } from \"../types\";\n\nexport interface AvatarProps extends HTMLAttributes<HTMLDivElement> {\n /** Name for fallback initials */\n name?: string;\n /** Image URL */\n src?: string;\n /** Alt text for image */\n alt?: string;\n /** Participant role for styling */\n role?: ParticipantRole;\n /** Fallback content when no image or name */\n fallback?: React.ReactNode;\n}\n\n/**\n * Get initials from a name.\n */\nfunction getInitials(name: string): string {\n const parts = name.trim().split(/\\s+/);\n if (parts.length === 1) {\n return parts[0].charAt(0).toUpperCase();\n }\n return (parts[0].charAt(0) + parts[parts.length - 1].charAt(0)).toUpperCase();\n}\n\n/**\n * Headless Avatar primitive.\n * Renders an image or fallback initials.\n */\nexport const Avatar = forwardRef<HTMLDivElement, AvatarProps>(\n ({ name, src, alt, role, fallback, children, ...props }, ref) => {\n const initials = name ? getInitials(name) : null;\n const altText = alt ?? name ?? role ?? \"Avatar\";\n\n return (\n <div ref={ref} data-role={role} {...props}>\n {children ?? (\n <>\n {src ? (\n <img src={src} alt={altText} style={{ width: \"100%\", height: \"100%\" }} />\n ) : (\n fallback ?? initials ?? role?.charAt(0).toUpperCase()\n )}\n </>\n )}\n </div>\n );\n }\n);\n\nAvatar.displayName = \"Avatar\";\n","import { forwardRef, type HTMLAttributes, type ReactNode } from \"react\";\n\nexport interface StreamingTextProps extends HTMLAttributes<HTMLDivElement> {\n /** The content to display */\n content: string;\n /** Whether the text is currently streaming */\n isStreaming?: boolean;\n /** Show a cursor indicator while streaming */\n showCursor?: boolean;\n /** Custom cursor element */\n cursor?: ReactNode;\n /** Children override (takes precedence over content) */\n children?: ReactNode;\n}\n\n/**\n * Headless StreamingText primitive.\n * Renders text with streaming indicator support.\n */\nexport const StreamingText = forwardRef<HTMLDivElement, StreamingTextProps>(\n (\n { content, isStreaming = false, showCursor = true, cursor, children, ...props },\n ref\n ) => {\n const defaultCursor = (\n <span\n aria-hidden=\"true\"\n style={{\n display: \"inline-block\",\n width: \"2px\",\n height: \"1em\",\n backgroundColor: \"currentColor\",\n marginLeft: \"2px\",\n verticalAlign: \"text-bottom\",\n animation: \"blink 1s step-end infinite\",\n }}\n />\n );\n\n return (\n <div ref={ref} data-streaming={isStreaming} {...props}>\n {children ?? content}\n {isStreaming && showCursor && (cursor ?? defaultCursor)}\n </div>\n );\n }\n);\n\nStreamingText.displayName = \"StreamingText\";\n","import {\n createContext,\n useContext,\n forwardRef,\n type ReactNode,\n type ButtonHTMLAttributes,\n} from \"react\";\nimport type { SuggestedAction } from \"../types\";\n\ninterface SuggestedActionsContextValue {\n actions: SuggestedAction[];\n onSelect: (action: SuggestedAction) => void;\n}\n\nconst SuggestedActionsContext = createContext<SuggestedActionsContextValue | null>(null);\n\n/**\n * Hook to access suggested actions context.\n */\nexport function useSuggestedActions() {\n const context = useContext(SuggestedActionsContext);\n if (!context) {\n throw new Error(\n \"useSuggestedActions must be used within a SuggestedActions component\"\n );\n }\n return context;\n}\n\nexport interface SuggestedActionsProps {\n /** List of suggested actions */\n actions: SuggestedAction[];\n /** Callback when an action is selected */\n onSelect: (action: SuggestedAction) => void;\n /** Children to render */\n children: ReactNode;\n /** Additional CSS classes */\n className?: string;\n}\n\n/**\n * Headless SuggestedActions primitive.\n * Provides context for rendering action buttons.\n */\nexport const SuggestedActions = forwardRef<HTMLDivElement, SuggestedActionsProps>(\n ({ actions, onSelect, children, className }, ref) => {\n if (actions.length === 0) {\n return null;\n }\n\n return (\n <SuggestedActionsContext.Provider value={{ actions, onSelect }}>\n <div ref={ref} role=\"group\" aria-label=\"Suggested actions\" className={className}>\n {children}\n </div>\n </SuggestedActionsContext.Provider>\n );\n }\n);\n\nSuggestedActions.displayName = \"SuggestedActions\";\n\nexport interface ActionButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {\n /** The action this button represents */\n action: SuggestedAction;\n /** Children to render inside button */\n children?: ReactNode;\n}\n\n/**\n * Button for a suggested action.\n */\nexport const ActionButton = forwardRef<HTMLButtonElement, ActionButtonProps>(\n ({ action, children, onClick, ...props }, ref) => {\n const { onSelect } = useSuggestedActions();\n\n const handleClick = (e: React.MouseEvent<HTMLButtonElement>) => {\n onClick?.(e);\n if (!e.defaultPrevented) {\n onSelect(action);\n }\n };\n\n return (\n <button ref={ref} type=\"button\" onClick={handleClick} {...props}>\n {children ?? action.label}\n </button>\n );\n }\n);\n\nActionButton.displayName = \"ActionButton\";\n\nexport { SuggestedActionsContext };\n","import { forwardRef, type HTMLAttributes, type ReactNode } from \"react\";\n\nexport interface TypingIndicatorProps extends HTMLAttributes<HTMLDivElement> {\n /** Custom content to show while typing */\n children?: ReactNode;\n /** Number of dots to show */\n dotCount?: number;\n}\n\n/**\n * Headless TypingIndicator primitive.\n * Shows animated dots or custom content.\n */\nexport const TypingIndicator = forwardRef<HTMLDivElement, TypingIndicatorProps>(\n ({ children, dotCount = 3, ...props }, ref) => {\n return (\n <div ref={ref} role=\"status\" aria-label=\"Assistant is typing\" {...props}>\n {children ?? (\n <span aria-hidden=\"true\">\n {Array.from({ length: dotCount }).map((_, i) => (\n <span\n key={i}\n style={{\n display: \"inline-block\",\n width: \"6px\",\n height: \"6px\",\n borderRadius: \"50%\",\n backgroundColor: \"currentColor\",\n marginRight: i < dotCount - 1 ? \"4px\" : 0,\n animation: `typing 1.4s infinite ease-in-out`,\n animationDelay: `${i * 0.2}s`,\n }}\n />\n ))}\n </span>\n )}\n </div>\n );\n }\n);\n\nTypingIndicator.displayName = \"TypingIndicator\";\n"]}
1
+ {"version":3,"sources":["../src/primitives/message.tsx","../src/primitives/message-list.tsx","../src/primitives/message-composer.tsx","../src/primitives/avatar.tsx","../src/primitives/streaming-text.tsx","../src/primitives/suggested-actions.tsx","../src/primitives/typing-indicator.tsx"],"names":["MessageContext","createContext","useMessage","context","useContext","Message","forwardRef","message","viewerRole","children","props","ref","isViewer","isStreaming","jsx","MessageContent","MessageTimestamp","format","date","formatted","MessageList","autoScroll","onIsAtBottomChange","onScrollToBottomRef","containerRef","scrollToBottom","isAtBottom","useAutoScroll","node","ComposerContext","useComposer","MessageComposer","onSubmit","disabled","className","composer","useMessageComposer","handleFormSubmit","e","contextValue","ComposerInput","content","handleContentChange","handleKeyDown","inputRef","ComposerSubmit","canSubmit","isSubmitting","getInitials","name","parts","Avatar","src","alt","role","fallback","initials","Fragment","StreamingText","showCursor","cursor","jsxs","SuggestedActionsContext","useSuggestedActions","SuggestedActions","actions","onSelect","ActionButton","action","onClick","TypingIndicator","dotCount","_","i"],"mappings":"gJASA,IAAMA,CAAAA,CAAiBC,cAA0C,IAAI,EAM9D,SAASC,CAAAA,EAAa,CAC5B,IAAMC,EAAUC,UAAAA,CAAWJ,CAAc,CAAA,CACzC,GAAI,CAACG,CAAAA,CACJ,MAAM,IAAI,KAAA,CAAM,oDAAoD,CAAA,CAErE,OAAOA,CACR,CAeO,IAAME,CAAAA,CAAUC,UAAAA,CACtB,CAAC,CAAE,OAAA,CAAAC,EAAS,UAAA,CAAAC,CAAAA,CAAa,MAAA,CAAQ,QAAA,CAAAC,CAAAA,CAAU,GAAGC,CAAM,CAAA,CAAGC,CAAAA,GAAQ,CAE9D,IAAMC,CAAAA,CAAAA,CAAYL,CAAAA,CAAQ,WAAA,EAAa,MAAQ,EAAA,EAAI,WAAA,EAAY,GAAA,CAAOC,CAAAA,EAAc,EAAA,EAAI,WAAA,GAClFK,CAAAA,CAAcN,CAAAA,CAAQ,WAAA,EAAe,KAAA,CAE3C,OACCO,GAAAA,CAACd,EAAe,QAAA,CAAf,CAAwB,KAAA,CAAO,CAAE,OAAA,CAAAO,CAAAA,CAAS,QAAA,CAAAK,CAAAA,CAAU,WAAA,CAAAC,CAAY,CAAA,CAChE,QAAA,CAAAC,GAAAA,CAAC,KAAA,CAAA,CACA,IAAKH,CAAAA,CACL,WAAA,CAAWJ,CAAAA,CAAQ,WAAA,EAAa,IAAA,CAChC,aAAA,CAAaK,EACb,gBAAA,CAAgBC,CAAAA,CACf,GAAGH,CAAAA,CACH,QAAA,CAAAD,CAAAA,CACF,EACD,CAEF,CACD,EAEAJ,CAAAA,CAAQ,WAAA,CAAc,SAAA,CAWf,IAAMU,CAAAA,CAAiBT,UAAAA,CAAgD,CAAC,CAAE,QAAA,CAAAG,CAAAA,CAAU,GAAGC,CAAM,CAAA,CAA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ACF,EAEAD,CAAAA,CAAa,YAAc,cAAA,CC9EpB,IAAMG,CAAAA,CAAkBhE,UAAAA,CAC7B,CAAC,CAAE,SAAAG,CAAAA,CAAU,QAAA,CAAA8D,CAAAA,CAAW,CAAA,CAAG,GAAG7D,CAAM,CAAA,CAAGC,CAAAA,GAEnCG,GAAAA,CAAC,KAAA,CAAA,CAAI,GAAA,CAAKH,CAAAA,CAAK,IAAA,CAAK,QAAA,CAAS,aAAW,qBAAA,CAAuB,GAAGD,CAAAA,CAC/D,QAAA,CAAAD,CAAAA,EACCK,GAAAA,CAAC,QAAK,aAAA,CAAY,MAAA,CACf,QAAA,CAAA,KAAA,CAAM,IAAA,CAAK,CAAE,MAAA,CAAQyD,CAAS,CAAC,CAAA,CAAE,GAAA,CAAI,CAACC,CAAAA,CAAGC,CAAAA,GACxC3D,GAAAA,CAAC,MAAA,CAAA,CAEC,KAAA,CAAO,CACL,OAAA,CAAS,cAAA,CACT,KAAA,CAAO,KAAA,CACP,OAAQ,KAAA,CACR,YAAA,CAAc,KAAA,CACd,eAAA,CAAiB,cAAA,CACjB,WAAA,CAAa2D,EAAIF,CAAAA,CAAW,CAAA,CAAI,KAAA,CAAQ,CAAA,CACxC,SAAA,CAAW,kCAAA,CACX,eAAgB,CAAA,EAAGE,CAAAA,CAAI,EAAG,CAAA,CAAA,CAC5B,CAAA,CAAA,CAVKA,CAWP,CACD,CAAA,CACH,CAAA,CAEJ,CAGN,EAEAH,CAAAA,CAAgB,WAAA,CAAc,iBAAA","file":"chunk-6RN7SUWT.js","sourcesContent":["import { createContext, forwardRef, useContext, type HTMLAttributes, type ReactNode } from \"react\";\nimport type { MessageData, ParticipantRole } from \"../types\";\n\ninterface MessageContextValue {\n\tmessage: MessageData;\n\tisViewer: boolean;\n\tisStreaming: boolean;\n}\n\nconst MessageContext = createContext<MessageContextValue | null>(null);\n\n/**\n * Hook to access the current message context.\n * Must be used within a Message component.\n */\nexport function useMessage() {\n\tconst context = useContext(MessageContext);\n\tif (!context) {\n\t\tthrow new Error(\"useMessage must be used within a Message component\");\n\t}\n\treturn context;\n}\n\nexport interface MessageProps extends HTMLAttributes<HTMLDivElement> {\n\t/** The message data */\n\tmessage: MessageData;\n\t/** The viewer's role (used to determine alignment) */\n\tviewerRole?: ParticipantRole;\n\t/** Children to render inside the message */\n\tchildren: ReactNode;\n}\n\n/**\n * Headless Message primitive.\n * Provides message context to children and data attributes for styling.\n */\nexport const Message = forwardRef<HTMLDivElement, MessageProps>(\n\t({ message, viewerRole = \"user\", children, ...props }, ref) => {\n\t\t// Case-insensitive comparison for role matching\n\t\tconst isViewer = (message.participant?.role || \"\").toLowerCase() === (viewerRole || \"\").toLowerCase();\n\t\tconst isStreaming = message.isStreaming ?? false;\n\n\t\treturn (\n\t\t\t<MessageContext.Provider value={{ message, isViewer, isStreaming }}>\n\t\t\t\t<div\n\t\t\t\t\tref={ref}\n\t\t\t\t\tdata-role={message.participant?.role}\n\t\t\t\t\tdata-viewer={isViewer}\n\t\t\t\t\tdata-streaming={isStreaming}\n\t\t\t\t\t{...props}>\n\t\t\t\t\t{children}\n\t\t\t\t</div>\n\t\t\t</MessageContext.Provider>\n\t\t);\n\t},\n);\n\nMessage.displayName = \"Message\";\n\nexport interface MessageContentProps extends HTMLAttributes<HTMLDivElement> {\n\t/** Custom content to render instead of message text */\n\tchildren?: ReactNode;\n}\n\n/**\n * Renders the message content.\n * By default renders the message's textContent.\n */\nexport const MessageContent = forwardRef<HTMLDivElement, MessageContentProps>(({ children, ...props }, ref) => {\n\tconst { message } = useMessage();\n\n\treturn (\n\t\t<div ref={ref} {...props}>\n\t\t\t{children ?? message.textContent}\n\t\t</div>\n\t);\n});\n\nMessageContent.displayName = \"MessageContent\";\n\nexport interface MessageTimestampProps extends HTMLAttributes<HTMLSpanElement> {\n\t/** Custom date formatter */\n\tformat?: (date: Date) => string;\n}\n\n/**\n * Renders the message timestamp.\n */\nexport const MessageTimestamp = forwardRef<HTMLSpanElement, MessageTimestampProps>(({ format, ...props }, ref) => {\n\tconst { message } = useMessage();\n\tconst date = typeof message.createdAt === \"string\" ? new Date(message.createdAt) : message.createdAt;\n\n\tconst formatted = format\n\t\t? format(date)\n\t\t: date.toLocaleTimeString(\"en-US\", {\n\t\t\t\thour: \"numeric\",\n\t\t\t\tminute: \"2-digit\",\n\t\t\t\thour12: true,\n\t\t\t});\n\n\treturn (\n\t\t<span ref={ref} {...props}>\n\t\t\t{formatted}\n\t\t</span>\n\t);\n});\n\nMessageTimestamp.displayName = \"MessageTimestamp\";\n\nexport { MessageContext };\n","import { forwardRef, type HTMLAttributes, type ReactNode } from \"react\";\nimport { useAutoScroll } from \"../hooks/use-auto-scroll\";\n\nexport interface MessageListProps extends HTMLAttributes<HTMLDivElement> {\n\t/** Messages to render */\n\tchildren: ReactNode;\n\t/** Whether to auto-scroll to bottom on new messages */\n\tautoScroll?: boolean;\n\t/** Whether the viewport is currently at the bottom (exposed for scroll-to-bottom button) */\n\tisAtBottom?: boolean;\n\t/** Callback to receive scroll state updates */\n\tonIsAtBottomChange?: (isAtBottom: boolean) => void;\n\t/** Callback to receive scrollToBottom function */\n\tonScrollToBottomRef?: (scrollToBottom: (behavior?: ScrollBehavior) => void) => void;\n}\n\n/**\n * Headless MessageList primitive.\n * Provides a scrollable container with auto-scroll behavior.\n * Exposes isAtBottom and scrollToBottom for scroll-to-bottom button integration.\n */\nexport const MessageList = forwardRef<HTMLDivElement, MessageListProps>(\n\t({ children, autoScroll = true, onIsAtBottomChange, onScrollToBottomRef, ...props }, ref) => {\n\t\tconst { containerRef, scrollToBottom, isAtBottom } = useAutoScroll<HTMLDivElement>({\n\t\t\tenabled: autoScroll,\n\t\t});\n\n\t\t// Notify parent of scroll state changes\n\t\tconst prevIsAtBottomRef = { current: isAtBottom };\n\t\tif (prevIsAtBottomRef.current !== isAtBottom) {\n\t\t\tonIsAtBottomChange?.(isAtBottom);\n\t\t}\n\n\t\t// Expose scrollToBottom to parent\n\t\tonScrollToBottomRef?.(scrollToBottom);\n\n\t\t// Merge refs\n\t\tconst mergedRef = (node: HTMLDivElement | null) => {\n\t\t\t(containerRef as React.MutableRefObject<HTMLDivElement | null>).current = node;\n\t\t\tif (typeof ref === \"function\") {\n\t\t\t\tref(node);\n\t\t\t} else if (ref) {\n\t\t\t\tref.current = node;\n\t\t\t}\n\t\t};\n\n\t\treturn (\n\t\t\t<div ref={mergedRef} {...props}>\n\t\t\t\t{children}\n\t\t\t</div>\n\t\t);\n\t},\n);\n\nMessageList.displayName = \"MessageList\";\n","import {\n createContext,\n useContext,\n forwardRef,\n type ReactNode,\n type TextareaHTMLAttributes,\n type ButtonHTMLAttributes,\n} from \"react\";\nimport { useMessageComposer } from \"../hooks/use-message-composer\";\n\ninterface ComposerContextValue {\n content: string;\n isSubmitting: boolean;\n canSubmit: boolean;\n error: string | null;\n handleContentChange: (value: string) => void;\n handleSubmit: () => Promise<void>;\n handleKeyDown: (e: React.KeyboardEvent<HTMLTextAreaElement>) => void;\n inputRef: React.RefObject<HTMLTextAreaElement | null>;\n}\n\nconst ComposerContext = createContext<ComposerContextValue | null>(null);\n\n/**\n * Hook to access the composer context.\n * Must be used within a MessageComposer component.\n */\nexport function useComposer() {\n const context = useContext(ComposerContext);\n if (!context) {\n throw new Error(\"useComposer must be used within a MessageComposer component\");\n }\n return context;\n}\n\nexport interface MessageComposerProps {\n /** Callback when message is submitted */\n onSubmit: (content: string, attachments?: File[]) => Promise<void>;\n /** Whether the composer is disabled */\n disabled?: boolean;\n /** Children to render inside the composer */\n children: ReactNode;\n /** Additional CSS classes */\n className?: string;\n}\n\n/**\n * Headless MessageComposer primitive.\n * Provides composer state and behavior to children.\n */\nexport const MessageComposer = forwardRef<HTMLFormElement, MessageComposerProps>(\n ({ onSubmit, disabled = false, children, className }, ref) => {\n const composer = useMessageComposer({ onSubmit, disabled });\n\n const handleFormSubmit = (e: React.FormEvent) => {\n e.preventDefault();\n composer.handleSubmit();\n };\n\n const contextValue: ComposerContextValue = {\n ...composer,\n canSubmit: Boolean(composer.canSubmit),\n };\n\n return (\n <ComposerContext.Provider value={contextValue}>\n <form\n ref={ref}\n className={className}\n onSubmit={handleFormSubmit}\n data-submitting={composer.isSubmitting}\n data-can-submit={composer.canSubmit}\n >\n {children}\n </form>\n </ComposerContext.Provider>\n );\n }\n);\n\nMessageComposer.displayName = \"MessageComposer\";\n\nexport interface ComposerInputProps\n extends Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, \"onChange\" | \"value\"> {}\n\n/**\n * Text input for the message composer.\n */\nexport const ComposerInput = forwardRef<HTMLTextAreaElement, ComposerInputProps>(\n (props, ref) => {\n const { content, handleContentChange, handleKeyDown, inputRef } = useComposer();\n\n // Merge refs\n const mergedRef = (node: HTMLTextAreaElement | null) => {\n (inputRef as React.MutableRefObject<HTMLTextAreaElement | null>).current = node;\n if (typeof ref === \"function\") {\n ref(node);\n } else if (ref) {\n ref.current = node;\n }\n };\n\n return (\n <textarea\n ref={mergedRef}\n value={content}\n onChange={(e) => handleContentChange(e.target.value)}\n onKeyDown={handleKeyDown}\n {...props}\n />\n );\n }\n);\n\nComposerInput.displayName = \"ComposerInput\";\n\nexport interface ComposerSubmitProps extends ButtonHTMLAttributes<HTMLButtonElement> {}\n\n/**\n * Submit button for the message composer.\n */\nexport const ComposerSubmit = forwardRef<HTMLButtonElement, ComposerSubmitProps>(\n ({ children, disabled, ...props }, ref) => {\n const { canSubmit, isSubmitting } = useComposer();\n\n return (\n <button\n ref={ref}\n type=\"submit\"\n disabled={disabled || !canSubmit}\n data-submitting={isSubmitting}\n {...props}\n >\n {children}\n </button>\n );\n }\n);\n\nComposerSubmit.displayName = \"ComposerSubmit\";\n\nexport { ComposerContext };\n","import { forwardRef, type HTMLAttributes } from \"react\";\nimport type { ParticipantRole } from \"../types\";\n\nexport interface AvatarProps extends HTMLAttributes<HTMLDivElement> {\n /** Name for fallback initials */\n name?: string;\n /** Image URL */\n src?: string;\n /** Alt text for image */\n alt?: string;\n /** Participant role for styling */\n role?: ParticipantRole;\n /** Fallback content when no image or name */\n fallback?: React.ReactNode;\n}\n\n/**\n * Get initials from a name.\n */\nfunction getInitials(name: string): string {\n const parts = name.trim().split(/\\s+/);\n if (parts.length === 1) {\n return parts[0].charAt(0).toUpperCase();\n }\n return (parts[0].charAt(0) + parts[parts.length - 1].charAt(0)).toUpperCase();\n}\n\n/**\n * Headless Avatar primitive.\n * Renders an image or fallback initials.\n */\nexport const Avatar = forwardRef<HTMLDivElement, AvatarProps>(\n ({ name, src, alt, role, fallback, children, ...props }, ref) => {\n const initials = name ? getInitials(name) : null;\n const altText = alt ?? name ?? role ?? \"Avatar\";\n\n return (\n <div ref={ref} data-role={role} {...props}>\n {children ?? (\n <>\n {src ? (\n <img src={src} alt={altText} style={{ width: \"100%\", height: \"100%\" }} />\n ) : (\n fallback ?? initials ?? role?.charAt(0).toUpperCase()\n )}\n </>\n )}\n </div>\n );\n }\n);\n\nAvatar.displayName = \"Avatar\";\n","import { forwardRef, type HTMLAttributes, type ReactNode } from \"react\";\n\nexport interface StreamingTextProps extends HTMLAttributes<HTMLDivElement> {\n /** The content to display */\n content: string;\n /** Whether the text is currently streaming */\n isStreaming?: boolean;\n /** Show a cursor indicator while streaming */\n showCursor?: boolean;\n /** Custom cursor element */\n cursor?: ReactNode;\n /** Children override (takes precedence over content) */\n children?: ReactNode;\n}\n\n/**\n * Headless StreamingText primitive.\n * Renders text with streaming indicator support.\n */\nexport const StreamingText = forwardRef<HTMLDivElement, StreamingTextProps>(\n (\n { content, isStreaming = false, showCursor = true, cursor, children, ...props },\n ref\n ) => {\n const defaultCursor = (\n <span\n aria-hidden=\"true\"\n style={{\n display: \"inline-block\",\n width: \"2px\",\n height: \"1em\",\n backgroundColor: \"currentColor\",\n marginLeft: \"2px\",\n verticalAlign: \"text-bottom\",\n animation: \"blink 1s step-end infinite\",\n }}\n />\n );\n\n return (\n <div ref={ref} data-streaming={isStreaming} {...props}>\n {children ?? content}\n {isStreaming && showCursor && (cursor ?? defaultCursor)}\n </div>\n );\n }\n);\n\nStreamingText.displayName = \"StreamingText\";\n","import {\n createContext,\n useContext,\n forwardRef,\n type ReactNode,\n type ButtonHTMLAttributes,\n} from \"react\";\nimport type { SuggestedAction } from \"../types\";\n\ninterface SuggestedActionsContextValue {\n actions: SuggestedAction[];\n onSelect: (action: SuggestedAction) => void;\n}\n\nconst SuggestedActionsContext = createContext<SuggestedActionsContextValue | null>(null);\n\n/**\n * Hook to access suggested actions context.\n */\nexport function useSuggestedActions() {\n const context = useContext(SuggestedActionsContext);\n if (!context) {\n throw new Error(\n \"useSuggestedActions must be used within a SuggestedActions component\"\n );\n }\n return context;\n}\n\nexport interface SuggestedActionsProps {\n /** List of suggested actions */\n actions: SuggestedAction[];\n /** Callback when an action is selected */\n onSelect: (action: SuggestedAction) => void;\n /** Children to render */\n children: ReactNode;\n /** Additional CSS classes */\n className?: string;\n}\n\n/**\n * Headless SuggestedActions primitive.\n * Provides context for rendering action buttons.\n */\nexport const SuggestedActions = forwardRef<HTMLDivElement, SuggestedActionsProps>(\n ({ actions, onSelect, children, className }, ref) => {\n if (actions.length === 0) {\n return null;\n }\n\n return (\n <SuggestedActionsContext.Provider value={{ actions, onSelect }}>\n <div ref={ref} role=\"group\" aria-label=\"Suggested actions\" className={className}>\n {children}\n </div>\n </SuggestedActionsContext.Provider>\n );\n }\n);\n\nSuggestedActions.displayName = \"SuggestedActions\";\n\nexport interface ActionButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {\n /** The action this button represents */\n action: SuggestedAction;\n /** Children to render inside button */\n children?: ReactNode;\n}\n\n/**\n * Button for a suggested action.\n */\nexport const ActionButton = forwardRef<HTMLButtonElement, ActionButtonProps>(\n ({ action, children, onClick, ...props }, ref) => {\n const { onSelect } = useSuggestedActions();\n\n const handleClick = (e: React.MouseEvent<HTMLButtonElement>) => {\n onClick?.(e);\n if (!e.defaultPrevented) {\n onSelect(action);\n }\n };\n\n return (\n <button ref={ref} type=\"button\" onClick={handleClick} {...props}>\n {children ?? action.label}\n </button>\n );\n }\n);\n\nActionButton.displayName = \"ActionButton\";\n\nexport { SuggestedActionsContext };\n","import { forwardRef, type HTMLAttributes, type ReactNode } from \"react\";\n\nexport interface TypingIndicatorProps extends HTMLAttributes<HTMLDivElement> {\n /** Custom content to show while typing */\n children?: ReactNode;\n /** Number of dots to show */\n dotCount?: number;\n}\n\n/**\n * Headless TypingIndicator primitive.\n * Shows animated dots or custom content.\n */\nexport const TypingIndicator = forwardRef<HTMLDivElement, TypingIndicatorProps>(\n ({ children, dotCount = 3, ...props }, ref) => {\n return (\n <div ref={ref} role=\"status\" aria-label=\"Assistant is typing\" {...props}>\n {children ?? (\n <span aria-hidden=\"true\">\n {Array.from({ length: dotCount }).map((_, i) => (\n <span\n key={i}\n style={{\n display: \"inline-block\",\n width: \"6px\",\n height: \"6px\",\n borderRadius: \"50%\",\n backgroundColor: \"currentColor\",\n marginRight: i < dotCount - 1 ? \"4px\" : 0,\n animation: `typing 1.4s infinite ease-in-out`,\n animationDelay: `${i * 0.2}s`,\n }}\n />\n ))}\n </span>\n )}\n </div>\n );\n }\n);\n\nTypingIndicator.displayName = \"TypingIndicator\";\n"]}
@@ -0,0 +1,20 @@
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-4WWJTYYA.js';import {a}from'./chunk-OCKHJ4WO.js';import {forwardRef,useState,useContext,useMemo,useRef,useCallback,useEffect}from'react';import {X,Zap,ExternalLink,Search,Mail,Copy,Navigation,Send,Loader2,Paperclip,ArrowUp,Image,FileText,File,User,Bot,Link,ArrowRight,Sparkle,MessageCircle,AlertCircle,MessageCircleQuestion,Check,Users,GitBranch,Terminal,Globe,Wrench,ListTodo,Download,CheckCircle2,XCircle,ChevronDown,ChevronRight,Eye,Save,Pencil,Clock,FileSearch,FolderSearch,ChevronUp,Video,FileIcon,CircleDashed,CircleCheck,CircleX,MoreVertical,Circle}from'lucide-react';import {clsx}from'clsx';import {twMerge}from'tailwind-merge';import {jsxs,jsx,Fragment}from'react/jsx-runtime';import Tr from'react-markdown';import Dr from'remark-gfm';import {Prism}from'react-syntax-highlighter';import {oneLight,oneDark}from'react-syntax-highlighter/dist/esm/styles/prism';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';function i(...e){return twMerge(clsx(e))}function gr(e){return e.startsWith("image/")?Image:e==="application/pdf"||e.startsWith("text/")?FileText:File}function fr(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}var va=forwardRef(({attachment:e,onRemove:a,removable:r=true,className:t},n)=>{let o=gr(e.mimeType),s=e.mimeType.startsWith("image/");return jsxs("div",{ref:n,className:i("relative group","flex items-center gap-2","p-2 rounded-lg","border border-chat-border","bg-chat-panel-bg",t),children:[jsx("div",{className:i("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:fr(e.size)})]}),r&&a&&jsx("button",{type:"button",onClick:a,className:i("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"})})]})});va.displayName="AttachmentPreview";var hr={sm:"w-6 h-6 text-xs",md:"w-8 h-8 text-sm",lg:"w-10 h-10 text-base"},yr={sm:14,md:16,lg:20};function vr(e,a){let r=yr[a];switch(e){case "assistant":return jsx(Bot,{size:r});case "user":return jsx(User,{size:r});default:return jsx(User,{size:r})}}var Ne=forwardRef(({name:e,src:a,alt:r,role:t,size:n="md",className:o,...s},l$1)=>jsx(l,{ref:l$1,name:e,src:a,alt:r,role:t,className:i("rounded-full overflow-hidden flex-shrink-0","flex items-center justify-center","font-medium",t==="assistant"?"bg-primary/10 text-primary":"bg-gray-200 dark:bg-gray-700 text-gray-600 dark:text-gray-300",hr[n],o),fallback:vr(t,n),...s}));Ne.displayName="Avatar";var ka=forwardRef(({children:e,className:a,...r},t)=>jsx("div",{ref:t,className:i("flex flex-col h-full","bg-white dark:bg-gray-900","font-sans text-chat-text",a),...r,children:e}));ka.displayName="ChatContainer";var Nr={small:"w-1.5 h-1.5",medium:"w-2 h-2",large:"w-2.5 h-2.5"},Cr={small:"gap-1",medium:"gap-1.5",large:"gap-2"};function qe({size:e="medium",className:a}){let r=Nr[e];return jsxs("div",{className:i("flex items-center",Cr[e],a),children:[jsx("div",{className:i(r,"rounded-full bg-[var(--chat-text-subtle)]","animate-loading-dot animate-loading-dot-1")}),jsx("div",{className:i(r,"rounded-full bg-[var(--chat-text-subtle)]","animate-loading-dot animate-loading-dot-2")}),jsx("div",{className:i(r,"rounded-full bg-[var(--chat-text-subtle)]","animate-loading-dot animate-loading-dot-3")})]})}var Ir={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 _r(e){return Ir[e.toLowerCase()]||e.toLowerCase()}function Vt(e){return e.toLowerCase().replace(/[^\w\s-]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-").trim()}function Vr({text:e}){let[a,r]=useState(false),t=useCallback(async()=>{try{await navigator.clipboard.writeText(e),r(!0),setTimeout(()=>r(!1),2e3);}catch{}},[e]);return jsxs("button",{onClick:t,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":a?"Copied":"Copy code",children:[a?jsx(Check,{size:14}):jsx(Copy,{size:14}),a?"Copied":"Copy"]})}function ne({children:e,className:a,baselineFontSize:r=1,darkCodeTheme:t}){let n=t??(typeof window<"u"&&window.matchMedia?.("(prefers-color-scheme: dark)").matches),o=r!==1?{fontSize:`${r}rem`}:void 0;return jsx(Tr,{className:i("chat-prose",a),remarkPlugins:[Dr],components:{h1:({children:s})=>{let l=String(s),c=Vt(l);return jsxs("h1",{id:c,className:"group text-xl font-semibold mt-4 mb-2 first:mt-0",style:o,children:[s,jsx("a",{href:`#${c}`,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:s})=>{let l=String(s),c=Vt(l);return jsxs("h2",{id:c,className:"group text-lg font-semibold mt-3 mb-2 first:mt-0",style:o,children:[s,jsx("a",{href:`#${c}`,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:s})=>{let l=String(s),c=Vt(l);return jsxs("h3",{id:c,className:"group text-base font-medium mt-2 mb-1 first:mt-0",style:o,children:[s,jsx("a",{href:`#${c}`,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:s})=>jsx("h4",{className:"text-base font-medium mt-2 mb-1 first:mt-0",style:o,children:s}),p:({children:s})=>jsx("p",{className:"mb-2 last:mb-0 leading-relaxed",style:o,children:s}),a:({href:s,children:l})=>jsx("a",{href:s,target:"_blank",rel:"noopener noreferrer",className:"text-primary underline hover:opacity-80 transition-opacity",style:o,children:l}),ul:({children:s})=>jsx("ul",{className:"list-disc pl-4 mb-2 space-y-1",children:s}),ol:({children:s})=>jsx("ol",{className:"list-decimal pl-4 mb-2 space-y-1",children:s}),li:({children:s})=>jsx("li",{className:"leading-relaxed",style:o,children:s}),blockquote:({children:s})=>jsx("blockquote",{className:"border-l-2 border-gray-300 dark:border-gray-600 pl-3 my-2 italic text-chat-subtle",style:o,children:s}),code:({className:s,children:l})=>{let c=/language-(\w+)/.exec(s||""),d=String(l).replace(/\n$/,"");if(!c&&!d.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 x=c?_r(c[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:x}),jsx(Vr,{text:d})]}),jsx(Prism,{language:x,style:n===false?oneLight:oneDark,customStyle:{margin:0,borderRadius:0,fontSize:"0.8125rem",lineHeight:"1.6"},codeTagProps:{style:{fontFamily:"'Fira Code', 'JetBrains Mono', monospace"}},children:d})]})},pre:({children:s})=>jsx(Fragment,{children:s}),table:({children:s})=>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:s})}),thead:({children:s})=>jsx("thead",{className:"bg-gray-50 dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700",children:s}),th:({children:s})=>jsx("th",{className:"px-3 py-2 text-left text-sm font-medium text-gray-700 dark:text-gray-300",style:o,children:s}),td:({children:s})=>jsx("td",{className:"px-3 py-2 text-sm text-gray-600 dark:text-gray-400 border-t border-gray-100 dark:border-gray-700",style:o,children:s}),hr:()=>jsx("hr",{className:"my-4 border-gray-200 dark:border-gray-700"}),strong:({children:s})=>jsx("strong",{className:"font-semibold",children:s}),em:({children:s})=>jsx("em",{className:"italic",children:s}),img:({src:s,alt:l})=>jsx("img",{src:s,alt:l??"",className:"max-w-full h-auto rounded-lg my-2",loading:"lazy"})},children:e})}function Ca(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"};default:return {label:"Source",color:"#757575"}}}function Ft({sources:e,className:a}){let[r,t]=useState(null);return !e||e.length===0?null:jsxs(Fragment,{children:[jsx("div",{className:i("flex flex-wrap gap-1.5 mt-2",a),children:e.map(n=>{let o=Ca(n.source_type);return jsxs("button",{onClick:()=>t(n),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:o.color+"1a",color:o.color,borderColor:o.color+"40"},children:["[",n.index,"] ",n.title]},n.index)})}),jsx(Sa,{source:r,onClose:()=>t(null)})]})}function Sa({source:e,onClose:a}){if(useEffect(()=>{if(!e)return;let t=n=>{n.key==="Escape"&&a();};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[e,a]),!e)return null;let r=Ca(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:a}),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:r.color+"1a",color:r.color},children:r.label})]}),jsx("button",{onClick:a,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:a,className:"px-3 py-1.5 text-sm rounded-lg hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors",children:"Close"})})]})]})})}function Hr({index:e,source:a}){return jsx("span",{className:i("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",a?.url?"cursor-pointer hover:opacity-85":"cursor-default"),title:a?`${a.title}${a.description?": "+a.description:""}`:void 0,onClick:r=>{a?.url&&(r.stopPropagation(),window.open(a.url,"_blank","noopener,noreferrer"));},children:e})}function Bt({clarification:e,onSubmit:a,onOptionSelect:r,disabled:t=false,loading:n=false,className:o}){let[s,l]=useState(""),c=useCallback(y=>{y.trim()&&(l(""),a(y.trim()));},[a]),d=y=>{let g=y.target.value;r?.(g),c(g);},f=y=>{y.key==="Enter"&&!y.shiftKey&&s.trim()&&(y.preventDefault(),c(s));},x=e.options&&e.options.length>0,N=e.allowFreeText!==false;return jsxs("div",{className:i("mx-4 mb-3 px-4 py-3","bg-orange-50/60 dark:bg-orange-950/20","border-l-[3px] border-orange-400","rounded-r-lg",o),children:[jsxs("div",{className:i("flex items-start gap-2",(x||N)&&"mb-2"),children:[jsx("span",{className:"text-orange-600 mt-0.5",children:jsx(MessageCircle,{size:14})}),jsx("p",{className:"text-sm font-medium",children:e.question})]}),x&&jsx("div",{className:i("ml-5 space-y-1",N&&"mb-2"),children:e.options.map((y,g)=>jsxs("label",{className:"flex items-center gap-2 py-0.5 cursor-pointer text-sm hover:bg-orange-100/50 dark:hover:bg-orange-900/20 rounded px-1 -mx-1",children:[jsx("input",{type:"radio",name:"clarification-option",value:y,onChange:d,disabled:t||n,className:"accent-orange-500 w-3.5 h-3.5"}),y]},g))}),N&&jsxs("div",{className:"flex items-center ml-5 bg-white dark:bg-gray-900 rounded border border-orange-200 dark:border-orange-800 px-3 py-1",children:[jsx("input",{type:"text",value:s,onChange:y=>l(y.target.value),onKeyDown:f,placeholder:x?"Or type your response...":"Type your response...",disabled:t||n,className:"flex-1 text-sm bg-transparent outline-none placeholder:text-gray-400 disabled:opacity-50"}),jsx("button",{onClick:()=>c(s),disabled:!s.trim()||t||n,className:i("p-1 rounded transition-colors",s.trim()?"text-orange-600 hover:text-orange-700":"text-gray-300"),children:jsx(Send,{size:16})})]})]})}function $t({textContent:e,onRegenerate:a,onEdit:r,className:t}){let[n,o]=useState(false),s=useCallback(async()=>{try{await navigator.clipboard.writeText(e),o(!0),setTimeout(()=>o(!1),2e3);}catch{let l=document.createElement("textarea");l.value=e,l.style.position="fixed",l.style.opacity="0",document.body.appendChild(l),l.select(),document.execCommand("copy"),document.body.removeChild(l),o(true),setTimeout(()=>o(false),2e3);}},[e]);return jsxs("div",{className:i("flex items-center gap-1","opacity-0 group-hover:opacity-100 transition-opacity duration-150",t),children:[jsx("button",{type:"button",onClick:s,"aria-label":n?"Copied":"Copy message",className:i("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:n?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"})]})}),a&&jsx("button",{type:"button",onClick:a,"aria-label":"Regenerate response",className:i("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"})]})}),r&&jsx("button",{type:"button",onClick:r,"aria-label":"Edit message",className:i("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"})]})})]})}function Wt({attachments:e,onDownload:a,onPreview:r,className:t}){let[n,o]=useState(null);if(!e||e.length===0)return null;let s=c=>{if(a){a(c);return}if(c.url){let d=document.createElement("a");d.href=c.url,d.download=c.filename,d.target="_blank",document.body.appendChild(d),d.click(),document.body.removeChild(d);}},l=c=>{if(r){r(c);return}c.isImage&&c.url&&o(c.url);};return jsxs("div",{className:i("flex flex-wrap gap-1.5",t),children:[e.map(c=>jsx(on,{attachment:c,onDownload:()=>s(c),onPreview:()=>l(c)},c.id)),n&&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:n,alt:"Preview",className:"max-w-[90vw] max-h-[90vh] object-contain",onClick:c=>c.stopPropagation()})]})]})}function on({attachment:e,onDownload:a,onPreview:r}){let t=e.humanReadableSize||ln(e.size);return jsxs("div",{className:i("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?r:void 0,children:[jsx(sn,{mimeType:e.mimeType,size:14}),jsx("span",{className:"text-xs text-[var(--chat-text)] truncate min-w-0",children:e.filename}),t&&t!=="0 Bytes"&&jsx("span",{className:"text-[10px] text-[var(--chat-text-subtle)] flex-shrink-0",children:t}),e.url&&jsx("button",{onClick:n=>{n.stopPropagation(),a();},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 sn({mimeType:e,size:a=14}){return e.startsWith("image/")?jsx(Image,{size:a,className:"text-[var(--chat-primary)] flex-shrink-0"}):e.startsWith("video/")?jsx(Video,{size:a,className:"text-[var(--chat-primary)] flex-shrink-0"}):e==="application/pdf"?jsx(FileText,{size:a,className:"text-red-500 flex-shrink-0"}):jsx(FileIcon,{size:a,className:"text-gray-500 flex-shrink-0"})}function ln(e){if(e===0)return "0 Bytes";let a=1024,r=["Bytes","KB","MB","GB"],t=Math.floor(Math.log(e)/Math.log(a));return parseFloat((e/Math.pow(a,t)).toFixed(2))+" "+r[t]}var za="miiflow-beamer-keyframes";function _e(e){if(typeof document>"u")return;let a=e?.getRootNode?.(),r=a instanceof ShadowRoot?a:document.head;if(r.querySelector(`#${za}`))return;let t=document.createElement("style");t.id=za,t.textContent="@keyframes beamer{0%{left:-30%}100%{left:100%}}",r.appendChild(t);}var Ve={position:"absolute",top:0,left:"-30%",width:"30%",height:"100%",background:"linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.7) 50%, transparent 100%)",animation:"beamer 2s linear infinite",zIndex:1,pointerEvents:"none"};function nt({status:e,size:a=16,className:r}){let t=Math.max(a-4,10);return jsxs("div",{className:i("relative flex-shrink-0 flex items-center justify-center",r),style:{width:a,height:a},children:[e==="pending"&&jsx(CircleDashed,{size:a,strokeWidth:2,className:"text-[var(--chat-text-subtle)] opacity-40"}),e==="running"&&jsxs("div",{className:"relative flex items-center justify-center",style:{width:a,height:a},children:[jsx("div",{className:"absolute inset-0 rounded-full bg-indigo-500/20 animate-ping",style:{animationDuration:"1.5s"}}),jsx("div",{className:"relative rounded-full bg-gradient-to-br from-indigo-500 to-purple-500 p-[2px] animate-pulse-glow",children:jsx("div",{className:"rounded-full bg-white dark:bg-gray-900 flex items-center justify-center",style:{width:t,height:t},children:jsx(Loader2,{size:t-2,strokeWidth:2.5,className:"text-indigo-500 animate-spin"})})})]}),e==="completed"&&jsx("div",{className:"animate-complete-pop",children:jsx("div",{className:"rounded-full animate-success-flash",children:jsx(CircleCheck,{size:a,strokeWidth:2,className:"text-green-500"})})}),e==="failed"&&jsx(CircleX,{size:a,strokeWidth:2,className:"text-red-500"})]})}function Fe({items:e,badgeSize:a=20,className:r}){let t=useRef(null);return useEffect(()=>{_e(t.current);},[]),e.length===0?null:jsx("div",{ref:t,className:i("max-w-full",r),children:jsx("div",{className:"flex flex-col",children:e.map((n,o)=>{let s=o===e.length-1,c=(s?null:e[o+1])?.status==="pending",d=n.status==="running"&&!s;return jsxs("div",{className:"animate-fade-in",style:{display:"grid",gridTemplateColumns:`${a}px 1fr`,gap:"0.5rem",paddingBottom:s?0:"0.5rem",position:"relative"},children:[jsxs("div",{className:"relative flex flex-col items-center flex-shrink-0",style:{paddingTop:"4px"},children:[jsx(nt,{status:n.status,size:a}),!s&&(d?jsx("div",{className:"absolute left-1/2 -translate-x-1/2 w-[2px] animate-flow-down",style:{top:a+6,height:`calc(100% - ${a}px + 4px)`,background:`repeating-linear-gradient(
3
+ 180deg,
4
+ rgb(99, 102, 241) 0px,
5
+ rgb(99, 102, 241) 4px,
6
+ transparent 4px,
7
+ transparent 8px
8
+ )`,zIndex:1}}):jsx("div",{className:"absolute left-1/2 -translate-x-1/2",style:{top:a+6,height:`calc(100% - ${a}px + 4px)`,width:0,borderLeft:"2px",borderStyle:c?"dashed":"solid",borderColor:"var(--chat-border)",zIndex:1}}))]}),jsxs("div",{style:{minWidth:0,flex:1,display:"flex",alignItems:"center",position:"relative",overflow:"hidden",borderRadius:4,...n.status==="running"&&{backgroundColor:"rgba(0, 0, 0, 0.02)",padding:"2px 4px"}},children:[n.status==="running"&&jsx("div",{style:Ve}),n.content]})]},n.id)})})})}function un({status:e,isLast:a=false,badgeSize:r=16,children:t,className:n}){let o=useRef(null);useEffect(()=>{_e(o.current);},[]);let s=e==="running"&&!a;return jsxs("div",{ref:o,className:i("relative flex items-start gap-3 animate-fade-in",!a&&"pb-3",n),children:[jsxs("div",{className:"relative flex-shrink-0 pt-0.5",children:[jsx(nt,{status:e,size:r}),!a&&(s?jsx("div",{className:"absolute w-[2px] animate-flow-down",style:{left:r/2-1,top:r+4,height:"calc(100% + 12px)",background:`repeating-linear-gradient(
9
+ 180deg,
10
+ rgb(99, 102, 241) 0px,
11
+ rgb(99, 102, 241) 4px,
12
+ transparent 4px,
13
+ transparent 8px
14
+ )`,zIndex:1}}):jsx("div",{className:"absolute bg-[var(--chat-border)] opacity-30",style:{left:r/2-.5,top:r+4,height:"calc(100% + 12px)",width:1,zIndex:1}}))]}),jsxs("div",{style:{minWidth:0,flex:1,position:"relative",overflow:"hidden",borderRadius:4,...e==="running"&&{backgroundColor:"rgba(0, 0, 0, 0.02)",padding:"2px 4px"}},children:[e==="running"&&jsx("div",{style:Ve}),t]})]})}function Ht({event:e,className:a,isRunning:r}){let t=useRef(null);if(useEffect(()=>{_e(t.current);},[]),e.type==="thinking")return jsx("div",{ref:t,className:i("p-1 rounded transition-colors","bg-black/[0.01] hover:bg-black/[0.02]",a),children:jsx("div",{className:"text-[var(--chat-text-subtle)] leading-relaxed",children:jsx(ne,{className:"text-[14px]",children:e.content})})});if(e.type==="planning")return jsx("div",{ref:t,className:i("p-1 rounded transition-colors","bg-black/[0.01] hover:bg-black/[0.02]",a),children:jsx("div",{className:"text-[var(--chat-text-subtle)] leading-relaxed",children:jsx(ne,{className:"text-[14px]",children:e.content})})});if(e.type==="tool")return jsxs("div",{ref:t,className:i("inline-flex items-center gap-1.5",a),style:{position:"relative",overflow:"hidden",borderRadius:4,...r&&{backgroundColor:"rgba(0, 0, 0, 0.02)",padding:"2px 4px"}},children:[r&&jsx("div",{style:Ve}),jsx(Wrench,{size:14,className:"text-black/50 relative z-10 shrink-0"}),jsx("span",{className:"text-[14px] text-black/65 relative z-10",children:e.toolDescription||e.toolName})]});if(e.type==="observation"){let n=e.success!==false;return jsxs("div",{ref:t,className:i("px-3 py-1.5 rounded max-w-full overflow-auto",n?"bg-green-50 border-l-[3px] border-green-400":"bg-yellow-50 border-l-[3px] border-yellow-400",a),children:[jsxs("span",{className:i("text-xs font-semibold uppercase tracking-wide block mb-1",n?"text-green-700":"text-yellow-700"),children:[e.toolName," Result"]}),jsx("div",{className:i(n?"text-green-900":"text-yellow-900"),children:jsx(ne,{className:"text-[14px]",children:e.content})})]})}return null}var xn=["create_plan","unknown"];function Ra(e){return e?xn.includes(e.toLowerCase().trim()):false}function ot(e,a){if(e.toolName&&Ra(e.toolName))return null;if(e.type==="thinking")return !e.content||e.content.trim().length===0?null:{id:`thinking-${a}`,type:"thinking",status:"completed",content:e.content};if(e.type==="planning"){if(!e.content||e.content.trim().length===0)return null;let r=e.planData!==void 0||e.content.includes("\u2713 Created plan");return {id:`planning-${a}`,type:"planning",status:r?"completed":"running",content:e.content,isComplete:r}}if(e.type==="tool"){let r=e.status==="executing"?"running":e.status==="completed"?"completed":"pending";return {id:`tool-${a}`,type:"tool",status:r,toolName:e.toolName||"Unknown Tool",toolDescription:e.toolDescription}}return null}function hn(e){let a=[];return e.forEach((r,t)=>{if(r.type==="thought"){let n=r.thought;if(!n||n.trim().length===0)return;a.push({id:`thought-${t}`,type:"thinking",status:"completed",content:n});}else if(r.type==="tool"){let n=r.tool||"Unknown Tool";if(Ra(n))return;a.push({id:`tool-${t}`,type:"tool",status:"completed",toolName:n,toolDescription:r.tool_description});}}),a}function Se({events:e,className:a}){if(e.length===0)return null;let r=e.map(t=>({id:t.id,status:t.status,content:jsx(Ht,{event:t,isRunning:t.status==="running"})}));return jsx(Fe,{items:r,badgeSize:20,className:a})}function kn(e){let a=[];return e.forEach((r,t)=>{if(r.type==="thinking"){if(!r.content||r.content.trim().length===0)return;a.push({id:`thinking-${t}`,type:"thinking",status:"completed",content:r.content});}else if(r.type==="tool"){let n=r.status==="executing"?"running":r.status==="completed"?"completed":"pending";a.push({id:`tool-${t}`,type:"tool",status:n,toolName:r.toolName||"Unknown Tool",toolDescription:r.toolDescription});}}),a}function Nn({subtask:e,executionChunks:a=[]}){let[r,t]=useState(e.status==="running"),n=e.status==="running",o=e.status==="failed",s=e.status==="completed";n&&!r&&t(true);let l=a.length>0,c=kn(a);return jsxs("div",{className:"flex-1 min-w-0",children:[jsxs("div",{onClick:()=>l&&t(!r),className:i("flex items-center gap-2 min-w-0",l&&"cursor-pointer"),children:[jsx("span",{className:i("text-sm font-medium truncate",o?"text-red-500":"text-black/85"),children:e.description}),o&&e.error&&jsx("span",{className:"text-sm text-red-500 truncate flex-1",children:e.error}),s&&e.execution_time!=null&&e.execution_time>0&&jsxs("span",{className:"text-xs text-black/40 shrink-0 tabular-nums",children:[e.execution_time.toFixed(1),"s"]}),l&&jsx("span",{className:"text-black/40 shrink-0 flex items-center",children:r?jsx(ChevronUp,{size:14}):jsx(ChevronDown,{size:14})})]}),l&&r&&jsx("div",{className:"mt-2 pl-2",children:jsx(Se,{events:c})})]})}function it({plan:e,streamingChunks:a=[],className:r}){let t=e.subtasks.map(n=>{let o=a.filter(l=>l.subtaskId===n.id),s=n.status==="running"?"running":n.status==="completed"?"completed":n.status==="failed"?"failed":"pending";return {id:String(n.id),status:s,content:jsx(Nn,{subtask:n,executionChunks:o})}});return jsxs("div",{className:i("space-y-2",r),children:[jsx("span",{className:"text-sm text-black/50",children:"Plan:"}),jsx(Fe,{items:t,badgeSize:20})]})}function lt({chunk:e}){let[a,r]=useState(false),t=e.claudeToolData;if(!t)return null;let n=t.status==="pending",o=t.status==="error",s=t.status==="completed",l=()=>n?jsx(Loader2,{size:14,className:"animate-spin text-gray-400"}):o?jsx(XCircle,{size:14,className:"text-red-500"}):jsx(CheckCircle2,{size:14,className:"text-green-500"});return jsxs("div",{className:"bg-gray-50 dark:bg-gray-800/50 rounded-lg border border-gray-200 dark:border-gray-700 overflow-hidden",children:[jsxs("div",{onClick:()=>r(!a),className:"flex items-center gap-2 px-3 py-2 cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-800",children:[jsx(Wrench,{size:16,className:"text-gray-400 shrink-0"}),jsxs("span",{className:"flex-1 text-sm truncate",children:[jsx("span",{className:"font-medium",children:(()=>{let d=t.toolName;if(d.startsWith("mcp__")){let f=d.split("__");if(f.length>=3)return `${f[1]}/${f[2]}`}return d})()}),t.toolDescription&&jsx("span",{className:"text-gray-400 ml-2",children:t.toolDescription})]}),l(),s&&t.durationMs!=null&&jsxs("span",{className:"text-[0.7rem] px-1.5 py-0.5 bg-black/5 dark:bg-white/5 rounded",children:[Math.round(t.durationMs),"ms"]}),jsx("span",{className:"p-0.5",children:a?jsx(ChevronDown,{size:14}):jsx(ChevronRight,{size:14})})]}),a&&jsxs("div",{className:"border-t border-gray-200 dark:border-gray-700 p-3",children:[t.toolInput&&Object.keys(t.toolInput).length>0&&jsxs("div",{className:"mb-3",children:[jsx("div",{className:"text-[0.75rem] text-gray-400 uppercase tracking-wider mb-1",children:"Input"}),jsx("pre",{className:"text-[0.75rem] font-mono bg-gray-100 dark:bg-gray-900 rounded p-2 overflow-auto max-h-[150px] m-0",children:JSON.stringify(t.toolInput,null,2)})]}),o&&jsx("p",{className:"text-sm text-red-500 font-mono",children:t.content||"Tool execution failed"}),n&&jsx("p",{className:"text-sm text-gray-400 italic",children:"Executing tool..."}),s&&t.content&&!t.isError&&jsxs("div",{children:[jsx("div",{className:"text-[0.75rem] text-gray-400 uppercase tracking-wider mb-1",children:"Result"}),jsx("pre",{className:"text-[0.75rem] font-mono bg-gray-100 dark:bg-gray-900 rounded p-2 overflow-auto max-h-[200px] whitespace-pre-wrap break-words m-0",children:t.content.length>1500?`${t.content.slice(0,1500)}
15
+ ... (truncated)`:t.content})]})]})]})}function ct({chunk:e}){let[a,r]=useState(true),t=e.terminalData;if(!t)return null;let n=()=>{switch(t.status){case "running":return jsx(Loader2,{size:14,className:"animate-spin text-blue-500"});case "completed":return jsx(CheckCircle2,{size:14,className:"text-green-500"});case "failed":return jsx(XCircle,{size:14,className:"text-red-500"});default:return null}},o=t.status==="running"?"border-blue-500/30":t.status==="failed"?"border-red-500/30":t.exitCode===0?"border-green-500/30":"border-yellow-500/30",s=t.status==="running"?"bg-blue-500/10":t.status==="failed"?"bg-red-500/10":"bg-green-500/10",l=t.status==="running"?"text-blue-500":t.status==="failed"?"text-red-500":"text-green-500",c=d=>d?d<1e3?d+"ms":(d/1e3).toFixed(1)+"s":null;return jsxs("div",{className:i("my-1 bg-[#1a1a1a] rounded border",o,"overflow-hidden"),children:[jsxs("div",{onClick:()=>r(!a),className:i("flex items-center gap-2 px-3 py-1.5 cursor-pointer",s,"hover:brightness-110"),children:[jsx("span",{className:"p-0.5 text-gray-500",children:a?jsx(ChevronDown,{size:16}):jsx(ChevronRight,{size:16})}),jsx(Terminal,{size:16,className:l}),jsxs("span",{className:"flex-1 font-mono text-[0.75rem] text-gray-300 truncate",children:[jsx("span",{className:"text-gray-500",children:"$ "}),t.command]}),t.durationMs!=null&&jsx("span",{className:"text-[0.7rem] text-gray-600",children:c(t.durationMs)}),n(),t.status!=="running"&&t.exitCode!==void 0&&jsxs("span",{className:i("text-[0.7rem] font-mono",t.exitCode===0?"text-green-500":"text-red-500"),children:["[",t.exitCode,"]"]})]}),a&&jsxs("div",{className:"p-3",children:[t.description&&jsx("p",{className:"text-gray-500 text-[0.75rem] italic mb-2",children:t.description}),t.stdout&&jsx("pre",{className:i("m-0 p-2 text-[0.7rem] font-mono bg-[#0d0d0d] rounded overflow-auto max-h-[300px]","text-green-400 whitespace-pre-wrap break-words",t.stderr&&"mb-2"),children:t.stdout}),t.stderr&&jsx("pre",{className:"m-0 p-2 text-[0.7rem] font-mono bg-red-500/10 rounded border border-red-500/30 overflow-auto max-h-[200px] text-red-400 whitespace-pre-wrap break-words",children:t.stderr}),t.status==="running"&&!t.stdout&&!t.stderr&&jsx("p",{className:"text-gray-500 text-[0.75rem] italic",children:"Running..."}),t.status==="completed"&&!t.stdout&&!t.stderr&&t.exitCode===0&&jsx("p",{className:"text-gray-600 text-[0.75rem] italic",children:"Command completed with no output"})]})]})}function dt({chunk:e}){let[a,r]=useState(false),t=e.fileOperationData;if(!t)return null;let n=t.operation==="read"?jsx(Eye,{size:16}):t.operation==="write"?jsx(Save,{size:16}):t.operation==="edit"?jsx(Pencil,{size:16}):jsx(FileText,{size:16}),o=t.operation==="read"?"text-blue-500 border-blue-500":t.operation==="write"?"text-green-500 border-green-500":t.operation==="edit"?"text-yellow-500 border-yellow-500":"text-gray-500 border-gray-500",s=t.operation==="read"?"bg-blue-500/5 hover:bg-blue-500/8":t.operation==="write"?"bg-green-500/5 hover:bg-green-500/8":t.operation==="edit"?"bg-yellow-500/5 hover:bg-yellow-500/8":"bg-gray-500/5",l=t.status==="pending"?jsx(Clock,{size:14,className:"text-gray-400"}):t.status==="completed"?jsx(CheckCircle2,{size:14,className:"text-green-500"}):jsx(XCircle,{size:14,className:"text-red-500"}),c=t.operation==="read"?"Read":t.operation==="write"?"Write":t.operation==="edit"?"Edit":"File",d=f=>{let x=f.split("/");return x.length<=3?f:".../"+x.slice(-3).join("/")};return jsxs("div",{className:i("my-1 border rounded overflow-hidden",o.split(" ")[1]+"/30"),children:[jsxs("div",{onClick:()=>r(!a),className:i("flex items-center gap-2 px-3 py-1.5 cursor-pointer",s),children:[jsx("span",{className:"p-0.5",children:a?jsx(ChevronDown,{size:16}):jsx(ChevronRight,{size:16})}),jsx("span",{className:o.split(" ")[0],children:n}),jsx("span",{className:i("font-medium text-[0.75rem]",o.split(" ")[0]),children:c}),jsx("span",{className:"flex-1 font-mono text-[0.75rem] text-gray-500 truncate",children:d(t.filePath)}),t.totalLines!=null&&jsxs("span",{className:"text-[0.7rem] text-gray-400",children:[t.totalLines," lines"]}),l]}),a&&jsxs("div",{className:"p-3 bg-gray-50 dark:bg-[#1e1e1e]",children:[t.operation==="read"&&t.content&&jsx(Xn,{content:t.content}),t.operation==="edit"&&jsx(Zn,{oldString:t.oldString,newString:t.newString}),t.operation==="write"&&t.status==="completed"&&jsx("p",{className:"text-green-500 text-sm",children:"File written successfully"}),t.error&&jsxs("p",{className:"text-red-500 text-sm",children:["Error: ",t.error]})]})]})}function Xn({content:e}){let a=useMemo(()=>e.split(`
16
+ `).slice(0,50),[e]),r=e.split(`
17
+ `).length,t=r>50;return jsxs("div",{children:[jsx("pre",{className:"m-0 p-2 text-[0.75rem] font-mono bg-gray-100 dark:bg-[#1a1a1a] rounded overflow-auto max-h-[300px]",children:a.map((n,o)=>jsxs("div",{className:"flex",children:[jsx("span",{className:"inline-block w-10 text-right pr-3 mr-3 border-r border-gray-200 dark:border-gray-700 text-gray-400 select-none",children:o+1}),jsx("span",{children:n||" "})]},o))}),t&&jsxs("p",{className:"text-[0.75rem] text-gray-400 mt-1",children:["... and ",r-50," more lines"]})]})}function Zn({oldString:e,newString:a}){return !e&&!a?jsx("p",{className:"text-gray-500 text-sm",children:"No changes to display"}):jsxs("div",{className:"flex gap-4",children:[jsxs("div",{className:"flex-1",children:[jsx("span",{className:"text-[0.75rem] font-medium text-red-500 block mb-1",children:"- Removed"}),jsx("pre",{className:"m-0 p-2 text-[0.7rem] font-mono bg-red-500/10 rounded border border-red-500/30 overflow-auto max-h-[200px] whitespace-pre-wrap break-words",children:e||"(empty)"})]}),jsxs("div",{className:"flex-1",children:[jsx("span",{className:"text-[0.75rem] font-medium text-green-500 block mb-1",children:"+ Added"}),jsx("pre",{className:"m-0 p-2 text-[0.7rem] font-mono bg-green-500/10 rounded border border-green-500/30 overflow-auto max-h-[200px] whitespace-pre-wrap break-words",children:a||"(empty)"})]})]})}function pt({chunk:e}){let[a,r]=useState(true),t=e.searchResultsData;if(!t)return null;let n=t.tool==="grep",o=n?"text-purple-500":"text-blue-500",s=n?"border-purple-500/30":"border-blue-500/30",l=n?"bg-purple-500/5 hover:bg-purple-500/8":"bg-blue-500/5 hover:bg-blue-500/8",c=n?"bg-purple-500/10 text-purple-500":"bg-blue-500/10 text-blue-500";return jsxs("div",{className:i("my-1 border rounded overflow-hidden",s),children:[jsxs("div",{onClick:()=>r(!a),className:i("flex items-center gap-2 px-3 py-1.5 cursor-pointer",l),children:[jsx("span",{className:"p-0.5",children:a?jsx(ChevronDown,{size:16}):jsx(ChevronRight,{size:16})}),jsx("span",{className:o,children:n?jsx(FileSearch,{size:16}):jsx(FolderSearch,{size:16})}),jsx("span",{className:i("text-[0.7rem] px-1.5 py-0.5 rounded font-medium",c),children:n?"Grep":"Glob"}),jsx("span",{className:"flex-1 font-mono text-[0.75rem] text-gray-500 truncate",children:t.pattern}),jsxs("span",{className:i("text-[0.7rem] px-1.5 py-0.5 rounded",t.totalCount>0?"bg-green-500/10 text-green-500":"bg-gray-500/10 text-gray-500"),children:[t.totalCount," results"]})]}),a&&jsxs("div",{className:"max-h-[300px] overflow-auto",children:[t.results.length>0?jsxs("div",{children:[t.results.slice(0,50).map((d,f)=>jsx(ro,{result:d,isGrep:n},f)),t.results.length>50&&jsx("div",{className:"py-1 px-3",children:jsxs("span",{className:"text-[0.75rem] text-gray-400",children:["... and ",t.results.length-50," more results"]})})]}):jsx("div",{className:"p-3",children:jsx("p",{className:"text-gray-500 text-sm",children:"No results found"})}),t.error&&jsx("div",{className:"p-3",children:jsxs("p",{className:"text-red-500 text-sm",children:["Error: ",t.error]})})]})]})}function ro({result:e,isGrep:a}){return jsxs("div",{className:"flex items-start gap-2 py-1 px-3 border-b border-gray-100 dark:border-gray-800 last:border-b-0 hover:bg-gray-50 dark:hover:bg-gray-800/50",children:[jsx(File,{size:14,className:"text-gray-400 mt-0.5 shrink-0"}),jsxs("div",{className:"min-w-0 flex-1",children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx("span",{className:"font-mono text-[0.75rem] truncate",children:(t=>{let n=t.split("/");return n.length<=4?t:".../"+n.slice(-4).join("/")})(e.filePath)}),a&&e.lineNumber!=null&&jsxs("span",{className:"font-mono text-[0.7rem] text-blue-500",children:[":",e.lineNumber]})]}),e.snippet&&jsx("p",{className:"font-mono text-[0.7rem] text-gray-500 truncate max-w-[400px]",children:e.snippet})]})]})}function mt({chunk:e}){let[a,r]=useState(false),t=e.webOperationData;if(!t)return null;let n=t.operation==="search",o=t.status==="pending",s=t.status==="error",l=t.status==="completed",c=()=>o?jsx(Loader2,{size:14,className:"animate-spin text-gray-400"}):s?jsx(XCircle,{size:14,className:"text-red-500"}):jsx(CheckCircle2,{size:14,className:"text-green-500"}),f=n?(()=>{if(!t.results||typeof t.results!="string")return [];let x=/\[([^\]]+)\]\(([^)]+)\)/g,N=[],y;for(;(y=x.exec(t.results))!==null;)N.push({title:y[1],url:y[2]});return N})():[];return jsxs("div",{className:"bg-gray-50 dark:bg-gray-800/50 rounded-lg border border-gray-200 dark:border-gray-700 overflow-hidden",children:[jsxs("div",{onClick:()=>r(!a),className:"flex items-center gap-2 px-3 py-2 cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-800",children:[n?jsx(Search,{size:16,className:"text-gray-400 shrink-0"}):jsx(Globe,{size:16,className:"text-gray-400 shrink-0"}),jsx("span",{className:"flex-1 text-sm truncate",children:n?jsxs(Fragment,{children:["Searching: ",jsx("span",{className:"font-medium",children:t.query})]}):jsxs(Fragment,{children:["Fetching: ",jsx("span",{className:"font-medium",children:t.url})]})}),c(),l&&t.durationMs!=null&&jsxs("span",{className:"text-[0.7rem] px-1.5 py-0.5 bg-black/5 dark:bg-white/5 rounded",children:[Math.round(t.durationMs),"ms"]}),jsx("span",{className:"p-0.5",children:a?jsx(ChevronDown,{size:14}):jsx(ChevronRight,{size:14})})]}),a&&jsxs("div",{className:"border-t border-gray-200 dark:border-gray-700 p-3",children:[s&&t.error&&jsx("p",{className:"text-sm text-red-500 font-mono",children:t.error}),o&&jsx("p",{className:"text-sm text-gray-400 italic",children:n?"Searching the web...":"Fetching content..."}),n&&l&&f.length>0&&jsxs("div",{className:"space-y-2",children:[jsxs("div",{className:"text-[0.75rem] text-gray-400 uppercase tracking-wider",children:[f.length," Results"]}),f.slice(0,5).map((x,N)=>jsxs("div",{className:i("flex items-center gap-2 py-1",N<Math.min(f.length,5)-1&&"border-b border-gray-200 dark:border-gray-700"),children:[jsx(ExternalLink,{size:12,className:"text-gray-400 shrink-0"}),jsx("a",{href:x.url,target:"_blank",rel:"noopener noreferrer",className:"text-sm truncate hover:underline",children:x.title})]},N)),f.length>5&&jsxs("p",{className:"text-[0.75rem] text-gray-400 italic",children:["+",f.length-5," more results"]})]}),n&&l&&f.length===0&&t.results&&jsxs("p",{className:"text-sm whitespace-pre-wrap max-h-[200px] overflow-auto",children:[typeof t.results=="string"?t.results.slice(0,1e3):JSON.stringify(t.results,null,2).slice(0,1e3),t.results.length>1e3&&"..."]}),!n&&l&&t.content&&jsx("div",{className:"max-h-[300px] overflow-auto bg-gray-100 dark:bg-gray-900 rounded p-2",children:jsxs("pre",{className:"text-[0.75rem] font-mono whitespace-pre-wrap break-words m-0",children:[t.content.slice(0,2e3),t.content.length>2e3&&`
18
+ ... (truncated)`]})})]})]})}var wo={code_reviewer:"Code Review",researcher:"Research",data_analyst:"Data Analysis",Explore:"Explore",Plan:"Planning",Bash:"Command Execution"};function ut({chunk:e}){let[a,r]=useState(true),t=e.subagentData;if(!t)return null;let n=t.status==="running"?jsx(Loader2,{size:16,className:"animate-spin text-blue-500"}):t.status==="completed"?jsx(CheckCircle2,{size:16,className:"text-green-500"}):t.status==="failed"?jsx(XCircle,{size:16,className:"text-red-500"}):null,o=t.status==="running"?"border-blue-500":t.status==="completed"?"border-green-500":t.status==="failed"?"border-red-500":"border-gray-500",s=t.status==="running"?"bg-blue-500/3":t.status==="completed"?"bg-green-500/3":t.status==="failed"?"bg-red-500/3":"bg-gray-500/3",l=t.status==="running"?"bg-blue-500/10 text-blue-500":t.status==="completed"?"bg-green-500/10 text-green-500":t.status==="failed"?"bg-red-500/10 text-red-500":"bg-gray-500/10 text-gray-500",c=f=>f?f<1e3?f+"ms":(f/1e3).toFixed(1)+"s":null,d=wo[t.subagentType]||t.subagentType;return jsxs("div",{className:i("border border-dashed rounded ml-4 my-2 overflow-hidden",o+"/50",s),children:[jsxs("div",{onClick:()=>r(!a),className:i("flex items-center gap-2 px-3 py-1.5 cursor-pointer hover:brightness-95"),children:[jsx("span",{className:"p-0.5",children:a?jsx(ChevronDown,{size:18}):jsx(ChevronRight,{size:18})}),jsx(GitBranch,{size:16,className:o.replace("border-","text-")}),jsx("span",{className:i("text-[0.75rem] px-2 py-0.5 rounded font-medium",l),children:d}),jsx("span",{className:"flex-1 text-sm text-gray-500 truncate",children:t.description}),n,t.durationMs!=null&&jsx("span",{className:"text-[0.7rem] text-gray-400",children:c(t.durationMs)})]}),a&&jsxs("div",{className:"px-4 pb-3",children:[t.nestedChunks&&t.nestedChunks.length>0&&jsx("div",{className:"mt-2 space-y-1",children:t.nestedChunks.map((f,x)=>jsx(ko,{chunk:f},x))}),t.status==="completed"&&t.result&&jsxs("div",{className:"mt-2 p-2 rounded bg-green-500/5 border border-green-500/20",children:[jsx("span",{className:"text-[0.75rem] font-medium text-green-500",children:"Result"}),jsx("p",{className:"mt-1 text-sm text-gray-500 whitespace-pre-wrap",children:t.result.length>500?t.result.slice(0,500)+"...":t.result})]})]})]})}function ko({chunk:e}){return e.type==="tool"||e.type==="observation"?jsxs("div",{className:"py-1 px-2 my-1 rounded bg-blue-500/5 text-[0.75rem]",children:[jsxs("span",{className:"font-medium text-blue-500",children:[e.toolName||"Tool",":"]})," ",jsxs("span",{className:"text-gray-500",children:[e.content?.slice(0,200)||e.toolDescription||"Executing...",e.content&&e.content.length>200&&"..."]})]}):e.type==="thinking"||e.type==="claude_thinking"?jsxs("p",{className:"py-1 text-[0.75rem] text-gray-400 italic",children:[e.content?.slice(0,150),e.content&&e.content.length>150&&"..."]}):null}function Ao(e){let a=useRef(null),[r,t]=useState(0),n=useRef(0);return useEffect(()=>{if(e){a.current===null&&(a.current=Date.now());let o=setInterval(()=>{if(a.current!==null){let s=Math.floor((Date.now()-a.current)/1e3);t(s),n.current=s;}},1e3);return ()=>clearInterval(o)}else a.current!==null&&(n.current=Math.floor((Date.now()-a.current)/1e3),t(n.current),a.current=null);},[e]),{display:`${r}`,finalSeconds:n.current}}function Lo(e){return e.some(a=>a.orchestrator==="claude_agent_sdk"||a.type==="subagent"||a.type==="file_operation"||a.type==="terminal"||a.type==="search_results"||a.type==="web_operation"||a.type==="claude_text"||a.type==="claude_thinking")}function Io(e){return e.some(a=>a.type==="wave_start"||a.type==="wave_complete"||a.type==="parallel_subtask_start"||a.type==="parallel_subtask_complete"||a.isParallel)}function _o(e){let a=e.filter(c=>c.type==="wave_start"&&c.waveData);if(a.length===0)return null;let r=a[a.length-1],t=r.waveData?.waveNumber??0,n=r.waveData?.totalWaves??1,o=r.waveData?.parallelCount??0,s=[],l=[];return e.forEach(c=>{if(c.type==="parallel_subtask_start"&&c.waveNumber===t&&c.subtaskId!==void 0&&(l.includes(c.subtaskId)||s.push(c.subtaskId)),c.type==="parallel_subtask_complete"&&c.waveNumber===t&&c.subtaskId!==void 0){l.push(c.subtaskId);let d=s.indexOf(c.subtaskId);d>=0&&s.splice(d,1);}}),{currentWave:t,totalWaves:n,parallelCount:o,activeSubtasks:s,completedSubtasks:l}}function Vo(e){return e.some(a=>a.type==="multi_agent_planning"||a.type==="multi_agent_planning_complete"||a.type==="subagent_start"||a.type==="subagent_complete"||a.type==="subagent_failed"||a.type==="synthesis"||a.isMultiAgent)}function Va(e){return e.find(r=>(r.type==="multi_agent_planning"||r.type==="multi_agent_planning_complete")&&r.subagentAllocations)?.subagentAllocations||[]}function Fa(e){let a=new Map,r=false;Va(e).forEach(o=>{a.set(o.name,{name:o.name,task:o.query||o.focus,status:"pending"});});let t={pending:0,running:1,completed:2,failed:2};e.forEach(o=>{if(o.subagentInfo?.name){let s=o.subagentInfo.id||o.subagentInfo.name,l=a.get(s);(!l||(t[o.subagentInfo.status]??0)>=(t[l.status]??0))&&a.set(s,o.subagentInfo);}o.type==="synthesis"&&(r=true);});let n=[...a.values()];return {subagents:a,running:n.filter(o=>o.status==="running").length,completed:n.filter(o=>o.status==="completed").length,failed:n.filter(o=>o.status==="failed").length,pending:n.filter(o=>o.status==="pending").length,isSynthesizing:r}}function Fo(e){let a=[];return e.forEach(r=>{r.type==="thought"&&r.thought?a.push({type:"thinking",content:r.thought,subtaskId:r.subtask_id}):r.type==="tool"&&(a.push({type:"tool",content:"",toolName:r.tool||"Unknown Tool",toolDescription:r.tool_description,status:"completed",subtaskId:r.subtask_id}),r.observation&&a.push({type:"observation",content:r.observation,toolName:r.tool||"Unknown Tool",success:true,subtaskId:r.subtask_id}));}),a}function Bo({chunks:e}){let a=Fa(e),r=[...a.subagents.values()];if(r.length===0){let n=e.some(s=>s.type==="multi_agent_planning"),o=Va(e);return o.length>0?jsxs("div",{className:"flex items-center gap-2",children:[jsx(Loader2,{size:14,className:"animate-spin text-gray-400"}),jsxs("span",{className:"text-sm text-gray-500",children:["Allocating agents: ",o.map(s=>s.name).join(", ")]})]}):n?jsxs("div",{className:"flex items-center gap-2",children:[jsx(Loader2,{size:14,className:"animate-spin text-gray-400"}),jsx("span",{className:"text-sm text-gray-500",children:"Planning agent allocation..."})]}):null}let t=r.map((n,o)=>({id:n.id||`agent-${o}`,status:n.status==="running"?"running":n.status==="completed"?"completed":n.status==="failed"?"failed":"pending",content:jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[jsx("span",{className:"text-sm font-medium",children:n.name}),jsx("span",{className:i("text-sm flex-1 truncate",n.status==="failed"?"text-red-500":"text-gray-500"),children:n.status==="failed"&&n.error?n.error:n.task}),n.status==="completed"&&n.executionTime!=null&&jsxs("span",{className:"text-xs text-gray-400 shrink-0",children:[n.executionTime.toFixed(1),"s"]})]})}));return jsxs("div",{className:"space-y-2",children:[jsx("span",{className:"text-sm text-gray-500",children:a.running===0?"Agents:":"Running agents:"}),jsx(Fe,{items:t,badgeSize:16}),a.isSynthesizing&&jsxs("div",{className:"flex items-center gap-2",children:[jsx(Sparkle,{size:14,className:"text-gray-500"}),jsx("span",{className:"text-sm text-gray-500",children:"Synthesizing results..."})]})]})}function $o({chunks:e}){return jsx("div",{className:"space-y-2",children:e.map((a,r)=>a.type==="subagent"&&a.subagentData?jsx(ut,{chunk:a},`subagent-${a.subagentData.subagentId}-${r}`):a.type==="file_operation"&&a.fileOperationData?jsx(dt,{chunk:a},`file-op-${a.fileOperationData.toolUseId}-${r}`):a.type==="terminal"&&a.terminalData?jsx(ct,{chunk:a},`terminal-${a.terminalData.toolUseId}-${r}`):a.type==="search_results"&&a.searchResultsData?jsx(pt,{chunk:a},`search-${a.searchResultsData.toolUseId}-${r}`):a.type==="web_operation"&&a.webOperationData?jsx(mt,{chunk:a},`web-op-${a.webOperationData.toolUseId}-${r}`):a.claudeToolData?jsx(lt,{chunk:a},`claude-tool-${a.claudeToolData.toolUseId}-${r}`):null)})}function La(e){return e<1?`${Math.round(e*1e3)}ms`:`${e.toFixed(1)}s`}function Kt({isStreaming:e=false,chunks:a=[],plan:r,executionTimeline:t=[],userMessageTimestamp:n,executionTime:o,defaultExpanded:s=false,expanded:l,onExpandedChange:c,className:d}){let[f,x]=useState(s),{display:N,finalSeconds:y}=Ao(e),g=useRef(null);useEffect(()=>{_e(g.current);},[]);let C=a$2(g,300),z=l??f,_=useCallback(k=>{C(),x(k),c?.(k);},[C,c]),M=useMemo(()=>e?a.map((k,D)=>ot(k,D)).filter(k=>k!==null):[],[e,a]),K=useMemo(()=>!e&&(t.length>0||a.length>0)?a.map((k,D)=>ot(k,D)).filter(k=>k!==null):[],[e,t,a]),E=useMemo(()=>!e&&t.length>0?Fo(t):[],[e,t]),u=useMemo(()=>{if(!e)return null;let k=a.find(S=>S.planData!==void 0);if(!k?.planData)return null;let D={...k.planData},b=[...D.subtasks||[]],I=0,A=0;return a.forEach(S=>{if(S.type==="parallel_subtask_start"&&S.subtaskId!==void 0){let W=b.findIndex(h=>String(h.id)===String(S.subtaskId));W!==-1&&(b[W]={...b[W],status:"running"});}else if(S.type==="parallel_subtask_complete"&&S.subtaskId!==void 0){let W=b.findIndex(h=>String(h.id)===String(S.subtaskId));if(W!==-1){let h={...b[W]};S.parallelSubtaskData?.success===false||S.success===false?(h.status="failed",h.error=S.parallelSubtaskData?.error,A++):(h.status="completed",h.result=S.parallelSubtaskData?.result,h.execution_time=S.parallelSubtaskData?.executionTime,I++),b[W]=h;}}else if(S.type==="subtask"&&S.subtaskId!==void 0){let W=b.findIndex(h=>String(h.id)===String(S.subtaskId));if(W!==-1){let h={...b[W]};if(S.content.includes("\u2713 Completed"))h.status="completed",S.subtaskData?.execution_time&&(h.execution_time=S.subtaskData.execution_time),I++;else if(S.content.includes("\u2717 Failed")){h.status="failed";let ke=S.content.match(/✗ Failed: (.*)/);ke&&(h.error=ke[1]),A++;}else S.content.includes("\u2192 **Subtask")&&(h.status="running");b[W]=h;}}}),D.subtasks=b,D.completed_subtasks=I,D.failed_subtasks=A,D.progress_percentage=I/D.total_subtasks*100,D},[e,a]),v=useMemo(()=>{if(o&&o>0)return o;if(!e){if(r?.subtasks)return r.subtasks.reduce((k,D)=>k+(D.execution_time||0),0);if(t.length>0){let k=t[t.length-1];if(n&&k.timestamp){let D=k.timestamp-n;if(D>0)return D}if(t.length>1){let D=t[0];if(D.timestamp&&k.timestamp){let b=k.timestamp-D.timestamp;if(b>0)return b}}}}return 0},[e,r,t,n,o]);if(!e){let k=r||t.length>0||a.length>0;if(!k||k&&K.length===0&&!r&&t.length===0)return null}let m=a.length>0?a[a.length-1]:null,F=m?.type==="tool"||!!m?.toolName,w=m?.type==="planning",q=Io(a),$=q?_o(a):null,me=Lo(a),ie=Vo(a),we=ie?Fa(a):null,Re=()=>{if(!e)return v>0?`Thought for ${La(v)}`:y>0?`Thought for ${La(y)}`:(a.length>0,"Thought for a few seconds");if(ie&&we){let{running:k,completed:D,failed:b,isSynthesizing:I}=we;if(I)return "Synthesizing results...";if(m?.type==="multi_agent_planning")return "Planning subagent allocation...";if(m?.type==="subagent_start"&&m?.subagentInfo)return `${m.subagentInfo.name}: ${m.subagentInfo.task?.slice(0,30)||"working"}...`;if(m?.type==="subagent_complete"&&m?.subagentInfo)return `${m.subagentInfo.name} complete`;if(m?.type==="subagent_failed"&&m?.subagentInfo)return `${m.subagentInfo.name} failed`;let A=k+D+b;if(k>0)return `${k} subagent${k>1?"s":""} running (${D}/${A} done)`;if(A>0)return `Multi-agent execution (${D}/${A} complete)`}if(me){if(m?.type==="subagent"&&m?.subagentData)return `${m.subagentData.subagentType}: ${m.subagentData.description}`;if(m?.type==="file_operation"&&m?.fileOperationData){let k=m.fileOperationData.operation,D=m.fileOperationData.filePath.split("/").pop();return `${k==="read"?"Reading":k==="edit"?"Editing":"Writing"} ${D}`}if(m?.type==="terminal"&&m?.terminalData){let k=m.terminalData.command;return k.length>40?`$ ${k.slice(0,37)}...`:`$ ${k}`}if(m?.type==="search_results"&&m?.searchResultsData)return `${m.searchResultsData.tool}: ${m.searchResultsData.pattern}`;if(m?.type==="web_operation"&&m?.webOperationData)return m.webOperationData.operation==="search"?`Searching: ${m.webOperationData.query}`:`Fetching: ${m.webOperationData.url?.slice(0,40)}...`}if(q&&$){let{currentWave:k,totalWaves:D,parallelCount:b,activeSubtasks:I,completedSubtasks:A}=$;if(m?.type==="wave_start")return `Wave ${k+1}/${D}: ${b} parallel subtasks`;if(m?.type==="wave_complete")return `Wave ${k+1} complete (${A.length} done)`;if(m?.type==="parallel_subtask_start"&&m?.parallelSubtaskData?.description){let S=m.parallelSubtaskData.description;return S.length>40?`${S.slice(0,37)}...`:S}return I.length>0?`Wave ${k+1}/${D}: ${I.length} running...`:`Parallel execution (Wave ${k+1}/${D})`}if(m?.toolDescription)return m.toolDescription;if(m?.toolName)return m.toolName;switch(m?.type){case "planning":return "Planning...";case "thinking":return "Thinking...";case "tool":return m.toolName||"Using tool...";case "subtask":return `Executing subtask ${m.subtaskId||""}...`;case "observation":return "Analyzing results...";case "progress":return "Working...";case "wave_start":return "Starting parallel execution...";case "wave_complete":return "Parallel wave complete";case "parallel_subtask_start":return "Running parallel subtask...";case "parallel_subtask_complete":return "Parallel subtask complete";default:return "Thinking..."}},Oe=()=>ie?jsx(Users,{size:14}):me?m?.type==="subagent"?jsx(GitBranch,{size:14}):m?.type==="file_operation"?jsx(FileText,{size:14}):m?.type==="terminal"?jsx(Terminal,{size:14}):m?.type==="search_results"?jsx(Search,{size:14}):m?.type==="web_operation"?jsx(Globe,{size:14}):jsx(Sparkle,{size:14}):q?jsx(Zap,{size:14}):F?jsx(Wrench,{size:14}):w?jsx(ListTodo,{size:14}):jsx(Sparkle,{size:14}),Me=k=>k?.subtasks&&k.subtasks.length>=2,Ae=e?u:r,Le=Me(Ae);return jsxs("div",{ref:g,className:i("max-w-full",d),children:[jsxs("div",{onClick:()=>_(!z),style:{position:"relative",display:"inline-flex",alignItems:"center",gap:6,padding:"4px 6px",overflow:"hidden",borderRadius:8,cursor:"pointer",transition:"opacity 0.2s",...!e&&{opacity:.6}},children:[e&&jsx("div",{style:Ve}),jsx("span",{className:i("flex items-center text-gray-500"),children:e?Oe():jsx(Sparkle,{size:14})}),jsx("span",{className:i("text-sm font-normal text-gray-500 text-[var(--chat-text-subtle)]"),children:Re()}),e&&parseInt(N)>0&&jsxs("span",{className:"text-gray-500 font-normal tabular-nums text-sm",children:[N,"s"]})]}),z&&jsx("div",{className:"mt-3 animate-fade-in",children:e?ie?jsx(Bo,{chunks:a}):me?jsx($o,{chunks:a}):Le&&Ae?jsx(it,{plan:Ae,streamingChunks:a}):u?.subtasks?.length===1?jsx(Se,{events:M}):u?.subtasks?.length===0?null:jsx(Se,{events:M}):r?r.subtasks?.length===0?null:r.subtasks?.length===1?jsx(Se,{events:K}):jsx(it,{plan:r,streamingChunks:E}):jsx(Se,{events:K})})]})}var Ze=forwardRef(({content:e,isStreaming:a=false,renderMarkdown:r=true,className:t,baselineFontSize:n,markdownProps:o},s)=>jsx(m,{ref:s,content:e,isStreaming:a,showCursor:false,className:i("relative",t),children:r?jsx(ne,{baselineFontSize:n,...o,children:e}):jsx("span",{className:"whitespace-pre-wrap",children:e})}));Ze.displayName="StreamingText";var es={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 ts(e){return e?es[e]||jsx(ArrowRight,{size:14}):jsx(ArrowRight,{size:14})}var ft=forwardRef(({actions:e,onSelect:a,className:r,showIcons:t=true,disabled:n=false},o)=>{let[s,l]=useState(null);if(e.length===0)return null;let c=async(d,f)=>{if(!(!a||s!==null)){l(f);try{await a(d);}finally{l(null);}}};return jsx("div",{ref:o,role:"group","aria-label":"Suggested actions",className:i("flex flex-wrap gap-2",r),children:jsx(AnimatePresence,{children:e.map((d,f)=>{let x=s===f,N=n||s!==null;return jsxs(motion.button,{type:"button",initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.2,delay:f*.05},disabled:N,onClick:()=>c(d,f),className:i("inline-flex items-center gap-1.5","px-3 py-1.5 rounded-lg","text-sm font-medium","border border-gray-200 dark:border-gray-700","bg-white dark:bg-gray-800","text-gray-700 dark:text-gray-300","opacity-80 hover:opacity-100","hover:border-gray-300 dark:hover:border-gray-600","hover:bg-gray-50 dark:hover:bg-gray-750","hover:-translate-y-px","active:translate-y-0","transition-all duration-200","focus:outline-none focus:ring-2 focus:ring-blue-500/20","disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:translate-y-0"),children:[x?jsx(Loader2,{size:14,className:"animate-spin"}):t&&jsx("span",{className:"text-gray-400 dark:text-gray-500",children:ts(d.type)}),d.label]},d.id)})})})});ft.displayName="SuggestedActions";var fs=["#3B82F6","#10B981","#F59E0B","#EF4444","#8B5CF6","#EC4899","#06B6D4","#F97316"];function yt({data:e,config:a,isStreaming:r=false}){let{chartType:t,series:n,xAxis:o,yAxis:s}=e,l=a?.colors||fs,c=a?.height||300,d=a?.legend!==false,f=a?.grid!==false,x=a?.tooltip!==false,N=a?.animate!==false&&!r,y=a?.stacked||false,C=(()=>{if(t==="pie")return (n[0]?.data||[]).map((v,m)=>({name:v.name||v.x||`Item ${m+1}`,value:v.value??v.y??0}));let E=new Map;return n.forEach(u=>{u.data.forEach(v=>{let m=v.x??v.name;E.has(m)||E.set(m,{x:m}),E.get(m)[u.name]=v.y??v.value??0;});}),Array.from(E.values())})(),z={data:C,margin:{top:10,right:30,left:0,bottom:0}},_={fontSize:12},M={backgroundColor:"#fff",border:"1px solid #e5e7eb",borderRadius:8};return jsx("div",{className:"w-full",style:{height:c},children:jsx(ResponsiveContainer,{width:"100%",height:"100%",children:(()=>{switch(t){case "line":return jsxs(LineChart,{...z,children:[f&&jsx(CartesianGrid,{strokeDasharray:"3 3",stroke:"#e5e7eb"}),jsx(XAxis,{dataKey:"x",..._,tickLine:false,padding:{left:10,right:10}}),jsx(YAxis,{..._,tickLine:false,width:40}),x&&jsx(Tooltip,{contentStyle:M}),d&&jsx(Legend,{}),n.map((E,u)=>jsx(Line,{type:"monotone",dataKey:E.name,stroke:E.color||l[u%l.length],strokeWidth:2,dot:false,activeDot:{r:4},isAnimationActive:N},E.name))]});case "bar":return jsxs(BarChart,{...z,children:[f&&jsx(CartesianGrid,{strokeDasharray:"3 3",stroke:"#e5e7eb"}),jsx(XAxis,{dataKey:"x",..._,tickLine:false,padding:{left:10,right:10}}),jsx(YAxis,{..._,tickLine:false,width:40}),x&&jsx(Tooltip,{contentStyle:M}),d&&jsx(Legend,{}),n.map((E,u)=>jsx(Bar,{dataKey:E.name,fill:E.color||l[u%l.length],stackId:y?"stack":void 0,isAnimationActive:N,radius:[4,4,0,0]},E.name))]});case "area":return jsxs(AreaChart,{...z,children:[f&&jsx(CartesianGrid,{strokeDasharray:"3 3",stroke:"#e5e7eb"}),jsx(XAxis,{dataKey:"x",..._,tickLine:false,padding:{left:10,right:10}}),jsx(YAxis,{..._,tickLine:false,width:40}),x&&jsx(Tooltip,{contentStyle:M}),d&&jsx(Legend,{}),n.map((E,u)=>jsx(Area,{type:"monotone",dataKey:E.name,stroke:E.color||l[u%l.length],fill:E.color||l[u%l.length],fillOpacity:.3,stackId:y?"stack":void 0,isAnimationActive:N},E.name))]});case "pie":return jsxs(PieChart,{children:[x&&jsx(Tooltip,{contentStyle:M}),d&&jsx(Legend,{}),jsx(Pie,{data:C,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",outerRadius:Math.min(c,300)/3,isAnimationActive:N,label:({name:E,percent:u})=>`${E}: ${((u??0)*100).toFixed(0)}%`,labelLine:false,children:C.map((E,u)=>jsx(Cell,{fill:l[u%l.length]},`cell-${u}`))})]});case "scatter":return jsxs(ScatterChart,{...z,children:[f&&jsx(CartesianGrid,{strokeDasharray:"3 3",stroke:"#e5e7eb"}),jsx(XAxis,{dataKey:"x",type:"number",..._,tickLine:false,name:o?.label,padding:{left:10,right:10}}),jsx(YAxis,{..._,tickLine:false,name:s?.label,width:40}),x&&jsx(Tooltip,{contentStyle:M}),d&&jsx(Legend,{}),n.map((E,u)=>jsx(Scatter,{name:E.name,data:E.data.map(v=>({x:v.x,y:v.y})),fill:E.color||l[u%l.length],isAnimationActive:N},E.name))]});default:return null}})()||jsx(Fragment,{})})})}var ks={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 Ns(e,a){if(e==null)return jsx("span",{className:"text-gray-400",children:"-"});switch(a.type||"string"){case "number":return typeof e=="number"?e.toLocaleString():String(e);case "currency":return typeof e=="number"?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format(e):String(e);case "date":try{return new Date(e).toLocaleDateString()}catch{return String(e)}case "badge":{let t=String(e).toLowerCase().replace(/\s+/g,"_"),n=ks[t]||"bg-gray-100 text-gray-700";return jsx("span",{className:i("inline-block px-2 py-0.5 rounded-full text-xs font-medium",n),children:String(e)})}case "link":return jsx("a",{href:String(e),target:"_blank",rel:"noopener noreferrer",className:"text-blue-500 hover:underline",children:String(e)});case "boolean":return e?jsx(Check,{size:18,className:"text-green-500"}):jsx(X,{size:18,className:"text-gray-400"});case "progress":{let t=typeof e=="number"?e:parseFloat(String(e));return jsxs("div",{className:"flex items-center gap-2",children:[jsx("div",{className:"flex-1 h-2 bg-gray-200 dark:bg-gray-700 rounded-full overflow-hidden",children:jsx("div",{className:"h-full bg-blue-500 rounded-full",style:{width:`${Math.min(100,Math.max(0,t))}%`}})}),jsxs("span",{className:"text-xs text-gray-500",children:[t.toFixed(0),"%"]})]})}default:return String(e)}}function $a(e,a,r){let t=e[r],n=a[r];return t==null?1:n==null?-1:typeof t=="number"&&typeof n=="number"?n-t:String(n).localeCompare(String(t))}function vt({data:e,config:a}){let{columns:r,rows:t}=e,n=a?.sortable!==false,o=a?.paginated||false,s=a?.pageSize||10,[l,c]=useState("asc"),[d,f]=useState(r[0]?.key||""),[x,N]=useState(0),y=z=>{c(d===z&&l==="asc"?"desc":"asc"),f(z);},g=useMemo(()=>{let z=[...t];return n&&d&&z.sort((_,M)=>l==="desc"?$a(_,M,d):-$a(_,M,d)),o&&(z=z.slice(x*s,(x+1)*s)),z},[t,l,d,x,s,n,o]),C=Math.ceil(t.length/s);return jsxs("div",{className:"w-full overflow-x-auto",children:[jsxs("table",{className:"min-w-full text-sm",children:[jsx("thead",{children:jsx("tr",{children:r.map(z=>jsx("th",{className:i("px-3 py-2 font-semibold bg-gray-50 dark:bg-gray-800 whitespace-nowrap text-left",n&&"cursor-pointer select-none hover:bg-gray-100 dark:hover:bg-gray-700"),style:{width:z.width,textAlign:z.align||"left"},onClick:()=>n&&y(z.key),children:jsxs("span",{className:"inline-flex items-center gap-1",children:[z.label,n&&d===z.key&&(l==="asc"?jsx(ChevronUp,{size:14}):jsx(ChevronDown,{size:14}))]})},z.key))})}),jsxs("tbody",{children:[g.map((z,_)=>jsx("tr",{className:"border-t border-gray-100 dark:border-gray-800 hover:bg-gray-50 dark:hover:bg-gray-800/50",children:r.map(M=>jsx("td",{className:"px-3 py-2 whitespace-nowrap max-w-[300px] overflow-hidden text-ellipsis",style:{textAlign:M.align||"left"},children:Ns(z[M.key],M)},M.key))},_)),g.length===0&&jsx("tr",{children:jsx("td",{colSpan:r.length,className:"px-3 py-8 text-center text-gray-400",children:"No data available"})})]})]}),o&&t.length>s&&jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-t border-gray-200 dark:border-gray-700 text-sm",children:[jsxs("span",{className:"text-gray-500",children:[x*s+1,"-",Math.min((x+1)*s,t.length)," of ",t.length]}),jsxs("div",{className:"flex gap-1",children:[jsx("button",{onClick:()=>N(Math.max(0,x-1)),disabled:x===0,className:"px-2 py-1 rounded hover:bg-gray-100 dark:hover:bg-gray-800 disabled:opacity-30",children:"Prev"}),jsx("button",{onClick:()=>N(Math.min(C-1,x+1)),disabled:x>=C-1,className:"px-2 py-1 rounded hover:bg-gray-100 dark:hover:bg-gray-800 disabled:opacity-30",children:"Next"})]})]})]})}function wt({data:e,config:a,onAction:r}){let{subtitle:t,imageUrl:n,sections:o,actions:s}=e,l=a?.collapsible||false,c=a?.initiallyCollapsed||false,[d,f]=useState(!c),x=g=>{g.startsWith("http://")||g.startsWith("https://")||g.startsWith("/")?window.open(g,"_blank","noopener,noreferrer"):r?r({type:"card_action",action:g}):window.dispatchEvent(new CustomEvent("visualization-action",{detail:{action:g}}));},N=(g,C)=>jsxs("div",{className:i(C<o.length-1&&"mb-4"),children:[g.title&&jsx("h4",{className:"font-semibold text-sm mb-2",children:g.title}),g.items&&g.items.length>0&&jsx("div",{className:"space-y-1",children:g.items.map((z,_)=>jsxs("div",{className:"flex justify-between items-start gap-4",children:[jsx("span",{className:"text-sm text-gray-500 shrink-0",children:z.label}),jsx("span",{className:"text-sm font-medium text-right",children:z.value})]},_))}),g.content&&jsx(ne,{children:g.content})]},C),y=jsxs(Fragment,{children:[n&&jsx("img",{src:n,alt:"",className:"w-full h-[140px] object-cover border-b border-gray-200 dark:border-gray-700"}),t&&jsx("p",{className:"text-sm text-gray-500 italic mb-4",children:t}),o.map((g,C)=>jsxs("div",{children:[N(g,C),C<o.length-1&&jsx("hr",{className:"my-4 border-gray-200 dark:border-gray-700"})]},C))]});return jsxs("div",{className:"w-full",children:[l&&jsxs("div",{className:"flex items-center justify-between mb-2 cursor-pointer",onClick:()=>f(!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})})]}),(!l||d)&&y,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((g,C)=>jsxs("button",{onClick:()=>x(g.action),className:i("px-3 py-1.5 text-sm rounded-lg transition-colors",g.variant==="primary"?"bg-blue-500 text-white hover:bg-blue-600":g.variant==="text"?"text-blue-500 hover:bg-blue-50":"border border-gray-300 hover:bg-gray-50"),children:[g.label,g.action.startsWith("http")&&jsx(ExternalLink,{size:14,className:"inline ml-1"})]},C))})]})}var Is=["#3B82F6","#10B981","#F59E0B","#8B5CF6"];function _s({metric:e,color:a,animate:r}){let t=e.trend==="up"?jsx(ArrowUp,{size:16,className:"text-green-500"}):e.trend==="down"?jsx(ChevronDown,{size:16,className:"text-red-500"}):e.trend==="neutral"?jsx(Circle,{size:14,className:"text-gray-400"}):null,n=e.trend==="up"?"text-green-500":e.trend==="down"?"text-red-500":"text-gray-500",o=e.sparkline?.map((s,l)=>({value:s,idx:l}));return jsxs("div",{className:"p-4 rounded-lg border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-900 relative overflow-hidden",children:[o&&o.length>0&&jsx("div",{className:"absolute bottom-0 left-0 right-0 h-10 opacity-30",children:jsx(ResponsiveContainer,{width:"100%",height:"100%",children:jsx(AreaChart,{data:o,margin:{top:0,right:0,left:0,bottom:0},children:jsx(Area,{type:"monotone",dataKey:"value",stroke:e.color||a,fill:e.color||a,strokeWidth:1,isAnimationActive:r})})})}),jsxs("div",{className:"relative z-10",children:[jsx("span",{className:"text-xs text-gray-500 font-medium uppercase tracking-wider",children:e.label}),jsxs("div",{className:"flex items-baseline gap-1 mt-1",children:[jsx("span",{className:"text-2xl font-bold",children:e.value}),e.unit&&jsx("span",{className:"text-sm text-gray-500",children:e.unit})]}),(e.trend||e.change)&&jsxs("div",{className:"flex items-center gap-1 mt-2",children:[t,e.change&&jsx("span",{className:i("text-sm font-medium",n),children:e.change}),e.changeLabel&&jsx("span",{className:"text-xs text-gray-500",children:e.changeLabel})]})]})]})}function Nt({data:e,config:a,isStreaming:r=false}){let{metrics:t,layout:n="row"}=e,o=a?.colors||Is,s=a?.animate!==false&&!r,l=n==="grid";return jsx("div",{className:i("w-full",l?"grid grid-cols-1 sm:grid-cols-2 gap-4":"flex gap-4 flex-wrap"),children:t.map((c,d)=>jsx("div",{className:i(!l&&"flex-1 min-w-[200px]"),children:jsx(_s,{metric:c,color:c.color||o[d%o.length],animate:s})},d))})}var Hs={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 Ct({data:e}){let{code:a,language:r,lineNumbers:t=true,highlightLines:n=[],startLine:o=1}=e,[s,l]=useState(false),c=Hs[r.toLowerCase()]||r.toLowerCase(),d=async()=>{try{await navigator.clipboard.writeText(a),l(!0);}catch{}};return useEffect(()=>{if(s){let x=setTimeout(()=>l(false),2e3);return ()=>clearTimeout(x)}},[s]),jsxs("div",{className:"relative rounded-lg overflow-hidden border border-gray-200 dark:border-gray-700",children:[jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 bg-gray-800 dark:bg-gray-900 border-b border-gray-700",children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx(FileText,{size:16,className:"text-gray-400"}),jsx("span",{className:"text-xs font-mono text-gray-400 lowercase",children:c})]}),jsx("button",{onClick: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:c,style:oneDark,showLineNumbers:t,startingLineNumber:o,wrapLines:true,lineProps:x=>{let N={};return n.includes(x)&&(N.backgroundColor="rgba(59, 130, 246, 0.1)",N.display="block",N.borderLeft="3px solid #3B82F6",N.paddingLeft="8px",N.marginLeft="-11px"),{style:N}},customStyle:{margin:0,borderRadius:0,fontSize:"0.8125rem",lineHeight:"1.6",background:"#1e1e1e"},codeTagProps:{style:{fontFamily:"'Fira Code', 'JetBrains Mono', monospace"}},children:a.trim()})]})}function St({data:e,config:a,isStreaming:r=false,onAction:t}){let{fields:n,submitAction:o}=e,s=a?.submitButtonText||"Submit",l=a?.cancelButtonText||"Cancel",[c,d]=useState(()=>{let u={};return n.forEach(v=>{v.defaultValue!==void 0?u[v.name]=v.defaultValue:v.type==="multiselect"?u[v.name]=[]:v.type==="checkbox"?u[v.name]=false:u[v.name]="";}),u}),[f,x]=useState({}),[N,y]=useState(false),g=(u,v)=>{d(m=>({...m,[u]:v})),f[u]&&x(m=>{let F={...m};return delete F[u],F});},C=()=>{let u={};return n.forEach(v=>{let m=c[v.name];if(v.required&&(m==null||m===""||Array.isArray(m)&&m.length===0)){u[v.name]=`${v.label} is required`;return}if(!(!m&&!v.required)){if(v.validation){let{min:F,max:w,pattern:q,message:$}=v.validation;F!==void 0&&typeof m=="number"&&m<F&&(u[v.name]=$||`Minimum value is ${F}`),w!==void 0&&typeof m=="number"&&m>w&&(u[v.name]=$||`Maximum value is ${w}`),q&&typeof m=="string"&&!new RegExp(q).test(m)&&(u[v.name]=$||"Invalid format");}v.type==="email"&&typeof m=="string"&&m&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(m)&&(u[v.name]="Invalid email address");}}),x(u),Object.keys(u).length===0},z=u=>{u.preventDefault(),C()&&(t?t({type:"form_submit",action:o||"",data:c}):window.dispatchEvent(new CustomEvent("visualization-form-submit",{detail:{action:o,data:c}})),y(true));},_=()=>{t?t({type:"form_cancel",action:o||""}):window.dispatchEvent(new CustomEvent("visualization-form-cancel",{detail:{action:o}}));};if(N)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",K="border-red-500 focus:ring-red-500/20 focus:border-red-500",E=u=>{let v=c[u.name],F=!!f[u.name];switch(u.type){case "text":case "email":case "number":return jsx("input",{type:u.type,placeholder:u.placeholder,required:u.required,value:String(v||""),onChange:w=>g(u.name,u.type==="number"?parseFloat(w.target.value)||"":w.target.value),className:i(M,F&&K),min:u.validation?.min,max:u.validation?.max});case "textarea":return jsx("textarea",{placeholder:u.placeholder,required:u.required,value:String(v||""),onChange:w=>g(u.name,w.target.value),className:i(M,"min-h-[100px] resize-y",F&&K),rows:4});case "select":return jsxs("select",{value:String(v||""),onChange:w=>g(u.name,w.target.value),className:i(M,F&&K),children:[jsx("option",{value:"",disabled:true,children:u.placeholder||"Select an option"}),u.options?.map(w=>jsx("option",{value:w.value,children:w.label},w.value))]});case "multiselect":return jsx("select",{multiple:true,value:v||[],onChange:w=>g(u.name,Array.from(w.target.selectedOptions,q=>q.value)),className:i(M,"min-h-[80px]",F&&K),children:u.options?.map(w=>jsx("option",{value:w.value,children:w.label},w.value))});case "checkbox":return jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[jsx("input",{type:"checkbox",checked:!!v,onChange:w=>g(u.name,w.target.checked),className:"w-4 h-4 accent-blue-500 rounded"}),jsx("span",{className:"text-sm",children:u.label})]});case "radio":return jsx("div",{className:"space-y-1",children:u.options?.map(w=>jsxs("label",{className:"flex items-center gap-2 cursor-pointer text-sm",children:[jsx("input",{type:"radio",name:u.name,value:w.value,checked:v===w.value,onChange:q=>g(u.name,q.target.value),className:"w-3.5 h-3.5 accent-blue-500"}),w.label]},w.value))});case "date":return jsx("input",{type:"date",value:String(v||""),onChange:w=>g(u.name,w.target.value),className:i(M,F&&K)});case "datetime":return jsx("input",{type:"datetime-local",value:String(v||""),onChange:w=>g(u.name,w.target.value),className:i(M,F&&K)});default:return null}};return jsxs("form",{onSubmit:z,className:"space-y-4",children:[n.map(u=>jsxs("div",{children:[u.type!=="checkbox"&&jsxs("label",{className:"block text-sm font-medium mb-1",children:[u.label,u.required&&jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]}),E(u),f[u.name]&&jsx("p",{className:"text-xs text-red-500 mt-1",children:f[u.name]})]},u.name)),jsxs("div",{className:"flex gap-2 pt-2",children:[jsx("button",{type:"submit",disabled:r,className:"px-4 py-2 text-sm rounded-lg bg-blue-500 text-white hover:bg-blue-600 disabled:opacity-50 transition-colors",children:s}),jsx("button",{type:"button",onClick:_,className:"px-4 py-2 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors",children:l})]})]})}var zt=new Map;function Te(e,a){zt.set(e,a);}function Pt(e){return zt.get(e)}function Oa(){return Array.from(zt.keys())}Te("chart",{component:yt});Te("table",{component:vt});Te("card",{component:wt});Te("kpi",{component:Nt});Te("code_preview",{component:Ct});Te("form",{component:St});function Wa(e){for(let[a,r]of Object.entries(e)){let t=zt.get(a);t&&(t.schema=r);}}var Us=z.object({name:z.string(),data:z.array(z.union([z.object({x:z.union([z.string(),z.number()]),y:z.number()}),z.object({name:z.string(),value:z.number()})])),color:z.string().optional()}),ja=z.object({label:z.string().optional(),type:z.enum(["category","number","time"]).optional(),min:z.number().optional(),max:z.number().optional()}),Yt=z.object({chartType:z.enum(["line","bar","pie","area","scatter","composed"]),series:z.array(Us),xAxis:ja.optional(),yAxis:ja.optional()}),Ks=z.object({key:z.string(),label:z.string(),type:z.enum(["string","number","currency","date","badge","link","boolean","progress"]).optional(),align:z.enum(["left","center","right"]).optional(),width:z.string().optional()}),Jt=z.object({columns:z.array(Ks),rows:z.array(z.record(z.string(),z.unknown()))}),qs=z.object({title:z.string().optional(),items:z.array(z.object({label:z.string(),value:z.union([z.string(),z.number()])})).optional(),content:z.string().optional()}),Gs=z.object({label:z.string(),action:z.string(),variant:z.enum(["primary","secondary","text"]).optional()}),Qt=z.object({subtitle:z.string().optional(),imageUrl:z.string().optional(),sections:z.array(qs),actions:z.array(Gs).optional()}),Xs=z.object({label:z.string(),value:z.union([z.string(),z.number()]),unit:z.string().optional(),trend:z.enum(["up","down","neutral"]).optional(),change:z.string().optional(),changeLabel:z.string().optional(),sparkline:z.array(z.number()).optional(),color:z.string().optional()}),ea=z.object({metrics:z.array(Xs),layout:z.enum(["row","grid"]).optional()}),ta=z.object({code:z.string(),language:z.string(),lineNumbers:z.boolean().optional(),highlightLines:z.array(z.number()).optional(),startLine:z.number().optional()}),Zs=z.object({name:z.string(),type:z.enum(["text","number","email","select","multiselect","checkbox","radio","textarea","date","datetime"]),label:z.string(),required:z.boolean().optional(),placeholder:z.string().optional(),options:z.array(z.object({value:z.string(),label:z.string()})).optional(),defaultValue:z.unknown().optional(),validation:z.object({min:z.number().optional(),max:z.number().optional(),pattern:z.string().optional(),message:z.string().optional()}).optional()}),aa=z.object({fields:z.array(Zs),submitAction:z.string().optional()});Wa({chart:Yt,table:Jt,card:Qt,kpi:ea,code_preview:ta,form:aa});function Tt({data:e,isStreaming:a=false,onAction:r}){let{type:t,title:n,description:o,data:s,config:l}=e;return jsxs("div",{className:"my-3 overflow-hidden",children:[(n||o)&&jsxs("div",{className:"mb-2",children:[n&&jsx("p",{className:"text-sm font-semibold",children:n}),o&&jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:o})]}),jsx("div",{children:(()=>{let d=Pt(t);if(!d)return jsxs("div",{className:"flex items-center gap-2 p-4 text-yellow-500",children:[jsx(AlertCircle,{size:20}),jsxs("span",{className:"text-sm",children:["Unknown visualization type: ",t]})]});if(d.schema){let x=d.schema.safeParse(s);if(!x.success){let N=x.error.issues.slice(0,3);return jsxs("div",{className:"p-4 rounded-lg border border-red-200 dark:border-red-800 bg-red-50 dark:bg-red-950/30",children:[jsxs("div",{className:"flex items-center gap-2 text-red-600 dark:text-red-400 mb-2",children:[jsx(AlertCircle,{size:18}),jsxs("span",{className:"text-sm font-medium",children:["Invalid ",t," visualization data"]})]}),jsxs("ul",{className:"text-xs text-red-500 dark:text-red-400 space-y-1 list-disc list-inside",children:[N.map((y,g)=>jsxs("li",{children:[y.path.join("."),": ",y.message]},g)),x.error.issues.length>3&&jsxs("li",{children:["...and ",x.error.issues.length-3," more"]})]})]})}}let f=d.component;return jsx(f,{data:s,config:l,isStreaming:a,onAction:r})})()})]})}var Ua=/\[(VIZ|MEDIA):([a-f0-9-]+)\]/gi;function Ka(e){let a=[],r=0,t;for(Ua.lastIndex=0;(t=Ua.exec(e))!==null;){if(t.index>r){let o=e.slice(r,t.index);o.trim()&&a.push({type:"text",content:o});}t[1].toUpperCase()==="VIZ"?a.push({type:"viz",id:t[2]}):a.push({type:"media",id:t[2]}),r=t.index+t[0].length;}if(r<e.length){let n=e.slice(r);n.trim()&&a.push({type:"text",content:n});}return a}var qa=forwardRef(({message:e,viewerRole:a$1="user",className:r,showAvatar:t=true,showTimestamp:n=true,renderMarkdown:o=true,reasoning:s,executionPlan:l,executionTimeline:c$1,suggestedActions:d$1,onSuggestedAction:f,reasoningExpanded:x,onReasoningExpandedChange:N,citations:y,visualizations:g,medias:C,baselineFontSize:z,executionTime:_,pendingClarification:M,onClarificationSubmit:K},E)=>{let v=useContext(a)?.onVisualizationAction,m=(e.participant?.role||"").toLowerCase(),F=(a$1||"").toLowerCase(),w=m===F,q=m==="assistant",$=e.isStreaming,me=s?.filter(h=>h.type==="thinking"||h.type==="tool"||h.type==="observation"||h.type==="planning"||h.type==="subtask"||h.type==="wave_start"||h.type==="wave_complete"||h.type==="parallel_subtask_start"||h.type==="parallel_subtask_complete"||h.type==="multi_agent_planning"||h.type==="subagent_start"||h.type==="subagent_complete"||h.type==="subagent_failed"||h.type==="synthesis"||h.type==="claude_thinking"||h.type==="subagent"||h.type==="file_operation"||h.type==="terminal"||h.type==="search_results"||h.type==="web_operation"||h.claudeToolData!=null),ie=me&&me.length>0,we=!$&&(l||c$1&&c$1.length>0),Re=ie||we,Oe=$&&!e.textContent&&!Re,Me=e.attachments,Ae=Me&&Me.length>0,Le=useMemo(()=>{if(!g||g.length===0)return null;let h=new Map;return g.forEach(ke=>h.set(ke.id,ke)),h},[g]),k=Le&&Le.size>0,D=useMemo(()=>!k||!e.textContent?null:Ka(e.textContent),[k,e.textContent]),b=useMemo(()=>!C||C.length===0||!e.textContent?e.textContent:e.textContent.replace(/\[MEDIA:[a-f0-9-]+\]/gi,"").trim(),[e.textContent,C]),I=()=>e.textContent?D&&D.length>0&&k?jsx(Fragment,{children:D.map((h,ke)=>{if(h.type==="text")return $?jsx(Ze,{content:h.content,isStreaming:true,baselineFontSize:z},ke):jsx(ne,{baselineFontSize:z,className:w?"prose-invert":"",children:h.content},ke);if(h.type==="viz"){let da=Le?.get(h.id);return da?jsx(Tt,{data:da,isStreaming:$,onAction:v},`viz-${h.id}`):null}return null})}):$&&o?jsx(Ze,{content:b||"",isStreaming:true,baselineFontSize:z,className:w?"prose-invert":""}):o?jsx(ne,{baselineFontSize:z,className:w?"prose-invert":"",children:b||""}):jsx("p",{className:"whitespace-pre-wrap",children:b}):null,A=()=>!C||C.length===0?null:C.map(h=>h.mediaType==="image"?jsx("div",{className:"my-3",children:jsx("img",{src:h.url,alt:h.altText||"Generated image",className:"max-w-full rounded-lg",style:{maxHeight:512,display:"block"}})},`media-${h.id}`):null),S=useRef($);$&&(S.current=true);let W=!$&&!S.current;return jsx(c,{ref:E,message:e,viewerRole:a$1,className:i("w-full",W&&"animate-message-in",r),children:jsxs("div",{className:i("flex flex-col gap-1 w-full"),"data-is-viewer":w,children:[Oe&&jsxs("div",{className:i("flex items-start gap-2 w-full"),children:[t&&!w&&jsx("div",{className:"flex-shrink-0",children:jsx(Ne,{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"})})]}),Re&&q&&jsx("div",{className:"w-full max-w-[80%]",children:jsx(Kt,{isStreaming:$,chunks:me,plan:l,executionTimeline:c$1,userMessageTimestamp:e.createdAt?new Date((typeof e.createdAt=="string",e.createdAt)).getTime()/1e3:void 0,executionTime:_,expanded:x,onExpandedChange:N})}),e.textContent&&jsxs("div",{className:i("group flex items-start gap-2 w-full",w?"flex-row-reverse":"flex-row"),children:[t&&!w&&jsx("div",{className:"flex-shrink-0",children:jsx(Ne,{name:e.participant?.name,src:e.participant?.avatarUrl,role:e.participant?.role,className:"w-10 h-10 flex-shrink-0"})}),jsxs("div",{className:i("max-w-[85%]","flex flex-col"),"data-message-role":w?"viewer":"other",children:[jsxs("div",{className:i("rounded-2xl",w||t?"px-4 py-3":""),style:{backgroundColor:w?"var(--chat-user-message-bg)":"transparent",color:w?"var(--chat-user-message-text, #ffffff)":"var(--chat-text)"},children:[jsx(d,{children:I()}),A(),y&&y.length>0&&jsx("div",{className:"mt-2 pt-2 border-t border-[var(--chat-border)]",children:jsx(Ft,{sources:y})})]}),Ae&&jsx("div",{className:"mt-2",children:jsx(Wt,{attachments:Me})}),!$&&(n&&e.createdAt||q&&e.textContent)&&jsxs("div",{className:i("flex items-center gap-2 mt-1",w&&"flex-row-reverse"),children:[n&&e.createdAt&&jsx(ti,{createdAt:typeof e.createdAt=="string"?e.createdAt:e.createdAt.toISOString(),isViewer:w}),q&&e.textContent&&jsx($t,{textContent:e.textContent})]})]})]}),e.error&&jsxs("div",{className:i("flex items-start gap-2 w-full max-w-[85%]","rounded-lg border px-3 py-2 mt-1"),style:{borderColor:"var(--chat-error, #B1001B)",backgroundColor:"color-mix(in srgb, var(--chat-error, #B1001B) 6%, transparent)",color:"var(--chat-error, #B1001B)"},children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"flex-shrink-0 mt-0.5",children:[jsx("path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z"}),jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}),jsx("span",{className:"text-sm",children:e.error.message})]}),!e.textContent&&t&&!w&&Re&&!Oe&&jsx("div",{className:"flex items-start gap-2 w-full",children:jsx("div",{className:"flex-shrink-0",children:jsx(Ne,{name:e.participant?.name,src:e.participant?.avatarUrl,role:e.participant?.role,className:"w-10 h-10 flex-shrink-0"})})}),M&&!$&&K&&jsx("div",{className:"w-full max-w-[80%]",children:jsx(Bt,{clarification:M,onSubmit:K})}),d$1&&d$1.length>0&&!$&&jsx("div",{className:"w-full max-w-[80%]",children:jsx(ft,{actions:d$1,onSelect:f})})]})})});qa.displayName="Message";function ti({createdAt:e}){return jsx("span",{className:"text-xs text-[var(--chat-text-subtle)]",children:(r=>{try{return new Date(r).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}catch{return ""}})(e)})}var pi=100*1024*1024,mi=["image/jpeg","image/jpg","image/png","image/gif","image/webp","image/svg+xml","image/bmp"],ui=["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"],gi=["video/mp4","video/webm","video/ogg","video/avi","video/mov","video/wmv","video/flv","video/mkv"],fi=[...mi,...ui,...gi];function Xa(e){if(e===0)return "0 Bytes";let a=1024,r=["Bytes","KB","MB","GB"],t=Math.floor(Math.log(e)/Math.log(a));return parseFloat((e/Math.pow(a,t)).toFixed(2))+" "+r[t]}function bi(e,a,r){return e.size>r?`File size (${Xa(e.size)}) exceeds max (${Xa(r)})`:a.includes(e.type)?null:`File type ${e.type||"unknown"} is not allowed`}function xi({attachments:e,onRemove:a,disabled:r}){return e.length===0?null:jsx("div",{className:"flex flex-wrap gap-2 px-3 pt-3 pb-0",children:e.map(t=>{let n=t.file.type.startsWith("image/"),o=t.status==="error",s=t.status==="uploading";return jsxs("div",{className:i("relative flex items-center gap-1.5 px-2 py-1.5 rounded-lg text-xs max-w-[200px]",o?"bg-red-50 dark:bg-red-900/30 text-red-600 dark:text-red-400":"bg-gray-100 dark:bg-zinc-700 text-gray-600 dark:text-zinc-300"),children:[s?jsx(Loader2,{size:14,className:"flex-shrink-0 animate-spin"}):o?jsx(AlertCircle,{size:14,className:"flex-shrink-0"}):n&&t.previewUrl?jsx("img",{src:t.previewUrl,alt:t.file.name,className:"w-5 h-5 rounded object-cover"}):n?jsx(Image,{size:14,className:"flex-shrink-0"}):jsx(FileText,{size:14,className:"flex-shrink-0"}),jsx("span",{className:"truncate",title:o?t.error:t.file.name,children:o?t.error:t.file.name}),!r&&jsx("button",{type:"button",onClick:()=>a(t.id),className:"flex-shrink-0 ml-0.5 p-0.5 rounded-full hover:bg-gray-200 dark:hover:bg-zinc-600 transition-colors",children:jsx(X,{size:12})})]},t.id)})})}var Ya=forwardRef(({onSubmit:e,onAttach:a,onUploadFile:r,onRemoveUploadedAttachment:t,disabled:n=false,supportsAttachments:o=true,allowedFileTypes:s=fi,maxFileSize:l=pi,placeholder:c="Type a message...",className:d,isSubmitting:f=false,centered:x=false},N)=>{let[y,g]=useState(""),[C,z]=useState([]),[_,M]=useState(false),K=useRef(null),E=useRef(null),u=useRef(0),v=useRef(false),m=n||f,F=C.some(b=>b.status==="uploading"),w=C.filter(b=>b.status==="uploaded"&&b.attachmentId).map(b=>b.attachmentId),q=w.length>0||C.some(b=>b.status==="pending"),$=y.trim().length>0||q,me=useCallback(()=>{let b=E.current;b&&(b.style.height="auto",b.style.height=Math.min(b.scrollHeight,200)+"px");},[]);useEffect(()=>{me();},[y,me]);let ie=useCallback(async b=>{let I=b.map(A=>{let S=bi(A,s,l),W={id:`${Date.now()}-${Math.random().toString(36).slice(2,9)}`,file:A,status:S?"error":r?"uploading":"pending",error:S||void 0};return !S&&A.type.startsWith("image/")&&(W.previewUrl=URL.createObjectURL(A)),W});if(z(A=>[...A,...I]),a?.(b),r){for(let A of I)if(A.status==="uploading")try{let S=await r(A.file);z(W=>W.map(h=>h.id===A.id?{...h,status:"uploaded",attachmentId:S}:h));}catch(S){z(W=>W.map(h=>h.id===A.id?{...h,status:"error",error:S instanceof Error?S.message:"Upload failed"}:h));}}},[s,l,r,a]),we=useCallback(async()=>{if(!$||m||F||v.current)return;v.current=true;let b=y,I=C.filter(S=>S.status!=="error").map(S=>S.file),A=C;g(""),z([]);try{r&&w.length>0?await e(b,void 0,w):await e(b,I.length>0?I:void 0);}catch{g(b),z(A);}finally{v.current=false;}},[y,C,$,m,F,e,r,w]),Re=useCallback(b=>{b.key==="Enter"&&!b.shiftKey&&(b.preventDefault(),!m&&!F&&we());},[we,m,F]),Oe=useCallback(b=>{let I=b.target.files;!I||I.length===0||(ie(Array.from(I)),b.target.value="");},[ie]),Me=useCallback(b=>{z(I=>{let A=I.find(S=>S.id===b);return A?.previewUrl&&URL.revokeObjectURL(A.previewUrl),A?.attachmentId&&t&&t(A.attachmentId),I.filter(S=>S.id!==b)});},[t]),Ae=useCallback(b=>{b.preventDefault(),b.stopPropagation(),!(!o||f)&&(u.current++,b.dataTransfer.types.includes("Files")&&M(true));},[o,f]),Le=useCallback(b=>{b.preventDefault(),b.stopPropagation(),u.current--,u.current===0&&M(false);},[]),k=useCallback(b=>{b.preventDefault(),b.stopPropagation();},[]),D=useCallback(b=>{if(b.preventDefault(),b.stopPropagation(),u.current=0,M(false),!o||f)return;let I=Array.from(b.dataTransfer.files);I.length>0&&ie(I);},[o,f,ie]);return useEffect(()=>()=>{C.forEach(b=>{b.previewUrl&&URL.revokeObjectURL(b.previewUrl);});},[]),jsx("div",{ref:N,className:i("flex-shrink-0",x?"p-0 bg-transparent":"px-3 pt-2 pb-3 border-t border-gray-200 dark:border-zinc-700 bg-white/95 dark:bg-zinc-900/95 backdrop-blur-sm",d),style:x?{padding:0,background:"transparent",border:"none"}:void 0,onDragEnter:Ae,onDragLeave:Le,onDragOver:k,onDrop:D,children:jsxs("div",{className:i("mx-auto max-w-[900px]","bg-white dark:bg-zinc-800","transition-all duration-200",x?"":"rounded-xl border border-gray-200 dark:border-zinc-700 shadow-sm focus-within:shadow-md focus-within:border-gray-300 dark:focus-within:border-zinc-600",_&&"ring-2 ring-blue-400 border-blue-400"),style:x?{borderRadius:"1rem",overflow:"hidden",backgroundColor:"var(--chat-composer-bg, #ffffff)",border:"1px solid var(--chat-composer-border, rgba(0,0,0,0.06))",boxShadow:"var(--chat-composer-shadow, 0 8px 30px rgba(0,0,0,0.08))"}:void 0,children:[_&&jsx("div",{className:"px-3 pt-3 pb-0",children:jsx("div",{className:"flex items-center justify-center py-4 rounded-lg border-2 border-dashed border-blue-300 bg-blue-50 dark:bg-blue-900/20 text-blue-500 text-sm",children:"Drop files here"})}),jsx(xi,{attachments:C,onRemove:Me,disabled:f}),jsxs("div",{className:i("flex items-center gap-2",x?"p-4":"p-3",C.length>0&&"pt-1.5"),style:x?{padding:"1rem"}:void 0,children:[o&&jsx("button",{type:"button",onClick:()=>K.current?.click(),disabled:f,className:i("flex-shrink-0","w-8 h-8 rounded-lg","flex items-center justify-center","border border-gray-200 dark:border-zinc-600","text-gray-500 dark:text-zinc-400","hover:bg-gray-50 dark:hover:bg-zinc-700","disabled:opacity-40 disabled:cursor-not-allowed","transition-colors"),children:jsx(Paperclip,{size:16})}),jsx("div",{className:"flex-1 min-w-0 flex items-center",children:jsx("textarea",{ref:E,value:y,onChange:b=>g(b.target.value),onKeyDown:Re,disabled:m,placeholder:c,rows:1,className:i("w-full resize-none outline-none","p-0 border-0 shadow-none","min-h-[24px] max-h-[200px]","text-sm leading-relaxed","text-gray-900 dark:text-zinc-100","placeholder:text-gray-400 dark:placeholder:text-zinc-500","bg-transparent","disabled:opacity-50 disabled:cursor-not-allowed")})}),jsx("button",{type:"button",onClick:we,disabled:!$||m||F,className:i("flex-shrink-0","w-9 h-9 rounded-lg","flex items-center justify-center","bg-blue-500 text-white","shadow-sm","hover:bg-blue-600 hover:shadow-md hover:-translate-y-px","active:translate-y-0 active:shadow-sm","disabled:bg-gray-300 dark:disabled:bg-zinc-600 disabled:shadow-none disabled:translate-y-0 disabled:cursor-not-allowed","transition-all duration-200"),children:f||F?jsx(Loader2,{size:16,className:"animate-spin"}):jsx(ArrowUp,{size:16})})]}),o&&jsx("input",{ref:K,type:"file",multiple:true,accept:s.join(","),onChange:Oe,className:"hidden"})]})})});Ya.displayName="MessageComposer";function ia({isAtBottom:e,onScrollToBottom:a,className:r}){return jsx("button",{type:"button",onClick:a,"aria-label":"Scroll to bottom",className:i("absolute bottom-4 left-1/2 -translate-x-1/2 z-10","flex items-center justify-center","w-8 h-8 rounded-full","bg-[var(--chat-bg,#ffffff)] border border-[var(--chat-border)]","shadow-subtle hover:shadow-button-hover","text-[var(--chat-text-subtle)] hover:text-[var(--chat-text)]","transition-all duration-200",e?"opacity-0 pointer-events-none translate-y-2":"opacity-100 translate-y-0",r),children:jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M12 5v14"}),jsx("path",{d:"m19 12-7 7-7-7"})]})})}var Qa=forwardRef(({children:e,autoScroll:a=true,showScrollToBottom:r=true,className:t},n)=>{let{containerRef:o,scrollToBottom:s,isAtBottom:l}=a$1({enabled:a});return jsxs("div",{className:"relative flex-1 overflow-hidden",children:[jsx("div",{ref:d=>{o.current=d,typeof n=="function"?n(d):n&&(n.current=d);},className:i("h-full overflow-y-auto","flex flex-col gap-4 p-4","chat-scrollbar",t),children:e}),r&&jsx(ia,{isAtBottom:l,onScrollToBottom:()=>s("smooth")})]})});Qa.displayName="MessageList";function wi({label:e,className:a}){return jsxs("div",{className:`flex items-center gap-3 py-6 select-none ${a??""}`,role:"separator",children:[jsx("div",{className:"flex-1 h-px bg-[var(--chat-border)]"}),jsx("span",{className:"text-xs font-medium text-[var(--chat-text-subtle)] whitespace-nowrap",children:e}),jsx("div",{className:"flex-1 h-px bg-[var(--chat-border)]"})]})}var tr=forwardRef(({className:e},a)=>jsx(r,{ref:a,className:i("inline-flex items-center gap-1","px-4 py-3",e),children:jsx(qe,{size:"small"})}));tr.displayName="TypingIndicator";function Ti({title:e,subtitle:a,logo:r,actions:t,showClose:n,onClose:o,loading:s,className:l,style:c}){let[d,f]=useState(false),x=useRef(null),N=useRef(null);return useEffect(()=>{let y=g=>{let C=g.composedPath();x.current&&!C.includes(x.current)&&N.current&&!C.includes(N.current)&&f(false);};if(d)return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[d]),jsxs("header",{className:i("flex items-center justify-between gap-3","px-4 py-3","border-b border-[var(--chat-border)]","bg-[var(--chat-header-bg,#ffffff)]",l),style:c,children:[jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[r&&jsx("div",{className:"flex-shrink-0",children:typeof r=="string"?jsx("img",{src:r,alt:"",className:"w-10 h-10 rounded-lg object-contain"}):r}),jsxs("div",{className:"flex flex-col min-w-0",children:[s?jsx("div",{className:"h-5 w-24 bg-gray-200 rounded animate-pulse"}):jsx("h1",{className:"text-lg font-semibold text-[var(--chat-text)] truncate",children:e}),a&&jsx("p",{className:"text-sm text-[var(--chat-text-subtle)] truncate",children:a})]})]}),jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[t&&t.length>0&&jsxs("div",{className:"relative",children:[jsx("button",{ref:N,onClick:()=>f(!d),className:i("p-2 rounded-lg","text-[var(--chat-text-subtle)]","hover:bg-[var(--chat-panel-bg)] hover:text-[var(--chat-text)]","transition-colors duration-200"),"aria-label":"Menu","aria-expanded":d,children:jsx(MoreVertical,{size:18})}),d&&jsx("div",{ref:x,className:i("absolute right-0 top-full mt-1 z-50","min-w-[180px]","bg-white rounded-lg shadow-lg","border border-[var(--chat-border)]","py-1","animate-fade-in"),children:t.map(y=>jsxs("button",{onClick:()=>{y.onClick(),f(false);},disabled:y.disabled,className:i("w-full flex items-center gap-2 px-3 py-2","text-sm text-left","text-[var(--chat-text)]","hover:bg-[var(--chat-panel-bg)]","disabled:opacity-50 disabled:cursor-not-allowed","transition-colors duration-150"),children:[y.icon&&jsx("span",{className:"flex-shrink-0 text-[var(--chat-text-subtle)]",children:y.icon}),y.label]},y.id))})]}),n&&o&&jsx("button",{onClick:o,className:i("p-2 rounded-lg","text-[var(--chat-text-subtle)]","hover:bg-[var(--chat-panel-bg)] hover:text-[var(--chat-text)]","transition-colors duration-200"),"aria-label":"Close",children:jsx(X,{size:18})})]})]})}function Di({toolName:e,status:a,description:r,className:t}){return jsxs("div",{className:i("relative flex items-center gap-2 py-1 px-2 rounded-md text-sm overflow-hidden",a==="running"&&"animate-shimmer",t),children:[jsx(Ei,{status:a}),jsx("span",{className:"font-medium text-[var(--chat-text)]",children:e}),r&&jsx("span",{className:"text-[var(--chat-text-subtle)] truncate",children:r})]})}function Ei({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 nr=forwardRef(({isEmpty:e,header:a,welcomeScreen:r,messageList:t,composer:n,footer:o,className:s},l)=>jsx("div",{ref:l,"data-chat-ui":true,className:i("relative h-full overflow-hidden flex flex-col min-h-0",s),children:jsx(AnimatePresence,{mode:"wait",children:e&&r?jsxs(motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.3},className:"flex-1 flex flex-col overflow-hidden min-h-0",children:[a,r]},"welcome"):jsxs(motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.4},className:"flex-1 flex flex-col overflow-hidden min-h-0",children:[a,jsx(motion.div,{initial:{opacity:0,y:-20},animate:{opacity:1,y:0},transition:{duration:.4,delay:.1},className:"flex-1 overflow-hidden flex flex-col min-h-0",children:t}),o,jsx(motion.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.4,delay:.2},children:n})]},"active")})}));nr.displayName="ChatLayout";function Vi(e,a=3e3){let[r,t]=useState(0),n=useRef(null);return useEffect(()=>{if(e.length<=1)return;let o=()=>{n.current=setInterval(()=>{t(l=>(l+1)%e.length);},a);},s=()=>{document.visibilityState!=="visible"?n.current&&(clearInterval(n.current),n.current=null):o();};return o(),document.addEventListener("visibilitychange",s),()=>{n.current&&clearInterval(n.current),document.removeEventListener("visibilitychange",s);}},[e,a]),e[r]??""}function Fi({placeholder:e,onSubmit:a,disabled:r,supportsAttachments:t}){let[n,o]=useState(""),[s,l]=useState([]),c=useRef(null),d=useRef(null);useEffect(()=>{c.current&&(c.current.style.height="auto",c.current.style.height=c.current.scrollHeight+"px");},[n]);let f=g=>{g.key==="Enter"&&!g.shiftKey&&(g.preventDefault(),x());},x=()=>{!n.trim()&&s.length===0||r||(a(n.trim(),s.length>0?s:void 0),o(""),l([]));},N=g=>{g.target.files&&l(C=>[...C,...Array.from(g.target.files)]),g.target.value="";},y=g=>{l(C=>C.filter((z,_)=>_!==g));};return jsxs("form",{className:i("w-full relative mx-auto","rounded-2xl overflow-hidden","transition duration-200"),style:{borderRadius:"1rem",overflow:"hidden",backgroundColor:"var(--chat-composer-bg, #ffffff)",border:"1px solid var(--chat-composer-border, rgba(0,0,0,0.06))",boxShadow:"var(--chat-composer-shadow, 0 8px 30px rgba(0,0,0,0.08))"},onSubmit:g=>{g.preventDefault(),x();},children:[s.length>0&&jsx("div",{className:"flex flex-wrap gap-2 px-4 pt-3",children:s.map((g,C)=>jsxs("div",{className:i("flex items-center gap-1.5 px-2.5 py-1 rounded-lg text-xs","bg-gray-100 dark:bg-zinc-700 text-gray-600 dark:text-zinc-300"),children:[jsx("span",{className:"max-w-[120px] truncate",children:g.name}),jsx("button",{type:"button",onClick:()=>y(C),className:"flex-shrink-0 text-gray-400 hover:text-gray-600 dark:hover:text-zinc-200",children:jsx(X,{size:12})})]},`${g.name}-${C}`))}),jsxs("div",{className:"flex items-center gap-2",style:{padding:"0.25rem 0"},children:[t&&jsx("button",{type:"button",onClick:()=>d.current?.click(),disabled:r,className:i("ml-3 flex-shrink-0","w-8 h-8 rounded-lg","flex items-center justify-center","text-gray-400 dark:text-zinc-500","hover:bg-gray-100 dark:hover:bg-zinc-700","hover:text-gray-600 dark:hover:text-zinc-300","disabled:opacity-40 disabled:cursor-not-allowed","transition-colors"),style:{marginLeft:"0.75rem"},children:jsx(Paperclip,{size:16})}),jsx("textarea",{ref:c,value:n,onChange:g=>o(g.target.value),onKeyDown:f,disabled:r,rows:1,placeholder:e,className:i("flex-1 text-sm sm:text-base","border-none bg-transparent","text-gray-900 dark:text-white","focus:outline-none focus:ring-0 resize-none","py-4 sm:py-5",t?"pl-1":"pl-4 sm:pl-6","placeholder:text-gray-400 dark:placeholder:text-zinc-500","disabled:opacity-50 disabled:cursor-not-allowed","max-h-[200px] overflow-y-auto"),style:{padding:"1rem 0.25rem",border:"none",background:"transparent",outline:"none",resize:"none"}}),jsx("button",{type:"submit",disabled:!n.trim()&&s.length===0||!!r,className:i("mr-3 flex-shrink-0","w-9 h-9 rounded-lg","flex items-center justify-center","bg-gray-900 dark:bg-zinc-600 text-white dark:text-zinc-100","shadow-sm","hover:bg-gray-700 dark:hover:bg-zinc-500","hover:shadow-md hover:-translate-y-px","active:translate-y-0 active:shadow-sm","disabled:bg-gray-300 dark:disabled:bg-zinc-700","disabled:text-gray-500 dark:disabled:text-zinc-400","disabled:shadow-none disabled:translate-y-0 disabled:cursor-not-allowed","transition-all duration-200"),style:{marginRight:"0.75rem",width:"2.25rem",height:"2.25rem",borderRadius:"0.5rem"},children:jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M12 19V5M5 12l7-7 7 7"})})})]}),t&&jsx("input",{ref:d,type:"file",multiple:true,onChange:N,className:"hidden"})]})}function Bi({text:e,onClick:a,index:r}){let t=useRef(null),n=useRef(typeof window<"u"?window.matchMedia("(prefers-reduced-motion: reduce)").matches:false),[o,s]=useState(null),l=useCallback(d=>{if(n.current)return;let f=d.currentTarget.getBoundingClientRect();s({x:d.clientX-f.left,y:d.clientY-f.top});},[]),c=useCallback(()=>{s(null);},[]);return jsx(motion.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.2+r*.1,duration:.4},children:jsxs("button",{ref:t,type:"button",onClick:a,onMouseMove:l,onMouseLeave:c,className:i("relative overflow-hidden","w-full text-left","p-3","cursor-pointer","border border-gray-200 dark:border-zinc-700","rounded-lg","transition-all duration-200 ease-out","bg-white dark:bg-zinc-800","hover:border-gray-300 dark:hover:border-zinc-600","hover:bg-gray-50 dark:hover:bg-zinc-750","hover:shadow-sm","active:bg-gray-100 dark:active:bg-zinc-700"),children:[o&&jsx("div",{className:"pointer-events-none absolute inset-0 z-0",style:{background:`radial-gradient(120px circle at ${o.x}px ${o.y}px, var(--chat-halo-primary, rgba(16,105,151,0.06)), transparent)`}}),jsxs("div",{className:"relative z-10 flex items-start gap-2.5",children:[jsx(MessageCircleQuestion,{size:16,strokeWidth:2,className:"mt-0.5 text-gray-400 dark:text-zinc-500 flex-shrink-0"}),jsx("span",{className:"text-sm text-gray-600 dark:text-zinc-300 leading-relaxed flex-1",children:e})]})]})})}var sr=forwardRef(({placeholders:e=[],suggestions:a=[],onSubmit:r,onSuggestionClick:t,welcomeText:n="How can I help you today?",supportsAttachments:o,composerSlot:s,className:l,assistantAvatar:c,assistantName:d},f)=>{let x=Vi(e),N=useCallback(y=>{t?.(y);},[t]);return jsxs("div",{ref:f,className:i("relative overflow-hidden","flex-1 flex items-center justify-center","px-4 sm:px-6",l),children:[jsx("div",{className:"pointer-events-none absolute inset-0 animate-welcome-halo",style:{background:"radial-gradient(ellipse 60% 50% at 50% 45%, var(--chat-halo-primary, rgba(16,105,151,0.06)), var(--chat-halo-secondary, rgba(86,193,138,0.03)) 60%, transparent 100%)"}}),jsxs(motion.div,{layout:true,initial:{scale:.95,y:20,opacity:0},animate:{scale:1,y:0,opacity:1},transition:{type:"spring",stiffness:200,damping:25},className:"relative w-full max-w-[800px] flex flex-col items-center gap-8",children:[n&&c?jsxs(motion.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},transition:{delay:.1,duration:.4},className:"flex items-start gap-2 w-full",children:[jsx("div",{className:"flex-shrink-0",children:jsx(Ne,{name:d,src:c,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"},className:"text-base text-gray-800 dark:text-white",children:n})})]}):n?jsx(motion.h2,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},transition:{delay:.1,duration:.4},style:{fontSize:"1.5rem",lineHeight:"2rem",fontWeight:600},className:"text-2xl font-semibold text-gray-800 dark:text-white text-center",children:n}):null,jsx("div",{className:i("w-full rounded-2xl","transition-shadow duration-500","shadow-[0_0_15px_rgba(16,105,151,0.08)]","focus-within:shadow-[0_0_20px_rgba(16,105,151,0.15),0_0_40px_rgba(86,193,138,0.08)]","dark:shadow-[0_0_15px_rgba(255,255,255,0.04)]","dark:focus-within:shadow-[0_0_20px_rgba(255,255,255,0.08),0_0_40px_rgba(255,255,255,0.03)]"),children:s??jsx(Fi,{placeholder:x,onSubmit:(y,g)=>r?.(y,g),supportsAttachments:o})}),a.length>0&&jsx("div",{className:i("grid gap-3 w-full max-w-[900px]","grid-cols-1 sm:grid-cols-[repeat(auto-fit,minmax(250px,1fr))]"),children:a.map((y,g)=>jsx(Bi,{text:y,onClick:()=>N(y),index:g},g))})]})]})});sr.displayName="WelcomeScreen";
19
+ export{Di as $,Kt as A,Ze as B,ft as C,yt as D,vt as E,wt as F,Nt as G,Ct as H,St as I,Te as J,Pt as K,Oa as L,Yt as M,Jt as N,Qt as O,ea as P,ta as Q,aa as R,Tt as S,Ka as T,qa as U,Ya as V,ia as W,Qa as X,wi as Y,tr as Z,Ti as _,i as a,nr as aa,va as b,sr as ba,Ne as c,ka as d,qe as e,ne as f,Ft as g,Sa as h,Hr as i,Bt as j,$t as k,Wt as l,nt as m,Fe as n,un as o,Ht as p,ot as q,hn as r,Se as s,it as t,lt as u,ct as v,dt as w,pt as x,mt as y,ut as z};//# sourceMappingURL=chunk-RZNLGXIW.js.map
20
+ //# sourceMappingURL=chunk-RZNLGXIW.js.map