@object-ui/plugin-chatbot 5.4.1 → 5.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`react`),require(`@object-ui/components`),require(`lucide-react`),require(`react/jsx-runtime`),require(`@ai-sdk/react`),require(`ai`),require(`react-dom`),require(`@object-ui/react`),require(`use-stick-to-bottom`),require(`class-variance-authority`),require(`@radix-ui/react-slot`),require(`streamdown`),require(`nanoid`),require(`shiki`),require(`@radix-ui/react-use-controllable-state`),require(`motion/react`),require(`@object-ui/core`)):typeof define==`function`&&define.amd?define([`exports`,`react`,`@object-ui/components`,`lucide-react`,`react/jsx-runtime`,`@ai-sdk/react`,`ai`,`react-dom`,`@object-ui/react`,`use-stick-to-bottom`,`class-variance-authority`,`@radix-ui/react-slot`,`streamdown`,`nanoid`,`shiki`,`@radix-ui/react-use-controllable-state`,`motion/react`,`@object-ui/core`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.ObjectUIPluginChatbot={},e.React,e.ObjectUIComponents,e.LucideReact,e.react_jsx_runtime,e._ai_sdk_react,e.ai,e.ReactDOM,e.ObjectUIReact,e.use_stick_to_bottom,e.class_variance_authority,e._radix_ui_react_slot,e.streamdown,e.nanoid,e.shiki,e._radix_ui_react_use_controllable_state,e.motion_react,e.ObjectUICore))})(this,function(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var v=Object.create,y=Object.defineProperty,b=Object.getOwnPropertyDescriptor,x=Object.getOwnPropertyNames,S=Object.getPrototypeOf,C=Object.prototype.hasOwnProperty,w=(e,t)=>{let n={};for(var r in e)y(n,r,{get:e[r],enumerable:!0});return t||y(n,Symbol.toStringTag,{value:`Module`}),n},T=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=x(t),a=0,o=i.length,s;a<o;a++)s=i[a],!C.call(e,s)&&s!==n&&y(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=b(t,s))||r.enumerable});return e},E=(e,t,n)=>(n=e==null?{}:v(S(e)),T(t||!e||!e.__esModule?y(n,`default`,{value:e,enumerable:!0}):n,e));t=E(t,1),s=E(s,1);function D(e=`msg`){return typeof crypto<`u`&&crypto.randomUUID?crypto.randomUUID():`${e}-${Date.now()}-${Math.random().toString(36).slice(2)}`}function O(e){return(e??[]).map((e,t)=>({id:e.id||`msg-${t}`,role:e.role||`user`,content:e.content||``,timestamp:typeof e.timestamp==`string`?e.timestamp:e.timestamp instanceof Date?e.timestamp.toISOString():void 0,metadata:e.metadata,streaming:e.streaming,toolInvocations:e.toolInvocations}))}function k(e={}){let{api:n,initialMessages:r,conversationId:i,systemPrompt:s,model:c,streamingEnabled:l=!0,headers:u,body:d,maxToolRoundtrips:f=5,onError:p,showTimestamp:m,autoResponse:h,autoResponseText:g,autoResponseDelay:_=1e3,onSend:v}=e,y=(0,t.useRef)(n?`api`:`local`).current===`api`,b=(0,t.useMemo)(()=>O(r).map(e=>({id:e.id,role:e.role,parts:[{type:`text`,text:e.content??``}]})),[]),x=(0,a.useChat)({transport:(0,t.useMemo)(()=>{if(y)return new o.DefaultChatTransport({api:n,headers:{...u},body:{...d,...i?{conversationId:i}:{},...c?{model:c}:{},...s?{systemPrompt:s}:{},...l===void 0?{}:{stream:l}}})},[y,n,u,d,c,s,l,i]),messages:y&&b.length>0?b:void 0,onError:y?e=>{p?.(e)}:void 0}),[S,C]=(0,t.useState)(()=>O(r)),[w,T]=(0,t.useState)(!1),[E,k]=(0,t.useState)(``),[A,j]=(0,t.useState)(``),M=(0,t.useRef)(null);if((0,t.useEffect)(()=>()=>{M.current&&=(clearTimeout(M.current),null)},[]),y){let{messages:e,status:n,error:r,sendMessage:i,regenerate:a,stop:o,setMessages:s}=x,c=n===`submitted`||n===`streaming`,l=e.map(t=>{let n=Array.isArray(t.parts)?t.parts:[],r=typeof t.content==`string`?t.content:n.filter(e=>e?.type===`text`).map(e=>e.text??``).join(``),i=n.filter(e=>e?.type===`reasoning`).map(e=>e.text??``).join(`
2
- `).trim()||void 0,a=n.filter(e=>typeof e?.type==`string`&&e.type.startsWith(`tool-`)).map(e=>({toolCallId:e.toolCallId??e.id??`${e.type}-${Math.random().toString(36).slice(2,8)}`,toolName:typeof e.type==`string`?e.type.replace(/^tool-/,``):`tool`,args:e.input??e.args,result:e.output??e.result,errorText:e.errorText,state:e.state})),o=n.filter(e=>e?.type===`source-url`||e?.type===`source`).map(e=>({id:e.id,title:e.title,url:e.url??e.href})).filter(e=>!!e.url),s=Array.isArray(t.toolInvocations)?t.toolInvocations:[];return{id:t.id,role:t.role,content:r,toolInvocations:a.length>0?a:s,reasoning:i,sources:o.length>0?o:void 0,metadata:t.metadata,streaming:c&&t.id===e[e.length-1]?.id&&t.role===`assistant`}});return{messages:l,isLoading:c,error:r,sendMessage:(0,t.useCallback)(e=>{let t=e.trim();if(!t)return;let n=[...l,{id:D(`msg`),role:`user`,content:t}];i({text:t}),j(``),v?.(t,n)},[i,v,l]),stop:o,reload:a,clear:(0,t.useCallback)(()=>{s([])},[s]),isApiMode:!0,input:A,setInput:j,handleInputChange:(0,t.useCallback)(e=>{j(e.target.value)},[])}}let N=(0,t.useCallback)(()=>{M.current&&=(clearTimeout(M.current),null),T(!1)},[]);return{messages:S,isLoading:w,error:void 0,sendMessage:(0,t.useCallback)(e=>{if(!e.trim())return;let t={id:D(`msg`),role:`user`,content:e.trim(),timestamp:m?new Date().toLocaleTimeString():void 0};C(n=>{let r=[...n,t];return v?.(e.trim(),r),r}),k(``),h&&(T(!0),M.current=setTimeout(()=>{let e={id:D(`msg`),role:`assistant`,content:g||`Thank you for your message!`,timestamp:m?new Date().toLocaleTimeString():void 0};C(t=>[...t,e]),T(!1)},_))},[m,h,g,_,v]),stop:N,reload:(0,t.useCallback)(()=>{},[]),clear:(0,t.useCallback)(()=>{N(),C([])},[N]),isApiMode:!1,input:E,setInput:k,handleInputChange:(0,t.useCallback)(e=>{k(e.target.value)},[])}}function A(e){return e.filter(e=>typeof e?.name==`string`&&e.name.length>0).map(e=>({name:e.name,label:e.label||e.name,description:e.description,role:e.role,active:e.active!==!1}))}function j(e={}){let{apiBase:n,headers:r,enabled:i=!0,fallback:a=[]}=e,[o,s]=(0,t.useState)(a),[c,l]=(0,t.useState)(!1),[u,d]=(0,t.useState)(void 0),[f,p]=(0,t.useState)(0),m=(0,t.useRef)(r);return m.current=r,(0,t.useEffect)(()=>{if(!i||!n)return;let e=new AbortController,t=!1;l(!0),d(void 0);let r=`${n.replace(/\/$/,``)}/agents`;return fetch(r,{method:`GET`,headers:{Accept:`application/json`,...m.current??{}},credentials:`include`,signal:e.signal}).then(async e=>{if(!e.ok)throw Error(`Failed to load agents (${e.status})`);return e.json()}).then(e=>{if(t)return;let n=A(Array.isArray(e)?e:e?.agents??[]);s(n.length>0?n:a)}).catch(e=>{t||e.name===`AbortError`||(d(e),s(a))}).finally(()=>{t||l(!1)}),()=>{t=!0,e.abort()}},[n,i,f]),{agents:o,isLoading:c,error:u,refetch:(0,t.useCallback)(()=>p(e=>e+1),[])}}var M=t.createContext(null);function N({defaultOpen:e=!1,children:n}){let[r,a]=t.useState(e),[o,s]=t.useState(!1),c=t.useMemo(()=>({isOpen:r,isFullscreen:o,open:()=>a(!0),close:()=>{a(!1),s(!1)},toggle:()=>a(e=>!e),toggleFullscreen:()=>s(e=>!e)}),[r,o]);return(0,i.jsx)(M.Provider,{value:c,children:n})}function P(){let e=t.useContext(M);if(!e)throw Error(`useFloatingChatbot must be used within a <FloatingChatbotProvider>`);return e}function F(){try{let{t:e}=(0,c.useObjectTranslation)();return(t,n)=>{let r=e(`common.${t}`);return!r||r===`common.${t}`?n:r}}catch{return(e,t)=>t}}function ee({position:e=`bottom-right`,size:t=56,className:a}){let{isOpen:o,toggle:s}=P(),c=F();return(0,i.jsx)(n.Button,{onClick:s,className:(0,n.cn)(`fixed z-50 rounded-full shadow-lg transition-transform hover:scale-105`,e===`bottom-right`?`right-6 bottom-20 sm:bottom-6`:`left-6 bottom-20 sm:bottom-6`,a),style:{width:t,height:t},size:`icon`,"aria-label":o?c(`closeChat`,`Close chat`):c(`openChat`,`Open chat`),"data-testid":`floating-chatbot-trigger`,children:o?(0,i.jsx)(r.X,{className:`h-6 w-6`}):(0,i.jsx)(r.MessageCircle,{className:`h-6 w-6`})})}function te({title:e=`Chat`,position:t=`bottom-right`,width:a=400,height:o=520,children:s,className:c,headerExtra:l}){let{isOpen:u,isFullscreen:d,close:f,toggleFullscreen:p}=P();if(!u)return null;let m=d?{inset:0,width:`100vw`,height:`100vh`}:{width:a,height:o,maxHeight:`calc(100vh - 100px)`};return(0,i.jsxs)(`div`,{className:(0,n.cn)(`fixed z-50 flex flex-col rounded-lg border bg-background shadow-xl overflow-hidden transition-all`,d?`inset-0 rounded-none`:t===`bottom-right`?`right-6 bottom-20`:`left-6 bottom-20`,c),style:m,role:`dialog`,"aria-label":e,"data-testid":`floating-chatbot-panel`,children:[(0,i.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-4 py-2 border-b bg-muted/40`,children:[(0,i.jsx)(`span`,{className:`text-sm font-medium truncate shrink-0`,children:e}),l?(0,i.jsx)(`div`,{className:`flex-1 min-w-0 flex items-center justify-end mr-1`,"data-testid":`floating-chatbot-header-extra`,children:l}):null,(0,i.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,i.jsx)(n.Button,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:p,"aria-label":d?`Exit fullscreen`:`Fullscreen`,"data-testid":`floating-chatbot-fullscreen`,children:d?(0,i.jsx)(r.Minimize2,{className:`h-4 w-4`}):(0,i.jsx)(r.Maximize2,{className:`h-4 w-4`})}),(0,i.jsx)(n.Button,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:f,"aria-label":`Close chat`,"data-testid":`floating-chatbot-close`,children:(0,i.jsx)(r.X,{className:`h-4 w-4`})})]})]}),(0,i.jsx)(`div`,{className:`flex-1 overflow-hidden`,children:s})]})}var I=({className:e,...t})=>(0,i.jsx)(l.StickToBottom,{className:(0,n.cn)(`relative flex-1 overflow-y-hidden`,e),initial:`smooth`,resize:`smooth`,role:`log`,...t}),L=({className:e,...t})=>(0,i.jsx)(l.StickToBottom.Content,{className:(0,n.cn)(`flex flex-col gap-8 p-4`,e),...t}),ne=({className:e,title:t=`No messages yet`,description:r=`Start a conversation to see messages here`,icon:a,children:o,...s})=>(0,i.jsx)(`div`,{className:(0,n.cn)(`flex size-full flex-col items-center justify-center gap-3 p-8 text-center`,e),...s,children:o??(0,i.jsxs)(i.Fragment,{children:[a&&(0,i.jsx)(`div`,{className:`text-muted-foreground`,children:a}),(0,i.jsxs)(`div`,{className:`space-y-1`,children:[(0,i.jsx)(`h3`,{className:`font-medium text-sm`,children:t}),r&&(0,i.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:r})]})]})}),re=({className:e,...a})=>{let{isAtBottom:o,scrollToBottom:s}=(0,l.useStickToBottomContext)(),c=(0,t.useCallback)(()=>{s()},[s]);return!o&&(0,i.jsx)(n.Button,{className:(0,n.cn)(`absolute bottom-4 left-[50%] translate-x-[-50%] rounded-full`,e),onClick:c,size:`icon`,type:`button`,variant:`outline`,...a,children:(0,i.jsx)(r.ArrowDownIcon,{className:`size-4`})})},ie=(0,u.cva)(`flex w-fit items-stretch has-[>[data-slot=button-group]]:gap-2 [&>*]:focus-visible:relative [&>*]:focus-visible:z-10 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-md [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1`,{variants:{orientation:{horizontal:`[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none`,vertical:`flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none`}},defaultVariants:{orientation:`horizontal`}});function ae({className:e,orientation:t,...r}){return(0,i.jsx)(`div`,{role:`group`,"data-slot":`button-group`,"data-orientation":t,className:(0,n.cn)(ie({orientation:t}),e),...r})}function oe({className:e,asChild:t=!1,...r}){return(0,i.jsx)(t?d.Slot:`div`,{className:(0,n.cn)(`flex items-center gap-2 rounded-md border bg-muted px-4 text-sm font-medium shadow-xs [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4`,e),...r})}var se=({className:e,from:t,...r})=>(0,i.jsx)(`div`,{className:(0,n.cn)(`group flex w-full max-w-[95%] flex-col gap-2`,t===`user`?`is-user ml-auto justify-end`:`is-assistant`,e),...r}),ce=({children:e,className:t,...r})=>(0,i.jsx)(`div`,{className:(0,n.cn)(`is-user:dark flex w-fit max-w-full min-w-0 flex-col gap-2 overflow-hidden text-sm`,`group-[.is-user]:ml-auto group-[.is-user]:rounded-lg group-[.is-user]:bg-secondary group-[.is-user]:px-4 group-[.is-user]:py-3 group-[.is-user]:text-foreground`,`group-[.is-assistant]:text-foreground`,t),...r,children:e}),le=({className:e,children:t,...r})=>(0,i.jsx)(`div`,{className:(0,n.cn)(`flex items-center gap-1`,e),...r,children:t}),R=({tooltip:e,children:t,label:r,variant:a=`ghost`,size:o=`icon`,...s})=>{let c=(0,i.jsxs)(n.Button,{size:o,type:`button`,variant:a,...s,children:[t,(0,i.jsx)(`span`,{className:`sr-only`,children:r||e})]});return e?(0,i.jsx)(n.TooltipProvider,{children:(0,i.jsxs)(n.Tooltip,{children:[(0,i.jsx)(n.TooltipTrigger,{asChild:!0,children:c}),(0,i.jsx)(n.TooltipContent,{children:(0,i.jsx)(`p`,{children:e})})]})}):c},ue=(0,t.createContext)(null),z=()=>{let e=(0,t.useContext)(ue);if(!e)throw Error(`MessageBranch components must be used within MessageBranch`);return e},de=({defaultBranch:e=0,onBranchChange:r,className:a,...o})=>{let[s,c]=(0,t.useState)(e),[l,u]=(0,t.useState)([]),d=e=>{c(e),r?.(e)},f={currentBranch:s,totalBranches:l.length,goToPrevious:()=>{d(s>0?s-1:l.length-1)},goToNext:()=>{d(s<l.length-1?s+1:0)},branches:l,setBranches:u};return(0,i.jsx)(ue.Provider,{value:f,children:(0,i.jsx)(`div`,{className:(0,n.cn)(`grid w-full gap-2 [&>div]:pb-0`,a),...o})})},fe=({children:e,...r})=>{let{currentBranch:a,setBranches:o,branches:s}=z(),c=Array.isArray(e)?e:[e];return(0,t.useEffect)(()=>{s.length!==c.length&&o(c)},[c,s,o]),c.map((e,t)=>(0,i.jsx)(`div`,{className:(0,n.cn)(`grid gap-2 overflow-hidden [&>div]:pb-0`,t===a?`block`:`hidden`),...r,children:e},e.key))},pe=({className:e,from:t,...n})=>{let{totalBranches:r}=z();return r<=1?null:(0,i.jsx)(ae,{className:`[&>*:not(:first-child)]:rounded-l-md [&>*:not(:last-child)]:rounded-r-md`,orientation:`horizontal`,...n})},me=({children:e,...t})=>{let{goToPrevious:a,totalBranches:o}=z();return(0,i.jsx)(n.Button,{"aria-label":`Previous branch`,disabled:o<=1,onClick:a,size:`icon`,type:`button`,variant:`ghost`,...t,children:e??(0,i.jsx)(r.ChevronLeftIcon,{size:14})})},he=({children:e,className:t,...a})=>{let{goToNext:o,totalBranches:s}=z();return(0,i.jsx)(n.Button,{"aria-label":`Next branch`,disabled:s<=1,onClick:o,size:`icon`,type:`button`,variant:`ghost`,...a,children:e??(0,i.jsx)(r.ChevronRightIcon,{size:14})})},ge=({className:e,...t})=>{let{currentBranch:r,totalBranches:a}=z();return(0,i.jsxs)(oe,{className:(0,n.cn)(`border-none bg-transparent text-muted-foreground shadow-none`,e),...t,children:[r+1,` of `,a]})},B=(0,t.memo)(({className:e,...t})=>(0,i.jsx)(f.Streamdown,{className:(0,n.cn)(`size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0`,e),...t}),(e,t)=>e.children===t.children);B.displayName=`MessageResponse`;function _e({data:e,className:t,onRemove:a,...o}){let s=e.filename||``,c=(e.mediaType?.startsWith(`image/`)&&e.url?`image`:`file`)==`image`,l=s||(c?`Image`:`Attachment`);return(0,i.jsx)(`div`,{className:(0,n.cn)(`group relative size-24 overflow-hidden rounded-lg`,t),...o,children:c?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(`img`,{alt:s||`attachment`,className:`size-full object-cover`,height:100,src:e.url,width:100}),a&&(0,i.jsxs)(n.Button,{"aria-label":`Remove attachment`,className:`absolute top-2 right-2 size-6 rounded-full bg-background/80 p-0 opacity-0 backdrop-blur-sm transition-opacity hover:bg-background group-hover:opacity-100 [&>svg]:size-3`,onClick:e=>{e.stopPropagation(),a()},type:`button`,variant:`ghost`,children:[(0,i.jsx)(r.XIcon,{}),(0,i.jsx)(`span`,{className:`sr-only`,children:`Remove`})]})]}):(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(n.Tooltip,{children:[(0,i.jsx)(n.TooltipTrigger,{asChild:!0,children:(0,i.jsx)(`div`,{className:`flex size-full shrink-0 items-center justify-center rounded-lg bg-muted text-muted-foreground`,children:(0,i.jsx)(r.PaperclipIcon,{className:`size-4`})})}),(0,i.jsx)(n.TooltipContent,{children:(0,i.jsx)(`p`,{children:l})})]}),a&&(0,i.jsxs)(n.Button,{"aria-label":`Remove attachment`,className:`size-6 shrink-0 rounded-full p-0 opacity-0 transition-opacity hover:bg-accent group-hover:opacity-100 [&>svg]:size-3`,onClick:e=>{e.stopPropagation(),a()},type:`button`,variant:`ghost`,children:[(0,i.jsx)(r.XIcon,{}),(0,i.jsx)(`span`,{className:`sr-only`,children:`Remove`})]})]})})}function ve({children:e,className:t,...r}){return e?(0,i.jsx)(`div`,{className:(0,n.cn)(`ml-auto flex w-fit flex-wrap items-start gap-2`,t),...r,children:e}):null}var ye=({className:e,children:t,...r})=>(0,i.jsx)(`div`,{className:(0,n.cn)(`mt-4 flex w-full items-center justify-between gap-4`,e),...r,children:t});function be({className:e,...t}){return(0,i.jsx)(`div`,{"data-slot":`input-group`,role:`group`,className:(0,n.cn)(`group/input-group relative flex w-full items-center rounded-md border border-input shadow-xs transition-[color,box-shadow] outline-none dark:bg-input/30`,`h-9 min-w-0 has-[>textarea]:h-auto`,`has-[>[data-align=inline-start]]:[&>input]:pl-2`,`has-[>[data-align=inline-end]]:[&>input]:pr-2`,`has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>[data-align=block-start]]:[&>input]:pb-3`,`has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-end]]:[&>input]:pt-3`,`has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-[3px] has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50`,`has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-destructive/20 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40`,e),...t})}var xe=(0,u.cva)(`flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium text-muted-foreground select-none group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4`,{variants:{align:{"inline-start":`order-first pl-3 has-[>button]:ml-[-0.45rem] has-[>kbd]:ml-[-0.35rem]`,"inline-end":`order-last pr-3 has-[>button]:mr-[-0.45rem] has-[>kbd]:mr-[-0.35rem]`,"block-start":`order-first w-full justify-start px-3 pt-3 group-has-[>input]/input-group:pt-2.5 [.border-b]:pb-3`,"block-end":`order-last w-full justify-start px-3 pb-3 group-has-[>input]/input-group:pb-2.5 [.border-t]:pt-3`}},defaultVariants:{align:`inline-start`}});function V({className:e,align:t=`inline-start`,...r}){return(0,i.jsx)(`div`,{role:`group`,"data-slot":`input-group-addon`,"data-align":t,className:(0,n.cn)(xe({align:t}),e),onClick:e=>{e.target.closest(`button`)||e.currentTarget.parentElement?.querySelector(`input`)?.focus()},...r})}var Se=(0,u.cva)(`flex items-center gap-2 text-sm shadow-none`,{variants:{size:{xs:`h-6 gap-1 rounded-[calc(var(--radius)-5px)] px-2 has-[>svg]:px-2 [&>svg:not([class*='size-'])]:size-3.5`,sm:`h-8 gap-1.5 rounded-md px-2.5 has-[>svg]:px-2.5`,"icon-xs":`size-6 rounded-[calc(var(--radius)-5px)] p-0 has-[>svg]:p-0`,"icon-sm":`size-8 p-0 has-[>svg]:p-0`}},defaultVariants:{size:`xs`}});function H({className:e,type:t=`button`,variant:r=`ghost`,size:a=`xs`,...o}){return(0,i.jsx)(n.Button,{type:t,"data-size":a,variant:r,className:(0,n.cn)(Se({size:a}),e),...o})}function Ce({className:e,...t}){return(0,i.jsx)(n.Textarea,{"data-slot":`input-group-control`,className:(0,n.cn)(`flex-1 resize-none rounded-none border-0 bg-transparent py-3 shadow-none focus-visible:ring-0 dark:bg-transparent`,e),...t})}var U=(0,t.createContext)(null),W=(0,t.createContext)(null),we=()=>{let e=(0,t.useContext)(U);if(!e)throw Error(`Wrap your component inside <PromptInputProvider> to use usePromptInputController().`);return e},Te=()=>(0,t.useContext)(U),Ee=()=>{let e=(0,t.useContext)(W);if(!e)throw Error(`Wrap your component inside <PromptInputProvider> to use useProviderAttachments().`);return e},De=()=>(0,t.useContext)(W);function Oe({initialInput:e=``,children:n}){let[r,a]=(0,t.useState)(e),o=(0,t.useCallback)(()=>a(``),[]),[s,c]=(0,t.useState)([]),l=(0,t.useRef)(null),u=(0,t.useRef)(()=>{}),d=(0,t.useCallback)(e=>{let t=Array.from(e);t.length!==0&&c(e=>e.concat(t.map(e=>({id:(0,p.nanoid)(),type:`file`,url:URL.createObjectURL(e),mediaType:e.type,filename:e.name}))))},[]),f=(0,t.useCallback)(e=>{c(t=>{let n=t.find(t=>t.id===e);return n?.url&&URL.revokeObjectURL(n.url),t.filter(t=>t.id!==e)})},[]),m=(0,t.useCallback)(()=>{c(e=>{for(let t of e)t.url&&URL.revokeObjectURL(t.url);return[]})},[]),h=(0,t.useRef)(s);h.current=s,(0,t.useEffect)(()=>()=>{for(let e of h.current)e.url&&URL.revokeObjectURL(e.url)},[]);let g=(0,t.useCallback)(()=>{u.current?.()},[]),_=(0,t.useMemo)(()=>({files:s,add:d,remove:f,clear:m,openFileDialog:g,fileInputRef:l}),[s,d,f,m,g]),v=(0,t.useCallback)((e,t)=>{l.current=e.current,u.current=t},[]),y=(0,t.useMemo)(()=>({textInput:{value:r,setInput:a,clear:o},attachments:_,__registerFileInput:v}),[r,o,_,v]);return(0,i.jsx)(U.Provider,{value:y,children:(0,i.jsx)(W.Provider,{value:_,children:n})})}var ke=(0,t.createContext)(null),G=()=>{let e=De(),n=(0,t.useContext)(ke),r=e??n;if(!r)throw Error(`usePromptInputAttachments must be used within a PromptInput or PromptInputProvider`);return r};function Ae({data:e,className:t,...a}){let o=G(),s=e.filename||``,c=(e.mediaType?.startsWith(`image/`)&&e.url?`image`:`file`)==`image`,l=s||(c?`Image`:`Attachment`);return(0,i.jsxs)(Xe,{children:[(0,i.jsx)(n.HoverCardTrigger,{asChild:!0,children:(0,i.jsxs)(`div`,{className:(0,n.cn)(`group relative flex h-8 cursor-pointer select-none items-center gap-1.5 rounded-md border border-border px-1.5 font-medium text-sm transition-all hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50`,t),...a,children:[(0,i.jsxs)(`div`,{className:`relative size-5 shrink-0`,children:[(0,i.jsx)(`div`,{className:`absolute inset-0 flex size-5 items-center justify-center overflow-hidden rounded bg-background transition-opacity group-hover:opacity-0`,children:c?(0,i.jsx)(`img`,{alt:s||`attachment`,className:`size-5 object-cover`,height:20,src:e.url,width:20}):(0,i.jsx)(`div`,{className:`flex size-5 items-center justify-center text-muted-foreground`,children:(0,i.jsx)(r.PaperclipIcon,{className:`size-3`})})}),(0,i.jsxs)(n.Button,{"aria-label":`Remove attachment`,className:`absolute inset-0 size-5 cursor-pointer rounded p-0 opacity-0 transition-opacity group-hover:pointer-events-auto group-hover:opacity-100 [&>svg]:size-2.5`,onClick:t=>{t.stopPropagation(),o.remove(e.id)},type:`button`,variant:`ghost`,children:[(0,i.jsx)(r.XIcon,{}),(0,i.jsx)(`span`,{className:`sr-only`,children:`Remove`})]})]}),(0,i.jsx)(`span`,{className:`flex-1 truncate`,children:l})]},e.id)}),(0,i.jsx)(Qe,{className:`w-auto p-2`,children:(0,i.jsxs)(`div`,{className:`w-auto space-y-3`,children:[c&&(0,i.jsx)(`div`,{className:`flex max-h-96 w-96 items-center justify-center overflow-hidden rounded-md border`,children:(0,i.jsx)(`img`,{alt:s||`attachment preview`,className:`max-h-full max-w-full object-contain`,height:384,src:e.url,width:448})}),(0,i.jsx)(`div`,{className:`flex items-center gap-2.5`,children:(0,i.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1 px-0.5`,children:[(0,i.jsx)(`h4`,{className:`truncate font-semibold text-sm leading-none`,children:s||(c?`Image`:`Attachment`)}),e.mediaType&&(0,i.jsx)(`p`,{className:`truncate font-mono text-muted-foreground text-xs`,children:e.mediaType})]})})]})})]})}function je({children:e,className:r,...a}){let o=G();return o.files.length?(0,i.jsx)(`div`,{className:(0,n.cn)(`flex flex-wrap items-center gap-2 p-3 w-full`,r),...a,children:o.files.map(n=>(0,i.jsx)(t.Fragment,{children:e(n)},n.id))}):null}var Me=({label:e=`Add photos or files`,...t})=>{let a=G();return(0,i.jsxs)(n.DropdownMenuItem,{...t,onSelect:e=>{e.preventDefault(),a.openFileDialog()},children:[(0,i.jsx)(r.ImageIcon,{className:`mr-2 size-4`}),` `,e]})},Ne=({className:e,accept:r,multiple:a,globalDrop:o,syncHiddenInput:s,maxFiles:c,maxFileSize:l,onError:u,onSubmit:d,children:f,...m})=>{let h=Te(),g=!!h,_=(0,t.useRef)(null),v=(0,t.useRef)(null),[y,b]=(0,t.useState)([]),x=g?h.attachments.files:y,S=(0,t.useRef)(x);S.current=x;let C=(0,t.useCallback)(()=>{_.current?.click()},[]),w=(0,t.useCallback)(e=>!r||r.trim()===``?!0:r.split(`,`).map(e=>e.trim()).filter(Boolean).some(t=>{if(t.endsWith(`/*`)){let n=t.slice(0,-1);return e.type.startsWith(n)}return e.type===t}),[r]),T=(0,t.useCallback)(e=>{let t=Array.from(e),n=t.filter(e=>w(e));if(t.length&&n.length===0){u?.({code:`accept`,message:`No files match the accepted types.`});return}let r=n.filter(e=>l?e.size<=l:!0);if(n.length>0&&r.length===0){u?.({code:`max_file_size`,message:`All files exceed the maximum size.`});return}b(e=>{let t=typeof c==`number`?Math.max(0,c-e.length):void 0,n=typeof t==`number`?r.slice(0,t):r;typeof t==`number`&&r.length>t&&u?.({code:`max_files`,message:`Too many files. Some were not added.`});let i=[];for(let e of n)i.push({id:(0,p.nanoid)(),type:`file`,url:URL.createObjectURL(e),mediaType:e.type,filename:e.name});return e.concat(i)})},[w,c,l,u]),E=(0,t.useCallback)(e=>b(t=>{let n=t.find(t=>t.id===e);return n?.url&&URL.revokeObjectURL(n.url),t.filter(t=>t.id!==e)}),[]),D=(0,t.useCallback)(()=>b(e=>{for(let t of e)t.url&&URL.revokeObjectURL(t.url);return[]}),[]),O=g?h.attachments.add:T,k=g?h.attachments.remove:E,A=g?h.attachments.clear:D,j=g?h.attachments.openFileDialog:C;(0,t.useEffect)(()=>{g&&h.__registerFileInput(_,()=>_.current?.click())},[g,h]),(0,t.useEffect)(()=>{s&&_.current&&x.length===0&&(_.current.value=``)},[x,s]),(0,t.useEffect)(()=>{let e=v.current;if(!e||o)return;let t=e=>{e.dataTransfer?.types?.includes(`Files`)&&e.preventDefault()},n=e=>{e.dataTransfer?.types?.includes(`Files`)&&e.preventDefault(),e.dataTransfer?.files&&e.dataTransfer.files.length>0&&O(e.dataTransfer.files)};return e.addEventListener(`dragover`,t),e.addEventListener(`drop`,n),()=>{e.removeEventListener(`dragover`,t),e.removeEventListener(`drop`,n)}},[O,o]),(0,t.useEffect)(()=>{if(!o)return;let e=e=>{e.dataTransfer?.types?.includes(`Files`)&&e.preventDefault()},t=e=>{e.dataTransfer?.types?.includes(`Files`)&&e.preventDefault(),e.dataTransfer?.files&&e.dataTransfer.files.length>0&&O(e.dataTransfer.files)};return document.addEventListener(`dragover`,e),document.addEventListener(`drop`,t),()=>{document.removeEventListener(`dragover`,e),document.removeEventListener(`drop`,t)}},[O,o]),(0,t.useEffect)(()=>()=>{if(!g)for(let e of S.current)e.url&&URL.revokeObjectURL(e.url)},[g]);let M=e=>{e.currentTarget.files&&O(e.currentTarget.files),e.currentTarget.value=``},N=async e=>{try{let t=await(await fetch(e)).blob();return new Promise(e=>{let n=new FileReader;n.onloadend=()=>e(n.result),n.onerror=()=>e(null),n.readAsDataURL(t)})}catch{return null}},P=(0,t.useMemo)(()=>({files:x.map(e=>({...e,id:e.id})),add:O,remove:k,clear:A,openFileDialog:j,fileInputRef:_}),[x,O,k,A,j]),F=(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(`input`,{accept:r,"aria-label":`Upload files`,className:`hidden`,multiple:a,onChange:M,ref:_,title:`Upload files`,type:`file`}),(0,i.jsx)(`form`,{className:(0,n.cn)(`w-full`,e),onSubmit:e=>{e.preventDefault();let t=e.currentTarget,n=g?h.textInput.value:new FormData(t).get(`message`)||``;g||t.reset(),Promise.all(x.map(async({id:e,...t})=>{if(t.url&&t.url.startsWith(`blob:`)){let e=await N(t.url);return{...t,url:e??t.url}}return t})).then(t=>{try{let r=d({text:n,files:t},e);r instanceof Promise?r.then(()=>{A(),g&&h.textInput.clear()}).catch(()=>{}):(A(),g&&h.textInput.clear())}catch{}}).catch(()=>{})},ref:v,...m,children:(0,i.jsx)(be,{className:`overflow-hidden`,children:f})})]});return g?F:(0,i.jsx)(ke.Provider,{value:P,children:F})},Pe=({className:e,...t})=>(0,i.jsx)(`div`,{className:(0,n.cn)(`contents`,e),...t}),Fe=({onChange:e,className:r,placeholder:a=`What would you like to know?`,...o})=>{let s=Te(),c=G(),[l,u]=(0,t.useState)(!1),d=e=>{if(e.key===`Enter`){if(l||e.nativeEvent.isComposing||e.shiftKey)return;e.preventDefault();let t=e.currentTarget.form;if(t?.querySelector(`button[type="submit"]`)?.disabled)return;t?.requestSubmit()}if(e.key===`Backspace`&&e.currentTarget.value===``&&c.files.length>0){e.preventDefault();let t=c.files[c.files.length-1];t&&c.remove(t.id)}},f=e=>{let t=e.clipboardData?.items;if(!t)return;let n=[];for(let e of t)if(e.kind===`file`){let t=e.getAsFile();t&&n.push(t)}n.length>0&&(e.preventDefault(),c.add(n))},p=s?{value:s.textInput.value,onChange:t=>{s.textInput.setInput(t.currentTarget.value),e?.(t)}}:{onChange:e};return(0,i.jsx)(Ce,{className:(0,n.cn)(`field-sizing-content max-h-48 min-h-16`,r),name:`message`,onCompositionEnd:()=>u(!1),onCompositionStart:()=>u(!0),onKeyDown:d,onPaste:f,placeholder:a,...o,...p})},Ie=({className:e,...t})=>(0,i.jsx)(V,{align:`block-end`,className:(0,n.cn)(`order-first flex-wrap gap-1`,e),...t}),Le=({className:e,...t})=>(0,i.jsx)(V,{align:`block-end`,className:(0,n.cn)(`justify-between gap-1`,e),...t}),Re=({className:e,...t})=>(0,i.jsx)(`div`,{className:(0,n.cn)(`flex items-center gap-1`,e),...t}),K=({variant:e=`ghost`,className:r,size:a,...o})=>{let s=a??(t.Children.count(o.children)>1?`sm`:`icon-sm`);return(0,i.jsx)(H,{className:(0,n.cn)(r),size:s,type:`button`,variant:e,...o})},ze=e=>(0,i.jsx)(n.DropdownMenu,{...e}),Be=({className:e,children:t,...a})=>(0,i.jsx)(n.DropdownMenuTrigger,{asChild:!0,children:(0,i.jsx)(K,{className:e,...a,children:t??(0,i.jsx)(r.PlusIcon,{className:`size-4`})})}),Ve=({className:e,...t})=>(0,i.jsx)(n.DropdownMenuContent,{align:`start`,className:(0,n.cn)(e),...t}),He=({className:e,...t})=>(0,i.jsx)(n.DropdownMenuItem,{className:(0,n.cn)(e),...t}),Ue=({className:e,variant:t=`default`,size:a=`icon-sm`,status:o,children:s,...c})=>{let l=(0,i.jsx)(r.CornerDownLeftIcon,{className:`size-4`});return o===`submitted`?l=(0,i.jsx)(r.Loader2Icon,{className:`size-4 animate-spin`}):o===`streaming`?l=(0,i.jsx)(r.SquareIcon,{className:`size-4`}):o===`error`&&(l=(0,i.jsx)(r.XIcon,{className:`size-4`})),(0,i.jsx)(H,{"aria-label":`Submit`,className:(0,n.cn)(e),size:a,type:`submit`,variant:t,...c,children:s??l})},We=({className:e,textareaRef:a,onTranscriptionChange:o,...s})=>{let[c,l]=(0,t.useState)(!1),[u,d]=(0,t.useState)(null),f=(0,t.useRef)(null);(0,t.useEffect)(()=>{if(typeof window<`u`&&(`SpeechRecognition`in window||`webkitSpeechRecognition`in window)){let e=new(window.SpeechRecognition||window.webkitSpeechRecognition);e.continuous=!0,e.interimResults=!0,e.lang=`en-US`,e.onstart=()=>{l(!0)},e.onend=()=>{l(!1)},e.onresult=e=>{let t=``;for(let n=e.resultIndex;n<e.results.length;n++){let r=e.results[n];r.isFinal&&(t+=r[0]?.transcript??``)}if(t&&a?.current){let e=a.current,n=e.value,r=n+(n?` `:``)+t;e.value=r,e.dispatchEvent(new Event(`input`,{bubbles:!0})),o?.(r)}},e.onerror=e=>{console.error(`Speech recognition error:`,e.error),l(!1)},f.current=e,d(e)}return()=>{f.current&&f.current.stop()}},[a,o]);let p=(0,t.useCallback)(()=>{u&&(c?u.stop():u.start())},[u,c]);return(0,i.jsx)(K,{className:(0,n.cn)(`relative transition-all duration-200`,c&&`animate-pulse bg-accent text-accent-foreground`,e),disabled:!u,onClick:p,...s,children:(0,i.jsx)(r.MicIcon,{className:`size-4`})})},Ge=e=>(0,i.jsx)(n.Select,{...e}),Ke=({className:e,...t})=>(0,i.jsx)(n.SelectTrigger,{className:(0,n.cn)(`border-none bg-transparent font-medium text-muted-foreground shadow-none transition-colors`,`hover:bg-accent hover:text-foreground aria-expanded:bg-accent aria-expanded:text-foreground`,e),...t}),qe=({className:e,...t})=>(0,i.jsx)(n.SelectContent,{className:(0,n.cn)(e),...t}),Je=({className:e,...t})=>(0,i.jsx)(n.SelectItem,{className:(0,n.cn)(e),...t}),Ye=({className:e,...t})=>(0,i.jsx)(n.SelectValue,{className:(0,n.cn)(e),...t}),Xe=({openDelay:e=0,closeDelay:t=0,...r})=>(0,i.jsx)(n.HoverCard,{closeDelay:t,openDelay:e,...r}),Ze=e=>(0,i.jsx)(n.HoverCardTrigger,{...e}),Qe=({align:e=`start`,...t})=>(0,i.jsx)(n.HoverCardContent,{align:e,...t}),$e=({className:e,...t})=>(0,i.jsx)(`div`,{className:(0,n.cn)(e),...t}),et=({className:e,...t})=>(0,i.jsx)(`div`,{className:(0,n.cn)(e),...t}),tt=({className:e,...t})=>(0,i.jsx)(`h3`,{className:(0,n.cn)(`mb-2 px-3 font-medium text-muted-foreground text-xs`,e),...t}),nt=({className:e,...t})=>(0,i.jsx)(`div`,{className:(0,n.cn)(`space-y-1`,e),...t}),rt=({className:e,...t})=>(0,i.jsx)(`div`,{className:(0,n.cn)(`flex items-center gap-2 px-3 py-2 text-xs hover:bg-accent`,e),...t}),it=({className:e,...t})=>(0,i.jsx)(n.Command,{className:(0,n.cn)(e),...t}),at=({className:e,...t})=>(0,i.jsx)(n.CommandInput,{className:(0,n.cn)(e),...t}),ot=({className:e,...t})=>(0,i.jsx)(n.CommandList,{className:(0,n.cn)(e),...t}),st=({className:e,...t})=>(0,i.jsx)(n.CommandEmpty,{className:(0,n.cn)(e),...t}),ct=({className:e,...t})=>(0,i.jsx)(n.CommandGroup,{className:(0,n.cn)(e),...t}),lt=({className:e,...t})=>(0,i.jsx)(n.CommandItem,{className:(0,n.cn)(e),...t}),ut=({className:e,...t})=>(0,i.jsx)(n.CommandSeparator,{className:(0,n.cn)(e),...t}),dt=({className:e,children:t,...r})=>(0,i.jsxs)(n.ScrollArea,{className:`w-full overflow-x-auto whitespace-nowrap`,...r,children:[(0,i.jsx)(`div`,{className:(0,n.cn)(`flex w-max flex-nowrap items-center gap-2`,e),children:t}),(0,i.jsx)(n.ScrollBar,{className:`hidden`,orientation:`horizontal`})]}),ft=({suggestion:e,onClick:t,className:r,variant:a=`outline`,size:o=`sm`,children:s,...c})=>(0,i.jsx)(n.Button,{className:(0,n.cn)(`cursor-pointer rounded-full px-4`,r),onClick:()=>{t?.(e)},size:o,type:`button`,variant:a,...c,children:s||e}),pt=(0,t.createContext)({code:``}),mt={name:`line-numbers`,line(e,t){e.children.unshift({type:`element`,tagName:`span`,properties:{className:[`inline-block`,`min-w-10`,`mr-4`,`text-right`,`select-none`,`text-muted-foreground`]},children:[{type:`text`,value:String(t)}]})}};async function ht(e,t,n=!1){let r=n?[mt]:[];return await Promise.all([(0,m.codeToHtml)(e,{lang:t,theme:`one-light`,transformers:r}),(0,m.codeToHtml)(e,{lang:t,theme:`one-dark-pro`,transformers:r})])}var q=({code:e,language:r,showLineNumbers:a=!1,className:o,children:s,...c})=>{let[l,u]=(0,t.useState)(``),[d,f]=(0,t.useState)(``),p=(0,t.useRef)(!1);return(0,t.useEffect)(()=>(ht(e,r,a).then(([e,t])=>{p.current||=(u(e),f(t),!0)}),()=>{p.current=!1}),[e,r,a]),(0,i.jsx)(pt.Provider,{value:{code:e},children:(0,i.jsx)(`div`,{className:(0,n.cn)(`group relative w-full overflow-hidden rounded-md border bg-background text-foreground`,o),...c,children:(0,i.jsxs)(`div`,{className:`relative`,children:[(0,i.jsx)(`div`,{className:`overflow-auto dark:hidden [&>pre]:m-0 [&>pre]:bg-background! [&>pre]:p-4 [&>pre]:text-foreground! [&>pre]:text-sm [&_code]:font-mono [&_code]:text-sm`,dangerouslySetInnerHTML:{__html:l}}),(0,i.jsx)(`div`,{className:`hidden overflow-auto dark:block [&>pre]:m-0 [&>pre]:bg-background! [&>pre]:p-4 [&>pre]:text-foreground! [&>pre]:text-sm [&_code]:font-mono [&_code]:text-sm`,dangerouslySetInnerHTML:{__html:d}}),s&&(0,i.jsx)(`div`,{className:`absolute top-2 right-2 flex items-center gap-2`,children:s})]})})})},gt=({onCopy:e,onError:a,timeout:o=2e3,children:s,className:c,...l})=>{let[u,d]=(0,t.useState)(!1),{code:f}=(0,t.useContext)(pt),p=async()=>{if(typeof window>`u`||!navigator?.clipboard?.writeText){a?.(Error(`Clipboard API not available`));return}try{await navigator.clipboard.writeText(f),d(!0),e?.(),setTimeout(()=>d(!1),o)}catch(e){a?.(e)}},m=u?r.CheckIcon:r.CopyIcon;return(0,i.jsx)(n.Button,{className:(0,n.cn)(`shrink-0`,c),onClick:p,size:`icon`,variant:`ghost`,...l,children:s??(0,i.jsx)(m,{size:14})})},_t=({className:e,...t})=>(0,i.jsx)(n.Collapsible,{className:(0,n.cn)(`not-prose mb-4 w-full rounded-md border`,e),...t}),vt=e=>(0,i.jsxs)(n.Badge,{className:`gap-1.5 rounded-full text-xs`,variant:`secondary`,children:[{"input-streaming":(0,i.jsx)(r.CircleIcon,{className:`size-4`}),"input-available":(0,i.jsx)(r.ClockIcon,{className:`size-4 animate-pulse`}),"approval-requested":(0,i.jsx)(r.ClockIcon,{className:`size-4 text-yellow-600`}),"approval-responded":(0,i.jsx)(r.CheckCircleIcon,{className:`size-4 text-blue-600`}),"output-available":(0,i.jsx)(r.CheckCircleIcon,{className:`size-4 text-green-600`}),"output-error":(0,i.jsx)(r.XCircleIcon,{className:`size-4 text-red-600`}),"output-denied":(0,i.jsx)(r.XCircleIcon,{className:`size-4 text-orange-600`})}[e],{"input-streaming":`Pending`,"input-available":`Running`,"approval-requested":`Awaiting Approval`,"approval-responded":`Responded`,"output-available":`Completed`,"output-error":`Error`,"output-denied":`Denied`}[e]]}),yt=({className:e,title:t,type:a,state:o,...s})=>(0,i.jsxs)(n.CollapsibleTrigger,{className:(0,n.cn)(`flex w-full items-center justify-between gap-4 p-3`,e),...s,children:[(0,i.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,i.jsx)(r.WrenchIcon,{className:`size-4 text-muted-foreground`}),(0,i.jsx)(`span`,{className:`font-medium text-sm`,children:t??a.split(`-`).slice(1).join(`-`)}),vt(o)]}),(0,i.jsx)(r.ChevronDownIcon,{className:`size-4 text-muted-foreground transition-transform group-data-[state=open]:rotate-180`})]}),bt=({className:e,...t})=>(0,i.jsx)(n.CollapsibleContent,{className:(0,n.cn)(`data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-popover-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in`,e),...t}),xt=({className:e,input:t,...r})=>(0,i.jsxs)(`div`,{className:(0,n.cn)(`space-y-2 overflow-hidden p-4`,e),...r,children:[(0,i.jsx)(`h4`,{className:`font-medium text-muted-foreground text-xs uppercase tracking-wide`,children:`Parameters`}),(0,i.jsx)(`div`,{className:`rounded-md bg-muted/50`,children:(0,i.jsx)(q,{code:JSON.stringify(t,null,2),language:`json`})})]}),St=({className:e,output:r,errorText:a,...o})=>{if(!(r||a))return null;let s=(0,i.jsx)(`div`,{children:r});return typeof r==`object`&&!(0,t.isValidElement)(r)?s=(0,i.jsx)(q,{code:JSON.stringify(r,null,2),language:`json`}):typeof r==`string`&&(s=(0,i.jsx)(q,{code:r,language:`json`})),(0,i.jsxs)(`div`,{className:(0,n.cn)(`space-y-2 p-4`,e),...o,children:[(0,i.jsx)(`h4`,{className:`font-medium text-muted-foreground text-xs uppercase tracking-wide`,children:a?`Error`:`Result`}),(0,i.jsxs)(`div`,{className:(0,n.cn)(`overflow-x-auto rounded-md text-xs [&_table]:w-full`,a?`bg-destructive/10 text-destructive`:`bg-muted/50 text-foreground`),children:[a&&(0,i.jsx)(`div`,{children:a}),s]})]})},Ct=(0,t.memo)(({children:e,as:r=`p`,className:a,duration:o=2,spread:s=2})=>{let c=g.motion.create(r),l=(0,t.useMemo)(()=>(e?.length??0)*s,[e,s]);return(0,i.jsx)(c,{animate:{backgroundPosition:`0% center`},className:(0,n.cn)(`relative inline-block bg-[length:250%_100%,auto] bg-clip-text text-transparent`,`[--bg:linear-gradient(90deg,#0000_calc(50%-var(--spread)),var(--color-background),#0000_calc(50%+var(--spread)))] [background-repeat:no-repeat,padding-box]`,a),initial:{backgroundPosition:`100% center`},style:{"--spread":`${l}px`,backgroundImage:`var(--bg), linear-gradient(var(--color-muted-foreground), var(--color-muted-foreground))`},transition:{repeat:1/0,duration:o,ease:`linear`},children:e})}),wt=(0,t.createContext)(null),Tt=()=>{let e=(0,t.useContext)(wt);if(!e)throw Error(`Reasoning components must be used within Reasoning`);return e},Et=1e3,Dt=1e3,J=(0,t.memo)(({className:e,isStreaming:r=!1,open:a,defaultOpen:o=!0,onOpenChange:s,duration:c,children:l,...u})=>{let[d,f]=(0,h.useControllableState)({prop:a,defaultProp:o,onChange:s}),[p,m]=(0,h.useControllableState)({prop:c,defaultProp:void 0}),[g,_]=(0,t.useState)(!1),[v,y]=(0,t.useState)(null);return(0,t.useEffect)(()=>{r?v===null&&y(Date.now()):v!==null&&(m(Math.ceil((Date.now()-v)/Dt)),y(null))},[r,v,m]),(0,t.useEffect)(()=>{if(o&&!r&&d&&!g){let e=setTimeout(()=>{f(!1),_(!0)},Et);return()=>clearTimeout(e)}},[r,d,o,f,g]),(0,i.jsx)(wt.Provider,{value:{isStreaming:r,isOpen:d,setIsOpen:f,duration:p},children:(0,i.jsx)(n.Collapsible,{className:(0,n.cn)(`not-prose mb-4`,e),onOpenChange:e=>{f(e)},open:d,...u,children:l})})}),Ot=(e,t)=>e||t===0?(0,i.jsx)(Ct,{duration:1,children:`Thinking...`}):t===void 0?(0,i.jsx)(`p`,{children:`Thought for a few seconds`}):(0,i.jsxs)(`p`,{children:[`Thought for `,t,` seconds`]}),Y=(0,t.memo)(({className:e,children:t,getThinkingMessage:a=Ot,...o})=>{let{isStreaming:s,isOpen:c,duration:l}=Tt();return(0,i.jsx)(n.CollapsibleTrigger,{className:(0,n.cn)(`flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground`,e),...o,children:t??(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(r.BrainIcon,{className:`size-4`}),a(s,l),(0,i.jsx)(r.ChevronDownIcon,{className:(0,n.cn)(`size-4 transition-transform`,c?`rotate-180`:`rotate-0`)})]})})}),X=(0,t.memo)(({className:e,children:t,...r})=>(0,i.jsx)(n.CollapsibleContent,{className:(0,n.cn)(`mt-4 text-sm`,`data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-muted-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in`,e),...r,children:(0,i.jsx)(f.Streamdown,{...r,children:t})}));J.displayName=`Reasoning`,Y.displayName=`ReasoningTrigger`,X.displayName=`ReasoningContent`;var Z=({className:e,...t})=>(0,i.jsx)(n.Collapsible,{className:(0,n.cn)(`not-prose mb-4 text-primary text-xs`,e),...t}),kt=({className:e,count:t,children:a,...o})=>(0,i.jsx)(n.CollapsibleTrigger,{className:(0,n.cn)(`flex items-center gap-2`,e),...o,children:a??(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(`p`,{className:`font-medium`,children:[`Used `,t,` sources`]}),(0,i.jsx)(r.ChevronDownIcon,{className:`h-4 w-4`})]})}),At=({className:e,...t})=>(0,i.jsx)(n.CollapsibleContent,{className:(0,n.cn)(`mt-3 flex w-fit flex-col gap-2`,`data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 outline-none data-[state=closed]:animate-out data-[state=open]:animate-in`,e),...t}),jt=({href:e,title:t,children:n,...a})=>(0,i.jsx)(`a`,{className:`flex items-center gap-2`,href:e,rel:`noreferrer`,target:`_blank`,...a,children:n??(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(r.BookIcon,{className:`h-4 w-4`}),(0,i.jsx)(`span`,{className:`block font-medium`,children:t})]})});function Mt(e,t){return t?`error`:e?`streaming`:`ready`}function Nt(e){return e===`user`?`user`:`assistant`}var Q=t.forwardRef(({className:e,messages:a=[],placeholder:o=`Type your message...`,onSendMessage:s,onClear:c,onStop:l,onReload:u,disabled:d=!1,isLoading:f=!1,error:p,showTimestamp:m=!1,userAvatarUrl:h,userAvatarFallback:g=`You`,assistantAvatarUrl:_,assistantAvatarFallback:v=`AI`,maxHeight:y=`500px`,enableMarkdown:b=!0,enableFileUpload:x=!1,acceptedFileTypes:S=`image/*,.pdf,.doc,.docx,.txt`,maxFileSize:C=10*1024*1024,suggestions:w,models:T,selectedModelId:E,onModelChange:D,...O},k)=>{let A=Mt(f,p),[j,M]=t.useState(null),N=t.useCallback(e=>{let t=!!e.text?.trim(),n=e.files?.map(e=>e.file).filter(Boolean),r=!!(n&&n.length>0);(t||r)&&s?.(e.text?.trim()??``,n)},[s]),P=t.useCallback(e=>{s?.(e)},[s]),F=t.useCallback(e=>{navigator.clipboard?.writeText(e.content),M(e.id),window.setTimeout(()=>M(t=>t===e.id?null:t),1500)},[]);return(0,i.jsxs)(`div`,{ref:k,className:(0,n.cn)(`flex flex-col border rounded-lg bg-background overflow-hidden`,e),style:{maxHeight:y},...O,children:[c&&a.length>0&&(0,i.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2 border-b bg-muted/30`,children:[(0,i.jsxs)(`span`,{className:`text-sm text-muted-foreground`,children:[a.length,` message`,a.length===1?``:`s`]}),(0,i.jsx)(`button`,{type:`button`,onClick:c,className:`text-xs text-muted-foreground hover:text-foreground transition-colors`,children:`Clear`})]}),(0,i.jsxs)(I,{className:`flex-1 min-h-0`,children:[(0,i.jsx)(L,{className:`space-y-4 px-4 py-3`,children:a.length===0?(0,i.jsx)(ne,{title:`Start a conversation`,description:`Ask anything — the assistant has access to your current app context.`,children:w&&w.length>0?(0,i.jsx)(dt,{className:`justify-center pt-2`,children:w.map(e=>(0,i.jsx)(ft,{suggestion:e,onClick:P},e))}):null}):a.map(e=>{let t=e.role===`user`,n=e.toolInvocations??[],a=e.reasoning?.trim(),o=e.sources??[];return(0,i.jsxs)(se,{from:Nt(e.role),children:[(0,i.jsxs)(ce,{children:[!t&&a?(0,i.jsxs)(J,{isStreaming:!!e.streaming&&!e.content,className:`mb-2`,children:[(0,i.jsx)(Y,{}),(0,i.jsx)(X,{children:a})]}):null,!t&&n.length>0?n.map(e=>{let t=e.state??(e.errorText?`output-error`:e.result===void 0?`input-available`:`output-available`),n=`tool-${e.toolName}`;return(0,i.jsxs)(_t,{defaultOpen:t!==`output-available`,children:[(0,i.jsx)(yt,{type:n,state:t,title:e.toolName}),(0,i.jsxs)(bt,{children:[e.args===void 0?null:(0,i.jsx)(xt,{input:e.args}),(0,i.jsx)(St,{output:e.result,errorText:e.errorText})]})]},e.toolCallId)}):null,e.content,e.streaming?(0,i.jsx)(`span`,{"aria-hidden":!0,className:`ml-0.5 inline-block w-[2px] h-4 align-middle bg-current animate-pulse`}):null,!t&&o.length>0?(0,i.jsxs)(Z,{children:[(0,i.jsx)(kt,{count:o.length}),(0,i.jsx)(At,{children:o.map((e,t)=>(0,i.jsx)(jt,{href:e.url,title:e.title??e.url},e.id??e.url??t))})]}):null,m&&e.timestamp?(0,i.jsx)(`div`,{className:`text-[10px] opacity-70 mt-1`,children:e.timestamp}):null]}),t?null:(0,i.jsxs)(le,{children:[(0,i.jsx)(R,{label:`Copy`,tooltip:`Copy`,onClick:()=>F(e),children:j===e.id?(0,i.jsx)(r.Check,{className:`size-3.5`}):(0,i.jsx)(r.Copy,{className:`size-3.5`})}),u?(0,i.jsx)(R,{label:`Regenerate`,tooltip:`Regenerate`,onClick:u,children:(0,i.jsx)(r.RefreshCw,{className:`size-3.5`})}):null,e.traceId?(0,i.jsx)(`a`,{href:`#trace/${e.traceId}`,"data-trace-id":e.traceId,className:`text-[10px] text-muted-foreground hover:text-foreground ml-1 underline`,title:`View trace`,children:`trace`}):null]})]},e.id)})}),(0,i.jsx)(re,{})]}),p?(0,i.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-2 border-t bg-destructive/10 text-destructive text-sm`,role:`alert`,children:[(0,i.jsx)(r.AlertCircle,{className:`h-4 w-4 shrink-0`}),(0,i.jsx)(`span`,{className:`flex-1 truncate`,children:p.message||`An error occurred`}),u?(0,i.jsx)(`button`,{type:`button`,onClick:u,className:`text-xs underline hover:no-underline`,children:`Retry`}):null]}):null,(0,i.jsxs)(Ne,{accept:S,maxFileSize:C,onSubmit:N,onError:e=>{console.warn(`[plugin-chatbot] prompt-input error`,e)},children:[x?(0,i.jsx)(Pe,{children:(0,i.jsx)(je,{children:e=>(0,i.jsx)(Ae,{data:e})})}):null,(0,i.jsx)(Fe,{placeholder:o,disabled:d||A===`streaming`}),(0,i.jsxs)(Le,{children:[(0,i.jsxs)(Re,{children:[x?(0,i.jsxs)(ze,{children:[(0,i.jsx)(Be,{}),(0,i.jsx)(Ve,{children:(0,i.jsx)(Me,{})})]}):null,T&&T.length>0?(0,i.jsx)(`select`,{"aria-label":`Model`,value:E??T[0].id,onChange:e=>D?.(e.target.value),className:`h-7 rounded-md border bg-background px-2 text-xs text-muted-foreground hover:text-foreground focus:outline-none focus:ring-1 focus:ring-ring`,children:T.map(e=>(0,i.jsxs)(`option`,{value:e.id,children:[e.label??e.id,e.provider?` · ${e.provider}`:``]},e.id))}):null]}),(0,i.jsx)(Ue,{status:A,disabled:d,onClick:A===`streaming`?l:void 0})]})]}),(0,i.jsx)(`span`,{hidden:!0,"data-avatar-user":h??g,"data-avatar-assistant":_??v})]})});Q.displayName=`ChatbotEnhanced`;function Pt({floatingConfig:e,headerExtra:n,...r}){let{position:a=`bottom-right`,defaultOpen:o=!1,panelWidth:c=400,panelHeight:l=520,title:u=`Chat`,triggerSize:d=56}=e??{},[f,p]=t.useState(null);t.useEffect(()=>{let e=document.getElementById(`floating-chatbot-portal`);return e||(e=document.createElement(`div`),e.id=`floating-chatbot-portal`,document.body.appendChild(e)),p(e),()=>{e&&e.parentNode&&!e.hasChildNodes()&&e.parentNode.removeChild(e)}},[]);let m=(0,i.jsxs)(N,{defaultOpen:o,children:[(0,i.jsx)(ee,{position:a,size:d}),(0,i.jsx)(te,{title:u,position:a,width:c,height:l,headerExtra:n,children:(0,i.jsx)(Q,{...r,maxHeight:`100%`,className:`h-full border-0 rounded-none`})})]});return f?s.createPortal(m,f):m}_.ComponentRegistry.register(`chatbot`,({schema:e,className:t,...n})=>{let{messages:r,isLoading:a,sendMessage:o}=k({api:e.api,initialMessages:e.messages,conversationId:e.conversationId,systemPrompt:e.systemPrompt,model:e.model,streamingEnabled:e.streamingEnabled,headers:e.headers,body:e.requestBody,maxToolRoundtrips:e.maxToolRoundtrips,onError:e.onError,showTimestamp:e.showTimestamp,autoResponse:e.autoResponse,autoResponseText:e.autoResponseText,autoResponseDelay:e.autoResponseDelay,onSend:e.onSend});return(0,i.jsx)($,{messages:r,placeholder:e.placeholder,onSendMessage:e=>{o(e)},disabled:e.disabled||a,showTimestamp:e.showTimestamp,userAvatarUrl:e.userAvatarUrl,userAvatarFallback:e.userAvatarFallback,assistantAvatarUrl:e.assistantAvatarUrl,assistantAvatarFallback:e.assistantAvatarFallback,maxHeight:e.maxHeight,className:t,...n})},{namespace:`plugin-chatbot`,label:`Chatbot`,inputs:[{name:`messages`,type:`array`,label:`Initial Messages`,description:`Array of message objects with id, role, content, and optional timestamp`},{name:`placeholder`,type:`string`,label:`Input Placeholder`,defaultValue:`Type your message...`},{name:`showTimestamp`,type:`boolean`,label:`Show Timestamps`,defaultValue:!1},{name:`disabled`,type:`boolean`,label:`Disabled`,defaultValue:!1},{name:`userAvatarUrl`,type:`string`,label:`User Avatar URL`,description:`URL of the user avatar image`},{name:`userAvatarFallback`,type:`string`,label:`User Avatar Fallback`,defaultValue:`You`,description:`Fallback text shown when user avatar image is not available`},{name:`assistantAvatarUrl`,type:`string`,label:`Assistant Avatar URL`,description:`URL of the assistant avatar image`},{name:`assistantAvatarFallback`,type:`string`,label:`Assistant Avatar Fallback`,defaultValue:`AI`,description:`Fallback text shown when assistant avatar image is not available`},{name:`maxHeight`,type:`string`,label:`Max Height`,defaultValue:`500px`},{name:`api`,type:`string`,label:`API Endpoint`,description:`Backend SSE endpoint (e.g., /api/v1/ai/chat). When set, enables streaming AI mode.`},{name:`conversationId`,type:`string`,label:`Conversation ID`,description:`Multi-turn conversation identifier`},{name:`systemPrompt`,type:`string`,label:`System Prompt`,description:`System prompt to configure assistant behavior`},{name:`model`,type:`string`,label:`AI Model`,description:`AI model identifier (e.g., gpt-4o)`},{name:`streamingEnabled`,type:`boolean`,label:`Enable Streaming`,defaultValue:!0},{name:`autoResponse`,type:`boolean`,label:`Enable Auto Response (Demo)`,defaultValue:!1,description:`Automatically send a response after user message (for demo purposes, ignored when API is set)`},{name:`autoResponseText`,type:`string`,label:`Auto Response Text`,defaultValue:`Thank you for your message!`},{name:`autoResponseDelay`,type:`number`,label:`Auto Response Delay (ms)`,defaultValue:1e3},{name:`className`,type:`string`,label:`CSS Class`}],defaultProps:{messages:[{id:`welcome`,role:`assistant`,content:`Hello! How can I help you today?`}],placeholder:`Type your message...`,showTimestamp:!1,disabled:!1,userAvatarFallback:`You`,assistantAvatarFallback:`AI`,maxHeight:`500px`,autoResponse:!0,autoResponseText:`Thank you for your message! This is an automated response.`,autoResponseDelay:1e3,className:`w-full max-w-2xl`}}),_.ComponentRegistry.register(`chatbot-enhanced`,({schema:e,className:t,...n})=>{let{messages:r,isLoading:a,error:o,sendMessage:s,stop:c,reload:l,clear:u,isApiMode:d}=k({api:e.api,initialMessages:e.messages,conversationId:e.conversationId,systemPrompt:e.systemPrompt,model:e.model,streamingEnabled:e.streamingEnabled,headers:e.headers,body:e.requestBody,maxToolRoundtrips:e.maxToolRoundtrips,onError:e.onError,showTimestamp:e.showTimestamp,autoResponse:e.autoResponse,autoResponseText:e.autoResponseText,autoResponseDelay:e.autoResponseDelay,onSend:e.onSend});return(0,i.jsx)(Q,{messages:r,placeholder:e.placeholder,onSendMessage:(e,t)=>{s(e,t)},onClear:()=>{u(),e.onClear?.()},onStop:d&&a?c:void 0,onReload:d?l:void 0,disabled:e.disabled,isLoading:a,error:o,showTimestamp:e.showTimestamp,userAvatarUrl:e.userAvatarUrl,userAvatarFallback:e.userAvatarFallback,assistantAvatarUrl:e.assistantAvatarUrl,assistantAvatarFallback:e.assistantAvatarFallback,maxHeight:e.maxHeight,enableMarkdown:e.enableMarkdown??!0,enableFileUpload:e.enableFileUpload??!1,className:t,...n})},{namespace:`plugin-chatbot`,label:`Chatbot (Enhanced)`,inputs:[{name:`messages`,type:`array`,label:`Initial Messages`},{name:`placeholder`,type:`string`,label:`Input Placeholder`,defaultValue:`Type your message...`},{name:`showTimestamp`,type:`boolean`,label:`Show Timestamps`,defaultValue:!1},{name:`disabled`,type:`boolean`,label:`Disabled`,defaultValue:!1},{name:`enableMarkdown`,type:`boolean`,label:`Enable Markdown`,defaultValue:!0},{name:`enableFileUpload`,type:`boolean`,label:`Enable File Upload`,defaultValue:!1},{name:`userAvatarUrl`,type:`string`,label:`User Avatar URL`},{name:`userAvatarFallback`,type:`string`,label:`User Avatar Fallback`,defaultValue:`You`},{name:`assistantAvatarUrl`,type:`string`,label:`Assistant Avatar URL`},{name:`assistantAvatarFallback`,type:`string`,label:`Assistant Avatar Fallback`,defaultValue:`AI`},{name:`maxHeight`,type:`string`,label:`Max Height`,defaultValue:`500px`},{name:`api`,type:`string`,label:`API Endpoint`,description:`Backend SSE endpoint for streaming AI mode`},{name:`conversationId`,type:`string`,label:`Conversation ID`},{name:`systemPrompt`,type:`string`,label:`System Prompt`},{name:`model`,type:`string`,label:`AI Model`},{name:`streamingEnabled`,type:`boolean`,label:`Enable Streaming`,defaultValue:!0},{name:`autoResponse`,type:`boolean`,label:`Enable Auto Response (Demo)`,defaultValue:!1},{name:`autoResponseText`,type:`string`,label:`Auto Response Text`,defaultValue:`Thank you for your message!`},{name:`autoResponseDelay`,type:`number`,label:`Auto Response Delay (ms)`,defaultValue:1e3},{name:`className`,type:`string`,label:`CSS Class`}],defaultProps:{messages:[{id:`welcome`,role:`assistant`,content:`Hello! How can I help you today?`}],placeholder:`Type your message...`,showTimestamp:!1,disabled:!1,enableMarkdown:!0,enableFileUpload:!1,userAvatarFallback:`You`,assistantAvatarFallback:`AI`,maxHeight:`500px`,autoResponse:!0,autoResponseText:`Thank you for your message! This is an automated response.`,autoResponseDelay:1e3,className:`w-full max-w-2xl`}}),_.ComponentRegistry.register(`chatbot-floating`,({schema:e,className:t,...n})=>{let{messages:r,isLoading:a,error:o,sendMessage:s,stop:c,reload:l,clear:u,isApiMode:d}=k({api:e.api,initialMessages:e.messages,conversationId:e.conversationId,systemPrompt:e.systemPrompt,model:e.model,streamingEnabled:e.streamingEnabled,headers:e.headers,body:e.requestBody,maxToolRoundtrips:e.maxToolRoundtrips,onError:e.onError,showTimestamp:e.showTimestamp,autoResponse:e.autoResponse,autoResponseText:e.autoResponseText,autoResponseDelay:e.autoResponseDelay,onSend:e.onSend});return(0,i.jsx)(Pt,{floatingConfig:e.floatingConfig,messages:r,placeholder:e.placeholder,onSendMessage:(e,t)=>{s(e,t)},onClear:()=>{u(),e.onClear?.()},onStop:d&&a?c:void 0,onReload:d?l:void 0,disabled:e.disabled,isLoading:a,error:o,showTimestamp:e.showTimestamp,userAvatarUrl:e.userAvatarUrl,userAvatarFallback:e.userAvatarFallback,assistantAvatarUrl:e.assistantAvatarUrl,assistantAvatarFallback:e.assistantAvatarFallback,enableMarkdown:e.enableMarkdown??!0,enableFileUpload:e.enableFileUpload??!1,className:t,...n})},{namespace:`plugin-chatbot`,label:`Chatbot (Floating)`,inputs:[{name:`displayMode`,type:`string`,label:`Display Mode`,defaultValue:`floating`,description:`Set to "floating" for FAB widget`},{name:`floatingConfig.position`,type:`string`,label:`FAB Position`,defaultValue:`bottom-right`,description:`bottom-right or bottom-left`},{name:`floatingConfig.defaultOpen`,type:`boolean`,label:`Default Open`,defaultValue:!1},{name:`floatingConfig.panelWidth`,type:`number`,label:`Panel Width`,defaultValue:400},{name:`floatingConfig.panelHeight`,type:`number`,label:`Panel Height`,defaultValue:520},{name:`floatingConfig.title`,type:`string`,label:`Panel Title`,defaultValue:`Chat`},{name:`floatingConfig.triggerSize`,type:`number`,label:`Trigger Size`,defaultValue:56},{name:`messages`,type:`array`,label:`Initial Messages`},{name:`placeholder`,type:`string`,label:`Input Placeholder`,defaultValue:`Type your message...`},{name:`enableMarkdown`,type:`boolean`,label:`Enable Markdown`,defaultValue:!0},{name:`enableFileUpload`,type:`boolean`,label:`Enable File Upload`,defaultValue:!1},{name:`api`,type:`string`,label:`API Endpoint`,description:`Backend SSE endpoint for streaming AI mode`},{name:`conversationId`,type:`string`,label:`Conversation ID`},{name:`systemPrompt`,type:`string`,label:`System Prompt`},{name:`model`,type:`string`,label:`AI Model`},{name:`streamingEnabled`,type:`boolean`,label:`Enable Streaming`,defaultValue:!0},{name:`autoResponse`,type:`boolean`,label:`Enable Auto Response (Demo)`,defaultValue:!1},{name:`autoResponseText`,type:`string`,label:`Auto Response Text`,defaultValue:`Thank you for your message!`},{name:`autoResponseDelay`,type:`number`,label:`Auto Response Delay (ms)`,defaultValue:1e3},{name:`className`,type:`string`,label:`CSS Class`}],defaultProps:{displayMode:`floating`,floatingConfig:{position:`bottom-right`,defaultOpen:!1,panelWidth:400,panelHeight:520,title:`Chat`,triggerSize:56},messages:[{id:`welcome`,role:`assistant`,content:`Hello! How can I help you today?`}],placeholder:`Type your message...`,enableMarkdown:!0,enableFileUpload:!1,autoResponse:!0,autoResponseText:`Thank you for your message! This is an automated response.`,autoResponseDelay:1e3}});var Ft=({size:e=16})=>(0,i.jsxs)(`svg`,{height:e,strokeLinejoin:`round`,style:{color:`currentcolor`},viewBox:`0 0 16 16`,width:e,children:[(0,i.jsx)(`title`,{children:`Loader`}),(0,i.jsxs)(`g`,{clipPath:`url(#clip0_2393_1490)`,children:[(0,i.jsx)(`path`,{d:`M8 0V4`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,i.jsx)(`path`,{d:`M8 16V12`,opacity:`0.5`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,i.jsx)(`path`,{d:`M3.29773 1.52783L5.64887 4.7639`,opacity:`0.9`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,i.jsx)(`path`,{d:`M12.7023 1.52783L10.3511 4.7639`,opacity:`0.1`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,i.jsx)(`path`,{d:`M12.7023 14.472L10.3511 11.236`,opacity:`0.4`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,i.jsx)(`path`,{d:`M3.29773 14.472L5.64887 11.236`,opacity:`0.6`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,i.jsx)(`path`,{d:`M15.6085 5.52783L11.8043 6.7639`,opacity:`0.2`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,i.jsx)(`path`,{d:`M0.391602 10.472L4.19583 9.23598`,opacity:`0.7`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,i.jsx)(`path`,{d:`M15.6085 10.4722L11.8043 9.2361`,opacity:`0.3`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,i.jsx)(`path`,{d:`M0.391602 5.52783L4.19583 6.7639`,opacity:`0.8`,stroke:`currentColor`,strokeWidth:`1.5`})]}),(0,i.jsx)(`defs`,{children:(0,i.jsx)(`clipPath`,{id:`clip0_2393_1490`,children:(0,i.jsx)(`rect`,{fill:`white`,height:`16`,width:`16`})})})]}),It=({className:e,size:t=16,...r})=>(0,i.jsx)(`div`,{className:(0,n.cn)(`inline-flex animate-spin items-center justify-center`,e),...r,children:(0,i.jsx)(Ft,{size:t})}),Lt=w({CodeBlock:()=>q,CodeBlockCopyButton:()=>gt,Conversation:()=>I,ConversationContent:()=>L,ConversationEmptyState:()=>ne,ConversationScrollButton:()=>re,Loader:()=>It,Message:()=>se,MessageAction:()=>R,MessageActions:()=>le,MessageAttachment:()=>_e,MessageAttachments:()=>ve,MessageBranch:()=>de,MessageBranchContent:()=>fe,MessageBranchNext:()=>he,MessageBranchPage:()=>ge,MessageBranchPrevious:()=>me,MessageBranchSelector:()=>pe,MessageContent:()=>ce,MessageResponse:()=>B,MessageToolbar:()=>ye,PromptInput:()=>Ne,PromptInputActionAddAttachments:()=>Me,PromptInputActionMenu:()=>ze,PromptInputActionMenuContent:()=>Ve,PromptInputActionMenuItem:()=>He,PromptInputActionMenuTrigger:()=>Be,PromptInputAttachment:()=>Ae,PromptInputAttachments:()=>je,PromptInputBody:()=>Pe,PromptInputButton:()=>K,PromptInputCommand:()=>it,PromptInputCommandEmpty:()=>st,PromptInputCommandGroup:()=>ct,PromptInputCommandInput:()=>at,PromptInputCommandItem:()=>lt,PromptInputCommandList:()=>ot,PromptInputCommandSeparator:()=>ut,PromptInputFooter:()=>Le,PromptInputHeader:()=>Ie,PromptInputHoverCard:()=>Xe,PromptInputHoverCardContent:()=>Qe,PromptInputHoverCardTrigger:()=>Ze,PromptInputProvider:()=>Oe,PromptInputSelect:()=>Ge,PromptInputSelectContent:()=>qe,PromptInputSelectItem:()=>Je,PromptInputSelectTrigger:()=>Ke,PromptInputSelectValue:()=>Ye,PromptInputSpeechButton:()=>We,PromptInputSubmit:()=>Ue,PromptInputTab:()=>et,PromptInputTabBody:()=>nt,PromptInputTabItem:()=>rt,PromptInputTabLabel:()=>tt,PromptInputTabsList:()=>$e,PromptInputTextarea:()=>Fe,PromptInputTools:()=>Re,Reasoning:()=>J,ReasoningContent:()=>X,ReasoningTrigger:()=>Y,Shimmer:()=>Ct,Source:()=>jt,Sources:()=>Z,SourcesContent:()=>At,SourcesTrigger:()=>kt,Suggestion:()=>ft,Suggestions:()=>dt,Tool:()=>_t,ToolContent:()=>bt,ToolHeader:()=>yt,ToolInput:()=>xt,ToolOutput:()=>St,highlightCode:()=>ht,usePromptInputAttachments:()=>G,usePromptInputController:()=>we,useProviderAttachments:()=>Ee,useReasoning:()=>Tt}),$=t.forwardRef(({className:e,messages:a=[],placeholder:o=`Type your message...`,onSendMessage:s,disabled:c=!1,showTimestamp:l=!1,userAvatarUrl:u,userAvatarFallback:d=`You`,assistantAvatarUrl:f,assistantAvatarFallback:p=`AI`,maxHeight:m=`500px`,...h},g)=>{let[_,v]=t.useState(``),y=t.useRef(null),b=t.useRef(null);t.useEffect(()=>{if(y.current){let e=y.current.querySelector(`[data-radix-scroll-area-viewport]`);e&&(e.scrollTop=e.scrollHeight)}},[a]);let x=()=>{_.trim()&&s&&(s(_.trim()),v(``),b.current?.focus())},S=e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),x())};return(0,i.jsxs)(`div`,{ref:g,className:(0,n.cn)(`flex flex-col border rounded-lg bg-background overflow-hidden`,e),style:{maxHeight:m},...h,children:[(0,i.jsx)(n.ScrollArea,{ref:y,className:`flex-1 p-4`,children:(0,i.jsx)(`div`,{className:`space-y-4`,children:a.length===0?(0,i.jsx)(`div`,{className:`flex items-center justify-center h-32 text-muted-foreground text-sm`,children:`No messages yet. Start a conversation!`}):a.map(e=>(0,i.jsx)(Rt,{message:e,showTimestamp:l,userAvatarUrl:u,userAvatarFallback:d,assistantAvatarUrl:f,assistantAvatarFallback:p},e.id))})}),(0,i.jsx)(`div`,{className:`border-t p-4`,children:(0,i.jsxs)(`div`,{className:`flex gap-2`,children:[(0,i.jsx)(n.Input,{ref:b,value:_,onChange:e=>v(e.target.value),onKeyDown:S,placeholder:o,disabled:c,className:`flex-1`}),(0,i.jsx)(n.Button,{onClick:x,disabled:c||!_.trim(),size:`icon`,children:(0,i.jsx)(r.Send,{className:`h-4 w-4`})})]})})]})});$.displayName=`Chatbot`;var Rt=({message:e,showTimestamp:t,userAvatarUrl:r,userAvatarFallback:a,assistantAvatarUrl:o,assistantAvatarFallback:s})=>{let c=e.role===`user`;if(e.role===`system`)return(0,i.jsx)(`div`,{className:`flex justify-center`,children:(0,i.jsx)(`div`,{className:`text-xs text-muted-foreground bg-muted px-3 py-1 rounded-full`,children:e.content})});let l=c?e.avatar||r:e.avatar||o,u=c?e.avatarFallback||a:e.avatarFallback||s;return(0,i.jsxs)(`div`,{className:(0,n.cn)(`flex gap-3`,c?`flex-row-reverse`:`flex-row`),children:[(0,i.jsxs)(n.Avatar,{className:`h-8 w-8`,children:[(0,i.jsx)(n.AvatarImage,{src:l}),(0,i.jsx)(n.AvatarFallback,{className:`text-xs`,children:u})]}),(0,i.jsxs)(`div`,{className:(0,n.cn)(`flex flex-col gap-1`,c?`items-end`:`items-start`),children:[(0,i.jsx)(`div`,{className:(0,n.cn)(`rounded-lg px-4 py-2 max-w-[70%] break-words`,c?`bg-primary text-primary-foreground`:`bg-muted`),children:(0,i.jsx)(`p`,{className:`text-sm whitespace-pre-wrap`,children:e.content})}),t&&e.timestamp&&(0,i.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.timestamp})]})]})},zt=t.forwardRef(({className:e,avatarSrc:t,avatarFallback:r=`AI`,...a},o)=>(0,i.jsxs)(`div`,{ref:o,className:(0,n.cn)(`flex gap-3`,e),...a,children:[(0,i.jsxs)(n.Avatar,{className:`h-8 w-8`,children:[(0,i.jsx)(n.AvatarImage,{src:t}),(0,i.jsx)(n.AvatarFallback,{className:`text-xs`,children:r})]}),(0,i.jsx)(`div`,{className:`flex items-center bg-muted rounded-lg px-4 py-2`,children:(0,i.jsxs)(`div`,{className:`flex gap-1`,children:[(0,i.jsx)(`span`,{className:`w-2 h-2 bg-muted-foreground rounded-full animate-bounce [animation-delay:-0.3s]`}),(0,i.jsx)(`span`,{className:`w-2 h-2 bg-muted-foreground rounded-full animate-bounce [animation-delay:-0.15s]`}),(0,i.jsx)(`span`,{className:`w-2 h-2 bg-muted-foreground rounded-full animate-bounce`})]})})]}));zt.displayName=`TypingIndicator`,Object.defineProperty(e,`AIElements`,{enumerable:!0,get:function(){return Lt}}),e.Chatbot=$,e.FloatingChatbot=Pt,e.FloatingChatbotPanel=te,e.FloatingChatbotProvider=N,e.FloatingChatbotTrigger=ee,e.TypingIndicator=zt,e.useAgents=j,e.useFloatingChatbot=P,e.useObjectChat=k});
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`react`),require(`@object-ui/components`),require(`lucide-react`),require(`react/jsx-runtime`),require(`@ai-sdk/react`),require(`ai`),require(`react-dom`),require(`@object-ui/react`),require(`use-stick-to-bottom`),require(`class-variance-authority`),require(`@radix-ui/react-slot`),require(`streamdown`),require(`nanoid`),require(`shiki`),require(`@radix-ui/react-use-controllable-state`),require(`motion/react`),require(`@object-ui/core`)):typeof define==`function`&&define.amd?define([`exports`,`react`,`@object-ui/components`,`lucide-react`,`react/jsx-runtime`,`@ai-sdk/react`,`ai`,`react-dom`,`@object-ui/react`,`use-stick-to-bottom`,`class-variance-authority`,`@radix-ui/react-slot`,`streamdown`,`nanoid`,`shiki`,`@radix-ui/react-use-controllable-state`,`motion/react`,`@object-ui/core`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.ObjectUIPluginChatbot={},e.React,e.ObjectUIComponents,e.LucideReact,e.react_jsx_runtime,e._ai_sdk_react,e.ai,e.ReactDOM,e.ObjectUIReact,e.use_stick_to_bottom,e.class_variance_authority,e._radix_ui_react_slot,e.streamdown,e.nanoid,e.shiki,e._radix_ui_react_use_controllable_state,e.motion_react,e.ObjectUICore))})(this,function(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var v=Object.create,y=Object.defineProperty,b=Object.getOwnPropertyDescriptor,x=Object.getOwnPropertyNames,S=Object.getPrototypeOf,C=Object.prototype.hasOwnProperty,w=(e,t)=>{let n={};for(var r in e)y(n,r,{get:e[r],enumerable:!0});return t||y(n,Symbol.toStringTag,{value:`Module`}),n},T=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=x(t),a=0,o=i.length,s;a<o;a++)s=i[a],!C.call(e,s)&&s!==n&&y(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=b(t,s))||r.enumerable});return e},E=(e,t,n)=>(n=e==null?{}:v(S(e)),T(t||!e||!e.__esModule?y(n,`default`,{value:e,enumerable:!0}):n,e));t=E(t,1),s=E(s,1);function D(e=`msg`){return typeof crypto<`u`&&crypto.randomUUID?crypto.randomUUID():`${e}-${Date.now()}-${Math.random().toString(36).slice(2)}`}function O(e,t){return typeof e.content==`string`?e.content:t.filter(e=>e.type===`text`).map(e=>e.text??``).join(``)}function k(e){let t=e.filter(e=>e.type===`reasoning`||e.type===`reasoning-delta`).map(e=>e.text??``).join(`
2
+ `).trim();return t.length>0?t:void 0}function A(e){return e.filter(e=>e.type===`dynamic-tool`?!0:typeof e.type==`string`&&e.type.startsWith(`tool-`)).map(e=>{let t=e.type===`dynamic-tool`?e.toolName??`tool`:typeof e.type==`string`?e.type.replace(/^tool-/,``):`tool`;return{toolCallId:e.toolCallId??e.id??`${e.type??`tool`}-${Math.random().toString(36).slice(2,8)}`,toolName:t,args:e.input??e.args,result:e.output??e.result,errorText:e.errorText,state:e.state}})}function j(e){let t=e.filter(e=>e.type===`source-url`||e.type===`source`).map(e=>({id:e.id,title:e.title,url:e.url??e.href})).filter(e=>!!e.url);return t.length>0?t:void 0}function M(e,t={}){let n=Array.isArray(e.parts)?e.parts:[],r=A(n),i=Array.isArray(e.toolInvocations)?e.toolInvocations:[];return{id:e.id??`msg-${Math.random().toString(36).slice(2,8)}`,role:e.role??`assistant`,content:O(e,n),reasoning:k(n),toolInvocations:r.length>0?r:i,sources:j(n),streaming:t.streaming}}function N(e,t={}){if(!Array.isArray(e)||e.length===0)return[];let n=e.length-1;return e.map((e,r)=>M(e,{streaming:!!t.isStreaming&&r===n&&e.role===`assistant`}))}function P(e){return(e??[]).map((e,t)=>({id:e.id||`msg-${t}`,role:e.role||`user`,content:e.content||``,timestamp:typeof e.timestamp==`string`?e.timestamp:e.timestamp instanceof Date?e.timestamp.toISOString():void 0,metadata:e.metadata,streaming:e.streaming,toolInvocations:e.toolInvocations}))}function F(e={}){let{api:n,initialMessages:r,conversationId:i,systemPrompt:s,model:c,streamingEnabled:l=!0,headers:u,body:d,maxToolRoundtrips:f=5,onError:p,showTimestamp:m,autoResponse:h,autoResponseText:g,autoResponseDelay:_=1e3,onSend:v}=e,y=(0,t.useRef)(n?`api`:`local`).current===`api`,b=(0,t.useMemo)(()=>P(r).map(e=>({id:e.id,role:e.role,parts:[{type:`text`,text:e.content??``}]})),[]),x=(0,a.useChat)({transport:(0,t.useMemo)(()=>{if(y)return new o.DefaultChatTransport({api:n,headers:{...u},body:{...d,...i?{conversationId:i}:{},...c?{model:c}:{},...s?{systemPrompt:s}:{},...l===void 0?{}:{stream:l}}})},[y,n,u,d,c,s,l,i]),messages:y&&b.length>0?b:void 0,onError:y?e=>{p?.(e)}:void 0}),[S,C]=(0,t.useState)(()=>P(r)),[w,T]=(0,t.useState)(!1),[E,O]=(0,t.useState)(``),[k,A]=(0,t.useState)(``),j=(0,t.useRef)(null);if((0,t.useEffect)(()=>()=>{j.current&&=(clearTimeout(j.current),null)},[]),y){let{messages:e,status:n,error:r,sendMessage:i,regenerate:a,stop:o,setMessages:s}=x,c=n===`submitted`||n===`streaming`,l=N(e,{isStreaming:c}).map((t,n)=>({...t,metadata:e[n]?.metadata}));return{messages:l,isLoading:c,error:r,sendMessage:(0,t.useCallback)(e=>{let t=e.trim();if(!t)return;let n=[...l,{id:D(`msg`),role:`user`,content:t}];i({text:t}),A(``),v?.(t,n)},[i,v,l]),stop:o,reload:a,clear:(0,t.useCallback)(()=>{s([])},[s]),isApiMode:!0,input:k,setInput:A,handleInputChange:(0,t.useCallback)(e=>{A(e.target.value)},[])}}let M=(0,t.useCallback)(()=>{j.current&&=(clearTimeout(j.current),null),T(!1)},[]);return{messages:S,isLoading:w,error:void 0,sendMessage:(0,t.useCallback)(e=>{if(!e.trim())return;let t={id:D(`msg`),role:`user`,content:e.trim(),timestamp:m?new Date().toLocaleTimeString():void 0};C(n=>{let r=[...n,t];return v?.(e.trim(),r),r}),O(``),h&&(T(!0),j.current=setTimeout(()=>{let e={id:D(`msg`),role:`assistant`,content:g||`Thank you for your message!`,timestamp:m?new Date().toLocaleTimeString():void 0};C(t=>[...t,e]),T(!1)},_))},[m,h,g,_,v]),stop:M,reload:(0,t.useCallback)(()=>{},[]),clear:(0,t.useCallback)(()=>{M(),C([])},[M]),isApiMode:!1,input:E,setInput:O,handleInputChange:(0,t.useCallback)(e=>{O(e.target.value)},[])}}function ee(e){return e.filter(e=>typeof e?.name==`string`&&e.name.length>0).map(e=>({name:e.name,label:e.label||e.name,description:e.description,role:e.role,active:e.active!==!1}))}function I(e={}){let{apiBase:n,headers:r,enabled:i=!0,fallback:a=[]}=e,[o,s]=(0,t.useState)(a),[c,l]=(0,t.useState)(!1),[u,d]=(0,t.useState)(void 0),[f,p]=(0,t.useState)(0),m=(0,t.useRef)(r);return m.current=r,(0,t.useEffect)(()=>{if(!i||!n)return;let e=new AbortController,t=!1;l(!0),d(void 0);let r=`${n.replace(/\/$/,``)}/agents`;return fetch(r,{method:`GET`,headers:{Accept:`application/json`,...m.current??{}},credentials:`include`,signal:e.signal}).then(async e=>{if(!e.ok)throw Error(`Failed to load agents (${e.status})`);return e.json()}).then(e=>{if(t)return;let n=ee(Array.isArray(e)?e:e?.agents??[]);s(n.length>0?n:a)}).catch(e=>{t||e.name===`AbortError`||(d(e),s(a))}).finally(()=>{t||l(!1)}),()=>{t=!0,e.abort()}},[n,i,f]),{agents:o,isLoading:c,error:u,refetch:(0,t.useCallback)(()=>p(e=>e+1),[])}}var L=t.createContext(null);function R({defaultOpen:e=!1,children:n}){let[r,a]=t.useState(e),[o,s]=t.useState(!1),c=t.useMemo(()=>({isOpen:r,isFullscreen:o,open:()=>a(!0),close:()=>{a(!1),s(!1)},toggle:()=>a(e=>!e),toggleFullscreen:()=>s(e=>!e)}),[r,o]);return(0,i.jsx)(L.Provider,{value:c,children:n})}function z(){let e=t.useContext(L);if(!e)throw Error(`useFloatingChatbot must be used within a <FloatingChatbotProvider>`);return e}function te(){try{let{t:e}=(0,c.useObjectTranslation)();return(t,n)=>{let r=e(`common.${t}`);return!r||r===`common.${t}`?n:r}}catch{return(e,t)=>t}}function B({position:e=`bottom-right`,size:t=56,className:a}){let{isOpen:o,toggle:s}=z(),c=te();return(0,i.jsx)(n.Button,{onClick:s,className:(0,n.cn)(`fixed z-50 rounded-full shadow-lg transition-transform hover:scale-105`,e===`bottom-right`?`right-6 bottom-20 sm:bottom-6`:`left-6 bottom-20 sm:bottom-6`,a),style:{width:t,height:t},size:`icon`,"aria-label":o?c(`closeChat`,`Close chat`):c(`openChat`,`Open chat`),"data-testid":`floating-chatbot-trigger`,children:o?(0,i.jsx)(r.X,{className:`h-6 w-6`}):(0,i.jsx)(r.MessageCircle,{className:`h-6 w-6`})})}function ne({title:e=`Chat`,position:t=`bottom-right`,width:a=400,height:o=520,children:s,className:c,headerExtra:l}){let{isOpen:u,isFullscreen:d,close:f,toggleFullscreen:p}=z();if(!u)return null;let m=d?{inset:0,width:`100vw`,height:`100vh`}:{width:a,height:o,maxHeight:`calc(100vh - 100px)`};return(0,i.jsxs)(`div`,{className:(0,n.cn)(`fixed z-50 flex flex-col rounded-lg border bg-background shadow-xl overflow-hidden transition-all`,d?`inset-0 rounded-none`:t===`bottom-right`?`right-6 bottom-20`:`left-6 bottom-20`,c),style:m,role:`dialog`,"aria-label":e,"data-testid":`floating-chatbot-panel`,children:[(0,i.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-4 py-2 border-b bg-muted/40`,children:[(0,i.jsx)(`span`,{className:`text-sm font-medium truncate shrink-0`,children:e}),l?(0,i.jsx)(`div`,{className:`flex-1 min-w-0 flex items-center justify-end mr-1`,"data-testid":`floating-chatbot-header-extra`,children:l}):null,(0,i.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,i.jsx)(n.Button,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:p,"aria-label":d?`Exit fullscreen`:`Fullscreen`,"data-testid":`floating-chatbot-fullscreen`,children:d?(0,i.jsx)(r.Minimize2,{className:`h-4 w-4`}):(0,i.jsx)(r.Maximize2,{className:`h-4 w-4`})}),(0,i.jsx)(n.Button,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:f,"aria-label":`Close chat`,"data-testid":`floating-chatbot-close`,children:(0,i.jsx)(r.X,{className:`h-4 w-4`})})]})]}),(0,i.jsx)(`div`,{className:`flex-1 overflow-hidden`,children:s})]})}var re=({className:e,...t})=>(0,i.jsx)(l.StickToBottom,{className:(0,n.cn)(`relative flex-1 overflow-y-hidden`,e),initial:`smooth`,resize:`smooth`,role:`log`,...t}),ie=({className:e,...t})=>(0,i.jsx)(l.StickToBottom.Content,{className:(0,n.cn)(`flex flex-col gap-8 p-4`,e),...t}),ae=({className:e,title:t=`No messages yet`,description:r=`Start a conversation to see messages here`,icon:a,children:o,...s})=>(0,i.jsx)(`div`,{className:(0,n.cn)(`flex size-full flex-col items-center justify-center gap-3 p-8 text-center`,e),...s,children:o??(0,i.jsxs)(i.Fragment,{children:[a&&(0,i.jsx)(`div`,{className:`text-muted-foreground`,children:a}),(0,i.jsxs)(`div`,{className:`space-y-1`,children:[(0,i.jsx)(`h3`,{className:`font-medium text-sm`,children:t}),r&&(0,i.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:r})]})]})}),oe=({className:e,...a})=>{let{isAtBottom:o,scrollToBottom:s}=(0,l.useStickToBottomContext)(),c=(0,t.useCallback)(()=>{s()},[s]);return!o&&(0,i.jsx)(n.Button,{className:(0,n.cn)(`absolute bottom-4 left-[50%] translate-x-[-50%] rounded-full`,e),onClick:c,size:`icon`,type:`button`,variant:`outline`,...a,children:(0,i.jsx)(r.ArrowDownIcon,{className:`size-4`})})},se=(0,u.cva)(`flex w-fit items-stretch has-[>[data-slot=button-group]]:gap-2 [&>*]:focus-visible:relative [&>*]:focus-visible:z-10 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-md [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1`,{variants:{orientation:{horizontal:`[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none`,vertical:`flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none`}},defaultVariants:{orientation:`horizontal`}});function ce({className:e,orientation:t,...r}){return(0,i.jsx)(`div`,{role:`group`,"data-slot":`button-group`,"data-orientation":t,className:(0,n.cn)(se({orientation:t}),e),...r})}function le({className:e,asChild:t=!1,...r}){return(0,i.jsx)(t?d.Slot:`div`,{className:(0,n.cn)(`flex items-center gap-2 rounded-md border bg-muted px-4 text-sm font-medium shadow-xs [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4`,e),...r})}var ue=({className:e,from:t,...r})=>(0,i.jsx)(`div`,{className:(0,n.cn)(`group flex w-full max-w-[95%] flex-col gap-2`,t===`user`?`is-user ml-auto justify-end`:`is-assistant`,e),...r}),de=({children:e,className:t,...r})=>(0,i.jsx)(`div`,{className:(0,n.cn)(`is-user:dark flex w-fit max-w-full min-w-0 flex-col gap-2 overflow-hidden text-sm`,`group-[.is-user]:ml-auto group-[.is-user]:rounded-lg group-[.is-user]:bg-secondary group-[.is-user]:px-4 group-[.is-user]:py-3 group-[.is-user]:text-foreground`,`group-[.is-assistant]:text-foreground`,t),...r,children:e}),fe=({className:e,children:t,...r})=>(0,i.jsx)(`div`,{className:(0,n.cn)(`flex items-center gap-1`,e),...r,children:t}),V=({tooltip:e,children:t,label:r,variant:a=`ghost`,size:o=`icon`,...s})=>{let c=(0,i.jsxs)(n.Button,{size:o,type:`button`,variant:a,...s,children:[t,(0,i.jsx)(`span`,{className:`sr-only`,children:r||e})]});return e?(0,i.jsx)(n.TooltipProvider,{children:(0,i.jsxs)(n.Tooltip,{children:[(0,i.jsx)(n.TooltipTrigger,{asChild:!0,children:c}),(0,i.jsx)(n.TooltipContent,{children:(0,i.jsx)(`p`,{children:e})})]})}):c},pe=(0,t.createContext)(null),H=()=>{let e=(0,t.useContext)(pe);if(!e)throw Error(`MessageBranch components must be used within MessageBranch`);return e},me=({defaultBranch:e=0,onBranchChange:r,className:a,...o})=>{let[s,c]=(0,t.useState)(e),[l,u]=(0,t.useState)([]),d=e=>{c(e),r?.(e)},f={currentBranch:s,totalBranches:l.length,goToPrevious:()=>{d(s>0?s-1:l.length-1)},goToNext:()=>{d(s<l.length-1?s+1:0)},branches:l,setBranches:u};return(0,i.jsx)(pe.Provider,{value:f,children:(0,i.jsx)(`div`,{className:(0,n.cn)(`grid w-full gap-2 [&>div]:pb-0`,a),...o})})},he=({children:e,...r})=>{let{currentBranch:a,setBranches:o,branches:s}=H(),c=Array.isArray(e)?e:[e];return(0,t.useEffect)(()=>{s.length!==c.length&&o(c)},[c,s,o]),c.map((e,t)=>(0,i.jsx)(`div`,{className:(0,n.cn)(`grid gap-2 overflow-hidden [&>div]:pb-0`,t===a?`block`:`hidden`),...r,children:e},e.key))},ge=({className:e,from:t,...n})=>{let{totalBranches:r}=H();return r<=1?null:(0,i.jsx)(ce,{className:`[&>*:not(:first-child)]:rounded-l-md [&>*:not(:last-child)]:rounded-r-md`,orientation:`horizontal`,...n})},_e=({children:e,...t})=>{let{goToPrevious:a,totalBranches:o}=H();return(0,i.jsx)(n.Button,{"aria-label":`Previous branch`,disabled:o<=1,onClick:a,size:`icon`,type:`button`,variant:`ghost`,...t,children:e??(0,i.jsx)(r.ChevronLeftIcon,{size:14})})},ve=({children:e,className:t,...a})=>{let{goToNext:o,totalBranches:s}=H();return(0,i.jsx)(n.Button,{"aria-label":`Next branch`,disabled:s<=1,onClick:o,size:`icon`,type:`button`,variant:`ghost`,...a,children:e??(0,i.jsx)(r.ChevronRightIcon,{size:14})})},ye=({className:e,...t})=>{let{currentBranch:r,totalBranches:a}=H();return(0,i.jsxs)(le,{className:(0,n.cn)(`border-none bg-transparent text-muted-foreground shadow-none`,e),...t,children:[r+1,` of `,a]})},be=(0,t.memo)(({className:e,...t})=>(0,i.jsx)(f.Streamdown,{className:(0,n.cn)(`size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0`,e),...t}),(e,t)=>e.children===t.children);be.displayName=`MessageResponse`;function xe({data:e,className:t,onRemove:a,...o}){let s=e.filename||``,c=(e.mediaType?.startsWith(`image/`)&&e.url?`image`:`file`)==`image`,l=s||(c?`Image`:`Attachment`);return(0,i.jsx)(`div`,{className:(0,n.cn)(`group relative size-24 overflow-hidden rounded-lg`,t),...o,children:c?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(`img`,{alt:s||`attachment`,className:`size-full object-cover`,height:100,src:e.url,width:100}),a&&(0,i.jsxs)(n.Button,{"aria-label":`Remove attachment`,className:`absolute top-2 right-2 size-6 rounded-full bg-background/80 p-0 opacity-0 backdrop-blur-sm transition-opacity hover:bg-background group-hover:opacity-100 [&>svg]:size-3`,onClick:e=>{e.stopPropagation(),a()},type:`button`,variant:`ghost`,children:[(0,i.jsx)(r.XIcon,{}),(0,i.jsx)(`span`,{className:`sr-only`,children:`Remove`})]})]}):(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(n.Tooltip,{children:[(0,i.jsx)(n.TooltipTrigger,{asChild:!0,children:(0,i.jsx)(`div`,{className:`flex size-full shrink-0 items-center justify-center rounded-lg bg-muted text-muted-foreground`,children:(0,i.jsx)(r.PaperclipIcon,{className:`size-4`})})}),(0,i.jsx)(n.TooltipContent,{children:(0,i.jsx)(`p`,{children:l})})]}),a&&(0,i.jsxs)(n.Button,{"aria-label":`Remove attachment`,className:`size-6 shrink-0 rounded-full p-0 opacity-0 transition-opacity hover:bg-accent group-hover:opacity-100 [&>svg]:size-3`,onClick:e=>{e.stopPropagation(),a()},type:`button`,variant:`ghost`,children:[(0,i.jsx)(r.XIcon,{}),(0,i.jsx)(`span`,{className:`sr-only`,children:`Remove`})]})]})})}function Se({children:e,className:t,...r}){return e?(0,i.jsx)(`div`,{className:(0,n.cn)(`ml-auto flex w-fit flex-wrap items-start gap-2`,t),...r,children:e}):null}var Ce=({className:e,children:t,...r})=>(0,i.jsx)(`div`,{className:(0,n.cn)(`mt-4 flex w-full items-center justify-between gap-4`,e),...r,children:t});function we({className:e,...t}){return(0,i.jsx)(`div`,{"data-slot":`input-group`,role:`group`,className:(0,n.cn)(`group/input-group relative flex w-full items-center rounded-md border border-input shadow-xs transition-[color,box-shadow] outline-none dark:bg-input/30`,`h-9 min-w-0 has-[>textarea]:h-auto`,`has-[>[data-align=inline-start]]:[&>input]:pl-2`,`has-[>[data-align=inline-end]]:[&>input]:pr-2`,`has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>[data-align=block-start]]:[&>input]:pb-3`,`has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-end]]:[&>input]:pt-3`,`has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-[3px] has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50`,`has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-destructive/20 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40`,e),...t})}var Te=(0,u.cva)(`flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium text-muted-foreground select-none group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4`,{variants:{align:{"inline-start":`order-first pl-3 has-[>button]:ml-[-0.45rem] has-[>kbd]:ml-[-0.35rem]`,"inline-end":`order-last pr-3 has-[>button]:mr-[-0.45rem] has-[>kbd]:mr-[-0.35rem]`,"block-start":`order-first w-full justify-start px-3 pt-3 group-has-[>input]/input-group:pt-2.5 [.border-b]:pb-3`,"block-end":`order-last w-full justify-start px-3 pb-3 group-has-[>input]/input-group:pb-2.5 [.border-t]:pt-3`}},defaultVariants:{align:`inline-start`}});function Ee({className:e,align:t=`inline-start`,...r}){return(0,i.jsx)(`div`,{role:`group`,"data-slot":`input-group-addon`,"data-align":t,className:(0,n.cn)(Te({align:t}),e),onClick:e=>{e.target.closest(`button`)||e.currentTarget.parentElement?.querySelector(`input`)?.focus()},...r})}var De=(0,u.cva)(`flex items-center gap-2 text-sm shadow-none`,{variants:{size:{xs:`h-6 gap-1 rounded-[calc(var(--radius)-5px)] px-2 has-[>svg]:px-2 [&>svg:not([class*='size-'])]:size-3.5`,sm:`h-8 gap-1.5 rounded-md px-2.5 has-[>svg]:px-2.5`,"icon-xs":`size-6 rounded-[calc(var(--radius)-5px)] p-0 has-[>svg]:p-0`,"icon-sm":`size-8 p-0 has-[>svg]:p-0`}},defaultVariants:{size:`xs`}});function Oe({className:e,type:t=`button`,variant:r=`ghost`,size:a=`xs`,...o}){return(0,i.jsx)(n.Button,{type:t,"data-size":a,variant:r,className:(0,n.cn)(De({size:a}),e),...o})}function ke({className:e,...t}){return(0,i.jsx)(n.Textarea,{"data-slot":`input-group-control`,className:(0,n.cn)(`flex-1 resize-none rounded-none border-0 bg-transparent py-3 shadow-none focus-visible:ring-0 dark:bg-transparent`,e),...t})}var U=(0,t.createContext)(null),W=(0,t.createContext)(null),Ae=()=>{let e=(0,t.useContext)(U);if(!e)throw Error(`Wrap your component inside <PromptInputProvider> to use usePromptInputController().`);return e},je=()=>(0,t.useContext)(U),Me=()=>{let e=(0,t.useContext)(W);if(!e)throw Error(`Wrap your component inside <PromptInputProvider> to use useProviderAttachments().`);return e},Ne=()=>(0,t.useContext)(W);function Pe({initialInput:e=``,children:n}){let[r,a]=(0,t.useState)(e),o=(0,t.useCallback)(()=>a(``),[]),[s,c]=(0,t.useState)([]),l=(0,t.useRef)(null),u=(0,t.useRef)(()=>{}),d=(0,t.useCallback)(e=>{let t=Array.from(e);t.length!==0&&c(e=>e.concat(t.map(e=>({id:(0,p.nanoid)(),type:`file`,url:URL.createObjectURL(e),mediaType:e.type,filename:e.name}))))},[]),f=(0,t.useCallback)(e=>{c(t=>{let n=t.find(t=>t.id===e);return n?.url&&URL.revokeObjectURL(n.url),t.filter(t=>t.id!==e)})},[]),m=(0,t.useCallback)(()=>{c(e=>{for(let t of e)t.url&&URL.revokeObjectURL(t.url);return[]})},[]),h=(0,t.useRef)(s);h.current=s,(0,t.useEffect)(()=>()=>{for(let e of h.current)e.url&&URL.revokeObjectURL(e.url)},[]);let g=(0,t.useCallback)(()=>{u.current?.()},[]),_=(0,t.useMemo)(()=>({files:s,add:d,remove:f,clear:m,openFileDialog:g,fileInputRef:l}),[s,d,f,m,g]),v=(0,t.useCallback)((e,t)=>{l.current=e.current,u.current=t},[]),y=(0,t.useMemo)(()=>({textInput:{value:r,setInput:a,clear:o},attachments:_,__registerFileInput:v}),[r,o,_,v]);return(0,i.jsx)(U.Provider,{value:y,children:(0,i.jsx)(W.Provider,{value:_,children:n})})}var Fe=(0,t.createContext)(null),G=()=>{let e=Ne(),n=(0,t.useContext)(Fe),r=e??n;if(!r)throw Error(`usePromptInputAttachments must be used within a PromptInput or PromptInputProvider`);return r};function Ie({data:e,className:t,...a}){let o=G(),s=e.filename||``,c=(e.mediaType?.startsWith(`image/`)&&e.url?`image`:`file`)==`image`,l=s||(c?`Image`:`Attachment`);return(0,i.jsxs)(nt,{children:[(0,i.jsx)(n.HoverCardTrigger,{asChild:!0,children:(0,i.jsxs)(`div`,{className:(0,n.cn)(`group relative flex h-8 cursor-pointer select-none items-center gap-1.5 rounded-md border border-border px-1.5 font-medium text-sm transition-all hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50`,t),...a,children:[(0,i.jsxs)(`div`,{className:`relative size-5 shrink-0`,children:[(0,i.jsx)(`div`,{className:`absolute inset-0 flex size-5 items-center justify-center overflow-hidden rounded bg-background transition-opacity group-hover:opacity-0`,children:c?(0,i.jsx)(`img`,{alt:s||`attachment`,className:`size-5 object-cover`,height:20,src:e.url,width:20}):(0,i.jsx)(`div`,{className:`flex size-5 items-center justify-center text-muted-foreground`,children:(0,i.jsx)(r.PaperclipIcon,{className:`size-3`})})}),(0,i.jsxs)(n.Button,{"aria-label":`Remove attachment`,className:`absolute inset-0 size-5 cursor-pointer rounded p-0 opacity-0 transition-opacity group-hover:pointer-events-auto group-hover:opacity-100 [&>svg]:size-2.5`,onClick:t=>{t.stopPropagation(),o.remove(e.id)},type:`button`,variant:`ghost`,children:[(0,i.jsx)(r.XIcon,{}),(0,i.jsx)(`span`,{className:`sr-only`,children:`Remove`})]})]}),(0,i.jsx)(`span`,{className:`flex-1 truncate`,children:l})]},e.id)}),(0,i.jsx)(it,{className:`w-auto p-2`,children:(0,i.jsxs)(`div`,{className:`w-auto space-y-3`,children:[c&&(0,i.jsx)(`div`,{className:`flex max-h-96 w-96 items-center justify-center overflow-hidden rounded-md border`,children:(0,i.jsx)(`img`,{alt:s||`attachment preview`,className:`max-h-full max-w-full object-contain`,height:384,src:e.url,width:448})}),(0,i.jsx)(`div`,{className:`flex items-center gap-2.5`,children:(0,i.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1 px-0.5`,children:[(0,i.jsx)(`h4`,{className:`truncate font-semibold text-sm leading-none`,children:s||(c?`Image`:`Attachment`)}),e.mediaType&&(0,i.jsx)(`p`,{className:`truncate font-mono text-muted-foreground text-xs`,children:e.mediaType})]})})]})})]})}function Le({children:e,className:r,...a}){let o=G();return o.files.length?(0,i.jsx)(`div`,{className:(0,n.cn)(`flex flex-wrap items-center gap-2 p-3 w-full`,r),...a,children:o.files.map(n=>(0,i.jsx)(t.Fragment,{children:e(n)},n.id))}):null}var Re=({label:e=`Add photos or files`,...t})=>{let a=G();return(0,i.jsxs)(n.DropdownMenuItem,{...t,onSelect:e=>{e.preventDefault(),a.openFileDialog()},children:[(0,i.jsx)(r.ImageIcon,{className:`mr-2 size-4`}),` `,e]})},ze=({className:e,accept:r,multiple:a,globalDrop:o,syncHiddenInput:s,maxFiles:c,maxFileSize:l,onError:u,onSubmit:d,children:f,...m})=>{let h=je(),g=!!h,_=(0,t.useRef)(null),v=(0,t.useRef)(null),[y,b]=(0,t.useState)([]),x=g?h.attachments.files:y,S=(0,t.useRef)(x);S.current=x;let C=(0,t.useCallback)(()=>{_.current?.click()},[]),w=(0,t.useCallback)(e=>!r||r.trim()===``?!0:r.split(`,`).map(e=>e.trim()).filter(Boolean).some(t=>{if(t.endsWith(`/*`)){let n=t.slice(0,-1);return e.type.startsWith(n)}return e.type===t}),[r]),T=(0,t.useCallback)(e=>{let t=Array.from(e),n=t.filter(e=>w(e));if(t.length&&n.length===0){u?.({code:`accept`,message:`No files match the accepted types.`});return}let r=n.filter(e=>l?e.size<=l:!0);if(n.length>0&&r.length===0){u?.({code:`max_file_size`,message:`All files exceed the maximum size.`});return}b(e=>{let t=typeof c==`number`?Math.max(0,c-e.length):void 0,n=typeof t==`number`?r.slice(0,t):r;typeof t==`number`&&r.length>t&&u?.({code:`max_files`,message:`Too many files. Some were not added.`});let i=[];for(let e of n)i.push({id:(0,p.nanoid)(),type:`file`,url:URL.createObjectURL(e),mediaType:e.type,filename:e.name});return e.concat(i)})},[w,c,l,u]),E=(0,t.useCallback)(e=>b(t=>{let n=t.find(t=>t.id===e);return n?.url&&URL.revokeObjectURL(n.url),t.filter(t=>t.id!==e)}),[]),D=(0,t.useCallback)(()=>b(e=>{for(let t of e)t.url&&URL.revokeObjectURL(t.url);return[]}),[]),O=g?h.attachments.add:T,k=g?h.attachments.remove:E,A=g?h.attachments.clear:D,j=g?h.attachments.openFileDialog:C;(0,t.useEffect)(()=>{g&&h.__registerFileInput(_,()=>_.current?.click())},[g,h]),(0,t.useEffect)(()=>{s&&_.current&&x.length===0&&(_.current.value=``)},[x,s]),(0,t.useEffect)(()=>{let e=v.current;if(!e||o)return;let t=e=>{e.dataTransfer?.types?.includes(`Files`)&&e.preventDefault()},n=e=>{e.dataTransfer?.types?.includes(`Files`)&&e.preventDefault(),e.dataTransfer?.files&&e.dataTransfer.files.length>0&&O(e.dataTransfer.files)};return e.addEventListener(`dragover`,t),e.addEventListener(`drop`,n),()=>{e.removeEventListener(`dragover`,t),e.removeEventListener(`drop`,n)}},[O,o]),(0,t.useEffect)(()=>{if(!o)return;let e=e=>{e.dataTransfer?.types?.includes(`Files`)&&e.preventDefault()},t=e=>{e.dataTransfer?.types?.includes(`Files`)&&e.preventDefault(),e.dataTransfer?.files&&e.dataTransfer.files.length>0&&O(e.dataTransfer.files)};return document.addEventListener(`dragover`,e),document.addEventListener(`drop`,t),()=>{document.removeEventListener(`dragover`,e),document.removeEventListener(`drop`,t)}},[O,o]),(0,t.useEffect)(()=>()=>{if(!g)for(let e of S.current)e.url&&URL.revokeObjectURL(e.url)},[g]);let M=e=>{e.currentTarget.files&&O(e.currentTarget.files),e.currentTarget.value=``},N=async e=>{try{let t=await(await fetch(e)).blob();return new Promise(e=>{let n=new FileReader;n.onloadend=()=>e(n.result),n.onerror=()=>e(null),n.readAsDataURL(t)})}catch{return null}},P=(0,t.useMemo)(()=>({files:x.map(e=>({...e,id:e.id})),add:O,remove:k,clear:A,openFileDialog:j,fileInputRef:_}),[x,O,k,A,j]),F=(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(`input`,{accept:r,"aria-label":`Upload files`,className:`hidden`,multiple:a,onChange:M,ref:_,title:`Upload files`,type:`file`}),(0,i.jsx)(`form`,{className:(0,n.cn)(`w-full`,e),onSubmit:e=>{e.preventDefault();let t=e.currentTarget,n=g?h.textInput.value:new FormData(t).get(`message`)||``;g||t.reset(),Promise.all(x.map(async({id:e,...t})=>{if(t.url&&t.url.startsWith(`blob:`)){let e=await N(t.url);return{...t,url:e??t.url}}return t})).then(t=>{try{let r=d({text:n,files:t},e);r instanceof Promise?r.then(()=>{A(),g&&h.textInput.clear()}).catch(()=>{}):(A(),g&&h.textInput.clear())}catch{}}).catch(()=>{})},ref:v,...m,children:(0,i.jsx)(we,{className:`overflow-hidden`,children:f})})]});return g?F:(0,i.jsx)(Fe.Provider,{value:P,children:F})},Be=({className:e,...t})=>(0,i.jsx)(`div`,{className:(0,n.cn)(`contents`,e),...t}),Ve=({onChange:e,className:r,placeholder:a=`What would you like to know?`,...o})=>{let s=je(),c=G(),[l,u]=(0,t.useState)(!1),d=e=>{if(e.key===`Enter`){if(l||e.nativeEvent.isComposing||e.shiftKey)return;e.preventDefault();let t=e.currentTarget.form;if(t?.querySelector(`button[type="submit"]`)?.disabled)return;t?.requestSubmit()}if(e.key===`Backspace`&&e.currentTarget.value===``&&c.files.length>0){e.preventDefault();let t=c.files[c.files.length-1];t&&c.remove(t.id)}},f=e=>{let t=e.clipboardData?.items;if(!t)return;let n=[];for(let e of t)if(e.kind===`file`){let t=e.getAsFile();t&&n.push(t)}n.length>0&&(e.preventDefault(),c.add(n))},p=s?{value:s.textInput.value,onChange:t=>{s.textInput.setInput(t.currentTarget.value),e?.(t)}}:{onChange:e};return(0,i.jsx)(ke,{className:(0,n.cn)(`field-sizing-content max-h-48 min-h-16`,r),name:`message`,onCompositionEnd:()=>u(!1),onCompositionStart:()=>u(!0),onKeyDown:d,onPaste:f,placeholder:a,...o,...p})},He=({className:e,...t})=>(0,i.jsx)(Ee,{align:`block-end`,className:(0,n.cn)(`order-first flex-wrap gap-1`,e),...t}),Ue=({className:e,...t})=>(0,i.jsx)(Ee,{align:`block-end`,className:(0,n.cn)(`justify-between gap-1`,e),...t}),We=({className:e,...t})=>(0,i.jsx)(`div`,{className:(0,n.cn)(`flex items-center gap-1`,e),...t}),K=({variant:e=`ghost`,className:r,size:a,...o})=>{let s=a??(t.Children.count(o.children)>1?`sm`:`icon-sm`);return(0,i.jsx)(Oe,{className:(0,n.cn)(r),size:s,type:`button`,variant:e,...o})},Ge=e=>(0,i.jsx)(n.DropdownMenu,{...e}),Ke=({className:e,children:t,...a})=>(0,i.jsx)(n.DropdownMenuTrigger,{asChild:!0,children:(0,i.jsx)(K,{className:e,...a,children:t??(0,i.jsx)(r.PlusIcon,{className:`size-4`})})}),qe=({className:e,...t})=>(0,i.jsx)(n.DropdownMenuContent,{align:`start`,className:(0,n.cn)(e),...t}),Je=({className:e,...t})=>(0,i.jsx)(n.DropdownMenuItem,{className:(0,n.cn)(e),...t}),Ye=({className:e,variant:t=`default`,size:a=`icon-sm`,status:o,children:s,...c})=>{let l=(0,i.jsx)(r.CornerDownLeftIcon,{className:`size-4`});return o===`submitted`?l=(0,i.jsx)(r.Loader2Icon,{className:`size-4 animate-spin`}):o===`streaming`?l=(0,i.jsx)(r.SquareIcon,{className:`size-4`}):o===`error`&&(l=(0,i.jsx)(r.XIcon,{className:`size-4`})),(0,i.jsx)(Oe,{"aria-label":`Submit`,className:(0,n.cn)(e),size:a,type:`submit`,variant:t,...c,children:s??l})},Xe=({className:e,textareaRef:a,onTranscriptionChange:o,...s})=>{let[c,l]=(0,t.useState)(!1),[u,d]=(0,t.useState)(null),f=(0,t.useRef)(null);(0,t.useEffect)(()=>{if(typeof window<`u`&&(`SpeechRecognition`in window||`webkitSpeechRecognition`in window)){let e=new(window.SpeechRecognition||window.webkitSpeechRecognition);e.continuous=!0,e.interimResults=!0,e.lang=`en-US`,e.onstart=()=>{l(!0)},e.onend=()=>{l(!1)},e.onresult=e=>{let t=``;for(let n=e.resultIndex;n<e.results.length;n++){let r=e.results[n];r.isFinal&&(t+=r[0]?.transcript??``)}if(t&&a?.current){let e=a.current,n=e.value,r=n+(n?` `:``)+t;e.value=r,e.dispatchEvent(new Event(`input`,{bubbles:!0})),o?.(r)}},e.onerror=e=>{console.error(`Speech recognition error:`,e.error),l(!1)},f.current=e,d(e)}return()=>{f.current&&f.current.stop()}},[a,o]);let p=(0,t.useCallback)(()=>{u&&(c?u.stop():u.start())},[u,c]);return(0,i.jsx)(K,{className:(0,n.cn)(`relative transition-all duration-200`,c&&`animate-pulse bg-accent text-accent-foreground`,e),disabled:!u,onClick:p,...s,children:(0,i.jsx)(r.MicIcon,{className:`size-4`})})},Ze=e=>(0,i.jsx)(n.Select,{...e}),Qe=({className:e,...t})=>(0,i.jsx)(n.SelectTrigger,{className:(0,n.cn)(`border-none bg-transparent font-medium text-muted-foreground shadow-none transition-colors`,`hover:bg-accent hover:text-foreground aria-expanded:bg-accent aria-expanded:text-foreground`,e),...t}),$e=({className:e,...t})=>(0,i.jsx)(n.SelectContent,{className:(0,n.cn)(e),...t}),et=({className:e,...t})=>(0,i.jsx)(n.SelectItem,{className:(0,n.cn)(e),...t}),tt=({className:e,...t})=>(0,i.jsx)(n.SelectValue,{className:(0,n.cn)(e),...t}),nt=({openDelay:e=0,closeDelay:t=0,...r})=>(0,i.jsx)(n.HoverCard,{closeDelay:t,openDelay:e,...r}),rt=e=>(0,i.jsx)(n.HoverCardTrigger,{...e}),it=({align:e=`start`,...t})=>(0,i.jsx)(n.HoverCardContent,{align:e,...t}),at=({className:e,...t})=>(0,i.jsx)(`div`,{className:(0,n.cn)(e),...t}),ot=({className:e,...t})=>(0,i.jsx)(`div`,{className:(0,n.cn)(e),...t}),st=({className:e,...t})=>(0,i.jsx)(`h3`,{className:(0,n.cn)(`mb-2 px-3 font-medium text-muted-foreground text-xs`,e),...t}),ct=({className:e,...t})=>(0,i.jsx)(`div`,{className:(0,n.cn)(`space-y-1`,e),...t}),lt=({className:e,...t})=>(0,i.jsx)(`div`,{className:(0,n.cn)(`flex items-center gap-2 px-3 py-2 text-xs hover:bg-accent`,e),...t}),ut=({className:e,...t})=>(0,i.jsx)(n.Command,{className:(0,n.cn)(e),...t}),dt=({className:e,...t})=>(0,i.jsx)(n.CommandInput,{className:(0,n.cn)(e),...t}),ft=({className:e,...t})=>(0,i.jsx)(n.CommandList,{className:(0,n.cn)(e),...t}),pt=({className:e,...t})=>(0,i.jsx)(n.CommandEmpty,{className:(0,n.cn)(e),...t}),mt=({className:e,...t})=>(0,i.jsx)(n.CommandGroup,{className:(0,n.cn)(e),...t}),ht=({className:e,...t})=>(0,i.jsx)(n.CommandItem,{className:(0,n.cn)(e),...t}),gt=({className:e,...t})=>(0,i.jsx)(n.CommandSeparator,{className:(0,n.cn)(e),...t}),_t=({className:e,children:t,...r})=>(0,i.jsxs)(n.ScrollArea,{className:`w-full overflow-x-auto whitespace-nowrap`,...r,children:[(0,i.jsx)(`div`,{className:(0,n.cn)(`flex w-max flex-nowrap items-center gap-2`,e),children:t}),(0,i.jsx)(n.ScrollBar,{className:`hidden`,orientation:`horizontal`})]}),vt=({suggestion:e,onClick:t,className:r,variant:a=`outline`,size:o=`sm`,children:s,...c})=>(0,i.jsx)(n.Button,{className:(0,n.cn)(`cursor-pointer rounded-full px-4`,r),onClick:()=>{t?.(e)},size:o,type:`button`,variant:a,...c,children:s||e}),yt=(0,t.createContext)({code:``}),bt={name:`line-numbers`,line(e,t){e.children.unshift({type:`element`,tagName:`span`,properties:{className:[`inline-block`,`min-w-10`,`mr-4`,`text-right`,`select-none`,`text-muted-foreground`]},children:[{type:`text`,value:String(t)}]})}};async function xt(e,t,n=!1){let r=n?[bt]:[];return await Promise.all([(0,m.codeToHtml)(e,{lang:t,theme:`one-light`,transformers:r}),(0,m.codeToHtml)(e,{lang:t,theme:`one-dark-pro`,transformers:r})])}var q=({code:e,language:r,showLineNumbers:a=!1,className:o,children:s,...c})=>{let[l,u]=(0,t.useState)(``),[d,f]=(0,t.useState)(``),p=(0,t.useRef)(!1);return(0,t.useEffect)(()=>(xt(e,r,a).then(([e,t])=>{p.current||=(u(e),f(t),!0)}),()=>{p.current=!1}),[e,r,a]),(0,i.jsx)(yt.Provider,{value:{code:e},children:(0,i.jsx)(`div`,{className:(0,n.cn)(`group relative w-full overflow-hidden rounded-md border bg-background text-foreground`,o),...c,children:(0,i.jsxs)(`div`,{className:`relative`,children:[(0,i.jsx)(`div`,{className:`overflow-auto dark:hidden [&>pre]:m-0 [&>pre]:bg-background! [&>pre]:p-4 [&>pre]:text-foreground! [&>pre]:text-sm [&_code]:font-mono [&_code]:text-sm`,dangerouslySetInnerHTML:{__html:l}}),(0,i.jsx)(`div`,{className:`hidden overflow-auto dark:block [&>pre]:m-0 [&>pre]:bg-background! [&>pre]:p-4 [&>pre]:text-foreground! [&>pre]:text-sm [&_code]:font-mono [&_code]:text-sm`,dangerouslySetInnerHTML:{__html:d}}),s&&(0,i.jsx)(`div`,{className:`absolute top-2 right-2 flex items-center gap-2`,children:s})]})})})},St=({onCopy:e,onError:a,timeout:o=2e3,children:s,className:c,...l})=>{let[u,d]=(0,t.useState)(!1),{code:f}=(0,t.useContext)(yt),p=async()=>{if(typeof window>`u`||!navigator?.clipboard?.writeText){a?.(Error(`Clipboard API not available`));return}try{await navigator.clipboard.writeText(f),d(!0),e?.(),setTimeout(()=>d(!1),o)}catch(e){a?.(e)}},m=u?r.CheckIcon:r.CopyIcon;return(0,i.jsx)(n.Button,{className:(0,n.cn)(`shrink-0`,c),onClick:p,size:`icon`,variant:`ghost`,...l,children:s??(0,i.jsx)(m,{size:14})})},Ct=({className:e,...t})=>(0,i.jsx)(n.Collapsible,{className:(0,n.cn)(`not-prose mb-4 w-full rounded-md border`,e),...t}),wt=e=>(0,i.jsxs)(n.Badge,{className:`gap-1.5 rounded-full text-xs`,variant:`secondary`,children:[{"input-streaming":(0,i.jsx)(r.CircleIcon,{className:`size-4`}),"input-available":(0,i.jsx)(r.ClockIcon,{className:`size-4 animate-pulse`}),"approval-requested":(0,i.jsx)(r.ClockIcon,{className:`size-4 text-yellow-600`}),"approval-responded":(0,i.jsx)(r.CheckCircleIcon,{className:`size-4 text-blue-600`}),"output-available":(0,i.jsx)(r.CheckCircleIcon,{className:`size-4 text-green-600`}),"output-error":(0,i.jsx)(r.XCircleIcon,{className:`size-4 text-red-600`}),"output-denied":(0,i.jsx)(r.XCircleIcon,{className:`size-4 text-orange-600`})}[e],{"input-streaming":`Pending`,"input-available":`Running`,"approval-requested":`Awaiting Approval`,"approval-responded":`Responded`,"output-available":`Completed`,"output-error":`Error`,"output-denied":`Denied`}[e]]}),Tt=({className:e,title:t,type:a,state:o,...s})=>(0,i.jsxs)(n.CollapsibleTrigger,{className:(0,n.cn)(`flex w-full items-center justify-between gap-4 p-3`,e),...s,children:[(0,i.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,i.jsx)(r.WrenchIcon,{className:`size-4 text-muted-foreground`}),(0,i.jsx)(`span`,{className:`font-medium text-sm`,children:t??a.split(`-`).slice(1).join(`-`)}),wt(o)]}),(0,i.jsx)(r.ChevronDownIcon,{className:`size-4 text-muted-foreground transition-transform group-data-[state=open]:rotate-180`})]}),Et=({className:e,...t})=>(0,i.jsx)(n.CollapsibleContent,{className:(0,n.cn)(`data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-popover-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in`,e),...t}),Dt=({className:e,input:t,...r})=>(0,i.jsxs)(`div`,{className:(0,n.cn)(`space-y-2 overflow-hidden p-4`,e),...r,children:[(0,i.jsx)(`h4`,{className:`font-medium text-muted-foreground text-xs uppercase tracking-wide`,children:`Parameters`}),(0,i.jsx)(`div`,{className:`rounded-md bg-muted/50`,children:(0,i.jsx)(q,{code:JSON.stringify(t,null,2),language:`json`})})]}),Ot=({className:e,output:r,errorText:a,...o})=>{if(!(r||a))return null;let s=(0,i.jsx)(`div`,{children:r});return typeof r==`object`&&!(0,t.isValidElement)(r)?s=(0,i.jsx)(q,{code:JSON.stringify(r,null,2),language:`json`}):typeof r==`string`&&(s=(0,i.jsx)(q,{code:r,language:`json`})),(0,i.jsxs)(`div`,{className:(0,n.cn)(`space-y-2 p-4`,e),...o,children:[(0,i.jsx)(`h4`,{className:`font-medium text-muted-foreground text-xs uppercase tracking-wide`,children:a?`Error`:`Result`}),(0,i.jsxs)(`div`,{className:(0,n.cn)(`overflow-x-auto rounded-md text-xs [&_table]:w-full`,a?`bg-destructive/10 text-destructive`:`bg-muted/50 text-foreground`),children:[a&&(0,i.jsx)(`div`,{children:a}),s]})]})},kt=(0,t.memo)(({children:e,as:r=`p`,className:a,duration:o=2,spread:s=2})=>{let c=g.motion.create(r),l=(0,t.useMemo)(()=>(e?.length??0)*s,[e,s]);return(0,i.jsx)(c,{animate:{backgroundPosition:`0% center`},className:(0,n.cn)(`relative inline-block bg-[length:250%_100%,auto] bg-clip-text text-transparent`,`[--bg:linear-gradient(90deg,#0000_calc(50%-var(--spread)),var(--color-background),#0000_calc(50%+var(--spread)))] [background-repeat:no-repeat,padding-box]`,a),initial:{backgroundPosition:`100% center`},style:{"--spread":`${l}px`,backgroundImage:`var(--bg), linear-gradient(var(--color-muted-foreground), var(--color-muted-foreground))`},transition:{repeat:1/0,duration:o,ease:`linear`},children:e})}),At=(0,t.createContext)(null),jt=()=>{let e=(0,t.useContext)(At);if(!e)throw Error(`Reasoning components must be used within Reasoning`);return e},Mt=1e3,Nt=1e3,J=(0,t.memo)(({className:e,isStreaming:r=!1,open:a,defaultOpen:o=!0,onOpenChange:s,duration:c,children:l,...u})=>{let[d,f]=(0,h.useControllableState)({prop:a,defaultProp:o,onChange:s}),[p,m]=(0,h.useControllableState)({prop:c,defaultProp:void 0}),[g,_]=(0,t.useState)(!1),[v,y]=(0,t.useState)(null);return(0,t.useEffect)(()=>{r?v===null&&y(Date.now()):v!==null&&(m(Math.ceil((Date.now()-v)/Nt)),y(null))},[r,v,m]),(0,t.useEffect)(()=>{if(o&&!r&&d&&!g){let e=setTimeout(()=>{f(!1),_(!0)},Mt);return()=>clearTimeout(e)}},[r,d,o,f,g]),(0,i.jsx)(At.Provider,{value:{isStreaming:r,isOpen:d,setIsOpen:f,duration:p},children:(0,i.jsx)(n.Collapsible,{className:(0,n.cn)(`not-prose mb-4`,e),onOpenChange:e=>{f(e)},open:d,...u,children:l})})}),Pt=(e,t)=>e||t===0?(0,i.jsx)(kt,{duration:1,children:`Thinking...`}):t===void 0?(0,i.jsx)(`p`,{children:`Thought for a few seconds`}):(0,i.jsxs)(`p`,{children:[`Thought for `,t,` seconds`]}),Y=(0,t.memo)(({className:e,children:t,getThinkingMessage:a=Pt,...o})=>{let{isStreaming:s,isOpen:c,duration:l}=jt();return(0,i.jsx)(n.CollapsibleTrigger,{className:(0,n.cn)(`flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground`,e),...o,children:t??(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(r.BrainIcon,{className:`size-4`}),a(s,l),(0,i.jsx)(r.ChevronDownIcon,{className:(0,n.cn)(`size-4 transition-transform`,c?`rotate-180`:`rotate-0`)})]})})}),X=(0,t.memo)(({className:e,children:t,...r})=>(0,i.jsx)(n.CollapsibleContent,{className:(0,n.cn)(`mt-4 text-sm`,`data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-muted-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in`,e),...r,children:(0,i.jsx)(f.Streamdown,{...r,children:t})}));J.displayName=`Reasoning`,Y.displayName=`ReasoningTrigger`,X.displayName=`ReasoningContent`;var Ft=({className:e,...t})=>(0,i.jsx)(n.Collapsible,{className:(0,n.cn)(`not-prose mb-4 text-primary text-xs`,e),...t}),Z=({className:e,count:t,children:a,...o})=>(0,i.jsx)(n.CollapsibleTrigger,{className:(0,n.cn)(`flex items-center gap-2`,e),...o,children:a??(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(`p`,{className:`font-medium`,children:[`Used `,t,` sources`]}),(0,i.jsx)(r.ChevronDownIcon,{className:`h-4 w-4`})]})}),It=({className:e,...t})=>(0,i.jsx)(n.CollapsibleContent,{className:(0,n.cn)(`mt-3 flex w-fit flex-col gap-2`,`data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 outline-none data-[state=closed]:animate-out data-[state=open]:animate-in`,e),...t}),Lt=({href:e,title:t,children:n,...a})=>(0,i.jsx)(`a`,{className:`flex items-center gap-2`,href:e,rel:`noreferrer`,target:`_blank`,...a,children:n??(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(r.BookIcon,{className:`h-4 w-4`}),(0,i.jsx)(`span`,{className:`block font-medium`,children:t})]})});function Rt(e,t){return t?`error`:e?`streaming`:`ready`}function zt(e){return e===`user`?`user`:`assistant`}var Q=t.forwardRef(({className:e,messages:a=[],placeholder:o=`Type your message...`,onSendMessage:s,onClear:c,onStop:l,onReload:u,disabled:d=!1,isLoading:f=!1,error:p,showTimestamp:m=!1,userAvatarUrl:h,userAvatarFallback:g=`You`,assistantAvatarUrl:_,assistantAvatarFallback:v=`AI`,maxHeight:y=`500px`,enableMarkdown:b=!0,enableFileUpload:x=!1,acceptedFileTypes:S=`image/*,.pdf,.doc,.docx,.txt`,maxFileSize:C=10*1024*1024,suggestions:w,models:T,selectedModelId:E,onModelChange:D,headerSlot:O,promptOverlaySlot:k,onInputChange:A,onToolApprove:j,toolApproveLabel:M=`Approve`,toolDenyLabel:N=`Deny`,toolDenyReason:P=`User denied the operation`,...F},ee)=>{let I=Rt(f,p),[L,R]=t.useState(null),z=t.useCallback(e=>{let t=!!e.text?.trim(),n=e.files?.map(e=>e.file).filter(Boolean),r=!!(n&&n.length>0);(t||r)&&s?.(e.text?.trim()??``,n)},[s]),te=t.useCallback(e=>{s?.(e)},[s]),B=t.useCallback(e=>{navigator.clipboard?.writeText(e.content),R(e.id),window.setTimeout(()=>R(t=>t===e.id?null:t),1500)},[]);return(0,i.jsxs)(`div`,{ref:ee,className:(0,n.cn)(`flex flex-col border rounded-lg bg-background overflow-hidden`,e),style:{maxHeight:y},...F,children:[c&&a.length>0&&(0,i.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2 border-b bg-muted/30`,children:[(0,i.jsxs)(`span`,{className:`text-sm text-muted-foreground`,children:[a.length,` message`,a.length===1?``:`s`]}),(0,i.jsx)(`button`,{type:`button`,onClick:c,className:`text-xs text-muted-foreground hover:text-foreground transition-colors`,children:`Clear`})]}),O?(0,i.jsx)(`div`,{className:`shrink-0 border-b bg-background/50`,children:O}):null,(0,i.jsxs)(re,{className:`flex-1 min-h-0`,children:[(0,i.jsx)(ie,{className:`space-y-4 px-4 py-3`,children:a.length===0?(0,i.jsx)(ae,{title:`Start a conversation`,description:`Ask anything — the assistant has access to your current app context.`,children:w&&w.length>0?(0,i.jsx)(_t,{className:`justify-center pt-2`,children:w.map(e=>(0,i.jsx)(vt,{suggestion:e,onClick:te},e))}):null}):a.map(e=>{let t=e.role===`user`,n=e.toolInvocations??[],a=e.reasoning?.trim(),o=e.sources??[];return(0,i.jsxs)(ue,{from:zt(e.role),children:[(0,i.jsxs)(de,{children:[!t&&a?(0,i.jsxs)(J,{isStreaming:!!e.streaming&&!e.content,className:`mb-2`,children:[(0,i.jsx)(Y,{}),(0,i.jsx)(X,{children:a})]}):null,!t&&n.length>0?n.map(e=>{let t=e.state??(e.errorText?`output-error`:e.result===void 0?`input-available`:`output-available`),n=`tool-${e.toolName}`,r=t===`approval-requested`&&!!j;return(0,i.jsxs)(Ct,{defaultOpen:t!==`output-available`,children:[(0,i.jsx)(Tt,{type:n,state:t,title:e.toolName}),(0,i.jsxs)(Et,{children:[e.args===void 0?null:(0,i.jsx)(Dt,{input:e.args}),(0,i.jsx)(Ot,{output:e.result,errorText:e.errorText}),r?(0,i.jsxs)(`div`,{className:`flex gap-2 p-3 border-t bg-muted/30`,children:[(0,i.jsx)(`button`,{type:`button`,onClick:()=>j?.(e.toolCallId,!0),className:`inline-flex h-7 items-center rounded-md bg-primary px-3 text-xs font-medium text-primary-foreground hover:bg-primary/90`,children:M}),(0,i.jsx)(`button`,{type:`button`,onClick:()=>j?.(e.toolCallId,!1,P),className:`inline-flex h-7 items-center rounded-md border bg-background px-3 text-xs font-medium hover:bg-accent`,children:N})]}):null]})]},e.toolCallId)}):null,e.content,e.streaming?(0,i.jsx)(`span`,{"aria-hidden":!0,className:`ml-0.5 inline-block w-[2px] h-4 align-middle bg-current animate-pulse`}):null,!t&&o.length>0?(0,i.jsxs)(Ft,{children:[(0,i.jsx)(Z,{count:o.length}),(0,i.jsx)(It,{children:o.map((e,t)=>(0,i.jsx)(Lt,{href:e.url,title:e.title??e.url},e.id??e.url??t))})]}):null,m&&e.timestamp?(0,i.jsx)(`div`,{className:`text-[10px] opacity-70 mt-1`,children:e.timestamp}):null]}),t?null:(0,i.jsxs)(fe,{children:[(0,i.jsx)(V,{label:`Copy`,tooltip:`Copy`,onClick:()=>B(e),children:L===e.id?(0,i.jsx)(r.Check,{className:`size-3.5`}):(0,i.jsx)(r.Copy,{className:`size-3.5`})}),u?(0,i.jsx)(V,{label:`Regenerate`,tooltip:`Regenerate`,onClick:u,children:(0,i.jsx)(r.RefreshCw,{className:`size-3.5`})}):null,e.traceId?(0,i.jsx)(`a`,{href:`#trace/${e.traceId}`,"data-trace-id":e.traceId,className:`text-[10px] text-muted-foreground hover:text-foreground ml-1 underline`,title:`View trace`,children:`trace`}):null]})]},e.id)})}),(0,i.jsx)(oe,{})]}),p?(0,i.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-2 border-t bg-destructive/10 text-destructive text-sm`,role:`alert`,children:[(0,i.jsx)(r.AlertCircle,{className:`h-4 w-4 shrink-0`}),(0,i.jsx)(`span`,{className:`flex-1 truncate`,children:p.message||`An error occurred`}),u?(0,i.jsx)(`button`,{type:`button`,onClick:u,className:`text-xs underline hover:no-underline`,children:`Retry`}):null]}):null,(0,i.jsxs)(`div`,{className:`relative`,children:[k?(0,i.jsx)(`div`,{className:`absolute bottom-full left-0 right-0 z-10 px-3 pb-1`,children:k}):null,(0,i.jsxs)(ze,{accept:S,maxFileSize:C,onSubmit:z,onError:e=>{console.warn(`[plugin-chatbot] prompt-input error`,e)},children:[x?(0,i.jsx)(Be,{children:(0,i.jsx)(Le,{children:e=>(0,i.jsx)(Ie,{data:e})})}):null,(0,i.jsx)(Ve,{placeholder:o,disabled:d||I===`streaming`,onChange:A?e=>A(e.currentTarget.value):void 0}),(0,i.jsxs)(Ue,{children:[(0,i.jsxs)(We,{children:[x?(0,i.jsxs)(Ge,{children:[(0,i.jsx)(Ke,{}),(0,i.jsx)(qe,{children:(0,i.jsx)(Re,{})})]}):null,T&&T.length>0?(0,i.jsx)(`select`,{"aria-label":`Model`,value:E??T[0].id,onChange:e=>D?.(e.target.value),className:`h-7 rounded-md border bg-background px-2 text-xs text-muted-foreground hover:text-foreground focus:outline-none focus:ring-1 focus:ring-ring`,children:T.map(e=>(0,i.jsxs)(`option`,{value:e.id,children:[e.label??e.id,e.provider?` · ${e.provider}`:``]},e.id))}):null]}),(0,i.jsx)(Ye,{status:I,disabled:d,onClick:I===`streaming`?l:void 0})]})]})]}),(0,i.jsx)(`span`,{hidden:!0,"data-avatar-user":h??g,"data-avatar-assistant":_??v})]})});Q.displayName=`ChatbotEnhanced`;function Bt({floatingConfig:e,headerExtra:n,...r}){let{position:a=`bottom-right`,defaultOpen:o=!1,panelWidth:c=400,panelHeight:l=520,title:u=`Chat`,triggerSize:d=56}=e??{},[f,p]=t.useState(null);t.useEffect(()=>{let e=document.getElementById(`floating-chatbot-portal`);return e||(e=document.createElement(`div`),e.id=`floating-chatbot-portal`,document.body.appendChild(e)),p(e),()=>{e&&e.parentNode&&!e.hasChildNodes()&&e.parentNode.removeChild(e)}},[]);let m=(0,i.jsxs)(R,{defaultOpen:o,children:[(0,i.jsx)(B,{position:a,size:d}),(0,i.jsx)(ne,{title:u,position:a,width:c,height:l,headerExtra:n,children:(0,i.jsx)(Q,{...r,maxHeight:`100%`,className:`h-full border-0 rounded-none`})})]});return f?s.createPortal(m,f):m}_.ComponentRegistry.register(`chatbot`,({schema:e,className:t,...n})=>{let{messages:r,isLoading:a,sendMessage:o}=F({api:e.api,initialMessages:e.messages,conversationId:e.conversationId,systemPrompt:e.systemPrompt,model:e.model,streamingEnabled:e.streamingEnabled,headers:e.headers,body:e.requestBody,maxToolRoundtrips:e.maxToolRoundtrips,onError:e.onError,showTimestamp:e.showTimestamp,autoResponse:e.autoResponse,autoResponseText:e.autoResponseText,autoResponseDelay:e.autoResponseDelay,onSend:e.onSend});return(0,i.jsx)($,{messages:r,placeholder:e.placeholder,onSendMessage:e=>{o(e)},disabled:e.disabled||a,showTimestamp:e.showTimestamp,userAvatarUrl:e.userAvatarUrl,userAvatarFallback:e.userAvatarFallback,assistantAvatarUrl:e.assistantAvatarUrl,assistantAvatarFallback:e.assistantAvatarFallback,maxHeight:e.maxHeight,className:t,...n})},{namespace:`plugin-chatbot`,label:`Chatbot`,inputs:[{name:`messages`,type:`array`,label:`Initial Messages`,description:`Array of message objects with id, role, content, and optional timestamp`},{name:`placeholder`,type:`string`,label:`Input Placeholder`,defaultValue:`Type your message...`},{name:`showTimestamp`,type:`boolean`,label:`Show Timestamps`,defaultValue:!1},{name:`disabled`,type:`boolean`,label:`Disabled`,defaultValue:!1},{name:`userAvatarUrl`,type:`string`,label:`User Avatar URL`,description:`URL of the user avatar image`},{name:`userAvatarFallback`,type:`string`,label:`User Avatar Fallback`,defaultValue:`You`,description:`Fallback text shown when user avatar image is not available`},{name:`assistantAvatarUrl`,type:`string`,label:`Assistant Avatar URL`,description:`URL of the assistant avatar image`},{name:`assistantAvatarFallback`,type:`string`,label:`Assistant Avatar Fallback`,defaultValue:`AI`,description:`Fallback text shown when assistant avatar image is not available`},{name:`maxHeight`,type:`string`,label:`Max Height`,defaultValue:`500px`},{name:`api`,type:`string`,label:`API Endpoint`,description:`Backend SSE endpoint (e.g., /api/v1/ai/chat). When set, enables streaming AI mode.`},{name:`conversationId`,type:`string`,label:`Conversation ID`,description:`Multi-turn conversation identifier`},{name:`systemPrompt`,type:`string`,label:`System Prompt`,description:`System prompt to configure assistant behavior`},{name:`model`,type:`string`,label:`AI Model`,description:`AI model identifier (e.g., gpt-4o)`},{name:`streamingEnabled`,type:`boolean`,label:`Enable Streaming`,defaultValue:!0},{name:`autoResponse`,type:`boolean`,label:`Enable Auto Response (Demo)`,defaultValue:!1,description:`Automatically send a response after user message (for demo purposes, ignored when API is set)`},{name:`autoResponseText`,type:`string`,label:`Auto Response Text`,defaultValue:`Thank you for your message!`},{name:`autoResponseDelay`,type:`number`,label:`Auto Response Delay (ms)`,defaultValue:1e3},{name:`className`,type:`string`,label:`CSS Class`}],defaultProps:{messages:[{id:`welcome`,role:`assistant`,content:`Hello! How can I help you today?`}],placeholder:`Type your message...`,showTimestamp:!1,disabled:!1,userAvatarFallback:`You`,assistantAvatarFallback:`AI`,maxHeight:`500px`,autoResponse:!0,autoResponseText:`Thank you for your message! This is an automated response.`,autoResponseDelay:1e3,className:`w-full max-w-2xl`}}),_.ComponentRegistry.register(`chatbot-enhanced`,({schema:e,className:t,...n})=>{let{messages:r,isLoading:a,error:o,sendMessage:s,stop:c,reload:l,clear:u,isApiMode:d}=F({api:e.api,initialMessages:e.messages,conversationId:e.conversationId,systemPrompt:e.systemPrompt,model:e.model,streamingEnabled:e.streamingEnabled,headers:e.headers,body:e.requestBody,maxToolRoundtrips:e.maxToolRoundtrips,onError:e.onError,showTimestamp:e.showTimestamp,autoResponse:e.autoResponse,autoResponseText:e.autoResponseText,autoResponseDelay:e.autoResponseDelay,onSend:e.onSend});return(0,i.jsx)(Q,{messages:r,placeholder:e.placeholder,onSendMessage:(e,t)=>{s(e,t)},onClear:()=>{u(),e.onClear?.()},onStop:d&&a?c:void 0,onReload:d?l:void 0,disabled:e.disabled,isLoading:a,error:o,showTimestamp:e.showTimestamp,userAvatarUrl:e.userAvatarUrl,userAvatarFallback:e.userAvatarFallback,assistantAvatarUrl:e.assistantAvatarUrl,assistantAvatarFallback:e.assistantAvatarFallback,maxHeight:e.maxHeight,enableMarkdown:e.enableMarkdown??!0,enableFileUpload:e.enableFileUpload??!1,className:t,...n})},{namespace:`plugin-chatbot`,label:`Chatbot (Enhanced)`,inputs:[{name:`messages`,type:`array`,label:`Initial Messages`},{name:`placeholder`,type:`string`,label:`Input Placeholder`,defaultValue:`Type your message...`},{name:`showTimestamp`,type:`boolean`,label:`Show Timestamps`,defaultValue:!1},{name:`disabled`,type:`boolean`,label:`Disabled`,defaultValue:!1},{name:`enableMarkdown`,type:`boolean`,label:`Enable Markdown`,defaultValue:!0},{name:`enableFileUpload`,type:`boolean`,label:`Enable File Upload`,defaultValue:!1},{name:`userAvatarUrl`,type:`string`,label:`User Avatar URL`},{name:`userAvatarFallback`,type:`string`,label:`User Avatar Fallback`,defaultValue:`You`},{name:`assistantAvatarUrl`,type:`string`,label:`Assistant Avatar URL`},{name:`assistantAvatarFallback`,type:`string`,label:`Assistant Avatar Fallback`,defaultValue:`AI`},{name:`maxHeight`,type:`string`,label:`Max Height`,defaultValue:`500px`},{name:`api`,type:`string`,label:`API Endpoint`,description:`Backend SSE endpoint for streaming AI mode`},{name:`conversationId`,type:`string`,label:`Conversation ID`},{name:`systemPrompt`,type:`string`,label:`System Prompt`},{name:`model`,type:`string`,label:`AI Model`},{name:`streamingEnabled`,type:`boolean`,label:`Enable Streaming`,defaultValue:!0},{name:`autoResponse`,type:`boolean`,label:`Enable Auto Response (Demo)`,defaultValue:!1},{name:`autoResponseText`,type:`string`,label:`Auto Response Text`,defaultValue:`Thank you for your message!`},{name:`autoResponseDelay`,type:`number`,label:`Auto Response Delay (ms)`,defaultValue:1e3},{name:`className`,type:`string`,label:`CSS Class`}],defaultProps:{messages:[{id:`welcome`,role:`assistant`,content:`Hello! How can I help you today?`}],placeholder:`Type your message...`,showTimestamp:!1,disabled:!1,enableMarkdown:!0,enableFileUpload:!1,userAvatarFallback:`You`,assistantAvatarFallback:`AI`,maxHeight:`500px`,autoResponse:!0,autoResponseText:`Thank you for your message! This is an automated response.`,autoResponseDelay:1e3,className:`w-full max-w-2xl`}}),_.ComponentRegistry.register(`chatbot-floating`,({schema:e,className:t,...n})=>{let{messages:r,isLoading:a,error:o,sendMessage:s,stop:c,reload:l,clear:u,isApiMode:d}=F({api:e.api,initialMessages:e.messages,conversationId:e.conversationId,systemPrompt:e.systemPrompt,model:e.model,streamingEnabled:e.streamingEnabled,headers:e.headers,body:e.requestBody,maxToolRoundtrips:e.maxToolRoundtrips,onError:e.onError,showTimestamp:e.showTimestamp,autoResponse:e.autoResponse,autoResponseText:e.autoResponseText,autoResponseDelay:e.autoResponseDelay,onSend:e.onSend});return(0,i.jsx)(Bt,{floatingConfig:e.floatingConfig,messages:r,placeholder:e.placeholder,onSendMessage:(e,t)=>{s(e,t)},onClear:()=>{u(),e.onClear?.()},onStop:d&&a?c:void 0,onReload:d?l:void 0,disabled:e.disabled,isLoading:a,error:o,showTimestamp:e.showTimestamp,userAvatarUrl:e.userAvatarUrl,userAvatarFallback:e.userAvatarFallback,assistantAvatarUrl:e.assistantAvatarUrl,assistantAvatarFallback:e.assistantAvatarFallback,enableMarkdown:e.enableMarkdown??!0,enableFileUpload:e.enableFileUpload??!1,className:t,...n})},{namespace:`plugin-chatbot`,label:`Chatbot (Floating)`,inputs:[{name:`displayMode`,type:`string`,label:`Display Mode`,defaultValue:`floating`,description:`Set to "floating" for FAB widget`},{name:`floatingConfig.position`,type:`string`,label:`FAB Position`,defaultValue:`bottom-right`,description:`bottom-right or bottom-left`},{name:`floatingConfig.defaultOpen`,type:`boolean`,label:`Default Open`,defaultValue:!1},{name:`floatingConfig.panelWidth`,type:`number`,label:`Panel Width`,defaultValue:400},{name:`floatingConfig.panelHeight`,type:`number`,label:`Panel Height`,defaultValue:520},{name:`floatingConfig.title`,type:`string`,label:`Panel Title`,defaultValue:`Chat`},{name:`floatingConfig.triggerSize`,type:`number`,label:`Trigger Size`,defaultValue:56},{name:`messages`,type:`array`,label:`Initial Messages`},{name:`placeholder`,type:`string`,label:`Input Placeholder`,defaultValue:`Type your message...`},{name:`enableMarkdown`,type:`boolean`,label:`Enable Markdown`,defaultValue:!0},{name:`enableFileUpload`,type:`boolean`,label:`Enable File Upload`,defaultValue:!1},{name:`api`,type:`string`,label:`API Endpoint`,description:`Backend SSE endpoint for streaming AI mode`},{name:`conversationId`,type:`string`,label:`Conversation ID`},{name:`systemPrompt`,type:`string`,label:`System Prompt`},{name:`model`,type:`string`,label:`AI Model`},{name:`streamingEnabled`,type:`boolean`,label:`Enable Streaming`,defaultValue:!0},{name:`autoResponse`,type:`boolean`,label:`Enable Auto Response (Demo)`,defaultValue:!1},{name:`autoResponseText`,type:`string`,label:`Auto Response Text`,defaultValue:`Thank you for your message!`},{name:`autoResponseDelay`,type:`number`,label:`Auto Response Delay (ms)`,defaultValue:1e3},{name:`className`,type:`string`,label:`CSS Class`}],defaultProps:{displayMode:`floating`,floatingConfig:{position:`bottom-right`,defaultOpen:!1,panelWidth:400,panelHeight:520,title:`Chat`,triggerSize:56},messages:[{id:`welcome`,role:`assistant`,content:`Hello! How can I help you today?`}],placeholder:`Type your message...`,enableMarkdown:!0,enableFileUpload:!1,autoResponse:!0,autoResponseText:`Thank you for your message! This is an automated response.`,autoResponseDelay:1e3}});var Vt=({size:e=16})=>(0,i.jsxs)(`svg`,{height:e,strokeLinejoin:`round`,style:{color:`currentcolor`},viewBox:`0 0 16 16`,width:e,children:[(0,i.jsx)(`title`,{children:`Loader`}),(0,i.jsxs)(`g`,{clipPath:`url(#clip0_2393_1490)`,children:[(0,i.jsx)(`path`,{d:`M8 0V4`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,i.jsx)(`path`,{d:`M8 16V12`,opacity:`0.5`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,i.jsx)(`path`,{d:`M3.29773 1.52783L5.64887 4.7639`,opacity:`0.9`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,i.jsx)(`path`,{d:`M12.7023 1.52783L10.3511 4.7639`,opacity:`0.1`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,i.jsx)(`path`,{d:`M12.7023 14.472L10.3511 11.236`,opacity:`0.4`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,i.jsx)(`path`,{d:`M3.29773 14.472L5.64887 11.236`,opacity:`0.6`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,i.jsx)(`path`,{d:`M15.6085 5.52783L11.8043 6.7639`,opacity:`0.2`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,i.jsx)(`path`,{d:`M0.391602 10.472L4.19583 9.23598`,opacity:`0.7`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,i.jsx)(`path`,{d:`M15.6085 10.4722L11.8043 9.2361`,opacity:`0.3`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,i.jsx)(`path`,{d:`M0.391602 5.52783L4.19583 6.7639`,opacity:`0.8`,stroke:`currentColor`,strokeWidth:`1.5`})]}),(0,i.jsx)(`defs`,{children:(0,i.jsx)(`clipPath`,{id:`clip0_2393_1490`,children:(0,i.jsx)(`rect`,{fill:`white`,height:`16`,width:`16`})})})]}),Ht=({className:e,size:t=16,...r})=>(0,i.jsx)(`div`,{className:(0,n.cn)(`inline-flex animate-spin items-center justify-center`,e),...r,children:(0,i.jsx)(Vt,{size:t})}),Ut=w({CodeBlock:()=>q,CodeBlockCopyButton:()=>St,Conversation:()=>re,ConversationContent:()=>ie,ConversationEmptyState:()=>ae,ConversationScrollButton:()=>oe,Loader:()=>Ht,Message:()=>ue,MessageAction:()=>V,MessageActions:()=>fe,MessageAttachment:()=>xe,MessageAttachments:()=>Se,MessageBranch:()=>me,MessageBranchContent:()=>he,MessageBranchNext:()=>ve,MessageBranchPage:()=>ye,MessageBranchPrevious:()=>_e,MessageBranchSelector:()=>ge,MessageContent:()=>de,MessageResponse:()=>be,MessageToolbar:()=>Ce,PromptInput:()=>ze,PromptInputActionAddAttachments:()=>Re,PromptInputActionMenu:()=>Ge,PromptInputActionMenuContent:()=>qe,PromptInputActionMenuItem:()=>Je,PromptInputActionMenuTrigger:()=>Ke,PromptInputAttachment:()=>Ie,PromptInputAttachments:()=>Le,PromptInputBody:()=>Be,PromptInputButton:()=>K,PromptInputCommand:()=>ut,PromptInputCommandEmpty:()=>pt,PromptInputCommandGroup:()=>mt,PromptInputCommandInput:()=>dt,PromptInputCommandItem:()=>ht,PromptInputCommandList:()=>ft,PromptInputCommandSeparator:()=>gt,PromptInputFooter:()=>Ue,PromptInputHeader:()=>He,PromptInputHoverCard:()=>nt,PromptInputHoverCardContent:()=>it,PromptInputHoverCardTrigger:()=>rt,PromptInputProvider:()=>Pe,PromptInputSelect:()=>Ze,PromptInputSelectContent:()=>$e,PromptInputSelectItem:()=>et,PromptInputSelectTrigger:()=>Qe,PromptInputSelectValue:()=>tt,PromptInputSpeechButton:()=>Xe,PromptInputSubmit:()=>Ye,PromptInputTab:()=>ot,PromptInputTabBody:()=>ct,PromptInputTabItem:()=>lt,PromptInputTabLabel:()=>st,PromptInputTabsList:()=>at,PromptInputTextarea:()=>Ve,PromptInputTools:()=>We,Reasoning:()=>J,ReasoningContent:()=>X,ReasoningTrigger:()=>Y,Shimmer:()=>kt,Source:()=>Lt,Sources:()=>Ft,SourcesContent:()=>It,SourcesTrigger:()=>Z,Suggestion:()=>vt,Suggestions:()=>_t,Tool:()=>Ct,ToolContent:()=>Et,ToolHeader:()=>Tt,ToolInput:()=>Dt,ToolOutput:()=>Ot,highlightCode:()=>xt,usePromptInputAttachments:()=>G,usePromptInputController:()=>Ae,useProviderAttachments:()=>Me,useReasoning:()=>jt}),$=t.forwardRef(({className:e,messages:a=[],placeholder:o=`Type your message...`,onSendMessage:s,disabled:c=!1,showTimestamp:l=!1,userAvatarUrl:u,userAvatarFallback:d=`You`,assistantAvatarUrl:f,assistantAvatarFallback:p=`AI`,maxHeight:m=`500px`,...h},g)=>{let[_,v]=t.useState(``),y=t.useRef(null),b=t.useRef(null);t.useEffect(()=>{if(y.current){let e=y.current.querySelector(`[data-radix-scroll-area-viewport]`);e&&(e.scrollTop=e.scrollHeight)}},[a]);let x=()=>{_.trim()&&s&&(s(_.trim()),v(``),b.current?.focus())},S=e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),x())};return(0,i.jsxs)(`div`,{ref:g,className:(0,n.cn)(`flex flex-col border rounded-lg bg-background overflow-hidden`,e),style:{maxHeight:m},...h,children:[(0,i.jsx)(n.ScrollArea,{ref:y,className:`flex-1 p-4`,children:(0,i.jsx)(`div`,{className:`space-y-4`,children:a.length===0?(0,i.jsx)(`div`,{className:`flex items-center justify-center h-32 text-muted-foreground text-sm`,children:`No messages yet. Start a conversation!`}):a.map(e=>(0,i.jsx)(Wt,{message:e,showTimestamp:l,userAvatarUrl:u,userAvatarFallback:d,assistantAvatarUrl:f,assistantAvatarFallback:p},e.id))})}),(0,i.jsx)(`div`,{className:`border-t p-4`,children:(0,i.jsxs)(`div`,{className:`flex gap-2`,children:[(0,i.jsx)(n.Input,{ref:b,value:_,onChange:e=>v(e.target.value),onKeyDown:S,placeholder:o,disabled:c,className:`flex-1`}),(0,i.jsx)(n.Button,{onClick:x,disabled:c||!_.trim(),size:`icon`,children:(0,i.jsx)(r.Send,{className:`h-4 w-4`})})]})})]})});$.displayName=`Chatbot`;var Wt=({message:e,showTimestamp:t,userAvatarUrl:r,userAvatarFallback:a,assistantAvatarUrl:o,assistantAvatarFallback:s})=>{let c=e.role===`user`;if(e.role===`system`)return(0,i.jsx)(`div`,{className:`flex justify-center`,children:(0,i.jsx)(`div`,{className:`text-xs text-muted-foreground bg-muted px-3 py-1 rounded-full`,children:e.content})});let l=c?e.avatar||r:e.avatar||o,u=c?e.avatarFallback||a:e.avatarFallback||s;return(0,i.jsxs)(`div`,{className:(0,n.cn)(`flex gap-3`,c?`flex-row-reverse`:`flex-row`),children:[(0,i.jsxs)(n.Avatar,{className:`h-8 w-8`,children:[(0,i.jsx)(n.AvatarImage,{src:l}),(0,i.jsx)(n.AvatarFallback,{className:`text-xs`,children:u})]}),(0,i.jsxs)(`div`,{className:(0,n.cn)(`flex flex-col gap-1`,c?`items-end`:`items-start`),children:[(0,i.jsx)(`div`,{className:(0,n.cn)(`rounded-lg px-4 py-2 max-w-[70%] break-words`,c?`bg-primary text-primary-foreground`:`bg-muted`),children:(0,i.jsx)(`p`,{className:`text-sm whitespace-pre-wrap`,children:e.content})}),t&&e.timestamp&&(0,i.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.timestamp})]})]})},Gt=t.forwardRef(({className:e,avatarSrc:t,avatarFallback:r=`AI`,...a},o)=>(0,i.jsxs)(`div`,{ref:o,className:(0,n.cn)(`flex gap-3`,e),...a,children:[(0,i.jsxs)(n.Avatar,{className:`h-8 w-8`,children:[(0,i.jsx)(n.AvatarImage,{src:t}),(0,i.jsx)(n.AvatarFallback,{className:`text-xs`,children:r})]}),(0,i.jsx)(`div`,{className:`flex items-center bg-muted rounded-lg px-4 py-2`,children:(0,i.jsxs)(`div`,{className:`flex gap-1`,children:[(0,i.jsx)(`span`,{className:`w-2 h-2 bg-muted-foreground rounded-full animate-bounce [animation-delay:-0.3s]`}),(0,i.jsx)(`span`,{className:`w-2 h-2 bg-muted-foreground rounded-full animate-bounce [animation-delay:-0.15s]`}),(0,i.jsx)(`span`,{className:`w-2 h-2 bg-muted-foreground rounded-full animate-bounce`})]})})]}));Gt.displayName=`TypingIndicator`,Object.defineProperty(e,`AIElements`,{enumerable:!0,get:function(){return Ut}}),e.Chatbot=$,e.ChatbotEnhanced=Q,e.FloatingChatbot=Bt,e.FloatingChatbotPanel=ne,e.FloatingChatbotProvider=R,e.FloatingChatbotTrigger=B,e.TypingIndicator=Gt,e.uiMessageToChatMessage=M,e.uiMessagesToChatMessages=N,e.useAgents=I,e.useFloatingChatbot=z,e.useObjectChat=F});
@@ -104,6 +104,35 @@ export interface ChatbotEnhancedProps extends React.HTMLAttributes<HTMLDivElemen
104
104
  selectedModelId?: string;
105
105
  /** Fired when the user picks a different model. */
106
106
  onModelChange?: (modelId: string) => void;
107
+ /**
108
+ * Optional banner rendered between the message-count strip and the
109
+ * conversation. Used by shell-level UIs (e.g. Studio's assistant status
110
+ * row) without forcing them to fork the whole component.
111
+ */
112
+ headerSlot?: React.ReactNode;
113
+ /**
114
+ * Optional overlay rendered absolute-positioned above the prompt input.
115
+ * Intended for slash-command palettes / inline suggestion popups.
116
+ */
117
+ promptOverlaySlot?: React.ReactNode;
118
+ /**
119
+ * Fired on every keystroke in the prompt textarea (forwarded from the
120
+ * AI Elements `PromptInputTextarea`). Lets callers drive a slash-command
121
+ * palette without owning the textarea state.
122
+ */
123
+ onInputChange?: (value: string) => void;
124
+ /**
125
+ * When provided, tool parts in `approval-requested` state render Approve /
126
+ * Deny buttons inside their body. The callback receives the tool's
127
+ * `toolCallId` (use it to look up the AI SDK approval id if different).
128
+ */
129
+ onToolApprove?: (toolCallId: string, approved: boolean, reason?: string) => void;
130
+ /** Label for the approve button (default "Approve"). */
131
+ toolApproveLabel?: string;
132
+ /** Label for the deny button (default "Deny"). */
133
+ toolDenyLabel?: string;
134
+ /** Reason text sent with a denial response (default "User denied the operation"). */
135
+ toolDenyReason?: string;
107
136
  }
108
137
  export interface ChatbotModelOption {
109
138
  id: string;
@@ -1 +1 @@
1
- {"version":3,"file":"ChatbotEnhanced.d.ts","sourceRoot":"","sources":["../../../../src/ChatbotEnhanced.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAoD/B,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,QAAQ,CAAC;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,0EAA0E;IAC1E,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;;OAIG;IACH,eAAe,CAAC,EAAE,kBAAkB,EAAE,CAAC;IACvC,sEAAsE;IACtE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kEAAkE;IAClE,OAAO,CAAC,EAAE,UAAU,EAAE,CAAC;IACvB,qEAAqE;IACrE,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,kBAAkB;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,KAAK,CAAC,EACF,iBAAiB,GACjB,iBAAiB,GACjB,oBAAoB,GACpB,oBAAoB,GACpB,kBAAkB,GAClB,cAAc,GACd,eAAe,CAAC;CACrB;AAED,MAAM,WAAW,UAAU;IACzB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,oBAAqB,SAAQ,KAAK,C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DAAgD;IAChD,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,mDAAmD;IACnD,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C;;;;OAIG;IACH,UAAU,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC7B;;;OAGG;IACH,iBAAiB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACpC;;;;OAIG;IACH,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC;;;;OAIG;IACH,aAAa,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACjF,wDAAwD;IACxD,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,kDAAkD;IAClD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,qFAAqF;IACrF,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAcD,QAAA,MAAM,eAAe,6FAgWpB,CAAC;AAIF,OAAO,EAAE,eAAe,EAAE,CAAC"}
@@ -54,5 +54,8 @@ export type { FloatingChatbotTriggerProps } from './FloatingChatbotTrigger';
54
54
  export { FloatingChatbotPanel } from './FloatingChatbotPanel';
55
55
  export type { FloatingChatbotPanelProps } from './FloatingChatbotPanel';
56
56
  export * from './renderer';
57
+ export { ChatbotEnhanced } from './ChatbotEnhanced';
58
+ export type { ChatbotEnhancedProps, ChatMessage as ChatbotEnhancedMessage, ChatToolInvocation as ChatbotEnhancedToolInvocation, ChatSource as ChatbotEnhancedSource, } from './ChatbotEnhanced';
57
59
  export * as AIElements from './elements';
60
+ export { uiMessageToChatMessage, uiMessagesToChatMessages, } from './mapMessages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oBAAoB,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAGjF,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,YAAY,EACV,gBAAgB,EAChB,eAAe,EACf,eAAe,GAChB,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,YAAY,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AACxF,YAAY,EACV,4BAA4B,EAC5B,oBAAoB,EACpB,sBAAsB,EACtB,2BAA2B,GAC5B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,YAAY,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,YAAY,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AAGxE,cAAc,YAAY,CAAC;AAI3B,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,YAAY,EACV,oBAAoB,EACpB,WAAW,IAAI,sBAAsB,EACrC,kBAAkB,IAAI,6BAA6B,EACnD,UAAU,IAAI,qBAAqB,GACpC,MAAM,mBAAmB,CAAC;AAM3B,OAAO,KAAK,UAAU,MAAM,YAAY,CAAC;AAIzC,OAAO,EACL,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,eAAe,CAAC"}
@@ -0,0 +1,45 @@
1
+ import { ChatMessage, ChatToolInvocation } from './ChatbotEnhanced';
2
+ interface AnyPart {
3
+ type?: string;
4
+ text?: string;
5
+ toolCallId?: string;
6
+ toolName?: string;
7
+ id?: string;
8
+ input?: unknown;
9
+ output?: unknown;
10
+ args?: unknown;
11
+ result?: unknown;
12
+ errorText?: string;
13
+ state?: ChatToolInvocation['state'];
14
+ url?: string;
15
+ href?: string;
16
+ title?: string;
17
+ }
18
+ interface AnyUIMessage {
19
+ id?: string;
20
+ role?: 'user' | 'assistant' | 'system';
21
+ parts?: AnyPart[];
22
+ content?: unknown;
23
+ toolInvocations?: ChatToolInvocation[];
24
+ metadata?: unknown;
25
+ }
26
+ /**
27
+ * Map a single Vercel AI SDK v6 `UIMessage` to the `ChatMessage` shape that
28
+ * `<ChatbotEnhanced>` renders.
29
+ *
30
+ * @param msg - AI SDK `UIMessage` (or compatible shape with `parts`).
31
+ * @param opts - Optional flags. `streaming` flags the latest assistant
32
+ * message during an in-flight stream so the cursor pulse renders.
33
+ */
34
+ export declare function uiMessageToChatMessage(msg: AnyUIMessage, opts?: {
35
+ streaming?: boolean;
36
+ }): ChatMessage;
37
+ /**
38
+ * Map an array of `UIMessage`s. The trailing assistant message gets the
39
+ * `streaming` flag when `isStreaming` is true (mirrors `useObjectChat`).
40
+ */
41
+ export declare function uiMessagesToChatMessages(messages: AnyUIMessage[], opts?: {
42
+ isStreaming?: boolean;
43
+ }): ChatMessage[];
44
+ export {};
45
+ //# sourceMappingURL=mapMessages.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mapMessages.d.ts","sourceRoot":"","sources":["../../../../src/mapMessages.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAc,MAAM,mBAAmB,CAAC;AAErF,UAAU,OAAO;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;IAC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C;IAC1B;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;OAEG;IACH,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,EAAE,KAAK,IAAI,CAAC;CAChE;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,4BAA4B;IAC5B,QAAQ,EAAE,cAAc,EAAE,CAAC;IAC3B,+DAA+D;IAC/D,SAAS,EAAE,OAAO,CAAC;IACnB,4BAA4B;IAC5B,KAAK,EAAE,KAAK,GAAG,SAAS,CAAC;IACzB,8BAA8B;IAC9B,WAAW,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,IAAI,EAAE,KAAK,IAAI,CAAC;IACvD,0CAA0C;IAC1C,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,gDAAgD;IAChD,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,yBAAyB;IACzB,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,4DAA4D;IAC5D,SAAS,EAAE,OAAO,CAAC;IACnB,wDAAwD;IACxD,KAAK,EAAE,MAAM,CAAC;IACd,sBAAsB;IACtB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,gCAAgC;IAChC,iBAAiB,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,gBAAgB,GAAG,mBAAmB,CAAC,KAAK,IAAI,CAAC;CAC3F;AAmBD;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAAC,OAAO,GAAE,oBAAyB,GAAG,mBAAmB,CA6NrF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@object-ui/plugin-chatbot",
3
- "version": "5.4.1",
3
+ "version": "5.4.2",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "Chatbot interface plugin for Object UI",
@@ -38,10 +38,10 @@
38
38
  "shiki": "^4.0.2",
39
39
  "streamdown": "^1.4.1",
40
40
  "use-stick-to-bottom": "^1.1.1",
41
- "@object-ui/components": "5.4.1",
42
- "@object-ui/core": "5.4.1",
43
- "@object-ui/react": "5.4.1",
44
- "@object-ui/types": "5.4.1"
41
+ "@object-ui/components": "5.4.2",
42
+ "@object-ui/core": "5.4.2",
43
+ "@object-ui/react": "5.4.2",
44
+ "@object-ui/types": "5.4.2"
45
45
  },
46
46
  "peerDependencies": {
47
47
  "react": "^18.0.0 || ^19.0.0",