@waniwani/sdk 0.11.0 → 0.11.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.
@@ -135,7 +135,7 @@ Error message: ${mE(a)}`,cause:a}),this[rE]=!0,this.value=t,this.context=n}stati
135
135
  `)},flush(e){e.enqueue(`data: [DONE]
136
136
 
137
137
  `)}})}};var dx=ff(()=>Zs(h.union([h.strictObject({type:h.literal("text-start"),id:h.string(),providerMetadata:W.optional()}),h.strictObject({type:h.literal("text-delta"),id:h.string(),delta:h.string(),providerMetadata:W.optional()}),h.strictObject({type:h.literal("text-end"),id:h.string(),providerMetadata:W.optional()}),h.strictObject({type:h.literal("error"),errorText:h.string()}),h.strictObject({type:h.literal("tool-input-start"),toolCallId:h.string(),toolName:h.string(),providerExecuted:h.boolean().optional(),providerMetadata:W.optional(),dynamic:h.boolean().optional(),title:h.string().optional()}),h.strictObject({type:h.literal("tool-input-delta"),toolCallId:h.string(),inputTextDelta:h.string()}),h.strictObject({type:h.literal("tool-input-available"),toolCallId:h.string(),toolName:h.string(),input:h.unknown(),providerExecuted:h.boolean().optional(),providerMetadata:W.optional(),dynamic:h.boolean().optional(),title:h.string().optional()}),h.strictObject({type:h.literal("tool-input-error"),toolCallId:h.string(),toolName:h.string(),input:h.unknown(),providerExecuted:h.boolean().optional(),providerMetadata:W.optional(),dynamic:h.boolean().optional(),errorText:h.string(),title:h.string().optional()}),h.strictObject({type:h.literal("tool-approval-request"),approvalId:h.string(),toolCallId:h.string()}),h.strictObject({type:h.literal("tool-output-available"),toolCallId:h.string(),output:h.unknown(),providerExecuted:h.boolean().optional(),providerMetadata:W.optional(),dynamic:h.boolean().optional(),preliminary:h.boolean().optional()}),h.strictObject({type:h.literal("tool-output-error"),toolCallId:h.string(),errorText:h.string(),providerExecuted:h.boolean().optional(),providerMetadata:W.optional(),dynamic:h.boolean().optional()}),h.strictObject({type:h.literal("tool-output-denied"),toolCallId:h.string()}),h.strictObject({type:h.literal("reasoning-start"),id:h.string(),providerMetadata:W.optional()}),h.strictObject({type:h.literal("reasoning-delta"),id:h.string(),delta:h.string(),providerMetadata:W.optional()}),h.strictObject({type:h.literal("reasoning-end"),id:h.string(),providerMetadata:W.optional()}),h.strictObject({type:h.literal("source-url"),sourceId:h.string(),url:h.string(),title:h.string().optional(),providerMetadata:W.optional()}),h.strictObject({type:h.literal("source-document"),sourceId:h.string(),mediaType:h.string(),title:h.string(),filename:h.string().optional(),providerMetadata:W.optional()}),h.strictObject({type:h.literal("file"),url:h.string(),mediaType:h.string(),providerMetadata:W.optional()}),h.strictObject({type:h.custom(e=>typeof e=="string"&&e.startsWith("data-"),{message:'Type must start with "data-"'}),id:h.string().optional(),data:h.unknown(),transient:h.boolean().optional()}),h.strictObject({type:h.literal("start-step")}),h.strictObject({type:h.literal("finish-step")}),h.strictObject({type:h.literal("start"),messageId:h.string().optional(),messageMetadata:h.unknown().optional()}),h.strictObject({type:h.literal("finish"),finishReason:h.enum(["stop","length","content-filter","tool-calls","error","other"]).optional(),messageMetadata:h.unknown().optional()}),h.strictObject({type:h.literal("abort"),reason:h.string().optional()}),h.strictObject({type:h.literal("message-metadata"),messageMetadata:h.unknown()})])));function UF(e){return e.type.startsWith("data-")}function cx(e){return e.type.startsWith("tool-")}function zF(e){return e.type==="dynamic-tool"}function gf(e){return cx(e)||zF(e)}function t2(e){return e.type.split("-").slice(1).join("-")}function qF({lastMessage:e,messageId:t}){return{message:e?.role==="assistant"?e:{id:t,metadata:void 0,role:"assistant",parts:[]},activeTextParts:{},activeReasoningParts:{},partialToolCalls:{}}}function FF({stream:e,messageMetadataSchema:t,dataPartSchemas:a,runUpdateMessageJob:n,onError:r,onToolCall:o,onData:l}){return e.pipeThrough(new TransformStream({async transform(i,s){await n(async({state:u,write:c})=>{var d,f,p,y;function v(m){let L=u.message.parts.filter(gf).find(b=>b.toolCallId===m);if(L==null)throw new Wl({chunkType:"tool-invocation",chunkId:m,message:`No tool invocation found for tool call ID "${m}".`});return L}function S(m){var w;let L=u.message.parts.find(R=>cx(R)&&R.toolCallId===m.toolCallId),b=m,A=L;if(L!=null){L.state=m.state,A.input=b.input,A.output=b.output,A.errorText=b.errorText,A.rawInput=b.rawInput,A.preliminary=b.preliminary,m.title!==void 0&&(A.title=m.title),A.providerExecuted=(w=b.providerExecuted)!=null?w:L.providerExecuted;let R=b.providerMetadata;if(R!=null)if(m.state==="output-available"||m.state==="output-error"){let _=L;_.resultProviderMetadata=R}else L.callProviderMetadata=R}else u.message.parts.push({type:`tool-${m.toolName}`,toolCallId:m.toolCallId,state:m.state,title:m.title,input:b.input,output:b.output,rawInput:b.rawInput,errorText:b.errorText,providerExecuted:b.providerExecuted,preliminary:b.preliminary,...b.providerMetadata!=null&&(m.state==="output-available"||m.state==="output-error")?{resultProviderMetadata:b.providerMetadata}:{},...b.providerMetadata!=null&&!(m.state==="output-available"||m.state==="output-error")?{callProviderMetadata:b.providerMetadata}:{}})}function g(m){var w,L;let b=u.message.parts.find(_=>_.type==="dynamic-tool"&&_.toolCallId===m.toolCallId),A=m,R=b;if(b!=null){b.state=m.state,R.toolName=m.toolName,R.input=A.input,R.output=A.output,R.errorText=A.errorText,R.rawInput=(w=A.rawInput)!=null?w:R.rawInput,R.preliminary=A.preliminary,m.title!==void 0&&(R.title=m.title),R.providerExecuted=(L=A.providerExecuted)!=null?L:b.providerExecuted;let _=A.providerMetadata;if(_!=null)if(m.state==="output-available"||m.state==="output-error"){let T=b;T.resultProviderMetadata=_}else b.callProviderMetadata=_}else u.message.parts.push({type:"dynamic-tool",toolName:m.toolName,toolCallId:m.toolCallId,state:m.state,input:A.input,output:A.output,errorText:A.errorText,preliminary:A.preliminary,providerExecuted:A.providerExecuted,title:m.title,...A.providerMetadata!=null&&(m.state==="output-available"||m.state==="output-error")?{resultProviderMetadata:A.providerMetadata}:{},...A.providerMetadata!=null&&!(m.state==="output-available"||m.state==="output-error")?{callProviderMetadata:A.providerMetadata}:{}})}async function x(m){if(m!=null){let w=u.message.metadata!=null?f2(u.message.metadata,m):m;t!=null&&await hf({value:w,schema:t,context:{field:"message.metadata",entityId:u.message.id}}),u.message.metadata=w}}switch(i.type){case"text-start":{let m={type:"text",text:"",providerMetadata:i.providerMetadata,state:"streaming"};u.activeTextParts[i.id]=m,u.message.parts.push(m),c();break}case"text-delta":{let m=u.activeTextParts[i.id];if(m==null)throw new Wl({chunkType:"text-delta",chunkId:i.id,message:`Received text-delta for missing text part with ID "${i.id}". Ensure a "text-start" chunk is sent before any "text-delta" chunks.`});m.text+=i.delta,m.providerMetadata=(d=i.providerMetadata)!=null?d:m.providerMetadata,c();break}case"text-end":{let m=u.activeTextParts[i.id];if(m==null)throw new Wl({chunkType:"text-end",chunkId:i.id,message:`Received text-end for missing text part with ID "${i.id}". Ensure a "text-start" chunk is sent before any "text-end" chunks.`});m.state="done",m.providerMetadata=(f=i.providerMetadata)!=null?f:m.providerMetadata,delete u.activeTextParts[i.id],c();break}case"reasoning-start":{let m={type:"reasoning",text:"",providerMetadata:i.providerMetadata,state:"streaming"};u.activeReasoningParts[i.id]=m,u.message.parts.push(m),c();break}case"reasoning-delta":{let m=u.activeReasoningParts[i.id];if(m==null)throw new Wl({chunkType:"reasoning-delta",chunkId:i.id,message:`Received reasoning-delta for missing reasoning part with ID "${i.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-delta" chunks.`});m.text+=i.delta,m.providerMetadata=(p=i.providerMetadata)!=null?p:m.providerMetadata,c();break}case"reasoning-end":{let m=u.activeReasoningParts[i.id];if(m==null)throw new Wl({chunkType:"reasoning-end",chunkId:i.id,message:`Received reasoning-end for missing reasoning part with ID "${i.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-end" chunks.`});m.providerMetadata=(y=i.providerMetadata)!=null?y:m.providerMetadata,m.state="done",delete u.activeReasoningParts[i.id],c();break}case"file":{u.message.parts.push({type:"file",mediaType:i.mediaType,url:i.url,...i.providerMetadata!=null?{providerMetadata:i.providerMetadata}:{}}),c();break}case"source-url":{u.message.parts.push({type:"source-url",sourceId:i.sourceId,url:i.url,title:i.title,providerMetadata:i.providerMetadata}),c();break}case"source-document":{u.message.parts.push({type:"source-document",sourceId:i.sourceId,mediaType:i.mediaType,title:i.title,filename:i.filename,providerMetadata:i.providerMetadata}),c();break}case"tool-input-start":{let m=u.message.parts.filter(cx);u.partialToolCalls[i.toolCallId]={text:"",toolName:i.toolName,index:m.length,dynamic:i.dynamic,title:i.title},i.dynamic?g({toolCallId:i.toolCallId,toolName:i.toolName,state:"input-streaming",input:void 0,providerExecuted:i.providerExecuted,title:i.title,providerMetadata:i.providerMetadata}):S({toolCallId:i.toolCallId,toolName:i.toolName,state:"input-streaming",input:void 0,providerExecuted:i.providerExecuted,title:i.title,providerMetadata:i.providerMetadata}),c();break}case"tool-input-delta":{let m=u.partialToolCalls[i.toolCallId];if(m==null)throw new Wl({chunkType:"tool-input-delta",chunkId:i.toolCallId,message:`Received tool-input-delta for missing tool call with ID "${i.toolCallId}". Ensure a "tool-input-start" chunk is sent before any "tool-input-delta" chunks.`});m.text+=i.inputTextDelta;let{value:w}=await Ks(m.text);m.dynamic?g({toolCallId:i.toolCallId,toolName:m.toolName,state:"input-streaming",input:w,title:m.title}):S({toolCallId:i.toolCallId,toolName:m.toolName,state:"input-streaming",input:w,title:m.title}),c();break}case"tool-input-available":{i.dynamic?g({toolCallId:i.toolCallId,toolName:i.toolName,state:"input-available",input:i.input,providerExecuted:i.providerExecuted,providerMetadata:i.providerMetadata,title:i.title}):S({toolCallId:i.toolCallId,toolName:i.toolName,state:"input-available",input:i.input,providerExecuted:i.providerExecuted,providerMetadata:i.providerMetadata,title:i.title}),c(),o&&!i.providerExecuted&&await o({toolCall:i});break}case"tool-input-error":{let m=u.message.parts.filter(gf).find(L=>L.toolCallId===i.toolCallId);(m!=null?m.type==="dynamic-tool":!!i.dynamic)?g({toolCallId:i.toolCallId,toolName:i.toolName,state:"output-error",input:i.input,errorText:i.errorText,providerExecuted:i.providerExecuted,providerMetadata:i.providerMetadata}):S({toolCallId:i.toolCallId,toolName:i.toolName,state:"output-error",input:void 0,rawInput:i.input,errorText:i.errorText,providerExecuted:i.providerExecuted,providerMetadata:i.providerMetadata}),c();break}case"tool-approval-request":{let m=v(i.toolCallId);m.state="approval-requested",m.approval={id:i.approvalId},c();break}case"tool-output-denied":{let m=v(i.toolCallId);m.state="output-denied",c();break}case"tool-output-available":{let m=v(i.toolCallId);m.type==="dynamic-tool"?g({toolCallId:i.toolCallId,toolName:m.toolName,state:"output-available",input:m.input,output:i.output,preliminary:i.preliminary,providerExecuted:i.providerExecuted,providerMetadata:i.providerMetadata,title:m.title}):S({toolCallId:i.toolCallId,toolName:t2(m),state:"output-available",input:m.input,output:i.output,providerExecuted:i.providerExecuted,preliminary:i.preliminary,providerMetadata:i.providerMetadata,title:m.title}),c();break}case"tool-output-error":{let m=v(i.toolCallId);m.type==="dynamic-tool"?g({toolCallId:i.toolCallId,toolName:m.toolName,state:"output-error",input:m.input,errorText:i.errorText,providerExecuted:i.providerExecuted,providerMetadata:i.providerMetadata,title:m.title}):S({toolCallId:i.toolCallId,toolName:t2(m),state:"output-error",input:m.input,rawInput:m.rawInput,errorText:i.errorText,providerExecuted:i.providerExecuted,providerMetadata:i.providerMetadata,title:m.title}),c();break}case"start-step":{u.message.parts.push({type:"step-start"});break}case"finish-step":{u.activeTextParts={},u.activeReasoningParts={};break}case"start":{i.messageId!=null&&(u.message.id=i.messageId),await x(i.messageMetadata),(i.messageId!=null||i.messageMetadata!=null)&&c();break}case"finish":{i.finishReason!=null&&(u.finishReason=i.finishReason),await x(i.messageMetadata),i.messageMetadata!=null&&c();break}case"message-metadata":{await x(i.messageMetadata),i.messageMetadata!=null&&c();break}case"error":{r?.(new Error(i.errorText));break}default:if(UF(i)){if(a?.[i.type]!=null){let L=u.message.parts.findIndex(A=>"id"in A&&"data"in A&&A.id===i.id&&A.type===i.type),b=L>=0?L:u.message.parts.length;await hf({value:i.data,schema:a[i.type],context:{field:`message.parts[${b}].data`,entityName:i.type,entityId:i.id}})}let m=i;if(m.transient){l?.(m);break}let w=m.id!=null?u.message.parts.find(L=>m.type===L.type&&m.id===L.id):void 0;w!=null?w.data=m.data:u.message.parts.push(m),l?.(m),c()}}s.enqueue(i)})}}))}async function HF({stream:e,onError:t}){let a=e.getReader();try{for(;;){let{done:n}=await a.read();if(n)break}}catch(n){t?.(n)}finally{a.releaseLock()}}var bJ=qn({prefix:"aitxt",size:24});var IJ=ff(()=>Zs(h.array(h.object({id:h.string(),role:h.enum(["system","user","assistant"]),metadata:h.unknown().optional(),parts:h.array(h.union([h.object({type:h.literal("text"),text:h.string(),state:h.enum(["streaming","done"]).optional(),providerMetadata:W.optional()}),h.object({type:h.literal("reasoning"),text:h.string(),state:h.enum(["streaming","done"]).optional(),providerMetadata:W.optional()}),h.object({type:h.literal("source-url"),sourceId:h.string(),url:h.string(),title:h.string().optional(),providerMetadata:W.optional()}),h.object({type:h.literal("source-document"),sourceId:h.string(),mediaType:h.string(),title:h.string(),filename:h.string().optional(),providerMetadata:W.optional()}),h.object({type:h.literal("file"),mediaType:h.string(),filename:h.string().optional(),url:h.string(),providerMetadata:W.optional()}),h.object({type:h.literal("step-start")}),h.object({type:h.string().startsWith("data-"),id:h.string().optional(),data:h.unknown()}),h.object({type:h.literal("dynamic-tool"),toolName:h.string(),toolCallId:h.string(),state:h.literal("input-streaming"),input:h.unknown().optional(),providerExecuted:h.boolean().optional(),callProviderMetadata:W.optional(),output:h.never().optional(),errorText:h.never().optional(),approval:h.never().optional()}),h.object({type:h.literal("dynamic-tool"),toolName:h.string(),toolCallId:h.string(),state:h.literal("input-available"),input:h.unknown(),providerExecuted:h.boolean().optional(),output:h.never().optional(),errorText:h.never().optional(),callProviderMetadata:W.optional(),approval:h.never().optional()}),h.object({type:h.literal("dynamic-tool"),toolName:h.string(),toolCallId:h.string(),state:h.literal("approval-requested"),input:h.unknown(),providerExecuted:h.boolean().optional(),output:h.never().optional(),errorText:h.never().optional(),callProviderMetadata:W.optional(),approval:h.object({id:h.string(),approved:h.never().optional(),reason:h.never().optional()})}),h.object({type:h.literal("dynamic-tool"),toolName:h.string(),toolCallId:h.string(),state:h.literal("approval-responded"),input:h.unknown(),providerExecuted:h.boolean().optional(),output:h.never().optional(),errorText:h.never().optional(),callProviderMetadata:W.optional(),approval:h.object({id:h.string(),approved:h.boolean(),reason:h.string().optional()})}),h.object({type:h.literal("dynamic-tool"),toolName:h.string(),toolCallId:h.string(),state:h.literal("output-available"),input:h.unknown(),providerExecuted:h.boolean().optional(),output:h.unknown(),errorText:h.never().optional(),callProviderMetadata:W.optional(),resultProviderMetadata:W.optional(),preliminary:h.boolean().optional(),approval:h.object({id:h.string(),approved:h.literal(!0),reason:h.string().optional()}).optional()}),h.object({type:h.literal("dynamic-tool"),toolName:h.string(),toolCallId:h.string(),state:h.literal("output-error"),input:h.unknown(),rawInput:h.unknown().optional(),providerExecuted:h.boolean().optional(),output:h.never().optional(),errorText:h.string(),callProviderMetadata:W.optional(),resultProviderMetadata:W.optional(),approval:h.object({id:h.string(),approved:h.literal(!0),reason:h.string().optional()}).optional()}),h.object({type:h.literal("dynamic-tool"),toolName:h.string(),toolCallId:h.string(),state:h.literal("output-denied"),input:h.unknown(),providerExecuted:h.boolean().optional(),output:h.never().optional(),errorText:h.never().optional(),callProviderMetadata:W.optional(),approval:h.object({id:h.string(),approved:h.literal(!1),reason:h.string().optional()})}),h.object({type:h.string().startsWith("tool-"),toolCallId:h.string(),state:h.literal("input-streaming"),providerExecuted:h.boolean().optional(),callProviderMetadata:W.optional(),input:h.unknown().optional(),output:h.never().optional(),errorText:h.never().optional(),approval:h.never().optional()}),h.object({type:h.string().startsWith("tool-"),toolCallId:h.string(),state:h.literal("input-available"),providerExecuted:h.boolean().optional(),input:h.unknown(),output:h.never().optional(),errorText:h.never().optional(),callProviderMetadata:W.optional(),approval:h.never().optional()}),h.object({type:h.string().startsWith("tool-"),toolCallId:h.string(),state:h.literal("approval-requested"),input:h.unknown(),providerExecuted:h.boolean().optional(),output:h.never().optional(),errorText:h.never().optional(),callProviderMetadata:W.optional(),approval:h.object({id:h.string(),approved:h.never().optional(),reason:h.never().optional()})}),h.object({type:h.string().startsWith("tool-"),toolCallId:h.string(),state:h.literal("approval-responded"),input:h.unknown(),providerExecuted:h.boolean().optional(),output:h.never().optional(),errorText:h.never().optional(),callProviderMetadata:W.optional(),approval:h.object({id:h.string(),approved:h.boolean(),reason:h.string().optional()})}),h.object({type:h.string().startsWith("tool-"),toolCallId:h.string(),state:h.literal("output-available"),providerExecuted:h.boolean().optional(),input:h.unknown(),output:h.unknown(),errorText:h.never().optional(),callProviderMetadata:W.optional(),resultProviderMetadata:W.optional(),preliminary:h.boolean().optional(),approval:h.object({id:h.string(),approved:h.literal(!0),reason:h.string().optional()}).optional()}),h.object({type:h.string().startsWith("tool-"),toolCallId:h.string(),state:h.literal("output-error"),providerExecuted:h.boolean().optional(),input:h.unknown(),rawInput:h.unknown().optional(),output:h.never().optional(),errorText:h.string(),callProviderMetadata:W.optional(),resultProviderMetadata:W.optional(),approval:h.object({id:h.string(),approved:h.literal(!0),reason:h.string().optional()}).optional()}),h.object({type:h.string().startsWith("tool-"),toolCallId:h.string(),state:h.literal("output-denied"),providerExecuted:h.boolean().optional(),input:h.unknown(),output:h.never().optional(),errorText:h.never().optional(),callProviderMetadata:W.optional(),approval:h.object({id:h.string(),approved:h.literal(!1),reason:h.string().optional()})})])).nonempty("Message must contain at least one part")})).nonempty("Messages array must not be empty")));var kJ=qn({prefix:"aiobj",size:24});function p2(e){return({url:t,abortSignal:a})=>wF({url:t,maxBytes:e?.maxBytes,abortSignal:a})}var jF=class{constructor(){this.queue=[],this.isProcessing=!1}async processQueue(){if(!this.isProcessing){for(this.isProcessing=!0;this.queue.length>0;)await this.queue[0](),this.queue.shift();this.isProcessing=!1}}async run(e){return new Promise((t,a)=>{this.queue.push(async()=>{try{await e(),t()}catch(n){a(n)}}),this.processQueue()})}};var MJ=qn({prefix:"aiobj",size:24});var AJ=p2();var VF="AI_NoSuchProviderError",GF=`vercel.ai.error.${VF}`,WF=Symbol.for(GF),$F;$F=WF;var EJ=p2();async function XF(e){if(e==null)return[];if(!globalThis.FileList||!(e instanceof globalThis.FileList))throw new Error("FileList is not supported in the current environment");return Promise.all(Array.from(e).map(async t=>{let{name:a,type:n}=t,r=await new Promise((o,l)=>{let i=new FileReader;i.onload=s=>{var u;o((u=s.target)==null?void 0:u.result)},i.onerror=s=>l(s),i.readAsDataURL(t)});return{type:"file",mediaType:n,filename:a,url:r}}))}var ZF=class{constructor({api:e="/api/chat",credentials:t,headers:a,body:n,fetch:r,prepareSendMessagesRequest:o,prepareReconnectToStreamRequest:l}){this.api=e,this.credentials=t,this.headers=a,this.body=n,this.fetch=r,this.prepareSendMessagesRequest=o,this.prepareReconnectToStreamRequest=l}async sendMessages({abortSignal:e,...t}){var a,n,r,o,l;let i=await on(this.body),s=await on(this.headers),u=await on(this.credentials),c={...Er(s),...Er(t.headers)},d=await((a=this.prepareSendMessagesRequest)==null?void 0:a.call(this,{api:this.api,id:t.chatId,messages:t.messages,body:{...i,...t.body},headers:c,credentials:u,requestMetadata:t.metadata,trigger:t.trigger,messageId:t.messageId})),f=(n=d?.api)!=null?n:this.api,p=d?.headers!==void 0?Er(d.headers):c,y=d?.body!==void 0?d.body:{...i,...t.body,id:t.chatId,messages:t.messages,trigger:t.trigger,messageId:t.messageId},v=(r=d?.credentials)!=null?r:u,g=await((o=this.fetch)!=null?o:globalThis.fetch)(f,{method:"POST",headers:{"Content-Type":"application/json",...p},body:JSON.stringify(y),credentials:v,signal:e});if(!g.ok)throw new Error((l=await g.text())!=null?l:"Failed to fetch the chat response.");if(!g.body)throw new Error("The response body is empty.");return this.processResponseStream(g.body)}async reconnectToStream(e){var t,a,n,r,o;let l=await on(this.body),i=await on(this.headers),s=await on(this.credentials),u={...Er(i),...Er(e.headers)},c=await((t=this.prepareReconnectToStreamRequest)==null?void 0:t.call(this,{api:this.api,id:e.chatId,body:{...l,...e.body},headers:u,credentials:s,requestMetadata:e.metadata})),d=(a=c?.api)!=null?a:`${this.api}/${e.chatId}/stream`,f=c?.headers!==void 0?Er(c.headers):u,p=(n=c?.credentials)!=null?n:s,v=await((r=this.fetch)!=null?r:globalThis.fetch)(d,{method:"GET",headers:f,credentials:p});if(v.status===204)return null;if(!v.ok)throw new Error((o=await v.text())!=null?o:"Failed to fetch the chat response.");if(!v.body)throw new Error("The response body is empty.");return this.processResponseStream(v.body)}},fx=class extends ZF{constructor(e={}){super(e)}processResponseStream(e){return e2({stream:e,schema:dx}).pipeThrough(new TransformStream({async transform(t,a){if(!t.success)throw t.error;a.enqueue(t.value)}}))}},m2=class{constructor({generateId:e=XE,id:t=e(),transport:a=new fx,messageMetadataSchema:n,dataPartSchemas:r,state:o,onError:l,onToolCall:i,onFinish:s,onData:u,sendAutomaticallyWhen:c}){this.activeResponse=void 0,this.jobExecutor=new jF,this.sendMessage=async(d,f)=>{var p,y,v,S;if(d==null){await this.makeRequest({trigger:"submit-message",messageId:(p=this.lastMessage)==null?void 0:p.id,...f});return}let g;if("text"in d||"files"in d?g={parts:[...Array.isArray(d.files)?d.files:await XF(d.files),..."text"in d&&d.text!=null?[{type:"text",text:d.text}]:[]]}:g=d,d.messageId!=null){let x=this.state.messages.findIndex(m=>m.id===d.messageId);if(x===-1)throw new Error(`message with id ${d.messageId} not found`);if(this.state.messages[x].role!=="user")throw new Error(`message with id ${d.messageId} is not a user message`);this.state.messages=this.state.messages.slice(0,x+1),this.state.replaceMessage(x,{...g,id:d.messageId,role:(y=g.role)!=null?y:"user",metadata:d.metadata})}else this.state.pushMessage({...g,id:(v=g.id)!=null?v:this.generateId(),role:(S=g.role)!=null?S:"user",metadata:d.metadata});await this.makeRequest({trigger:"submit-message",messageId:d.messageId,...f})},this.regenerate=async({messageId:d,...f}={})=>{let p=d==null?this.state.messages.length-1:this.state.messages.findIndex(y=>y.id===d);if(p===-1)throw new Error(`message ${d} not found`);this.state.messages=this.state.messages.slice(0,this.messages[p].role==="assistant"?p:p+1),await this.makeRequest({trigger:"regenerate-message",messageId:d,...f})},this.resumeStream=async(d={})=>{await this.makeRequest({trigger:"resume-stream",...d})},this.clearError=()=>{this.status==="error"&&(this.state.error=void 0,this.setStatus({status:"ready"}))},this.addToolApprovalResponse=async({id:d,approved:f,reason:p,options:y})=>this.jobExecutor.run(async()=>{let v=this.state.messages,S=v[v.length-1],g=x=>gf(x)&&x.state==="approval-requested"&&x.approval.id===d?{...x,state:"approval-responded",approval:{id:d,approved:f,reason:p}}:x;this.state.replaceMessage(v.length-1,{...S,parts:S.parts.map(g)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(g)),this.status!=="streaming"&&this.status!=="submitted"&&this.sendAutomaticallyWhen&&this.shouldSendAutomatically().then(x=>{var m;x&&this.makeRequest({trigger:"submit-message",messageId:(m=this.lastMessage)==null?void 0:m.id,...y})})}),this.addToolOutput=async({state:d="output-available",toolCallId:f,output:p,errorText:y,options:v})=>this.jobExecutor.run(async()=>{let S=this.state.messages,g=S[S.length-1],x=m=>gf(m)&&m.toolCallId===f?{...m,state:d,output:p,errorText:y}:m;this.state.replaceMessage(S.length-1,{...g,parts:g.parts.map(x)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(x)),this.status!=="streaming"&&this.status!=="submitted"&&this.sendAutomaticallyWhen&&this.shouldSendAutomatically().then(m=>{var w;m&&this.makeRequest({trigger:"submit-message",messageId:(w=this.lastMessage)==null?void 0:w.id,...v})})}),this.addToolResult=this.addToolOutput,this.stop=async()=>{var d;this.status!=="streaming"&&this.status!=="submitted"||(d=this.activeResponse)!=null&&d.abortController&&this.activeResponse.abortController.abort()},this.id=t,this.transport=a,this.generateId=e,this.messageMetadataSchema=n,this.dataPartSchemas=r,this.state=o,this.onError=l,this.onToolCall=i,this.onFinish=s,this.onData=u,this.sendAutomaticallyWhen=c}get status(){return this.state.status}setStatus({status:e,error:t}){this.status!==e&&(this.state.status=e,this.state.error=t)}get error(){return this.state.error}get messages(){return this.state.messages}get lastMessage(){return this.state.messages[this.state.messages.length-1]}set messages(e){this.state.messages=e}async shouldSendAutomatically(){if(!this.sendAutomaticallyWhen)return!1;let e=this.sendAutomaticallyWhen({messages:this.state.messages});return e&&typeof e=="object"&&"then"in e?await e:e}async makeRequest({trigger:e,metadata:t,headers:a,body:n,messageId:r}){var o,l,i;let s;if(e==="resume-stream")try{let p=await this.transport.reconnectToStream({chatId:this.id,metadata:t,headers:a,body:n});if(p==null)return;s=p}catch(p){this.onError&&p instanceof Error&&this.onError(p),this.setStatus({status:"error",error:p});return}this.setStatus({status:"submitted",error:void 0});let u=this.lastMessage,c=!1,d=!1,f=!1;try{let p={state:qF({lastMessage:this.state.snapshot(u),messageId:this.generateId()}),abortController:new AbortController};p.abortController.signal.addEventListener("abort",()=>{c=!0}),this.activeResponse=p;let y;e==="resume-stream"?y=s:y=await this.transport.sendMessages({chatId:this.id,messages:this.state.messages,abortSignal:p.abortController.signal,metadata:t,headers:a,body:n,trigger:e,messageId:r});let v=S=>this.jobExecutor.run(()=>S({state:p.state,write:()=>{var g;this.setStatus({status:"streaming"}),p.state.message.id===((g=this.lastMessage)==null?void 0:g.id)?this.state.replaceMessage(this.state.messages.length-1,p.state.message):this.state.pushMessage(p.state.message)}}));await HF({stream:FF({stream:y,onToolCall:this.onToolCall,onData:this.onData,messageMetadataSchema:this.messageMetadataSchema,dataPartSchemas:this.dataPartSchemas,runUpdateMessageJob:v,onError:S=>{throw S}}),onError:S=>{throw S}}),this.setStatus({status:"ready"})}catch(p){if(c||p.name==="AbortError")return c=!0,this.setStatus({status:"ready"}),null;f=!0,p instanceof TypeError&&(p.message.toLowerCase().includes("fetch")||p.message.toLowerCase().includes("network"))&&(d=!0),this.onError&&p instanceof Error&&this.onError(p),this.setStatus({status:"error",error:p})}finally{try{(l=this.onFinish)==null||l.call(this,{message:this.activeResponse.state.message,messages:this.state.messages,isAbort:c,isDisconnect:d,isError:f,finishReason:(o=this.activeResponse)==null?void 0:o.state.finishReason})}catch(p){console.error(p)}this.activeResponse=void 0}!f&&await this.shouldSendAutomatically()&&await this.makeRequest({trigger:"submit-message",messageId:(i=this.lastMessage)==null?void 0:i.id,metadata:t,headers:a,body:n})}};var v2=q(g2(),1);var tu=q(xe(),1);var vf=q(xe(),1);var x2=(e,t,a)=>{if(!t.has(e))throw TypeError("Cannot "+a)},We=(e,t,a)=>(x2(e,t,"read from private field"),a?a.call(e):t.get(e)),ln=(e,t,a)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,a)},Dr=(e,t,a,n)=>(x2(e,t,"write to private field"),n?n.call(e,a):t.set(e,a),a);function KF(e,t){return t!=null?(0,v2.default)(e,t):e}var Pa,yf,xf,Ys,Js,eu,$l,px,mx,YF=class{constructor(e=[]){ln(this,Pa,void 0),ln(this,yf,"ready"),ln(this,xf,void 0),ln(this,Ys,new Set),ln(this,Js,new Set),ln(this,eu,new Set),this.pushMessage=t=>{Dr(this,Pa,We(this,Pa).concat(t)),We(this,$l).call(this)},this.popMessage=()=>{Dr(this,Pa,We(this,Pa).slice(0,-1)),We(this,$l).call(this)},this.replaceMessage=(t,a)=>{Dr(this,Pa,[...We(this,Pa).slice(0,t),this.snapshot(a),...We(this,Pa).slice(t+1)]),We(this,$l).call(this)},this.snapshot=t=>structuredClone(t),this["~registerMessagesCallback"]=(t,a)=>{let n=a?KF(t,a):t;return We(this,Ys).add(n),()=>{We(this,Ys).delete(n)}},this["~registerStatusCallback"]=t=>(We(this,Js).add(t),()=>{We(this,Js).delete(t)}),this["~registerErrorCallback"]=t=>(We(this,eu).add(t),()=>{We(this,eu).delete(t)}),ln(this,$l,()=>{We(this,Ys).forEach(t=>t())}),ln(this,px,()=>{We(this,Js).forEach(t=>t())}),ln(this,mx,()=>{We(this,eu).forEach(t=>t())}),Dr(this,Pa,e)}get status(){return We(this,yf)}set status(e){Dr(this,yf,e),We(this,px).call(this)}get error(){return We(this,xf)}set error(e){Dr(this,xf,e),We(this,mx).call(this)}get messages(){return We(this,Pa)}set messages(e){Dr(this,Pa,[...e]),We(this,$l).call(this)}};Pa=new WeakMap;yf=new WeakMap;xf=new WeakMap;Ys=new WeakMap;Js=new WeakMap;eu=new WeakMap;$l=new WeakMap;px=new WeakMap;mx=new WeakMap;var Xl,y2=class extends m2{constructor({messages:e,...t}){let a=new YF(e);super({...t,state:a}),ln(this,Xl,void 0),this["~registerMessagesCallback"]=(n,r)=>We(this,Xl)["~registerMessagesCallback"](n,r),this["~registerStatusCallback"]=n=>We(this,Xl)["~registerStatusCallback"](n),this["~registerErrorCallback"]=n=>We(this,Xl)["~registerErrorCallback"](n),Dr(this,Xl,a)}};Xl=new WeakMap;function w2({experimental_throttle:e,resume:t=!1,...a}={}){let n=(0,Na.useRef)("chat"in a?{}:{onToolCall:a.onToolCall,onData:a.onData,onFinish:a.onFinish,onError:a.onError,sendAutomaticallyWhen:a.sendAutomaticallyWhen});"chat"in a||(n.current={onToolCall:a.onToolCall,onData:a.onData,onFinish:a.onFinish,onError:a.onError,sendAutomaticallyWhen:a.sendAutomaticallyWhen});let r={...a,onToolCall:f=>{var p,y;return(y=(p=n.current).onToolCall)==null?void 0:y.call(p,f)},onData:f=>{var p,y;return(y=(p=n.current).onData)==null?void 0:y.call(p,f)},onFinish:f=>{var p,y;return(y=(p=n.current).onFinish)==null?void 0:y.call(p,f)},onError:f=>{var p,y;return(y=(p=n.current).onError)==null?void 0:y.call(p,f)},sendAutomaticallyWhen:f=>{var p,y,v;return(v=(y=(p=n.current).sendAutomaticallyWhen)==null?void 0:y.call(p,f))!=null?v:!1}},o=(0,Na.useRef)("chat"in a?a.chat:new y2(r));("chat"in a&&a.chat!==o.current||"id"in a&&o.current.id!==a.id)&&(o.current="chat"in a?a.chat:new y2(r));let i=(0,Na.useCallback)(f=>o.current["~registerMessagesCallback"](f,e),[e,o.current.id]),s=(0,Na.useSyncExternalStore)(i,()=>o.current.messages,()=>o.current.messages),u=(0,Na.useSyncExternalStore)(o.current["~registerStatusCallback"],()=>o.current.status,()=>o.current.status),c=(0,Na.useSyncExternalStore)(o.current["~registerErrorCallback"],()=>o.current.error,()=>o.current.error),d=(0,Na.useCallback)(f=>{typeof f=="function"&&(f=f(o.current.messages)),o.current.messages=f},[o]);return(0,Na.useEffect)(()=>{t&&o.current.resumeStream()},[t,o]),{id:o.current.id,messages:s,setMessages:d,sendMessage:o.current.sendMessage,regenerate:o.current.regenerate,clearError:o.current.clearError,stop:o.current.stop,error:c,resumeStream:o.current.resumeStream,status:u,addToolResult:o.current.addToolOutput,addToolOutput:o.current.addToolOutput,addToolApprovalResponse:o.current.addToolApprovalResponse}}var be=q(xe(),1);function JF(e){let t=e?.cause,a=t?.issues??t?.errors;if(!Array.isArray(a))return null;let n=a.find(r=>r.code==="invalid_union");if(!n?.errors)return null;for(let r of n.errors){if(!Array.isArray(r)||r.some(i=>(i.code==="invalid_value"||i.code==="invalid_literal")&&i.path?.[0]==="type"))continue;let l=r.filter(i=>i.code==="unrecognized_keys").flatMap(i=>i.keys??[]);if(l.length>0)return l}return null}var wf=class extends fx{processResponseStream(t){let a="",n=dx(),r=n.validate?.bind(n);return t.pipeThrough(new TextDecoderStream).pipeThrough(new TransformStream({async transform(o,l){a+=o;let i=a.split(`
138
- `);a=i.pop()??"";for(let s of i){let u=s.trim();if(!u.startsWith("data:"))continue;let c=u.slice(5).trim();if(c!=="[DONE]")try{let d=JSON.parse(c);if(!r){l.enqueue(d);continue}let f=await r(d);if(f.success){l.enqueue(f.value);continue}let p=JF(f.error);if(p?.length){let y={...d};for(let S of p)delete y[S];let v=await r(y);v.success&&l.enqueue(v.value)}}catch{}}}}))}};var b2="waniwani-visitor-id";function S2(e,t){return e.match(t)?.[1]??null}function e6(e){let t=[["Edge",/Edg(?:e|A|iOS)?\/(\S+)/],["Opera",/(?:OPR|Opera)\/(\S+)/],["Samsung Internet",/SamsungBrowser\/(\S+)/],["Firefox",/Firefox\/(\S+)/],["Chrome",/Chrome\/(\S+)/],["Safari",/Version\/(\S+).*Safari/]];for(let[a,n]of t){let r=S2(e,n);if(r)return{name:a,version:r}}return null}function t6(e){let t=[["iOS",/(?:iPhone|iPad|iPod).+?OS (\d+[_.\d]*)/],["Android",/Android (\d+[.\d]*)/],["macOS",/Mac OS X (\d+[_.\d]*)/],["Windows",/Windows NT (\d+[.\d]*)/],["ChromeOS",/CrOS \S+ (\d+[.\d]*)/],["Linux",/Linux/]];for(let[a,n]of t){let r=S2(e,n);if(r)return{name:a,version:r.replace(/_/g,".")};if(a==="Linux"&&n.test(e))return{name:a,version:""}}return null}function a6(e){return typeof navigator<"u"&&"userAgentData"in navigator&&navigator.userAgentData?.mobile?"mobile":/iPad|tablet|PlayBook/i.test(e)?"tablet":/Mobi|Android.*Mobile|iPhone|iPod/i.test(e)?"mobile":"desktop"}async function n6(e){let t=new TextEncoder().encode(e),a=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(a)).map(n=>n.toString(16).padStart(2,"0")).join("")}async function r6(){try{let a=localStorage.getItem(b2);if(a)return a}catch{}let e=[navigator.userAgent,screen.width,screen.height,screen.colorDepth,Intl.DateTimeFormat().resolvedOptions().timeZone,navigator.language,navigator.hardwareConcurrency??"",navigator.platform??""].join("|"),t=await n6(e);try{localStorage.setItem(b2,t)}catch{}return t}async function C2(){let e=navigator.userAgent,t=await r6();return{userAgent:e,browser:e6(e),os:t6(e),deviceType:a6(e),language:navigator.language,languages:[...navigator.languages],timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,screenWidth:screen.width,screenHeight:screen.height,viewportWidth:window.innerWidth,viewportHeight:window.innerHeight,colorDepth:screen.colorDepth,devicePixelRatio:window.devicePixelRatio??1,touchSupport:"ontouchstart"in window||navigator.maxTouchPoints>0,connectionType:navigator.connection?.effectiveType??"unknown",referrer:document.referrer,visitorId:t}}var o6="x-session-id";function I2(e){if(typeof e!="string")return;let t=e.trim();return t.length>0?t:void 0}async function l6(e,t){let a=`${e.replace(/\/$/,"")}/tools`,n=await fetch(a,{method:"GET",headers:t?{...t}:void 0});if(!n.ok)throw new Error(`[WaniWani] Failed to fetch /tools: ${n.status} ${n.statusText}`);let r=await n.json();if(!r||!Array.isArray(r.tools))return{};let o={};for(let l of r.tools)l&&typeof l.name=="string"&&(o[l.name]=l);return o}function Zl(e){let{api:t="/api/waniwani",headers:a,body:n,onMessageSent:r,onResponseReceived:o}=e,l=(0,be.useRef)(a),i=(0,be.useRef)(n),s=(0,be.useRef)(void 0),u=(0,be.useRef)(null),[c,d]=(0,be.useState)(void 0),f=(0,be.useRef)(c),p=(0,be.useCallback)(()=>f.current,[]),y=(0,be.useCallback)(G=>{let Q=I2(G);Q&&f.current!==Q&&(f.current=Q,d(Q))},[]),v=(0,be.useCallback)(()=>{f.current=void 0,d(void 0)},[]);(0,be.useEffect)(()=>{l.current=a},[a]),(0,be.useEffect)(()=>{i.current=n},[n]),(0,be.useEffect)(()=>{C2().then(G=>{u.current=G}).catch(()=>{})},[]);let S=(0,be.useRef)(new wf({api:t,headers:()=>({...l.current}),body:()=>{let G={...i.current??{}},Q=Object.hasOwn(G,"sessionId"),ke=I2(G.sessionId);if(ke)y(ke),G.sessionId=ke;else if(Q)v(),delete G.sessionId;else{let se=p();se&&(G.sessionId=se)}if(Fl(s.current)&&(G.modelContext=s.current),u.current){let se=u.current;G.visitorContext={timezone:se.timezone,language:se.language,languages:se.languages,deviceType:se.deviceType,referrer:se.referrer,visitorId:se.visitorId}}return G},fetch:(async(G,Q)=>{let ke=await fetch(G,Q);return s.current=void 0,y(ke.headers.get(o6)),ke})})),g=(0,be.useRef)(null),x=(0,be.useRef)(null),m=(0,be.useRef)({}),[w,L]=(0,be.useState)(0),b=e.skipRemoteConfig===!0,A=(0,be.useCallback)(async()=>{if(!b)try{let G=await l6(t,l.current);m.current=G,L(Q=>Q+1)}catch(G){console.warn("[WaniWani] Failed to fetch tool definitions:",G instanceof Error?G.message:G)}},[t,b]);(0,be.useEffect)(()=>{A()},[A]);let{messages:R,sendMessage:_,setMessages:T,status:D}=w2({messages:e.initialMessages,transport:S.current,onFinish({message:G}){o?.(),g.current&&(x.current=G)},onError(G){console.warn("[WaniWani] Chat error:",G.message),g.current&&(g.current.reject(G),g.current=null)}});(0,be.useEffect)(()=>{if(D==="ready"&&g.current&&x.current){let G=g.current,Q=x.current;g.current=null,x.current=null,G.resolve(Q)}},[D]);let[N,B]=(0,be.useState)(""),[j,V]=(0,be.useState)([]),F=D==="submitted"||D==="streaming",te=(0,be.useCallback)(G=>{V(Q=>Q.filter(ke=>ke.id!==G))},[]),$e=F&&j.length>0,Z=(0,be.useCallback)(G=>{let Q=!!G.text?.trim(),ke=!!G.files?.length;if(Q||ke){if(F){if(j.length>0)return;V(se=>[...se,{id:jc(),text:G.text||"",files:G.files??[],modelContext:G.modelContext}]),B("");return}s.current=G.modelContext,_({text:G.text||"",files:G.files}),r?.(G.text||""),B("")}},[_,r,F,j.length]),C=(0,be.useCallback)(G=>new Promise((Q,ke)=>{g.current={resolve:Q,reject:ke},_({text:G}),r?.(G)}),[_,r]);(0,be.useEffect)(()=>{if(D!=="ready"||j.length===0)return;let[G,...Q]=j;V(Q),s.current=G.modelContext,_({text:G.text,files:G.files.length>0?G.files:void 0}),r?.(G.text)},[D,_,r,j]);let Xe=(0,be.useCallback)(()=>{T([]),V([]),v(),B(""),m.current={},L(G=>G+1),A()},[T,v,A]),le=(0,be.useCallback)(G=>{B(G.target.value)},[]),k=R[R.length-1],Ze=R.length>0,Ue=F&&(!Ze||k.role==="user"),Hn=m.current;return{messages:R,status:D,text:N,setText:B,handleSubmit:Z,handleTextChange:le,isLoading:F,showLoaderBubble:Ue,lastMessage:k,hasMessages:Ze,sendMessage:_,sendMessageAndWait:C,reset:Xe,queuedMessages:j,queueFull:$e,removeQueuedMessage:te,sessionId:c,toolDefinitions:Hn,refreshToolDefinitions:A}}var ko=q(xe(),1),i6={debug:!1,eval:!1};function bf(e="/api/waniwani",t,a=!1){let[n,r]=(0,ko.useState)(i6),o=(0,ko.useRef)(t);return(0,ko.useEffect)(()=>{o.current=t},[t]),(0,ko.useEffect)(()=>{a||(async()=>{try{let l=o.current,s=await(await fetch(`${e}/config`,{headers:l?{...l}:void 0})).json();r({debug:s.debug===!0,eval:s.eval===!0})}catch{}})()},[e,a]),n}var sn=q(xe(),1);function s6(e){for(let t of e.parts){let a=t;if(a.type==="data"||a.type==="data-suggestions"){let n=a.data;if(n&&Array.isArray(n.suggestions))return n.suggestions}}return null}function L2(e){return typeof e=="object"&&e!==null&&"initial"in e}function Ql(e){let{messages:t,status:a,config:n}=e,r=L2(n)&&n.initial?n.initial:void 0,[o,l]=(0,sn.useState)(r??[]),i=(0,sn.useRef)(a),s=n===!0||L2(n)&&n.dynamic!==!1,u=(0,sn.useCallback)(()=>{l([])},[]),c=t.length>0;(0,sn.useEffect)(()=>{!c&&r&&r.length>0&&l(r)},[r,c]);let d=t[t.length-1];return(0,sn.useEffect)(()=>{d?.role==="user"&&u()},[d,u]),(0,sn.useEffect)(()=>{let f=i.current;if(i.current=a,f==="streaming"&&a==="ready"&&s){let p=[...t].reverse().find(v=>v.role==="assistant");if(!p)return;console.log("[WaniWani] Assistant parts:",p.parts);let y=s6(p);console.log("[WaniWani] Extracted suggestions:",y),y&&l(y)}},[a,s,t]),{suggestions:o,isLoading:!1,clear:u}}var Kl=q(xe(),1),u6=50,c6=30,d6=2e3,k2=500;function Yl(e,t=!0){let[a,n]=(0,Kl.useState)(""),r=(0,Kl.useRef)(void 0);return(0,Kl.useEffect)(()=>{if(!t){n("");return}let o=0,l=!1,i=!1,s=()=>{i||(l?(o--,n(e.slice(0,o)),o<=0?(l=!1,r.current=setTimeout(s,k2)):r.current=setTimeout(s,c6)):(o++,n(e.slice(0,o)),o>=e.length?(l=!0,r.current=setTimeout(s,d6)):r.current=setTimeout(s,u6)))};return r.current=setTimeout(s,k2),()=>{i=!0,clearTimeout(r.current)}},[e,t]),a}function Sf(e,t){let a=t?.Authorization,n=typeof a=="string"&&a.startsWith("Bearer ")?a.slice(7):null;return n?`${e}/resource?token=${encodeURIComponent(n)}`:`${e}/resource`}var f6={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"};var p6={primaryColor:["--ww-primary","--ww-color-primary"],primaryForeground:["--ww-primary-fg","--ww-color-primary-foreground"],backgroundColor:["--ww-bg","--ww-color-background"],textColor:["--ww-text","--ww-color-foreground","--ww-color-accent-foreground"],mutedColor:["--ww-muted","--ww-color-muted-foreground"],borderColor:["--ww-border","--ww-color-border"],assistantBubbleColor:["--ww-assistant-bubble","--ww-color-accent"],userBubbleColor:["--ww-user-bubble"],inputBackgroundColor:["--ww-input-bg","--ww-color-input"],borderRadius:["--ww-radius"],messageBorderRadius:["--ww-msg-radius"],fontFamily:["--ww-font"],headerBackgroundColor:["--ww-header-bg"],headerTextColor:["--ww-header-text"],statusColor:["--ww-status"],toolCardColor:["--ww-tool-card","--ww-color-tool-card"]};function Jl(e){return{...f6,...e}}function ei(e){let t=e.backgroundColor.replace("#",""),a=parseInt(t.substring(0,2),16),n=parseInt(t.substring(2,4),16),r=parseInt(t.substring(4,6),16);return(a*299+n*587+r*114)/1e3<128}function ti(e){let t={};for(let[a,n]of Object.entries(p6)){let r=e[a],o=typeof r=="number"?`${r}px`:String(r);for(let l of n)t[l]=o}return t}var rt=q(ee(),1),Cf=(0,Ut.forwardRef)(function(t,a){let{theme:n,title:r="Assistant",width:o,height:l,className:i,allowAttachments:s=!1,welcomeMessage:u,welcome:c,placeholder:d="Ask me anything...",triggerEvent:f="triggerDemoRequest",api:p,debug:y}=t,v=p??"/api/waniwani",S=Sf(v,t.headers),g=Jl(n),x=ti(g),m=ei(g),w=bf(v,t.headers,t.skipRemoteConfig),L=y??w.debug,b=Zl({...t,api:v}),A=Vl({...t,api:v,sessionId:b.sessionId}),R=Yl(d,!b.text),[_,T]=(0,Ut.useState)(!1),[D,N]=(0,Ut.useState)(null),B=(0,Ut.useRef)(null),j=(0,Ut.useRef)(void 0),V=(0,Ut.useCallback)(()=>{let Z=B.current;if(!Z)return;Z.scrollIntoView({behavior:"smooth",block:"center"});let C=Z.querySelector("textarea");C&&setTimeout(()=>C.focus(),300),T(!0),clearTimeout(j.current),j.current=setTimeout(()=>T(!1),2e3)},[]),F=Ql({messages:b.messages,status:b.status,config:t.suggestions}),te=(0,Ut.useCallback)(Z=>{let C=Z.content.map(Xe=>Xe.text??"").join("").trim();C&&b.handleSubmit({text:C,files:[],modelContext:Z.modelContext})},[b.handleSubmit]),$e=(0,Ut.useCallback)(Z=>{F.clear(),b.handleSubmit({text:Z,files:[]})},[F.clear,b.handleSubmit]);return(0,Ut.useImperativeHandle)(a,()=>({sendMessage:Z=>{b.handleSubmit({text:Z,files:[]}),V()},sendMessageAndWait:Z=>b.sendMessageAndWait(Z),reset:b.reset,focus:V,get messages(){return b.messages}}),[b.handleSubmit,b.sendMessageAndWait,b.reset,b.messages,V]),(0,Ut.useEffect)(()=>{if(!f)return;let Z=C=>{let Xe=C.detail,le=typeof Xe?.message=="string"?Xe.message:void 0;le&&b.handleSubmit({text:le,files:[]}),V()};return window.addEventListener(f,Z),()=>window.removeEventListener(f,Z)},[f,b.handleSubmit,V]),(0,rt.jsxs)("div",{ref:B,style:{...x,width:o,height:l},"data-waniwani-chat":"","data-waniwani-layout":"card",...m?{"data-waniwani-dark":""}:{},className:$("ww:flex ww:flex-col ww:font-[family-name:var(--ww-font)] ww:text-foreground ww:bg-background ww:rounded-[var(--ww-radius)] ww:overflow-hidden",_&&"ww:ring-2 ww:ring-blue-400/70 ww:ring-offset-2 ww:ring-offset-background",i),children:[(0,rt.jsxs)("div",{className:"ww:shrink-0 ww:flex ww:items-center ww:px-6 ww:py-3",style:{backgroundColor:g.headerBackgroundColor,color:g.headerTextColor},children:[(0,rt.jsx)("div",{className:"ww:text-sm ww:font-semibold ww:truncate",children:r}),(0,rt.jsx)(Gc,{messages:b.messages,evalEnabled:w.eval,api:v})]}),(0,rt.jsxs)(Sl,{className:"ww:flex-1 ww:min-h-0 ww:bg-background",children:[(0,rt.jsx)(Cl,{scrollClassName:D?"ww:!relative ww:!overflow-hidden":void 0,children:(0,rt.jsx)(Hl,{messages:b.messages,status:b.status,welcomeMessage:u,welcome:c,onSuggestionSelect:$e,resourceEndpoint:S,chatSessionId:b.sessionId,isDark:m,onFollowUp:te,onCallTool:A,fullscreenToolCallId:D,debug:L,toolDefinitions:b.toolDefinitions,onWidgetDisplayModeChange:(Z,C)=>{N(Z==="fullscreen"?C.toolCallId:null)}})}),(0,rt.jsx)(Il,{})]}),(0,rt.jsx)("div",{style:D?{display:"none"}:void 0,children:(0,rt.jsx)(jl,{suggestions:F.suggestions,isLoading:F.isLoading,onSelect:$e})}),(0,rt.jsx)("div",{style:D?{display:"none"}:void 0,children:(0,rt.jsx)(Al,{queuedMessages:b.queuedMessages,onRemove:b.removeQueuedMessage})}),(0,rt.jsx)("div",{style:D?{display:"none"}:void 0,children:(0,rt.jsx)("div",{className:"ww:shrink-0 ww:px-4 ww:pb-8 ww:pt-2 ww:bg-background",children:(0,rt.jsx)("div",{className:"ww:mx-auto ww:w-full ww:max-w-3xl",children:(0,rt.jsx)(Ll,{onSubmit:b.handleSubmit,globalDrop:s,multiple:s,className:"ww:rounded-2xl ww:border-border ww:bg-input",children:(0,rt.jsxs)("div",{className:"ww:flex ww:items-center ww:gap-1 ww:pl-4 ww:pr-3 ww:py-2.5",children:[s&&(0,rt.jsx)(Ml,{}),(0,rt.jsx)(kl,{onChange:b.handleTextChange,value:b.text,placeholder:R,className:"ww:min-h-0 ww:py-1 ww:px-0"}),(0,rt.jsx)(Tl,{status:b.status,disabled:b.queueFull})]})})})})})]})});var If=q(xe(),1);async function m6(e,t,a){try{let n=`${e.replace(/\/$/,"")}/config`,r=await fetch(n,{method:"GET",headers:{Authorization:`Bearer ${t}`},signal:a});if(!r.ok)return{};let o=await r.json(),l=o&&typeof o=="object"&&"data"in o&&o.data?o.data:o;return l?h6(l):{}}catch{return{}}}function h6(e){let t={};return e.title!=null&&(t.title=e.title),e.welcomeMessage!=null&&(t.welcomeMessage=e.welcomeMessage),e.placeholder!=null&&(t.placeholder=e.placeholder),e.suggestions!=null&&e.suggestions.length>0&&(t.suggestions=e.suggestions),t}function Lf(e,t,a){let[n,r]=(0,If.useState)(e);return(0,If.useEffect)(()=>{let o=e.api,l=e.token;if(!o||!l)return;let i=new AbortController;return m6(o,l,i.signal).then(s=>{if(!i.signal.aborted&&Object.keys(s).length!==0)try{r(Nc(t,s,a))}catch(u){console.error("[WaniWani] Failed to apply remote config:",u)}}).catch(s=>{console.error("[WaniWani] Remote config fetch failed:",s)}),()=>i.abort()},[e.api,e.token]),n}var Tt=q(ee(),1);function g6(){return(0,Tt.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",role:"img","aria-label":"Chat",children:[(0,Tt.jsx)("title",{children:"Chat"}),(0,Tt.jsx)("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})]})}function y6(){return(0,Tt.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",role:"img","aria-label":"Close",children:[(0,Tt.jsx)("title",{children:"Close"}),(0,Tt.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,Tt.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}var hx=56,gx=20,x6=12,To=200,T2=(0,ct.forwardRef)(function({config:t,programmatic:a,scriptConfig:n,onReady:r},o){let l=Lf(t,a,n),[i,s]=(0,ct.useState)(!1),[u,c]=(0,ct.useState)(0),[d,f]=(0,ct.useState)(!1),p=(0,ct.useRef)(null),y=(0,ct.useRef)(i);y.current=i,(0,ct.useEffect)(()=>{r?.()},[]),(0,ct.useEffect)(()=>{let F=window.matchMedia("(max-width: 768px)"),te=$e=>f($e.matches);return te(F),F.addEventListener("change",te),()=>F.removeEventListener("change",te)},[]),(0,ct.useEffect)(()=>{if(!i)return;let F=te=>{te.key==="Escape"&&s(!1)};return document.addEventListener("keydown",F),()=>document.removeEventListener("keydown",F)},[i]),(0,ct.useEffect)(()=>{i&&c(0)},[i]);let v=(0,ct.useCallback)(()=>{y.current||c(F=>F+1)},[]),S=(0,ct.useCallback)(()=>s(!0),[]),g=(0,ct.useCallback)(()=>s(!1),[]),x=(0,ct.useCallback)(()=>s(F=>!F),[]);(0,ct.useImperativeHandle)(o,()=>({open:S,close:g,toggle:x,get chat(){return p.current}}));let m=!i&&u>0,w=l.mode==="custom",L=l.position==="bottom-left",b=l.width??400,A=l.height??600,R=l.theme?.primaryColor??"#6366f1",_={position:"fixed",bottom:gx,...L?{left:gx}:{right:gx},zIndex:2147483647,fontFamily:l.theme?.fontFamily??"system-ui, -apple-system, 'Segoe UI', sans-serif"},T={width:hx,height:hx,borderRadius:"50%",backgroundColor:R,color:"#ffffff",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)",transition:`transform ${To}ms ease, box-shadow ${To}ms ease`,outline:"none"},D=d?{position:"fixed",inset:0,zIndex:2147483647,transition:`transform ${To}ms ease, opacity ${To}ms ease`,...i?{transform:"translateY(0) scale(1)",opacity:1}:{transform:"translateY(20px) scale(0.95)",opacity:0,pointerEvents:"none"}}:{position:"absolute",bottom:w?0:hx+x6,...L?{left:0}:{right:0},width:b,height:A,transition:`transform ${To}ms ease, opacity ${To}ms ease`,...i?{transform:"translateY(0) scale(1)",opacity:1}:{transform:"translateY(20px) scale(0.95)",opacity:0,pointerEvents:"none"}},N={width:"100%",height:"100%",borderRadius:d?0:12,overflow:"hidden",boxShadow:d?"none":"0 8px 32px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.08)"},B={position:"absolute",top:d?12:8,right:d?12:8,zIndex:10,width:d?36:28,height:d?36:28,borderRadius:"50%",backgroundColor:"rgba(0, 0, 0, 0.06)",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",color:"inherit",outline:"none",transition:`background-color ${To}ms ease`},j={position:"absolute",top:-2,right:-2,width:12,height:12,borderRadius:"50%",backgroundColor:"#ef4444",border:"2px solid #ffffff"},V=Bc(l);return(0,Tt.jsxs)("div",{style:_,children:[(0,Tt.jsx)("div",{style:D,role:"dialog","aria-label":"Chat panel",children:(0,Tt.jsxs)("div",{style:{...N,position:"relative"},children:[(0,Tt.jsx)("button",{type:"button",onClick:g,style:B,"aria-label":"Close chat",onMouseEnter:F=>{F.currentTarget.style.backgroundColor="rgba(0, 0, 0, 0.12)"},onMouseLeave:F=>{F.currentTarget.style.backgroundColor="rgba(0, 0, 0, 0.06)"},children:(0,Tt.jsx)(y6,{})}),(0,Tt.jsx)(Cf,{ref:p,api:l.api,headers:{Authorization:`Bearer ${l.token}`},skipRemoteConfig:!0,body:l.mcpServerUrl?{mcpServerUrl:l.mcpServerUrl}:void 0,theme:V,title:l.title??"Assistant",welcomeMessage:l.welcomeMessage,placeholder:l.placeholder,suggestions:l.suggestions?{initial:l.suggestions}:void 0,onResponseReceived:v,width:"100%",height:"100%"})]})}),!w&&(0,Tt.jsxs)("button",{type:"button",onClick:x,style:{...T,position:"relative"},"aria-label":i?"Close chat":"Open chat",onMouseEnter:F=>{F.currentTarget.style.transform="scale(1.08)",F.currentTarget.style.boxShadow="0 6px 20px rgba(0, 0, 0, 0.2)"},onMouseLeave:F=>{F.currentTarget.style.transform="scale(1)",F.currentTarget.style.boxShadow="0 4px 12px rgba(0, 0, 0, 0.15)"},children:[(0,Tt.jsx)(g6,{}),m&&(0,Tt.jsx)("span",{style:j})]})]})});var _r=q(xe(),1);var wt=q(xe(),1);var dt=q(ee(),1),M2=(0,wt.forwardRef)(function(t,a){let{theme:n,title:r="Assistant",width:o=600,expandedWidth:l,expandedHeight:i=400,allowAttachments:s=!1,welcomeMessage:u,welcome:c,placeholder:d="Ask me anything...",triggerEvent:f="triggerDemoRequest",api:p}=t,y=l??Math.round((typeof o=="number"?o:600)*1.2),v=p??"/api/waniwani",S=Sf(v,t.headers),g=Jl(n),x=ti(g),m=ei(g),w=bf(p,t.headers,t.skipRemoteConfig),L=Zl(t),b=Vl({...t,sessionId:L.sessionId}),A=Ql({messages:L.messages,status:L.status,config:t.suggestions}),R=(0,wt.useCallback)(le=>{let k=le.content.map(Ze=>Ze.text??"").join("").trim();k&&L.handleSubmit({text:k,files:[],modelContext:le.modelContext})},[L.handleSubmit]),_=(0,wt.useCallback)(le=>{A.clear(),L.handleSubmit({text:le,files:[]})},[A.clear,L.handleSubmit]),T=Yl(d,!L.text),[D,N]=(0,wt.useState)(!1),[B,j]=(0,wt.useState)(!1),[V,F]=(0,wt.useState)(null),te=(0,wt.useRef)(null),$e=(0,wt.useRef)(void 0),Z=(0,wt.useCallback)(()=>{let le=te.current;if(!le)return;le.scrollIntoView({behavior:"smooth",block:"center"});let k=le.querySelector("textarea");k&&setTimeout(()=>k.focus(),300),N(!0),j(!0),clearTimeout($e.current),$e.current=setTimeout(()=>j(!1),2e3)},[]);(0,wt.useImperativeHandle)(a,()=>({sendMessage:le=>{L.handleSubmit({text:le,files:[]}),Z()},sendMessageAndWait:le=>L.sendMessageAndWait(le),reset:L.reset,focus:Z,get messages(){return L.messages}}),[L.handleSubmit,L.sendMessageAndWait,L.reset,L.messages,Z]),(0,wt.useEffect)(()=>{if(!f)return;let le=k=>{let Ze=k.detail,Ue=typeof Ze?.message=="string"?Ze.message:void 0;Ue&&L.handleSubmit({text:Ue,files:[]}),Z()};return window.addEventListener(f,le),()=>window.removeEventListener(f,le)},[f,L.handleSubmit,Z]);let C=D||V!==null;(0,wt.useEffect)(()=>{if(!D)return;let le=k=>{te.current&&!te.current.contains(k.target)&&N(!1)};return document.addEventListener("mousedown",le),()=>document.removeEventListener("mousedown",le)},[D]);let Xe=(0,wt.useCallback)(()=>{N(!0)},[]);return(0,dt.jsxs)("div",{ref:te,style:{...x,width:C?y:o,transition:"width 0.4s cubic-bezier(0.16, 1, 0.3, 1)"},"data-waniwani-chat":"","data-waniwani-layout":"bar",...m?{"data-waniwani-dark":""}:{},className:"ww:flex ww:flex-col ww:font-[family-name:var(--ww-font)] ww:text-foreground",children:[(0,dt.jsxs)("div",{style:{overflow:"hidden",backgroundColor:g.backgroundColor,borderRadius:"var(--ww-radius) var(--ww-radius) 0 0",maxHeight:C?i+200:0,opacity:C?1:0,transform:C?"scaleX(1)":"scaleX(0.88)",transformOrigin:"center bottom",transition:"max-height 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease-out, transform 0.4s cubic-bezier(0.16, 1, 0.3, 1)"},children:[(0,dt.jsxs)("div",{className:"ww:shrink-0 ww:flex ww:items-center ww:px-6 ww:py-3",style:{backgroundColor:g.headerBackgroundColor,color:g.headerTextColor},children:[(0,dt.jsx)("div",{className:"ww:text-sm ww:font-semibold ww:truncate",children:r}),(0,dt.jsx)(Gc,{messages:L.messages,evalEnabled:w.eval,api:v})]}),(0,dt.jsxs)(Sl,{className:"ww:flex-1",style:{height:i},children:[(0,dt.jsx)(Cl,{scrollClassName:V?"ww:!relative ww:!overflow-hidden":void 0,children:(0,dt.jsx)(Hl,{messages:L.messages,status:L.status,welcomeMessage:u,welcome:c,onSuggestionSelect:_,resourceEndpoint:S,chatSessionId:L.sessionId,isDark:m,onFollowUp:R,onCallTool:b,fullscreenToolCallId:V,toolDefinitions:L.toolDefinitions,onWidgetDisplayModeChange:(le,k)=>{F(le==="fullscreen"?k.toolCallId:null)}})}),(0,dt.jsx)(Il,{})]}),(0,dt.jsx)("div",{style:V?{display:"none"}:void 0,children:(0,dt.jsx)(jl,{suggestions:A.suggestions,isLoading:A.isLoading,onSelect:_})}),(0,dt.jsx)("div",{style:V?{display:"none"}:void 0,children:(0,dt.jsx)(Al,{queuedMessages:L.queuedMessages,onRemove:L.removeQueuedMessage})})]}),(0,dt.jsx)("div",{style:{backgroundColor:C?g.backgroundColor:"transparent",borderRadius:C?"0 0 var(--ww-radius) var(--ww-radius)":void 0,boxShadow:C?"0 8px 24px rgba(0,0,0,0.1)":"none",transition:"background-color 0.2s ease, border-radius 0.3s ease, box-shadow 0.35s ease, padding 0.3s ease",padding:C?"8px 16px 16px":"0"},children:(0,dt.jsx)(Ll,{onSubmit:L.handleSubmit,globalDrop:s,multiple:s,className:$("ww:rounded-2xl ww:border-border ww:bg-input ww:transition-all ww:duration-300",!C&&"ww:shadow-sm",B&&"ww:ring-2 ww:ring-blue-400/70 ww:ring-offset-2 ww:ring-offset-background"),children:(0,dt.jsxs)("div",{className:"ww:flex ww:items-center ww:gap-1 ww:pl-4 ww:pr-3 ww:py-2.5",children:[s&&(0,dt.jsx)(Ml,{}),(0,dt.jsx)(kl,{onChange:L.handleTextChange,value:L.text,placeholder:T,onFocus:Xe,className:"ww:min-h-0 ww:py-1 ww:px-0"}),(0,dt.jsx)(Tl,{status:L.status,disabled:L.queueFull})]})})})]})});var ra=q(xe(),1);var bt=q(ee(),1),A2=(0,ra.forwardRef)(function(t,a){let{theme:n,className:r,allowAttachments:o=!1,welcomeMessage:l,welcome:i,placeholder:s="Ask me anything...",triggerEvent:u="triggerDemoRequest",api:c,mcp:d,debug:f=!1,readOnly:p=!1}=t,y=Jl(n),v=ti(y),S=ei(y),g=Zl({...t,api:c}),x=Vl({...t,api:c,sessionId:g.sessionId,onCallTool:d?.onCallTool}),m=Yl(s,!g.text),[w,L]=(0,ra.useState)(null),b=(0,ra.useRef)(null),A=(0,ra.useCallback)(()=>{let D=b.current;if(!D)return;let N=D.querySelector("textarea");N&&N.focus()},[]),R=Ql({messages:g.messages,status:g.status,config:t.suggestions}),_=(0,ra.useCallback)(D=>{let N=D.content.map(B=>B.text??"").join("").trim();N&&g.handleSubmit({text:N,files:[],modelContext:D.modelContext})},[g.handleSubmit]),T=(0,ra.useCallback)(D=>{R.clear(),g.handleSubmit({text:D,files:[]})},[R.clear,g.handleSubmit]);return(0,ra.useImperativeHandle)(a,()=>({sendMessage:D=>{g.handleSubmit({text:D,files:[]}),A()},sendMessageAndWait:D=>g.sendMessageAndWait(D),reset:g.reset,focus:A,get messages(){return g.messages}}),[g.handleSubmit,g.sendMessageAndWait,g.reset,g.messages,A]),(0,ra.useEffect)(()=>{if(!u)return;let D=N=>{let B=N.detail,j=typeof B?.message=="string"?B.message:void 0;j&&g.handleSubmit({text:j,files:[]}),A()};return window.addEventListener(u,D),()=>window.removeEventListener(u,D)},[u,g.handleSubmit,A]),(0,bt.jsxs)("div",{ref:b,style:v,"data-waniwani-chat":"","data-waniwani-layout":"embed",...S?{"data-waniwani-dark":""}:{},className:$("ww:flex ww:flex-col ww:w-full ww:h-full ww:font-[family-name:var(--ww-font)] ww:text-foreground ww:bg-background ww:overflow-hidden",r),children:[(0,bt.jsxs)(Sl,{className:"ww:flex-1 ww:min-h-0 ww:bg-background",children:[(0,bt.jsx)(Cl,{scrollClassName:w?"ww:!relative ww:!overflow-hidden":void 0,children:(0,bt.jsx)(Hl,{messages:g.messages,status:g.status,welcomeMessage:l,welcome:i,onSuggestionSelect:T,resourceEndpoint:d?.resourceEndpoint,chatSessionId:g.sessionId,isDark:S,onFollowUp:_,onCallTool:x,fullscreenToolCallId:w,debug:f,toolDefinitions:g.toolDefinitions,onWidgetDisplayModeChange:(D,N)=>{L(D==="fullscreen"?N.toolCallId:null)}})}),(0,bt.jsx)(Il,{})]}),!p&&(0,bt.jsx)("div",{style:w?{display:"none"}:void 0,children:(0,bt.jsx)(jl,{suggestions:R.suggestions,isLoading:R.isLoading,onSelect:T})}),!p&&(0,bt.jsx)("div",{style:w?{display:"none"}:void 0,children:(0,bt.jsx)(Al,{queuedMessages:g.queuedMessages,onRemove:g.removeQueuedMessage})}),!p&&(0,bt.jsx)("div",{style:w?{display:"none"}:void 0,children:(0,bt.jsx)("div",{className:"ww:shrink-0 ww:px-4 ww:pb-8 ww:pt-2 ww:bg-background",children:(0,bt.jsx)("div",{className:"ww:mx-auto ww:w-full ww:max-w-3xl",children:(0,bt.jsx)(Ll,{onSubmit:g.handleSubmit,globalDrop:o,multiple:o,className:"ww:rounded-2xl ww:border-border ww:bg-input",children:(0,bt.jsxs)("div",{className:"ww:flex ww:items-center ww:gap-1 ww:pl-4 ww:pr-3 ww:py-2.5",children:[o&&(0,bt.jsx)(Ml,{}),(0,bt.jsx)(kl,{onChange:g.handleTextChange,value:g.text,placeholder:m,className:"ww:min-h-0 ww:py-1 ww:px-0"}),(0,bt.jsx)(Tl,{status:g.status,disabled:g.queueFull})]})})})})})]})});var kf=q(ee(),1),E2=(0,_r.forwardRef)(function({config:t,programmatic:a,scriptConfig:n,onReady:r},o){let l=Lf(t,a,n),i=(0,_r.useRef)(null);(0,_r.useEffect)(()=>{r?.()},[]),(0,_r.useImperativeHandle)(o,()=>({get chat(){return i.current}}),[]);let s={...Bc(l),borderRadius:0},u={api:l.api,headers:{Authorization:`Bearer ${l.token}`},skipRemoteConfig:!0,body:l.mcpServerUrl?{mcpServerUrl:l.mcpServerUrl}:void 0,theme:s,welcomeMessage:l.welcomeMessage,placeholder:l.placeholder,suggestions:l.suggestions?{initial:l.suggestions}:void 0},c=l.layout??"card";return c==="bar"?(0,kf.jsx)(M2,{...u,ref:i,title:l.title??"Assistant"}):c==="embed"?(0,kf.jsx)(A2,{...u,ref:i,api:u.api}):(0,kf.jsx)(Cf,{...u,ref:i,title:l.title??"Assistant",width:"100%",height:"100%"})});var yx="/*! tailwindcss v4.1.18 | MIT License | https://tailwindcss.com */\n@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-space-y-reverse:0;--tw-border-style:solid;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-duration:initial;--tw-ease:initial}}}@layer theme{:root,:host{--ww-font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,\"Liberation Mono\",\"Courier New\",monospace;--ww-color-red-300:oklch(80.8% .114 19.571);--ww-color-red-400:oklch(70.4% .191 22.216);--ww-color-red-500:oklch(63.7% .237 25.331);--ww-color-blue-400:oklch(70.7% .165 254.624);--ww-spacing:.25rem;--ww-container-sm:24rem;--ww-container-md:28rem;--ww-container-3xl:48rem;--ww-text-xs:.75rem;--ww-text-xs--line-height:calc(1/.75);--ww-text-sm:.875rem;--ww-text-sm--line-height:calc(1.25/.875);--ww-text-base:1rem;--ww-text-base--line-height:calc(1.5/1);--ww-text-lg:1.125rem;--ww-text-lg--line-height:calc(1.75/1.125);--ww-font-weight-medium:500;--ww-font-weight-semibold:600;--ww-tracking-wide:.025em;--ww-tracking-wider:.05em;--ww-tracking-widest:.1em;--ww-leading-normal:1.5;--ww-radius-md:.375rem;--ww-radius-lg:.5rem;--ww-radius-xl:.75rem;--ww-radius-2xl:1rem;--ww-ease-out:cubic-bezier(0,0,.2,1);--ww-animate-spin:spin 1s linear infinite;--ww-animate-pulse:pulse 2s cubic-bezier(.4,0,.6,1)infinite;--ww-default-transition-duration:.15s;--ww-default-transition-timing-function:cubic-bezier(.4,0,.2,1);--ww-default-font-family:var(--ww-font-sans,system-ui,-apple-system,\"Segoe UI\",sans-serif);--ww-default-mono-font-family:var(--ww-font-mono)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--ww-default-font-family,ui-sans-serif,system-ui,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\",\"Segoe UI Symbol\",\"Noto Color Emoji\");font-feature-settings:var(--ww-default-font-feature-settings,normal);font-variation-settings:var(--ww-default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--ww-default-mono-font-family,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,\"Liberation Mono\",\"Courier New\",monospace);font-feature-settings:var(--ww-default-mono-font-feature-settings,normal);font-variation-settings:var(--ww-default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab, red, red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer components;@layer utilities{.ww\\:\\!relative{position:relative!important}.ww\\:absolute{position:absolute}.ww\\:relative{position:relative}.ww\\:bottom-4{bottom:calc(var(--ww-spacing)*4)}.ww\\:left-\\[50\\%\\]{left:50%}.ww\\:mx-3{margin-inline:calc(var(--ww-spacing)*3)}.ww\\:mx-auto{margin-inline:auto}.ww\\:my-2{margin-block:calc(var(--ww-spacing)*2)}.ww\\:mt-0\\.5{margin-top:calc(var(--ww-spacing)*.5)}.ww\\:mt-1{margin-top:calc(var(--ww-spacing)*1)}.ww\\:mt-2{margin-top:calc(var(--ww-spacing)*2)}.ww\\:mt-6{margin-top:calc(var(--ww-spacing)*6)}.ww\\:mb-2{margin-bottom:calc(var(--ww-spacing)*2)}.ww\\:mb-4{margin-bottom:calc(var(--ww-spacing)*4)}.ww\\:ml-auto{margin-left:auto}.ww\\:line-clamp-1{-webkit-line-clamp:1;-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden}.ww\\:block{display:block}.ww\\:contents{display:contents}.ww\\:flex{display:flex}.ww\\:grid{display:grid}.ww\\:hidden{display:none}.ww\\:inline-block{display:inline-block}.ww\\:inline-flex{display:inline-flex}.ww\\:field-sizing-content{field-sizing:content}.ww\\:size-2{width:calc(var(--ww-spacing)*2);height:calc(var(--ww-spacing)*2)}.ww\\:size-3{width:calc(var(--ww-spacing)*3);height:calc(var(--ww-spacing)*3)}.ww\\:size-3\\.5{width:calc(var(--ww-spacing)*3.5);height:calc(var(--ww-spacing)*3.5)}.ww\\:size-4{width:calc(var(--ww-spacing)*4);height:calc(var(--ww-spacing)*4)}.ww\\:size-5{width:calc(var(--ww-spacing)*5);height:calc(var(--ww-spacing)*5)}.ww\\:size-7{width:calc(var(--ww-spacing)*7);height:calc(var(--ww-spacing)*7)}.ww\\:size-8{width:calc(var(--ww-spacing)*8);height:calc(var(--ww-spacing)*8)}.ww\\:size-9{width:calc(var(--ww-spacing)*9);height:calc(var(--ww-spacing)*9)}.ww\\:size-12{width:calc(var(--ww-spacing)*12);height:calc(var(--ww-spacing)*12)}.ww\\:size-auto{width:auto;height:auto}.ww\\:size-full{width:100%;height:100%}.ww\\:h-1\\.5{height:calc(var(--ww-spacing)*1.5)}.ww\\:h-3\\.5{height:calc(var(--ww-spacing)*3.5)}.ww\\:h-7{height:calc(var(--ww-spacing)*7)}.ww\\:h-8{height:calc(var(--ww-spacing)*8)}.ww\\:h-9{height:calc(var(--ww-spacing)*9)}.ww\\:h-16{height:calc(var(--ww-spacing)*16)}.ww\\:h-auto{height:auto}.ww\\:h-full{height:100%}.ww\\:max-h-48{max-height:calc(var(--ww-spacing)*48)}.ww\\:min-h-0{min-height:calc(var(--ww-spacing)*0)}.ww\\:min-h-full{min-height:100%}.ww\\:w-1\\.5{width:calc(var(--ww-spacing)*1.5)}.ww\\:w-fit{width:fit-content}.ww\\:w-full{width:100%}.ww\\:max-w-3xl{max-width:var(--ww-container-3xl)}.ww\\:max-w-24{max-width:calc(var(--ww-spacing)*24)}.ww\\:max-w-32{max-width:calc(var(--ww-spacing)*32)}.ww\\:max-w-\\[80\\%\\]{max-width:80%}.ww\\:max-w-full{max-width:100%}.ww\\:max-w-md{max-width:var(--ww-container-md)}.ww\\:max-w-sm{max-width:var(--ww-container-sm)}.ww\\:min-w-0{min-width:calc(var(--ww-spacing)*0)}.ww\\:flex-1{flex:1}.ww\\:shrink-0{flex-shrink:0}.ww\\:grow{flex-grow:1}.ww\\:translate-x-\\[-50\\%\\]{--tw-translate-x:-50%;translate:var(--tw-translate-x)var(--tw-translate-y)}.ww\\:rotate-90{rotate:90deg}.ww\\:rotate-180{rotate:180deg}.ww\\:animate-\\[ww-fade-in_0\\.2s_ease-out_both\\]{animation:.2s ease-out both ww-fade-in}.ww\\:animate-pulse{animation:var(--ww-animate-pulse)}.ww\\:animate-spin{animation:var(--ww-animate-spin)}.ww\\:cursor-pointer{cursor:pointer}.ww\\:resize-none{resize:none}.ww\\:grid-rows-\\[0fr\\]{grid-template-rows:0fr}.ww\\:grid-rows-\\[1fr\\]{grid-template-rows:1fr}.ww\\:flex-col{flex-direction:column}.ww\\:flex-wrap{flex-wrap:wrap}.ww\\:items-center{align-items:center}.ww\\:items-end{align-items:flex-end}.ww\\:items-start{align-items:flex-start}.ww\\:justify-between{justify-content:space-between}.ww\\:justify-center{justify-content:center}.ww\\:gap-1{gap:calc(var(--ww-spacing)*1)}.ww\\:gap-1\\.5{gap:calc(var(--ww-spacing)*1.5)}.ww\\:gap-2{gap:calc(var(--ww-spacing)*2)}.ww\\:gap-3{gap:calc(var(--ww-spacing)*3)}.ww\\:gap-6{gap:calc(var(--ww-spacing)*6)}:where(.ww\\:space-y-2>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--ww-spacing)*2)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--ww-spacing)*2)*calc(1 - var(--tw-space-y-reverse)))}:where(.ww\\:space-y-3>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--ww-spacing)*3)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--ww-spacing)*3)*calc(1 - var(--tw-space-y-reverse)))}.ww\\:truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.ww\\:\\!overflow-hidden{overflow:hidden!important}.ww\\:overflow-hidden{overflow:hidden}.ww\\:overflow-x-auto{overflow-x:auto}.ww\\:overflow-y-auto{overflow-y:auto}.ww\\:overflow-y-hidden{overflow-y:hidden}.ww\\:\\!rounded-full{border-radius:3.40282e38px!important}.ww\\:rounded{border-radius:var(--ww-radius,16px)}.ww\\:rounded-2xl{border-radius:var(--ww-radius-2xl)}.ww\\:rounded-\\[var\\(--ww-radius\\)\\]{border-radius:var(--ww-radius)}.ww\\:rounded-full{border-radius:3.40282e38px}.ww\\:rounded-lg{border-radius:var(--ww-radius-lg)}.ww\\:rounded-md{border-radius:var(--ww-radius-md)}.ww\\:rounded-xl{border-radius:var(--ww-radius-xl)}.ww\\:border{border-style:var(--tw-border-style);border-width:1px}.ww\\:border-0{border-style:var(--tw-border-style);border-width:0}.ww\\:border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.ww\\:border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.ww\\:border-l{border-left-style:var(--tw-border-style);border-left-width:1px}.ww\\:border-l-2{border-left-style:var(--tw-border-style);border-left-width:2px}.ww\\:border-\\[\\#03d916\\]{border-color:#03d916}.ww\\:border-border,.ww\\:border-border\\/50{border-color:var(--ww-color-border,#e5e7eb)}@supports (color:color-mix(in lab, red, red)){.ww\\:border-border\\/50{border-color:color-mix(in oklab,var(--ww-color-border,#e5e7eb)50%,transparent)}}.ww\\:border-foreground\\/30{border-color:var(--ww-color-foreground,#1f2937)}@supports (color:color-mix(in lab, red, red)){.ww\\:border-foreground\\/30{border-color:color-mix(in oklab,var(--ww-color-foreground,#1f2937)30%,transparent)}}.ww\\:border-muted-foreground\\/50{border-color:var(--ww-color-muted-foreground,#6b7280)}@supports (color:color-mix(in lab, red, red)){.ww\\:border-muted-foreground\\/50{border-color:color-mix(in oklab,var(--ww-color-muted-foreground,#6b7280)50%,transparent)}}.ww\\:border-transparent{border-color:#0000}.ww\\:bg-\\[\\#03d916\\]\\/10{background-color:oklab(76.761% -.205195 .155304/.1)}.ww\\:bg-accent{background-color:var(--ww-color-accent,#f3f4f6)}.ww\\:bg-background,.ww\\:bg-background\\/20{background-color:var(--ww-color-background,#fff)}@supports (color:color-mix(in lab, red, red)){.ww\\:bg-background\\/20{background-color:color-mix(in oklab,var(--ww-color-background,#fff)20%,transparent)}}.ww\\:bg-foreground{background-color:var(--ww-color-foreground,#1f2937)}.ww\\:bg-input{background-color:var(--ww-color-input,#f9fafb)}.ww\\:bg-muted{background-color:var(--ww-color-muted,#f1f5f9)}.ww\\:bg-muted-foreground\\/10{background-color:var(--ww-color-muted-foreground,#6b7280)}@supports (color:color-mix(in lab, red, red)){.ww\\:bg-muted-foreground\\/10{background-color:color-mix(in oklab,var(--ww-color-muted-foreground,#6b7280)10%,transparent)}}.ww\\:bg-muted-foreground\\/20{background-color:var(--ww-color-muted-foreground,#6b7280)}@supports (color:color-mix(in lab, red, red)){.ww\\:bg-muted-foreground\\/20{background-color:color-mix(in oklab,var(--ww-color-muted-foreground,#6b7280)20%,transparent)}}.ww\\:bg-muted-foreground\\/60{background-color:var(--ww-color-muted-foreground,#6b7280)}@supports (color:color-mix(in lab, red, red)){.ww\\:bg-muted-foreground\\/60{background-color:color-mix(in oklab,var(--ww-color-muted-foreground,#6b7280)60%,transparent)}}.ww\\:bg-muted\\/50{background-color:var(--ww-color-muted,#f1f5f9)}@supports (color:color-mix(in lab, red, red)){.ww\\:bg-muted\\/50{background-color:color-mix(in oklab,var(--ww-color-muted,#f1f5f9)50%,transparent)}}.ww\\:bg-primary{background-color:var(--ww-color-primary,#6366f1)}.ww\\:bg-red-500\\/10{background-color:var(--ww-color-red-500)}@supports (color:color-mix(in lab, red, red)){.ww\\:bg-red-500\\/10{background-color:color-mix(in oklab,var(--ww-color-red-500)10%,transparent)}}.ww\\:bg-tool-card{background-color:var(--ww-color-tool-card,#f4f4f5)}.ww\\:bg-transparent{background-color:#0000}.ww\\:object-cover{object-fit:cover}.ww\\:p-0{padding:calc(var(--ww-spacing)*0)}.ww\\:p-1{padding:calc(var(--ww-spacing)*1)}.ww\\:p-3{padding:calc(var(--ww-spacing)*3)}.ww\\:px-0{padding-inline:calc(var(--ww-spacing)*0)}.ww\\:px-1\\.5{padding-inline:calc(var(--ww-spacing)*1.5)}.ww\\:px-2{padding-inline:calc(var(--ww-spacing)*2)}.ww\\:px-3{padding-inline:calc(var(--ww-spacing)*3)}.ww\\:px-4{padding-inline:calc(var(--ww-spacing)*4)}.ww\\:px-6{padding-inline:calc(var(--ww-spacing)*6)}.ww\\:py-0\\.5{padding-block:calc(var(--ww-spacing)*.5)}.ww\\:py-1{padding-block:calc(var(--ww-spacing)*1)}.ww\\:py-1\\.5{padding-block:calc(var(--ww-spacing)*1.5)}.ww\\:py-2{padding-block:calc(var(--ww-spacing)*2)}.ww\\:py-2\\.5{padding-block:calc(var(--ww-spacing)*2.5)}.ww\\:py-3{padding-block:calc(var(--ww-spacing)*3)}.ww\\:py-6{padding-block:calc(var(--ww-spacing)*6)}.ww\\:py-8{padding-block:calc(var(--ww-spacing)*8)}.ww\\:py-12{padding-block:calc(var(--ww-spacing)*12)}.ww\\:pt-2{padding-top:calc(var(--ww-spacing)*2)}.ww\\:pt-2\\.5{padding-top:calc(var(--ww-spacing)*2.5)}.ww\\:pt-3{padding-top:calc(var(--ww-spacing)*3)}.ww\\:pr-3{padding-right:calc(var(--ww-spacing)*3)}.ww\\:pb-1\\.5{padding-bottom:calc(var(--ww-spacing)*1.5)}.ww\\:pb-3{padding-bottom:calc(var(--ww-spacing)*3)}.ww\\:pb-8{padding-bottom:calc(var(--ww-spacing)*8)}.ww\\:pl-4{padding-left:calc(var(--ww-spacing)*4)}.ww\\:text-center{text-align:center}.ww\\:text-left{text-align:left}.ww\\:font-\\[family-name\\:var\\(--ww-font\\)\\]{font-family:var(--ww-font)}.ww\\:font-mono{font-family:var(--ww-font-mono)}.ww\\:text-base{font-size:var(--ww-text-base);line-height:var(--tw-leading,var(--ww-text-base--line-height))}.ww\\:text-lg{font-size:var(--ww-text-lg);line-height:var(--tw-leading,var(--ww-text-lg--line-height))}.ww\\:text-sm{font-size:var(--ww-text-sm);line-height:var(--tw-leading,var(--ww-text-sm--line-height))}.ww\\:text-xs{font-size:var(--ww-text-xs);line-height:var(--tw-leading,var(--ww-text-xs--line-height))}.ww\\:text-\\[10px\\]{font-size:10px}.ww\\:text-\\[11px\\]{font-size:11px}.ww\\:leading-normal{--tw-leading:var(--ww-leading-normal);line-height:var(--ww-leading-normal)}.ww\\:font-medium{--tw-font-weight:var(--ww-font-weight-medium);font-weight:var(--ww-font-weight-medium)}.ww\\:font-semibold{--tw-font-weight:var(--ww-font-weight-semibold);font-weight:var(--ww-font-weight-semibold)}.ww\\:tracking-wide{--tw-tracking:var(--ww-tracking-wide);letter-spacing:var(--ww-tracking-wide)}.ww\\:tracking-wider{--tw-tracking:var(--ww-tracking-wider);letter-spacing:var(--ww-tracking-wider)}.ww\\:tracking-widest{--tw-tracking:var(--ww-tracking-widest);letter-spacing:var(--ww-tracking-widest)}.ww\\:break-words{overflow-wrap:break-word}.ww\\:break-all{word-break:break-all}.ww\\:whitespace-pre-wrap{white-space:pre-wrap}.ww\\:text-background{color:var(--ww-color-background,#fff)}.ww\\:text-foreground,.ww\\:text-foreground\\/50{color:var(--ww-color-foreground,#1f2937)}@supports (color:color-mix(in lab, red, red)){.ww\\:text-foreground\\/50{color:color-mix(in oklab,var(--ww-color-foreground,#1f2937)50%,transparent)}}.ww\\:text-foreground\\/60{color:var(--ww-color-foreground,#1f2937)}@supports (color:color-mix(in lab, red, red)){.ww\\:text-foreground\\/60{color:color-mix(in oklab,var(--ww-color-foreground,#1f2937)60%,transparent)}}.ww\\:text-foreground\\/80{color:var(--ww-color-foreground,#1f2937)}@supports (color:color-mix(in lab, red, red)){.ww\\:text-foreground\\/80{color:color-mix(in oklab,var(--ww-color-foreground,#1f2937)80%,transparent)}}.ww\\:text-muted-foreground{color:var(--ww-color-muted-foreground,#6b7280)}.ww\\:text-primary{color:var(--ww-color-primary,#6366f1)}.ww\\:text-primary-foreground{color:var(--ww-color-primary-foreground,#1f2937)}.ww\\:text-red-400{color:var(--ww-color-red-400)}.ww\\:uppercase{text-transform:uppercase}.ww\\:opacity-0{opacity:0}.ww\\:opacity-100{opacity:1}.ww\\:shadow-sm{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a),0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ww\\:ring-2{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(2px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ww\\:ring-blue-400\\/70{--tw-ring-color:var(--ww-color-blue-400)}@supports (color:color-mix(in lab, red, red)){.ww\\:ring-blue-400\\/70{--tw-ring-color:color-mix(in oklab,var(--ww-color-blue-400)70%,transparent)}}.ww\\:ring-offset-2{--tw-ring-offset-width:2px;--tw-ring-offset-shadow:var(--tw-ring-inset,)0 0 0 var(--tw-ring-offset-width)var(--tw-ring-offset-color)}.ww\\:ring-offset-background{--tw-ring-offset-color:var(--ww-color-background,#fff)}.ww\\:transition-\\[grid-template-rows\\,opacity\\]{transition-property:grid-template-rows,opacity;transition-timing-function:var(--tw-ease,var(--ww-default-transition-timing-function));transition-duration:var(--tw-duration,var(--ww-default-transition-duration))}.ww\\:transition-all{transition-property:all;transition-timing-function:var(--tw-ease,var(--ww-default-transition-timing-function));transition-duration:var(--tw-duration,var(--ww-default-transition-duration))}.ww\\:transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--ww-default-transition-timing-function));transition-duration:var(--tw-duration,var(--ww-default-transition-duration))}.ww\\:transition-opacity{transition-property:opacity;transition-timing-function:var(--tw-ease,var(--ww-default-transition-timing-function));transition-duration:var(--tw-duration,var(--ww-default-transition-duration))}.ww\\:transition-transform{transition-property:transform,translate,scale,rotate;transition-timing-function:var(--tw-ease,var(--ww-default-transition-timing-function));transition-duration:var(--tw-duration,var(--ww-default-transition-duration))}.ww\\:duration-150{--tw-duration:.15s;transition-duration:.15s}.ww\\:duration-200{--tw-duration:.2s;transition-duration:.2s}.ww\\:duration-300{--tw-duration:.3s;transition-duration:.3s}.ww\\:ease-out{--tw-ease:var(--ww-ease-out);transition-timing-function:var(--ww-ease-out)}.ww\\:outline-none{--tw-outline-style:none;outline-style:none}@media (hover:hover){.ww\\:group-hover\\:opacity-0:is(:where(.ww\\:group):hover *){opacity:0}.ww\\:group-hover\\:opacity-100:is(:where(.ww\\:group):hover *){opacity:1}}.ww\\:group-\\[\\.is-assistant\\]\\:text-foreground:is(:where(.ww\\:group).is-assistant *){color:var(--ww-color-foreground,#1f2937)}.ww\\:group-\\[\\.is-user\\]\\:ml-auto:is(:where(.ww\\:group).is-user *){margin-left:auto}.ww\\:group-\\[\\.is-user\\]\\:rounded-lg:is(:where(.ww\\:group).is-user *){border-radius:var(--ww-radius-lg)}.ww\\:group-\\[\\.is-user\\]\\:bg-user-bubble:is(:where(.ww\\:group).is-user *){background-color:var(--ww-color-user-bubble,#f4f4f4)}.ww\\:group-\\[\\.is-user\\]\\:px-4:is(:where(.ww\\:group).is-user *){padding-inline:calc(var(--ww-spacing)*4)}.ww\\:group-\\[\\.is-user\\]\\:py-3:is(:where(.ww\\:group).is-user *){padding-block:calc(var(--ww-spacing)*3)}.ww\\:group-\\[\\.is-user\\]\\:text-primary-foreground:is(:where(.ww\\:group).is-user *){color:var(--ww-color-primary-foreground,#1f2937)}.ww\\:placeholder\\:text-muted-foreground::placeholder{color:var(--ww-color-muted-foreground,#6b7280)}@media (hover:hover){.ww\\:hover\\:border-primary\\/30:hover{border-color:var(--ww-color-primary,#6366f1)}@supports (color:color-mix(in lab, red, red)){.ww\\:hover\\:border-primary\\/30:hover{border-color:color-mix(in oklab,var(--ww-color-primary,#6366f1)30%,transparent)}}.ww\\:hover\\:bg-accent:hover{background-color:var(--ww-color-accent,#f3f4f6)}.ww\\:hover\\:bg-foreground:hover{background-color:var(--ww-color-foreground,#1f2937)}.ww\\:hover\\:bg-muted:hover{background-color:var(--ww-color-muted,#f1f5f9)}.ww\\:hover\\:bg-muted-foreground\\/10:hover{background-color:var(--ww-color-muted-foreground,#6b7280)}@supports (color:color-mix(in lab, red, red)){.ww\\:hover\\:bg-muted-foreground\\/10:hover{background-color:color-mix(in oklab,var(--ww-color-muted-foreground,#6b7280)10%,transparent)}}.ww\\:hover\\:bg-muted\\/50:hover{background-color:var(--ww-color-muted,#f1f5f9)}@supports (color:color-mix(in lab, red, red)){.ww\\:hover\\:bg-muted\\/50:hover{background-color:color-mix(in oklab,var(--ww-color-muted,#f1f5f9)50%,transparent)}}.ww\\:hover\\:bg-primary\\/90:hover{background-color:var(--ww-color-primary,#6366f1)}@supports (color:color-mix(in lab, red, red)){.ww\\:hover\\:bg-primary\\/90:hover{background-color:color-mix(in oklab,var(--ww-color-primary,#6366f1)90%,transparent)}}.ww\\:hover\\:text-accent-foreground:hover{color:var(--ww-color-accent-foreground,#1f2937)}.ww\\:hover\\:text-foreground:hover{color:var(--ww-color-foreground,#1f2937)}.ww\\:hover\\:text-red-300:hover{color:var(--ww-color-red-300)}.ww\\:hover\\:underline:hover{text-decoration-line:underline}}.ww\\:disabled\\:pointer-events-none:disabled{pointer-events:none}.ww\\:disabled\\:opacity-30:disabled{opacity:.3}.ww\\:disabled\\:opacity-40:disabled{opacity:.4}.ww\\:disabled\\:opacity-50:disabled{opacity:.5}.ww\\:\\[\\&\\>\\*\\:first-child\\]\\:mt-0>:first-child{margin-top:calc(var(--ww-spacing)*0)}.ww\\:\\[\\&\\>\\*\\:last-child\\]\\:mb-0>:last-child{margin-bottom:calc(var(--ww-spacing)*0)}}@keyframes ww-fade-in{0%{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:translateY(0)}}@keyframes ww-fade-out{0%{opacity:1;transform:translateY(0)}to{opacity:0;transform:translateY(-4px)}}@keyframes ww-pulse{0%,80%,to{opacity:.3;transform:scale(.8)}40%{opacity:1;transform:scale(1)}}[data-waniwani-chat] ::-webkit-scrollbar{width:8px}[data-waniwani-chat] ::-webkit-scrollbar-track{background:0 0}[data-waniwani-chat] ::-webkit-scrollbar-thumb{background:var(--ww-color-border);border-radius:9999px}[data-waniwani-chat] ::-webkit-scrollbar-thumb:hover{background:var(--ww-color-muted-foreground)}[data-waniwani-chat] *{scrollbar-width:thin;scrollbar-color:var(--ww-color-border)transparent}[data-waniwani-chat]{--ww-color-background:var(--ww-bg,#fff);--ww-color-foreground:var(--ww-text,#1f2937);--ww-color-primary:var(--ww-primary,#6366f1);--ww-color-primary-foreground:var(--ww-primary-fg,#1f2937);--ww-color-muted-foreground:var(--ww-muted,#6b7280);--ww-color-border:var(--ww-border,#e5e7eb);--ww-color-input:var(--ww-input-bg,#f9fafb);--ww-color-accent:var(--ww-assistant-bubble,#f3f4f6);--ww-color-accent-foreground:var(--ww-text,#1f2937);--ww-color-user-bubble:var(--ww-user-bubble,#f4f4f4);--ww-color-card:var(--ww-bg,#fff);--ww-color-card-foreground:var(--ww-text,#1f2937);--ww-color-card-header:var(--ww-header-bg,#fff);--ww-color-card-header-foreground:var(--ww-header-text,#1f2937);--ww-color-status:var(--ww-status,#22c55e);--ww-color-tool-card:var(--ww-tool-card,#f4f4f5);--ww-radius:var(--ww-radius,16px);--ww-font-sans:var(--ww-font,system-ui,-apple-system,\"Segoe UI\",sans-serif)}.dark [data-waniwani-chat],[data-waniwani-chat].dark{--ww-color-background:var(--ww-bg,#212121);--ww-color-foreground:var(--ww-text,#ececec);--ww-color-primary:var(--ww-primary,#6366f1);--ww-color-primary-foreground:var(--ww-primary-fg,#fff);--ww-color-muted-foreground:var(--ww-muted,#8e8ea0);--ww-color-border:var(--ww-border,#444);--ww-color-input:var(--ww-input-bg,#2f2f2f);--ww-color-accent:var(--ww-assistant-bubble,#2f2f2f);--ww-color-accent-foreground:var(--ww-text,#ececec);--ww-color-user-bubble:var(--ww-user-bubble,#303030);--ww-color-card:var(--ww-bg,#212121);--ww-color-card-foreground:var(--ww-text,#ececec);--ww-color-card-header:var(--ww-header-bg,#1e1e1e);--ww-color-card-header-foreground:var(--ww-header-text,#ececec);--ww-color-status:var(--ww-status,#22c55e);--ww-color-tool-card:var(--ww-tool-card,#262626)}[data-waniwani-chat] [data-streamdown=table-wrapper]{flex-direction:column;gap:.5rem;margin-top:1rem;margin-bottom:1rem;display:flex}[data-waniwani-chat] [data-streamdown=table-wrapper]>div:first-child:has(button){justify-content:flex-end;align-items:center;gap:.25rem;display:flex}[data-waniwani-chat] [data-streamdown=table-wrapper]>div:last-child{overflow-x:auto}[data-waniwani-chat] [data-streamdown=table]{border-collapse:collapse;border:1px solid var(--ww-color-border);border-radius:.75rem;width:100%;overflow:hidden}[data-waniwani-chat] [data-streamdown=table-header]{background-color:var(--ww-color-accent)}@supports (color:color-mix(in lab, red, red)){[data-waniwani-chat] [data-streamdown=table-header]{background-color:color-mix(in srgb,var(--ww-color-accent)80%,transparent)}}[data-waniwani-chat] [data-streamdown=table-body]{background-color:var(--ww-color-accent)}@supports (color:color-mix(in lab, red, red)){[data-waniwani-chat] [data-streamdown=table-body]{background-color:color-mix(in srgb,var(--ww-color-accent)40%,transparent)}}[data-waniwani-chat] [data-streamdown=table-body]>tr+tr{border-top:1px solid var(--ww-color-border)}[data-waniwani-chat] [data-streamdown=table-row]{border-bottom:1px solid var(--ww-color-border)}[data-waniwani-chat] [data-streamdown=table-header-cell]{white-space:nowrap;text-align:left;padding:.5rem 1rem;font-size:.875rem;font-weight:600}[data-waniwani-chat] [data-streamdown=table-cell]{padding:.5rem 1rem;font-size:.875rem}[data-waniwani-chat] [data-streamdown=link]{color:var(--ww-color-primary);overflow-wrap:anywhere;cursor:pointer;font-weight:500;text-decoration:underline}[data-waniwani-chat] [data-streamdown=link-safety-modal]{z-index:50;background-color:var(--ww-color-background);justify-content:center;align-items:center;display:flex;position:fixed;inset:0}@supports (color:color-mix(in lab, red, red)){[data-waniwani-chat] [data-streamdown=link-safety-modal]{background-color:color-mix(in srgb,var(--ww-color-background)50%,transparent)}}[data-waniwani-chat] [data-streamdown=link-safety-modal]{-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px)}[data-waniwani-chat] [data-streamdown=link-safety-modal]>div{border:1px solid var(--ww-color-border);background-color:var(--ww-color-background);width:100%;max-width:28rem;color:var(--ww-color-foreground);border-radius:.75rem;flex-direction:column;gap:1rem;margin:0 1rem;padding:1.5rem;display:flex;position:relative;box-shadow:0 10px 25px #0000001a}[data-waniwani-chat] [data-streamdown=link-safety-modal] button{cursor:pointer}[data-waniwani-chat] [data-streamdown=link-safety-modal]>div>button:first-child{color:var(--ww-color-muted-foreground);background:0 0;border:none;border-radius:.375rem;padding:.25rem;transition:background-color .15s,color .15s;position:absolute;top:1rem;right:1rem}[data-waniwani-chat] [data-streamdown=link-safety-modal]>div>button:first-child:hover{background-color:var(--ww-color-accent);color:var(--ww-color-foreground)}[data-waniwani-chat] [data-streamdown=link-safety-modal]>div>div:first-of-type{flex-direction:column;gap:.5rem;display:flex}[data-waniwani-chat] [data-streamdown=link-safety-modal]>div>div:first-of-type>div{align-items:center;gap:.5rem;font-size:1.125rem;font-weight:600;display:flex}[data-waniwani-chat] [data-streamdown=link-safety-modal]>div>div:first-of-type>p{color:var(--ww-color-muted-foreground);font-size:.875rem}[data-waniwani-chat] [data-streamdown=link-safety-modal]>div>div:nth-child(3){word-break:break-all;background-color:var(--ww-color-accent);border-radius:.375rem;max-height:8rem;padding:.75rem;font-family:ui-monospace,monospace;font-size:.875rem;overflow-y:auto}[data-waniwani-chat] [data-streamdown=link-safety-modal]>div>div:last-child{gap:.5rem;display:flex}[data-waniwani-chat] [data-streamdown=link-safety-modal]>div>div:last-child>button{border:none;border-radius:.375rem;flex:1;justify-content:center;align-items:center;gap:.5rem;padding:.5rem 1rem;font-size:.875rem;font-weight:500;transition:background-color .15s;display:flex}[data-waniwani-chat] [data-streamdown=link-safety-modal]>div>div:last-child>button:first-child{border:1px solid var(--ww-color-border);background-color:var(--ww-color-background);color:var(--ww-color-foreground)}[data-waniwani-chat] [data-streamdown=link-safety-modal]>div>div:last-child>button:first-child:hover{background-color:var(--ww-color-accent)}[data-waniwani-chat] [data-streamdown=link-safety-modal]>div>div:last-child>button:last-child{background-color:var(--ww-color-primary);color:#fff}[data-waniwani-chat] [data-streamdown=link-safety-modal]>div>div:last-child>button:last-child:hover{opacity:.9}[data-waniwani-chat] [data-streamdown=ordered-list]{white-space:normal;list-style-type:decimal;list-style-position:inside}[data-waniwani-chat] li [data-streamdown=ordered-list]{padding-left:1.5rem}[data-waniwani-chat] [data-streamdown=unordered-list]{white-space:normal;list-style-type:disc;list-style-position:inside}[data-waniwani-chat] li [data-streamdown=unordered-list]{padding-left:1.5rem}[data-waniwani-chat] [data-streamdown=list-item]{padding-top:.25rem;padding-bottom:.25rem}[data-waniwani-chat] [data-streamdown=list-item]>p{display:inline}[data-waniwani-chat] [data-streamdown=inline-code]{background-color:var(--ww-color-accent);border-radius:.25rem;padding:.125rem .375rem;font-family:ui-monospace,SFMono-Regular,SF Mono,Menlo,monospace;font-size:.875rem}[data-waniwani-chat] [data-streamdown=heading-1]{margin-top:1.5rem;margin-bottom:.5rem;font-size:1.875rem;font-weight:600;line-height:2.25rem}[data-waniwani-chat] [data-streamdown=heading-2]{margin-top:1.5rem;margin-bottom:.5rem;font-size:1.5rem;font-weight:600;line-height:2rem}[data-waniwani-chat] [data-streamdown=heading-3]{margin-top:1.5rem;margin-bottom:.5rem;font-size:1.25rem;font-weight:600;line-height:1.75rem}[data-waniwani-chat] [data-streamdown=heading-4]{margin-top:1.5rem;margin-bottom:.5rem;font-size:1.125rem;font-weight:600;line-height:1.75rem}[data-waniwani-chat] [data-streamdown=heading-5]{margin-top:1.5rem;margin-bottom:.5rem;font-size:1rem;font-weight:600;line-height:1.5rem}[data-waniwani-chat] [data-streamdown=heading-6]{margin-top:1.5rem;margin-bottom:.5rem;font-size:.875rem;font-weight:600;line-height:1.25rem}[data-waniwani-chat] [data-streamdown=blockquote]{border-left:4px solid var(--ww-color-muted-foreground);margin-top:1rem;margin-bottom:1rem}@supports (color:color-mix(in lab, red, red)){[data-waniwani-chat] [data-streamdown=blockquote]{border-left:4px solid color-mix(in srgb,var(--ww-color-muted-foreground)30%,transparent)}}[data-waniwani-chat] [data-streamdown=blockquote]{color:var(--ww-color-muted-foreground);padding-left:1rem;font-style:italic}[data-waniwani-chat] [data-streamdown=horizontal-rule]{border-color:var(--ww-color-border);margin-top:1.5rem;margin-bottom:1.5rem}[data-waniwani-chat] [data-streamdown=strong]{font-weight:600}[data-waniwani-chat] [data-streamdown=image-wrapper]{margin-top:1rem;margin-bottom:1rem;display:inline-block;position:relative}[data-waniwani-chat] [data-streamdown=image]{border-radius:.5rem;max-width:100%}[data-waniwani-chat] [data-streamdown=code-block]{border:1px solid var(--ww-color-border);border-radius:.75rem;width:100%;margin-top:1rem;margin-bottom:1rem;overflow:hidden}[data-waniwani-chat] [data-streamdown=code-block-header]{background-color:var(--ww-color-accent);justify-content:space-between;align-items:center;display:flex}@supports (color:color-mix(in lab, red, red)){[data-waniwani-chat] [data-streamdown=code-block-header]{background-color:color-mix(in srgb,var(--ww-color-accent)80%,transparent)}}[data-waniwani-chat] [data-streamdown=code-block-header]{color:var(--ww-color-muted-foreground);padding:.75rem;font-size:.75rem}[data-waniwani-chat] [data-streamdown=code-block-body]{padding:1rem;font-size:.875rem;overflow-x:auto}[data-waniwani-chat] [data-streamdown=code-block-copy-button],[data-waniwani-chat] [data-streamdown=code-block-download-button]{cursor:pointer;color:var(--ww-color-muted-foreground);background:0 0;border:none;padding:.25rem;transition:color .15s}[data-waniwani-chat] [data-streamdown=code-block-copy-button]:hover,[data-waniwani-chat] [data-streamdown=code-block-download-button]:hover{color:var(--ww-color-foreground)}[data-waniwani-chat] [data-streamdown=mermaid-block]{border:1px solid var(--ww-color-border);border-radius:.75rem;height:auto;margin-top:1rem;margin-bottom:1rem;padding:1rem;position:relative}[data-waniwani-chat] [data-streamdown=mermaid]{width:100%;height:100%}@property --tw-translate-x{syntax:\"*\";inherits:false;initial-value:0}@property --tw-translate-y{syntax:\"*\";inherits:false;initial-value:0}@property --tw-translate-z{syntax:\"*\";inherits:false;initial-value:0}@property --tw-space-y-reverse{syntax:\"*\";inherits:false;initial-value:0}@property --tw-border-style{syntax:\"*\";inherits:false;initial-value:solid}@property --tw-leading{syntax:\"*\";inherits:false}@property --tw-font-weight{syntax:\"*\";inherits:false}@property --tw-tracking{syntax:\"*\";inherits:false}@property --tw-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:\"*\";inherits:false}@property --tw-shadow-alpha{syntax:\"<percentage>\";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:\"*\";inherits:false}@property --tw-inset-shadow-alpha{syntax:\"<percentage>\";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:\"*\";inherits:false}@property --tw-ring-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:\"*\";inherits:false}@property --tw-inset-ring-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:\"*\";inherits:false}@property --tw-ring-offset-width{syntax:\"<length>\";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:\"*\";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}@property --tw-duration{syntax:\"*\";inherits:false}@property --tw-ease{syntax:\"*\";inherits:false}@keyframes spin{to{transform:rotate(360deg)}}@keyframes pulse{50%{opacity:.5}}",Ba=null,Or=null,oa=null;function _2(e,t){if(yx&&yx!=="__WANIWANI_EMBED_CSS__"){let a=document.createElement("style");a.textContent=yx,e.appendChild(a)}if(t.css)try{let a=new URL(t.css,window.location.href);if(a.protocol==="https:"||a.protocol==="http:"){let n=document.createElement("link");n.rel="stylesheet",n.href=a.href,e.appendChild(n)}else console.warn("[WaniWani] Custom CSS URL must use http or https protocol.")}catch{console.warn("[WaniWani] Invalid custom CSS URL:",t.css)}}var R2="data-waniwani-embed";function v6(e,t,a){let n=document.querySelector(`[${R2}]`);if(!n)throw new Error(`[WaniWani] No inline mount target. Place \`<div ${R2}></div>\` in your page for \`mode: "inline"\`.`);oa=document.createElement("div"),oa.id="waniwani-chat-embed",oa.style.width="100%",oa.style.height="100%",n.appendChild(oa);let r=oa.attachShadow({mode:"open"});_2(r,e);let o=document.createElement("div");o.style.width="100%",o.style.height="100%",r.appendChild(o);let l=au.default.createRef();return Or=xx.default.createRoot(o),Or.render(au.default.createElement(E2,{ref:l,config:e,programmatic:t,scriptConfig:a})),{destroy:()=>{Or?.unmount(),Or=null,oa?.remove(),oa=null,Ba=null},open:()=>{},close:()=>{},toggle:()=>{},sendMessage:i=>l.current?.chat?.sendMessage(i)}}function w6(e,t){let a=t.position==="bottom-left",n=t.theme?.primaryColor??"#6366f1",r=document.createElement("div");r.setAttribute("data-waniwani-skeleton","");let o=document.createElement("style");o.textContent=`
138
+ `);a=i.pop()??"";for(let s of i){let u=s.trim();if(!u.startsWith("data:"))continue;let c=u.slice(5).trim();if(c!=="[DONE]")try{let d=JSON.parse(c);if(!r){l.enqueue(d);continue}let f=await r(d);if(f.success){l.enqueue(f.value);continue}let p=JF(f.error);if(p?.length){let y={...d};for(let S of p)delete y[S];let v=await r(y);v.success&&l.enqueue(v.value)}}catch{}}}}))}};var b2="waniwani-visitor-id";function S2(e,t){return e.match(t)?.[1]??null}function e6(e){let t=[["Edge",/Edg(?:e|A|iOS)?\/(\S+)/],["Opera",/(?:OPR|Opera)\/(\S+)/],["Samsung Internet",/SamsungBrowser\/(\S+)/],["Firefox",/Firefox\/(\S+)/],["Chrome",/Chrome\/(\S+)/],["Safari",/Version\/(\S+).*Safari/]];for(let[a,n]of t){let r=S2(e,n);if(r)return{name:a,version:r}}return null}function t6(e){let t=[["iOS",/(?:iPhone|iPad|iPod).+?OS (\d+[_.\d]*)/],["Android",/Android (\d+[.\d]*)/],["macOS",/Mac OS X (\d+[_.\d]*)/],["Windows",/Windows NT (\d+[.\d]*)/],["ChromeOS",/CrOS \S+ (\d+[.\d]*)/],["Linux",/Linux/]];for(let[a,n]of t){let r=S2(e,n);if(r)return{name:a,version:r.replace(/_/g,".")};if(a==="Linux"&&n.test(e))return{name:a,version:""}}return null}function a6(e){return typeof navigator<"u"&&"userAgentData"in navigator&&navigator.userAgentData?.mobile?"mobile":/iPad|tablet|PlayBook/i.test(e)?"tablet":/Mobi|Android.*Mobile|iPhone|iPod/i.test(e)?"mobile":"desktop"}async function n6(e){let t=new TextEncoder().encode(e),a=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(a)).map(n=>n.toString(16).padStart(2,"0")).join("")}async function r6(){try{let a=localStorage.getItem(b2);if(a)return a}catch{}let e=[navigator.userAgent,screen.width,screen.height,screen.colorDepth,Intl.DateTimeFormat().resolvedOptions().timeZone,navigator.language,navigator.hardwareConcurrency??"",navigator.platform??""].join("|"),t=await n6(e);try{localStorage.setItem(b2,t)}catch{}return t}async function C2(){let e=navigator.userAgent,t=await r6();return{userAgent:e,browser:e6(e),os:t6(e),deviceType:a6(e),language:navigator.language,languages:[...navigator.languages],timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,screenWidth:screen.width,screenHeight:screen.height,viewportWidth:window.innerWidth,viewportHeight:window.innerHeight,colorDepth:screen.colorDepth,devicePixelRatio:window.devicePixelRatio??1,touchSupport:"ontouchstart"in window||navigator.maxTouchPoints>0,connectionType:navigator.connection?.effectiveType??"unknown",referrer:document.referrer,visitorId:t}}var o6="x-session-id";function I2(e){if(typeof e!="string")return;let t=e.trim();return t.length>0?t:void 0}async function l6(e,t){let a=`${e.replace(/\/$/,"")}/tools`,n=await fetch(a,{method:"GET",headers:t?{...t}:void 0});if(!n.ok)throw new Error(`[WaniWani] Failed to fetch /tools: ${n.status} ${n.statusText}`);let r=await n.json();if(!r||!Array.isArray(r.tools))return{};let o={};for(let l of r.tools)l&&typeof l.name=="string"&&(o[l.name]=l);return o}function Zl(e){let{api:t="/api/waniwani",headers:a,body:n,onMessageSent:r,onResponseReceived:o}=e,l=(0,be.useRef)(a),i=(0,be.useRef)(n),s=(0,be.useRef)(void 0),u=(0,be.useRef)(null),[c,d]=(0,be.useState)(void 0),f=(0,be.useRef)(c),p=(0,be.useCallback)(()=>f.current,[]),y=(0,be.useCallback)(G=>{let Q=I2(G);Q&&f.current!==Q&&(f.current=Q,d(Q))},[]),v=(0,be.useCallback)(()=>{f.current=void 0,d(void 0)},[]);(0,be.useEffect)(()=>{l.current=a},[a]),(0,be.useEffect)(()=>{i.current=n},[n]),(0,be.useEffect)(()=>{C2().then(G=>{u.current=G}).catch(()=>{})},[]);let S=(0,be.useRef)(new wf({api:t,headers:()=>({...l.current}),body:()=>{let G={...i.current??{}},Q=Object.hasOwn(G,"sessionId"),ke=I2(G.sessionId);if(ke)y(ke),G.sessionId=ke;else if(Q)v(),delete G.sessionId;else{let se=p();se&&(G.sessionId=se)}if(Fl(s.current)&&(G.modelContext=s.current),u.current){let se=u.current;G.visitorContext={timezone:se.timezone,language:se.language,languages:se.languages,deviceType:se.deviceType,referrer:se.referrer,visitorId:se.visitorId}}return G},fetch:(async(G,Q)=>{let ke=await fetch(G,Q);return s.current=void 0,y(ke.headers.get(o6)),ke})})),g=(0,be.useRef)(null),x=(0,be.useRef)(null),m=(0,be.useRef)({}),[w,L]=(0,be.useState)(0),b=e.skipRemoteConfig===!0,A=(0,be.useCallback)(async()=>{if(!b)try{let G=await l6(t,l.current);m.current=G,L(Q=>Q+1)}catch(G){console.warn("[WaniWani] Failed to fetch tool definitions:",G instanceof Error?G.message:G)}},[t,b]);(0,be.useEffect)(()=>{A()},[A]);let{messages:R,sendMessage:_,setMessages:T,status:D}=w2({messages:e.initialMessages,transport:S.current,onFinish({message:G}){o?.(),g.current&&(x.current=G)},onError(G){console.warn("[WaniWani] Chat error:",G.message),g.current&&(g.current.reject(G),g.current=null)}});(0,be.useEffect)(()=>{if(D==="ready"&&g.current&&x.current){let G=g.current,Q=x.current;g.current=null,x.current=null,G.resolve(Q)}},[D]);let[N,B]=(0,be.useState)(""),[j,V]=(0,be.useState)([]),F=D==="submitted"||D==="streaming",te=(0,be.useCallback)(G=>{V(Q=>Q.filter(ke=>ke.id!==G))},[]),$e=F&&j.length>0,Z=(0,be.useCallback)(G=>{let Q=!!G.text?.trim(),ke=!!G.files?.length;if(Q||ke){if(F){if(j.length>0)return;V(se=>[...se,{id:jc(),text:G.text||"",files:G.files??[],modelContext:G.modelContext}]),B("");return}s.current=G.modelContext,_({text:G.text||"",files:G.files}),r?.(G.text||""),B("")}},[_,r,F,j.length]),C=(0,be.useCallback)(G=>new Promise((Q,ke)=>{g.current={resolve:Q,reject:ke},_({text:G}),r?.(G)}),[_,r]);(0,be.useEffect)(()=>{if(D!=="ready"||j.length===0)return;let[G,...Q]=j;V(Q),s.current=G.modelContext,_({text:G.text,files:G.files.length>0?G.files:void 0}),r?.(G.text)},[D,_,r,j]);let Xe=(0,be.useCallback)(()=>{T([]),V([]),v(),B(""),m.current={},L(G=>G+1),A()},[T,v,A]),le=(0,be.useCallback)(G=>{B(G.target.value)},[]),k=R[R.length-1],Ze=R.length>0,Ue=F&&(!Ze||k.role==="user"),Hn=m.current;return{messages:R,status:D,text:N,setText:B,handleSubmit:Z,handleTextChange:le,isLoading:F,showLoaderBubble:Ue,lastMessage:k,hasMessages:Ze,sendMessage:_,sendMessageAndWait:C,reset:Xe,queuedMessages:j,queueFull:$e,removeQueuedMessage:te,sessionId:c,toolDefinitions:Hn,refreshToolDefinitions:A}}var ko=q(xe(),1),i6={debug:!1,eval:!1};function bf(e="/api/waniwani",t,a=!1){let[n,r]=(0,ko.useState)(i6),o=(0,ko.useRef)(t);return(0,ko.useEffect)(()=>{o.current=t},[t]),(0,ko.useEffect)(()=>{a||(async()=>{try{let l=o.current,s=await(await fetch(`${e}/config`,{headers:l?{...l}:void 0})).json();r({debug:s.debug===!0,eval:s.eval===!0})}catch{}})()},[e,a]),n}var sn=q(xe(),1);function s6(e){for(let t of e.parts){let a=t;if(a.type==="data"||a.type==="data-suggestions"){let n=a.data;if(n&&Array.isArray(n.suggestions))return n.suggestions}}return null}function L2(e){return typeof e=="object"&&e!==null&&"initial"in e}function Ql(e){let{messages:t,status:a,config:n}=e,r=L2(n)&&n.initial?n.initial:void 0,[o,l]=(0,sn.useState)(r??[]),i=(0,sn.useRef)(a),s=n===!0||L2(n)&&n.dynamic!==!1,u=(0,sn.useCallback)(()=>{l([])},[]),c=t.length>0;(0,sn.useEffect)(()=>{!c&&r&&r.length>0&&l(r)},[r,c]);let d=t[t.length-1];return(0,sn.useEffect)(()=>{d?.role==="user"&&u()},[d,u]),(0,sn.useEffect)(()=>{let f=i.current;if(i.current=a,f==="streaming"&&a==="ready"&&s){let p=[...t].reverse().find(v=>v.role==="assistant");if(!p)return;let y=s6(p);y&&l(y)}},[a,s,t]),{suggestions:o,isLoading:!1,clear:u}}var Kl=q(xe(),1),u6=50,c6=30,d6=2e3,k2=500;function Yl(e,t=!0){let[a,n]=(0,Kl.useState)(""),r=(0,Kl.useRef)(void 0);return(0,Kl.useEffect)(()=>{if(!t){n("");return}let o=0,l=!1,i=!1,s=()=>{i||(l?(o--,n(e.slice(0,o)),o<=0?(l=!1,r.current=setTimeout(s,k2)):r.current=setTimeout(s,c6)):(o++,n(e.slice(0,o)),o>=e.length?(l=!0,r.current=setTimeout(s,d6)):r.current=setTimeout(s,u6)))};return r.current=setTimeout(s,k2),()=>{i=!0,clearTimeout(r.current)}},[e,t]),a}function Sf(e,t){let a=t?.Authorization,n=typeof a=="string"&&a.startsWith("Bearer ")?a.slice(7):null;return n?`${e}/resource?token=${encodeURIComponent(n)}`:`${e}/resource`}var f6={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"};var p6={primaryColor:["--ww-primary","--ww-color-primary"],primaryForeground:["--ww-primary-fg","--ww-color-primary-foreground"],backgroundColor:["--ww-bg","--ww-color-background"],textColor:["--ww-text","--ww-color-foreground","--ww-color-accent-foreground"],mutedColor:["--ww-muted","--ww-color-muted-foreground"],borderColor:["--ww-border","--ww-color-border"],assistantBubbleColor:["--ww-assistant-bubble","--ww-color-accent"],userBubbleColor:["--ww-user-bubble"],inputBackgroundColor:["--ww-input-bg","--ww-color-input"],borderRadius:["--ww-radius"],messageBorderRadius:["--ww-msg-radius"],fontFamily:["--ww-font"],headerBackgroundColor:["--ww-header-bg"],headerTextColor:["--ww-header-text"],statusColor:["--ww-status"],toolCardColor:["--ww-tool-card","--ww-color-tool-card"]};function Jl(e){return{...f6,...e}}function ei(e){let t=e.backgroundColor.replace("#",""),a=parseInt(t.substring(0,2),16),n=parseInt(t.substring(2,4),16),r=parseInt(t.substring(4,6),16);return(a*299+n*587+r*114)/1e3<128}function ti(e){let t={};for(let[a,n]of Object.entries(p6)){let r=e[a],o=typeof r=="number"?`${r}px`:String(r);for(let l of n)t[l]=o}return t}var rt=q(ee(),1),Cf=(0,Ut.forwardRef)(function(t,a){let{theme:n,title:r="Assistant",width:o,height:l,className:i,allowAttachments:s=!1,welcomeMessage:u,welcome:c,placeholder:d="Ask me anything...",triggerEvent:f="triggerDemoRequest",api:p,debug:y}=t,v=p??"/api/waniwani",S=Sf(v,t.headers),g=Jl(n),x=ti(g),m=ei(g),w=bf(v,t.headers,t.skipRemoteConfig),L=y??w.debug,b=Zl({...t,api:v}),A=Vl({...t,api:v,sessionId:b.sessionId}),R=Yl(d,!b.text),[_,T]=(0,Ut.useState)(!1),[D,N]=(0,Ut.useState)(null),B=(0,Ut.useRef)(null),j=(0,Ut.useRef)(void 0),V=(0,Ut.useCallback)(()=>{let Z=B.current;if(!Z)return;Z.scrollIntoView({behavior:"smooth",block:"center"});let C=Z.querySelector("textarea");C&&setTimeout(()=>C.focus(),300),T(!0),clearTimeout(j.current),j.current=setTimeout(()=>T(!1),2e3)},[]),F=Ql({messages:b.messages,status:b.status,config:t.suggestions}),te=(0,Ut.useCallback)(Z=>{let C=Z.content.map(Xe=>Xe.text??"").join("").trim();C&&b.handleSubmit({text:C,files:[],modelContext:Z.modelContext})},[b.handleSubmit]),$e=(0,Ut.useCallback)(Z=>{F.clear(),b.handleSubmit({text:Z,files:[]})},[F.clear,b.handleSubmit]);return(0,Ut.useImperativeHandle)(a,()=>({sendMessage:Z=>{b.handleSubmit({text:Z,files:[]}),V()},sendMessageAndWait:Z=>b.sendMessageAndWait(Z),reset:b.reset,focus:V,get messages(){return b.messages}}),[b.handleSubmit,b.sendMessageAndWait,b.reset,b.messages,V]),(0,Ut.useEffect)(()=>{if(!f)return;let Z=C=>{let Xe=C.detail,le=typeof Xe?.message=="string"?Xe.message:void 0;le&&b.handleSubmit({text:le,files:[]}),V()};return window.addEventListener(f,Z),()=>window.removeEventListener(f,Z)},[f,b.handleSubmit,V]),(0,rt.jsxs)("div",{ref:B,style:{...x,width:o,height:l},"data-waniwani-chat":"","data-waniwani-layout":"card",...m?{"data-waniwani-dark":""}:{},className:$("ww:flex ww:flex-col ww:font-[family-name:var(--ww-font)] ww:text-foreground ww:bg-background ww:rounded-[var(--ww-radius)] ww:overflow-hidden",_&&"ww:ring-2 ww:ring-blue-400/70 ww:ring-offset-2 ww:ring-offset-background",i),children:[(0,rt.jsxs)("div",{className:"ww:shrink-0 ww:flex ww:items-center ww:px-6 ww:py-3",style:{backgroundColor:g.headerBackgroundColor,color:g.headerTextColor},children:[(0,rt.jsx)("div",{className:"ww:text-sm ww:font-semibold ww:truncate",children:r}),(0,rt.jsx)(Gc,{messages:b.messages,evalEnabled:w.eval,api:v})]}),(0,rt.jsxs)(Sl,{className:"ww:flex-1 ww:min-h-0 ww:bg-background",children:[(0,rt.jsx)(Cl,{scrollClassName:D?"ww:!relative ww:!overflow-hidden":void 0,children:(0,rt.jsx)(Hl,{messages:b.messages,status:b.status,welcomeMessage:u,welcome:c,onSuggestionSelect:$e,resourceEndpoint:S,chatSessionId:b.sessionId,isDark:m,onFollowUp:te,onCallTool:A,fullscreenToolCallId:D,debug:L,toolDefinitions:b.toolDefinitions,onWidgetDisplayModeChange:(Z,C)=>{N(Z==="fullscreen"?C.toolCallId:null)}})}),(0,rt.jsx)(Il,{})]}),(0,rt.jsx)("div",{style:D?{display:"none"}:void 0,children:(0,rt.jsx)(jl,{suggestions:F.suggestions,isLoading:F.isLoading,onSelect:$e})}),(0,rt.jsx)("div",{style:D?{display:"none"}:void 0,children:(0,rt.jsx)(Al,{queuedMessages:b.queuedMessages,onRemove:b.removeQueuedMessage})}),(0,rt.jsx)("div",{style:D?{display:"none"}:void 0,children:(0,rt.jsx)("div",{className:"ww:shrink-0 ww:px-4 ww:pb-8 ww:pt-2 ww:bg-background",children:(0,rt.jsx)("div",{className:"ww:mx-auto ww:w-full ww:max-w-3xl",children:(0,rt.jsx)(Ll,{onSubmit:b.handleSubmit,globalDrop:s,multiple:s,className:"ww:rounded-2xl ww:border-border ww:bg-input",children:(0,rt.jsxs)("div",{className:"ww:flex ww:items-center ww:gap-1 ww:pl-4 ww:pr-3 ww:py-2.5",children:[s&&(0,rt.jsx)(Ml,{}),(0,rt.jsx)(kl,{onChange:b.handleTextChange,value:b.text,placeholder:R,className:"ww:min-h-0 ww:py-1 ww:px-0"}),(0,rt.jsx)(Tl,{status:b.status,disabled:b.queueFull})]})})})})})]})});var If=q(xe(),1);async function m6(e,t,a){try{let n=`${e.replace(/\/$/,"")}/config`,r=await fetch(n,{method:"GET",headers:{Authorization:`Bearer ${t}`},signal:a});if(!r.ok)return{};let o=await r.json(),l=o&&typeof o=="object"&&"data"in o&&o.data?o.data:o;return l?h6(l):{}}catch{return{}}}function h6(e){let t={};return e.title!=null&&(t.title=e.title),e.welcomeMessage!=null&&(t.welcomeMessage=e.welcomeMessage),e.placeholder!=null&&(t.placeholder=e.placeholder),e.suggestions!=null&&e.suggestions.length>0&&(t.suggestions=e.suggestions),t}function Lf(e,t,a){let[n,r]=(0,If.useState)(e);return(0,If.useEffect)(()=>{let o=e.api,l=e.token;if(!o||!l)return;let i=new AbortController;return m6(o,l,i.signal).then(s=>{if(!i.signal.aborted&&Object.keys(s).length!==0)try{r(Nc(t,s,a))}catch(u){console.error("[WaniWani] Failed to apply remote config:",u)}}).catch(s=>{console.error("[WaniWani] Remote config fetch failed:",s)}),()=>i.abort()},[e.api,e.token]),n}var Tt=q(ee(),1);function g6(){return(0,Tt.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",role:"img","aria-label":"Chat",children:[(0,Tt.jsx)("title",{children:"Chat"}),(0,Tt.jsx)("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})]})}function y6(){return(0,Tt.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",role:"img","aria-label":"Close",children:[(0,Tt.jsx)("title",{children:"Close"}),(0,Tt.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,Tt.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}var hx=56,gx=20,x6=12,To=200,T2=(0,ct.forwardRef)(function({config:t,programmatic:a,scriptConfig:n,onReady:r},o){let l=Lf(t,a,n),[i,s]=(0,ct.useState)(!1),[u,c]=(0,ct.useState)(0),[d,f]=(0,ct.useState)(!1),p=(0,ct.useRef)(null),y=(0,ct.useRef)(i);y.current=i,(0,ct.useEffect)(()=>{r?.()},[]),(0,ct.useEffect)(()=>{let F=window.matchMedia("(max-width: 768px)"),te=$e=>f($e.matches);return te(F),F.addEventListener("change",te),()=>F.removeEventListener("change",te)},[]),(0,ct.useEffect)(()=>{if(!i)return;let F=te=>{te.key==="Escape"&&s(!1)};return document.addEventListener("keydown",F),()=>document.removeEventListener("keydown",F)},[i]),(0,ct.useEffect)(()=>{i&&c(0)},[i]);let v=(0,ct.useCallback)(()=>{y.current||c(F=>F+1)},[]),S=(0,ct.useCallback)(()=>s(!0),[]),g=(0,ct.useCallback)(()=>s(!1),[]),x=(0,ct.useCallback)(()=>s(F=>!F),[]);(0,ct.useImperativeHandle)(o,()=>({open:S,close:g,toggle:x,get chat(){return p.current}}));let m=!i&&u>0,w=l.mode==="custom",L=l.position==="bottom-left",b=l.width??400,A=l.height??600,R=l.theme?.primaryColor??"#6366f1",_={position:"fixed",bottom:gx,...L?{left:gx}:{right:gx},zIndex:2147483647,fontFamily:l.theme?.fontFamily??"system-ui, -apple-system, 'Segoe UI', sans-serif"},T={width:hx,height:hx,borderRadius:"50%",backgroundColor:R,color:"#ffffff",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)",transition:`transform ${To}ms ease, box-shadow ${To}ms ease`,outline:"none"},D=d?{position:"fixed",inset:0,zIndex:2147483647,transition:`transform ${To}ms ease, opacity ${To}ms ease`,...i?{transform:"translateY(0) scale(1)",opacity:1}:{transform:"translateY(20px) scale(0.95)",opacity:0,pointerEvents:"none"}}:{position:"absolute",bottom:w?0:hx+x6,...L?{left:0}:{right:0},width:b,height:A,transition:`transform ${To}ms ease, opacity ${To}ms ease`,...i?{transform:"translateY(0) scale(1)",opacity:1}:{transform:"translateY(20px) scale(0.95)",opacity:0,pointerEvents:"none"}},N={width:"100%",height:"100%",borderRadius:d?0:12,overflow:"hidden",boxShadow:d?"none":"0 8px 32px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.08)"},B={position:"absolute",top:d?12:8,right:d?12:8,zIndex:10,width:d?36:28,height:d?36:28,borderRadius:"50%",backgroundColor:"rgba(0, 0, 0, 0.06)",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",color:"inherit",outline:"none",transition:`background-color ${To}ms ease`},j={position:"absolute",top:-2,right:-2,width:12,height:12,borderRadius:"50%",backgroundColor:"#ef4444",border:"2px solid #ffffff"},V=Bc(l);return(0,Tt.jsxs)("div",{style:_,children:[(0,Tt.jsx)("div",{style:D,role:"dialog","aria-label":"Chat panel",children:(0,Tt.jsxs)("div",{style:{...N,position:"relative"},children:[(0,Tt.jsx)("button",{type:"button",onClick:g,style:B,"aria-label":"Close chat",onMouseEnter:F=>{F.currentTarget.style.backgroundColor="rgba(0, 0, 0, 0.12)"},onMouseLeave:F=>{F.currentTarget.style.backgroundColor="rgba(0, 0, 0, 0.06)"},children:(0,Tt.jsx)(y6,{})}),(0,Tt.jsx)(Cf,{ref:p,api:l.api,headers:{Authorization:`Bearer ${l.token}`},skipRemoteConfig:!0,body:l.mcpServerUrl?{mcpServerUrl:l.mcpServerUrl}:void 0,theme:V,title:l.title??"Assistant",welcomeMessage:l.welcomeMessage,placeholder:l.placeholder,suggestions:l.suggestions?{initial:l.suggestions}:void 0,onResponseReceived:v,width:"100%",height:"100%"})]})}),!w&&(0,Tt.jsxs)("button",{type:"button",onClick:x,style:{...T,position:"relative"},"aria-label":i?"Close chat":"Open chat",onMouseEnter:F=>{F.currentTarget.style.transform="scale(1.08)",F.currentTarget.style.boxShadow="0 6px 20px rgba(0, 0, 0, 0.2)"},onMouseLeave:F=>{F.currentTarget.style.transform="scale(1)",F.currentTarget.style.boxShadow="0 4px 12px rgba(0, 0, 0, 0.15)"},children:[(0,Tt.jsx)(g6,{}),m&&(0,Tt.jsx)("span",{style:j})]})]})});var _r=q(xe(),1);var wt=q(xe(),1);var dt=q(ee(),1),M2=(0,wt.forwardRef)(function(t,a){let{theme:n,title:r="Assistant",width:o=600,expandedWidth:l,expandedHeight:i=400,allowAttachments:s=!1,welcomeMessage:u,welcome:c,placeholder:d="Ask me anything...",triggerEvent:f="triggerDemoRequest",api:p}=t,y=l??Math.round((typeof o=="number"?o:600)*1.2),v=p??"/api/waniwani",S=Sf(v,t.headers),g=Jl(n),x=ti(g),m=ei(g),w=bf(p,t.headers,t.skipRemoteConfig),L=Zl(t),b=Vl({...t,sessionId:L.sessionId}),A=Ql({messages:L.messages,status:L.status,config:t.suggestions}),R=(0,wt.useCallback)(le=>{let k=le.content.map(Ze=>Ze.text??"").join("").trim();k&&L.handleSubmit({text:k,files:[],modelContext:le.modelContext})},[L.handleSubmit]),_=(0,wt.useCallback)(le=>{A.clear(),L.handleSubmit({text:le,files:[]})},[A.clear,L.handleSubmit]),T=Yl(d,!L.text),[D,N]=(0,wt.useState)(!1),[B,j]=(0,wt.useState)(!1),[V,F]=(0,wt.useState)(null),te=(0,wt.useRef)(null),$e=(0,wt.useRef)(void 0),Z=(0,wt.useCallback)(()=>{let le=te.current;if(!le)return;le.scrollIntoView({behavior:"smooth",block:"center"});let k=le.querySelector("textarea");k&&setTimeout(()=>k.focus(),300),N(!0),j(!0),clearTimeout($e.current),$e.current=setTimeout(()=>j(!1),2e3)},[]);(0,wt.useImperativeHandle)(a,()=>({sendMessage:le=>{L.handleSubmit({text:le,files:[]}),Z()},sendMessageAndWait:le=>L.sendMessageAndWait(le),reset:L.reset,focus:Z,get messages(){return L.messages}}),[L.handleSubmit,L.sendMessageAndWait,L.reset,L.messages,Z]),(0,wt.useEffect)(()=>{if(!f)return;let le=k=>{let Ze=k.detail,Ue=typeof Ze?.message=="string"?Ze.message:void 0;Ue&&L.handleSubmit({text:Ue,files:[]}),Z()};return window.addEventListener(f,le),()=>window.removeEventListener(f,le)},[f,L.handleSubmit,Z]);let C=D||V!==null;(0,wt.useEffect)(()=>{if(!D)return;let le=k=>{te.current&&!te.current.contains(k.target)&&N(!1)};return document.addEventListener("mousedown",le),()=>document.removeEventListener("mousedown",le)},[D]);let Xe=(0,wt.useCallback)(()=>{N(!0)},[]);return(0,dt.jsxs)("div",{ref:te,style:{...x,width:C?y:o,transition:"width 0.4s cubic-bezier(0.16, 1, 0.3, 1)"},"data-waniwani-chat":"","data-waniwani-layout":"bar",...m?{"data-waniwani-dark":""}:{},className:"ww:flex ww:flex-col ww:font-[family-name:var(--ww-font)] ww:text-foreground",children:[(0,dt.jsxs)("div",{style:{overflow:"hidden",backgroundColor:g.backgroundColor,borderRadius:"var(--ww-radius) var(--ww-radius) 0 0",maxHeight:C?i+200:0,opacity:C?1:0,transform:C?"scaleX(1)":"scaleX(0.88)",transformOrigin:"center bottom",transition:"max-height 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease-out, transform 0.4s cubic-bezier(0.16, 1, 0.3, 1)"},children:[(0,dt.jsxs)("div",{className:"ww:shrink-0 ww:flex ww:items-center ww:px-6 ww:py-3",style:{backgroundColor:g.headerBackgroundColor,color:g.headerTextColor},children:[(0,dt.jsx)("div",{className:"ww:text-sm ww:font-semibold ww:truncate",children:r}),(0,dt.jsx)(Gc,{messages:L.messages,evalEnabled:w.eval,api:v})]}),(0,dt.jsxs)(Sl,{className:"ww:flex-1",style:{height:i},children:[(0,dt.jsx)(Cl,{scrollClassName:V?"ww:!relative ww:!overflow-hidden":void 0,children:(0,dt.jsx)(Hl,{messages:L.messages,status:L.status,welcomeMessage:u,welcome:c,onSuggestionSelect:_,resourceEndpoint:S,chatSessionId:L.sessionId,isDark:m,onFollowUp:R,onCallTool:b,fullscreenToolCallId:V,toolDefinitions:L.toolDefinitions,onWidgetDisplayModeChange:(le,k)=>{F(le==="fullscreen"?k.toolCallId:null)}})}),(0,dt.jsx)(Il,{})]}),(0,dt.jsx)("div",{style:V?{display:"none"}:void 0,children:(0,dt.jsx)(jl,{suggestions:A.suggestions,isLoading:A.isLoading,onSelect:_})}),(0,dt.jsx)("div",{style:V?{display:"none"}:void 0,children:(0,dt.jsx)(Al,{queuedMessages:L.queuedMessages,onRemove:L.removeQueuedMessage})})]}),(0,dt.jsx)("div",{style:{backgroundColor:C?g.backgroundColor:"transparent",borderRadius:C?"0 0 var(--ww-radius) var(--ww-radius)":void 0,boxShadow:C?"0 8px 24px rgba(0,0,0,0.1)":"none",transition:"background-color 0.2s ease, border-radius 0.3s ease, box-shadow 0.35s ease, padding 0.3s ease",padding:C?"8px 16px 16px":"0"},children:(0,dt.jsx)(Ll,{onSubmit:L.handleSubmit,globalDrop:s,multiple:s,className:$("ww:rounded-2xl ww:border-border ww:bg-input ww:transition-all ww:duration-300",!C&&"ww:shadow-sm",B&&"ww:ring-2 ww:ring-blue-400/70 ww:ring-offset-2 ww:ring-offset-background"),children:(0,dt.jsxs)("div",{className:"ww:flex ww:items-center ww:gap-1 ww:pl-4 ww:pr-3 ww:py-2.5",children:[s&&(0,dt.jsx)(Ml,{}),(0,dt.jsx)(kl,{onChange:L.handleTextChange,value:L.text,placeholder:T,onFocus:Xe,className:"ww:min-h-0 ww:py-1 ww:px-0"}),(0,dt.jsx)(Tl,{status:L.status,disabled:L.queueFull})]})})})]})});var ra=q(xe(),1);var bt=q(ee(),1),A2=(0,ra.forwardRef)(function(t,a){let{theme:n,className:r,allowAttachments:o=!1,welcomeMessage:l,welcome:i,placeholder:s="Ask me anything...",triggerEvent:u="triggerDemoRequest",api:c,mcp:d,debug:f=!1,readOnly:p=!1}=t,y=Jl(n),v=ti(y),S=ei(y),g=Zl({...t,api:c}),x=Vl({...t,api:c,sessionId:g.sessionId,onCallTool:d?.onCallTool}),m=Yl(s,!g.text),[w,L]=(0,ra.useState)(null),b=(0,ra.useRef)(null),A=(0,ra.useCallback)(()=>{let D=b.current;if(!D)return;let N=D.querySelector("textarea");N&&N.focus()},[]),R=Ql({messages:g.messages,status:g.status,config:t.suggestions}),_=(0,ra.useCallback)(D=>{let N=D.content.map(B=>B.text??"").join("").trim();N&&g.handleSubmit({text:N,files:[],modelContext:D.modelContext})},[g.handleSubmit]),T=(0,ra.useCallback)(D=>{R.clear(),g.handleSubmit({text:D,files:[]})},[R.clear,g.handleSubmit]);return(0,ra.useImperativeHandle)(a,()=>({sendMessage:D=>{g.handleSubmit({text:D,files:[]}),A()},sendMessageAndWait:D=>g.sendMessageAndWait(D),reset:g.reset,focus:A,get messages(){return g.messages}}),[g.handleSubmit,g.sendMessageAndWait,g.reset,g.messages,A]),(0,ra.useEffect)(()=>{if(!u)return;let D=N=>{let B=N.detail,j=typeof B?.message=="string"?B.message:void 0;j&&g.handleSubmit({text:j,files:[]}),A()};return window.addEventListener(u,D),()=>window.removeEventListener(u,D)},[u,g.handleSubmit,A]),(0,bt.jsxs)("div",{ref:b,style:v,"data-waniwani-chat":"","data-waniwani-layout":"embed",...S?{"data-waniwani-dark":""}:{},className:$("ww:flex ww:flex-col ww:w-full ww:h-full ww:font-[family-name:var(--ww-font)] ww:text-foreground ww:bg-background ww:overflow-hidden",r),children:[(0,bt.jsxs)(Sl,{className:"ww:flex-1 ww:min-h-0 ww:bg-background",children:[(0,bt.jsx)(Cl,{scrollClassName:w?"ww:!relative ww:!overflow-hidden":void 0,children:(0,bt.jsx)(Hl,{messages:g.messages,status:g.status,welcomeMessage:l,welcome:i,onSuggestionSelect:T,resourceEndpoint:d?.resourceEndpoint,chatSessionId:g.sessionId,isDark:S,onFollowUp:_,onCallTool:x,fullscreenToolCallId:w,debug:f,toolDefinitions:g.toolDefinitions,onWidgetDisplayModeChange:(D,N)=>{L(D==="fullscreen"?N.toolCallId:null)}})}),(0,bt.jsx)(Il,{})]}),!p&&(0,bt.jsx)("div",{style:w?{display:"none"}:void 0,children:(0,bt.jsx)(jl,{suggestions:R.suggestions,isLoading:R.isLoading,onSelect:T})}),!p&&(0,bt.jsx)("div",{style:w?{display:"none"}:void 0,children:(0,bt.jsx)(Al,{queuedMessages:g.queuedMessages,onRemove:g.removeQueuedMessage})}),!p&&(0,bt.jsx)("div",{style:w?{display:"none"}:void 0,children:(0,bt.jsx)("div",{className:"ww:shrink-0 ww:px-4 ww:pb-8 ww:pt-2 ww:bg-background",children:(0,bt.jsx)("div",{className:"ww:mx-auto ww:w-full ww:max-w-3xl",children:(0,bt.jsx)(Ll,{onSubmit:g.handleSubmit,globalDrop:o,multiple:o,className:"ww:rounded-2xl ww:border-border ww:bg-input",children:(0,bt.jsxs)("div",{className:"ww:flex ww:items-center ww:gap-1 ww:pl-4 ww:pr-3 ww:py-2.5",children:[o&&(0,bt.jsx)(Ml,{}),(0,bt.jsx)(kl,{onChange:g.handleTextChange,value:g.text,placeholder:m,className:"ww:min-h-0 ww:py-1 ww:px-0"}),(0,bt.jsx)(Tl,{status:g.status,disabled:g.queueFull})]})})})})})]})});var kf=q(ee(),1),E2=(0,_r.forwardRef)(function({config:t,programmatic:a,scriptConfig:n,onReady:r},o){let l=Lf(t,a,n),i=(0,_r.useRef)(null);(0,_r.useEffect)(()=>{r?.()},[]),(0,_r.useImperativeHandle)(o,()=>({get chat(){return i.current}}),[]);let s={...Bc(l),borderRadius:0},u={api:l.api,headers:{Authorization:`Bearer ${l.token}`},skipRemoteConfig:!0,body:l.mcpServerUrl?{mcpServerUrl:l.mcpServerUrl}:void 0,theme:s,welcomeMessage:l.welcomeMessage,placeholder:l.placeholder,suggestions:l.suggestions?{initial:l.suggestions}:void 0},c=l.layout??"card";return c==="bar"?(0,kf.jsx)(M2,{...u,ref:i,title:l.title??"Assistant"}):c==="embed"?(0,kf.jsx)(A2,{...u,ref:i,api:u.api}):(0,kf.jsx)(Cf,{...u,ref:i,title:l.title??"Assistant",width:"100%",height:"100%"})});var yx="/*! tailwindcss v4.1.18 | MIT License | https://tailwindcss.com */\n@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-space-y-reverse:0;--tw-border-style:solid;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-duration:initial;--tw-ease:initial}}}@layer theme{:root,:host{--ww-font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,\"Liberation Mono\",\"Courier New\",monospace;--ww-color-red-300:oklch(80.8% .114 19.571);--ww-color-red-400:oklch(70.4% .191 22.216);--ww-color-red-500:oklch(63.7% .237 25.331);--ww-color-blue-400:oklch(70.7% .165 254.624);--ww-spacing:.25rem;--ww-container-sm:24rem;--ww-container-md:28rem;--ww-container-3xl:48rem;--ww-text-xs:.75rem;--ww-text-xs--line-height:calc(1/.75);--ww-text-sm:.875rem;--ww-text-sm--line-height:calc(1.25/.875);--ww-text-base:1rem;--ww-text-base--line-height:calc(1.5/1);--ww-text-lg:1.125rem;--ww-text-lg--line-height:calc(1.75/1.125);--ww-font-weight-medium:500;--ww-font-weight-semibold:600;--ww-tracking-wide:.025em;--ww-tracking-wider:.05em;--ww-tracking-widest:.1em;--ww-leading-normal:1.5;--ww-radius-md:.375rem;--ww-radius-lg:.5rem;--ww-radius-xl:.75rem;--ww-radius-2xl:1rem;--ww-ease-out:cubic-bezier(0,0,.2,1);--ww-animate-spin:spin 1s linear infinite;--ww-animate-pulse:pulse 2s cubic-bezier(.4,0,.6,1)infinite;--ww-default-transition-duration:.15s;--ww-default-transition-timing-function:cubic-bezier(.4,0,.2,1);--ww-default-font-family:var(--ww-font-sans,system-ui,-apple-system,\"Segoe UI\",sans-serif);--ww-default-mono-font-family:var(--ww-font-mono)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--ww-default-font-family,ui-sans-serif,system-ui,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\",\"Segoe UI Symbol\",\"Noto Color Emoji\");font-feature-settings:var(--ww-default-font-feature-settings,normal);font-variation-settings:var(--ww-default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--ww-default-mono-font-family,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,\"Liberation Mono\",\"Courier New\",monospace);font-feature-settings:var(--ww-default-mono-font-feature-settings,normal);font-variation-settings:var(--ww-default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab, red, red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer components;@layer utilities{.ww\\:\\!relative{position:relative!important}.ww\\:absolute{position:absolute}.ww\\:relative{position:relative}.ww\\:bottom-4{bottom:calc(var(--ww-spacing)*4)}.ww\\:left-\\[50\\%\\]{left:50%}.ww\\:mx-3{margin-inline:calc(var(--ww-spacing)*3)}.ww\\:mx-auto{margin-inline:auto}.ww\\:my-2{margin-block:calc(var(--ww-spacing)*2)}.ww\\:mt-0\\.5{margin-top:calc(var(--ww-spacing)*.5)}.ww\\:mt-1{margin-top:calc(var(--ww-spacing)*1)}.ww\\:mt-2{margin-top:calc(var(--ww-spacing)*2)}.ww\\:mt-6{margin-top:calc(var(--ww-spacing)*6)}.ww\\:mb-2{margin-bottom:calc(var(--ww-spacing)*2)}.ww\\:mb-4{margin-bottom:calc(var(--ww-spacing)*4)}.ww\\:ml-auto{margin-left:auto}.ww\\:line-clamp-1{-webkit-line-clamp:1;-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden}.ww\\:block{display:block}.ww\\:contents{display:contents}.ww\\:flex{display:flex}.ww\\:grid{display:grid}.ww\\:hidden{display:none}.ww\\:inline-block{display:inline-block}.ww\\:inline-flex{display:inline-flex}.ww\\:field-sizing-content{field-sizing:content}.ww\\:size-2{width:calc(var(--ww-spacing)*2);height:calc(var(--ww-spacing)*2)}.ww\\:size-3{width:calc(var(--ww-spacing)*3);height:calc(var(--ww-spacing)*3)}.ww\\:size-3\\.5{width:calc(var(--ww-spacing)*3.5);height:calc(var(--ww-spacing)*3.5)}.ww\\:size-4{width:calc(var(--ww-spacing)*4);height:calc(var(--ww-spacing)*4)}.ww\\:size-5{width:calc(var(--ww-spacing)*5);height:calc(var(--ww-spacing)*5)}.ww\\:size-7{width:calc(var(--ww-spacing)*7);height:calc(var(--ww-spacing)*7)}.ww\\:size-8{width:calc(var(--ww-spacing)*8);height:calc(var(--ww-spacing)*8)}.ww\\:size-9{width:calc(var(--ww-spacing)*9);height:calc(var(--ww-spacing)*9)}.ww\\:size-12{width:calc(var(--ww-spacing)*12);height:calc(var(--ww-spacing)*12)}.ww\\:size-auto{width:auto;height:auto}.ww\\:size-full{width:100%;height:100%}.ww\\:h-1\\.5{height:calc(var(--ww-spacing)*1.5)}.ww\\:h-3\\.5{height:calc(var(--ww-spacing)*3.5)}.ww\\:h-7{height:calc(var(--ww-spacing)*7)}.ww\\:h-8{height:calc(var(--ww-spacing)*8)}.ww\\:h-9{height:calc(var(--ww-spacing)*9)}.ww\\:h-16{height:calc(var(--ww-spacing)*16)}.ww\\:h-auto{height:auto}.ww\\:h-full{height:100%}.ww\\:max-h-48{max-height:calc(var(--ww-spacing)*48)}.ww\\:min-h-0{min-height:calc(var(--ww-spacing)*0)}.ww\\:min-h-full{min-height:100%}.ww\\:w-1\\.5{width:calc(var(--ww-spacing)*1.5)}.ww\\:w-fit{width:fit-content}.ww\\:w-full{width:100%}.ww\\:max-w-3xl{max-width:var(--ww-container-3xl)}.ww\\:max-w-24{max-width:calc(var(--ww-spacing)*24)}.ww\\:max-w-32{max-width:calc(var(--ww-spacing)*32)}.ww\\:max-w-\\[80\\%\\]{max-width:80%}.ww\\:max-w-full{max-width:100%}.ww\\:max-w-md{max-width:var(--ww-container-md)}.ww\\:max-w-sm{max-width:var(--ww-container-sm)}.ww\\:min-w-0{min-width:calc(var(--ww-spacing)*0)}.ww\\:flex-1{flex:1}.ww\\:shrink-0{flex-shrink:0}.ww\\:grow{flex-grow:1}.ww\\:translate-x-\\[-50\\%\\]{--tw-translate-x:-50%;translate:var(--tw-translate-x)var(--tw-translate-y)}.ww\\:rotate-90{rotate:90deg}.ww\\:rotate-180{rotate:180deg}.ww\\:animate-\\[ww-fade-in_0\\.2s_ease-out_both\\]{animation:.2s ease-out both ww-fade-in}.ww\\:animate-pulse{animation:var(--ww-animate-pulse)}.ww\\:animate-spin{animation:var(--ww-animate-spin)}.ww\\:cursor-pointer{cursor:pointer}.ww\\:resize-none{resize:none}.ww\\:grid-rows-\\[0fr\\]{grid-template-rows:0fr}.ww\\:grid-rows-\\[1fr\\]{grid-template-rows:1fr}.ww\\:flex-col{flex-direction:column}.ww\\:flex-wrap{flex-wrap:wrap}.ww\\:items-center{align-items:center}.ww\\:items-end{align-items:flex-end}.ww\\:items-start{align-items:flex-start}.ww\\:justify-between{justify-content:space-between}.ww\\:justify-center{justify-content:center}.ww\\:gap-1{gap:calc(var(--ww-spacing)*1)}.ww\\:gap-1\\.5{gap:calc(var(--ww-spacing)*1.5)}.ww\\:gap-2{gap:calc(var(--ww-spacing)*2)}.ww\\:gap-3{gap:calc(var(--ww-spacing)*3)}.ww\\:gap-6{gap:calc(var(--ww-spacing)*6)}:where(.ww\\:space-y-2>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--ww-spacing)*2)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--ww-spacing)*2)*calc(1 - var(--tw-space-y-reverse)))}:where(.ww\\:space-y-3>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--ww-spacing)*3)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--ww-spacing)*3)*calc(1 - var(--tw-space-y-reverse)))}.ww\\:truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.ww\\:\\!overflow-hidden{overflow:hidden!important}.ww\\:overflow-hidden{overflow:hidden}.ww\\:overflow-x-auto{overflow-x:auto}.ww\\:overflow-y-auto{overflow-y:auto}.ww\\:overflow-y-hidden{overflow-y:hidden}.ww\\:\\!rounded-full{border-radius:3.40282e38px!important}.ww\\:rounded{border-radius:var(--ww-radius,16px)}.ww\\:rounded-2xl{border-radius:var(--ww-radius-2xl)}.ww\\:rounded-\\[var\\(--ww-radius\\)\\]{border-radius:var(--ww-radius)}.ww\\:rounded-full{border-radius:3.40282e38px}.ww\\:rounded-lg{border-radius:var(--ww-radius-lg)}.ww\\:rounded-md{border-radius:var(--ww-radius-md)}.ww\\:rounded-xl{border-radius:var(--ww-radius-xl)}.ww\\:border{border-style:var(--tw-border-style);border-width:1px}.ww\\:border-0{border-style:var(--tw-border-style);border-width:0}.ww\\:border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.ww\\:border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.ww\\:border-l{border-left-style:var(--tw-border-style);border-left-width:1px}.ww\\:border-l-2{border-left-style:var(--tw-border-style);border-left-width:2px}.ww\\:border-\\[\\#03d916\\]{border-color:#03d916}.ww\\:border-border,.ww\\:border-border\\/50{border-color:var(--ww-color-border,#e5e7eb)}@supports (color:color-mix(in lab, red, red)){.ww\\:border-border\\/50{border-color:color-mix(in oklab,var(--ww-color-border,#e5e7eb)50%,transparent)}}.ww\\:border-foreground\\/30{border-color:var(--ww-color-foreground,#1f2937)}@supports (color:color-mix(in lab, red, red)){.ww\\:border-foreground\\/30{border-color:color-mix(in oklab,var(--ww-color-foreground,#1f2937)30%,transparent)}}.ww\\:border-muted-foreground\\/50{border-color:var(--ww-color-muted-foreground,#6b7280)}@supports (color:color-mix(in lab, red, red)){.ww\\:border-muted-foreground\\/50{border-color:color-mix(in oklab,var(--ww-color-muted-foreground,#6b7280)50%,transparent)}}.ww\\:border-transparent{border-color:#0000}.ww\\:bg-\\[\\#03d916\\]\\/10{background-color:oklab(76.761% -.205195 .155304/.1)}.ww\\:bg-accent{background-color:var(--ww-color-accent,#f3f4f6)}.ww\\:bg-background,.ww\\:bg-background\\/20{background-color:var(--ww-color-background,#fff)}@supports (color:color-mix(in lab, red, red)){.ww\\:bg-background\\/20{background-color:color-mix(in oklab,var(--ww-color-background,#fff)20%,transparent)}}.ww\\:bg-foreground{background-color:var(--ww-color-foreground,#1f2937)}.ww\\:bg-input{background-color:var(--ww-color-input,#f9fafb)}.ww\\:bg-muted{background-color:var(--ww-color-muted,#f1f5f9)}.ww\\:bg-muted-foreground\\/10{background-color:var(--ww-color-muted-foreground,#6b7280)}@supports (color:color-mix(in lab, red, red)){.ww\\:bg-muted-foreground\\/10{background-color:color-mix(in oklab,var(--ww-color-muted-foreground,#6b7280)10%,transparent)}}.ww\\:bg-muted-foreground\\/20{background-color:var(--ww-color-muted-foreground,#6b7280)}@supports (color:color-mix(in lab, red, red)){.ww\\:bg-muted-foreground\\/20{background-color:color-mix(in oklab,var(--ww-color-muted-foreground,#6b7280)20%,transparent)}}.ww\\:bg-muted-foreground\\/60{background-color:var(--ww-color-muted-foreground,#6b7280)}@supports (color:color-mix(in lab, red, red)){.ww\\:bg-muted-foreground\\/60{background-color:color-mix(in oklab,var(--ww-color-muted-foreground,#6b7280)60%,transparent)}}.ww\\:bg-muted\\/50{background-color:var(--ww-color-muted,#f1f5f9)}@supports (color:color-mix(in lab, red, red)){.ww\\:bg-muted\\/50{background-color:color-mix(in oklab,var(--ww-color-muted,#f1f5f9)50%,transparent)}}.ww\\:bg-primary{background-color:var(--ww-color-primary,#6366f1)}.ww\\:bg-red-500\\/10{background-color:var(--ww-color-red-500)}@supports (color:color-mix(in lab, red, red)){.ww\\:bg-red-500\\/10{background-color:color-mix(in oklab,var(--ww-color-red-500)10%,transparent)}}.ww\\:bg-tool-card{background-color:var(--ww-color-tool-card,#f4f4f5)}.ww\\:bg-transparent{background-color:#0000}.ww\\:object-cover{object-fit:cover}.ww\\:p-0{padding:calc(var(--ww-spacing)*0)}.ww\\:p-1{padding:calc(var(--ww-spacing)*1)}.ww\\:p-3{padding:calc(var(--ww-spacing)*3)}.ww\\:px-0{padding-inline:calc(var(--ww-spacing)*0)}.ww\\:px-1\\.5{padding-inline:calc(var(--ww-spacing)*1.5)}.ww\\:px-2{padding-inline:calc(var(--ww-spacing)*2)}.ww\\:px-3{padding-inline:calc(var(--ww-spacing)*3)}.ww\\:px-4{padding-inline:calc(var(--ww-spacing)*4)}.ww\\:px-6{padding-inline:calc(var(--ww-spacing)*6)}.ww\\:py-0\\.5{padding-block:calc(var(--ww-spacing)*.5)}.ww\\:py-1{padding-block:calc(var(--ww-spacing)*1)}.ww\\:py-1\\.5{padding-block:calc(var(--ww-spacing)*1.5)}.ww\\:py-2{padding-block:calc(var(--ww-spacing)*2)}.ww\\:py-2\\.5{padding-block:calc(var(--ww-spacing)*2.5)}.ww\\:py-3{padding-block:calc(var(--ww-spacing)*3)}.ww\\:py-6{padding-block:calc(var(--ww-spacing)*6)}.ww\\:py-8{padding-block:calc(var(--ww-spacing)*8)}.ww\\:py-12{padding-block:calc(var(--ww-spacing)*12)}.ww\\:pt-2{padding-top:calc(var(--ww-spacing)*2)}.ww\\:pt-2\\.5{padding-top:calc(var(--ww-spacing)*2.5)}.ww\\:pt-3{padding-top:calc(var(--ww-spacing)*3)}.ww\\:pr-3{padding-right:calc(var(--ww-spacing)*3)}.ww\\:pb-1\\.5{padding-bottom:calc(var(--ww-spacing)*1.5)}.ww\\:pb-3{padding-bottom:calc(var(--ww-spacing)*3)}.ww\\:pb-8{padding-bottom:calc(var(--ww-spacing)*8)}.ww\\:pl-4{padding-left:calc(var(--ww-spacing)*4)}.ww\\:text-center{text-align:center}.ww\\:text-left{text-align:left}.ww\\:font-\\[family-name\\:var\\(--ww-font\\)\\]{font-family:var(--ww-font)}.ww\\:font-mono{font-family:var(--ww-font-mono)}.ww\\:text-base{font-size:var(--ww-text-base);line-height:var(--tw-leading,var(--ww-text-base--line-height))}.ww\\:text-lg{font-size:var(--ww-text-lg);line-height:var(--tw-leading,var(--ww-text-lg--line-height))}.ww\\:text-sm{font-size:var(--ww-text-sm);line-height:var(--tw-leading,var(--ww-text-sm--line-height))}.ww\\:text-xs{font-size:var(--ww-text-xs);line-height:var(--tw-leading,var(--ww-text-xs--line-height))}.ww\\:text-\\[10px\\]{font-size:10px}.ww\\:text-\\[11px\\]{font-size:11px}.ww\\:leading-normal{--tw-leading:var(--ww-leading-normal);line-height:var(--ww-leading-normal)}.ww\\:font-medium{--tw-font-weight:var(--ww-font-weight-medium);font-weight:var(--ww-font-weight-medium)}.ww\\:font-semibold{--tw-font-weight:var(--ww-font-weight-semibold);font-weight:var(--ww-font-weight-semibold)}.ww\\:tracking-wide{--tw-tracking:var(--ww-tracking-wide);letter-spacing:var(--ww-tracking-wide)}.ww\\:tracking-wider{--tw-tracking:var(--ww-tracking-wider);letter-spacing:var(--ww-tracking-wider)}.ww\\:tracking-widest{--tw-tracking:var(--ww-tracking-widest);letter-spacing:var(--ww-tracking-widest)}.ww\\:break-words{overflow-wrap:break-word}.ww\\:break-all{word-break:break-all}.ww\\:whitespace-pre-wrap{white-space:pre-wrap}.ww\\:text-background{color:var(--ww-color-background,#fff)}.ww\\:text-foreground,.ww\\:text-foreground\\/50{color:var(--ww-color-foreground,#1f2937)}@supports (color:color-mix(in lab, red, red)){.ww\\:text-foreground\\/50{color:color-mix(in oklab,var(--ww-color-foreground,#1f2937)50%,transparent)}}.ww\\:text-foreground\\/60{color:var(--ww-color-foreground,#1f2937)}@supports (color:color-mix(in lab, red, red)){.ww\\:text-foreground\\/60{color:color-mix(in oklab,var(--ww-color-foreground,#1f2937)60%,transparent)}}.ww\\:text-foreground\\/80{color:var(--ww-color-foreground,#1f2937)}@supports (color:color-mix(in lab, red, red)){.ww\\:text-foreground\\/80{color:color-mix(in oklab,var(--ww-color-foreground,#1f2937)80%,transparent)}}.ww\\:text-muted-foreground{color:var(--ww-color-muted-foreground,#6b7280)}.ww\\:text-primary{color:var(--ww-color-primary,#6366f1)}.ww\\:text-primary-foreground{color:var(--ww-color-primary-foreground,#1f2937)}.ww\\:text-red-400{color:var(--ww-color-red-400)}.ww\\:uppercase{text-transform:uppercase}.ww\\:opacity-0{opacity:0}.ww\\:opacity-100{opacity:1}.ww\\:shadow-sm{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a),0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ww\\:ring-2{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(2px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ww\\:ring-blue-400\\/70{--tw-ring-color:var(--ww-color-blue-400)}@supports (color:color-mix(in lab, red, red)){.ww\\:ring-blue-400\\/70{--tw-ring-color:color-mix(in oklab,var(--ww-color-blue-400)70%,transparent)}}.ww\\:ring-offset-2{--tw-ring-offset-width:2px;--tw-ring-offset-shadow:var(--tw-ring-inset,)0 0 0 var(--tw-ring-offset-width)var(--tw-ring-offset-color)}.ww\\:ring-offset-background{--tw-ring-offset-color:var(--ww-color-background,#fff)}.ww\\:transition-\\[grid-template-rows\\,opacity\\]{transition-property:grid-template-rows,opacity;transition-timing-function:var(--tw-ease,var(--ww-default-transition-timing-function));transition-duration:var(--tw-duration,var(--ww-default-transition-duration))}.ww\\:transition-all{transition-property:all;transition-timing-function:var(--tw-ease,var(--ww-default-transition-timing-function));transition-duration:var(--tw-duration,var(--ww-default-transition-duration))}.ww\\:transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--ww-default-transition-timing-function));transition-duration:var(--tw-duration,var(--ww-default-transition-duration))}.ww\\:transition-opacity{transition-property:opacity;transition-timing-function:var(--tw-ease,var(--ww-default-transition-timing-function));transition-duration:var(--tw-duration,var(--ww-default-transition-duration))}.ww\\:transition-transform{transition-property:transform,translate,scale,rotate;transition-timing-function:var(--tw-ease,var(--ww-default-transition-timing-function));transition-duration:var(--tw-duration,var(--ww-default-transition-duration))}.ww\\:duration-150{--tw-duration:.15s;transition-duration:.15s}.ww\\:duration-200{--tw-duration:.2s;transition-duration:.2s}.ww\\:duration-300{--tw-duration:.3s;transition-duration:.3s}.ww\\:ease-out{--tw-ease:var(--ww-ease-out);transition-timing-function:var(--ww-ease-out)}.ww\\:outline-none{--tw-outline-style:none;outline-style:none}@media (hover:hover){.ww\\:group-hover\\:opacity-0:is(:where(.ww\\:group):hover *){opacity:0}.ww\\:group-hover\\:opacity-100:is(:where(.ww\\:group):hover *){opacity:1}}.ww\\:group-\\[\\.is-assistant\\]\\:text-foreground:is(:where(.ww\\:group).is-assistant *){color:var(--ww-color-foreground,#1f2937)}.ww\\:group-\\[\\.is-user\\]\\:ml-auto:is(:where(.ww\\:group).is-user *){margin-left:auto}.ww\\:group-\\[\\.is-user\\]\\:rounded-lg:is(:where(.ww\\:group).is-user *){border-radius:var(--ww-radius-lg)}.ww\\:group-\\[\\.is-user\\]\\:bg-user-bubble:is(:where(.ww\\:group).is-user *){background-color:var(--ww-color-user-bubble,#f4f4f4)}.ww\\:group-\\[\\.is-user\\]\\:px-4:is(:where(.ww\\:group).is-user *){padding-inline:calc(var(--ww-spacing)*4)}.ww\\:group-\\[\\.is-user\\]\\:py-3:is(:where(.ww\\:group).is-user *){padding-block:calc(var(--ww-spacing)*3)}.ww\\:group-\\[\\.is-user\\]\\:text-primary-foreground:is(:where(.ww\\:group).is-user *){color:var(--ww-color-primary-foreground,#1f2937)}.ww\\:placeholder\\:text-muted-foreground::placeholder{color:var(--ww-color-muted-foreground,#6b7280)}@media (hover:hover){.ww\\:hover\\:border-primary\\/30:hover{border-color:var(--ww-color-primary,#6366f1)}@supports (color:color-mix(in lab, red, red)){.ww\\:hover\\:border-primary\\/30:hover{border-color:color-mix(in oklab,var(--ww-color-primary,#6366f1)30%,transparent)}}.ww\\:hover\\:bg-accent:hover{background-color:var(--ww-color-accent,#f3f4f6)}.ww\\:hover\\:bg-foreground:hover{background-color:var(--ww-color-foreground,#1f2937)}.ww\\:hover\\:bg-muted:hover{background-color:var(--ww-color-muted,#f1f5f9)}.ww\\:hover\\:bg-muted-foreground\\/10:hover{background-color:var(--ww-color-muted-foreground,#6b7280)}@supports (color:color-mix(in lab, red, red)){.ww\\:hover\\:bg-muted-foreground\\/10:hover{background-color:color-mix(in oklab,var(--ww-color-muted-foreground,#6b7280)10%,transparent)}}.ww\\:hover\\:bg-muted\\/50:hover{background-color:var(--ww-color-muted,#f1f5f9)}@supports (color:color-mix(in lab, red, red)){.ww\\:hover\\:bg-muted\\/50:hover{background-color:color-mix(in oklab,var(--ww-color-muted,#f1f5f9)50%,transparent)}}.ww\\:hover\\:bg-primary\\/90:hover{background-color:var(--ww-color-primary,#6366f1)}@supports (color:color-mix(in lab, red, red)){.ww\\:hover\\:bg-primary\\/90:hover{background-color:color-mix(in oklab,var(--ww-color-primary,#6366f1)90%,transparent)}}.ww\\:hover\\:text-accent-foreground:hover{color:var(--ww-color-accent-foreground,#1f2937)}.ww\\:hover\\:text-foreground:hover{color:var(--ww-color-foreground,#1f2937)}.ww\\:hover\\:text-red-300:hover{color:var(--ww-color-red-300)}.ww\\:hover\\:underline:hover{text-decoration-line:underline}}.ww\\:disabled\\:pointer-events-none:disabled{pointer-events:none}.ww\\:disabled\\:opacity-30:disabled{opacity:.3}.ww\\:disabled\\:opacity-40:disabled{opacity:.4}.ww\\:disabled\\:opacity-50:disabled{opacity:.5}.ww\\:\\[\\&\\>\\*\\:first-child\\]\\:mt-0>:first-child{margin-top:calc(var(--ww-spacing)*0)}.ww\\:\\[\\&\\>\\*\\:last-child\\]\\:mb-0>:last-child{margin-bottom:calc(var(--ww-spacing)*0)}}@keyframes ww-fade-in{0%{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:translateY(0)}}@keyframes ww-fade-out{0%{opacity:1;transform:translateY(0)}to{opacity:0;transform:translateY(-4px)}}@keyframes ww-pulse{0%,80%,to{opacity:.3;transform:scale(.8)}40%{opacity:1;transform:scale(1)}}[data-waniwani-chat] ::-webkit-scrollbar{width:8px}[data-waniwani-chat] ::-webkit-scrollbar-track{background:0 0}[data-waniwani-chat] ::-webkit-scrollbar-thumb{background:var(--ww-color-border);border-radius:9999px}[data-waniwani-chat] ::-webkit-scrollbar-thumb:hover{background:var(--ww-color-muted-foreground)}[data-waniwani-chat] *{scrollbar-width:thin;scrollbar-color:var(--ww-color-border)transparent}[data-waniwani-chat]{--ww-color-background:var(--ww-bg,#fff);--ww-color-foreground:var(--ww-text,#1f2937);--ww-color-primary:var(--ww-primary,#6366f1);--ww-color-primary-foreground:var(--ww-primary-fg,#1f2937);--ww-color-muted-foreground:var(--ww-muted,#6b7280);--ww-color-border:var(--ww-border,#e5e7eb);--ww-color-input:var(--ww-input-bg,#f9fafb);--ww-color-accent:var(--ww-assistant-bubble,#f3f4f6);--ww-color-accent-foreground:var(--ww-text,#1f2937);--ww-color-user-bubble:var(--ww-user-bubble,#f4f4f4);--ww-color-card:var(--ww-bg,#fff);--ww-color-card-foreground:var(--ww-text,#1f2937);--ww-color-card-header:var(--ww-header-bg,#fff);--ww-color-card-header-foreground:var(--ww-header-text,#1f2937);--ww-color-status:var(--ww-status,#22c55e);--ww-color-tool-card:var(--ww-tool-card,#f4f4f5);--ww-radius:var(--ww-radius,16px);--ww-font-sans:var(--ww-font,system-ui,-apple-system,\"Segoe UI\",sans-serif)}.dark [data-waniwani-chat],[data-waniwani-chat].dark{--ww-color-background:var(--ww-bg,#212121);--ww-color-foreground:var(--ww-text,#ececec);--ww-color-primary:var(--ww-primary,#6366f1);--ww-color-primary-foreground:var(--ww-primary-fg,#fff);--ww-color-muted-foreground:var(--ww-muted,#8e8ea0);--ww-color-border:var(--ww-border,#444);--ww-color-input:var(--ww-input-bg,#2f2f2f);--ww-color-accent:var(--ww-assistant-bubble,#2f2f2f);--ww-color-accent-foreground:var(--ww-text,#ececec);--ww-color-user-bubble:var(--ww-user-bubble,#303030);--ww-color-card:var(--ww-bg,#212121);--ww-color-card-foreground:var(--ww-text,#ececec);--ww-color-card-header:var(--ww-header-bg,#1e1e1e);--ww-color-card-header-foreground:var(--ww-header-text,#ececec);--ww-color-status:var(--ww-status,#22c55e);--ww-color-tool-card:var(--ww-tool-card,#262626)}[data-waniwani-chat] [data-streamdown=table-wrapper]{flex-direction:column;gap:.5rem;margin-top:1rem;margin-bottom:1rem;display:flex}[data-waniwani-chat] [data-streamdown=table-wrapper]>div:first-child:has(button){justify-content:flex-end;align-items:center;gap:.25rem;display:flex}[data-waniwani-chat] [data-streamdown=table-wrapper]>div:last-child{overflow-x:auto}[data-waniwani-chat] [data-streamdown=table]{border-collapse:collapse;border:1px solid var(--ww-color-border);border-radius:.75rem;width:100%;overflow:hidden}[data-waniwani-chat] [data-streamdown=table-header]{background-color:var(--ww-color-accent)}@supports (color:color-mix(in lab, red, red)){[data-waniwani-chat] [data-streamdown=table-header]{background-color:color-mix(in srgb,var(--ww-color-accent)80%,transparent)}}[data-waniwani-chat] [data-streamdown=table-body]{background-color:var(--ww-color-accent)}@supports (color:color-mix(in lab, red, red)){[data-waniwani-chat] [data-streamdown=table-body]{background-color:color-mix(in srgb,var(--ww-color-accent)40%,transparent)}}[data-waniwani-chat] [data-streamdown=table-body]>tr+tr{border-top:1px solid var(--ww-color-border)}[data-waniwani-chat] [data-streamdown=table-row]{border-bottom:1px solid var(--ww-color-border)}[data-waniwani-chat] [data-streamdown=table-header-cell]{white-space:nowrap;text-align:left;padding:.5rem 1rem;font-size:.875rem;font-weight:600}[data-waniwani-chat] [data-streamdown=table-cell]{padding:.5rem 1rem;font-size:.875rem}[data-waniwani-chat] [data-streamdown=link]{color:var(--ww-color-primary);overflow-wrap:anywhere;cursor:pointer;font-weight:500;text-decoration:underline}[data-waniwani-chat] [data-streamdown=link-safety-modal]{z-index:50;background-color:var(--ww-color-background);justify-content:center;align-items:center;display:flex;position:fixed;inset:0}@supports (color:color-mix(in lab, red, red)){[data-waniwani-chat] [data-streamdown=link-safety-modal]{background-color:color-mix(in srgb,var(--ww-color-background)50%,transparent)}}[data-waniwani-chat] [data-streamdown=link-safety-modal]{-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px)}[data-waniwani-chat] [data-streamdown=link-safety-modal]>div{border:1px solid var(--ww-color-border);background-color:var(--ww-color-background);width:100%;max-width:28rem;color:var(--ww-color-foreground);border-radius:.75rem;flex-direction:column;gap:1rem;margin:0 1rem;padding:1.5rem;display:flex;position:relative;box-shadow:0 10px 25px #0000001a}[data-waniwani-chat] [data-streamdown=link-safety-modal] button{cursor:pointer}[data-waniwani-chat] [data-streamdown=link-safety-modal]>div>button:first-child{color:var(--ww-color-muted-foreground);background:0 0;border:none;border-radius:.375rem;padding:.25rem;transition:background-color .15s,color .15s;position:absolute;top:1rem;right:1rem}[data-waniwani-chat] [data-streamdown=link-safety-modal]>div>button:first-child:hover{background-color:var(--ww-color-accent);color:var(--ww-color-foreground)}[data-waniwani-chat] [data-streamdown=link-safety-modal]>div>div:first-of-type{flex-direction:column;gap:.5rem;display:flex}[data-waniwani-chat] [data-streamdown=link-safety-modal]>div>div:first-of-type>div{align-items:center;gap:.5rem;font-size:1.125rem;font-weight:600;display:flex}[data-waniwani-chat] [data-streamdown=link-safety-modal]>div>div:first-of-type>p{color:var(--ww-color-muted-foreground);font-size:.875rem}[data-waniwani-chat] [data-streamdown=link-safety-modal]>div>div:nth-child(3){word-break:break-all;background-color:var(--ww-color-accent);border-radius:.375rem;max-height:8rem;padding:.75rem;font-family:ui-monospace,monospace;font-size:.875rem;overflow-y:auto}[data-waniwani-chat] [data-streamdown=link-safety-modal]>div>div:last-child{gap:.5rem;display:flex}[data-waniwani-chat] [data-streamdown=link-safety-modal]>div>div:last-child>button{border:none;border-radius:.375rem;flex:1;justify-content:center;align-items:center;gap:.5rem;padding:.5rem 1rem;font-size:.875rem;font-weight:500;transition:background-color .15s;display:flex}[data-waniwani-chat] [data-streamdown=link-safety-modal]>div>div:last-child>button:first-child{border:1px solid var(--ww-color-border);background-color:var(--ww-color-background);color:var(--ww-color-foreground)}[data-waniwani-chat] [data-streamdown=link-safety-modal]>div>div:last-child>button:first-child:hover{background-color:var(--ww-color-accent)}[data-waniwani-chat] [data-streamdown=link-safety-modal]>div>div:last-child>button:last-child{background-color:var(--ww-color-primary);color:#fff}[data-waniwani-chat] [data-streamdown=link-safety-modal]>div>div:last-child>button:last-child:hover{opacity:.9}[data-waniwani-chat] [data-streamdown=ordered-list]{white-space:normal;list-style-type:decimal;list-style-position:inside}[data-waniwani-chat] li [data-streamdown=ordered-list]{padding-left:1.5rem}[data-waniwani-chat] [data-streamdown=unordered-list]{white-space:normal;list-style-type:disc;list-style-position:inside}[data-waniwani-chat] li [data-streamdown=unordered-list]{padding-left:1.5rem}[data-waniwani-chat] [data-streamdown=list-item]{padding-top:.25rem;padding-bottom:.25rem}[data-waniwani-chat] [data-streamdown=list-item]>p{display:inline}[data-waniwani-chat] [data-streamdown=inline-code]{background-color:var(--ww-color-accent);border-radius:.25rem;padding:.125rem .375rem;font-family:ui-monospace,SFMono-Regular,SF Mono,Menlo,monospace;font-size:.875rem}[data-waniwani-chat] [data-streamdown=heading-1]{margin-top:1.5rem;margin-bottom:.5rem;font-size:1.875rem;font-weight:600;line-height:2.25rem}[data-waniwani-chat] [data-streamdown=heading-2]{margin-top:1.5rem;margin-bottom:.5rem;font-size:1.5rem;font-weight:600;line-height:2rem}[data-waniwani-chat] [data-streamdown=heading-3]{margin-top:1.5rem;margin-bottom:.5rem;font-size:1.25rem;font-weight:600;line-height:1.75rem}[data-waniwani-chat] [data-streamdown=heading-4]{margin-top:1.5rem;margin-bottom:.5rem;font-size:1.125rem;font-weight:600;line-height:1.75rem}[data-waniwani-chat] [data-streamdown=heading-5]{margin-top:1.5rem;margin-bottom:.5rem;font-size:1rem;font-weight:600;line-height:1.5rem}[data-waniwani-chat] [data-streamdown=heading-6]{margin-top:1.5rem;margin-bottom:.5rem;font-size:.875rem;font-weight:600;line-height:1.25rem}[data-waniwani-chat] [data-streamdown=blockquote]{border-left:4px solid var(--ww-color-muted-foreground);margin-top:1rem;margin-bottom:1rem}@supports (color:color-mix(in lab, red, red)){[data-waniwani-chat] [data-streamdown=blockquote]{border-left:4px solid color-mix(in srgb,var(--ww-color-muted-foreground)30%,transparent)}}[data-waniwani-chat] [data-streamdown=blockquote]{color:var(--ww-color-muted-foreground);padding-left:1rem;font-style:italic}[data-waniwani-chat] [data-streamdown=horizontal-rule]{border-color:var(--ww-color-border);margin-top:1.5rem;margin-bottom:1.5rem}[data-waniwani-chat] [data-streamdown=strong]{font-weight:600}[data-waniwani-chat] [data-streamdown=image-wrapper]{margin-top:1rem;margin-bottom:1rem;display:inline-block;position:relative}[data-waniwani-chat] [data-streamdown=image]{border-radius:.5rem;max-width:100%}[data-waniwani-chat] [data-streamdown=code-block]{border:1px solid var(--ww-color-border);border-radius:.75rem;width:100%;margin-top:1rem;margin-bottom:1rem;overflow:hidden}[data-waniwani-chat] [data-streamdown=code-block-header]{background-color:var(--ww-color-accent);justify-content:space-between;align-items:center;display:flex}@supports (color:color-mix(in lab, red, red)){[data-waniwani-chat] [data-streamdown=code-block-header]{background-color:color-mix(in srgb,var(--ww-color-accent)80%,transparent)}}[data-waniwani-chat] [data-streamdown=code-block-header]{color:var(--ww-color-muted-foreground);padding:.75rem;font-size:.75rem}[data-waniwani-chat] [data-streamdown=code-block-body]{padding:1rem;font-size:.875rem;overflow-x:auto}[data-waniwani-chat] [data-streamdown=code-block-copy-button],[data-waniwani-chat] [data-streamdown=code-block-download-button]{cursor:pointer;color:var(--ww-color-muted-foreground);background:0 0;border:none;padding:.25rem;transition:color .15s}[data-waniwani-chat] [data-streamdown=code-block-copy-button]:hover,[data-waniwani-chat] [data-streamdown=code-block-download-button]:hover{color:var(--ww-color-foreground)}[data-waniwani-chat] [data-streamdown=mermaid-block]{border:1px solid var(--ww-color-border);border-radius:.75rem;height:auto;margin-top:1rem;margin-bottom:1rem;padding:1rem;position:relative}[data-waniwani-chat] [data-streamdown=mermaid]{width:100%;height:100%}@property --tw-translate-x{syntax:\"*\";inherits:false;initial-value:0}@property --tw-translate-y{syntax:\"*\";inherits:false;initial-value:0}@property --tw-translate-z{syntax:\"*\";inherits:false;initial-value:0}@property --tw-space-y-reverse{syntax:\"*\";inherits:false;initial-value:0}@property --tw-border-style{syntax:\"*\";inherits:false;initial-value:solid}@property --tw-leading{syntax:\"*\";inherits:false}@property --tw-font-weight{syntax:\"*\";inherits:false}@property --tw-tracking{syntax:\"*\";inherits:false}@property --tw-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:\"*\";inherits:false}@property --tw-shadow-alpha{syntax:\"<percentage>\";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:\"*\";inherits:false}@property --tw-inset-shadow-alpha{syntax:\"<percentage>\";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:\"*\";inherits:false}@property --tw-ring-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:\"*\";inherits:false}@property --tw-inset-ring-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:\"*\";inherits:false}@property --tw-ring-offset-width{syntax:\"<length>\";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:\"*\";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}@property --tw-duration{syntax:\"*\";inherits:false}@property --tw-ease{syntax:\"*\";inherits:false}@keyframes spin{to{transform:rotate(360deg)}}@keyframes pulse{50%{opacity:.5}}",Ba=null,Or=null,oa=null;function _2(e,t){if(yx&&yx!=="__WANIWANI_EMBED_CSS__"){let a=document.createElement("style");a.textContent=yx,e.appendChild(a)}if(t.css)try{let a=new URL(t.css,window.location.href);if(a.protocol==="https:"||a.protocol==="http:"){let n=document.createElement("link");n.rel="stylesheet",n.href=a.href,e.appendChild(n)}else console.warn("[WaniWani] Custom CSS URL must use http or https protocol.")}catch{console.warn("[WaniWani] Invalid custom CSS URL:",t.css)}}var R2="data-waniwani-embed";function v6(e,t,a){let n=document.querySelector(`[${R2}]`);if(!n)throw new Error(`[WaniWani] No inline mount target. Place \`<div ${R2}></div>\` in your page for \`mode: "inline"\`.`);oa=document.createElement("div"),oa.id="waniwani-chat-embed",oa.style.width="100%",oa.style.height="100%",n.appendChild(oa);let r=oa.attachShadow({mode:"open"});_2(r,e);let o=document.createElement("div");o.style.width="100%",o.style.height="100%",r.appendChild(o);let l=au.default.createRef();return Or=xx.default.createRoot(o),Or.render(au.default.createElement(E2,{ref:l,config:e,programmatic:t,scriptConfig:a})),{destroy:()=>{Or?.unmount(),Or=null,oa?.remove(),oa=null,Ba=null},open:()=>{},close:()=>{},toggle:()=>{},sendMessage:i=>l.current?.chat?.sendMessage(i)}}function w6(e,t){let a=t.position==="bottom-left",n=t.theme?.primaryColor??"#6366f1",r=document.createElement("div");r.setAttribute("data-waniwani-skeleton","");let o=document.createElement("style");o.textContent=`
139
139
  @keyframes ww-skeleton-pulse { 0%,100% { opacity:1; } 50% { opacity:0.7; } }
140
140
  [data-waniwani-skeleton] .ww-sk-bubble {
141
141
  position:fixed; bottom:20px; ${a?"left":"right"}:20px;