@waniwani/sdk 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chat/index.d.ts +17 -4
- package/dist/chat/index.js +1 -1
- package/dist/chat/index.js.map +1 -1
- package/dist/chat/styles.css +1 -1
- package/dist/mcp/react.js +1 -1
- package/dist/mcp/react.js.map +1 -1
- package/package.json +1 -1
package/dist/chat/index.d.ts
CHANGED
|
@@ -54,6 +54,14 @@ interface ChatBaseProps {
|
|
|
54
54
|
body?: Record<string, unknown>;
|
|
55
55
|
/** Enable file attachments in the input. Defaults to false. */
|
|
56
56
|
allowAttachments?: boolean;
|
|
57
|
+
/** Placeholder text shown in the input field. Defaults to "Ask me anything...". Animates with a typing effect. */
|
|
58
|
+
placeholder?: string;
|
|
59
|
+
/**
|
|
60
|
+
* Name of a custom DOM event to listen for that triggers focus (scroll + glow) and optionally sends a message.
|
|
61
|
+
* Dispatch via `new CustomEvent('triggerDemoRequest', { detail: { message: 'Hi!' } })`.
|
|
62
|
+
* Set to `false` to disable. Defaults to `"triggerDemoRequest"`.
|
|
63
|
+
*/
|
|
64
|
+
triggerEvent?: string | false;
|
|
57
65
|
/** Callback fired when a message is sent */
|
|
58
66
|
onMessageSent?: (message: string) => void;
|
|
59
67
|
/** Callback fired when a response is received */
|
|
@@ -89,6 +97,8 @@ interface ChatCardProps extends ChatBaseProps {
|
|
|
89
97
|
interface ChatHandle {
|
|
90
98
|
/** Programmatically send a user message into the chat */
|
|
91
99
|
sendMessage: (text: string) => void;
|
|
100
|
+
/** Scroll to the chat input, focus it, and show a highlight glow */
|
|
101
|
+
focus: () => void;
|
|
92
102
|
}
|
|
93
103
|
/** @deprecated Use ChatBarProps instead */
|
|
94
104
|
type ChatWidgetProps = ChatBarProps;
|
|
@@ -112,13 +122,16 @@ interface McpAppFrameProps {
|
|
|
112
122
|
autoHeight?: boolean;
|
|
113
123
|
/** Called when the view requests to open a URL */
|
|
114
124
|
onOpenLink?: (url: string) => void;
|
|
115
|
-
/** Called when
|
|
116
|
-
|
|
125
|
+
/** Called when a widget sends a follow-up message via `ui/message` */
|
|
126
|
+
onFollowUp?: (message: {
|
|
117
127
|
role: string;
|
|
118
|
-
content:
|
|
128
|
+
content: Array<{
|
|
129
|
+
type: string;
|
|
130
|
+
text?: string;
|
|
131
|
+
}>;
|
|
119
132
|
}) => void;
|
|
120
133
|
}
|
|
121
|
-
declare function McpAppFrame({ resourceUri, toolInput, toolResult, resourceEndpoint, isDark, className, autoHeight, onOpenLink,
|
|
134
|
+
declare function McpAppFrame({ resourceUri, toolInput, toolResult, resourceEndpoint, isDark, className, autoHeight, onOpenLink, onFollowUp, }: McpAppFrameProps): react_jsx_runtime.JSX.Element;
|
|
122
135
|
|
|
123
136
|
declare const ChatCard: react.ForwardRefExoticComponent<ChatCardProps & react.RefAttributes<ChatHandle>>;
|
|
124
137
|
|
package/dist/chat/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{forwardRef as no,useCallback as et,useEffect as so,useImperativeHandle as ao,useRef as io,useState as lo}from"react";import{ArrowDownIcon as nt}from"lucide-react";import{useCallback as st}from"react";import{StickToBottom as Ie,useStickToBottomContext as at}from"use-stick-to-bottom";import{clsx as tt}from"clsx";import{twMerge as ot}from"tailwind-merge";function u(...t){return ot(tt(t))}import{jsx as rt}from"react/jsx-runtime";var z=({className:t,variant:e="default",size:o="default",type:n="button",...r})=>rt("button",{type:n,className:u("inline-flex cursor-pointer items-center justify-center rounded-md font-medium transition-colors disabled:pointer-events-none disabled:opacity-50",e==="default"&&"bg-primary text-primary-foreground hover:bg-primary/90",e==="outline"&&"border border-border bg-background hover:bg-accent hover:text-accent-foreground",e==="ghost"&&"hover:bg-accent hover:text-accent-foreground",o==="default"&&"h-9 px-4 py-2 text-sm",o==="sm"&&"h-8 px-3 text-xs",o==="icon"&&"size-9",o==="icon-sm"&&"size-7",t),...r});import{jsx as X}from"react/jsx-runtime";var Z=({className:t,...e})=>X(Ie,{className:u("relative flex-1 overflow-y-hidden",t),initial:"smooth",resize:"smooth",role:"log",...e}),Q=({className:t,...e})=>X(Ie.Content,{className:u("flex flex-col gap-8 p-4",t),...e}),Y=({className:t,...e})=>{let{isAtBottom:o,scrollToBottom:n}=at(),r=st(()=>{n()},[n]);return!o&&X(z,{className:u("absolute bottom-4 left-[50%] translate-x-[-50%] rounded-full",t),onClick:r,size:"icon",variant:"outline",...e,children:X(nt,{className:"size-4"})})};import{ArrowUpIcon as it,LoaderIcon as lt,PaperclipIcon as ut,SquareIcon as ct,XIcon as pt}from"lucide-react";import{nanoid as mt}from"nanoid";import{createContext as dt,useCallback as U,useContext as ft,useEffect as ge,useMemo as gt,useRef as he,useState as Ee}from"react";import{jsx as A,jsxs as Re}from"react/jsx-runtime";var ht=async t=>{try{let o=await(await fetch(t)).blob();return new Promise(n=>{let r=new FileReader;r.onloadend=()=>n(r.result),r.onerror=()=>n(null),r.readAsDataURL(o)})}catch{return null}},Ne=dt(null),Le=()=>{let t=ft(Ne);if(!t)throw new Error("usePromptInputAttachments must be used within a PromptInput");return t},ee=({className:t,accept:e,multiple:o,globalDrop:n,maxFiles:r,maxFileSize:s,onSubmit:a,children:p,...C})=>{let i=he(null),g=he(null),[m,v]=Ee([]),w=he(m);ge(()=>{w.current=m},[m]);let d=U(()=>{i.current?.click()},[]),T=U(b=>{let f=[...b];if(f.length===0)return;let x=S=>s?S.size<=s:!0,R=f.filter(x);v(S=>{let D=typeof r=="number"?Math.max(0,r-S.length):void 0,E=typeof D=="number"?R.slice(0,D):R;return[...S,...E.map(k=>({filename:k.name,id:mt(),mediaType:k.type,type:"file",url:URL.createObjectURL(k)}))]})},[r,s]),c=U(b=>{v(f=>{let x=f.find(R=>R.id===b);return x?.url&&URL.revokeObjectURL(x.url),f.filter(R=>R.id!==b)})},[]),l=U(()=>{v(b=>{for(let f of b)f.url&&URL.revokeObjectURL(f.url);return[]})},[]);ge(()=>()=>{for(let b of w.current)b.url&&URL.revokeObjectURL(b.url)},[]);let h=U(b=>{b.currentTarget.files&&T(b.currentTarget.files),b.currentTarget.value=""},[T]);ge(()=>{if(!n)return;let b=x=>{x.dataTransfer?.types?.includes("Files")&&x.preventDefault()},f=x=>{x.dataTransfer?.types?.includes("Files")&&x.preventDefault(),x.dataTransfer?.files&&x.dataTransfer.files.length>0&&T(x.dataTransfer.files)};return document.addEventListener("dragover",b),document.addEventListener("drop",f),()=>{document.removeEventListener("dragover",b),document.removeEventListener("drop",f)}},[T,n]);let P=U(async b=>{b.preventDefault();let f=b.currentTarget,R=new FormData(f).get("message")||"";f.reset();let S=await Promise.all(m.map(async({id:D,...E})=>{if(E.url?.startsWith("blob:")){let k=await ht(E.url);return{...E,url:k??E.url}}return E}));try{let D=a({files:S,text:R},b);D instanceof Promise&&await D,l()}catch{}},[m,a,l]),M=gt(()=>({add:T,clear:l,files:m,openFileDialog:d,remove:c}),[m,T,c,l,d]);return Re(Ne.Provider,{value:M,children:[A("input",{accept:e,"aria-label":"Upload files",className:"hidden",multiple:o,onChange:h,ref:i,title:"Upload files",type:"file"}),A("form",{className:u("flex w-full flex-col rounded-lg border border-border bg-background",t),onSubmit:P,ref:g,...C,children:p})]})};var te=({onChange:t,onKeyDown:e,className:o,placeholder:n="What would you like to know?",...r})=>{let s=Le(),[a,p]=Ee(!1),C=U(g=>{if(e?.(g),!g.defaultPrevented){if(g.key==="Enter"){if(a||g.nativeEvent.isComposing||g.shiftKey)return;g.preventDefault();let{form:m}=g.currentTarget;if(m?.querySelector('button[type="submit"]')?.disabled)return;m?.requestSubmit()}if(g.key==="Backspace"&&g.currentTarget.value===""&&s.files.length>0){g.preventDefault();let m=s.files.at(-1);m&&s.remove(m.id)}}},[e,a,s]),i=U(g=>{let m=g.clipboardData?.items;if(!m)return;let v=[];for(let w of m)if(w.kind==="file"){let d=w.getAsFile();d&&v.push(d)}v.length>0&&(g.preventDefault(),s.add(v))},[s]);return A("textarea",{className:u("field-sizing-content max-h-48 min-h-16 w-full resize-none border-0 bg-transparent px-3 py-3 text-sm outline-none placeholder:text-muted-foreground",o),name:"message",onCompositionEnd:()=>p(!1),onCompositionStart:()=>p(!0),onKeyDown:C,onPaste:i,placeholder:n,onChange:t,...r})},oe=({className:t,status:e,onStop:o,onClick:n,children:r,...s})=>{let a=e==="submitted"||e==="streaming",p=A(it,{className:"size-4"});e==="submitted"?p=A(lt,{className:"size-4 animate-spin"}):e==="streaming"&&(p=A(ct,{className:"size-4"}));let C=U(i=>{if(a&&o){i.preventDefault(),o();return}n?.(i)},[a,o,n]);return A(z,{"aria-label":a?"Stop":"Submit",className:u("bg-foreground text-background hover:bg-foreground",t),onClick:C,size:"icon-sm",type:a&&o?"button":"submit",variant:"ghost",...s,children:r??p})},re=({className:t,children:e,...o})=>{let n=Le();return n.files.length>0?Re(z,{className:u("group relative",t),onClick:()=>n.clear(),size:"icon-sm",type:"button",variant:"ghost","aria-label":"Remove all attachments",...o,children:[A("span",{className:"flex size-5 items-center justify-center rounded-full bg-primary text-[10px] font-medium text-primary-foreground transition-opacity group-hover:opacity-0",children:n.files.length}),A(pt,{className:"absolute size-4 opacity-0 transition-opacity group-hover:opacity-100"})]}):A(z,{className:u(t),onClick:()=>n.openFileDialog(),size:"icon-sm",type:"button",variant:"ghost",...o,children:e??A(ut,{className:"size-4"})})};import{FileIcon as bt}from"lucide-react";import{jsx as K,jsxs as Ct}from"react/jsx-runtime";var Ae=({files:t,className:e,...o})=>t.length===0?null:K("div",{className:u("flex flex-wrap gap-1.5",e),...o,children:t.map((n,r)=>K(xt,{file:n},r))});function xt({file:t}){return t.mediaType?.startsWith("image/")&&t.url?K("img",{src:t.url,alt:t.filename??"attachment",className:"h-16 max-w-32 rounded object-cover"}):Ct("span",{className:"inline-flex items-center gap-1.5 rounded bg-background/20 px-2 py-1 text-xs",children:[K(bt,{className:"size-3 shrink-0"}),K("span",{className:"max-w-24 truncate",children:t.filename??"file"})]})}import{jsx as He}from"react/jsx-runtime";var be=({className:t,size:e=5,...o})=>He("div",{className:u("flex items-center gap-1",t),...o,children:[0,1,2].map(n=>He("div",{className:"rounded-full bg-muted-foreground/60",style:{width:e,height:e,animation:"ww-pulse 1.4s ease-in-out infinite",animationDelay:`${n*.2}s`}},n))});import{cjk as yt}from"@streamdown/cjk";import{code as vt}from"@streamdown/code";import{memo as wt}from"react";import{Streamdown as Tt}from"streamdown";import{jsx as xe}from"react/jsx-runtime";var ne=({className:t,from:e,...o})=>xe("div",{className:u("group flex w-full max-w-[95%] flex-col gap-2",e==="user"?"is-user ml-auto justify-end":"is-assistant",t),...o}),se=({children:t,className:e,...o})=>xe("div",{className:u("flex w-fit min-w-0 max-w-full flex-col gap-2 overflow-hidden text-base","group-[.is-user]:ml-auto group-[.is-user]:rounded-lg group-[.is-user]:bg-user-bubble group-[.is-user]:px-4 group-[.is-user]:py-3 group-[.is-user]:text-primary-foreground","group-[.is-assistant]:text-foreground",e),...o,children:t}),Pt={cjk:yt,code:vt},ae=wt(({className:t,...e})=>xe(Tt,{className:u("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",t),plugins:Pt,...e}),(t,e)=>t.children===e.children);ae.displayName="MessageResponse";import{jsx as Mt}from"react/jsx-runtime";function Be({className:t,text:e,...o}){return e?Mt("pre",{className:u("mb-2 overflow-x-auto whitespace-pre-wrap break-words text-xs font-mono text-muted-foreground",t),...o,children:e}):null}import{BracesIcon as kt,CheckIcon as St,ChevronDownIcon as It,ChevronRightIcon as Et,ClipboardCopyIcon as Nt,ServerIcon as Qo}from"lucide-react";import{createContext as Lt,useCallback as Rt,useContext as Fe,useEffect as At,useMemo as Ht,useRef as Bt,useState as Ce}from"react";import{Fragment as De,jsx as y,jsxs as W}from"react/jsx-runtime";function Dt(t,e=80){if(t==null)return String(t);if(typeof t!="object")return String(t).slice(0,e);if(Array.isArray(t))return`Array(${t.length})`;let o=JSON.stringify(t);if(o.length<=e)return o;let n=Object.entries(t),r=[],s=e-2;for(let[a,p]of n){if(s<=8)break;let C=a.length>4?`${a.slice(0,4)}\u2026`:a,i;typeof p=="string"?i=p.length>2?`'${p.slice(0,1)}\u2026`:`'${p}'`:Array.isArray(p)?i=`Array(${p.length})`:typeof p=="object"&&p!==null?i="{\u2026}":i=String(p);let g=`${C}\u2009${i}`;r.push(g),s-=g.length+3}return`{${r.join(", ")}}`}function Ft({text:t,className:e}){let[o,n]=Ce(!1),r=Bt(null);At(()=>()=>{r.current&&clearTimeout(r.current)},[]);let s=Rt(async a=>{a.stopPropagation();try{await navigator.clipboard.writeText(t),n(!0),r.current&&clearTimeout(r.current),r.current=setTimeout(()=>n(!1),2e3)}catch{}},[t]);return y(z,{variant:"ghost",size:"sm",onClick:s,className:u("h-auto gap-1 px-1.5 py-0.5 text-xs text-muted-foreground hover:text-foreground",e),children:o?W(De,{children:[y(St,{className:"size-3.5"}),y("span",{children:"Copied"})]}):W(De,{children:[y(Nt,{className:"size-3.5"}),y("span",{children:"Copy"})]})})}function Ue({data:t,label:e,className:o,...n}){let[r,s]=Ce(!1),a=Ht(()=>JSON.stringify(t,null,2),[t]),p=Dt(t);return W("div",{className:u("rounded-lg bg-tool-card",o),...n,children:[W("div",{className:"flex items-center justify-between px-3 pt-2.5 pb-1.5",children:[y("span",{className:"text-xs font-medium text-muted-foreground",children:e}),y(Ft,{text:a})]}),W("button",{type:"button",onClick:()=>s(C=>!C),className:"flex w-full items-start gap-2 px-3 pb-3 text-left",children:[y(Et,{className:u("mt-0.5 size-3.5 shrink-0 text-muted-foreground transition-transform duration-150",r&&"rotate-90")}),r?y("pre",{className:"overflow-x-auto text-xs font-mono text-foreground whitespace-pre-wrap break-all",children:y("code",{children:a})}):y("span",{className:"truncate text-xs font-mono text-foreground/80",children:p})]})]})}var ye=Lt({open:!1,toggle:()=>{}});function Oe({className:t,defaultOpen:e=!1,children:o,...n}){let[r,s]=Ce(e);return y(ye.Provider,{value:{open:r,toggle:()=>s(a=>!a)},children:y("div",{className:u("mb-4 w-full",t),"data-state":r?"open":"closed",...n,children:o})})}function ze({className:t,title:e,state:o,...n}){let{open:r,toggle:s}=Fe(ye),a=o==="input-available"||o==="input-streaming";return W("button",{type:"button",onClick:s,className:u("flex w-full items-center justify-between gap-3 py-1.5",t),"aria-expanded":r,...n,children:[W("div",{className:"flex min-w-0 items-center gap-2",children:[y(kt,{className:"size-4 shrink-0 text-muted-foreground"}),y("span",{className:"truncate text-sm font-medium",children:e}),a&&y("span",{className:"size-2 shrink-0 rounded-full bg-primary animate-pulse"})]}),y(It,{className:u("size-4 shrink-0 text-muted-foreground transition-transform duration-200",r&&"rotate-180")})]})}function We({className:t,children:e,...o}){let{open:n}=Fe(ye);return y("div",{className:u("grid transition-[grid-template-rows,opacity] duration-200 ease-out",n?"grid-rows-[1fr] opacity-100":"grid-rows-[0fr] opacity-0"),children:y("div",{className:"min-h-0 overflow-hidden",children:y("div",{className:u("mt-2 space-y-3 rounded-lg border border-border bg-background p-3",t),...o,children:e})})})}function $e({className:t,input:e,...o}){return y(Ue,{data:e,label:"Request",className:t,...o})}function je(t){if(typeof t!="object"||t===null)return;let e=t._meta;if(typeof e!="object"||e===null)return;let o=e.ui;if(!(typeof o!="object"||o===null))return o}function _e(t){let e=je(t)?.resourceUri;return typeof e=="string"?e:void 0}function Ke(t){return je(t)?.autoHeight===!0}function Ve({className:t,output:e,errorText:o,...n}){return e||o?o?W("div",{className:u("space-y-2",t),...n,children:[y("h4",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Error"}),y("div",{className:"rounded-lg bg-destructive/10 p-3 text-xs text-destructive",children:o})]}):y(Ue,{data:e,label:"Response",className:t,...n}):null}import{useCallback as Ut,useEffect as qe,useMemo as Ot,useRef as $,useState as Je}from"react";import{jsx as Kt}from"react/jsx-runtime";var zt="/api/mcp/resource",Wt=500,$t=300,jt="2026-01-26",_t=300;function ve({resourceUri:t,toolInput:e,toolResult:o,resourceEndpoint:n=zt,isDark:r=!1,className:s,autoHeight:a=!0,onOpenLink:p,onMessage:C}){let i=$(null),g=$(e),m=$(o),v=$({width:0,height:0}),w=$(!1),[d,T]=Je($t),[c,l]=Je(void 0),h=$(p),P=$(C);g.current=e,m.current=o,h.current=p,P.current=C;let M=Ut(x=>a?Math.max(x,0):Math.min(Math.max(x,50),Wt),[a]),b=Ot(()=>`${n}?uri=${encodeURIComponent(t)}`,[n,t]),f=$(r);return f.current=r,qe(()=>{if(!w.current)return;let x=i.current;x?.contentWindow&&x.contentWindow.postMessage({jsonrpc:"2.0",method:"ui/notifications/host-context-changed",params:{theme:r?"dark":"light"}},"*")},[r]),qe(()=>{let x=i.current;if(!x)return;let R=!1,S=E=>{x.contentWindow?.postMessage(E,"*")},D=E=>{if(R||E.source!==x.contentWindow)return;let k=E.data;if(!k||typeof k!="object"||k.jsonrpc!=="2.0")return;let O=k.method,N=k.id;if(O==="ui/initialize"&&N!=null){S({jsonrpc:"2.0",id:N,result:{protocolVersion:k.params?.protocolVersion??jt,hostInfo:{name:"WaniWani Chat",version:"1.0.0"},hostCapabilities:{openLinks:{},message:{}},hostContext:{theme:f.current?"dark":"light",displayMode:"inline"}}});return}if(O==="ui/notifications/initialized"){w.current=!0;let H=g.current,F=m.current;S({jsonrpc:"2.0",method:"ui/notifications/tool-input",params:{arguments:H}});let j=F.content??[{type:"text",text:JSON.stringify(F)}];S({jsonrpc:"2.0",method:"ui/notifications/tool-result",params:{content:j,structuredContent:F.structuredContent}});return}if(O==="ui/notifications/size-changed"){let H=k.params,F=typeof H?.height=="number"?H.height:void 0,j=typeof H?.width=="number"?H.width:void 0,G=v.current,Me=F!==void 0&&F!==G.height,ke=j!==void 0&&j!==G.width;if(!Me&&!ke)return;if(Me&&F!==void 0){G.height=F;let fe=M(F);if(x.animate){let Se=x.getBoundingClientRect().height;Math.abs(Se-fe)>2&&x.animate([{height:`${Se}px`},{height:`${fe}px`}],{duration:_t,easing:"ease-out",fill:"forwards"})}T(fe)}ke&&a&&j!==void 0&&(G.width=j,l(j));return}if(O==="ui/open-link"&&N!=null){let H=k.params?.url;typeof H=="string"&&(h.current?h.current(H):window.open(H,"_blank","noopener,noreferrer")),S({jsonrpc:"2.0",id:N,result:{}});return}if(O==="ui/message"&&N!=null){P.current&&k.params&&P.current(k.params),S({jsonrpc:"2.0",id:N,result:{}});return}if(O==="ui/request-display-mode"&&N!=null){S({jsonrpc:"2.0",id:N,result:{}});return}if(O==="ui/resource-teardown"&&N!=null){S({jsonrpc:"2.0",id:N,result:{}});return}O==="ping"&&N!=null&&S({jsonrpc:"2.0",id:N,result:{}})};return window.addEventListener("message",D),()=>{R=!0,window.removeEventListener("message",D)}},[a,M]),Kt("iframe",{ref:i,src:b,sandbox:"allow-scripts allow-forms allow-same-origin",className:u("rounded-md border border-border",s),style:{height:d||void 0,minWidth:c?`min(${c}px, 100%)`:void 0,width:"100%",border:"none",colorScheme:"auto"},title:"MCP App"})}import{Component as Vt}from"react";import{jsx as Ge,jsxs as qt}from"react/jsx-runtime";var ie=class extends Vt{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e){console.warn("[WaniWani] Widget failed to render:",e.message)}render(){return this.state.hasError?qt("div",{className:"flex items-center justify-between rounded-md border border-border bg-muted/50 px-4 py-3 text-sm text-muted-foreground",children:[Ge("span",{children:"Widget failed to load"}),Ge("button",{type:"button",onClick:()=>this.setState({hasError:!1}),className:"text-xs font-medium text-primary hover:underline",children:"Retry"})]}):this.props.children}};import{Fragment as Gt,jsx as I,jsxs as _}from"react/jsx-runtime";function Jt(t){return t.replace(/[-_]/g," ").replace(/^\w/,e=>e.toUpperCase())}function le({messages:t,status:e,welcomeMessage:o,resourceEndpoint:n,isDark:r}){let s=e==="submitted"||e==="streaming",a=t[t.length-1],p=t.length>0,C=s&&(!p||a.role==="user");return _(Gt,{children:[o&&I(ne,{from:"assistant",children:I(se,{children:I(ae,{children:o})})}),t.map(i=>{let g=i.parts.filter(c=>c.type==="text"),m=i.parts.filter(c=>c.type==="reasoning"),v=i.parts.filter(c=>c.type==="file"),w=i.parts.filter(c=>"toolCallId"in c),d=i===a&&i.role==="assistant",T=g.length>0;return _(ne,{from:i.role,children:[m.map((c,l)=>I(Be,{text:c.text},`reasoning-${i.id}-${l}`)),w.map(c=>{let l="output"in c?c.output:void 0,h=l!==void 0?_e(l):void 0,P=l!==void 0?Ke(l):!1;return _("div",{children:[_(Oe,{defaultOpen:c.state==="output-available",children:[I(ze,{title:c.title??Jt(c.toolName),state:c.state}),_(We,{children:[I($e,{input:c.input}),l!==void 0&&I(Ve,{output:l,errorText:"errorText"in c?c.errorText:void 0})]})]}),h&&l!==void 0&&I(ie,{children:I(ve,{resourceUri:h,toolInput:c.input??{},toolResult:{content:l.content,structuredContent:l.structuredContent},resourceEndpoint:n,isDark:r,autoHeight:P})})]},c.toolCallId)}),_(se,{children:[v.length>0&&I(Ae,{files:v}),T?g.map((c,l)=>I(ae,{children:c.type==="text"?c.text:""},`${i.id}-${l}`)):d&&s&&I(be,{})]})]},i.id)}),C&&I(ne,{from:"assistant",children:I(se,{children:I(be,{})})})]})}import{jsx as we}from"react/jsx-runtime";function ue({suggestions:t,isLoading:e,onSelect:o,className:n,...r}){return t.length===0&&!e?null:we("div",{className:u("flex flex-wrap gap-2 px-3 py-2",n),...r,children:e?[0,1,2].map(s=>we("div",{className:"h-7 rounded-full bg-accent animate-pulse",style:{width:`${60+s*20}px`}},s)):t.map((s,a)=>we("button",{type:"button",onClick:()=>o(s),className:u("rounded-full border border-border bg-background px-3 py-1 text-xs","text-foreground hover:bg-accent hover:border-primary/30","transition-all duration-200 ease-out cursor-pointer","animate-[ww-fade-in_0.2s_ease-out_both]"),style:{animationDelay:`${a*50}ms`},children:s},s))})}import{useChat as Xt}from"@ai-sdk/react";import{DefaultChatTransport as Zt}from"ai";import{useCallback as Xe,useRef as Qt,useState as Yt}from"react";function ce(t){let{api:e="https://app.waniwani.ai/api/chat",headers:o,body:n,onMessageSent:r,onResponseReceived:s}=t,a=Qt(new Zt({api:e,headers:{...o},body:n})),{messages:p,sendMessage:C,status:i}=Xt({transport:a.current,onFinish(){s?.()},onError(h){console.warn("[WaniWani] Chat error:",h.message)}}),[g,m]=Yt(""),v=Xe(h=>{let P=!!h.text?.trim(),M=!!h.files?.length;(P||M)&&(C({text:h.text||"",files:h.files}),r?.(h.text||""),m(""))},[C,r]),w=Xe(h=>{m(h.target.value)},[]),d=i==="submitted"||i==="streaming",T=p[p.length-1],c=p.length>0,l=d&&(!c||T.role==="user");return{messages:p,status:i,text:g,setText:m,handleSubmit:v,handleTextChange:w,isLoading:d,showLoaderBubble:l,lastMessage:T,hasMessages:c,sendMessage:C}}import{useCallback as eo,useEffect as pe,useRef as Ze,useState as Qe}from"react";function to(t){try{let e=new URL(t);return e.pathname="/api/mcp/suggestions",e.toString()}catch{return"/api/mcp/suggestions"}}function me(t){let{messages:e,status:o,initialSuggestions:n,suggestions:r,api:s="https://app.waniwani.ai/api/chat",apiKey:a,headers:p}=t,[C,i]=Qe([]),[g,m]=Qe(!1),v=Ze(o),w=Ze(null),d=!!r,T=typeof r=="object"?r.count??3:3,c=e.some(M=>M.role==="user"),l=to(s),h=eo(()=>{i([]),w.current?.abort(),w.current=null},[]);pe(()=>{!c&&n?.length&&i(n)},[c,n]);let P=e[e.length-1];return pe(()=>{P?.role==="user"&&h()},[P,h]),pe(()=>{let M=v.current;if(v.current=o,M==="streaming"&&o==="ready"&&d){let b=new AbortController;w.current?.abort(),w.current=b,m(!0),fetch(l,{method:"POST",headers:{"Content-Type":"application/json",...a?{Authorization:`Bearer ${a}`}:{},...p},body:JSON.stringify({messages:e,count:T}),signal:b.signal}).then(f=>{if(!f.ok)throw new Error(`Suggestions API error: ${f.status}`);return f.json()}).then(f=>{b.signal.aborted||i(f.suggestions??[])}).catch(f=>{f.name!=="AbortError"&&console.warn("[WaniWani] Failed to fetch suggestions:",f)}).finally(()=>{b.signal.aborted||m(!1)})}},[o,d,l,a,e,T,p]),pe(()=>()=>{w.current?.abort()},[]),{suggestions:C,isLoading:g,clear:h}}var Ye={primaryColor:"#6366f1",primaryForeground:"#1f2937",backgroundColor:"#ffffff",textColor:"#1f2937",mutedColor:"#6b7280",borderColor:"#e5e7eb",assistantBubbleColor:"#f3f4f6",userBubbleColor:"#f4f4f4",inputBackgroundColor:"#f9fafb",borderRadius:16,messageBorderRadius:12,fontFamily:"system-ui, -apple-system, 'Segoe UI', sans-serif",headerBackgroundColor:"#ffffff",headerTextColor:"#1f2937",statusColor:"#22c55e",toolCardColor:"#f4f4f5"},oo={backgroundColor:"#212121",headerBackgroundColor:"#1e1e1e",headerTextColor:"#ececec",textColor:"#ececec",primaryForeground:"#ffffff",mutedColor:"#8e8ea0",borderColor:"#303030",assistantBubbleColor:"#2f2f2f",userBubbleColor:"#303030",inputBackgroundColor:"#2f2f2f",primaryColor:"#6366f1",statusColor:"#22c55e",toolCardColor:"#262626"},ro={primaryColor:["--ww-primary","--color-primary"],primaryForeground:["--ww-primary-fg","--color-primary-foreground"],backgroundColor:["--ww-bg","--color-background"],textColor:["--ww-text","--color-foreground","--color-accent-foreground"],mutedColor:["--ww-muted","--color-muted-foreground"],borderColor:["--ww-border","--color-border"],assistantBubbleColor:["--ww-assistant-bubble","--color-accent"],userBubbleColor:["--ww-user-bubble"],inputBackgroundColor:["--ww-input-bg","--color-input"],borderRadius:["--ww-radius","--radius"],messageBorderRadius:["--ww-msg-radius"],fontFamily:["--ww-font"],headerBackgroundColor:["--ww-header-bg"],headerTextColor:["--ww-header-text"],statusColor:["--ww-status"],toolCardColor:["--ww-tool-card","--color-tool-card"]};function V(t){return{...Ye,...t}}function de(t){let e=t.backgroundColor.replace("#",""),o=parseInt(e.substring(0,2),16),n=parseInt(e.substring(2,4),16),r=parseInt(e.substring(4,6),16);return(o*299+n*587+r*114)/1e3<128}function q(t){let e={};for(let[o,n]of Object.entries(ro)){let r=t[o],s=typeof r=="number"?`${r}px`:String(r);for(let a of n)e[a]=s}return e}import{jsx as B,jsxs as Te}from"react/jsx-runtime";var Pe=no(function(e,o){let{theme:n,width:r=600,expandedHeight:s=400,allowAttachments:a=!1,welcomeMessage:p,resourceEndpoint:C,api:i}=e,g=C??(i?`${i}/resource`:void 0),m=V(n),v=q(m),w=de(m),d=ce(e),T=me({messages:d.messages,status:d.status,initialSuggestions:e.initialSuggestions,suggestions:e.suggestions,api:e.api,apiKey:e.apiKey,headers:e.headers}),c=et(f=>{T.clear(),d.handleSubmit({text:f,files:[]})},[T.clear,d.handleSubmit]);ao(o,()=>({sendMessage:f=>{d.handleSubmit({text:f,files:[]})}}),[d.handleSubmit]);let[l,h]=lo(!1),P=io(null),M=l;so(()=>{if(!l)return;let f=x=>{P.current&&!P.current.contains(x.target)&&h(!1)};return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[l]);let b=et(()=>{h(!0)},[]);return Te("div",{ref:P,style:{...v,width:r},"data-waniwani-chat":"","data-waniwani-layout":"bar",...w?{"data-waniwani-dark":""}:{},className:"flex flex-col font-[family-name:var(--ww-font)] text-foreground",children:[B("div",{className:u("overflow-hidden bg-background/80 backdrop-blur-xl transition-all duration-300 ease-out",M?"opacity-100 translate-y-0":"opacity-0 translate-y-2 pointer-events-none max-h-0"),style:{...M?{maxHeight:s}:void 0,maskImage:"linear-gradient(to bottom, transparent, black 24px, black calc(100% - 16px), transparent), linear-gradient(to right, transparent, black 16px, black calc(100% - 16px), transparent)",maskComposite:"intersect",WebkitMaskImage:"linear-gradient(to bottom, transparent, black 24px, black calc(100% - 16px), transparent), linear-gradient(to right, transparent, black 16px, black calc(100% - 16px), transparent)",WebkitMaskComposite:"source-in"},children:Te(Z,{className:"flex-1",style:{height:s},children:[B(Q,{children:B(le,{messages:d.messages,status:d.status,welcomeMessage:p,resourceEndpoint:g,isDark:w})}),B(Y,{})]})}),B(ue,{suggestions:T.suggestions,isLoading:T.isLoading,onSelect:c}),B("div",{className:"shrink-0",children:B(ee,{onSubmit:d.handleSubmit,globalDrop:a,multiple:a,className:u("rounded-[var(--ww-radius)] shadow-sm transition-all duration-300 ease-out"),children:Te("div",{className:"flex items-center gap-1 px-3 py-2",children:[a&&B(re,{}),B(te,{onChange:d.handleTextChange,value:d.text,placeholder:"Ask anything...",onFocus:b,className:"min-h-0 py-1.5 px-2"}),B(oe,{status:d.status})]})})})]})});import{forwardRef as uo,useCallback as co,useImperativeHandle as po}from"react";import{jsx as L,jsxs as J}from"react/jsx-runtime";var mo=uo(function(e,o){let{theme:n,title:r="Assistant",subtitle:s,showStatus:a=!0,width:p=500,height:C=600,allowAttachments:i=!1,welcomeMessage:g,resourceEndpoint:m,api:v}=e,w=m??(v?`${v}/resource`:void 0),d=V(n),T=q(d),c=de(d),l=ce(e),h=me({messages:l.messages,status:l.status,initialSuggestions:e.initialSuggestions,suggestions:e.suggestions,api:e.api,apiKey:e.apiKey,headers:e.headers}),P=co(M=>{h.clear(),l.handleSubmit({text:M,files:[]})},[h.clear,l.handleSubmit]);return po(o,()=>({sendMessage:M=>{l.handleSubmit({text:M,files:[]})}}),[l.handleSubmit]),J("div",{style:{...T,width:p,height:C},"data-waniwani-chat":"","data-waniwani-layout":"card",...c?{"data-waniwani-dark":""}:{},className:"flex flex-col font-[family-name:var(--ww-font)] text-foreground bg-background rounded-[var(--ww-radius)] border border-border shadow-md overflow-hidden",children:[J("div",{className:"shrink-0 flex items-center gap-3 px-4 py-2 border-b border-border",style:{backgroundColor:d.headerBackgroundColor,color:d.headerTextColor},children:[a&&L("span",{className:"size-2.5 rounded-full bg-status"}),J("div",{className:"flex-1 min-w-0",children:[L("div",{className:"text-xs font-semibold truncate",children:r}),s&&L("div",{className:"text-[11px] text-muted-foreground truncate",children:s})]})]}),J(Z,{className:"flex-1 min-h-0 bg-background",children:[L(Q,{children:L(le,{messages:l.messages,status:l.status,welcomeMessage:g,resourceEndpoint:w,isDark:c})}),L(Y,{})]}),L(ue,{suggestions:h.suggestions,isLoading:h.isLoading,onSelect:P,className:"border-t border-border"}),L("div",{className:"shrink-0 border-t border-border bg-background",children:L(ee,{onSubmit:l.handleSubmit,globalDrop:i,multiple:i,className:u("rounded-none border-0"),children:J("div",{className:"flex items-center gap-1 px-3 py-2",children:[i&&L(re,{}),L(te,{onChange:l.handleTextChange,value:l.text,placeholder:"Ask anything...",className:"min-h-0 py-1.5 px-2"}),L(oe,{status:l.status})]})})})]})});export{Pe as ChatBar,mo as ChatCard,Pe as ChatWidget,oo as DARK_THEME,Ye as DEFAULT_THEME,ve as McpAppFrame,V as mergeTheme,q as themeToCSSProperties};
|
|
2
|
+
import{forwardRef as Mo,useCallback as ve,useEffect as pt,useImperativeHandle as ko,useRef as mt,useState as dt}from"react";import{ArrowDownIcon as xt}from"lucide-react";import{useCallback as yt}from"react";import{StickToBottom as Ue,useStickToBottomContext as Ct}from"use-stick-to-bottom";import{clsx as gt}from"clsx";import{twMerge as ht}from"tailwind-merge";function l(...t){return ht(gt(t))}import{jsx as bt}from"react/jsx-runtime";var V=({className:t,variant:e="default",size:o="default",type:n="button",...r})=>bt("button",{type:n,className:l("inline-flex cursor-pointer items-center justify-center rounded-md font-medium transition-colors disabled:pointer-events-none disabled:opacity-50",e==="default"&&"bg-primary text-primary-foreground hover:bg-primary/90",e==="outline"&&"border border-border bg-background hover:bg-accent hover:text-accent-foreground",e==="ghost"&&"hover:bg-accent hover:text-accent-foreground",o==="default"&&"h-9 px-4 py-2 text-sm",o==="sm"&&"h-8 px-3 text-xs",o==="icon"&&"size-9",o==="icon-sm"&&"size-7",t),...r});import{jsx as oe}from"react/jsx-runtime";var re=({className:t,...e})=>oe(Ue,{className:l("relative flex-1 overflow-y-hidden",t),initial:"smooth",resize:"smooth",role:"log",...e}),ne=({className:t,...e})=>oe(Ue.Content,{className:l("flex flex-col gap-8 p-4",t),...e}),se=({className:t,...e})=>{let{isAtBottom:o,scrollToBottom:n}=Ct(),r=yt(()=>{n()},[n]);return!o&&oe(V,{className:l("absolute bottom-4 left-[50%] translate-x-[-50%] rounded-full",t),onClick:r,size:"icon",variant:"outline",...e,children:oe(xt,{className:"size-4"})})};import{ArrowUpIcon as vt,LoaderIcon as Tt,PaperclipIcon as wt,SquareIcon as Pt,XIcon as St}from"lucide-react";import{nanoid as Mt}from"nanoid";import{createContext as kt,useCallback as q,useContext as Et,useEffect as Se,useMemo as It,useRef as Me,useState as Oe}from"react";import{jsx as O,jsxs as We}from"react/jsx-runtime";var Rt=async t=>{try{let o=await(await fetch(t)).blob();return new Promise(n=>{let r=new FileReader;r.onloadend=()=>n(r.result),r.onerror=()=>n(null),r.readAsDataURL(o)})}catch{return null}},ze=kt(null),_e=()=>{let t=Et(ze);if(!t)throw new Error("usePromptInputAttachments must be used within a PromptInput");return t},ae=({className:t,accept:e,multiple:o,globalDrop:n,maxFiles:r,maxFileSize:s,onSubmit:a,children:u,...C})=>{let m=Me(null),c=Me(null),[g,T]=Oe([]),v=Me(g);Se(()=>{v.current=g},[g]);let S=q(()=>{m.current?.click()},[]),w=q(f=>{let h=[...f];if(h.length===0)return;let M=b=>s?b.size<=s:!0,N=h.filter(M);T(b=>{let I=typeof r=="number"?Math.max(0,r-b.length):void 0,R=typeof I=="number"?N.slice(0,I):N;return[...b,...R.map(k=>({filename:k.name,id:Mt(),mediaType:k.type,type:"file",url:URL.createObjectURL(k)}))]})},[r,s]),d=q(f=>{T(h=>{let M=h.find(N=>N.id===f);return M?.url&&URL.revokeObjectURL(M.url),h.filter(N=>N.id!==f)})},[]),i=q(()=>{T(f=>{for(let h of f)h.url&&URL.revokeObjectURL(h.url);return[]})},[]);Se(()=>()=>{for(let f of v.current)f.url&&URL.revokeObjectURL(f.url)},[]);let p=q(f=>{f.currentTarget.files&&w(f.currentTarget.files),f.currentTarget.value=""},[w]);Se(()=>{if(!n)return;let f=M=>{M.dataTransfer?.types?.includes("Files")&&M.preventDefault()},h=M=>{M.dataTransfer?.types?.includes("Files")&&M.preventDefault(),M.dataTransfer?.files&&M.dataTransfer.files.length>0&&w(M.dataTransfer.files)};return document.addEventListener("dragover",f),document.addEventListener("drop",h),()=>{document.removeEventListener("dragover",f),document.removeEventListener("drop",h)}},[w,n]);let y=q(async f=>{f.preventDefault();let h=f.currentTarget,N=new FormData(h).get("message")||"";h.reset();let b=await Promise.all(g.map(async({id:I,...R})=>{if(R.url?.startsWith("blob:")){let k=await Rt(R.url);return{...R,url:k??R.url}}return R}));try{let I=a({files:b,text:N},f);I instanceof Promise&&await I,i()}catch{}},[g,a,i]),L=It(()=>({add:w,clear:i,files:g,openFileDialog:S,remove:d}),[g,w,d,i,S]);return We(ze.Provider,{value:L,children:[O("input",{accept:e,"aria-label":"Upload files",className:"hidden",multiple:o,onChange:p,ref:m,title:"Upload files",type:"file"}),O("form",{className:l("flex w-full flex-col rounded-lg border border-border bg-background",t),onSubmit:y,ref:c,...C,children:u})]})};var ie=({onChange:t,onKeyDown:e,className:o,placeholder:n="What would you like to know?",...r})=>{let s=_e(),[a,u]=Oe(!1),C=q(c=>{if(e?.(c),!c.defaultPrevented){if(c.key==="Enter"){if(a||c.nativeEvent.isComposing||c.shiftKey)return;c.preventDefault();let{form:g}=c.currentTarget;if(g?.querySelector('button[type="submit"]')?.disabled)return;g?.requestSubmit()}if(c.key==="Backspace"&&c.currentTarget.value===""&&s.files.length>0){c.preventDefault();let g=s.files.at(-1);g&&s.remove(g.id)}}},[e,a,s]),m=q(c=>{let g=c.clipboardData?.items;if(!g)return;let T=[];for(let v of g)if(v.kind==="file"){let S=v.getAsFile();S&&T.push(S)}T.length>0&&(c.preventDefault(),s.add(T))},[s]);return O("textarea",{className:l("field-sizing-content max-h-48 min-h-16 w-full resize-none border-0 bg-transparent px-3 py-3 text-sm outline-none placeholder:text-muted-foreground",o),name:"message",onCompositionEnd:()=>u(!1),onCompositionStart:()=>u(!0),onKeyDown:C,onPaste:m,placeholder:n,onChange:t,...r})},le=({className:t,status:e,onStop:o,onClick:n,children:r,...s})=>{let a=e==="submitted"||e==="streaming",u=O(vt,{className:"size-4"});e==="submitted"?u=O(Tt,{className:"size-4 animate-spin"}):e==="streaming"&&(u=O(Pt,{className:"size-4"}));let C=q(m=>{if(a&&o){m.preventDefault(),o();return}n?.(m)},[a,o,n]);return O(V,{"aria-label":a?"Stop":"Submit",className:l("bg-foreground text-background hover:bg-foreground",t),onClick:C,size:"icon-sm",type:a&&o?"button":"submit",variant:"ghost",...s,children:r??u})},ue=({className:t,children:e,...o})=>{let n=_e();return n.files.length>0?We(V,{className:l("group relative",t),onClick:()=>n.clear(),size:"icon-sm",type:"button",variant:"ghost","aria-label":"Remove all attachments",...o,children:[O("span",{className:"flex size-5 items-center justify-center rounded-full bg-primary text-[10px] font-medium text-primary-foreground transition-opacity group-hover:opacity-0",children:n.files.length}),O(St,{className:"absolute size-4 opacity-0 transition-opacity group-hover:opacity-100"})]}):O(V,{className:l(t),onClick:()=>n.openFileDialog(),size:"icon-sm",type:"button",variant:"ghost",...o,children:e??O(wt,{className:"size-4"})})};import{FileIcon as Lt}from"lucide-react";import{jsx as Y,jsxs as At}from"react/jsx-runtime";var $e=({files:t,className:e,...o})=>t.length===0?null:Y("div",{className:l("flex flex-wrap gap-1.5",e),...o,children:t.map((n,r)=>Y(Nt,{file:n},r))});function Nt({file:t}){return t.mediaType?.startsWith("image/")&&t.url?Y("img",{src:t.url,alt:t.filename??"attachment",className:"h-16 max-w-32 rounded object-cover"}):At("span",{className:"inline-flex items-center gap-1.5 rounded bg-background/20 px-2 py-1 text-xs",children:[Y(Lt,{className:"size-3 shrink-0"}),Y("span",{className:"max-w-24 truncate",children:t.filename??"file"})]})}import{jsx as je}from"react/jsx-runtime";var ke=({className:t,size:e=5,...o})=>je("div",{className:l("flex items-center gap-1",t),...o,children:[0,1,2].map(n=>je("div",{className:"rounded-full bg-muted-foreground/60",style:{width:e,height:e,animation:"ww-pulse 1.4s ease-in-out infinite",animationDelay:`${n*.2}s`}},n))});import{cjk as Ht}from"@streamdown/cjk";import{code as Bt}from"@streamdown/code";import{memo as Dt}from"react";import{Streamdown as Ft}from"streamdown";import{jsx as Ee}from"react/jsx-runtime";var ce=({className:t,from:e,...o})=>Ee("div",{className:l("group flex w-full max-w-[95%] flex-col gap-2",e==="user"?"is-user ml-auto justify-end":"is-assistant",t),...o}),pe=({children:t,className:e,...o})=>Ee("div",{className:l("flex w-fit min-w-0 max-w-full flex-col gap-2 overflow-hidden text-base","group-[.is-user]:ml-auto group-[.is-user]:rounded-lg group-[.is-user]:bg-user-bubble group-[.is-user]:px-4 group-[.is-user]:py-3 group-[.is-user]:text-primary-foreground","group-[.is-assistant]:text-foreground",e),...o,children:t}),Ut={cjk:Ht,code:Bt},me=Dt(({className:t,...e})=>Ee(Ft,{className:l("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",t),plugins:Ut,...e}),(t,e)=>t.children===e.children);me.displayName="MessageResponse";import{jsx as Ot}from"react/jsx-runtime";function qe({className:t,text:e,...o}){return e?Ot("pre",{className:l("mb-2 overflow-x-auto whitespace-pre-wrap break-words text-xs font-mono text-muted-foreground",t),...o,children:e}):null}import{BracesIcon as zt,CheckIcon as _t,ChevronDownIcon as Wt,ChevronRightIcon as $t,ClipboardCopyIcon as jt,ServerIcon as br}from"lucide-react";import{createContext as qt,useCallback as Kt,useContext as Ve,useEffect as Vt,useMemo as Jt,useRef as Gt,useState as Ie}from"react";import{Fragment as Ke,jsx as P,jsxs as J}from"react/jsx-runtime";function Xt(t,e=80){if(t==null)return String(t);if(typeof t!="object")return String(t).slice(0,e);if(Array.isArray(t))return`Array(${t.length})`;let o=JSON.stringify(t);if(o.length<=e)return o;let n=Object.entries(t),r=[],s=e-2;for(let[a,u]of n){if(s<=8)break;let C=a.length>4?`${a.slice(0,4)}\u2026`:a,m;typeof u=="string"?m=u.length>2?`'${u.slice(0,1)}\u2026`:`'${u}'`:Array.isArray(u)?m=`Array(${u.length})`:typeof u=="object"&&u!==null?m="{\u2026}":m=String(u);let c=`${C}\u2009${m}`;r.push(c),s-=c.length+3}return`{${r.join(", ")}}`}function Yt({text:t,className:e}){let[o,n]=Ie(!1),r=Gt(null);Vt(()=>()=>{r.current&&clearTimeout(r.current)},[]);let s=Kt(async a=>{a.stopPropagation();try{await navigator.clipboard.writeText(t),n(!0),r.current&&clearTimeout(r.current),r.current=setTimeout(()=>n(!1),2e3)}catch{}},[t]);return P(V,{variant:"ghost",size:"sm",onClick:s,className:l("h-auto gap-1 px-1.5 py-0.5 text-xs text-muted-foreground hover:text-foreground",e),children:o?J(Ke,{children:[P(_t,{className:"size-3.5"}),P("span",{children:"Copied"})]}):J(Ke,{children:[P(jt,{className:"size-3.5"}),P("span",{children:"Copy"})]})})}function Je({data:t,label:e,className:o,...n}){let[r,s]=Ie(!1),a=Jt(()=>JSON.stringify(t,null,2),[t]),u=Xt(t);return J("div",{className:l("rounded-lg bg-tool-card",o),...n,children:[J("div",{className:"flex items-center justify-between px-3 pt-2.5 pb-1.5",children:[P("span",{className:"text-xs font-medium text-muted-foreground",children:e}),P(Yt,{text:a})]}),J("button",{type:"button",onClick:()=>s(C=>!C),className:"flex w-full items-start gap-2 px-3 pb-3 text-left",children:[P($t,{className:l("mt-0.5 size-3.5 shrink-0 text-muted-foreground transition-transform duration-150",r&&"rotate-90")}),r?P("pre",{className:"overflow-x-auto text-xs font-mono text-foreground whitespace-pre-wrap break-all",children:P("code",{children:a})}):P("span",{className:"truncate text-xs font-mono text-foreground/80",children:u})]})]})}var Re=qt({open:!1,toggle:()=>{}});function Ge({className:t,defaultOpen:e=!1,children:o,...n}){let[r,s]=Ie(e);return P(Re.Provider,{value:{open:r,toggle:()=>s(a=>!a)},children:P("div",{className:l("mb-4 w-full",t),"data-state":r?"open":"closed",...n,children:o})})}function Xe({className:t,title:e,state:o,...n}){let{open:r,toggle:s}=Ve(Re),a=o==="input-available"||o==="input-streaming";return J("button",{type:"button",onClick:s,className:l("flex w-full items-center justify-between gap-3 py-1.5",t),"aria-expanded":r,...n,children:[J("div",{className:"flex min-w-0 items-center gap-2",children:[P(zt,{className:"size-4 shrink-0 text-muted-foreground"}),P("span",{className:"truncate text-sm font-medium",children:e}),a&&P("span",{className:"size-2 shrink-0 rounded-full bg-primary animate-pulse"})]}),P(Wt,{className:l("size-4 shrink-0 text-muted-foreground transition-transform duration-200",r&&"rotate-180")})]})}function Ye({className:t,children:e,...o}){let{open:n}=Ve(Re);return P("div",{className:l("grid transition-[grid-template-rows,opacity] duration-200 ease-out",n?"grid-rows-[1fr] opacity-100":"grid-rows-[0fr] opacity-0"),children:P("div",{className:"min-h-0 overflow-hidden",children:P("div",{className:l("mt-2 space-y-3 rounded-lg border border-border bg-background p-3",t),...o,children:e})})})}function Ze({className:t,input:e,...o}){return P(Je,{data:e,label:"Request",className:t,...o})}function Qe(t){if(typeof t!="object"||t===null)return;let e=t._meta;if(typeof e!="object"||e===null)return;let o=e.ui;if(!(typeof o!="object"||o===null))return o}function et(t){let e=Qe(t)?.resourceUri;return typeof e=="string"?e:void 0}function tt(t){return Qe(t)?.autoHeight===!0}function ot({className:t,output:e,errorText:o,...n}){return e||o?o?J("div",{className:l("space-y-2",t),...n,children:[P("h4",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Error"}),P("div",{className:"rounded-lg bg-destructive/10 p-3 text-xs text-destructive",children:o})]}):P(Je,{data:e,label:"Response",className:t,...n}):null}import{useCallback as Zt,useEffect as rt,useMemo as Qt,useRef as W,useState as nt}from"react";import{jsx as ao}from"react/jsx-runtime";var eo="/api/mcp/resource",to=500,oo=0,ro="2026-01-26",no=300,so=3e3,Le=3;function Ne({resourceUri:t,toolInput:e,toolResult:o,resourceEndpoint:n=eo,isDark:r=!1,className:s,autoHeight:a=!0,onOpenLink:u,onFollowUp:C}){let m=W(null),c=W(e),g=W(o),T=W({width:0,height:0}),v=W(null),S=W(!1),w=W(0),[d,i]=nt(oo),[p,y]=nt(void 0),L=W(u),f=W(C);c.current=e,g.current=o,L.current=u,f.current=C;let h=Zt(b=>a?Math.max(b,0):Math.min(Math.max(b,50),to),[a]),M=Qt(()=>`${n}?uri=${encodeURIComponent(t)}`,[n,t]),N=W(r);return N.current=r,rt(()=>{if(!S.current)return;let b=m.current;b?.contentWindow&&b.contentWindow.postMessage({jsonrpc:"2.0",method:"ui/notifications/host-context-changed",params:{theme:r?"dark":"light"}},"*")},[r]),rt(()=>{let b=m.current;if(!b)return;let I=!1,R=!1,k=(...E)=>console.debug("[McpAppFrame]",...E);k("effect mounted, waiting for handshake");let A=setTimeout(()=>{if(I||R)return;if(w.current>=Le){k("handshake failed after",Le,"retries, giving up");return}w.current+=1,k("handshake timeout, reloading iframe (retry",w.current,"of",Le,")");let E=new URL(b.src);E.searchParams.set("_retry",String(w.current)),b.src=E.toString()},so),x=E=>{k("\u2192 send",E.method??`response:${E.id}`,E),b.contentWindow?.postMessage(E,"*")},H=E=>{if(I||E.source!==b.contentWindow)return;let D=E.data;if(!D||typeof D!="object"||D.jsonrpc!=="2.0")return;let j=D.method,F=D.id;if(k("\u2190 recv",j??`response:${F}`,D),j==="ui/initialize"&&F!=null){R=!0,clearTimeout(A),k("handshake started"),x({jsonrpc:"2.0",id:F,result:{protocolVersion:D.params?.protocolVersion??ro,hostInfo:{name:"WaniWani Chat",version:"1.0.0"},hostCapabilities:{openLinks:{},message:{}},hostContext:{theme:N.current?"dark":"light",displayMode:"inline"}}});return}if(j==="ui/notifications/initialized"){k("handshake complete, sending tool data"),S.current=!0;let z=c.current,_=g.current;x({jsonrpc:"2.0",method:"ui/notifications/tool-input",params:{arguments:z}});let K=_.content??[{type:"text",text:JSON.stringify(_)}];x({jsonrpc:"2.0",method:"ui/notifications/tool-result",params:{content:K,structuredContent:_.structuredContent}});return}if(j==="ui/notifications/size-changed"){let z=D.params,_=typeof z?.height=="number"?z.height:void 0,K=typeof z?.width=="number"?z.width:void 0,G=T.current,Te=_!==void 0&&_!==G.height,we=K!==void 0&&K!==G.width;if(k("size-changed",{newHeight:_,newWidth:K,lastHeight:G.height,lastWidth:G.width,heightChanged:Te,widthChanged:we}),!Te&&!we)return;if(Te&&_!==void 0){G.height=_;let Pe=h(_),Fe=b.getBoundingClientRect().height;if(v.current&&(v.current.cancel(),v.current=null),i(Pe),b.animate&&Math.abs(Fe-Pe)>2){let te=b.animate([{height:`${Fe}px`},{height:`${Pe}px`}],{duration:no,easing:"ease-out",fill:"forwards"});v.current=te,te.onfinish=()=>{v.current===te&&(te.cancel(),v.current=null)}}}we&&a&&K!==void 0&&(G.width=K,y(K));return}if(j==="ui/open-link"&&F!=null){let z=D.params?.url;typeof z=="string"&&(L.current?L.current(z):window.open(z,"_blank","noopener,noreferrer")),x({jsonrpc:"2.0",id:F,result:{}});return}if(j==="ui/message"&&F!=null){f.current&&D.params&&f.current(D.params),x({jsonrpc:"2.0",id:F,result:{}});return}if(j==="ui/request-display-mode"&&F!=null){x({jsonrpc:"2.0",id:F,result:{}});return}if(j==="ui/resource-teardown"&&F!=null){x({jsonrpc:"2.0",id:F,result:{}});return}j==="ping"&&F!=null&&x({jsonrpc:"2.0",id:F,result:{}})};return window.addEventListener("message",H),()=>{k("effect cleanup (disposed)"),I=!0,clearTimeout(A),window.removeEventListener("message",H)}},[a,h]),ao("iframe",{ref:m,src:M,sandbox:"allow-scripts allow-forms allow-same-origin",className:l("rounded-md border border-border",s),style:{height:d,minWidth:p?`min(${p}px, 100%)`:void 0,width:"100%",border:"none",colorScheme:"auto"},title:"MCP App"})}import{Component as io}from"react";import{jsx as st,jsxs as lo}from"react/jsx-runtime";var de=class extends io{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e){console.warn("[WaniWani] Widget failed to render:",e.message)}render(){return this.state.hasError?lo("div",{className:"flex items-center justify-between rounded-md border border-border bg-muted/50 px-4 py-3 text-sm text-muted-foreground",children:[st("span",{children:"Widget failed to load"}),st("button",{type:"button",onClick:()=>this.setState({hasError:!1}),className:"text-xs font-medium text-primary hover:underline",children:"Retry"})]}):this.props.children}};import{Fragment as co,jsx as B,jsxs as X}from"react/jsx-runtime";function uo(t){return t.replace(/[-_]/g," ").replace(/^\w/,e=>e.toUpperCase())}function fe({messages:t,status:e,welcomeMessage:o,resourceEndpoint:n,isDark:r,onFollowUp:s}){let a=e==="submitted"||e==="streaming",u=t[t.length-1],C=t.length>0,m=a&&(!C||u.role==="user");return X(co,{children:[o&&B(ce,{from:"assistant",children:B(pe,{children:B(me,{children:o})})}),t.map(c=>{let g=c.parts.filter(i=>i.type==="text"),T=c.parts.filter(i=>i.type==="reasoning"),v=c.parts.filter(i=>i.type==="file"),S=c.parts.filter(i=>"toolCallId"in i),w=c===u&&c.role==="assistant",d=g.length>0;return X(ce,{from:c.role,children:[T.map((i,p)=>B(qe,{text:i.text},`reasoning-${c.id}-${p}`)),S.map(i=>{let p="output"in i?i.output:void 0,y=p!==void 0?et(p):void 0,L=p!==void 0?tt(p):!1;return X("div",{children:[X(Ge,{defaultOpen:i.state==="output-available",children:[B(Xe,{title:i.title??uo(i.toolName),state:i.state}),X(Ye,{children:[B(Ze,{input:i.input}),p!==void 0&&B(ot,{output:p,errorText:"errorText"in i?i.errorText:void 0})]})]}),y&&p!==void 0&&B(de,{children:B(Ne,{resourceUri:y,toolInput:i.input??{},toolResult:{content:p.content,structuredContent:p.structuredContent},resourceEndpoint:n,isDark:r,autoHeight:L,onFollowUp:s})})]},i.toolCallId)}),X(pe,{children:[v.length>0&&B($e,{files:v}),d?g.map((i,p)=>B(me,{children:i.type==="text"?i.text:""},`${c.id}-${p}`)):w&&a&&B(ke,{})]})]},c.id)}),m&&B(ce,{from:"assistant",children:B(pe,{children:B(ke,{})})})]})}import{jsx as Ae}from"react/jsx-runtime";function ge({suggestions:t,isLoading:e,onSelect:o,className:n,...r}){return t.length===0&&!e?null:Ae("div",{className:l("flex flex-wrap gap-2 px-3 py-2",n),...r,children:e?[0,1,2].map(s=>Ae("div",{className:"h-7 rounded-full bg-accent animate-pulse",style:{width:`${60+s*20}px`}},s)):t.map((s,a)=>Ae("button",{type:"button",onClick:()=>o(s),className:l("rounded-full border border-border bg-background px-3 py-1 text-xs","text-foreground hover:bg-accent hover:border-primary/30","transition-all duration-200 ease-out cursor-pointer","animate-[ww-fade-in_0.2s_ease-out_both]"),style:{animationDelay:`${a*50}ms`},children:s},s))})}import{useChat as po}from"@ai-sdk/react";import{DefaultChatTransport as mo}from"ai";import{useCallback as at,useRef as fo,useState as go}from"react";function he(t){let{api:e="https://app.waniwani.ai/api/chat",headers:o,body:n,onMessageSent:r,onResponseReceived:s}=t,a=fo(new mo({api:e,headers:{...o},body:n})),{messages:u,sendMessage:C,status:m}=po({transport:a.current,onFinish(){s?.()},onError(p){console.warn("[WaniWani] Chat error:",p.message)}}),[c,g]=go(""),T=at(p=>{let y=!!p.text?.trim(),L=!!p.files?.length;(y||L)&&(C({text:p.text||"",files:p.files}),r?.(p.text||""),g(""))},[C,r]),v=at(p=>{g(p.target.value)},[]),S=m==="submitted"||m==="streaming",w=u[u.length-1],d=u.length>0,i=S&&(!d||w.role==="user");return{messages:u,status:m,text:c,setText:g,handleSubmit:T,handleTextChange:v,isLoading:S,showLoaderBubble:i,lastMessage:w,hasMessages:d,sendMessage:C}}import{useCallback as ho,useEffect as be,useRef as it,useState as lt}from"react";function bo(t){try{let e=new URL(t);return e.pathname="/api/mcp/suggestions",e.toString()}catch{return"/api/mcp/suggestions"}}function xe(t){let{messages:e,status:o,initialSuggestions:n,suggestions:r,api:s="https://app.waniwani.ai/api/chat",apiKey:a,headers:u}=t,[C,m]=lt([]),[c,g]=lt(!1),T=it(o),v=it(null),S=!!r,w=typeof r=="object"?r.count??3:3,d=e.some(L=>L.role==="user"),i=bo(s),p=ho(()=>{m([]),v.current?.abort(),v.current=null},[]);be(()=>{!d&&n?.length&&m(n)},[d,n]);let y=e[e.length-1];return be(()=>{y?.role==="user"&&p()},[y,p]),be(()=>{let L=T.current;if(T.current=o,L==="streaming"&&o==="ready"&&S){let f=new AbortController;v.current?.abort(),v.current=f,g(!0),fetch(i,{method:"POST",headers:{"Content-Type":"application/json",...a?{Authorization:`Bearer ${a}`}:{},...u},body:JSON.stringify({messages:e,count:w}),signal:f.signal}).then(h=>{if(!h.ok)throw new Error(`Suggestions API error: ${h.status}`);return h.json()}).then(h=>{f.signal.aborted||m(h.suggestions??[])}).catch(h=>{h.name!=="AbortError"&&console.warn("[WaniWani] Failed to fetch suggestions:",h)}).finally(()=>{f.signal.aborted||g(!1)})}},[o,S,i,a,e,w,u]),be(()=>()=>{v.current?.abort()},[]),{suggestions:C,isLoading:c,clear:p}}import{useEffect as xo,useRef as yo,useState as Co}from"react";var vo=50,To=30,wo=2e3,ut=500;function ye(t,e=!0){let[o,n]=Co(""),r=yo(void 0);return xo(()=>{if(!e){n("");return}let s=0,a=!1,u=!1,C=()=>{u||(a?(s--,n(t.slice(0,s)),s<=0?(a=!1,r.current=setTimeout(C,ut)):r.current=setTimeout(C,To)):(s++,n(t.slice(0,s)),s>=t.length?(a=!0,r.current=setTimeout(C,wo)):r.current=setTimeout(C,vo)))};return r.current=setTimeout(C,ut),()=>{u=!0,clearTimeout(r.current)}},[t,e]),o}var ct={primaryColor:"#6366f1",primaryForeground:"#1f2937",backgroundColor:"#ffffff",textColor:"#1f2937",mutedColor:"#6b7280",borderColor:"#e5e7eb",assistantBubbleColor:"#f3f4f6",userBubbleColor:"#f4f4f4",inputBackgroundColor:"#f9fafb",borderRadius:16,messageBorderRadius:12,fontFamily:"system-ui, -apple-system, 'Segoe UI', sans-serif",headerBackgroundColor:"#ffffff",headerTextColor:"#1f2937",statusColor:"#22c55e",toolCardColor:"#f4f4f5"},Po={backgroundColor:"#212121",headerBackgroundColor:"#1e1e1e",headerTextColor:"#ececec",textColor:"#ececec",primaryForeground:"#ffffff",mutedColor:"#8e8ea0",borderColor:"#303030",assistantBubbleColor:"#2f2f2f",userBubbleColor:"#303030",inputBackgroundColor:"#2f2f2f",primaryColor:"#6366f1",statusColor:"#22c55e",toolCardColor:"#262626"},So={primaryColor:["--ww-primary","--color-primary"],primaryForeground:["--ww-primary-fg","--color-primary-foreground"],backgroundColor:["--ww-bg","--color-background"],textColor:["--ww-text","--color-foreground","--color-accent-foreground"],mutedColor:["--ww-muted","--color-muted-foreground"],borderColor:["--ww-border","--color-border"],assistantBubbleColor:["--ww-assistant-bubble","--color-accent"],userBubbleColor:["--ww-user-bubble"],inputBackgroundColor:["--ww-input-bg","--color-input"],borderRadius:["--ww-radius","--radius"],messageBorderRadius:["--ww-msg-radius"],fontFamily:["--ww-font"],headerBackgroundColor:["--ww-header-bg"],headerTextColor:["--ww-header-text"],statusColor:["--ww-status"],toolCardColor:["--ww-tool-card","--color-tool-card"]};function Z(t){return{...ct,...t}}function Ce(t){let e=t.backgroundColor.replace("#",""),o=parseInt(e.substring(0,2),16),n=parseInt(e.substring(2,4),16),r=parseInt(e.substring(4,6),16);return(o*299+n*587+r*114)/1e3<128}function Q(t){let e={};for(let[o,n]of Object.entries(So)){let r=t[o],s=typeof r=="number"?`${r}px`:String(r);for(let a of n)e[a]=s}return e}import{jsx as $,jsxs as He}from"react/jsx-runtime";var Be=Mo(function(e,o){let{theme:n,width:r=600,expandedHeight:s=400,allowAttachments:a=!1,welcomeMessage:u,placeholder:C="Ask me anything...",triggerEvent:m="triggerDemoRequest",resourceEndpoint:c,api:g}=e,T=c??(g?`${g}/resource`:void 0),v=Z(n),S=Q(v),w=Ce(v),d=he(e),i=xe({messages:d.messages,status:d.status,initialSuggestions:e.initialSuggestions,suggestions:e.suggestions,api:e.api,apiKey:e.apiKey,headers:e.headers}),p=ve(x=>{let H=x.content.map(E=>E.text??"").join("").trim();H&&d.handleSubmit({text:H,files:[]})},[d.handleSubmit]),y=ve(x=>{i.clear(),d.handleSubmit({text:x,files:[]})},[i.clear,d.handleSubmit]),L=ye(C,!d.text),[f,h]=dt(!1),[M,N]=dt(!1),b=mt(null),I=mt(void 0),R=ve(()=>{let x=b.current;if(!x)return;x.scrollIntoView({behavior:"smooth",block:"center"});let H=x.querySelector("textarea");H&&setTimeout(()=>H.focus(),300),h(!0),N(!0),clearTimeout(I.current),I.current=setTimeout(()=>N(!1),2e3)},[]);ko(o,()=>({sendMessage:x=>{d.handleSubmit({text:x,files:[]}),R()},focus:R}),[d.handleSubmit,R]),pt(()=>{if(!m)return;let x=H=>{let E=H.detail,D=typeof E?.message=="string"?E.message:void 0;D&&d.handleSubmit({text:D,files:[]}),R()};return window.addEventListener(m,x),()=>window.removeEventListener(m,x)},[m,d.handleSubmit,R]);let k=f;pt(()=>{if(!f)return;let x=H=>{b.current&&!b.current.contains(H.target)&&h(!1)};return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},[f]);let A=ve(()=>{h(!0)},[]);return He("div",{ref:b,style:{...S,width:r},"data-waniwani-chat":"","data-waniwani-layout":"bar",...w?{"data-waniwani-dark":""}:{},className:"flex flex-col font-[family-name:var(--ww-font)] text-foreground",children:[$("div",{className:l("overflow-hidden bg-background/80 backdrop-blur-xl transition-all duration-300 ease-out",k?"opacity-100 translate-y-0":"opacity-0 translate-y-2 pointer-events-none max-h-0"),style:{...k?{maxHeight:s}:void 0,maskImage:"linear-gradient(to bottom, transparent, black 24px, black calc(100% - 16px), transparent), linear-gradient(to right, transparent, black 16px, black calc(100% - 16px), transparent)",maskComposite:"intersect",WebkitMaskImage:"linear-gradient(to bottom, transparent, black 24px, black calc(100% - 16px), transparent), linear-gradient(to right, transparent, black 16px, black calc(100% - 16px), transparent)",WebkitMaskComposite:"source-in"},children:He(re,{className:"flex-1",style:{height:s},children:[$(ne,{children:$(fe,{messages:d.messages,status:d.status,welcomeMessage:u,resourceEndpoint:T,isDark:w,onFollowUp:p})}),$(se,{})]})}),$(ge,{suggestions:i.suggestions,isLoading:i.isLoading,onSelect:y}),$("div",{className:"shrink-0",children:$(ae,{onSubmit:d.handleSubmit,globalDrop:a,multiple:a,className:l("rounded-[var(--ww-radius)] shadow-sm transition-all duration-300 ease-out",M&&"ring-2 ring-blue-400/70 ring-offset-2 ring-offset-background"),children:He("div",{className:"flex items-center gap-1 px-3 py-2",children:[a&&$(ue,{}),$(ie,{onChange:d.handleTextChange,value:d.text,placeholder:L,onFocus:A,className:"min-h-0 py-1.5 px-2"}),$(le,{status:d.status})]})})})]})});import{forwardRef as Eo,useCallback as De,useEffect as Io,useImperativeHandle as Ro,useRef as ft,useState as Lo}from"react";import{jsx as U,jsxs as ee}from"react/jsx-runtime";var No=Eo(function(e,o){let{theme:n,title:r="Assistant",subtitle:s,showStatus:a=!0,width:u=500,height:C=600,allowAttachments:m=!1,welcomeMessage:c,placeholder:g="Ask me anything...",triggerEvent:T="triggerDemoRequest",resourceEndpoint:v,api:S}=e,w=v??(S?`${S}/resource`:void 0),d=Z(n),i=Q(d),p=Ce(d),y=he(e),L=ye(g,!y.text),[f,h]=Lo(!1),M=ft(null),N=ft(void 0),b=De(()=>{let A=M.current;if(!A)return;A.scrollIntoView({behavior:"smooth",block:"center"});let x=A.querySelector("textarea");x&&setTimeout(()=>x.focus(),300),h(!0),clearTimeout(N.current),N.current=setTimeout(()=>h(!1),2e3)},[]),I=xe({messages:y.messages,status:y.status,initialSuggestions:e.initialSuggestions,suggestions:e.suggestions,api:e.api,apiKey:e.apiKey,headers:e.headers}),R=De(A=>{let x=A.content.map(H=>H.text??"").join("").trim();x&&y.handleSubmit({text:x,files:[]})},[y.handleSubmit]),k=De(A=>{I.clear(),y.handleSubmit({text:A,files:[]})},[I.clear,y.handleSubmit]);return Ro(o,()=>({sendMessage:A=>{y.handleSubmit({text:A,files:[]}),b()},focus:b}),[y.handleSubmit,b]),Io(()=>{if(!T)return;let A=x=>{let H=x.detail,E=typeof H?.message=="string"?H.message:void 0;E&&y.handleSubmit({text:E,files:[]}),b()};return window.addEventListener(T,A),()=>window.removeEventListener(T,A)},[T,y.handleSubmit,b]),ee("div",{ref:M,style:{...i,width:u,height:C},"data-waniwani-chat":"","data-waniwani-layout":"card",...p?{"data-waniwani-dark":""}:{},className:l("flex flex-col font-[family-name:var(--ww-font)] text-foreground bg-background rounded-[var(--ww-radius)] border border-border shadow-md overflow-hidden transition-shadow duration-300",f&&"ring-2 ring-blue-400/70 ring-offset-2 ring-offset-background"),children:[ee("div",{className:"shrink-0 flex items-center gap-3 px-4 py-2 border-b border-border",style:{backgroundColor:d.headerBackgroundColor,color:d.headerTextColor},children:[a&&U("span",{className:"size-2.5 rounded-full bg-status"}),ee("div",{className:"flex-1 min-w-0",children:[U("div",{className:"text-xs font-semibold truncate",children:r}),s&&U("div",{className:"text-[11px] text-muted-foreground truncate",children:s})]})]}),ee(re,{className:"flex-1 min-h-0 bg-background",children:[U(ne,{children:U(fe,{messages:y.messages,status:y.status,welcomeMessage:c,resourceEndpoint:w,isDark:p,onFollowUp:R})}),U(se,{})]}),U(ge,{suggestions:I.suggestions,isLoading:I.isLoading,onSelect:k,className:"border-t border-border"}),U("div",{className:"shrink-0 border-t border-border bg-background",children:U(ae,{onSubmit:y.handleSubmit,globalDrop:m,multiple:m,className:l("rounded-none border-0"),children:ee("div",{className:"flex items-center gap-1 px-3 py-2",children:[m&&U(ue,{}),U(ie,{onChange:y.handleTextChange,value:y.text,placeholder:L,className:"min-h-0 py-1.5 px-2"}),U(le,{status:y.status})]})})})]})});export{Be as ChatBar,No as ChatCard,Be as ChatWidget,Po as DARK_THEME,ct as DEFAULT_THEME,Ne as McpAppFrame,Z as mergeTheme,Q as themeToCSSProperties};
|
|
3
3
|
//# sourceMappingURL=index.js.map
|