@tavus/embed 0.1.9 → 0.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.iife.js +2 -2
- package/dist/index.mjs +141 -137
- package/package.json +1 -1
package/dist/index.iife.js
CHANGED
|
@@ -160,7 +160,7 @@ Boolean requesting whether a visible border and background is provided by the ho
|
|
|
160
160
|
- omitted: host decides border`)});var eP=Z({method:$(`ui/request-display-mode`),params:Z({mode:zN.describe(`The display mode being requested.`)})});Z({mode:zN.describe(`The display mode that was actually set. May differ from requested if not supported.`)}).passthrough();var tP=Q([$(`model`),$(`app`)]).describe(`Tool visibility scope - who can access the tool.`);Z({resourceUri:J().optional(),visibility:X(tP).optional().describe(`Who can access this tool. Default: ["model", "app"]
|
|
161
161
|
- "model": Tool visible to and callable by the agent
|
|
162
162
|
- "app": Tool callable by the app from this server only`),csp:wk().optional(),permissions:wk().optional()}),Z({mimeTypes:X(J()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')});var nP=Z({method:$(`ui/download-file`),params:Z({contents:X(Q([AM,jM])).describe(`Resource contents to download — embedded (inline data) or linked (host fetches). Uses standard MCP resource types.`)})}),rP=Z({method:$(`ui/message`),params:Z({role:$(`user`).describe(`Message role, currently only "user" is supported.`),content:X(MM).describe(`Message content blocks (text, image, etc.).`)})});Z({method:$(`ui/notifications/sandbox-resource-ready`),params:Z({html:J().describe(`HTML content to load into the inner iframe.`),sandbox:J().optional().describe(`Optional override for the inner iframe's sandbox attribute.`),csp:UN.optional().describe(`CSP configuration from resource metadata.`),permissions:WN.optional().describe(`Sandbox permissions from resource metadata.`)})}),Z({method:$(`ui/notifications/tool-result`),params:VM.describe(`Standard MCP tool execution result.`)});var iP=Z({toolInfo:Z({id:sj.optional().describe(`JSON-RPC id of the tools/call request.`),tool:RM.describe(`Tool definition including name, inputSchema, etc.`)}).optional().describe(`Metadata of the tool call that instantiated this App.`),theme:RN.optional().describe(`Current color theme preference.`),styles:qN.optional().describe(`Style configuration for theming the app.`),displayMode:zN.optional().describe(`How the UI is currently displayed.`),availableDisplayModes:X(zN).optional().describe(`Display modes the host supports.`),containerDimensions:Q([Z({height:Y().describe(`Fixed container height in pixels.`)}),Z({maxHeight:Q([Y(),xk()]).optional().describe(`Maximum container height in pixels.`)})]).and(Q([Z({width:Y().describe(`Fixed container width in pixels.`)}),Z({maxWidth:Q([Y(),xk()]).optional().describe(`Maximum container width in pixels.`)})])).optional().describe(`Container dimensions. Represents the dimensions of the iframe or other
|
|
163
|
-
container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:J().optional().describe(`User's language and region preference in BCP 47 format.`),timeZone:J().optional().describe(`User's timezone in IANA format.`),userAgent:J().optional().describe(`Host application identifier.`),platform:Q([$(`web`),$(`desktop`),$(`mobile`)]).optional().describe(`Platform type for responsive design decisions.`),deviceCapabilities:Z({touch:bk().optional().describe(`Whether the device supports touch input.`),hover:bk().optional().describe(`Whether the device supports hover interactions.`)}).optional().describe(`Device input capabilities.`),safeAreaInsets:Z({top:Y().describe(`Top safe area inset in pixels.`),right:Y().describe(`Right safe area inset in pixels.`),bottom:Y().describe(`Bottom safe area inset in pixels.`),left:Y().describe(`Left safe area inset in pixels.`)}).optional().describe(`Mobile safe area boundaries in pixels.`)}).passthrough();Z({method:$(`ui/notifications/host-context-changed`),params:iP.describe(`Partial context update containing only changed fields.`)});var aP=Z({method:$(`ui/update-model-context`),params:Z({content:X(MM).optional().describe(`Context content blocks (text, image, etc.).`),structuredContent:Ok(J(),Ck().describe(`Structured content for machine-readable context data.`)).optional().describe(`Structured content for machine-readable context data.`)})}),oP=Z({method:$(`ui/initialize`),params:Z({appInfo:Sj.describe(`App identification (name and version).`),appCapabilities:QN.describe(`Features and capabilities this app provides.`),protocolVersion:J().describe(`Protocol version this app supports.`)})});Z({protocolVersion:J().describe(`Negotiated protocol version string (e.g., "2025-11-21").`),hostInfo:Sj.describe(`Host application identification and version.`),hostCapabilities:ZN.describe(`Features and capabilities provided by the host.`),hostContext:iP.describe(`Rich context about the host environment.`)}).passthrough();var sP=[LN],cP=class extends IN{_client;_hostInfo;_capabilities;_appCapabilities;_hostContext={};_appInfo;_initializedReceived=!1;_baseReplaceRequestHandler=this.replaceRequestHandler;replaceRequestHandler=(e,t)=>{this._baseReplaceRequestHandler(e,(e,n)=>(this._initializedReceived||console.warn(`[ext-apps] AppBridge received '${e.method}' before ui/notifications/initialized. The View is calling host methods before completing the handshake; it should await app.connect() first.`),t(e,n)))};eventSchemas={sizechange:GN,sandboxready:HN,initialized:$N,requestteardown:XN,loggingmessage:YM};constructor(e,t,n,r){super(r),this._client=e,this._hostInfo=t,this._capabilities=n,this.addEventListener(`initialized`,()=>{this._initializedReceived=!0}),this._hostContext=r?.hostContext||{},this.setRequestHandler(oP,e=>this._oninitialize(e)),this.setRequestHandler(Mj,(e,t)=>(this.onping?.(e.params,t),{})),this.replaceRequestHandler(eP,e=>({mode:this._hostContext.displayMode??`inline`}))}getAppCapabilities(){return this._appCapabilities}getAppVersion(){return this._appInfo}onping;get onsizechange(){return this.getEventHandler(`sizechange`)}set onsizechange(e){this.setEventHandler(`sizechange`,e)}get onsandboxready(){return this.getEventHandler(`sandboxready`)}set onsandboxready(e){this.setEventHandler(`sandboxready`,e)}get oninitialized(){return this.getEventHandler(`initialized`)}set oninitialized(e){this.setEventHandler(`initialized`,e)}_onmessage;get onmessage(){return this._onmessage}set onmessage(e){this.warnIfRequestHandlerReplaced(`onmessage`,this._onmessage,e),this._onmessage=e,this.replaceRequestHandler(rP,async(e,t)=>{if(!this._onmessage)throw Error(`No onmessage handler set`);return this._onmessage(e.params,t)})}_onopenlink;get onopenlink(){return this._onopenlink}set onopenlink(e){this.warnIfRequestHandlerReplaced(`onopenlink`,this._onopenlink,e),this._onopenlink=e,this.replaceRequestHandler(VN,async(e,t)=>{if(!this._onopenlink)throw Error(`No onopenlink handler set`);return this._onopenlink(e.params,t)})}_ondownloadfile;get ondownloadfile(){return this._ondownloadfile}set ondownloadfile(e){this.warnIfRequestHandlerReplaced(`ondownloadfile`,this._ondownloadfile,e),this._ondownloadfile=e,this.replaceRequestHandler(nP,async(e,t)=>{if(!this._ondownloadfile)throw Error(`No ondownloadfile handler set`);return this._ondownloadfile(e.params,t)})}get onrequestteardown(){return this.getEventHandler(`requestteardown`)}set onrequestteardown(e){this.setEventHandler(`requestteardown`,e)}_onrequestdisplaymode;get onrequestdisplaymode(){return this._onrequestdisplaymode}set onrequestdisplaymode(e){this.warnIfRequestHandlerReplaced(`onrequestdisplaymode`,this._onrequestdisplaymode,e),this._onrequestdisplaymode=e,this.replaceRequestHandler(eP,async(e,t)=>{if(!this._onrequestdisplaymode)throw Error(`No onrequestdisplaymode handler set`);return this._onrequestdisplaymode(e.params,t)})}get onloggingmessage(){return this.getEventHandler(`loggingmessage`)}set onloggingmessage(e){this.setEventHandler(`loggingmessage`,e)}_onupdatemodelcontext;get onupdatemodelcontext(){return this._onupdatemodelcontext}set onupdatemodelcontext(e){this.warnIfRequestHandlerReplaced(`onupdatemodelcontext`,this._onupdatemodelcontext,e),this._onupdatemodelcontext=e,this.replaceRequestHandler(aP,async(e,t)=>{if(!this._onupdatemodelcontext)throw Error(`No onupdatemodelcontext handler set`);return this._onupdatemodelcontext(e.params,t)})}_oncalltool;get oncalltool(){return this._oncalltool}set oncalltool(e){this.warnIfRequestHandlerReplaced(`oncalltool`,this._oncalltool,e),this._oncalltool=e,this.replaceRequestHandler(UM,async(e,t)=>{if(!this._oncalltool)throw Error(`No oncalltool handler set`);return this._oncalltool(e.params,t)})}set oncreatesamplingmessage(e){this.setRequestHandler(rN,async(t,n)=>e(t.params,n))}sendToolListChanged(e={}){return this.notification({method:`notifications/tools/list_changed`,params:e})}_onlistresources;get onlistresources(){return this._onlistresources}set onlistresources(e){this.warnIfRequestHandlerReplaced(`onlistresources`,this._onlistresources,e),this._onlistresources=e,this.replaceRequestHandler(aM,async(e,t)=>{if(!this._onlistresources)throw Error(`No onlistresources handler set`);return this._onlistresources(e.params,t)})}_onlistresourcetemplates;get onlistresourcetemplates(){return this._onlistresourcetemplates}set onlistresourcetemplates(e){this.warnIfRequestHandlerReplaced(`onlistresourcetemplates`,this._onlistresourcetemplates,e),this._onlistresourcetemplates=e,this.replaceRequestHandler(sM,async(e,t)=>{if(!this._onlistresourcetemplates)throw Error(`No onlistresourcetemplates handler set`);return this._onlistresourcetemplates(e.params,t)})}_onreadresource;get onreadresource(){return this._onreadresource}set onreadresource(e){this.warnIfRequestHandlerReplaced(`onreadresource`,this._onreadresource,e),this._onreadresource=e,this.replaceRequestHandler(dM,async(e,t)=>{if(!this._onreadresource)throw Error(`No onreadresource handler set`);return this._onreadresource(e.params,t)})}sendResourceListChanged(e={}){return this.notification({method:`notifications/resources/list_changed`,params:e})}_onlistprompts;get onlistprompts(){return this._onlistprompts}set onlistprompts(e){this.warnIfRequestHandlerReplaced(`onlistprompts`,this._onlistprompts,e),this._onlistprompts=e,this.replaceRequestHandler(SM,async(e,t)=>{if(!this._onlistprompts)throw Error(`No onlistprompts handler set`);return this._onlistprompts(e.params,t)})}sendPromptListChanged(e={}){return this.notification({method:`notifications/prompts/list_changed`,params:e})}assertCapabilityForMethod(e){}assertRequestHandlerCapability(e){}assertNotificationCapability(e){}assertTaskCapability(e){throw Error(`Tasks are not supported in MCP Apps`)}assertTaskHandlerCapability(e){throw Error(`Task handlers are not supported in MCP Apps`)}getCapabilities(){return this._capabilities}async _oninitialize(e){let t=e.params.protocolVersion;return this._appInfo!==void 0&&console.warn(`[ext-apps] AppBridge received a second ui/initialize. The View may be double-mounting (e.g. React StrictMode in dev) without closing the previous App instance. Responding normally; the latest appInfo/appCapabilities replace the previous values.`),this._appCapabilities=e.params.appCapabilities,this._appInfo=e.params.appInfo,{protocolVersion:sP.includes(t)?t:LN,hostCapabilities:this.getCapabilities(),hostInfo:this._hostInfo,hostContext:this._hostContext}}setHostContext(e){let t={},n=!1;for(let r of Object.keys(e)){let i=this._hostContext[r],a=e[r];lP(i,a)||(t[r]=a,n=!0)}n&&(this._hostContext=e,this.sendHostContextChange(t))}sendHostContextChange(e){return this.notification({method:`ui/notifications/host-context-changed`,params:e})}sendToolInput(e){return this.notification({method:`ui/notifications/tool-input`,params:e})}sendToolInputPartial(e){return this.notification({method:`ui/notifications/tool-input-partial`,params:e})}sendToolResult(e){return this.notification({method:`ui/notifications/tool-result`,params:e})}sendToolCancelled(e){return this.notification({method:`ui/notifications/tool-cancelled`,params:e})}sendSandboxResourceReady(e){return this.notification({method:`ui/notifications/sandbox-resource-ready`,params:e})}teardownResource(e,t){return this.request({method:`ui/resource-teardown`,params:e},JN,t)}sendResourceTeardown=this.teardownResource;callTool(e,t){return this.request({method:`tools/call`,params:e},VM,t)}listTools(e,t){return this.request({method:`tools/list`,params:e},BM,t)}async connect(e){if(this.transport)throw Error(`AppBridge is already connected. Call close() before connecting again.`);if(this._initializedReceived=!1,this._client){let e=this._client.getServerCapabilities();if(!e)throw Error(`Client server capabilities not available`);e.tools&&(this.oncalltool=async(e,t)=>this._client.request({method:`tools/call`,params:e},VM,{signal:t.signal}),e.tools.listChanged&&this._client.setNotificationHandler(WM,e=>this.sendToolListChanged(e.params))),e.resources&&(this.onlistresources=async(e,t)=>this._client.request({method:`resources/list`,params:e},oM,{signal:t.signal}),this.onlistresourcetemplates=async(e,t)=>this._client.request({method:`resources/templates/list`,params:e},cM,{signal:t.signal}),this.onreadresource=async(e,t)=>this._client.request({method:`resources/read`,params:e},fM,{signal:t.signal}),e.resources.listChanged&&this._client.setNotificationHandler(pM,e=>this.sendResourceListChanged(e.params))),e.prompts&&(this.onlistprompts=async(e,t)=>this._client.request({method:`prompts/list`,params:e},CM,{signal:t.signal}),e.prompts.listChanged&&this._client.setNotificationHandler(FM,e=>this.sendPromptListChanged(e.params)))}return super.connect(e)}};function lP(e,t){return JSON.stringify(e)===JSON.stringify(t)}function uP(){let e=pt(Cv);if(!e)throw Error(`useTheme must be used within ThemeProvider`);return e}function dP({state:e}){return e.enabled?A(`details`,{class:`pointer-events-auto w-full max-w-md rounded-lg border border-base-300 bg-base-100/95 p-2 text-xs shadow-lg backdrop-blur`,children:[A(`summary`,{class:`cursor-pointer font-medium`,children:`Magic Canvas debug`}),A(`dl`,{class:`mt-2 grid gap-2`,children:[A(fP,{label:`iframe`,value:e.iframeLifecycleState}),A(fP,{label:`post`,value:e.lastInteractionPostResult}),A(fP,{label:`context`,value:e.lastModelContextUpdate}),A(fP,{label:`error`,value:e.lastError}),A(pP,{label:`tool_call`,value:e.lastToolCall}),A(pP,{label:`canvas_config`,value:e.parsedCanvasConfig})]})]}):null}function fP({label:e,value:t}){return t?A(`div`,{children:[A(`dt`,{class:`font-semibold`,children:e}),A(`dd`,{class:`break-words text-base-content/70`,children:t})]}):null}function pP({label:e,value:t}){return t===void 0?null:A(`div`,{children:[A(`dt`,{class:`font-semibold`,children:e}),A(`dd`,{children:A(`pre`,{class:`max-h-40 overflow-auto rounded bg-base-200 p-2 text-[10px] leading-relaxed`,children:JSON.stringify(t,null,2)})})]})}var mP=1e3,hP=5e3,gP=1200,_P=48,vP=`allow-scripts`,yP={"canvas.scheduling_embed":`allow-scripts allow-same-origin allow-popups allow-forms`};function bP(e,t){if(!t.contentWindow||e.source!==t.contentWindow)return!1;let n=e.data;return!!n&&typeof n==`object`&&n?.jsonrpc===`2.0`}var xP=class{onmessage;onerror;onclose;#e;#t;constructor(e){this.#e=e}start(){let e=e=>{bP(e,this.#e)&&this.onmessage?.(e.data)};return this.#t=e,globalThis.addEventListener(`message`,e),Promise.resolve()}send(e){return this.#e.contentWindow?.postMessage(e,`*`),Promise.resolve()}close(){return this.#t&&globalThis.removeEventListener(`message`,this.#t),this.#t=void 0,this.onclose?.(),Promise.resolve()}};function SP(e){for(let t of Wx)if(e.some(e=>LP(e)===t))return t;return null}function CP({onLayoutEffectChange:e,onRenderedSlotChange:t,debugEnabled:n=RP()}={}){let{client:r}=ev(),{dataTheme:i,cssVars:a}=uP(),o=ph(),s=Bg(),[c,l]=T([]),[u,d]=MP(),[f,p]=T(()=>({enabled:n,iframeLifecycleState:`idle`})),m=k(e=>{p(t=>({...t,...e}))},[]),h=k((e,t=`*`)=>{if(s!==`joined-meeting`){m({lastError:`Dropped Magic Canvas app message because the Daily meeting is not joined.`});return}o?.sendAppMessage(e,t)},[o,s,m]),g=O(()=>({theme:i.value===`dark`?`dark`:`light`,cssVars:a.value}),[i.value,a.value]);E(()=>{p(e=>e.enabled===n?e:{...e,enabled:n})},[n]),Qg({onAppMessage:k(e=>{if(s!==`joined-meeting`){m({lastToolCall:e.data,iframeLifecycleState:`idle`,lastError:`Dropped Magic Canvas tool call because the Daily meeting is not joined.`});return}try{let t=LS(e.data);if(!t)return;l(e=>nS(e,t)),m({lastToolCall:e.data,parsedCanvasConfig:t.kind===`show`?t.instance.canvas_config:void 0,iframeLifecycleState:t.kind===`clear`?`closed`:`received`,lastError:void 0})}catch(e){m({iframeLifecycleState:`error`,lastError:VP(e).message})}},[s,m])});let _=c.map(e=>({instance:e,layout:lS(e,d)})),v=uS(_.map(({layout:e})=>e),d),y=[..._].reverse().find(({layout:e})=>e.display_mode===`fullscreen`)?.instance.tool_call_id;E(()=>{e?.(v)},[e,v.active,v.side,v.video_shift_x,v.backdrop.type,v.safe_area?.x,v.safe_area?.y,v.safe_area?.width,v.safe_area?.height]);let b=SP(_.map(({layout:e})=>e));E(()=>{t?.(b)},[t,b]);let x=c.length>0||f.enabled;return A(`div`,{ref:u,"data-magic-canvas-root":!0,class:`pointer-events-none absolute inset-0 z-30`,children:[x&&y&&A(`div`,{class:`absolute inset-0 bg-black/45`}),x&&Wx.map(e=>{let t=_.filter(({layout:t})=>LP(t)===e);return t.length===0?null:A(TP,{slot:e,safeAreaTop:v.safe_area?.y,frameWidth:d.width,children:e=>t.map(({instance:t,layout:n})=>A(EP,{availableHeight:e,client:r,hostTheme:g,instance:t,layout:n,dimmed:!!(y&&y!==t.tool_call_id),onDebug:m,onComplete:()=>{l(e=>e.filter(e=>e.id!==t.id))},onDisplayModeChange:e=>{l(n=>n.map(n=>n.tool_call_id===t.tool_call_id?{...n,layout:{...n.layout,display_mode:e}}:n))},sendAppMessage:h},t.id))},e)}),x&&A(`div`,{class:`absolute right-4 bottom-24 @max-mobile:right-3 @max-mobile:bottom-20`,children:A(dP,{state:f})})]})}var wP=16;function TP({slot:e,safeAreaTop:t,frameWidth:n,children:r}){let[i,a]=NP(),o=r(e===`full`?void 0:a);if(e===`safe-area-left`||e===`safe-area-right`){let r=t==null?`1rem`:`${t*100}%`,a=n!=null&&n>0?Math.max(0,n-wP*2):void 0;return A(`div`,{ref:i,class:IP(e),style:{top:r,bottom:`${FP}px`,maxWidth:a},"data-canvas-slot":e,children:A(`div`,{class:`my-auto flex w-full flex-col gap-2`,children:o})})}return A(`div`,{ref:i,class:IP(e),"data-canvas-slot":e,children:o})}function EP({availableHeight:e,client:t,hostTheme:n,instance:r,layout:i,dimmed:a,onDebug:o,onComplete:s,onDisplayModeChange:c,sendAppMessage:l}){let u=D(null),d=D(null),f=D(e),p=D(320),m=D(n),h=D(r),g=D(i),_=D(-1),v=D(s),y=D(c),b=D(l),[x,S]=T(320);E(()=>{h.current=r},[r]),E(()=>{p.current=x,d.current?.setHostContext(AP(h.current,m.current,g.current,f.current,x))},[x]),E(()=>{f.current=e;let t=kP(n,u.current);m.current=t,d.current?.setHostContext(AP(h.current,t,g.current,e,p.current))},[e,n]),E(()=>{g.current=i,d.current?.setHostContext(AP(h.current,m.current,i,e,p.current))},[e,i]),E(()=>{v.current=s,y.current=c,b.current=l},[s,c,l]),E(()=>{let e=u.current;if(!e)return;let n=!1,i=null,a=null,s=null,c=null,l=new URL(r.canvas_config.sandbox_url,globalThis.location.href).href,x=e=>{n||o({iframeLifecycleState:`error`,lastError:VP(e).message})},C=()=>{if(n||!a)return;let e=h.current,t=sS(e,a);a=null,b.current({message_type:`conversation`,event_type:`conversation.append_llm_context`,conversation_id:e.conversation_id,properties:{context:t}}),o({lastModelContextUpdate:e.canvas_config.component,lastError:void 0})},w=()=>{if(i)return;if(e.src!==l){e.src;return}if(n||!e.contentWindow)return;let u=new cP(null,{name:`tavus-deployment`,version:`0.0.0`},{logging:{},message:{text:{},structuredContent:{}},updateModelContext:{text:{},structuredContent:{}}},{hostContext:AP(r,kP(m.current,e),g.current,f.current,p.current)});i=u,d.current=u,u.oninitialized=()=>{n||(o({iframeLifecycleState:`ready`}),_.current=h.current.revision,u.sendToolInput({arguments:h.current.arguments}).catch(x))},u.onsizechange=({height:e})=>{!n&&typeof e==`number`&&Number.isFinite(e)&&S(Math.min(Math.max(e,_P),720))},u.onmessage=async e=>{let r=rS(e),i=oS(e);if(!r){if(i){let e=`Magic Canvas message included text without interaction metadata; no interaction row was recorded.`;return o({lastInteractionPostResult:`error`,lastError:e}),{isError:!0,code:`missing_interaction_metadata`,message:e}}return{}}try{let e=h.current,a=iS(e,r),s=RS(a),l=new AbortController,u=globalThis.setTimeout(()=>l.abort(),hP);try{await En(t,a.conversation_id,s.body,{signal:l.signal})}finally{globalThis.clearTimeout(u)}if(n)return{};i&&b.current({message_type:`conversation`,event_type:`conversation.respond`,conversation_id:e.conversation_id,properties:{text:i}}),o({lastInteractionPostResult:`success`,lastError:void 0}),aS(a)&&(a.type===`submit`?(c&&clearTimeout(c),c=setTimeout(()=>{c=null,n||v.current()},gP)):v.current())}catch(e){let t=VP(e).message;return o({lastInteractionPostResult:`error`,lastError:t}),{isError:!0,code:`interaction_post_failed`,message:t}}return{}},u.onupdatemodelcontext=async e=>(a=e,s||=setTimeout(()=>{s=null,C()},mP),{}),u.onrequestdisplaymode=async({mode:e})=>{let t=e===`fullscreen`?`fullscreen`:`inline`;return y.current(t),g.current={...g.current,display_mode:t,viable_slot:t===`fullscreen`?`full`:g.current.viable_slot},u.setHostContext(AP(h.current,m.current,g.current,f.current,p.current)),{mode:t}},u.connect(new xP(e)).then(()=>void 0).catch(x)};o({iframeLifecycleState:`mounting`,lastInteractionPostResult:void 0}),r.canvas_config.sandbox_url,e.src=r.canvas_config.sandbox_url;let ee=()=>{w()};return e.addEventListener(`load`,ee),w(),()=>{s&&=(clearTimeout(s),null),c&&=(clearTimeout(c),null),C(),n=!0,e.removeEventListener(`load`,ee),d.current=null,o({iframeLifecycleState:`closed`}),i&&Hx(i)}},[t,r.id,r.canvas_config.sandbox_url,o]),E(()=>{r.revision!==0&&(r.revision<=_.current||(_.current=r.revision,d.current?.sendToolInput({arguments:r.arguments}).catch(e=>{o({iframeLifecycleState:`error`,lastError:VP(e).message})})))},[r.arguments,r.revision,o]);let C=i.viable_slot===`full`||i.display_mode===`fullscreen`,w=C?null:jP(x,e),ee=w?.placeholderStyle,te=w?.cardStyle,ne=C?{height:`100%`}:w?.iframeStyle??{height:`${x}px`},re=[`pointer-events-auto w-full overflow-hidden rounded-lg border border-base-300 bg-base-100 shadow-xl transition-[opacity,transform]`,C?`fixed inset-4 z-10 max-w-none`:`max-w-md`,a?`scale-[0.98] opacity-40`:``].filter(Boolean).join(` `),ie=yP[r.canvas_config.component]??vP,ae=A(`div`,{class:re,style:te,"data-canvas-card":i.viable_slot,children:A(`iframe`,{ref:u,title:`${r.canvas_config.component} ${r.canvas_config.component_version}`,class:C?`block h-full w-full border-0 bg-transparent`:`block border-0 bg-transparent`,sandbox:ie,style:ne})});return C?ae:A(`div`,{class:`block w-full`,style:ee,children:ae})}var DP=[`--color-base-100`,`--color-base-200`,`--color-base-300`,`--color-base-content`,`--color-primary`,`--color-error`];function OP(e){if(!e||typeof getComputedStyle!=`function`)return{};let t=getComputedStyle(e),n={};for(let e of DP){let r=t.getPropertyValue(e).trim();r&&(n[e]=r)}return n}function kP(e,t){let n=OP(t);return Object.keys(n).length===0?e:{...e,cssVars:{...e.cssVars,...n}}}function AP(e,t,n,r,i){let a=zS(t,n),o=n.viable_slot===`full`||n.display_mode===`fullscreen`,s=o?void 0:zP(r),c=o?1:jP(i??0,r)?.displayScale??1;return{...e.canvas_config.host_context,...a,containerDimensions:{...BP(a.containerDimensions)?a.containerDimensions:{},...s===void 0?{}:{maxHeight:s},displayScale:c}}}function jP(e,t){if(t===void 0||!Number.isFinite(t)||t<=0)return null;let n=Math.min(e,720);if(n<=t)return{displayScale:1,placeholderStyle:{maxHeight:`${t}px`},cardStyle:void 0,iframeStyle:{width:`100%`,height:`${n}px`}};let r=t/n;return r>=.85?{displayScale:r,placeholderStyle:{height:`${n*r}px`,maxHeight:`${t}px`,overflow:`hidden`},cardStyle:{height:`${n}px`,transform:`scale(${r})`,transformOrigin:`top center`},iframeStyle:{width:`100%`,height:`${n}px`}}:{displayScale:1,placeholderStyle:{maxHeight:`${t}px`},cardStyle:void 0,iframeStyle:{width:`100%`,height:`${t}px`}}}function MP(){let e=D(null),[t,n]=T(()=>PP(null));return E(()=>{let t=()=>n(t=>{let n=PP(e.current);return t.width===n.width&&t.height===n.height&&t.visualViewportHeight===n.visualViewportHeight?t:n});t(),globalThis.addEventListener(`resize`,t),globalThis.visualViewport?.addEventListener(`resize`,t);let r;return typeof ResizeObserver<`u`&&e.current&&(r=new ResizeObserver(t),r.observe(e.current)),()=>{globalThis.removeEventListener(`resize`,t),globalThis.visualViewport?.removeEventListener(`resize`,t),r?.disconnect()}},[]),[e,t]}function NP(){let e=D(null),[t,n]=T();return E(()=>{let t=e.current;if(!t)return;let r=e=>{let r=e??t.getBoundingClientRect().height;!Number.isFinite(r)||r<=0||n(Math.floor(r))},i=()=>r();if(i(),typeof ResizeObserver>`u`)return globalThis.addEventListener(`resize`,i),()=>globalThis.removeEventListener(`resize`,i);let a=new ResizeObserver(e=>{r(e[0]?.contentRect.height)});return a.observe(t),()=>a.disconnect()},[]),[e,t]}function PP(e){let t=globalThis.visualViewport?.height,n=e?.getBoundingClientRect();if(n&&n.width>0&&n.height>0){let e=t===void 0?void 0:Math.max(0,(globalThis.innerHeight||0)-t);return{width:n.width,height:n.height,visualViewportHeight:e===void 0?void 0:Math.max(0,n.height-e)}}return{width:globalThis.innerWidth||1024,height:globalThis.innerHeight||768,visualViewportHeight:t}}var FP=72;function IP(e){let t=`absolute flex gap-2`;switch(e){case`safe-area-left`:return`${t} left-4 w-[28rem] flex-col overflow-y-auto`;case`safe-area-right`:return`${t} right-4 w-[28rem] flex-col overflow-y-auto`;case`safe-area-bottom`:return`${t} right-4 bottom-24 left-4 flex-col items-center justify-end @max-mobile:right-3 @max-mobile:bottom-20 @max-mobile:left-3`;case`full`:return`${t} inset-4 flex-col items-stretch justify-stretch`}}function LP(e){return e.display_mode===`fullscreen`&&e.preferred_slot!==`full`?e.preferred_slot:e.viable_slot}function RP(){return!1}function zP(e){return e===void 0||!Number.isFinite(e)||e<=0?720:Math.min(Math.floor(e),720)}function BP(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function VP(e){return e instanceof Error?e:Error(String(e))}var HP=1e4;function UP({onTimeout:e,timeoutMs:t=HP,active:n=!0}){let r=Dx().length>0,[i,a]=T(!1),o=D(e);return E(()=>{o.current=e},[e]),E(()=>{if(!n||r){a(!1);return}let e=setTimeout(()=>{a(!0),o.current()},t);return()=>clearTimeout(e)},[n,r,t]),{hasJoined:r,timedOut:i}}function WP(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.message_type===`system`&&t.event_type===`system.shutdown`}function GP({onShutdown:e}){let t=D(e);E(()=>{t.current=e},[e]),Qg({onAppMessage:k(e=>{WP(e?.data)&&t.current()},[])})}function KP(){let e=ph();return{joinCall:k(({url:t,micOnly:n=!1})=>{e?.join(n?{url:t,videoSource:!1}:{url:t})},[e]),leaveCall:k(()=>{e?.leave()},[e])}}var qP=yn(`PiP`),JP=360,YP=280;function XP(){return globalThis.window!==void 0&&`documentPictureInPicture`in globalThis.window}function ZP(e){let{enabled:t,active:n}=e,[r,i]=T(null),a=XP(),o=pt(Cv),s=k(()=>{i(e=>(e&&!e.closed&&e.close(),null))},[]),c=k(async()=>{if(a&&!(!t||!n)&&!(r&&!r.closed))try{let e=await globalThis.window.documentPictureInPicture.requestWindow({width:JP,height:YP}),t=Ye.replace(/:host(?=[\s,{])/g,`:host, :root`),n=e.document.createElement(`style`);n.textContent=t,e.document.head.appendChild(n),e.document.body.style.margin=`0`,e.document.body.style.width=`100%`,e.document.body.style.height=`100vh`,e.document.body.style.overflow=`hidden`,e.addEventListener(`pagehide`,()=>{i(t=>t===e?null:t)},{once:!0}),i(e)}catch(e){qP.warn(`Failed to open PiP window`,e)}},[a,t,n,r]);return E(()=>{if(!t||!a||!n)return;let e=()=>{document.visibilityState===`hidden`?c():document.visibilityState===`visible`&&s()};document.addEventListener(`visibilitychange`,e);let r=[],i=null,o=`none`,l=!1;if(typeof navigator<`u`&&`mediaSession`in navigator){let e=navigator.mediaSession;i=e.metadata,o=e.playbackState;try{e.metadata=new MediaMetadata({title:`Tavus conversation`}),e.playbackState=`playing`,l=!0}catch(e){qP.warn(`mediaSession metadata setup failed`,e)}let t=(t,n)=>{try{e.setActionHandler(t,n),r.push(t)}catch(e){qP.warn(`mediaSession.${t} not supported`,e)}};t(`enterpictureinpicture`,()=>{c()}),t(`play`,()=>{}),t(`pause`,()=>{})}return()=>{if(document.removeEventListener(`visibilitychange`,e),typeof navigator<`u`&&`mediaSession`in navigator){let e=navigator.mediaSession;for(let t of r)try{e.setActionHandler(t,null)}catch{}if(l)try{e.metadata=i,e.playbackState=o}catch{}}}},[t,a,n,c,s]),E(()=>{(!n||!t)&&r&&!r.closed&&s()},[n,t,r,s]),E(()=>()=>{r&&!r.closed&&r.close()},[r]),E(()=>{if(!r||r.closed||!o)return;let e=()=>{r.document.body.setAttribute(`data-theme`,o.dataTheme.value);let e=o.cssVars.value;for(let[t,n]of Object.entries(e))r.document.body.style.setProperty(t,n)};e();let t=o.dataTheme.subscribe(()=>e()),n=o.cssVars.subscribe(()=>e());return()=>{t(),n()}},[r,o]),{pipWindow:r,isSupported:a,requestPipWindow:c,closePipWindow:s}}var QP=Wt(null),$P={active:!1,video_shift_x:0,backdrop:{type:`snapshot_mirror`}},eF=ya(({id:e,showAudioWave:t=!0})=>{let n=d_(e).isOff;return A(`div`,{class:`relative aspect-square w-32 @max-mobile:w-24 rounded-box overflow-hidden bg-black/30 z-10 ${n?`hidden`:``}`,children:[A(dg,{automirror:!0,sessionId:e,type:`video`,fit:`cover`,className:`w-full h-full object-cover ${n?`hidden`:``}`}),t&&A(`div`,{class:`absolute bottom-2 right-2`,children:A(bx,{id:e})})]})}),tF=ya(()=>{let e=Zh(),{isScreenSharing:t}=Ob(),n=Dx()[0];return A(ue,{children:[t&&n&&A(eF,{id:n}),e&&A(eF,{id:e,showAudioWave:!1})]})}),nF=ya(()=>A(`div`,{class:`absolute top-4 left-4 flex flex-col items-end gap-2 z-20`,children:A(tF,{})})),rF=ya(({isAudioOnly:e,canvasLayoutEffect:t,canvasRenderedSlot:n})=>{let r=Zh(),i=!l_(r??``).isOff,a=Ox(e),o=l_(a.phase===`ready`?a.replicaId:``),s=!i&&(o.state===`playable`||o.state===`loading`),c=t.active&&!i&&(!e||s);return a.phase===`left`?A(vx,{}):a.phase===`connecting`?A(_x,{}):e&&!s?A(`div`,{class:`absolute inset-0 flex items-center justify-center`,children:[A(wx,{sessionId:a.replicaId}),A(lg,{sessionId:a.replicaId})]}):A(ue,{children:[s?A(vC,{personaSessionId:a.replicaId,isAudioOnly:e,avatarOff:a.videoState.isOff,canvasLayoutEffect:t,smartSidecarActive:c}):A(iF,{personaSessionId:a.replicaId,localId:r,isScreenSharing:i,avatarOff:a.videoState.isOff,smartSidecarActive:c,canvasLayoutEffect:t,canvasRenderedSlot:n}),A(lg,{sessionId:a.replicaId})]})}),iF=ya(({personaSessionId:e,localId:t,isScreenSharing:n,avatarOff:r,smartSidecarActive:i,canvasLayoutEffect:a,canvasRenderedSlot:o})=>A(gC,{canvasLayoutEffect:a,smartSidecarActive:i,isScreenSharing:n,captureSnapshot:cF,personaMode:`auto`,renderedSlot:o,fill:i=>A(Mx,{personaSessionId:e,localSessionId:t,isScreenSharing:n,avatarOff:r,videoRef:i})})),aF=ya(({items:e})=>{let[t,n]=T(!1),r=D(null);return E(()=>{if(!t)return;let e=e=>{r.current&&!e.composedPath().includes(r.current)&&n(!1)},i=e=>{e.key===`Escape`&&n(!1)};return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,i),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,i)}},[t]),A(`div`,{ref:r,class:`relative`,children:[A(`button`,{type:`button`,onClick:()=>n(e=>!e),"aria-pressed":t,"aria-expanded":t,"aria-haspopup":`true`,"aria-label":t?`Close more controls`:`More controls`,class:`btn btn-control ${t?`btn-primary`:`btn-neutral`}`,children:A(Qy,{name:`more`})}),t&&A(`div`,{role:`menu`,class:`absolute bottom-full mb-1 left-1/2 -translate-x-1/2 flex flex-row items-center gap-1 p-1 rounded-box bg-base-100 border border-base-300 shadow-lg z-30 whitespace-nowrap`,children:e})]})}),oF=ya(({items:e})=>e.length<=1?A(ue,{children:e}):A(aF,{items:e})),sF=ya(({onLeave:e})=>{let{joinCall:t,leaveCall:n}=KP(),r=Bg(),{config:i}=ev(),{session:a,end:o}=ix(),s=Zh(),c=D(null),l=pt(Wv)?.frameRef??c,[u,d]=T(!1),[f,p]=T(!1),[m,h]=T($P),[g,_]=T(null),v=a.value?.conversationUrl,y=i.value.customization.conversation,b=y.modality===`audio`,x=y.enable_chat,S=y.enable_closed_captions,C=y.enable_picture_in_picture,{pipWindow:w}=ZP({enabled:C,active:r===`joined-meeting`});E(()=>(v&&t({url:v,micOnly:!s}),()=>{n()}),[]);let{camera:ee,requestCamera:te}=Nb(),{isCamMuted:ne}=Eb(),re=ee.isGranted&&!ne;E(()=>{!b&&r===`joined-meeting`&&(QP.value=re)},[b,r,re]);let ie=D(!b&&!s&&QP.value===!0);E(()=>{r===`joined-meeting`&&ie.current&&(ie.current=!1,te())},[r,te]),E(()=>{(r===`left-meeting`||r===`error`)&&e()},[r,e]),E(()=>{let e=()=>{let e=l.current,t=e?.getRootNode(),n=t instanceof Document||t instanceof ShadowRoot?t:null;d(!!e&&n?.fullscreenElement===e)};return document.addEventListener(`fullscreenchange`,e),()=>document.removeEventListener(`fullscreenchange`,e)},[]);let ae=k(()=>{let e=l.current;if(!e)return;let t=e.getRootNode();(t instanceof Document||t instanceof ShadowRoot?t:null)?.fullscreenElement===e?document.exitFullscreen?.():e.requestFullscreen?.()},[]);k(()=>{p(e=>!e)},[]);let oe=k(()=>{o(),n()},[o]);if(UP({active:r===`joined-meeting`,onTimeout:oe}),GP({onShutdown:oe}),!v)return null;let se=[A(rx,{compact:!0},`screen-share`)];x&&se.push(A(px,{compact:!0},`chat`));let ce=r===`left-meeting`;return A(ox,{children:A(dx,{children:A(Bb,{children:[A(`div`,{class:`cvi-call-surface absolute inset-0`,children:[A(`div`,{class:`relative w-full h-full z-[5]`,children:[A(rF,{isAudioOnly:b,canvasLayoutEffect:m,canvasRenderedSlot:g}),!b&&A(nF,{}),A(lx,{}),A(CP,{debugEnabled:f,onLayoutEffectChange:h,onRenderedSlotChange:_}),A(`div`,{class:`cvi-autohide absolute top-4 right-4 z-20`,"data-hidden":ce,children:A(yx,{active:u,onToggle:ae,compact:!0})})]}),A(hx,{}),A(`div`,{class:`cvi-autohide cvi-autohide-slide pointer-events-none absolute bottom-6 left-0 right-0 z-20`,"data-hidden":ce,"aria-hidden":ce,children:A(`div`,{class:`cvi-control-rail flex justify-center items-center gap-2 @max-mobile:gap-1`,"data-hidden":ce,children:[A(Qb,{level:!0}),!b&&A(ex,{}),S&&A(cx,{}),A(oF,{items:se}),A(`button`,{type:`button`,class:`btn btn-control btn-error`,onClick:oe,"aria-label":`Leave call`,children:A(Qy,{name:`leave`,"aria-label":`Leave Call`})})]})})]}),w&&Ia(A(Ax,{onLeave:oe}),w.document.body)]})})})});function cF(e){if(!e||e.readyState<2||!e.videoWidth||!e.videoHeight)return null;let t=document.createElement(`canvas`),n=Math.round(640*(e.videoHeight/e.videoWidth));t.width=640,t.height=n;let r=t.getContext(`2d`);if(!r)return null;r.drawImage(e,0,0,640,n);try{return t.toDataURL(`image/jpeg`,.82)}catch{return null}}function lF({loading:e=!1,disabled:t,class:n,children:r,...i}){return A(`button`,{type:`button`,class:`btn relative ${n?` ${n}`:``}`,disabled:t||e,"aria-busy":e||void 0,...i,children:[A(`span`,{children:r}),e&&A(`span`,{class:`absolute inset-0 flex items-center justify-center backdrop-blur-xs`,"aria-hidden":`true`,children:A(`span`,{class:`loading loading-spinner loading-sm`})})]})}function uF(e,t,n){switch(t){case`granted`:return n?e?.cameraOptional??`Camera is optional — turn it on anytime.`:e?.ready??`You're all set — join whenever you're ready.`;case`blocked`:return e?.denied??`Microphone is blocked. Click the mic to see how to allow it.`;case`in-use`:return`Your microphone is in use by another app. Close it and try again.`;case`not-found`:return`No microphone found. Connect one to continue.`;case`unsupported`:return`This browser can't access your microphone.`;case`prompt`:return e?.prompt??`Allow microphone access to join.`;default:return e?.loading??`Getting your microphone ready...`}}function dF({message:e}){return A(`div`,{class:`relative max-w-[min(20rem,90%)]`,children:[A(`div`,{class:`px-4 py-2 rounded-box bg-neutral text-neutral-content text-sm font-medium shadow-lg text-center`,role:`status`,"aria-live":`polite`,children:e}),A(`svg`,{class:`absolute left-1/2 -translate-x-1/2 top-full text-neutral`,width:`16`,height:`8`,viewBox:`0 0 16 8`,"aria-hidden":`true`,children:A(`path`,{d:`M0 0 L8 8 L16 0 Z`,fill:`currentColor`})})]})}var fF=ya(({text:e,isJoining:t=!1,onJoin:n,onCancel:r})=>{let i=ph(),{config:a}=ev(),{localSessionId:o,isCamMuted:s}=Eb(),{mic:c,camera:l,requestMic:u,requestCamera:d}=Nb(),f=a.value.customization.conversation.modality===`video`;E(()=>{u()},[]);let p=c.isGranted,m=D(!1);E(()=>{!f||!p||m.current||l.isGranted||l.isBlocked||(m.current=!0,d())},[f,p,l.isGranted,l.isBlocked,d]);let h=f&&p&&!l.isGranted,g=uF(e,c.status,h);return A(Bb,{children:A(`div`,{class:`absolute inset-0 motion-safe:animate-[tavusFadeUp_280ms_ease-out]`,children:[l.isGranted&&!s?A(`div`,{class:`absolute inset-0 flex items-center justify-center bg-black overflow-hidden`,children:A(dg,{type:`video`,sessionId:o??``,mirror:!0,fit:`cover`,className:`w-full h-full object-cover!`})}):A(`div`,{class:`absolute inset-0 flex items-center justify-center text-base-content/40`,children:A(Qy,{name:`face-smile`,size:`7rem`,"aria-label":`Camera off`})}),A(`div`,{class:`absolute bottom-6 left-1/2 -translate-x-1/2 z-10 flex flex-col items-center gap-2 max-w-[90%]`,children:[g&&A(dF,{message:g}),A(`div`,{class:`flex flex-wrap items-center justify-center gap-1.5 @max-mobile:gap-1`,children:[A(`div`,{class:`flex items-center justify-center gap-1.5 shrink-0 @max-mobile:gap-1`,children:[A(Qb,{level:!0}),f&&A(ex,{})]}),A(lF,{class:`btn-accent `,loading:t,disabled:!p,onClick:n,children:e?.join??`Join Video Chat`}),c.isBlocked&&A(`button`,{type:`button`,class:`btn btn-error `,onClick:()=>{i&&i.leave(),r?.()},children:e?.cancel??`Cancel`})]})]})]})})}),pF=`Password required`,mF=`Enter the password to start this conversation.`,hF=`Password`,gF=`Continue`;function _F({onSubmit:e,text:t,isSubmitting:n=!1,errorMessage:r}){let[i,a]=T(``),o=ht();return A(`div`,{class:`absolute inset-0 z-30 flex items-center justify-center bg-black/50 backdrop-blur-sm p-4`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`${o}-title`,children:A(`form`,{onSubmit:t=>{t.preventDefault();let r=i.trim();!r||n||e(r)},class:`card bg-base-100 shadow-xl w-full max-w-sm`,children:A(`div`,{class:`card-body gap-3`,children:[A(`h3`,{id:`${o}-title`,class:`card-title text-base-content`,children:t?.title??pF}),A(`p`,{class:`text-sm text-base-content/70`,children:t?.description??mF}),A(`input`,{id:o,type:`password`,autocomplete:`current-password`,class:`input input-bordered w-full`,placeholder:t?.placeholder??hF,value:i,disabled:n,onInput:e=>a(e.target.value),autoFocus:!0}),r&&A(`p`,{class:`text-error text-xs`,role:`alert`,children:r}),A(lF,{class:`btn-primary`,type:`submit`,disabled:!i.trim(),loading:n,children:t?.submit??gF})]})})})}var vF=yn(`CaptchaChallenge`),yF=1;function bF(e){return typeof e==`object`&&!!e&&e.source===`tavus-captcha`&&typeof e.type==`string`}function xF(e,t,n,r,i){return`${e.replace(/\/+$/,``)}${t.startsWith(`/`)?t:`/${t}`}?deployment_uuid=${encodeURIComponent(n)}&action=${encodeURIComponent(r)}&parent_origin=${encodeURIComponent(i)}`}function SF({captcha:e,deploymentId:t,onToken:n,onFallback:r}){let i=(pt(wt).baseUrl??`https://tavusapi.com`).replace(/\/+$/,``),a=new URL(i).origin,[o,s]=T(0),[c,l]=T(0),[u,d]=T(!1),[f,p]=T(!1),m=xF(i,e.challenge_path,t,e.action,window.location.origin),h=k(()=>{p(!1),s(e=>e+1)},[]);return E(()=>{function e(e){if(u||e.origin!==a)return;let i=e.data;if(bF(i)&&i.deployment_uuid===t){if(i.type===`interactive`){p(!0);return}if(i.type===`token`&&i.token){vF.info(`Captcha token received`),p(!1),n(i.token);return}if(i.type===`expired`){vF.info(`Captcha token expired, reloading iframe`),h();return}i.type===`error`&&(vF.warn(`Captcha error received`,i.code),c<yF?(l(e=>e+1),h()):(vF.warn(`Captcha error retries exhausted, falling back to no-token mode`),d(!0),r()))}}return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},[a,t,c,u,n,r,h]),u?null:A(`div`,{class:f?`absolute inset-0 z-30 flex items-center justify-center p-4 bg-base-100/70 backdrop-blur-sm animate-[tavusFadeUp_180ms_ease-out]`:`absolute top-0 left-0 w-0 h-0 overflow-hidden opacity-0 pointer-events-none`,"aria-hidden":!f,children:A(`iframe`,{src:m,sandbox:`allow-scripts allow-same-origin allow-forms allow-popups`,title:`Security challenge`,style:{border:`none`,width:`300px`,height:`65px`},scrolling:`no`},o)})}function CF({text:e,onStart:t,isStarting:n}){let{config:r,deploymentId:i}=ev(),a=pt(G_),o=rb(r.value),s=o.btn_title??e?.fallback_button??`Start the conversation`,c=r.value.customization.terms_content?.trim()??``,l=r.value.customization.terms_enabled===!0,u=c.length>0,d=u&&l,f=O(()=>d&&S_(i,c),[d,i,c]),p=d&&!f,m=r.value.has_password===!0,h=a?.password.value??null,g=m&&!h,_=r.value.captcha??null,{captchaReady:v,captchaEpoch:y,handleCaptchaToken:b,handleCaptchaFallback:x}=_v(_,a),S=ht(),[C,w]=T(f),ee=_!==null&&!v,te=n||d&&!C||g||ee;return A(fb,{title:o.title,description:o.description,overlay:A(ue,{children:[ee&&A(SF,{captcha:_,deploymentId:i,onToken:b,onFallback:x},y),g&&a?A(_F,{onSubmit:a.setPassword}):null]}),children:[A(lF,{class:`btn-neutral rounded-box`,onClick:()=>{d&&C&&!f&&T_(i,c),t()},disabled:te,loading:n,children:s}),u&&A(`div`,{class:`max-w-xs`,children:p?A(`label`,{for:S,class:`flex items-center gap-2 text-xs text-left cursor-pointer`,children:[A(`input`,{id:S,type:`checkbox`,class:`checkbox checkbox-secondary checkbox-xs mt-0.5 shrink-0`,checked:C,onChange:e=>w(e.target.checked)}),A(`span`,{class:`leading-snug`,children:c})]}):A(`p`,{class:`text-xs leading-snug text-base-content/60`,children:c})})]})}function wF({flow:e,welcomeText:t,onUnavailableCancel:n}){switch(e.state){case`idle`:return A(CF,{text:t,onStart:()=>{e.start()},isStarting:e.isStarting});case`haircheck`:return A(fF,{onJoin:()=>{e.join()},onCancel:()=>e.cancel(),isJoining:e.isStarting});case`call`:return A(sF,{onLeave:()=>e.leave()});case`ended`:return A(Tb,{onRestart:()=>e.restart()});case`unavailable`:return A(_b,{cause:e.unavailableCause??`busy`,canRetry:e.canRetry,onRetry:()=>{e.start()},onCancel:n});default:{let t=e.state;throw Error(`Unreachable flow state: ${String(t)}`)}}}function TF(){let{config:e,configError:t}=ev(),n=bb(),r=vb(),i=O(()=>({fallback_button:n.start_button}),[n.start_button]),a=e.value.is_available,o=e.value.unavailable_reason;return A(Gv,{children:t.value?A(_b,{cause:`error`,canRetry:!1,onRetry:()=>{}}):a===!1?A(_b,{cause:o??`daily_limit`,canRetry:!1,onRetry:()=>{}}):A(wF,{flow:r,welcomeText:i})})}var EF=`:host {
|
|
163
|
+
container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:J().optional().describe(`User's language and region preference in BCP 47 format.`),timeZone:J().optional().describe(`User's timezone in IANA format.`),userAgent:J().optional().describe(`Host application identifier.`),platform:Q([$(`web`),$(`desktop`),$(`mobile`)]).optional().describe(`Platform type for responsive design decisions.`),deviceCapabilities:Z({touch:bk().optional().describe(`Whether the device supports touch input.`),hover:bk().optional().describe(`Whether the device supports hover interactions.`)}).optional().describe(`Device input capabilities.`),safeAreaInsets:Z({top:Y().describe(`Top safe area inset in pixels.`),right:Y().describe(`Right safe area inset in pixels.`),bottom:Y().describe(`Bottom safe area inset in pixels.`),left:Y().describe(`Left safe area inset in pixels.`)}).optional().describe(`Mobile safe area boundaries in pixels.`)}).passthrough();Z({method:$(`ui/notifications/host-context-changed`),params:iP.describe(`Partial context update containing only changed fields.`)});var aP=Z({method:$(`ui/update-model-context`),params:Z({content:X(MM).optional().describe(`Context content blocks (text, image, etc.).`),structuredContent:Ok(J(),Ck().describe(`Structured content for machine-readable context data.`)).optional().describe(`Structured content for machine-readable context data.`)})}),oP=Z({method:$(`ui/initialize`),params:Z({appInfo:Sj.describe(`App identification (name and version).`),appCapabilities:QN.describe(`Features and capabilities this app provides.`),protocolVersion:J().describe(`Protocol version this app supports.`)})});Z({protocolVersion:J().describe(`Negotiated protocol version string (e.g., "2025-11-21").`),hostInfo:Sj.describe(`Host application identification and version.`),hostCapabilities:ZN.describe(`Features and capabilities provided by the host.`),hostContext:iP.describe(`Rich context about the host environment.`)}).passthrough();var sP=[LN],cP=class extends IN{_client;_hostInfo;_capabilities;_appCapabilities;_hostContext={};_appInfo;_initializedReceived=!1;_baseReplaceRequestHandler=this.replaceRequestHandler;replaceRequestHandler=(e,t)=>{this._baseReplaceRequestHandler(e,(e,n)=>(this._initializedReceived||console.warn(`[ext-apps] AppBridge received '${e.method}' before ui/notifications/initialized. The View is calling host methods before completing the handshake; it should await app.connect() first.`),t(e,n)))};eventSchemas={sizechange:GN,sandboxready:HN,initialized:$N,requestteardown:XN,loggingmessage:YM};constructor(e,t,n,r){super(r),this._client=e,this._hostInfo=t,this._capabilities=n,this.addEventListener(`initialized`,()=>{this._initializedReceived=!0}),this._hostContext=r?.hostContext||{},this.setRequestHandler(oP,e=>this._oninitialize(e)),this.setRequestHandler(Mj,(e,t)=>(this.onping?.(e.params,t),{})),this.replaceRequestHandler(eP,e=>({mode:this._hostContext.displayMode??`inline`}))}getAppCapabilities(){return this._appCapabilities}getAppVersion(){return this._appInfo}onping;get onsizechange(){return this.getEventHandler(`sizechange`)}set onsizechange(e){this.setEventHandler(`sizechange`,e)}get onsandboxready(){return this.getEventHandler(`sandboxready`)}set onsandboxready(e){this.setEventHandler(`sandboxready`,e)}get oninitialized(){return this.getEventHandler(`initialized`)}set oninitialized(e){this.setEventHandler(`initialized`,e)}_onmessage;get onmessage(){return this._onmessage}set onmessage(e){this.warnIfRequestHandlerReplaced(`onmessage`,this._onmessage,e),this._onmessage=e,this.replaceRequestHandler(rP,async(e,t)=>{if(!this._onmessage)throw Error(`No onmessage handler set`);return this._onmessage(e.params,t)})}_onopenlink;get onopenlink(){return this._onopenlink}set onopenlink(e){this.warnIfRequestHandlerReplaced(`onopenlink`,this._onopenlink,e),this._onopenlink=e,this.replaceRequestHandler(VN,async(e,t)=>{if(!this._onopenlink)throw Error(`No onopenlink handler set`);return this._onopenlink(e.params,t)})}_ondownloadfile;get ondownloadfile(){return this._ondownloadfile}set ondownloadfile(e){this.warnIfRequestHandlerReplaced(`ondownloadfile`,this._ondownloadfile,e),this._ondownloadfile=e,this.replaceRequestHandler(nP,async(e,t)=>{if(!this._ondownloadfile)throw Error(`No ondownloadfile handler set`);return this._ondownloadfile(e.params,t)})}get onrequestteardown(){return this.getEventHandler(`requestteardown`)}set onrequestteardown(e){this.setEventHandler(`requestteardown`,e)}_onrequestdisplaymode;get onrequestdisplaymode(){return this._onrequestdisplaymode}set onrequestdisplaymode(e){this.warnIfRequestHandlerReplaced(`onrequestdisplaymode`,this._onrequestdisplaymode,e),this._onrequestdisplaymode=e,this.replaceRequestHandler(eP,async(e,t)=>{if(!this._onrequestdisplaymode)throw Error(`No onrequestdisplaymode handler set`);return this._onrequestdisplaymode(e.params,t)})}get onloggingmessage(){return this.getEventHandler(`loggingmessage`)}set onloggingmessage(e){this.setEventHandler(`loggingmessage`,e)}_onupdatemodelcontext;get onupdatemodelcontext(){return this._onupdatemodelcontext}set onupdatemodelcontext(e){this.warnIfRequestHandlerReplaced(`onupdatemodelcontext`,this._onupdatemodelcontext,e),this._onupdatemodelcontext=e,this.replaceRequestHandler(aP,async(e,t)=>{if(!this._onupdatemodelcontext)throw Error(`No onupdatemodelcontext handler set`);return this._onupdatemodelcontext(e.params,t)})}_oncalltool;get oncalltool(){return this._oncalltool}set oncalltool(e){this.warnIfRequestHandlerReplaced(`oncalltool`,this._oncalltool,e),this._oncalltool=e,this.replaceRequestHandler(UM,async(e,t)=>{if(!this._oncalltool)throw Error(`No oncalltool handler set`);return this._oncalltool(e.params,t)})}set oncreatesamplingmessage(e){this.setRequestHandler(rN,async(t,n)=>e(t.params,n))}sendToolListChanged(e={}){return this.notification({method:`notifications/tools/list_changed`,params:e})}_onlistresources;get onlistresources(){return this._onlistresources}set onlistresources(e){this.warnIfRequestHandlerReplaced(`onlistresources`,this._onlistresources,e),this._onlistresources=e,this.replaceRequestHandler(aM,async(e,t)=>{if(!this._onlistresources)throw Error(`No onlistresources handler set`);return this._onlistresources(e.params,t)})}_onlistresourcetemplates;get onlistresourcetemplates(){return this._onlistresourcetemplates}set onlistresourcetemplates(e){this.warnIfRequestHandlerReplaced(`onlistresourcetemplates`,this._onlistresourcetemplates,e),this._onlistresourcetemplates=e,this.replaceRequestHandler(sM,async(e,t)=>{if(!this._onlistresourcetemplates)throw Error(`No onlistresourcetemplates handler set`);return this._onlistresourcetemplates(e.params,t)})}_onreadresource;get onreadresource(){return this._onreadresource}set onreadresource(e){this.warnIfRequestHandlerReplaced(`onreadresource`,this._onreadresource,e),this._onreadresource=e,this.replaceRequestHandler(dM,async(e,t)=>{if(!this._onreadresource)throw Error(`No onreadresource handler set`);return this._onreadresource(e.params,t)})}sendResourceListChanged(e={}){return this.notification({method:`notifications/resources/list_changed`,params:e})}_onlistprompts;get onlistprompts(){return this._onlistprompts}set onlistprompts(e){this.warnIfRequestHandlerReplaced(`onlistprompts`,this._onlistprompts,e),this._onlistprompts=e,this.replaceRequestHandler(SM,async(e,t)=>{if(!this._onlistprompts)throw Error(`No onlistprompts handler set`);return this._onlistprompts(e.params,t)})}sendPromptListChanged(e={}){return this.notification({method:`notifications/prompts/list_changed`,params:e})}assertCapabilityForMethod(e){}assertRequestHandlerCapability(e){}assertNotificationCapability(e){}assertTaskCapability(e){throw Error(`Tasks are not supported in MCP Apps`)}assertTaskHandlerCapability(e){throw Error(`Task handlers are not supported in MCP Apps`)}getCapabilities(){return this._capabilities}async _oninitialize(e){let t=e.params.protocolVersion;return this._appInfo!==void 0&&console.warn(`[ext-apps] AppBridge received a second ui/initialize. The View may be double-mounting (e.g. React StrictMode in dev) without closing the previous App instance. Responding normally; the latest appInfo/appCapabilities replace the previous values.`),this._appCapabilities=e.params.appCapabilities,this._appInfo=e.params.appInfo,{protocolVersion:sP.includes(t)?t:LN,hostCapabilities:this.getCapabilities(),hostInfo:this._hostInfo,hostContext:this._hostContext}}setHostContext(e){let t={},n=!1;for(let r of Object.keys(e)){let i=this._hostContext[r],a=e[r];lP(i,a)||(t[r]=a,n=!0)}n&&(this._hostContext=e,this.sendHostContextChange(t))}sendHostContextChange(e){return this.notification({method:`ui/notifications/host-context-changed`,params:e})}sendToolInput(e){return this.notification({method:`ui/notifications/tool-input`,params:e})}sendToolInputPartial(e){return this.notification({method:`ui/notifications/tool-input-partial`,params:e})}sendToolResult(e){return this.notification({method:`ui/notifications/tool-result`,params:e})}sendToolCancelled(e){return this.notification({method:`ui/notifications/tool-cancelled`,params:e})}sendSandboxResourceReady(e){return this.notification({method:`ui/notifications/sandbox-resource-ready`,params:e})}teardownResource(e,t){return this.request({method:`ui/resource-teardown`,params:e},JN,t)}sendResourceTeardown=this.teardownResource;callTool(e,t){return this.request({method:`tools/call`,params:e},VM,t)}listTools(e,t){return this.request({method:`tools/list`,params:e},BM,t)}async connect(e){if(this.transport)throw Error(`AppBridge is already connected. Call close() before connecting again.`);if(this._initializedReceived=!1,this._client){let e=this._client.getServerCapabilities();if(!e)throw Error(`Client server capabilities not available`);e.tools&&(this.oncalltool=async(e,t)=>this._client.request({method:`tools/call`,params:e},VM,{signal:t.signal}),e.tools.listChanged&&this._client.setNotificationHandler(WM,e=>this.sendToolListChanged(e.params))),e.resources&&(this.onlistresources=async(e,t)=>this._client.request({method:`resources/list`,params:e},oM,{signal:t.signal}),this.onlistresourcetemplates=async(e,t)=>this._client.request({method:`resources/templates/list`,params:e},cM,{signal:t.signal}),this.onreadresource=async(e,t)=>this._client.request({method:`resources/read`,params:e},fM,{signal:t.signal}),e.resources.listChanged&&this._client.setNotificationHandler(pM,e=>this.sendResourceListChanged(e.params))),e.prompts&&(this.onlistprompts=async(e,t)=>this._client.request({method:`prompts/list`,params:e},CM,{signal:t.signal}),e.prompts.listChanged&&this._client.setNotificationHandler(FM,e=>this.sendPromptListChanged(e.params)))}return super.connect(e)}};function lP(e,t){return JSON.stringify(e)===JSON.stringify(t)}function uP(){let e=pt(Cv);if(!e)throw Error(`useTheme must be used within ThemeProvider`);return e}function dP({state:e}){return e.enabled?A(`details`,{class:`pointer-events-auto w-full max-w-md rounded-lg border border-base-300 bg-base-100/95 p-2 text-xs shadow-lg backdrop-blur`,children:[A(`summary`,{class:`cursor-pointer font-medium`,children:`Magic Canvas debug`}),A(`dl`,{class:`mt-2 grid gap-2`,children:[A(fP,{label:`iframe`,value:e.iframeLifecycleState}),A(fP,{label:`post`,value:e.lastInteractionPostResult}),A(fP,{label:`context`,value:e.lastModelContextUpdate}),A(fP,{label:`error`,value:e.lastError}),A(pP,{label:`tool_call`,value:e.lastToolCall}),A(pP,{label:`canvas_config`,value:e.parsedCanvasConfig})]})]}):null}function fP({label:e,value:t}){return t?A(`div`,{children:[A(`dt`,{class:`font-semibold`,children:e}),A(`dd`,{class:`break-words text-base-content/70`,children:t})]}):null}function pP({label:e,value:t}){return t===void 0?null:A(`div`,{children:[A(`dt`,{class:`font-semibold`,children:e}),A(`dd`,{children:A(`pre`,{class:`max-h-40 overflow-auto rounded bg-base-200 p-2 text-[10px] leading-relaxed`,children:JSON.stringify(t,null,2)})})]})}var mP=1e3,hP=5e3,gP=1200,_P=2e3;function vP(e){return e.correct_answer===void 0?gP:_P}var yP=48,bP=`allow-scripts`,xP={"canvas.scheduling_embed":`allow-scripts allow-same-origin allow-popups allow-forms`};function SP(e,t){if(!t.contentWindow||e.source!==t.contentWindow)return!1;let n=e.data;return!!n&&typeof n==`object`&&n?.jsonrpc===`2.0`}var CP=class{onmessage;onerror;onclose;#e;#t;constructor(e){this.#e=e}start(){let e=e=>{SP(e,this.#e)&&this.onmessage?.(e.data)};return this.#t=e,globalThis.addEventListener(`message`,e),Promise.resolve()}send(e){return this.#e.contentWindow?.postMessage(e,`*`),Promise.resolve()}close(){return this.#t&&globalThis.removeEventListener(`message`,this.#t),this.#t=void 0,this.onclose?.(),Promise.resolve()}};function wP(e){for(let t of Wx)if(e.some(e=>zP(e)===t))return t;return null}function TP({onLayoutEffectChange:e,onRenderedSlotChange:t,debugEnabled:n=BP()}={}){let{client:r}=ev(),{dataTheme:i,cssVars:a}=uP(),o=ph(),s=Bg(),[c,l]=T([]),[u,d]=PP(),[f,p]=T(()=>({enabled:n,iframeLifecycleState:`idle`})),m=k(e=>{p(t=>({...t,...e}))},[]),h=k((e,t=`*`)=>{if(s!==`joined-meeting`){m({lastError:`Dropped Magic Canvas app message because the Daily meeting is not joined.`});return}o?.sendAppMessage(e,t)},[o,s,m]),g=O(()=>({theme:i.value===`dark`?`dark`:`light`,cssVars:a.value}),[i.value,a.value]);E(()=>{p(e=>e.enabled===n?e:{...e,enabled:n})},[n]),Qg({onAppMessage:k(e=>{if(s!==`joined-meeting`){m({lastToolCall:e.data,iframeLifecycleState:`idle`,lastError:`Dropped Magic Canvas tool call because the Daily meeting is not joined.`});return}try{let t=LS(e.data);if(!t)return;l(e=>nS(e,t)),m({lastToolCall:e.data,parsedCanvasConfig:t.kind===`show`?t.instance.canvas_config:void 0,iframeLifecycleState:t.kind===`clear`?`closed`:`received`,lastError:void 0})}catch(e){m({iframeLifecycleState:`error`,lastError:UP(e).message})}},[s,m])});let _=c.map(e=>({instance:e,layout:lS(e,d)})),v=uS(_.map(({layout:e})=>e),d),y=[..._].reverse().find(({layout:e})=>e.display_mode===`fullscreen`)?.instance.tool_call_id;E(()=>{e?.(v)},[e,v.active,v.side,v.video_shift_x,v.backdrop.type,v.safe_area?.x,v.safe_area?.y,v.safe_area?.width,v.safe_area?.height]);let b=wP(_.map(({layout:e})=>e));E(()=>{t?.(b)},[t,b]);let x=c.length>0||f.enabled;return A(`div`,{ref:u,"data-magic-canvas-root":!0,class:`pointer-events-none absolute inset-0 z-30`,children:[x&&y&&A(`div`,{class:`absolute inset-0 bg-black/45`}),x&&Wx.map(e=>{let t=_.filter(({layout:t})=>zP(t)===e);return t.length===0?null:A(DP,{slot:e,safeAreaTop:v.safe_area?.y,frameWidth:d.width,children:e=>t.map(({instance:t,layout:n})=>A(OP,{availableHeight:e,client:r,hostTheme:g,instance:t,layout:n,dimmed:!!(y&&y!==t.tool_call_id),onDebug:m,onComplete:()=>{l(e=>e.filter(e=>e.id!==t.id))},onDisplayModeChange:e=>{l(n=>n.map(n=>n.tool_call_id===t.tool_call_id?{...n,layout:{...n.layout,display_mode:e}}:n))},sendAppMessage:h},t.id))},e)}),x&&A(`div`,{class:`absolute right-4 bottom-24 @max-mobile:right-3 @max-mobile:bottom-20`,children:A(dP,{state:f})})]})}var EP=16;function DP({slot:e,safeAreaTop:t,frameWidth:n,children:r}){let[i,a]=FP(),o=r(e===`full`?void 0:a);if(e===`safe-area-left`||e===`safe-area-right`){let r=t==null?`1rem`:`${t*100}%`,a=n!=null&&n>0?Math.max(0,n-EP*2):void 0;return A(`div`,{ref:i,class:RP(e),style:{top:r,bottom:`${LP}px`,maxWidth:a},"data-canvas-slot":e,children:A(`div`,{class:`my-auto flex w-full flex-col gap-2`,children:o})})}return A(`div`,{ref:i,class:RP(e),"data-canvas-slot":e,children:o})}function OP({availableHeight:e,client:t,hostTheme:n,instance:r,layout:i,dimmed:a,onDebug:o,onComplete:s,onDisplayModeChange:c,sendAppMessage:l}){let u=D(null),d=D(null),f=D(e),p=D(320),m=D(n),h=D(r),g=D(i),_=D(-1),v=D(s),y=D(c),b=D(l),[x,S]=T(320);E(()=>{h.current=r},[r]),E(()=>{p.current=x,d.current?.setHostContext(MP(h.current,m.current,g.current,f.current,x))},[x]),E(()=>{f.current=e;let t=jP(n,u.current);m.current=t,d.current?.setHostContext(MP(h.current,t,g.current,e,p.current))},[e,n]),E(()=>{g.current=i,d.current?.setHostContext(MP(h.current,m.current,i,e,p.current))},[e,i]),E(()=>{v.current=s,y.current=c,b.current=l},[s,c,l]),E(()=>{let e=u.current;if(!e)return;let n=!1,i=null,a=null,s=null,c=null,l=new URL(r.canvas_config.sandbox_url,globalThis.location.href).href,x=e=>{n||o({iframeLifecycleState:`error`,lastError:UP(e).message})},C=()=>{if(n||!a)return;let e=h.current,t=sS(e,a);a=null,b.current({message_type:`conversation`,event_type:`conversation.append_llm_context`,conversation_id:e.conversation_id,properties:{context:t}}),o({lastModelContextUpdate:e.canvas_config.component,lastError:void 0})},w=()=>{if(i)return;if(e.src!==l){e.src;return}if(n||!e.contentWindow)return;let u=new cP(null,{name:`tavus-deployment`,version:`0.0.0`},{logging:{},message:{text:{},structuredContent:{}},updateModelContext:{text:{},structuredContent:{}}},{hostContext:MP(r,jP(m.current,e),g.current,f.current,p.current)});i=u,d.current=u,u.oninitialized=()=>{n||(o({iframeLifecycleState:`ready`}),_.current=h.current.revision,u.sendToolInput({arguments:h.current.arguments}).catch(x))},u.onsizechange=({height:e})=>{!n&&typeof e==`number`&&Number.isFinite(e)&&S(Math.min(Math.max(e,yP),720))},u.onmessage=async e=>{let r=rS(e),i=oS(e);if(!r){if(i){let e=`Magic Canvas message included text without interaction metadata; no interaction row was recorded.`;return o({lastInteractionPostResult:`error`,lastError:e}),{isError:!0,code:`missing_interaction_metadata`,message:e}}return{}}try{let e=h.current,a=iS(e,r),s=RS(a),l=new AbortController,u=globalThis.setTimeout(()=>l.abort(),hP);try{await En(t,a.conversation_id,s.body,{signal:l.signal})}finally{globalThis.clearTimeout(u)}if(n)return{};i&&b.current({message_type:`conversation`,event_type:`conversation.respond`,conversation_id:e.conversation_id,properties:{text:i}}),o({lastInteractionPostResult:`success`,lastError:void 0}),aS(a)&&(a.type===`submit`?(c&&clearTimeout(c),c=setTimeout(()=>{c=null,n||v.current()},vP(e.arguments))):v.current())}catch(e){let t=UP(e).message;return o({lastInteractionPostResult:`error`,lastError:t}),{isError:!0,code:`interaction_post_failed`,message:t}}return{}},u.onupdatemodelcontext=async e=>(a=e,s||=setTimeout(()=>{s=null,C()},mP),{}),u.onrequestdisplaymode=async({mode:e})=>{let t=e===`fullscreen`?`fullscreen`:`inline`;return y.current(t),g.current={...g.current,display_mode:t,viable_slot:t===`fullscreen`?`full`:g.current.viable_slot},u.setHostContext(MP(h.current,m.current,g.current,f.current,p.current)),{mode:t}},u.connect(new CP(e)).then(()=>void 0).catch(x)};o({iframeLifecycleState:`mounting`,lastInteractionPostResult:void 0}),r.canvas_config.sandbox_url,e.src=r.canvas_config.sandbox_url;let ee=()=>{w()};return e.addEventListener(`load`,ee),w(),()=>{s&&=(clearTimeout(s),null),c&&=(clearTimeout(c),null),C(),n=!0,e.removeEventListener(`load`,ee),d.current=null,o({iframeLifecycleState:`closed`}),i&&Hx(i)}},[t,r.id,r.canvas_config.sandbox_url,o]),E(()=>{r.revision!==0&&(r.revision<=_.current||(_.current=r.revision,d.current?.sendToolInput({arguments:r.arguments}).catch(e=>{o({iframeLifecycleState:`error`,lastError:UP(e).message})})))},[r.arguments,r.revision,o]);let C=i.viable_slot===`full`||i.display_mode===`fullscreen`,w=C?null:NP(x,e),ee=w?.placeholderStyle,te=w?.cardStyle,ne=C?{height:`100%`}:w?.iframeStyle??{height:`${x}px`},re=[`pointer-events-auto w-full overflow-hidden rounded-lg border border-base-300 bg-base-100 shadow-xl transition-[opacity,transform]`,C?`fixed inset-4 z-10 max-w-none`:`max-w-md`,a?`scale-[0.98] opacity-40`:``].filter(Boolean).join(` `),ie=xP[r.canvas_config.component]??bP,ae=A(`div`,{class:re,style:te,"data-canvas-card":i.viable_slot,children:A(`iframe`,{ref:u,title:`${r.canvas_config.component} ${r.canvas_config.component_version}`,class:C?`block h-full w-full border-0 bg-transparent`:`block border-0 bg-transparent`,sandbox:ie,style:ne})});return C?ae:A(`div`,{class:`block w-full`,style:ee,children:ae})}var kP=[`--color-base-100`,`--color-base-200`,`--color-base-300`,`--color-base-content`,`--color-primary`,`--color-error`];function AP(e){if(!e||typeof getComputedStyle!=`function`)return{};let t=getComputedStyle(e),n={};for(let e of kP){let r=t.getPropertyValue(e).trim();r&&(n[e]=r)}return n}function jP(e,t){let n=AP(t);return Object.keys(n).length===0?e:{...e,cssVars:{...e.cssVars,...n}}}function MP(e,t,n,r,i){let a=zS(t,n),o=n.viable_slot===`full`||n.display_mode===`fullscreen`,s=o?void 0:VP(r),c=o?1:NP(i??0,r)?.displayScale??1;return{...e.canvas_config.host_context,...a,containerDimensions:{...HP(a.containerDimensions)?a.containerDimensions:{},...s===void 0?{}:{maxHeight:s},displayScale:c}}}function NP(e,t){if(t===void 0||!Number.isFinite(t)||t<=0)return null;let n=Math.min(e,720);if(n<=t)return{displayScale:1,placeholderStyle:{maxHeight:`${t}px`},cardStyle:void 0,iframeStyle:{width:`100%`,height:`${n}px`}};let r=t/n;return r>=.85?{displayScale:r,placeholderStyle:{height:`${n*r}px`,maxHeight:`${t}px`,overflow:`hidden`},cardStyle:{height:`${n}px`,transform:`scale(${r})`,transformOrigin:`top center`},iframeStyle:{width:`100%`,height:`${n}px`}}:{displayScale:1,placeholderStyle:{maxHeight:`${t}px`},cardStyle:void 0,iframeStyle:{width:`100%`,height:`${t}px`}}}function PP(){let e=D(null),[t,n]=T(()=>IP(null));return E(()=>{let t=()=>n(t=>{let n=IP(e.current);return t.width===n.width&&t.height===n.height&&t.visualViewportHeight===n.visualViewportHeight?t:n});t(),globalThis.addEventListener(`resize`,t),globalThis.visualViewport?.addEventListener(`resize`,t);let r;return typeof ResizeObserver<`u`&&e.current&&(r=new ResizeObserver(t),r.observe(e.current)),()=>{globalThis.removeEventListener(`resize`,t),globalThis.visualViewport?.removeEventListener(`resize`,t),r?.disconnect()}},[]),[e,t]}function FP(){let e=D(null),[t,n]=T();return E(()=>{let t=e.current;if(!t)return;let r=e=>{let r=e??t.getBoundingClientRect().height;!Number.isFinite(r)||r<=0||n(Math.floor(r))},i=()=>r();if(i(),typeof ResizeObserver>`u`)return globalThis.addEventListener(`resize`,i),()=>globalThis.removeEventListener(`resize`,i);let a=new ResizeObserver(e=>{r(e[0]?.contentRect.height)});return a.observe(t),()=>a.disconnect()},[]),[e,t]}function IP(e){let t=globalThis.visualViewport?.height,n=e?.getBoundingClientRect();if(n&&n.width>0&&n.height>0){let e=t===void 0?void 0:Math.max(0,(globalThis.innerHeight||0)-t);return{width:n.width,height:n.height,visualViewportHeight:e===void 0?void 0:Math.max(0,n.height-e)}}return{width:globalThis.innerWidth||1024,height:globalThis.innerHeight||768,visualViewportHeight:t}}var LP=72;function RP(e){let t=`absolute flex gap-2`;switch(e){case`safe-area-left`:return`${t} left-4 w-[28rem] flex-col overflow-y-auto`;case`safe-area-right`:return`${t} right-4 w-[28rem] flex-col overflow-y-auto`;case`safe-area-bottom`:return`${t} right-4 bottom-24 left-4 flex-col items-center justify-end @max-mobile:right-3 @max-mobile:bottom-20 @max-mobile:left-3`;case`full`:return`${t} inset-4 flex-col items-stretch justify-stretch`}}function zP(e){return e.display_mode===`fullscreen`&&e.preferred_slot!==`full`?e.preferred_slot:e.viable_slot}function BP(){return!1}function VP(e){return e===void 0||!Number.isFinite(e)||e<=0?720:Math.min(Math.floor(e),720)}function HP(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function UP(e){return e instanceof Error?e:Error(String(e))}var WP=1e4;function GP({onTimeout:e,timeoutMs:t=WP,active:n=!0}){let r=Dx().length>0,[i,a]=T(!1),o=D(e);return E(()=>{o.current=e},[e]),E(()=>{if(!n||r){a(!1);return}let e=setTimeout(()=>{a(!0),o.current()},t);return()=>clearTimeout(e)},[n,r,t]),{hasJoined:r,timedOut:i}}function KP(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.message_type===`system`&&t.event_type===`system.shutdown`}function qP({onShutdown:e}){let t=D(e);E(()=>{t.current=e},[e]),Qg({onAppMessage:k(e=>{KP(e?.data)&&t.current()},[])})}function JP(){let e=ph();return{joinCall:k(({url:t,micOnly:n=!1})=>{e?.join(n?{url:t,videoSource:!1}:{url:t})},[e]),leaveCall:k(()=>{e?.leave()},[e])}}var YP=yn(`PiP`),XP=360,ZP=280;function QP(){return globalThis.window!==void 0&&`documentPictureInPicture`in globalThis.window}function $P(e){let{enabled:t,active:n}=e,[r,i]=T(null),a=QP(),o=pt(Cv),s=k(()=>{i(e=>(e&&!e.closed&&e.close(),null))},[]),c=k(async()=>{if(a&&!(!t||!n)&&!(r&&!r.closed))try{let e=await globalThis.window.documentPictureInPicture.requestWindow({width:XP,height:ZP}),t=Ye.replace(/:host(?=[\s,{])/g,`:host, :root`),n=e.document.createElement(`style`);n.textContent=t,e.document.head.appendChild(n),e.document.body.style.margin=`0`,e.document.body.style.width=`100%`,e.document.body.style.height=`100vh`,e.document.body.style.overflow=`hidden`,e.addEventListener(`pagehide`,()=>{i(t=>t===e?null:t)},{once:!0}),i(e)}catch(e){YP.warn(`Failed to open PiP window`,e)}},[a,t,n,r]);return E(()=>{if(!t||!a||!n)return;let e=()=>{document.visibilityState===`hidden`?c():document.visibilityState===`visible`&&s()};document.addEventListener(`visibilitychange`,e);let r=[],i=null,o=`none`,l=!1;if(typeof navigator<`u`&&`mediaSession`in navigator){let e=navigator.mediaSession;i=e.metadata,o=e.playbackState;try{e.metadata=new MediaMetadata({title:`Tavus conversation`}),e.playbackState=`playing`,l=!0}catch(e){YP.warn(`mediaSession metadata setup failed`,e)}let t=(t,n)=>{try{e.setActionHandler(t,n),r.push(t)}catch(e){YP.warn(`mediaSession.${t} not supported`,e)}};t(`enterpictureinpicture`,()=>{c()}),t(`play`,()=>{}),t(`pause`,()=>{})}return()=>{if(document.removeEventListener(`visibilitychange`,e),typeof navigator<`u`&&`mediaSession`in navigator){let e=navigator.mediaSession;for(let t of r)try{e.setActionHandler(t,null)}catch{}if(l)try{e.metadata=i,e.playbackState=o}catch{}}}},[t,a,n,c,s]),E(()=>{(!n||!t)&&r&&!r.closed&&s()},[n,t,r,s]),E(()=>()=>{r&&!r.closed&&r.close()},[r]),E(()=>{if(!r||r.closed||!o)return;let e=()=>{r.document.body.setAttribute(`data-theme`,o.dataTheme.value);let e=o.cssVars.value;for(let[t,n]of Object.entries(e))r.document.body.style.setProperty(t,n)};e();let t=o.dataTheme.subscribe(()=>e()),n=o.cssVars.subscribe(()=>e());return()=>{t(),n()}},[r,o]),{pipWindow:r,isSupported:a,requestPipWindow:c,closePipWindow:s}}var eF=Wt(null),tF={active:!1,video_shift_x:0,backdrop:{type:`snapshot_mirror`}},nF=ya(({id:e,showAudioWave:t=!0})=>{let n=d_(e).isOff;return A(`div`,{class:`relative aspect-square w-32 @max-mobile:w-24 rounded-box overflow-hidden bg-black/30 z-10 ${n?`hidden`:``}`,children:[A(dg,{automirror:!0,sessionId:e,type:`video`,fit:`cover`,className:`w-full h-full object-cover ${n?`hidden`:``}`}),t&&A(`div`,{class:`absolute bottom-2 right-2`,children:A(bx,{id:e})})]})}),rF=ya(()=>{let e=Zh(),{isScreenSharing:t}=Ob(),n=Dx()[0];return A(ue,{children:[t&&n&&A(nF,{id:n}),e&&A(nF,{id:e,showAudioWave:!1})]})}),iF=ya(()=>A(`div`,{class:`absolute top-4 left-4 flex flex-col items-end gap-2 z-20`,children:A(rF,{})})),aF=ya(({isAudioOnly:e,canvasLayoutEffect:t,canvasRenderedSlot:n})=>{let r=Zh(),i=!l_(r??``).isOff,a=Ox(e),o=l_(a.phase===`ready`?a.replicaId:``),s=!i&&(o.state===`playable`||o.state===`loading`),c=t.active&&!i&&(!e||s);return a.phase===`left`?A(vx,{}):a.phase===`connecting`?A(_x,{}):e&&!s?A(`div`,{class:`absolute inset-0 flex items-center justify-center`,children:[A(wx,{sessionId:a.replicaId}),A(lg,{sessionId:a.replicaId})]}):A(ue,{children:[s?A(vC,{personaSessionId:a.replicaId,isAudioOnly:e,avatarOff:a.videoState.isOff,canvasLayoutEffect:t,smartSidecarActive:c}):A(oF,{personaSessionId:a.replicaId,localId:r,isScreenSharing:i,avatarOff:a.videoState.isOff,smartSidecarActive:c,canvasLayoutEffect:t,canvasRenderedSlot:n}),A(lg,{sessionId:a.replicaId})]})}),oF=ya(({personaSessionId:e,localId:t,isScreenSharing:n,avatarOff:r,smartSidecarActive:i,canvasLayoutEffect:a,canvasRenderedSlot:o})=>A(gC,{canvasLayoutEffect:a,smartSidecarActive:i,isScreenSharing:n,captureSnapshot:uF,personaMode:`auto`,renderedSlot:o,fill:i=>A(Mx,{personaSessionId:e,localSessionId:t,isScreenSharing:n,avatarOff:r,videoRef:i})})),sF=ya(({items:e})=>{let[t,n]=T(!1),r=D(null);return E(()=>{if(!t)return;let e=e=>{r.current&&!e.composedPath().includes(r.current)&&n(!1)},i=e=>{e.key===`Escape`&&n(!1)};return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,i),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,i)}},[t]),A(`div`,{ref:r,class:`relative`,children:[A(`button`,{type:`button`,onClick:()=>n(e=>!e),"aria-pressed":t,"aria-expanded":t,"aria-haspopup":`true`,"aria-label":t?`Close more controls`:`More controls`,class:`btn btn-control ${t?`btn-primary`:`btn-neutral`}`,children:A(Qy,{name:`more`})}),t&&A(`div`,{role:`menu`,class:`absolute bottom-full mb-1 left-1/2 -translate-x-1/2 flex flex-row items-center gap-1 p-1 rounded-box bg-base-100 border border-base-300 shadow-lg z-30 whitespace-nowrap`,children:e})]})}),cF=ya(({items:e})=>e.length<=1?A(ue,{children:e}):A(sF,{items:e})),lF=ya(({onLeave:e})=>{let{joinCall:t,leaveCall:n}=JP(),r=Bg(),{config:i}=ev(),{session:a,end:o}=ix(),s=Zh(),c=D(null),l=pt(Wv)?.frameRef??c,[u,d]=T(!1),[f,p]=T(!1),[m,h]=T(tF),[g,_]=T(null),v=a.value?.conversationUrl,y=i.value.customization.conversation,b=y.modality===`audio`,x=y.enable_chat,S=y.enable_closed_captions,C=y.enable_picture_in_picture,{pipWindow:w}=$P({enabled:C,active:r===`joined-meeting`});E(()=>(v&&t({url:v,micOnly:!s}),()=>{n()}),[]);let{camera:ee,requestCamera:te}=Nb(),{isCamMuted:ne}=Eb(),re=ee.isGranted&&!ne;E(()=>{!b&&r===`joined-meeting`&&(eF.value=re)},[b,r,re]);let ie=D(!b&&!s&&eF.value===!0);E(()=>{r===`joined-meeting`&&ie.current&&(ie.current=!1,te())},[r,te]),E(()=>{(r===`left-meeting`||r===`error`)&&e()},[r,e]),E(()=>{let e=()=>{let e=l.current,t=e?.getRootNode(),n=t instanceof Document||t instanceof ShadowRoot?t:null;d(!!e&&n?.fullscreenElement===e)};return document.addEventListener(`fullscreenchange`,e),()=>document.removeEventListener(`fullscreenchange`,e)},[]);let ae=k(()=>{let e=l.current;if(!e)return;let t=e.getRootNode();(t instanceof Document||t instanceof ShadowRoot?t:null)?.fullscreenElement===e?document.exitFullscreen?.():e.requestFullscreen?.()},[]);k(()=>{p(e=>!e)},[]);let oe=k(()=>{o(),n()},[o]);if(GP({active:r===`joined-meeting`,onTimeout:oe}),qP({onShutdown:oe}),!v)return null;let se=[A(rx,{compact:!0},`screen-share`)];x&&se.push(A(px,{compact:!0},`chat`));let ce=r===`left-meeting`;return A(ox,{children:A(dx,{children:A(Bb,{children:[A(`div`,{class:`cvi-call-surface absolute inset-0`,children:[A(`div`,{class:`relative w-full h-full z-[5]`,children:[A(aF,{isAudioOnly:b,canvasLayoutEffect:m,canvasRenderedSlot:g}),!b&&A(iF,{}),A(lx,{}),A(TP,{debugEnabled:f,onLayoutEffectChange:h,onRenderedSlotChange:_}),A(`div`,{class:`cvi-autohide absolute top-4 right-4 z-20`,"data-hidden":ce,children:A(yx,{active:u,onToggle:ae,compact:!0})})]}),A(hx,{}),A(`div`,{class:`cvi-autohide cvi-autohide-slide pointer-events-none absolute bottom-6 left-0 right-0 z-20`,"data-hidden":ce,"aria-hidden":ce,children:A(`div`,{class:`cvi-control-rail flex justify-center items-center gap-2 @max-mobile:gap-1`,"data-hidden":ce,children:[A(Qb,{level:!0}),!b&&A(ex,{}),S&&A(cx,{}),A(cF,{items:se}),A(`button`,{type:`button`,class:`btn btn-control btn-error`,onClick:oe,"aria-label":`Leave call`,children:A(Qy,{name:`leave`,"aria-label":`Leave Call`})})]})})]}),w&&Ia(A(Ax,{onLeave:oe}),w.document.body)]})})})});function uF(e){if(!e||e.readyState<2||!e.videoWidth||!e.videoHeight)return null;let t=document.createElement(`canvas`),n=Math.round(640*(e.videoHeight/e.videoWidth));t.width=640,t.height=n;let r=t.getContext(`2d`);if(!r)return null;r.drawImage(e,0,0,640,n);try{return t.toDataURL(`image/jpeg`,.82)}catch{return null}}function dF({loading:e=!1,disabled:t,class:n,children:r,...i}){return A(`button`,{type:`button`,class:`btn relative ${n?` ${n}`:``}`,disabled:t||e,"aria-busy":e||void 0,...i,children:[A(`span`,{children:r}),e&&A(`span`,{class:`absolute inset-0 flex items-center justify-center backdrop-blur-xs`,"aria-hidden":`true`,children:A(`span`,{class:`loading loading-spinner loading-sm`})})]})}function fF(e,t,n){switch(t){case`granted`:return n?e?.cameraOptional??`Camera is optional — turn it on anytime.`:e?.ready??`You're all set — join whenever you're ready.`;case`blocked`:return e?.denied??`Microphone is blocked. Click the mic to see how to allow it.`;case`in-use`:return`Your microphone is in use by another app. Close it and try again.`;case`not-found`:return`No microphone found. Connect one to continue.`;case`unsupported`:return`This browser can't access your microphone.`;case`prompt`:return e?.prompt??`Allow microphone access to join.`;default:return e?.loading??`Getting your microphone ready...`}}function pF({message:e}){return A(`div`,{class:`relative max-w-[min(20rem,90%)]`,children:[A(`div`,{class:`px-4 py-2 rounded-box bg-neutral text-neutral-content text-sm font-medium shadow-lg text-center`,role:`status`,"aria-live":`polite`,children:e}),A(`svg`,{class:`absolute left-1/2 -translate-x-1/2 top-full text-neutral`,width:`16`,height:`8`,viewBox:`0 0 16 8`,"aria-hidden":`true`,children:A(`path`,{d:`M0 0 L8 8 L16 0 Z`,fill:`currentColor`})})]})}var mF=ya(({text:e,isJoining:t=!1,onJoin:n,onCancel:r})=>{let i=ph(),{config:a}=ev(),{localSessionId:o,isCamMuted:s}=Eb(),{mic:c,camera:l,requestMic:u,requestCamera:d}=Nb(),f=a.value.customization.conversation.modality===`video`;E(()=>{u()},[]);let p=c.isGranted,m=D(!1);E(()=>{!f||!p||m.current||l.isGranted||l.isBlocked||(m.current=!0,d())},[f,p,l.isGranted,l.isBlocked,d]);let h=f&&p&&!l.isGranted,g=fF(e,c.status,h);return A(Bb,{children:A(`div`,{class:`absolute inset-0 motion-safe:animate-[tavusFadeUp_280ms_ease-out]`,children:[l.isGranted&&!s?A(`div`,{class:`absolute inset-0 flex items-center justify-center bg-black overflow-hidden`,children:A(dg,{type:`video`,sessionId:o??``,mirror:!0,fit:`cover`,className:`w-full h-full object-cover!`})}):A(`div`,{class:`absolute inset-0 flex items-center justify-center text-base-content/40`,children:A(Qy,{name:`face-smile`,size:`7rem`,"aria-label":`Camera off`})}),A(`div`,{class:`absolute bottom-6 left-1/2 -translate-x-1/2 z-10 flex flex-col items-center gap-2 max-w-[90%]`,children:[g&&A(pF,{message:g}),A(`div`,{class:`flex flex-wrap items-center justify-center gap-1.5 @max-mobile:gap-1`,children:[A(`div`,{class:`flex items-center justify-center gap-1.5 shrink-0 @max-mobile:gap-1`,children:[A(Qb,{level:!0}),f&&A(ex,{})]}),A(dF,{class:`btn-accent `,loading:t,disabled:!p,onClick:n,children:e?.join??`Join Video Chat`}),c.isBlocked&&A(`button`,{type:`button`,class:`btn btn-error `,onClick:()=>{i&&i.leave(),r?.()},children:e?.cancel??`Cancel`})]})]})]})})}),hF=`Password required`,gF=`Enter the password to start this conversation.`,_F=`Password`,vF=`Continue`;function yF({onSubmit:e,text:t,isSubmitting:n=!1,errorMessage:r}){let[i,a]=T(``),o=ht();return A(`div`,{class:`absolute inset-0 z-30 flex items-center justify-center bg-black/50 backdrop-blur-sm p-4`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`${o}-title`,children:A(`form`,{onSubmit:t=>{t.preventDefault();let r=i.trim();!r||n||e(r)},class:`card bg-base-100 shadow-xl w-full max-w-sm`,children:A(`div`,{class:`card-body gap-3`,children:[A(`h3`,{id:`${o}-title`,class:`card-title text-base-content`,children:t?.title??hF}),A(`p`,{class:`text-sm text-base-content/70`,children:t?.description??gF}),A(`input`,{id:o,type:`password`,autocomplete:`current-password`,class:`input input-bordered w-full`,placeholder:t?.placeholder??_F,value:i,disabled:n,onInput:e=>a(e.target.value),autoFocus:!0}),r&&A(`p`,{class:`text-error text-xs`,role:`alert`,children:r}),A(dF,{class:`btn-primary`,type:`submit`,disabled:!i.trim(),loading:n,children:t?.submit??vF})]})})})}var bF=yn(`CaptchaChallenge`),xF=1;function SF(e){return typeof e==`object`&&!!e&&e.source===`tavus-captcha`&&typeof e.type==`string`}function CF(e,t,n,r,i){return`${e.replace(/\/+$/,``)}${t.startsWith(`/`)?t:`/${t}`}?deployment_uuid=${encodeURIComponent(n)}&action=${encodeURIComponent(r)}&parent_origin=${encodeURIComponent(i)}`}function wF({captcha:e,deploymentId:t,onToken:n,onFallback:r}){let i=(pt(wt).baseUrl??`https://tavusapi.com`).replace(/\/+$/,``),a=new URL(i).origin,[o,s]=T(0),[c,l]=T(0),[u,d]=T(!1),[f,p]=T(!1),m=CF(i,e.challenge_path,t,e.action,window.location.origin),h=k(()=>{p(!1),s(e=>e+1)},[]);return E(()=>{function e(e){if(u||e.origin!==a)return;let i=e.data;if(SF(i)&&i.deployment_uuid===t){if(i.type===`interactive`){p(!0);return}if(i.type===`token`&&i.token){bF.info(`Captcha token received`),p(!1),n(i.token);return}if(i.type===`expired`){bF.info(`Captcha token expired, reloading iframe`),h();return}i.type===`error`&&(bF.warn(`Captcha error received`,i.code),c<xF?(l(e=>e+1),h()):(bF.warn(`Captcha error retries exhausted, falling back to no-token mode`),d(!0),r()))}}return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},[a,t,c,u,n,r,h]),u?null:A(`div`,{class:f?`absolute inset-0 z-30 flex items-center justify-center p-4 bg-base-100/70 backdrop-blur-sm animate-[tavusFadeUp_180ms_ease-out]`:`absolute top-0 left-0 w-0 h-0 overflow-hidden opacity-0 pointer-events-none`,"aria-hidden":!f,children:A(`iframe`,{src:m,sandbox:`allow-scripts allow-same-origin allow-forms allow-popups`,title:`Security challenge`,style:{border:`none`,width:`300px`,height:`65px`},scrolling:`no`},o)})}function TF({text:e,onStart:t,isStarting:n}){let{config:r,deploymentId:i}=ev(),a=pt(G_),o=rb(r.value),s=o.btn_title??e?.fallback_button??`Start the conversation`,c=r.value.customization.terms_content?.trim()??``,l=r.value.customization.terms_enabled===!0,u=c.length>0,d=u&&l,f=O(()=>d&&S_(i,c),[d,i,c]),p=d&&!f,m=r.value.has_password===!0,h=a?.password.value??null,g=m&&!h,_=r.value.captcha??null,{captchaReady:v,captchaEpoch:y,handleCaptchaToken:b,handleCaptchaFallback:x}=_v(_,a),S=ht(),[C,w]=T(f),ee=_!==null&&!v,te=n||d&&!C||g||ee;return A(fb,{title:o.title,description:o.description,overlay:A(ue,{children:[ee&&A(wF,{captcha:_,deploymentId:i,onToken:b,onFallback:x},y),g&&a?A(yF,{onSubmit:a.setPassword}):null]}),children:[A(dF,{class:`btn-neutral rounded-box`,onClick:()=>{d&&C&&!f&&T_(i,c),t()},disabled:te,loading:n,children:s}),u&&A(`div`,{class:`max-w-xs`,children:p?A(`label`,{for:S,class:`flex items-center gap-2 text-xs text-left cursor-pointer`,children:[A(`input`,{id:S,type:`checkbox`,class:`checkbox checkbox-secondary checkbox-xs mt-0.5 shrink-0`,checked:C,onChange:e=>w(e.target.checked)}),A(`span`,{class:`leading-snug`,children:c})]}):A(`p`,{class:`text-xs leading-snug text-base-content/60`,children:c})})]})}function EF({flow:e,welcomeText:t,onUnavailableCancel:n}){switch(e.state){case`idle`:return A(TF,{text:t,onStart:()=>{e.start()},isStarting:e.isStarting});case`haircheck`:return A(mF,{onJoin:()=>{e.join()},onCancel:()=>e.cancel(),isJoining:e.isStarting});case`call`:return A(lF,{onLeave:()=>e.leave()});case`ended`:return A(Tb,{onRestart:()=>e.restart()});case`unavailable`:return A(_b,{cause:e.unavailableCause??`busy`,canRetry:e.canRetry,onRetry:()=>{e.start()},onCancel:n});default:{let t=e.state;throw Error(`Unreachable flow state: ${String(t)}`)}}}function DF(){let{config:e,configError:t}=ev(),n=bb(),r=vb(),i=O(()=>({fallback_button:n.start_button}),[n.start_button]),a=e.value.is_available,o=e.value.unavailable_reason;return A(Gv,{children:t.value?A(_b,{cause:`error`,canRetry:!1,onRetry:()=>{}}):a===!1?A(_b,{cause:o??`daily_limit`,canRetry:!1,onRetry:()=>{}}):A(EF,{flow:r,welcomeText:i})})}var OF=`:host {
|
|
164
164
|
display: block;
|
|
165
165
|
width: 100%;
|
|
166
166
|
height: 100%;
|
|
@@ -168,4 +168,4 @@ container holding the app. Specify either width or maxWidth, and either height o
|
|
|
168
168
|
overflow: hidden;
|
|
169
169
|
background: transparent;
|
|
170
170
|
font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
|
171
|
-
}`;function
|
|
171
|
+
}`;function kF(e){return A(ue,{children:[A(`style`,{dangerouslySetInnerHTML:{__html:Ye}}),A(`style`,{dangerouslySetInnerHTML:{__html:OF}}),A(Et,{"deployment-id":e[`deployment-id`],"override-config":e[`override-config`],"conversational-context":e[`conversational-context`],"custom-greeting":e[`custom-greeting`],"memory-stores":e[`memory-stores`],"base-url":e[`base-url`],token:e.token,children:A(Si,{fallback:A(Uv,{}),children:A(wi,{children:A(K_,{children:A(vv,{children:A(Sv,{children:A(wv,{children:A(Pv,{children:A(DF,{})})})})})})})})})]})}var AF;function jF(){AF||=Ve(kF,`tavus-embed`,[`deployment-id`,`override-config`,`conversational-context`,`custom-greeting`,`memory-stores`,`base-url`,`token`],{shadow:!0,mode:`open`})}Ie(null),yn(`Widget`);var MF=[`tavus:chat-message`,`tavus:conversation-ended`,`tavus:conversation-started`,`tavus:error`,`tavus:message`,`tavus:mode-change`,`tavus:protocol-message`,`tavus:ready`,`tavus:state-change`,`tavus:tool-call`],NF=class{element=null;tagName;constructor(e=`tavus-embed`){this.tagName=e,this.element=document.querySelector(this.tagName)}getElement(){if(this.element||=document.querySelector(this.tagName),!this.element)throw Error(`Element <${this.tagName}> not found in the DOM`);return this.element}open(){this.getElement().open?.()}close(){this.getElement().close?.()}startConversation(){this.getElement().startConversation?.()}endConversation(){this.getElement().endConversation?.()}sendMessage(e){let t=this.getElement();if(typeof e==`string`){let n={event_type:`conversation.respond`,properties:{text:e}};t.tavus?.sendMessage?.(n)}else t.tavus?.sendMessage?.(e)}updateConfig(e){this.getElement().updateConfig?.(e)}destroy(){this.getElement().destroy?.(),this.element=null}on(e,t){this.getElement().addEventListener(e,t)}off(e,t){this.getElement().removeEventListener(e,t)}};return typeof window<`u`&&jF(),e.TAVUS_EVENT_NAMES=MF,e.TavusIntegration=NF,e})({});
|
package/dist/index.mjs
CHANGED
|
@@ -27046,13 +27046,17 @@ function FN({ label: e, value: t }) {
|
|
|
27046
27046
|
}
|
|
27047
27047
|
//#endregion
|
|
27048
27048
|
//#region ../core/src/magic-canvas/magic-canvas.tsx
|
|
27049
|
-
var IN = 1e3, LN = 5e3, RN = 1200, zN =
|
|
27050
|
-
function
|
|
27049
|
+
var IN = 1e3, LN = 5e3, RN = 1200, zN = 2e3;
|
|
27050
|
+
function BN(e) {
|
|
27051
|
+
return e.correct_answer === void 0 ? RN : zN;
|
|
27052
|
+
}
|
|
27053
|
+
var VN = 48, HN = "allow-scripts", UN = { "canvas.scheduling_embed": "allow-scripts allow-same-origin allow-popups allow-forms" };
|
|
27054
|
+
function WN(e, t) {
|
|
27051
27055
|
if (!t.contentWindow || e.source !== t.contentWindow) return !1;
|
|
27052
27056
|
let n = e.data;
|
|
27053
27057
|
return !!n && typeof n == "object" && n?.jsonrpc === "2.0";
|
|
27054
27058
|
}
|
|
27055
|
-
var
|
|
27059
|
+
var GN = class {
|
|
27056
27060
|
onmessage;
|
|
27057
27061
|
onerror;
|
|
27058
27062
|
onclose;
|
|
@@ -27063,7 +27067,7 @@ var UN = class {
|
|
|
27063
27067
|
}
|
|
27064
27068
|
start() {
|
|
27065
27069
|
let e = (e) => {
|
|
27066
|
-
|
|
27070
|
+
WN(e, this.#e) && this.onmessage?.(e.data);
|
|
27067
27071
|
};
|
|
27068
27072
|
return this.#t = e, globalThis.addEventListener("message", e), Promise.resolve();
|
|
27069
27073
|
}
|
|
@@ -27074,12 +27078,12 @@ var UN = class {
|
|
|
27074
27078
|
return this.#t && globalThis.removeEventListener("message", this.#t), this.#t = void 0, this.onclose?.(), Promise.resolve();
|
|
27075
27079
|
}
|
|
27076
27080
|
};
|
|
27077
|
-
function
|
|
27078
|
-
for (let t of Wx) if (e.some((e) =>
|
|
27081
|
+
function KN(e) {
|
|
27082
|
+
for (let t of Wx) if (e.some((e) => sP(e) === t)) return t;
|
|
27079
27083
|
return null;
|
|
27080
27084
|
}
|
|
27081
|
-
function
|
|
27082
|
-
let { client: r } = ev(), { dataTheme: i, cssVars: a } = MN(), o = ph(), s = Bg(), [c, l] = w([]), [u, d] =
|
|
27085
|
+
function qN({ onLayoutEffectChange: e, onRenderedSlotChange: t, debugEnabled: n = cP() } = {}) {
|
|
27086
|
+
let { client: r } = ev(), { dataTheme: i, cssVars: a } = MN(), o = ph(), s = Bg(), [c, l] = w([]), [u, d] = nP(), [f, p] = w(() => ({
|
|
27083
27087
|
enabled: n,
|
|
27084
27088
|
iframeLifecycleState: "idle"
|
|
27085
27089
|
})), m = O((e) => {
|
|
@@ -27127,7 +27131,7 @@ function GN({ onLayoutEffectChange: e, onRenderedSlotChange: t, debugEnabled: n
|
|
|
27127
27131
|
} catch (e) {
|
|
27128
27132
|
m({
|
|
27129
27133
|
iframeLifecycleState: "error",
|
|
27130
|
-
lastError:
|
|
27134
|
+
lastError: dP(e).message
|
|
27131
27135
|
});
|
|
27132
27136
|
}
|
|
27133
27137
|
}, [s, m]) });
|
|
@@ -27148,7 +27152,7 @@ function GN({ onLayoutEffectChange: e, onRenderedSlotChange: t, debugEnabled: n
|
|
|
27148
27152
|
v.safe_area?.width,
|
|
27149
27153
|
v.safe_area?.height
|
|
27150
27154
|
]);
|
|
27151
|
-
let b =
|
|
27155
|
+
let b = KN(_.map(({ layout: e }) => e));
|
|
27152
27156
|
T(() => {
|
|
27153
27157
|
t?.(b);
|
|
27154
27158
|
}, [t, b]);
|
|
@@ -27160,12 +27164,12 @@ function GN({ onLayoutEffectChange: e, onRenderedSlotChange: t, debugEnabled: n
|
|
|
27160
27164
|
children: [
|
|
27161
27165
|
x && y && /* @__PURE__ */ k("div", { class: "absolute inset-0 bg-black/45" }),
|
|
27162
27166
|
x && Wx.map((e) => {
|
|
27163
|
-
let t = _.filter(({ layout: t }) =>
|
|
27164
|
-
return t.length === 0 ? null : /* @__PURE__ */ k(
|
|
27167
|
+
let t = _.filter(({ layout: t }) => sP(t) === e);
|
|
27168
|
+
return t.length === 0 ? null : /* @__PURE__ */ k(YN, {
|
|
27165
27169
|
slot: e,
|
|
27166
27170
|
safeAreaTop: v.safe_area?.y,
|
|
27167
27171
|
frameWidth: d.width,
|
|
27168
|
-
children: (e) => t.map(({ instance: t, layout: n }) => /* @__PURE__ */ k(
|
|
27172
|
+
children: (e) => t.map(({ instance: t, layout: n }) => /* @__PURE__ */ k(XN, {
|
|
27169
27173
|
availableHeight: e,
|
|
27170
27174
|
client: r,
|
|
27171
27175
|
hostTheme: g,
|
|
@@ -27196,17 +27200,17 @@ function GN({ onLayoutEffectChange: e, onRenderedSlotChange: t, debugEnabled: n
|
|
|
27196
27200
|
]
|
|
27197
27201
|
});
|
|
27198
27202
|
}
|
|
27199
|
-
var
|
|
27200
|
-
function
|
|
27201
|
-
let [i, a] =
|
|
27203
|
+
var JN = 16;
|
|
27204
|
+
function YN({ slot: e, safeAreaTop: t, frameWidth: n, children: r }) {
|
|
27205
|
+
let [i, a] = rP(), o = r(e === "full" ? void 0 : a);
|
|
27202
27206
|
if (e === "safe-area-left" || e === "safe-area-right") {
|
|
27203
|
-
let r = t == null ? "1rem" : `${t * 100}%`, a = n != null && n > 0 ? Math.max(0, n -
|
|
27207
|
+
let r = t == null ? "1rem" : `${t * 100}%`, a = n != null && n > 0 ? Math.max(0, n - JN * 2) : void 0;
|
|
27204
27208
|
return /* @__PURE__ */ k("div", {
|
|
27205
27209
|
ref: i,
|
|
27206
|
-
class:
|
|
27210
|
+
class: oP(e),
|
|
27207
27211
|
style: {
|
|
27208
27212
|
top: r,
|
|
27209
|
-
bottom: `${
|
|
27213
|
+
bottom: `${aP}px`,
|
|
27210
27214
|
maxWidth: a
|
|
27211
27215
|
},
|
|
27212
27216
|
"data-canvas-slot": e,
|
|
@@ -27218,23 +27222,23 @@ function qN({ slot: e, safeAreaTop: t, frameWidth: n, children: r }) {
|
|
|
27218
27222
|
}
|
|
27219
27223
|
return /* @__PURE__ */ k("div", {
|
|
27220
27224
|
ref: i,
|
|
27221
|
-
class:
|
|
27225
|
+
class: oP(e),
|
|
27222
27226
|
"data-canvas-slot": e,
|
|
27223
27227
|
children: o
|
|
27224
27228
|
});
|
|
27225
27229
|
}
|
|
27226
|
-
function
|
|
27230
|
+
function XN({ availableHeight: e, client: t, hostTheme: n, instance: r, layout: i, dimmed: a, onDebug: o, onComplete: s, onDisplayModeChange: c, sendAppMessage: l }) {
|
|
27227
27231
|
let u = E(null), d = E(null), f = E(e), p = E(320), m = E(n), h = E(r), g = E(i), _ = E(-1), v = E(s), y = E(c), b = E(l), [x, S] = w(320);
|
|
27228
27232
|
T(() => {
|
|
27229
27233
|
h.current = r;
|
|
27230
27234
|
}, [r]), T(() => {
|
|
27231
|
-
p.current = x, d.current?.setHostContext(
|
|
27235
|
+
p.current = x, d.current?.setHostContext(eP(h.current, m.current, g.current, f.current, x));
|
|
27232
27236
|
}, [x]), T(() => {
|
|
27233
27237
|
f.current = e;
|
|
27234
|
-
let t =
|
|
27235
|
-
m.current = t, d.current?.setHostContext(
|
|
27238
|
+
let t = $N(n, u.current);
|
|
27239
|
+
m.current = t, d.current?.setHostContext(eP(h.current, t, g.current, e, p.current));
|
|
27236
27240
|
}, [e, n]), T(() => {
|
|
27237
|
-
g.current = i, d.current?.setHostContext(
|
|
27241
|
+
g.current = i, d.current?.setHostContext(eP(h.current, m.current, i, e, p.current));
|
|
27238
27242
|
}, [e, i]), T(() => {
|
|
27239
27243
|
v.current = s, y.current = c, b.current = l;
|
|
27240
27244
|
}, [
|
|
@@ -27247,7 +27251,7 @@ function JN({ availableHeight: e, client: t, hostTheme: n, instance: r, layout:
|
|
|
27247
27251
|
let n = !1, i = null, a = null, s = null, c = null, l = new URL(r.canvas_config.sandbox_url, globalThis.location.href).href, x = (e) => {
|
|
27248
27252
|
n || o({
|
|
27249
27253
|
iframeLifecycleState: "error",
|
|
27250
|
-
lastError:
|
|
27254
|
+
lastError: dP(e).message
|
|
27251
27255
|
});
|
|
27252
27256
|
}, C = () => {
|
|
27253
27257
|
if (n || !a) return;
|
|
@@ -27281,11 +27285,11 @@ function JN({ availableHeight: e, client: t, hostTheme: n, instance: r, layout:
|
|
|
27281
27285
|
text: {},
|
|
27282
27286
|
structuredContent: {}
|
|
27283
27287
|
}
|
|
27284
|
-
}, { hostContext:
|
|
27288
|
+
}, { hostContext: eP(r, $N(m.current, e), g.current, f.current, p.current) });
|
|
27285
27289
|
i = u, d.current = u, u.oninitialized = () => {
|
|
27286
27290
|
n || (o({ iframeLifecycleState: "ready" }), _.current = h.current.revision, u.sendToolInput({ arguments: h.current.arguments }).catch(x));
|
|
27287
27291
|
}, u.onsizechange = ({ height: e }) => {
|
|
27288
|
-
!n && typeof e == "number" && Number.isFinite(e) && S(Math.min(Math.max(e,
|
|
27292
|
+
!n && typeof e == "number" && Number.isFinite(e) && S(Math.min(Math.max(e, VN), 720));
|
|
27289
27293
|
}, u.onmessage = async (e) => {
|
|
27290
27294
|
let r = rS(e), i = oS(e);
|
|
27291
27295
|
if (!r) {
|
|
@@ -27320,9 +27324,9 @@ function JN({ availableHeight: e, client: t, hostTheme: n, instance: r, layout:
|
|
|
27320
27324
|
lastError: void 0
|
|
27321
27325
|
}), aS(a) && (a.type === "submit" ? (c && clearTimeout(c), c = setTimeout(() => {
|
|
27322
27326
|
c = null, n || v.current();
|
|
27323
|
-
},
|
|
27327
|
+
}, BN(e.arguments))) : v.current());
|
|
27324
27328
|
} catch (e) {
|
|
27325
|
-
let t =
|
|
27329
|
+
let t = dP(e).message;
|
|
27326
27330
|
return o({
|
|
27327
27331
|
lastInteractionPostResult: "error",
|
|
27328
27332
|
lastError: t
|
|
@@ -27341,8 +27345,8 @@ function JN({ availableHeight: e, client: t, hostTheme: n, instance: r, layout:
|
|
|
27341
27345
|
...g.current,
|
|
27342
27346
|
display_mode: t,
|
|
27343
27347
|
viable_slot: t === "fullscreen" ? "full" : g.current.viable_slot
|
|
27344
|
-
}, u.setHostContext(
|
|
27345
|
-
}, u.connect(new
|
|
27348
|
+
}, u.setHostContext(eP(h.current, m.current, g.current, f.current, p.current)), { mode: t };
|
|
27349
|
+
}, u.connect(new GN(e)).then(() => void 0).catch(x);
|
|
27346
27350
|
};
|
|
27347
27351
|
o({
|
|
27348
27352
|
iframeLifecycleState: "mounting",
|
|
@@ -27363,7 +27367,7 @@ function JN({ availableHeight: e, client: t, hostTheme: n, instance: r, layout:
|
|
|
27363
27367
|
r.revision !== 0 && (r.revision <= _.current || (_.current = r.revision, d.current?.sendToolInput({ arguments: r.arguments }).catch((e) => {
|
|
27364
27368
|
o({
|
|
27365
27369
|
iframeLifecycleState: "error",
|
|
27366
|
-
lastError:
|
|
27370
|
+
lastError: dP(e).message
|
|
27367
27371
|
});
|
|
27368
27372
|
})));
|
|
27369
27373
|
}, [
|
|
@@ -27371,11 +27375,11 @@ function JN({ availableHeight: e, client: t, hostTheme: n, instance: r, layout:
|
|
|
27371
27375
|
r.revision,
|
|
27372
27376
|
o
|
|
27373
27377
|
]);
|
|
27374
|
-
let C = i.viable_slot === "full" || i.display_mode === "fullscreen", ee = C ? null :
|
|
27378
|
+
let C = i.viable_slot === "full" || i.display_mode === "fullscreen", ee = C ? null : tP(x, e), te = ee?.placeholderStyle, ne = ee?.cardStyle, re = C ? { height: "100%" } : ee?.iframeStyle ?? { height: `${x}px` }, ie = [
|
|
27375
27379
|
"pointer-events-auto w-full overflow-hidden rounded-lg border border-base-300 bg-base-100 shadow-xl transition-[opacity,transform]",
|
|
27376
27380
|
C ? "fixed inset-4 z-10 max-w-none" : "max-w-md",
|
|
27377
27381
|
a ? "scale-[0.98] opacity-40" : ""
|
|
27378
|
-
].filter(Boolean).join(" "), ae =
|
|
27382
|
+
].filter(Boolean).join(" "), ae = UN[r.canvas_config.component] ?? HN, oe = /* @__PURE__ */ k("div", {
|
|
27379
27383
|
class: ie,
|
|
27380
27384
|
style: ne,
|
|
27381
27385
|
"data-canvas-card": i.viable_slot,
|
|
@@ -27393,7 +27397,7 @@ function JN({ availableHeight: e, client: t, hostTheme: n, instance: r, layout:
|
|
|
27393
27397
|
children: oe
|
|
27394
27398
|
});
|
|
27395
27399
|
}
|
|
27396
|
-
var
|
|
27400
|
+
var ZN = [
|
|
27397
27401
|
"--color-base-100",
|
|
27398
27402
|
"--color-base-200",
|
|
27399
27403
|
"--color-base-300",
|
|
@@ -27401,17 +27405,17 @@ var YN = [
|
|
|
27401
27405
|
"--color-primary",
|
|
27402
27406
|
"--color-error"
|
|
27403
27407
|
];
|
|
27404
|
-
function
|
|
27408
|
+
function QN(e) {
|
|
27405
27409
|
if (!e || typeof getComputedStyle != "function") return {};
|
|
27406
27410
|
let t = getComputedStyle(e), n = {};
|
|
27407
|
-
for (let e of
|
|
27411
|
+
for (let e of ZN) {
|
|
27408
27412
|
let r = t.getPropertyValue(e).trim();
|
|
27409
27413
|
r && (n[e] = r);
|
|
27410
27414
|
}
|
|
27411
27415
|
return n;
|
|
27412
27416
|
}
|
|
27413
|
-
function
|
|
27414
|
-
let n =
|
|
27417
|
+
function $N(e, t) {
|
|
27418
|
+
let n = QN(t);
|
|
27415
27419
|
return Object.keys(n).length === 0 ? e : {
|
|
27416
27420
|
...e,
|
|
27417
27421
|
cssVars: {
|
|
@@ -27420,19 +27424,19 @@ function ZN(e, t) {
|
|
|
27420
27424
|
}
|
|
27421
27425
|
};
|
|
27422
27426
|
}
|
|
27423
|
-
function
|
|
27424
|
-
let a = zS(t, n), o = n.viable_slot === "full" || n.display_mode === "fullscreen", s = o ? void 0 :
|
|
27427
|
+
function eP(e, t, n, r, i) {
|
|
27428
|
+
let a = zS(t, n), o = n.viable_slot === "full" || n.display_mode === "fullscreen", s = o ? void 0 : lP(r), c = o ? 1 : tP(i ?? 0, r)?.displayScale ?? 1;
|
|
27425
27429
|
return {
|
|
27426
27430
|
...e.canvas_config.host_context,
|
|
27427
27431
|
...a,
|
|
27428
27432
|
containerDimensions: {
|
|
27429
|
-
...
|
|
27433
|
+
...uP(a.containerDimensions) ? a.containerDimensions : {},
|
|
27430
27434
|
...s === void 0 ? {} : { maxHeight: s },
|
|
27431
27435
|
displayScale: c
|
|
27432
27436
|
}
|
|
27433
27437
|
};
|
|
27434
27438
|
}
|
|
27435
|
-
function
|
|
27439
|
+
function tP(e, t) {
|
|
27436
27440
|
if (t === void 0 || !Number.isFinite(t) || t <= 0) return null;
|
|
27437
27441
|
let n = Math.min(e, 720);
|
|
27438
27442
|
if (n <= t) return {
|
|
@@ -27471,11 +27475,11 @@ function $N(e, t) {
|
|
|
27471
27475
|
}
|
|
27472
27476
|
};
|
|
27473
27477
|
}
|
|
27474
|
-
function
|
|
27475
|
-
let e = E(null), [t, n] = w(() =>
|
|
27478
|
+
function nP() {
|
|
27479
|
+
let e = E(null), [t, n] = w(() => iP(null));
|
|
27476
27480
|
return T(() => {
|
|
27477
27481
|
let t = () => n((t) => {
|
|
27478
|
-
let n =
|
|
27482
|
+
let n = iP(e.current);
|
|
27479
27483
|
return t.width === n.width && t.height === n.height && t.visualViewportHeight === n.visualViewportHeight ? t : n;
|
|
27480
27484
|
});
|
|
27481
27485
|
t(), globalThis.addEventListener("resize", t), globalThis.visualViewport?.addEventListener("resize", t);
|
|
@@ -27485,7 +27489,7 @@ function eP() {
|
|
|
27485
27489
|
};
|
|
27486
27490
|
}, []), [e, t];
|
|
27487
27491
|
}
|
|
27488
|
-
function
|
|
27492
|
+
function rP() {
|
|
27489
27493
|
let e = E(null), [t, n] = w();
|
|
27490
27494
|
return T(() => {
|
|
27491
27495
|
let t = e.current;
|
|
@@ -27501,7 +27505,7 @@ function tP() {
|
|
|
27501
27505
|
return a.observe(t), () => a.disconnect();
|
|
27502
27506
|
}, []), [e, t];
|
|
27503
27507
|
}
|
|
27504
|
-
function
|
|
27508
|
+
function iP(e) {
|
|
27505
27509
|
let t = globalThis.visualViewport?.height, n = e?.getBoundingClientRect();
|
|
27506
27510
|
if (n && n.width > 0 && n.height > 0) {
|
|
27507
27511
|
let e = t === void 0 ? void 0 : Math.max(0, (globalThis.innerHeight || 0) - t);
|
|
@@ -27517,8 +27521,8 @@ function nP(e) {
|
|
|
27517
27521
|
visualViewportHeight: t
|
|
27518
27522
|
};
|
|
27519
27523
|
}
|
|
27520
|
-
var
|
|
27521
|
-
function
|
|
27524
|
+
var aP = 72;
|
|
27525
|
+
function oP(e) {
|
|
27522
27526
|
let t = "absolute flex gap-2";
|
|
27523
27527
|
switch (e) {
|
|
27524
27528
|
case "safe-area-left": return `${t} left-4 w-[28rem] flex-col overflow-y-auto`;
|
|
@@ -27527,25 +27531,25 @@ function iP(e) {
|
|
|
27527
27531
|
case "full": return `${t} inset-4 flex-col items-stretch justify-stretch`;
|
|
27528
27532
|
}
|
|
27529
27533
|
}
|
|
27530
|
-
function
|
|
27534
|
+
function sP(e) {
|
|
27531
27535
|
return e.display_mode === "fullscreen" && e.preferred_slot !== "full" ? e.preferred_slot : e.viable_slot;
|
|
27532
27536
|
}
|
|
27533
|
-
function
|
|
27537
|
+
function cP() {
|
|
27534
27538
|
return !1;
|
|
27535
27539
|
}
|
|
27536
|
-
function
|
|
27540
|
+
function lP(e) {
|
|
27537
27541
|
return e === void 0 || !Number.isFinite(e) || e <= 0 ? 720 : Math.min(Math.floor(e), 720);
|
|
27538
27542
|
}
|
|
27539
|
-
function
|
|
27543
|
+
function uP(e) {
|
|
27540
27544
|
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
27541
27545
|
}
|
|
27542
|
-
function
|
|
27546
|
+
function dP(e) {
|
|
27543
27547
|
return e instanceof Error ? e : Error(String(e));
|
|
27544
27548
|
}
|
|
27545
27549
|
//#endregion
|
|
27546
27550
|
//#region ../core/src/hooks/use-replica-join-timeout.ts
|
|
27547
|
-
var
|
|
27548
|
-
function
|
|
27551
|
+
var fP = 1e4;
|
|
27552
|
+
function pP({ onTimeout: e, timeoutMs: t = fP, active: n = !0 }) {
|
|
27549
27553
|
let r = Dx().length > 0, [i, a] = w(!1), o = E(e);
|
|
27550
27554
|
return T(() => {
|
|
27551
27555
|
o.current = e;
|
|
@@ -27569,22 +27573,22 @@ function dP({ onTimeout: e, timeoutMs: t = uP, active: n = !0 }) {
|
|
|
27569
27573
|
}
|
|
27570
27574
|
//#endregion
|
|
27571
27575
|
//#region ../core/src/hooks/use-system-shutdown.ts
|
|
27572
|
-
function
|
|
27576
|
+
function mP(e) {
|
|
27573
27577
|
if (typeof e != "object" || !e) return !1;
|
|
27574
27578
|
let t = e;
|
|
27575
27579
|
return t.message_type === "system" && t.event_type === "system.shutdown";
|
|
27576
27580
|
}
|
|
27577
|
-
function
|
|
27581
|
+
function hP({ onShutdown: e }) {
|
|
27578
27582
|
let t = E(e);
|
|
27579
27583
|
T(() => {
|
|
27580
27584
|
t.current = e;
|
|
27581
27585
|
}, [e]), Qg({ onAppMessage: O((e) => {
|
|
27582
|
-
|
|
27586
|
+
mP(e?.data) && t.current();
|
|
27583
27587
|
}, []) });
|
|
27584
27588
|
}
|
|
27585
27589
|
//#endregion
|
|
27586
27590
|
//#region ../core/src/hooks/use-cvi-call.ts
|
|
27587
|
-
function
|
|
27591
|
+
function gP() {
|
|
27588
27592
|
let e = ph();
|
|
27589
27593
|
return {
|
|
27590
27594
|
joinCall: O(({ url: t, micOnly: n = !1 }) => {
|
|
@@ -27600,24 +27604,24 @@ function mP() {
|
|
|
27600
27604
|
}
|
|
27601
27605
|
//#endregion
|
|
27602
27606
|
//#region ../core/src/hooks/use-picture-in-picture.ts
|
|
27603
|
-
var
|
|
27604
|
-
function
|
|
27607
|
+
var _P = bn("PiP"), vP = 360, yP = 280;
|
|
27608
|
+
function bP() {
|
|
27605
27609
|
return globalThis.window !== void 0 && "documentPictureInPicture" in globalThis.window;
|
|
27606
27610
|
}
|
|
27607
|
-
function
|
|
27608
|
-
let { enabled: t, active: n } = e, [r, i] = w(null), a =
|
|
27611
|
+
function xP(e) {
|
|
27612
|
+
let { enabled: t, active: n } = e, [r, i] = w(null), a = bP(), o = mt(Cv), s = O(() => {
|
|
27609
27613
|
i((e) => (e && !e.closed && e.close(), null));
|
|
27610
27614
|
}, []), c = O(async () => {
|
|
27611
27615
|
if (a && !(!t || !n) && !(r && !r.closed)) try {
|
|
27612
27616
|
let e = await globalThis.window.documentPictureInPicture.requestWindow({
|
|
27613
|
-
width:
|
|
27614
|
-
height:
|
|
27617
|
+
width: vP,
|
|
27618
|
+
height: yP
|
|
27615
27619
|
}), t = Xe.replace(/:host(?=[\s,{])/g, ":host, :root"), n = e.document.createElement("style");
|
|
27616
27620
|
n.textContent = t, e.document.head.appendChild(n), e.document.body.style.margin = "0", e.document.body.style.width = "100%", e.document.body.style.height = "100vh", e.document.body.style.overflow = "hidden", e.addEventListener("pagehide", () => {
|
|
27617
27621
|
i((t) => t === e ? null : t);
|
|
27618
27622
|
}, { once: !0 }), i(e);
|
|
27619
27623
|
} catch (e) {
|
|
27620
|
-
|
|
27624
|
+
_P.warn("Failed to open PiP window", e);
|
|
27621
27625
|
}
|
|
27622
27626
|
}, [
|
|
27623
27627
|
a,
|
|
@@ -27638,13 +27642,13 @@ function yP(e) {
|
|
|
27638
27642
|
try {
|
|
27639
27643
|
e.metadata = new MediaMetadata({ title: "Tavus conversation" }), e.playbackState = "playing", l = !0;
|
|
27640
27644
|
} catch (e) {
|
|
27641
|
-
|
|
27645
|
+
_P.warn("mediaSession metadata setup failed", e);
|
|
27642
27646
|
}
|
|
27643
27647
|
let t = (t, n) => {
|
|
27644
27648
|
try {
|
|
27645
27649
|
e.setActionHandler(t, n), r.push(t);
|
|
27646
27650
|
} catch (e) {
|
|
27647
|
-
|
|
27651
|
+
_P.warn(`mediaSession.${t} not supported`, e);
|
|
27648
27652
|
}
|
|
27649
27653
|
};
|
|
27650
27654
|
t("enterpictureinpicture", () => {
|
|
@@ -27698,11 +27702,11 @@ function yP(e) {
|
|
|
27698
27702
|
}
|
|
27699
27703
|
//#endregion
|
|
27700
27704
|
//#region ../core/src/utils/device-preferences.ts
|
|
27701
|
-
var
|
|
27705
|
+
var SP = Gt(null), CP = {
|
|
27702
27706
|
active: !1,
|
|
27703
27707
|
video_shift_x: 0,
|
|
27704
27708
|
backdrop: { type: "snapshot_mirror" }
|
|
27705
|
-
},
|
|
27709
|
+
}, wP = ya(({ id: e, showAudioWave: t = !0 }) => {
|
|
27706
27710
|
let n = d_(e).isOff;
|
|
27707
27711
|
return /* @__PURE__ */ k("div", {
|
|
27708
27712
|
class: `relative aspect-square w-32 @max-mobile:w-24 rounded-box overflow-hidden bg-black/30 z-10 ${n ? "hidden" : ""}`,
|
|
@@ -27717,16 +27721,16 @@ var bP = Gt(null), xP = {
|
|
|
27717
27721
|
children: /* @__PURE__ */ k(bx, { id: e })
|
|
27718
27722
|
})]
|
|
27719
27723
|
});
|
|
27720
|
-
}),
|
|
27724
|
+
}), TP = ya(() => {
|
|
27721
27725
|
let e = Zh(), { isScreenSharing: t } = Ob(), n = Dx()[0];
|
|
27722
|
-
return /* @__PURE__ */ k(de, { children: [t && n && /* @__PURE__ */ k(
|
|
27726
|
+
return /* @__PURE__ */ k(de, { children: [t && n && /* @__PURE__ */ k(wP, { id: n }), e && /* @__PURE__ */ k(wP, {
|
|
27723
27727
|
id: e,
|
|
27724
27728
|
showAudioWave: !1
|
|
27725
27729
|
})] });
|
|
27726
|
-
}),
|
|
27730
|
+
}), EP = ya(() => /* @__PURE__ */ k("div", {
|
|
27727
27731
|
class: "absolute top-4 left-4 flex flex-col items-end gap-2 z-20",
|
|
27728
|
-
children: /* @__PURE__ */ k(
|
|
27729
|
-
})),
|
|
27732
|
+
children: /* @__PURE__ */ k(TP, {})
|
|
27733
|
+
})), DP = ya(({ isAudioOnly: e, canvasLayoutEffect: t, canvasRenderedSlot: n }) => {
|
|
27730
27734
|
let r = Zh(), i = !l_(r ?? "").isOff, a = Ox(e), o = l_(a.phase === "ready" ? a.replicaId : ""), s = !i && (o.state === "playable" || o.state === "loading"), c = t.active && !i && (!e || s);
|
|
27731
27735
|
return a.phase === "left" ? /* @__PURE__ */ k(vx, {}) : a.phase === "connecting" ? /* @__PURE__ */ k(_x, {}) : e && !s ? /* @__PURE__ */ k("div", {
|
|
27732
27736
|
class: "absolute inset-0 flex items-center justify-center",
|
|
@@ -27737,7 +27741,7 @@ var bP = Gt(null), xP = {
|
|
|
27737
27741
|
avatarOff: a.videoState.isOff,
|
|
27738
27742
|
canvasLayoutEffect: t,
|
|
27739
27743
|
smartSidecarActive: c
|
|
27740
|
-
}) : /* @__PURE__ */ k(
|
|
27744
|
+
}) : /* @__PURE__ */ k(OP, {
|
|
27741
27745
|
personaSessionId: a.replicaId,
|
|
27742
27746
|
localId: r,
|
|
27743
27747
|
isScreenSharing: i,
|
|
@@ -27746,11 +27750,11 @@ var bP = Gt(null), xP = {
|
|
|
27746
27750
|
canvasLayoutEffect: t,
|
|
27747
27751
|
canvasRenderedSlot: n
|
|
27748
27752
|
}), /* @__PURE__ */ k(lg, { sessionId: a.replicaId })] });
|
|
27749
|
-
}),
|
|
27753
|
+
}), OP = ya(({ personaSessionId: e, localId: t, isScreenSharing: n, avatarOff: r, smartSidecarActive: i, canvasLayoutEffect: a, canvasRenderedSlot: o }) => /* @__PURE__ */ k(gC, {
|
|
27750
27754
|
canvasLayoutEffect: a,
|
|
27751
27755
|
smartSidecarActive: i,
|
|
27752
27756
|
isScreenSharing: n,
|
|
27753
|
-
captureSnapshot:
|
|
27757
|
+
captureSnapshot: MP,
|
|
27754
27758
|
personaMode: "auto",
|
|
27755
27759
|
renderedSlot: o,
|
|
27756
27760
|
fill: (i) => /* @__PURE__ */ k(Mx, {
|
|
@@ -27760,7 +27764,7 @@ var bP = Gt(null), xP = {
|
|
|
27760
27764
|
avatarOff: r,
|
|
27761
27765
|
videoRef: i
|
|
27762
27766
|
})
|
|
27763
|
-
})),
|
|
27767
|
+
})), kP = ya(({ items: e }) => {
|
|
27764
27768
|
let [t, n] = w(!1), r = E(null);
|
|
27765
27769
|
return T(() => {
|
|
27766
27770
|
if (!t) return;
|
|
@@ -27790,8 +27794,8 @@ var bP = Gt(null), xP = {
|
|
|
27790
27794
|
children: e
|
|
27791
27795
|
})]
|
|
27792
27796
|
});
|
|
27793
|
-
}),
|
|
27794
|
-
let { joinCall: t, leaveCall: n } =
|
|
27797
|
+
}), AP = ya(({ items: e }) => e.length <= 1 ? /* @__PURE__ */ k(de, { children: e }) : /* @__PURE__ */ k(kP, { items: e })), jP = ya(({ onLeave: e }) => {
|
|
27798
|
+
let { joinCall: t, leaveCall: n } = gP(), r = Bg(), { config: i } = ev(), { session: a, end: o } = ix(), s = Zh(), c = E(null), l = mt(Wv)?.frameRef ?? c, [u, d] = w(!1), [f, p] = w(!1), [m, h] = w(CP), [g, _] = w(null), v = a.value?.conversationUrl, y = i.value.customization.conversation, b = y.modality === "audio", x = y.enable_chat, S = y.enable_closed_captions, C = y.enable_picture_in_picture, { pipWindow: ee } = xP({
|
|
27795
27799
|
enabled: C,
|
|
27796
27800
|
active: r === "joined-meeting"
|
|
27797
27801
|
});
|
|
@@ -27803,13 +27807,13 @@ var bP = Gt(null), xP = {
|
|
|
27803
27807
|
}), []);
|
|
27804
27808
|
let { camera: te, requestCamera: ne } = Nb(), { isCamMuted: re } = Eb(), ie = te.isGranted && !re;
|
|
27805
27809
|
T(() => {
|
|
27806
|
-
!b && r === "joined-meeting" && (
|
|
27810
|
+
!b && r === "joined-meeting" && (SP.value = ie);
|
|
27807
27811
|
}, [
|
|
27808
27812
|
b,
|
|
27809
27813
|
r,
|
|
27810
27814
|
ie
|
|
27811
27815
|
]);
|
|
27812
|
-
let ae = E(!b && !s &&
|
|
27816
|
+
let ae = E(!b && !s && SP.value === !0);
|
|
27813
27817
|
T(() => {
|
|
27814
27818
|
r === "joined-meeting" && ae.current && (ae.current = !1, ne());
|
|
27815
27819
|
}, [r, ne]), T(() => {
|
|
@@ -27833,10 +27837,10 @@ var bP = Gt(null), xP = {
|
|
|
27833
27837
|
let se = O(() => {
|
|
27834
27838
|
o(), n();
|
|
27835
27839
|
}, [o]);
|
|
27836
|
-
if (
|
|
27840
|
+
if (pP({
|
|
27837
27841
|
active: r === "joined-meeting",
|
|
27838
27842
|
onTimeout: se
|
|
27839
|
-
}),
|
|
27843
|
+
}), hP({ onShutdown: se }), !v) return null;
|
|
27840
27844
|
let ce = [/* @__PURE__ */ k(rx, { compact: !0 }, "screen-share")];
|
|
27841
27845
|
x && ce.push(/* @__PURE__ */ k(px, { compact: !0 }, "chat"));
|
|
27842
27846
|
let le = r === "left-meeting";
|
|
@@ -27846,14 +27850,14 @@ var bP = Gt(null), xP = {
|
|
|
27846
27850
|
/* @__PURE__ */ k("div", {
|
|
27847
27851
|
class: "relative w-full h-full z-[5]",
|
|
27848
27852
|
children: [
|
|
27849
|
-
/* @__PURE__ */ k(
|
|
27853
|
+
/* @__PURE__ */ k(DP, {
|
|
27850
27854
|
isAudioOnly: b,
|
|
27851
27855
|
canvasLayoutEffect: m,
|
|
27852
27856
|
canvasRenderedSlot: g
|
|
27853
27857
|
}),
|
|
27854
|
-
!b && /* @__PURE__ */ k(
|
|
27858
|
+
!b && /* @__PURE__ */ k(EP, {}),
|
|
27855
27859
|
/* @__PURE__ */ k(lx, {}),
|
|
27856
|
-
/* @__PURE__ */ k(
|
|
27860
|
+
/* @__PURE__ */ k(qN, {
|
|
27857
27861
|
debugEnabled: f,
|
|
27858
27862
|
onLayoutEffectChange: h,
|
|
27859
27863
|
onRenderedSlotChange: _
|
|
@@ -27881,7 +27885,7 @@ var bP = Gt(null), xP = {
|
|
|
27881
27885
|
/* @__PURE__ */ k(Qb, { level: !0 }),
|
|
27882
27886
|
!b && /* @__PURE__ */ k(ex, {}),
|
|
27883
27887
|
S && /* @__PURE__ */ k(cx, {}),
|
|
27884
|
-
/* @__PURE__ */ k(
|
|
27888
|
+
/* @__PURE__ */ k(AP, { items: ce }),
|
|
27885
27889
|
/* @__PURE__ */ k("button", {
|
|
27886
27890
|
type: "button",
|
|
27887
27891
|
class: "btn btn-control btn-error",
|
|
@@ -27898,7 +27902,7 @@ var bP = Gt(null), xP = {
|
|
|
27898
27902
|
]
|
|
27899
27903
|
}), ee && Ia(/* @__PURE__ */ k(Ax, { onLeave: se }), ee.document.body)] }) }) });
|
|
27900
27904
|
});
|
|
27901
|
-
function
|
|
27905
|
+
function MP(e) {
|
|
27902
27906
|
if (!e || e.readyState < 2 || !e.videoWidth || !e.videoHeight) return null;
|
|
27903
27907
|
let t = document.createElement("canvas"), n = Math.round(640 * (e.videoHeight / e.videoWidth));
|
|
27904
27908
|
t.width = 640, t.height = n;
|
|
@@ -27913,7 +27917,7 @@ function AP(e) {
|
|
|
27913
27917
|
}
|
|
27914
27918
|
//#endregion
|
|
27915
27919
|
//#region ../core/src/components/ui/loading-button.tsx
|
|
27916
|
-
function
|
|
27920
|
+
function NP({ loading: e = !1, disabled: t, class: n, children: r, ...i }) {
|
|
27917
27921
|
return /* @__PURE__ */ k("button", {
|
|
27918
27922
|
type: "button",
|
|
27919
27923
|
class: `btn relative ${n ? ` ${n}` : ""}`,
|
|
@@ -27929,7 +27933,7 @@ function jP({ loading: e = !1, disabled: t, class: n, children: r, ...i }) {
|
|
|
27929
27933
|
}
|
|
27930
27934
|
//#endregion
|
|
27931
27935
|
//#region ../core/src/components/hair-check/index.tsx
|
|
27932
|
-
function
|
|
27936
|
+
function PP(e, t, n) {
|
|
27933
27937
|
switch (t) {
|
|
27934
27938
|
case "granted": return n ? e?.cameraOptional ?? "Camera is optional — turn it on anytime." : e?.ready ?? "You're all set — join whenever you're ready.";
|
|
27935
27939
|
case "blocked": return e?.denied ?? "Microphone is blocked. Click the mic to see how to allow it.";
|
|
@@ -27940,7 +27944,7 @@ function MP(e, t, n) {
|
|
|
27940
27944
|
default: return e?.loading ?? "Getting your microphone ready...";
|
|
27941
27945
|
}
|
|
27942
27946
|
}
|
|
27943
|
-
function
|
|
27947
|
+
function FP({ message: e }) {
|
|
27944
27948
|
return /* @__PURE__ */ k("div", {
|
|
27945
27949
|
class: "relative max-w-[min(20rem,90%)]",
|
|
27946
27950
|
children: [/* @__PURE__ */ k("div", {
|
|
@@ -27961,7 +27965,7 @@ function NP({ message: e }) {
|
|
|
27961
27965
|
})]
|
|
27962
27966
|
});
|
|
27963
27967
|
}
|
|
27964
|
-
var
|
|
27968
|
+
var IP = ya(({ text: e, isJoining: t = !1, onJoin: n, onCancel: r }) => {
|
|
27965
27969
|
let i = ph(), { config: a } = ev(), { localSessionId: o, isCamMuted: s } = Eb(), { mic: c, camera: l, requestMic: u, requestCamera: d } = Nb(), f = a.value.customization.conversation.modality === "video";
|
|
27966
27970
|
T(() => {
|
|
27967
27971
|
u();
|
|
@@ -27976,7 +27980,7 @@ var PP = ya(({ text: e, isJoining: t = !1, onJoin: n, onCancel: r }) => {
|
|
|
27976
27980
|
l.isBlocked,
|
|
27977
27981
|
d
|
|
27978
27982
|
]);
|
|
27979
|
-
let h = f && p && !l.isGranted, g =
|
|
27983
|
+
let h = f && p && !l.isGranted, g = PP(e, c.status, h);
|
|
27980
27984
|
return /* @__PURE__ */ k(Bb, { children: /* @__PURE__ */ k("div", {
|
|
27981
27985
|
class: "absolute inset-0 motion-safe:animate-[tavusFadeUp_280ms_ease-out]",
|
|
27982
27986
|
children: [l.isGranted && !s ? /* @__PURE__ */ k("div", {
|
|
@@ -27997,14 +28001,14 @@ var PP = ya(({ text: e, isJoining: t = !1, onJoin: n, onCancel: r }) => {
|
|
|
27997
28001
|
})
|
|
27998
28002
|
}), /* @__PURE__ */ k("div", {
|
|
27999
28003
|
class: "absolute bottom-6 left-1/2 -translate-x-1/2 z-10 flex flex-col items-center gap-2 max-w-[90%]",
|
|
28000
|
-
children: [g && /* @__PURE__ */ k(
|
|
28004
|
+
children: [g && /* @__PURE__ */ k(FP, { message: g }), /* @__PURE__ */ k("div", {
|
|
28001
28005
|
class: "flex flex-wrap items-center justify-center gap-1.5 @max-mobile:gap-1",
|
|
28002
28006
|
children: [
|
|
28003
28007
|
/* @__PURE__ */ k("div", {
|
|
28004
28008
|
class: "flex items-center justify-center gap-1.5 shrink-0 @max-mobile:gap-1",
|
|
28005
28009
|
children: [/* @__PURE__ */ k(Qb, { level: !0 }), f && /* @__PURE__ */ k(ex, {})]
|
|
28006
28010
|
}),
|
|
28007
|
-
/* @__PURE__ */ k(
|
|
28011
|
+
/* @__PURE__ */ k(NP, {
|
|
28008
28012
|
class: "btn-accent ",
|
|
28009
28013
|
loading: t,
|
|
28010
28014
|
disabled: !p,
|
|
@@ -28023,8 +28027,8 @@ var PP = ya(({ text: e, isJoining: t = !1, onJoin: n, onCancel: r }) => {
|
|
|
28023
28027
|
})]
|
|
28024
28028
|
})]
|
|
28025
28029
|
}) });
|
|
28026
|
-
}),
|
|
28027
|
-
function
|
|
28030
|
+
}), LP = "Password required", RP = "Enter the password to start this conversation.", zP = "Password", BP = "Continue";
|
|
28031
|
+
function VP({ onSubmit: e, text: t, isSubmitting: n = !1, errorMessage: r }) {
|
|
28028
28032
|
let [i, a] = w(""), o = gt();
|
|
28029
28033
|
return /* @__PURE__ */ k("div", {
|
|
28030
28034
|
class: "absolute inset-0 z-30 flex items-center justify-center bg-black/50 backdrop-blur-sm p-4",
|
|
@@ -28044,18 +28048,18 @@ function zP({ onSubmit: e, text: t, isSubmitting: n = !1, errorMessage: r }) {
|
|
|
28044
28048
|
/* @__PURE__ */ k("h3", {
|
|
28045
28049
|
id: `${o}-title`,
|
|
28046
28050
|
class: "card-title text-base-content",
|
|
28047
|
-
children: t?.title ??
|
|
28051
|
+
children: t?.title ?? LP
|
|
28048
28052
|
}),
|
|
28049
28053
|
/* @__PURE__ */ k("p", {
|
|
28050
28054
|
class: "text-sm text-base-content/70",
|
|
28051
|
-
children: t?.description ??
|
|
28055
|
+
children: t?.description ?? RP
|
|
28052
28056
|
}),
|
|
28053
28057
|
/* @__PURE__ */ k("input", {
|
|
28054
28058
|
id: o,
|
|
28055
28059
|
type: "password",
|
|
28056
28060
|
autocomplete: "current-password",
|
|
28057
28061
|
class: "input input-bordered w-full",
|
|
28058
|
-
placeholder: t?.placeholder ??
|
|
28062
|
+
placeholder: t?.placeholder ?? zP,
|
|
28059
28063
|
value: i,
|
|
28060
28064
|
disabled: n,
|
|
28061
28065
|
onInput: (e) => a(e.target.value),
|
|
@@ -28066,12 +28070,12 @@ function zP({ onSubmit: e, text: t, isSubmitting: n = !1, errorMessage: r }) {
|
|
|
28066
28070
|
role: "alert",
|
|
28067
28071
|
children: r
|
|
28068
28072
|
}),
|
|
28069
|
-
/* @__PURE__ */ k(
|
|
28073
|
+
/* @__PURE__ */ k(NP, {
|
|
28070
28074
|
class: "btn-primary",
|
|
28071
28075
|
type: "submit",
|
|
28072
28076
|
disabled: !i.trim(),
|
|
28073
28077
|
loading: n,
|
|
28074
|
-
children: t?.submit ??
|
|
28078
|
+
children: t?.submit ?? BP
|
|
28075
28079
|
})
|
|
28076
28080
|
]
|
|
28077
28081
|
})
|
|
@@ -28080,35 +28084,35 @@ function zP({ onSubmit: e, text: t, isSubmitting: n = !1, errorMessage: r }) {
|
|
|
28080
28084
|
}
|
|
28081
28085
|
//#endregion
|
|
28082
28086
|
//#region ../core/src/components/captcha-challenge/index.tsx
|
|
28083
|
-
var
|
|
28084
|
-
function
|
|
28087
|
+
var HP = bn("CaptchaChallenge"), UP = 1;
|
|
28088
|
+
function WP(e) {
|
|
28085
28089
|
return typeof e == "object" && !!e && e.source === "tavus-captcha" && typeof e.type == "string";
|
|
28086
28090
|
}
|
|
28087
|
-
function
|
|
28091
|
+
function GP(e, t, n, r, i) {
|
|
28088
28092
|
return `${e.replace(/\/+$/, "")}${t.startsWith("/") ? t : `/${t}`}?deployment_uuid=${encodeURIComponent(n)}&action=${encodeURIComponent(r)}&parent_origin=${encodeURIComponent(i)}`;
|
|
28089
28093
|
}
|
|
28090
|
-
function
|
|
28091
|
-
let i = (mt(Tt).baseUrl ?? "https://tavusapi.com").replace(/\/+$/, ""), a = new URL(i).origin, [o, s] = w(0), [c, l] = w(0), [u, d] = w(!1), [f, p] = w(!1), m =
|
|
28094
|
+
function KP({ captcha: e, deploymentId: t, onToken: n, onFallback: r }) {
|
|
28095
|
+
let i = (mt(Tt).baseUrl ?? "https://tavusapi.com").replace(/\/+$/, ""), a = new URL(i).origin, [o, s] = w(0), [c, l] = w(0), [u, d] = w(!1), [f, p] = w(!1), m = GP(i, e.challenge_path, t, e.action, window.location.origin), h = O(() => {
|
|
28092
28096
|
p(!1), s((e) => e + 1);
|
|
28093
28097
|
}, []);
|
|
28094
28098
|
return T(() => {
|
|
28095
28099
|
function e(e) {
|
|
28096
28100
|
if (u || e.origin !== a) return;
|
|
28097
28101
|
let i = e.data;
|
|
28098
|
-
if (
|
|
28102
|
+
if (WP(i) && i.deployment_uuid === t) {
|
|
28099
28103
|
if (i.type === "interactive") {
|
|
28100
28104
|
p(!0);
|
|
28101
28105
|
return;
|
|
28102
28106
|
}
|
|
28103
28107
|
if (i.type === "token" && i.token) {
|
|
28104
|
-
|
|
28108
|
+
HP.info("Captcha token received"), p(!1), n(i.token);
|
|
28105
28109
|
return;
|
|
28106
28110
|
}
|
|
28107
28111
|
if (i.type === "expired") {
|
|
28108
|
-
|
|
28112
|
+
HP.info("Captcha token expired, reloading iframe"), h();
|
|
28109
28113
|
return;
|
|
28110
28114
|
}
|
|
28111
|
-
i.type === "error" && (
|
|
28115
|
+
i.type === "error" && (HP.warn("Captcha error received", i.code), c < UP ? (l((e) => e + 1), h()) : (HP.warn("Captcha error retries exhausted, falling back to no-token mode"), d(!0), r()));
|
|
28112
28116
|
}
|
|
28113
28117
|
}
|
|
28114
28118
|
return window.addEventListener("message", e), () => window.removeEventListener("message", e);
|
|
@@ -28138,7 +28142,7 @@ function WP({ captcha: e, deploymentId: t, onToken: n, onFallback: r }) {
|
|
|
28138
28142
|
}
|
|
28139
28143
|
//#endregion
|
|
28140
28144
|
//#region ../core/src/components/welcome/index.tsx
|
|
28141
|
-
function
|
|
28145
|
+
function qP({ text: e, onStart: t, isStarting: n }) {
|
|
28142
28146
|
let { config: r, deploymentId: i } = ev(), a = mt(G_), o = rb(r.value), s = o.btn_title ?? e?.fallback_button ?? "Start the conversation", c = r.value.customization.terms_content?.trim() ?? "", l = r.value.customization.terms_enabled === !0, u = c.length > 0, d = u && l, f = D(() => d && S_(i, c), [
|
|
28143
28147
|
d,
|
|
28144
28148
|
i,
|
|
@@ -28147,13 +28151,13 @@ function GP({ text: e, onStart: t, isStarting: n }) {
|
|
|
28147
28151
|
return /* @__PURE__ */ k(fb, {
|
|
28148
28152
|
title: o.title,
|
|
28149
28153
|
description: o.description,
|
|
28150
|
-
overlay: /* @__PURE__ */ k(de, { children: [te && /* @__PURE__ */ k(
|
|
28154
|
+
overlay: /* @__PURE__ */ k(de, { children: [te && /* @__PURE__ */ k(KP, {
|
|
28151
28155
|
captcha: _,
|
|
28152
28156
|
deploymentId: i,
|
|
28153
28157
|
onToken: b,
|
|
28154
28158
|
onFallback: x
|
|
28155
|
-
}, y), g && a ? /* @__PURE__ */ k(
|
|
28156
|
-
children: [/* @__PURE__ */ k(
|
|
28159
|
+
}, y), g && a ? /* @__PURE__ */ k(VP, { onSubmit: a.setPassword }) : null] }),
|
|
28160
|
+
children: [/* @__PURE__ */ k(NP, {
|
|
28157
28161
|
class: "btn-neutral rounded-box",
|
|
28158
28162
|
onClick: () => {
|
|
28159
28163
|
d && C && !f && T_(i, c), t();
|
|
@@ -28185,23 +28189,23 @@ function GP({ text: e, onStart: t, isStarting: n }) {
|
|
|
28185
28189
|
}
|
|
28186
28190
|
//#endregion
|
|
28187
28191
|
//#region ../core/src/shells/flow-state-body.tsx
|
|
28188
|
-
function
|
|
28192
|
+
function JP({ flow: e, welcomeText: t, onUnavailableCancel: n }) {
|
|
28189
28193
|
switch (e.state) {
|
|
28190
|
-
case "idle": return /* @__PURE__ */ k(
|
|
28194
|
+
case "idle": return /* @__PURE__ */ k(qP, {
|
|
28191
28195
|
text: t,
|
|
28192
28196
|
onStart: () => {
|
|
28193
28197
|
e.start();
|
|
28194
28198
|
},
|
|
28195
28199
|
isStarting: e.isStarting
|
|
28196
28200
|
});
|
|
28197
|
-
case "haircheck": return /* @__PURE__ */ k(
|
|
28201
|
+
case "haircheck": return /* @__PURE__ */ k(IP, {
|
|
28198
28202
|
onJoin: () => {
|
|
28199
28203
|
e.join();
|
|
28200
28204
|
},
|
|
28201
28205
|
onCancel: () => e.cancel(),
|
|
28202
28206
|
isJoining: e.isStarting
|
|
28203
28207
|
});
|
|
28204
|
-
case "call": return /* @__PURE__ */ k(
|
|
28208
|
+
case "call": return /* @__PURE__ */ k(jP, { onLeave: () => e.leave() });
|
|
28205
28209
|
case "ended": return /* @__PURE__ */ k(Tb, { onRestart: () => e.restart() });
|
|
28206
28210
|
case "unavailable": return /* @__PURE__ */ k(_b, {
|
|
28207
28211
|
cause: e.unavailableCause ?? "busy",
|
|
@@ -28219,7 +28223,7 @@ function KP({ flow: e, welcomeText: t, onUnavailableCancel: n }) {
|
|
|
28219
28223
|
}
|
|
28220
28224
|
//#endregion
|
|
28221
28225
|
//#region ../core/src/shells/embed/embed-shell.tsx
|
|
28222
|
-
function
|
|
28226
|
+
function YP() {
|
|
28223
28227
|
let { config: e, configError: t } = ev(), n = bb(), r = vb(), i = D(() => ({ fallback_button: n.start_button }), [n.start_button]), a = e.value.is_available, o = e.value.unavailable_reason;
|
|
28224
28228
|
return /* @__PURE__ */ k(Gv, { children: t.value ? /* @__PURE__ */ k(_b, {
|
|
28225
28229
|
cause: "error",
|
|
@@ -28229,18 +28233,18 @@ function qP() {
|
|
|
28229
28233
|
cause: o ?? "daily_limit",
|
|
28230
28234
|
canRetry: !1,
|
|
28231
28235
|
onRetry: () => {}
|
|
28232
|
-
}) : /* @__PURE__ */ k(
|
|
28236
|
+
}) : /* @__PURE__ */ k(JP, {
|
|
28233
28237
|
flow: r,
|
|
28234
28238
|
welcomeText: i
|
|
28235
28239
|
}) });
|
|
28236
28240
|
}
|
|
28237
28241
|
//#endregion
|
|
28238
28242
|
//#region ../core/src/embed/tavus-embed.tsx
|
|
28239
|
-
var
|
|
28240
|
-
function
|
|
28243
|
+
var XP = ":host {\n display: block;\n width: 100%;\n height: 100%;\n max-height: 100vh;\n overflow: hidden;\n background: transparent;\n font-family: system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, sans-serif;\n}";
|
|
28244
|
+
function ZP(e) {
|
|
28241
28245
|
return /* @__PURE__ */ k(de, { children: [
|
|
28242
28246
|
/* @__PURE__ */ k("style", { dangerouslySetInnerHTML: { __html: Xe } }),
|
|
28243
|
-
/* @__PURE__ */ k("style", { dangerouslySetInnerHTML: { __html:
|
|
28247
|
+
/* @__PURE__ */ k("style", { dangerouslySetInnerHTML: { __html: XP } }),
|
|
28244
28248
|
/* @__PURE__ */ k(Dt, {
|
|
28245
28249
|
"deployment-id": e["deployment-id"],
|
|
28246
28250
|
"override-config": e["override-config"],
|
|
@@ -28251,14 +28255,14 @@ function YP(e) {
|
|
|
28251
28255
|
token: e.token,
|
|
28252
28256
|
children: /* @__PURE__ */ k(Si, {
|
|
28253
28257
|
fallback: /* @__PURE__ */ k(Uv, {}),
|
|
28254
|
-
children: /* @__PURE__ */ k(wi, { children: /* @__PURE__ */ k(K_, { children: /* @__PURE__ */ k(vv, { children: /* @__PURE__ */ k(Sv, { children: /* @__PURE__ */ k(wv, { children: /* @__PURE__ */ k(Pv, { children: /* @__PURE__ */ k(
|
|
28258
|
+
children: /* @__PURE__ */ k(wi, { children: /* @__PURE__ */ k(K_, { children: /* @__PURE__ */ k(vv, { children: /* @__PURE__ */ k(Sv, { children: /* @__PURE__ */ k(wv, { children: /* @__PURE__ */ k(Pv, { children: /* @__PURE__ */ k(YP, {}) }) }) }) }) }) })
|
|
28255
28259
|
})
|
|
28256
28260
|
})
|
|
28257
28261
|
] });
|
|
28258
28262
|
}
|
|
28259
|
-
var
|
|
28260
|
-
function
|
|
28261
|
-
|
|
28263
|
+
var QP;
|
|
28264
|
+
function $P() {
|
|
28265
|
+
QP ||= He(ZP, "tavus-embed", [
|
|
28262
28266
|
"deployment-id",
|
|
28263
28267
|
"override-config",
|
|
28264
28268
|
"conversational-context",
|
|
@@ -28274,7 +28278,7 @@ function ZP() {
|
|
|
28274
28278
|
Le(null), bn("Widget");
|
|
28275
28279
|
//#endregion
|
|
28276
28280
|
//#region src/integration.ts
|
|
28277
|
-
var
|
|
28281
|
+
var eF = [
|
|
28278
28282
|
"tavus:chat-message",
|
|
28279
28283
|
"tavus:conversation-ended",
|
|
28280
28284
|
"tavus:conversation-started",
|
|
@@ -28285,7 +28289,7 @@ var QP = [
|
|
|
28285
28289
|
"tavus:ready",
|
|
28286
28290
|
"tavus:state-change",
|
|
28287
28291
|
"tavus:tool-call"
|
|
28288
|
-
],
|
|
28292
|
+
], tF = class {
|
|
28289
28293
|
element = null;
|
|
28290
28294
|
tagName;
|
|
28291
28295
|
constructor(e = "tavus-embed") {
|
|
@@ -28332,6 +28336,6 @@ var QP = [
|
|
|
28332
28336
|
};
|
|
28333
28337
|
//#endregion
|
|
28334
28338
|
//#region src/index.ts
|
|
28335
|
-
typeof window < "u" &&
|
|
28339
|
+
typeof window < "u" && $P();
|
|
28336
28340
|
//#endregion
|
|
28337
|
-
export {
|
|
28341
|
+
export { eF as TAVUS_EVENT_NAMES, tF as TavusIntegration };
|