@tavus/widget 0.0.1-beta.7 → 0.0.1-beta.8
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 +16 -16
- package/dist/index.mjs +1854 -1832
- package/package.json +1 -1
package/dist/index.iife.js
CHANGED
|
@@ -47,9 +47,9 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
47
47
|
pointer-events: none;
|
|
48
48
|
`,document.body.appendChild(n),t.layout||=`custom-v1`,e.wrap(n,t)}},{key:`getCallInstance`,value:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:void 0;return e?cm[e]:Object.values(cm)[0]}}]);var t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,ee,T,te,ne,re,ie,ae,oe,se,ce,le,ue,de,fe}();function wm(e){if(e.extension){if(typeof e.extension!=`string`)throw Error(`Error starting dial out: extension must be a string`);if(e.extension.length>20)throw Error(`Error starting dial out: extension length must be less than or equal to 20`)}if(e.waitBeforeExtensionDialSec){if(typeof e.waitBeforeExtensionDialSec!=`number`)throw Error(`Error starting dial out: waitBeforeExtensionDialSec must be a number`);if(e.waitBeforeExtensionDialSec>60)throw Error(`Error starting dial out: waitBeforeExtensionDialSec must be less than or equal to 60`);if(!e.extension)throw Error(`Error starting dial out: waitBeforeExtensionDialSec requires a phoneNumber and extension`)}}function Tm(e,t){var n={};for(var r in e)if(e[r]instanceof MediaStreamTrack)console.warn(`MediaStreamTrack found in props or cache.`,r),n[r]=Tf;else if(r===`dailyConfig`){if(e[r].modifyLocalSdpHook){var i=window._daily.instances[t].customCallbacks||{};i.modifyLocalSdpHook=e[r].modifyLocalSdpHook,window._daily.instances[t].customCallbacks=i,delete e[r].modifyLocalSdpHook}if(e[r].modifyRemoteSdpHook){var a=window._daily.instances[t].customCallbacks||{};a.modifyRemoteSdpHook=e[r].modifyRemoteSdpHook,window._daily.instances[t].customCallbacks=a,delete e[r].modifyRemoteSdpHook}n[r]=e[r]}else n[r]=e[r];return n}function Em(e){var t=arguments.length>2?arguments[2]:void 0;if(e!==`joined-meeting`){var n=`${arguments.length>1&&arguments[1]!==void 0?arguments[1]:`This daily-js method`} only supported after join.`;throw t&&(n+=` ${t}`),console.error(n),Error(n)}}function Dm(e,t){return[`joining-meeting`,`joined-meeting`].includes(e)||t}function Om(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:`This daily-js method`,r=arguments.length>3?arguments[3]:void 0;if(Dm(e,t)){var i=`${n} not supported after joining a meeting.`;throw r&&(i+=` ${r}`),console.error(i),Error(i)}}function km(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:`This daily-js method`,n=arguments.length>2?arguments[2]:void 0;if(!e){var r=`${t}${arguments.length>3&&arguments[3]!==void 0&&arguments[3]?` requires preAuth() or startCamera() to initialize call state.`:` requires preAuth(), startCamera(), or join() to initialize call state.`}`;throw n&&(r+=` ${n}`),console.error(r),Error(r)}}function Am(e){if(e){var t=`A pre-call quality test is in progress. Please try ${arguments.length>1&&arguments[1]!==void 0?arguments[1]:`This daily-js method`} again once testing has completed. Use stopTestCallQuality() to end it early.`;throw console.error(t),Error(t)}}function jm(e){if(!e){var t=`${arguments.length>1&&arguments[1]!==void 0?arguments[1]:`This daily-js method`} is only supported on custom callObject instances`;throw console.error(t),Error(t)}}function Mm(e){if(e){var t=`${arguments.length>1&&arguments[1]!==void 0?arguments[1]:`This daily-js method`} is only supported as part of Daily's Prebuilt`;throw console.error(t),Error(t)}}function H(){if(B())throw Error(`This daily-js method is not currently supported in React Native`)}function Nm(){if(!B())throw Error(`This daily-js method is only supported in React Native`)}function Pm(e){if(e===void 0)return!0;var t;if(typeof e==`string`)t=e;else try{t=JSON.stringify(e),Io(JSON.parse(t),e)||console.warn(`The userData provided will be modified when serialized.`)}catch(e){throw Error(`userData must be serializable to JSON: ${e}`)}if(t.length>4096)throw Error(`userData is too large (${t.length} characters). Maximum size suppported is 4096.`);return!0}function Fm(e,t){for(var n=t.allowAllParticipantsKey,r=function(e){var t=[`local`];return n||t.push(`*`),e&&!t.includes(e)},i=function(e){return!!(e.layer===void 0||Number.isInteger(e.layer)&&e.layer>=0||e.layer===`inherit`)},a=function(e){return!!e&&!(e.video&&!i(e.video))&&!(e.screenVideo&&!i(e.screenVideo))},o=0,s=Object.entries(e);o<s.length;o++){var c=Oo(s[o],2),l=c[0],u=c[1];if(!r(l)||!a(u))return!1}return!0}function Im(e){if(I(e)!==`object`)return!1;for(var t=0,n=Object.entries(e);t<n.length;t++){var r=Oo(n[t],2),i=r[0],a=r[1];switch(i){case`video`:if(I(a)!==`object`)return!1;for(var o=0,s=Object.entries(a);o<s.length;o++){var c=Oo(s[o],2),l=c[0],u=c[1];switch(l){case`processor`:if(!zm(u))return!1;break;case`settings`:if(!Bm(u))return!1;break;default:return!1}}break;case`audio`:if(I(a)!==`object`)return!1;for(var d=0,f=Object.entries(a);d<f.length;d++){var p=Oo(f[d],2),m=p[0],h=p[1];switch(m){case`processor`:if(!Rm(h))return!1;break;case`settings`:if(!Bm(h))return!1;break;default:return!1}}break;default:return!1}}return!0}function Lm(e,t,n){var r,i=[];e.video&&e.video.processor&&(Vf((r=t?.useLegacyVideoProcessor)!=null&&r)||(e.video.settings?delete e.video.processor:delete e.video,i.push(`video`))),e.audio&&e.audio.processor&&(Hf()||(e.audio.settings?delete e.audio.processor:delete e.audio,i.push(`audio`))),i.length>0&&console.error(`Ignoring settings for browser- or platform-unsupported input processor(s): ${i.join(`, `)}`),e.audio&&e.audio.settings&&(e.audio.settings.customTrack?(n.audioTrack=e.audio.settings.customTrack,e.audio.settings={customTrack:Tf}):delete n.audioTrack),e.video&&e.video.settings&&(e.video.settings.customTrack?(n.videoTrack=e.video.settings.customTrack,e.video.settings={customTrack:Tf}):delete n.videoTrack)}function Rm(e){if(B())return console.warn(`Video processing is not yet supported in React Native`),!1;var t=[`type`];return!!e&&I(e)===`object`&&(Object.keys(e).filter((function(e){return!t.includes(e)})).forEach((function(t){console.warn(`invalid key inputSettings -> audio -> processor : ${t}`),delete e[t]})),!!function(e){return typeof e==`string`?Object.values(Df).includes(e)?!0:(console.error(`inputSettings audio processor type invalid`),!1):!1}(e.type))}function zm(e){if(B())return console.warn(`Video processing is not yet supported in React Native`),!1;var t=[`type`,`config`];return!e||I(e)!==`object`||!function(e){return typeof e==`string`?Object.values(Ef).includes(e)?!0:(console.error(`inputSettings video processor type invalid`),!1):!1}(e.type)||e.config&&(I(e.config)!==`object`||!function(e,t){var n=Object.keys(t);if(n.length===0)return!0;var r=`invalid object in inputSettings -> video -> processor -> config`;switch(e){case Ef.BGBLUR:return n.length>1||n[0]!==`strength`?(console.error(r),!1):!(typeof t.strength!=`number`||t.strength<=0||t.strength>1||isNaN(t.strength))||(console.error(`${r}; expected: {0 < strength <= 1}, got: ${t.strength}`),!1);case Ef.BGIMAGE:return!(t.source!==void 0&&!function(e){if(e.source==="default")return e.type=`default`,!0;if(e.source instanceof ArrayBuffer)return!0;if($o(e.source))return e.type=`url`,!!function(e){var t=new URL(e),n=t.pathname;if(t.protocol===`data:`)try{var r=n.substring(n.indexOf(`:`)+1,n.indexOf(`;`)).split(`/`)[1];return kf.includes(r)}catch(e){return console.error(`failed to deduce blob content type`,e),!1}var i=n.split(`.`).at(-1).toLowerCase().trim();return kf.includes(i)}(e.source)||(console.error(`invalid image type; supported types: [${kf.join(`, `)}]`),!1);return t=e.source,n=Number(t),isNaN(n)||!Number.isInteger(n)||n<=0||n>10?(console.error(`invalid image selection; must be an int, > 0, <= 10`),!1):(e.type=`daily-preselect`,!0);var t,n}(t));default:return!0}}(e.type,e.config))?!1:(Object.keys(e).filter((function(e){return!t.includes(e)})).forEach((function(t){console.warn(`invalid key inputSettings -> video -> processor : ${t}`),delete e[t]})),!0)}function Bm(e){return I(e)===`object`&&(!e.customTrack||e.customTrack instanceof MediaStreamTrack)}function Vm(){return`inputSettings must be of the form: { video?: { processor?: { type: [ ${Object.values(Ef).join(` | `)} ], config?: {} } }, audio?: { processor: {type: [ ${Object.values(Df).join(` | `)} ] } } }`}function Hm(e){return`receiveSettings must be of the form { [<remote participant id> | ${yd}${e.allowAllParticipantsKey?` | "*"`:``}]: { [video: [{ layer: [<non-negative integer> | "inherit"] } | "inherit"]], [screenVideo: [{ layer: [<non-negative integer> | "inherit"] } | "inherit"]] }}}`}function Um(){return`customIntegrations should be an object of type ${JSON.stringify(vm)}.`}function Wm(e){if(e&&I(e)!==`object`||Array.isArray(e))return console.error(`customTrayButtons should be an Object of the type ${JSON.stringify(_m)}.`),!1;if(e)for(var t=0,n=Object.entries(e);t<n.length;t++)for(var r=Oo(n[t],1)[0],i=0,a=Object.entries(e[r]);i<a.length;i++){var o=Oo(a[i],2),s=o[0],c=o[1],l=_m.id[s];if(!l)return console.error(`customTrayButton does not support key ${s}`),!1;switch(s){case`iconPath`:case`iconPathDarkMode`:if(!$o(c))return console.error(`customTrayButton ${s} should be a url.`),!1;break;case`visualState`:if(![`default`,`sidebar-open`,`active`].includes(c))return console.error(`customTrayButton ${s} should be ${l}. Got: ${c}`),!1;break;default:if(I(c)!==l)return console.error(`customTrayButton ${s} should be a ${l}.`),!1}}return!0}function Gm(e){if(!e||e&&I(e)!==`object`||Array.isArray(e))return console.error(Um()),!1;for(var t=function(e){return`${e} should be ${vm.id[e]}`},n=function(e,t){return console.error(`customIntegration ${e}: ${t}`)},r=0,i=Object.entries(e);r<i.length;r++){var a=Oo(i[r],1)[0];if(!(`label`in e[a]))return n(a,`label is required`),!1;if(!(`location`in e[a]))return n(a,`location is required`),!1;if(!(`src`in e[a])&&!(`srcdoc`in e[a]))return n(a,`src or srcdoc is required`),!1;for(var o=0,s=Object.entries(e[a]);o<s.length;o++){var c=Oo(s[o],2),l=c[0],u=c[1];switch(l){case`allow`:case`csp`:case`name`:case`referrerPolicy`:case`sandbox`:if(typeof u!=`string`)return n(a,t(l)),!1;break;case`iconURL`:if(!$o(u))return n(a,`${l} should be a url`),!1;break;case`src`:if(`srcdoc`in e[a])return n(a,`cannot have both src and srcdoc`),!1;if(!$o(u))return n(a,`src "${u}" is not a valid URL`),!1;break;case`srcdoc`:if(`src`in e[a])return n(a,`cannot have both src and srcdoc`),!1;if(typeof u!=`string`)return n(a,t(l)),!1;break;case`location`:if(![`main`,`sidebar`].includes(u))return n(a,t(l)),!1;break;case`controlledBy`:if(u!==`*`&&u!==`owners`&&(!Array.isArray(u)||u.some((function(e){return typeof e!=`string`}))))return n(a,t(l)),!1;break;case`shared`:if((!Array.isArray(u)||u.some((function(e){return typeof e!=`string`})))&&u!==`owners`&&typeof u!=`boolean`)return n(a,t(l)),!1;break;default:if(!vm.id[l])return console.error(`customIntegration does not support key ${l}`),!1}}}return!0}function Km(e,t){if(t===void 0)return!1;switch(I(t)){case`string`:return I(e)===t;case`object`:if(I(e)!==`object`)return!1;for(var n in e)if(!Km(e[n],t[n]))return!1;return!0;default:return!1}}function qm(e,t){var n=e.sessionId,r=e.toEndPoint,i=e.callerId,a=e.useSipRefer;if(!n||!r)throw Error(`${t}() requires a sessionId and toEndPoint`);if(typeof n!=`string`||typeof r!=`string`)throw Error(`Invalid paramater: sessionId and toEndPoint must be of type string`);if(a&&!r.startsWith(`sip:`))throw Error(`"toEndPoint" must be a "sip" address`);if(!r.startsWith(`sip:`)&&!r.startsWith(`+`))throw Error(`toEndPoint: ${r} must starts with either "sip:" or "+"`);if(i&&typeof i!=`string`)throw Error(`callerId must be of type string`);if(i&&!r.startsWith(`+`))throw Error(`callerId is only valid when transferring to a PSTN number`)}function Jm(e){if(I(e)!==`object`)throw Error(`RemoteMediaPlayerSettings: must be "object" type`);if(e.state&&!Object.values(Of).includes(e.state))throw Error(`Invalid value for RemoteMediaPlayerSettings.state, valid values are: `+JSON.stringify(Of));if(e.volume){if(typeof e.volume!=`number`)throw Error(`RemoteMediaPlayerSettings.volume: must be "number" type`);if(e.volume<0||e.volume>2)throw Error(`RemoteMediaPlayerSettings.volume: must be between 0.0 - 2.0`)}}function Ym(e,t,n){return!(typeof e!=`number`||e<t||e>n)}function Xm(e,t){return e&&!t&&delete e.data,e}function Zm(e){"@babel/helpers - typeof";return Zm=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},Zm(e)}var U=function(){return U=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},U.apply(this,arguments)};function Qm(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function $m(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})}function eh(e,t){var n={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},r,i,a,o;return o={next:s(0),throw:s(1),return:s(2)},typeof Symbol==`function`&&(o[Symbol.iterator]=function(){return this}),o;function s(e){return function(t){return c([e,t])}}function c(s){if(r)throw TypeError(`Generator is already executing.`);for(;o&&(o=0,s[0]&&(n=0)),n;)try{if(r=1,i&&(a=s[0]&2?i.return:s[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,s[1])).done)return a;switch(i=0,a&&(s=[s[0]&2,a.value]),s[0]){case 0:case 1:a=s;break;case 4:return n.label++,{value:s[1],done:!1};case 5:n.label++,i=s[1],s=[0];continue;case 7:s=n.ops.pop(),n.trys.pop();continue;default:if((a=n.trys,!(a=a.length>0&&a[a.length-1]))&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!a||s[1]>a[0]&&s[1]<a[3])){n.label=s[1];break}if(s[0]===6&&n.label<a[1]){n.label=a[1],a=s;break}if(a&&n.label<a[2]){n.label=a[2],n.ops.push(s);break}a[2]&&n.ops.pop(),n.trys.pop();continue}s=t.call(e,n)}catch(e){s=[6,e],i=0}finally{r=a=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}}function th(e){var t=typeof Symbol==`function`&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length==`number`)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw TypeError(t?`Object is not iterable.`:`Symbol.iterator is not defined.`)}function nh(e,t){var n=typeof Symbol==`function`&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,a=[],o;try{for(;(t===void 0||t-- >0)&&!(i=r.next()).done;)a.push(i.value)}catch(e){o={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a}function rh(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}var ih=Fe(null),ah=function(){var e=ft(ih);return pt(e),e},oh=Fe({on:function(){},off:function(){}}),sh=-1,ch=function(){return sh--},lh=1,uh=function(){return lh++},W=function(e,t,n){n===void 0&&(n=!1);var r=ft(oh),i=r.off,a=r.on,o=nh(E(!1),2),s=o[0],c=o[1],l=O(0),u=k(function(){return n?ch():uh()},[n]);D(function(){if(!(!e||s)){if(l.current>1e5){console.error(`useDailyEvent called with potentially non-memoized event callback or due to too many re-renders.
|
|
49
49
|
Memoize using useCallback to avoid re-render loop or reduce the amount of state transitions the callback depends on.
|
|
50
|
-
Passed callback for '${e}' event is NOT registered.`,t),c(!0);return}l.current++;var n=setTimeout(function(){l.current=0},50);return a(e,t,u),function(){clearTimeout(n),i(e,u)}}},[t,e,u,s,i,a]),pt({event:e,eventId:u,isBlocked:s,callback:t})};function dh(e,t){var n,r;if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(var i=0;i<e.length;i++)if(!dh(e[i],t[i]))return!1;return!0}if(MediaStream&&e instanceof MediaStream&&t instanceof MediaStream)return e.id===t.id&&e.active===t.active&&e.getTracks().length===t.getTracks().length&&e.getTracks().every(function(e,n){return dh(e,t.getTracks()[n])});if(MediaStreamTrack&&e instanceof MediaStreamTrack&&t instanceof MediaStreamTrack)return e.id===t.id&&e.kind===t.kind&&e.readyState===t.readyState;if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();if(e instanceof RegExp&&t instanceof RegExp)return e.source===t.source&&e.flags===t.flags;if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;var a=Array.from(e).sort(),o=Array.from(t).sort();return a.every(function(e,t){return dh(e,o[t])})}if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;try{for(var s=th(e.entries()),c=s.next();!c.done;c=s.next()){var l=nh(c.value,2),u=l[0],d=l[1];if(!t.has(u)||!dh(d,t.get(u)))return!1}}catch(e){n={error:e}}finally{try{c&&!c.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}return!0}if(Zm(e)!==`object`||e===null||Zm(t)!==`object`||t===null)return!1;var f=Object.keys(e),p=Object.keys(t);if(f.length!==p.length)return!1;for(var i=0;i<f.length;i++){var u=f[i];if(!Object.prototype.hasOwnProperty.call(t,u)||!dh(e[u],t[u]))return!1}return!0}function fh(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(var n=0;n<e.length;n++){var r=e[n],i=t[n],a=r!==null&&Zm(r)===`object`,o=i!==null&&Zm(i)===`object`;if(a||o){if(!dh(r,i))return!1}else if(r!==i)return!1}return!0}function G(e){return`daily-react-`+e}function ph(e){var t=new Map,n=new Map;return function(r){if(!t.has(r)){var i=N(function(t){var i=e.get(r)(t),a=n.get(r);return a!=null&&e.equals(i,a)?a:(n.set(r,i),i)});t.set(r,i)}return t.get(r)}}var mh=`::`,hh=`;`,gh=function(e,t){return e+mh+t},_h=function(e,t){return e+mh+t.join(hh)},vh=function(e,t){return bh(gh(e,t))},yh=sa(function(e){var t=N([]);return t.debugLabel=G(`participant-property-paths-${e}`),t}),bh=sa(function(e){var t=N(null);return t.debugLabel=G(`participant-property-${e}`),t}),xh=ph({equals:fh,get:function(e){return function(t){var n=nh(e.split(mh),2),r=n[0];return n[1].split(hh).map(function(e){return t(vh(r,e))})}}}),Sh=function(e,t){var n,r=mo(Array.isArray(t)?xh(_h(e,t)):bh(gh(e,t)));return pt(Array.isArray(t)?t.reduce(function(e,t,n){return e[t]=r[n],e},{}):(n={},n[t]=r,n)),r},Ch=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};function wh(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,`default`)?e.default:e}var Th,Eh;function Dh(){if(Eh)return Th;Eh=1;var e=`Expected a function`,t=NaN,n=`[object Symbol]`,r=/^\s+|\s+$/g,i=/^[-+]0x[0-9a-f]+$/i,a=/^0b[01]+$/i,o=/^0o[0-7]+$/i,s=parseInt,c=Zm(Ch)==`object`&&Ch&&Ch.Object===Object&&Ch,l=(typeof self>`u`?`undefined`:Zm(self))==`object`&&self&&self.Object===Object&&self,u=c||l||Function(`return this`)(),d=Object.prototype.toString,f=Math.max,p=Math.min,m=function(){return u.Date.now()};function h(t,n,r){var i,a,o,s,c,l,u=0,d=!1,h=!1,g=!0;if(typeof t!=`function`)throw TypeError(e);n=b(n)||0,_(r)&&(d=!!r.leading,h=`maxWait`in r,o=h?f(b(r.maxWait)||0,n):o,g=`trailing`in r?!!r.trailing:g);function v(e){var n=i,r=a;return i=a=void 0,u=e,s=t.apply(r,n),s}function y(e){return u=e,c=setTimeout(C,n),d?v(e):s}function x(e){var t=e-l,r=e-u,i=n-t;return h?p(i,o-r):i}function S(e){var t=e-l,r=e-u;return l===void 0||t>=n||t<0||h&&r>=o}function C(){var e=m();if(S(e))return w(e);c=setTimeout(C,x(e))}function w(e){return c=void 0,g&&i?v(e):(i=a=void 0,s)}function ee(){c!==void 0&&clearTimeout(c),u=0,i=l=a=c=void 0}function T(){return c===void 0?s:w(m())}function te(){var e=m(),t=S(e);if(i=arguments,a=this,l=e,t){if(c===void 0)return y(l);if(h)return c=setTimeout(C,n),v(l)}return c===void 0&&(c=setTimeout(C,n)),s}return te.cancel=ee,te.flush=T,te}function g(t,n,r){var i=!0,a=!0;if(typeof t!=`function`)throw TypeError(e);return _(r)&&(i=`leading`in r?!!r.leading:i,a=`trailing`in r?!!r.trailing:a),h(t,n,{leading:i,maxWait:n,trailing:a})}function _(e){var t=Zm(e);return!!e&&(t==`object`||t==`function`)}function v(e){return!!e&&Zm(e)==`object`}function y(e){return Zm(e)==`symbol`||v(e)&&d.call(e)==n}function b(e){if(typeof e==`number`)return e;if(y(e))return t;if(_(e)){var n=typeof e.valueOf==`function`?e.valueOf():e;e=_(n)?n+``:n}if(typeof e!=`string`)return e===0?e:+e;e=e.replace(r,``);var c=a.test(e);return c||o.test(e)?s(e.slice(2),c?2:8):i.test(e)?t:+e}return Th=g,Th}var Oh=wh(Dh()),kh=function(e,t,n,r){n===void 0&&(n=500),r===void 0&&(r=!1);var i=ft(oh),a=i.off,o=i.on,s=k(function(){var t;return Array.isArray(e)?e.reduce(function(e,t){return e[t]=r?ch():uh(),e},{}):(t={},t[e]=r?ch():uh(),t)},[e,r]),c=O([]);W(`call-instance-destroyed`,A(function(){c.current.length=0},[]));var l=k(function(){return Oh(function(){c.current.length!==0&&(t(c.current),c.current.length=0)},n,{trailing:!0})},[t,n]);D(function(){if(e){var t=function(e){c.current.push(e),l()};return Array.isArray(e)?e.forEach(function(e){return o(e,t,s[e])}):o(e,t,s[e]),function(){Array.isArray(e)?e.forEach(function(e){return a(e,s[e])}):a(e,s[e])}}},[l,e,s,a,o]),pt({event:e,eventId:s})},Ah=function(e,t,n){if(t===void 0&&(t=``),n===void 0&&(n=new Set),Zm(e)!==`object`||e===null||n.has(e))return[t];n.add(e);var r=[];for(var i in e)if(Object.prototype.hasOwnProperty.call(e,i)){var a=t?`${t}.${i}`:i;r.push.apply(r,rh([a],nh(Ah(e[i],a,n)),!1))}return n.delete(e),r},jh=function(e){return Ah(e)},Mh=function(e,t){return String(t).split(`.`).filter(function(e){return e.length}).reduce(function(e,t){return e&&e[t]},e)},Nh=function(e,t){return t.map(function(t){return Mh(e,t)})},Ph=N(null);Ph.debugLabel=G(`active-id`);var Fh=N(``);Fh.debugLabel=G(`local-id`);var Ih=N(null);Ih.debugLabel=G(`local-join-date`);var Lh=N([]);Lh.debugLabel=G(`participant-ids`);var Rh=sa(function(e){var t=N(null);return t.debugLabel=G(`participant-${e}`),t}),zh=N([]);zh.debugLabel=G(`waiting-participants`);var Bh=sa(function(e){var t=N({awaitingAccess:{level:`full`},id:e,name:``});return t.debugLabel=G(`waiting-participant-${e}`),t}),Vh=function(e){var t=e.children,n=ah(),r=nh(E(!1),2),i=r[0],a=r[1],o=F(A(function(e,t,n){t(Fh,n.local.session_id);var r=Object.values(n);t(Lh,r.map(function(e){return e.session_id})),r.forEach(function(e){t(Rh(e.session_id),e);var n=jh(e);t(yh(e.session_id),n),n.forEach(function(n){var r=nh(Nh(e,[n]),1)[0];t(vh(e.session_id,n),r)})}),a(!0)},[]));D(function(){if(!(!n||i)){var e=setInterval(function(){var t=n.participants();`local`in t&&(o(t),clearInterval(e))},100);return function(){clearInterval(e)}}},[n,i,o]);var s=A(function(){if(n){var e=n?.participants();e.local&&o(e)}},[n,o]);W(`started-camera`,s,!0),W(`access-state-updated`,s,!0),W(`joining-meeting`,F(A(function(e,t){t(Ih,new Date),s()},[s])),!0),W(`joined-meeting`,A(function(e){o(e.participants)},[o]),!0);var c=F(A(function(e,t){t(Fh,``),t(Ph,null),e(Lh).forEach(function(e){return Rh.remove(e)}),t(Lh,[])},[]));return W(`call-instance-destroyed`,c,!0),W(`left-meeting`,c,!0),kh([`active-speaker-change`,`participant-joined`,`participant-updated`,`participant-left`],F(A(function(e,t,n){n.length&&n.forEach(function(n){switch(n.action){case`active-speaker-change`:t(Ph,n.activeSpeaker.peerId),t(Rh(n.activeSpeaker.peerId),function(e){return e?U(U({},e),{last_active:new Date}):null});break;case`participant-joined`:t(Lh,function(e){return e.includes(n.participant.session_id)?e:rh(rh([],nh(e),!1),[n.participant.session_id],!1)}),t(Rh(n.participant.session_id),n.participant);var r=jh(n.participant);t(yh(n.participant.session_id),r),r.forEach(function(e){var r=nh(Nh(n.participant,[e]),1)[0];t(vh(n.participant.session_id,e),r)});break;case`participant-updated`:t(Rh(n.participant.session_id),n.participant),n.participant.local&&t(Fh,n.participant.session_id);var r=jh(n.participant),i=e(yh(n.participant.session_id));(r.length!==i.length||r.some(function(e){return!i.includes(e)}))&&t(yh(n.participant.session_id),r);var a=new Set(i),o=Nh(n.participant,r);r.forEach(function(e,r){var i=o[r];a.delete(e),t(vh(n.participant.session_id,e),function(e){return dh(e,i)?e:i})}),a.forEach(function(e){t(vh(n.participant.session_id,e),null)});break;case`participant-left`:t(Lh,function(e){return e.includes(n.participant.session_id)?e.filter(function(e){return e!==n.participant.session_id}):e}),Rh.remove(n.participant.session_id),e(yh(n.participant.session_id)).forEach(function(e){bh.remove(gh(n.participant.session_id,e))}),yh.remove(n.participant.session_id);break}})},[])),100,!0),kh([`waiting-participant-added`,`waiting-participant-updated`,`waiting-participant-removed`],F(A(function(e,t,n){n.forEach(function(e){switch(e.action){case`waiting-participant-added`:t(zh,function(t){return t.includes(e.participant.id)?t:rh(rh([],nh(t),!1),[e.participant.id],!1)}),t(Bh(e.participant.id),e.participant);break;case`waiting-participant-updated`:t(Bh(e.participant.id),e.participant);break;case`waiting-participant-removed`:t(zh,function(t){return t.filter(function(t){return t!==e.participant.id})}),Bh.remove(e.participant.id);break}})},[])),100,!0),P.createElement(P.Fragment,null,t)},Hh=function(){var e=mo(Fh);return pt(e),e},Uh=function(){return!0},Wh=function(e){var t=e===void 0?{}:e,n=t.filter,r=n===void 0?Uh:n,i=t.ignoreLocal,a=i===void 0?!1:i,o=Hh(),s=mo(Ph),c=a&&s===o,l=!r?.(s),u=nh(E(!c&&!l?s:null),2),d=u[0],f=u[1];return D(function(){c||l||f(s)},[l,c,s]),pt(d),d},Gh=function(e){return[`blocked`,`off`].includes(e)},Kh=`;`,qh=function(e,t){return`${e}${Kh}${t}`},Jh=ph({equals:dh,get:function(e){return function(t){var n=nh(e.split(Kh),2),r=n[0],i=n[1];return t(Lh).filter(function(e){switch(r){case`local`:case`owner`:case`record`:return t(vh(e,r));case`remote`:return!t(vh(e,`local`));case`screen`:var n=t(vh(e,`tracks.screenAudio.state`)),i=t(vh(e,`tracks.screenVideo.state`));return!Gh(n)||!Gh(i);default:return!0}}).sort(function(e,n){switch(i){case`joined_at`:case`session_id`:case`user_id`:case`user_name`:var r=t(vh(e,i)),a=t(vh(n,i));if(r!==void 0||a!==void 0){if(r===void 0)return-1;if(a===void 0||r>a)return 1;if(r<a)return-1}return 0;default:return 0}})}}}),Yh=function(e){var t=e===void 0?{}:e,n=t.filter,r=t.onActiveSpeakerChange,i=t.onParticipantJoined,a=t.onParticipantLeft,o=t.onParticipantUpdated,s=t.sort,c=mo(Jh(qh(typeof n==`string`?n:null,typeof s==`string`?s:null))),l=typeof n==`function`||typeof s==`function`,u=A(function(e){return typeof n!=`function`&&typeof s!=`function`?[]:c.map(function(t){return e(Rh(t))}).filter(function(e){return!!e}).filter(typeof n==`function`?n:function(){return!0}).sort(typeof s==`function`?s:function(){return 0}).map(function(e){return e.session_id}).filter(Boolean)},[n,c,s]),d=nh(E([]),2),f=d[0],p=d[1],m=F(A(function(e){if(l){var t=u(e);dh(t,f)||p(t)}},[f,u,l]));D(function(){m()},[m]),kh([`participant-joined`,`participant-updated`,`active-speaker-change`,`participant-left`],A(function(e){e.length&&(e.forEach(function(e){switch(e.action){case`participant-joined`:i?.(e);break;case`participant-updated`:o?.(e);break;case`active-speaker-change`:r?.(e);break;case`participant-left`:a?.(e);break}}),m())},[m,r,i,a,o]));var h=typeof n==`function`||typeof s==`function`?f:c;return pt(h),h},Xh=ph({equals:fh,get:function(){return function(e){return e(Jh(qh(`screen`,null))).map(function(t){return{local:e(vh(t,`local`)),screenAudio:e(vh(t,`tracks.screenAudio`)),screenVideo:e(vh(t,`tracks.screenVideo`)),screenId:`${t}-screen`,session_id:t}})}}}),Zh=function(e){var t=e===void 0?{}:e,n=t.onError,r=t.onLocalScreenShareStarted,i=t.onLocalScreenShareStopped,a=ah(),o=A(function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];a?.startScreenShare.apply(a,rh([],nh(e),!1))},[a]),s=A(function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];a?.stopScreenShare.apply(a,rh([],nh(e),!1))},[a]);W(`local-screen-share-started`,A(function(){return r?.()},[r])),W(`local-screen-share-stopped`,A(function(){return i?.()},[i])),W(`nonfatal-error`,A(function(e){e.type===`screen-share-error`&&n?.(e)},[n]));var c=mo(Xh(void 0)),l={isSharingScreen:c.some(function(e){return e.local}),screens:c,startScreenShare:o,stopScreenShare:s};return pt(l),l},Qh=function(e,t){t===void 0&&(t=`video`);var n=Sh(e,`tracks.${t}`),r=n?U(U({},n),{isOff:Gh(n.state)}):{isOff:!0,persistentTrack:void 0,state:`off`,subscribed:!1};return pt(r),r};function $h(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return A(function(t){for(var n=0;n<e.length;n++){var r=e[n];typeof r==`function`?r(t):r&&Zm(r)===`object`&&(r.current=t)}},e)}var eg=ya(Sa(function(e,t){var n=e.onPlayFailed,r=e.sessionId,i=e.type,a=i===void 0?`audio`:i,o=Qm(e,[`onPlayFailed`,`sessionId`,`type`]),s=O(null),c=Qh(r,a),l=$h(s,t),u=c?.subscribed;return D(function(){var e=s.current;if(!(!e||!c?.persistentTrack)){if(!MediaStream){console.warn(`MediaStream API not available. Can't setup ${a} for ${r}`),n?.({sessionId:r,target:e,type:a,message:`MediaStream API not available`,name:`MediaStream API not available`});return}var t=function(){e.play().catch(function(t){n?.({sessionId:r,target:e,type:a,message:t.message,name:t.name})})};return e.addEventListener(`loadedmetadata`,t),e.srcObject=new MediaStream([c.persistentTrack]),e.load(),function(){e.removeEventListener(`loadedmetadata`,t)}}},[c?.persistentTrack,n,r,a]),W(`participant-left`,A(function(e){var t=s.current;e.participant.session_id!==r||!t||(t.srcObject=null)},[r])),W(`left-meeting`,A(function(){var e=s.current;e&&(e.pause(),e.srcObject=null)},[])),P.createElement(`audio`,U({autoPlay:!0,ref:l},o,{"data-session-id":r,"data-audio-type":a,"data-subscribed":u}))}));eg.displayName=`DailyAudioTrack`;var tg=ya(Sa(function(e,t){var n=e.autoSubscribeActiveSpeaker,r=n===void 0?!1:n,i=e.maxSpeakers,a=i===void 0?5:i,o=e.onPlayFailed,s=e.playLocalScreenAudio,c=s===void 0?!1:s,l=ah(),u=nh(E(Array(a).fill(``)),2),d=u[0],f=u[1],p=Zh().screens,m=Hh(),h=Wh({ignoreLocal:!0}),g=O(null);dt(t,function(){return{getActiveSpeakerAudio:function(){return g.current?.querySelector(`audio[data-session-id="${h}"][data-audio-type="audio"]`)??null},getAllAudio:function(){return Array.from(g.current?.querySelectorAll(`audio`)??[])},getAudioBySessionId:function(e){return g.current?.querySelector(`audio[data-session-id="${e}"][data-audio-type="audio"]`)??null},getRmpAudio:function(){return Array.from(g.current?.querySelectorAll(`audio[data-audio-type="rmpAudio"]`)??[])},getScreenAudio:function(){return Array.from(g.current?.querySelectorAll(`audio[data-audio-type="screenAudio"]`)??[])},getRmpAudioBySessionId:function(e){return g.current?.querySelector(`audio[data-session-id="${e}"][data-audio-type="rmpAudio"]`)??null},getScreenAudioBySessionId:function(e){return g.current?.querySelector(`audio[data-session-id="${e}"][data-audio-type="screenAudio"]`)??null}}},[h]);var _=F(A(function(e,t,n){return $m(void 0,void 0,void 0,function(){var t,i;return eh(this,function(a){if(t=Object.values(l?.participants()??{}).filter(function(e){return!e.local&&!!e.tracks.audio.subscribed}),i=function(e){return t.some(function(t){return t.session_id===e})},!i(n))if(l&&!l.isDestroyed()&&r&&!l.subscribeToTracksAutomatically())l.updateParticipant(n,{setSubscribedTracks:{audio:!0}});else return[2];return f(function(r){if(r.includes(n))return r;var a=function(e){return!e||!i(e)};if(r.some(a)){var o=r.findIndex(a);return r[o]=n,rh([],nh(r),!1)}var s=r.findIndex(function(e){return t.some(function(t){return t.session_id===e&&Gh(t.tracks.audio.state)})});if(s>=0)return r[s]=n,rh([],nh(r),!1);var c=t.filter(function(e){return r.includes(e.session_id)&&e.session_id!==h}).sort(function(t,n){var r=e(vh(t.session_id,`last_active`))??new Date(`1970-01-01`),i=e(vh(n.session_id,`last_active`))??new Date(`1970-01-01`);return r>i?1:r<i?-1:0});if(!c.length){var l=r.findIndex(function(e){return e!==h});return r[l]=n,rh([],nh(r),!1)}var u=r.indexOf(c[0]?.session_id);return r[u]=n,rh([],nh(r),!1)}),[2]})})},[h,r,l])),v=A(function(e){f(function(t){if(!t.includes(e))return t;var n=rh([],nh(t),!1),r=n.indexOf(e);return n[r]=``,n})},[]);kh([`active-speaker-change`,`track-started`,`participant-left`],A(function(e){e.forEach(function(e){switch(e.action){case`active-speaker-change`:if(e.activeSpeaker.peerId===m)return;_(e.activeSpeaker.peerId);break;case`track-started`:e.track.kind===`audio`&&e.participant&&!e.participant.local&&_(e.participant.session_id);break;case`participant-left`:v(e.participant.session_id);break}})},[_,m,v]),200);var y=Yh({filter:A(function(e){return!!e?.tracks?.rmpAudio},[])});return P.createElement(`div`,{ref:g},d.map(function(e,t){return P.createElement(eg,{key:`speaker-slot-${t}`,onPlayFailed:o,sessionId:e,type:`audio`})}),p.filter(function(e){return c?!0:!e.local}).map(function(e){return P.createElement(eg,{key:e.screenId,onPlayFailed:o,sessionId:e.session_id,type:`screenAudio`})}),y.map(function(e){return P.createElement(eg,{key:`${e}-rmp`,onPlayFailed:o,sessionId:e,type:`rmpAudio`})}))}));tg.displayName=`DailyAudio`;var ng=Sa(function(e,t){var n=e.automirror,r=e.fit,i=r===void 0?`contain`:r,a=e.mirror,o=e.onResize,s=e.playableStyle,c=s===void 0?{}:s,l=e.sessionId,u=e.style,d=u===void 0?{}:u,f=e.type,p=f===void 0?`video`:f,m=Qm(e,[`automirror`,`fit`,`mirror`,`onResize`,`playableStyle`,`sessionId`,`style`,`type`]),h=Hh()===l,g=p===`screenVideo`,_=h&&!g,v=O(null),y=$h(v,t),b=Qh(l,p),x=b.persistentTrack,S=_||g||!b.isOff,C=Sh(l,`tracks.${p}`)?.subscribed,w=k(function(){if(typeof a==`boolean`)return a;if(!n)return!1;if(!x)return _;var e=x.getSettings();return`facingMode`in e?_&&e.facingMode===`user`:_},[n,_,a,x]);return D(function(){var e=v.current;if(e){var t=function(){var t=e.play();t!==void 0&&t.then(function(){e.controls=!1}).catch(function(t){e.controls=!0,console.warn(`Failed to play video`,t)})},n=function(){e.paused&&t()},r=function(){e.style.transform=`scale(1)`},i=function(){e.style.transform=``,setTimeout(function(){e.paused&&t()},100)},a=function(){document.visibilityState!==`hidden`&&e.paused&&t()};return e.addEventListener(`canplay`,n),e.addEventListener(`enterpictureinpicture`,r),e.addEventListener(`leavepictureinpicture`,i),document.addEventListener(`visibilitychange`,a),function(){e.removeEventListener(`canplay`,n),e.removeEventListener(`enterpictureinpicture`,r),e.removeEventListener(`leavepictureinpicture`,i),document.removeEventListener(`visibilitychange`,a)}}},[]),D(function(){var e=v.current;if(!(!e||!x)){if(!MediaStream){console.warn(`MediaStream API not available. Can't setup ${p} for ${l}`);return}return e.srcObject=new MediaStream([x]),e.load(),function(){e.srcObject=null,e.load()}}},[l,p,x,x?.id]),D(function(){var e=v.current;if(!o||!e)return;var t;function n(){t&&cancelAnimationFrame(t),t=requestAnimationFrame(function(){var e=v.current;if(!(!e||document.hidden)){var t=e.videoWidth,n=e.videoHeight;t&&n&&o?.({aspectRatio:t/n,height:n,width:t})}})}return n(),e.addEventListener(`loadedmetadata`,n),e.addEventListener(`resize`,n),function(){t&&cancelAnimationFrame(t),e.removeEventListener(`loadedmetadata`,n),e.removeEventListener(`resize`,n)}},[o]),P.createElement(`video`,U({autoPlay:!0,muted:!0,playsInline:!0,ref:y,"data-local":h,"data-mirrored":w||void 0,"data-playable":S||void 0,"data-session-id":l,"data-subscribed":C,"data-video-type":p,style:U(U({objectFit:i,transform:w?`scale(-1, 1)`:``},d),S?c:{})},m))});ng.displayName=`DailyVideo`;var rg=Fe({refreshDevices:function(){return Promise.resolve()}}),ig=N(`idle`);ig.debugLabel=G(`camera-state`);var ag=N(`idle`);ag.debugLabel=G(`microphone-state`);var og=N([]);og.debugLabel=G(`camera-devices`);var sg=N([]);sg.debugLabel=G(`microphone-devices`);var cg=N([]);cg.debugLabel=G(`speaker-devices`);var lg=N(null);lg.debugLabel=G(`last-camera-error`);var ug=function(e){var t=e.children,n=ah(),r=F(A(function(e,t){return $m(void 0,void 0,void 0,function(){var e,r,i,a,o,s,c,l,u,d;return eh(this,function(f){switch(f.label){case 0:if((navigator==null?void 0:navigator.mediaDevices)?.getUserMedia===void 0||(navigator==null?void 0:navigator.mediaDevices)?.enumerateDevices===void 0)return t(ig,`not-supported`),t(ag,`not-supported`),[2];if(!n)return[2];f.label=1;case 1:return f.trys.push([1,4,,5]),[4,n.enumerateDevices()];case 2:return e=f.sent().devices,r=e.filter(function(e){return e.kind===`videoinput`&&e.deviceId!==``}),i=e.filter(function(e){return e.kind===`audioinput`&&e.deviceId!==``}),a=e.filter(function(e){return e.kind===`audiooutput`&&e.deviceId!==``}),[4,n.getInputDevices()];case 3:return o=f.sent(),s=o.camera,c=o.mic,l=o.speaker,u=function(e,t,n){var r=n.find(function(e){return e.device.deviceId===t.deviceId}),i=`deviceId`in e&&t.deviceId===e.deviceId,a=!(`deviceId`in e)&&r?.selected;return{device:t,selected:i||!!a,state:r?.state??`granted`}},d=function(e,t){return e.device.deviceId==="default"?-1:t.device.deviceId==="default"?1:e.device.label<t.device.label?-1:+(e.device.label>t.device.label)},t(og,function(e){return r.filter(Boolean).map(function(t){return u(s,t,e)}).sort(d)}),t(sg,function(e){return i.filter(Boolean).map(function(t){return u(c,t,e)}).sort(d)}),t(cg,function(e){return a.filter(Boolean).map(function(t){return u(l,t,e)}).sort(d)}),[3,5];case 4:return f.sent(),t(ig,`not-supported`),t(ag,`not-supported`),[3,5];case 5:return[2]}})})},[n])),i=F(A(function(e,t){return $m(void 0,void 0,void 0,function(){var i,a,o,s,c,l,u,d,f,p,m,h;return eh(this,function(g){switch(g.label){case 0:if(!n||(i=e(ig),a=e(ag),o=n.participants(),!o.local))return[2];if(s=o.local.tracks,c=`prompt`,l=`prompt`,!navigator.permissions)return[3,5];g.label=1;case 1:return g.trys.push([1,4,,5]),[4,navigator.permissions.query({name:`camera`})];case 2:return u=g.sent(),c=u.state,[4,navigator.permissions.query({name:`microphone`})];case 3:return d=g.sent(),l=d.state,[3,5];case 4:return g.sent(),[3,5];case 5:return f=c===`prompt`&&[`idle`,`pending`].includes(i)&&s.video.state===`interrupted`&&!s.video.persistentTrack,p=[`idle`,`pending`].includes(i)&&!s.video.persistentTrack&&!!s.video.off?.byUser,m=l===`prompt`&&[`idle`,`pending`].includes(a)&&s.audio.state===`interrupted`&&!s.audio.persistentTrack,h=[`idle`,`pending`].includes(a)&&!s.audio.persistentTrack&&!!s.audio.off?.byUser,s.audio?.blocked?.byDeviceInUse?(t(ag,`in-use`),t(sg,function(e){return e.map(function(e){return e.selected?U(U({},e),{state:`in-use`}):e})})):s.audio?.blocked?.byDeviceMissing?t(ag,`not-found`):s.audio?.blocked?.byPermissions||l===`denied`?t(ag,`blocked`):m?t(ag,`pending`):h?t(ag,`idle`):(t(ag,`granted`),t(sg,function(e){return e.map(function(e){return e.selected?U(U({},e),{state:`granted`}):e})})),s.video?.blocked?.byDeviceInUse?(t(ig,`in-use`),t(og,function(e){return e.map(function(e){return e.selected?U(U({},e),{state:`in-use`}):e})})):s.video?.blocked?.byDeviceMissing?t(ig,`not-found`):s.video?.blocked?.byPermissions||c===`denied`?t(ig,`blocked`):f?t(ig,`pending`):p?t(ig,`idle`):(t(ig,`granted`),t(og,function(e){return e.map(function(e){return e.selected?U(U({},e),{state:`granted`}):e})})),r(),[2]}})})},[n,r]));return W(`participant-updated`,A(function(e){e.participant.local&&i()},[i])),W(`available-devices-updated`,r),W(`selected-devices-updated`,r),W(`camera-error`,F(A(function(e,t,n){switch(t(lg,n.error),n.error?.type){case`cam-in-use`:t(ig,`in-use`);break;case`mic-in-use`:t(ag,`in-use`);break;case`cam-mic-in-use`:t(ig,`in-use`),t(ag,`in-use`);break;case`not-found`:n.error?.missingMedia.includes(`video`)&&t(ig,`not-found`),n.error?.missingMedia.includes(`audio`)&&t(ag,`not-found`);break;case`permissions`:n.error?.blockedMedia.includes(`video`)&&t(ig,`blocked`),n.error?.blockedMedia.includes(`audio`)&&t(ag,`blocked`);break;case`constraints`:n.error?.reason===`invalid`?(t(ig,`constraints-invalid`),t(ag,`constraints-invalid`)):n.error?.reason===`none-specified`&&(t(ig,`constraints-none-specified`),t(ag,`constraints-none-specified`));break;case`undefined-mediadevices`:t(ig,`undefined-mediadevices`),t(ag,`undefined-mediadevices`);break;default:t(ig,`unknown`),t(ag,`unknown`);break}},[]))),W(`started-camera`,F(A(function(e,t){t(ig,`granted`),t(ag,`granted`),i()},[i]))),P.createElement(rg.Provider,{value:{refreshDevices:r}},t)};function dg(e){return e.instanceId??`__default__`}var fg=N({});fg.debugLabel=G(`live-streaming-instances`);var pg=N(function(e){var t=e(fg),n=Object.values(t),r=n.filter(function(e){return e.isLiveStreaming}),i=r[0]??n[n.length-1];return{errorMsg:n.find(function(e){return e.errorMsg})?.errorMsg,isLiveStreaming:r.length>0,layout:i?.layout}});pg.debugLabel=G(`live-streaming`);var mg=function(e){var t=e.children;return W(`live-streaming-started`,F(A(function(e,t,n){var r=dg(n);t(fg,function(e){var t;return U(U({},e),(t={},t[r]={instanceId:r,isLiveStreaming:!0,layout:n?.layout},t))})},[]))),W(`live-streaming-stopped`,F(A(function(e,t,n){var r=dg(n);t(fg,function(e){var t;return e[r]?U(U({},e),(t={},t[r]=U(U({},e[r]),{isLiveStreaming:!1,layout:void 0}),t)):e})},[]))),W(`live-streaming-error`,F(A(function(e,t,n){var r=dg(n);t(fg,function(e){var t;return U(U({},e),(t={},t[r]=U(U({},e[r]??{instanceId:r,isLiveStreaming:!1}),{errorMsg:n.errorMsg}),t))})},[]))),W(`left-meeting`,F(A(function(e,t){t(fg,{})},[]))),P.createElement(P.Fragment,null,t)},hg=N(`new`);hg.debugLabel=G(`meeting-state`);var gg=N(null);gg.debugLabel=G(`meeting-error`);var _g=N(null);_g.debugLabel=G(`non-fatal-error`);var vg=N({data:void 0,topology:`none`});vg.debugLabel=G(`meeting-session-data`);var yg=function(e){var t=e.children,n=ah(),r=F(A(function(e,t){if(n){var r=n.meetingState();return t(hg,r),r}},[n]));return W(`loading`,r),W(`loaded`,r),W(`joining-meeting`,r),W(`joined-meeting`,r),W(`left-meeting`,r),W(`error`,F(A(function(e,t,n){t(gg,n),r()},[r]))),W(`nonfatal-error`,F(A(function(e,t,n){t(_g,n)},[]))),W(`joined-meeting`,F(A(function(e,t){n&&t(vg,n.meetingSessionState())},[n]))),W(`meeting-session-state-updated`,F(A(function(e,t,n){t(vg,n.meetingSessionState)},[]))),W(`left-meeting`,F(A(function(e,t){t(vg,{data:void 0,topology:`none`})},[]))),W(`call-instance-destroyed`,F(A(function(e,t){t(hg,`new`),t(gg,null),t(_g,null),t(vg,{data:void 0,topology:`none`})},[]))),P.createElement(P.Fragment,null,t)},bg=N(`none`);bg.debugLabel=G(`topology`);var xg=N(`unknown`),Sg=N([]),Cg=N(`interrupted`),wg=N(100);wg.debugLabel=G(`network-quality`);var Tg=N(`good`);Tg.debugLabel=G(`network-threshold`);var Eg=function(e){var t=e.children,n=ah(),r=mo(bg),i=F(A(function(e,t){return $m(void 0,void 0,void 0,function(){var e;return eh(this,function(r){switch(r.label){case 0:return n?[4,n.getNetworkTopology()]:[2];case 1:return e=r.sent(),!e||e?.topology===`none`||t(bg,e.topology),[2]}})})},[n]));return W(`joined-meeting`,i),W(`network-connection`,F(A(function(e,t,n){switch(t(Cg,n.event),n.event){case`connected`:n.type===`peer-to-peer`&&t(bg,`peer`),n.type===`sfu`&&t(bg,`sfu`);break}},[]))),W(`network-quality-change`,F(A(function(e,t,n){t(xg,function(e){return e===n.networkState?e:n.networkState}),t(Sg,function(e){var t=n.networkStateReasons??[];return fh(e,t)?e:t}),t(wg,function(e){return e===n.quality?e:n.quality}),t(Tg,function(e){return e===n.threshold?e:n.threshold})},[]))),W(`left-meeting`,F(A(function(e,t){t(bg,`none`),t(xg,`unknown`),t(Sg,[]),t(Cg,`interrupted`),t(wg,100),t(Tg,`good`)},[]))),D(function(){!n||r!==`none`||i()},[n,i,r]),P.createElement(P.Fragment,null,t)};function Dg(e){return e.instanceId?e.instanceId:e.type===`local`||e.local?`__local__`:`__default__`}var Og=N({});Og.debugLabel=G(`recording-instances`);var kg=N(function(e){var t=e(Og),n=Object.values(t),r=n.filter(function(e){return e.isRecording}),i=r[0]??n[n.length-1];return{error:n.some(function(e){return e.error}),isLocalParticipantRecorded:n.some(function(e){return e.isLocalParticipantRecorded}),isRecording:r.length>0,layout:i?.layout,local:i?.local,recordingId:i?.recordingId,recordingStartedDate:i?.recordingStartedDate,startedBy:i?.startedBy,type:i?.type}});kg.debugLabel=G(`recording-state`);var Ag=function(e){var t=e.children,n=Hh(),r=Yh({filter:`record`}),i=F(A(function(e,t,n,r){var i=e(Og).__local__,a={instanceId:`__local__`,isLocalParticipantRecorded:n,isRecording:n,local:n?r:i?.local,type:n?`local`:i?.type};i&&dh(i,a)||!n&&!i||(n?t(Og,function(e){return U(U({},e),{__local__:a})}):i&&t(Og,function(e){return U(U({},e),{__local__:U(U({},i),{isLocalParticipantRecorded:!1,isRecording:!1})})}))},[]));return D(function(){i(r.length>0,r.includes(n||`local`))},[n,i,r]),W(`recording-started`,F(A(function(e,t,r){var i=Dg(r),a=!0;switch(r.type){case`cloud-audio-only`:case`cloud-beta`:case`cloud`:n&&r.layout?.preset===`single-participant`&&r.layout.session_id!==n&&(a=!1);break}t(Og,function(e){var t;return U(U({},e),(t={},t[i]={error:!1,instanceId:i,isLocalParticipantRecorded:a,isRecording:!0,layout:r?.layout,local:r?.local,recordingId:r?.recordingId,recordingStartedDate:new Date,startedBy:r?.startedBy,type:r?.type},t))})},[n]))),W(`recording-stopped`,F(A(function(e,t,n){var r=Dg(n);t(Og,function(e){var t;return e[r]?U(U({},e),(t={},t[r]=U(U({},e[r]),{isLocalParticipantRecorded:!1,isRecording:!1}),t)):e})},[]))),W(`recording-error`,F(A(function(e,t,n){var r=Dg(n);t(Og,function(e){var t,i=e[r];return U(U({},e),(t={},t[r]=U(U({},i??{instanceId:r}),{error:!0,errorMsg:n.errorMsg,isLocalParticipantRecorded:!1,isRecording:!1}),t))})},[]))),W(`left-meeting`,F(A(function(e,t){t(Og,{})},[]))),P.createElement(P.Fragment,null,t)},jg=function(){var e=mo(hg);return pt(e),e},Mg=N(null);Mg.debugLabel=G(`room-state`);var Ng=function(e){var t=e.children,n=ah(),r=jg();return W(`access-state-updated`,F(A(function(e,t){return $m(void 0,void 0,void 0,function(){var e;return eh(this,function(i){switch(i.label){case 0:return!n||r===`left-meeting`?[2]:[4,n.room()];case 1:return e=i.sent(),e&&`id`in e&&t(Mg,e),[2,e]}})})},[n,r]))),W(`left-meeting`,F(A(function(e,t){return function(){t(Mg,null)}},[]))),P.createElement(P.Fragment,null,t)},Pg=N({isTranscribing:!1,model:`general`,language:`en`,transcriptions:[]});Pg.debugLabel=G(`transcription-state`);var Fg=function(e){var t=e.children;return W(`transcription-started`,F(A(function(e,t,n){t(Pg,{error:!1,transcriptionStartDate:new Date,isTranscribing:!0,transcriptions:[],endpointing:n.endpointing,extra:n.extra,includeRawResponse:n.includeRawResponse,instanceId:n.instanceId,language:n.language,model:n.model,profanity_filter:n.profanity_filter,punctuate:n.punctuate,redact:n.redact,startedBy:n.startedBy,tier:n.tier})},[]))),W(`transcription-stopped`,F(A(function(e,t,n){t(Pg,function(e){return U(U({},e),{updatedBy:n.updatedBy,isTranscribing:!1})})},[]))),W(`transcription-error`,F(A(function(e,t){t(Pg,function(e){return U(U({},e),{error:!0,isTranscribing:!1})})},[]))),W(`left-meeting`,F(A(function(e,t){t(Pg,function(e){return U(U({},e),{isTranscribing:!1})})},[]))),W(`app-message`,F(A(function(e,t,n){n?.fromId===`transcription`&&t(Pg,function(e){return U(U({},e),{isTranscribing:!0,transcriptions:rh(rh([],nh(e.transcriptions),!1),[n.data],!1)})})},[]))),P.createElement(P.Fragment,null,t)},Ig=`0.25.2`,Lg={strictMode:!0},Rg=function(){return!0},zg={options:Lg,shouldCreateInstance:Rg},Bg=function(e,t){var n=t===void 0?zg:t,r=n.parentElRef,i=n.options,a=i===void 0?Lg:i,o=n.shouldCreateInstance,s=o===void 0?Rg:o,c=nh(E(null),2),l=c[0],u=c[1],d=O();return D(function(){if(e===`callFrame`&&r?.current===null||!s())return;function t(e){return $m(this,void 0,void 0,function(){return eh(this,function(t){switch(t.label){case 0:return[4,e.destroy()];case 1:return t.sent(),[2]}})})}var n=function(){setTimeout(function(){return u(null)},0)},i=Cm.getCallInstance();if(!l&&i&&!i.isDestroyed()){i.once(`call-instance-destroyed`,n),u(i);return}if(l){dh(d.current,a)||t(l);return}if(!i||i.isDestroyed())try{var o=U(U({},a),{aboutClient:U(U({},a.aboutClient??{}),{"daily-react":Ig})});switch(e){case`callFrame`:i=r?.current?Cm.createFrame(r.current,o):Cm.createFrame(o);break;case`callObject`:i=Cm.createCallObject(o);break}d.current=a,u(i),i.once(`call-instance-destroyed`,n)}catch(e){if(console.error(`Error creating call instance:`,e),a.strictMode)throw e}},[l,a,r,s,e]),l},Vg=function(e){return Bg(`callObject`,e)},Hg=function(e){var t=e.children,n=e.jotaiStore,r=Qm(e,[`children`,`jotaiStore`]),i=O({}),a=A(function(e){var t,n;if(`action`in e){var r=e.action,a=Array.from(i.current?.[r]??[]),o=a.filter(function(e){return nh(e,1)[0]<0}),s=a.filter(function(e){return nh(e,1)[0]>0}),c=rh(rh([],nh(o),!1),nh(s),!1);try{for(var l=th(c),u=l.next();!u.done;u=l.next()){var d=nh(u.value,2)[1];d(e)}}catch(e){t={error:e}}finally{try{u&&!u.done&&(n=l.return)&&n.call(l)}finally{if(t)throw t.error}}}},[]),o=A(function(e){e&&Object.keys(i.current).forEach(function(t){e.off(t,a),e.isDestroyed()||e.on(t,a)})},[a]),s=`callObject`in r?r.callObject:null,c=Vg({options:k(function(){return`callObject`in r?{}:r},[r]),shouldCreateInstance:A(function(){return!(`callObject`in r)},[r])}),l=s??c;D(function(){l&&o(l)},[l,o]);var u=A(function(e,t,n){var r;i.current[e]||(i.current[e]=new Map,l&&(l.off(e,a),l.isDestroyed()||l.on(e,a))),i.current[e]?.has(n)||(r=i.current[e])==null||r.set(n,t)},[l,a]),d=A(function(e,t){var n;(n=i.current[e])==null||n.delete(t),i.current[e]?.size===0&&(l?.off(e,a),delete i.current[e])},[l,a]);return P.createElement(so,{store:n},P.createElement(ih.Provider,{value:l},P.createElement(oh.Provider,{value:{on:u,off:d}},P.createElement(Ng,null,P.createElement(yg,null,P.createElement(Eg,null,P.createElement(Vh,null,P.createElement(Ag,null,P.createElement(mg,null,P.createElement(Fg,null,P.createElement(ug,null,t)))))))))))},Ug=function(e){var t=(e===void 0?{}:e).onAppMessage,n=ah(),r=A(function(e,t){t===void 0&&(t=`*`),n&&n.sendAppMessage(e,t)},[n]);return W(`app-message`,A(function(e){t?.(e,r)},[t,r])),r},Wg=function(e,t,n,r){var i=ah(),a=e===Hh();W(`local-audio-level`,A(function(e){a&&t(e.audioLevel)},[t,a])),W(`remote-participants-audio-level`,A(function(n){a||t(n.participantsAudioLevel[e])},[t,e,a])),D(function(){if(!(!i||i.isDestroyed()||!a)&&!i.isLocalAudioLevelObserverRunning())try{i.startLocalAudioLevelObserver(r)}catch{n?.(`Local audio level observer not supported in this browser`)}},[i,n,r,a]),D(function(){!i||i.isDestroyed()||a||i.isRemoteParticipantsAudioLevelObserverRunning()||i.startRemoteParticipantsAudioLevelObserver(r)},[i,r,a])},Gg=function(e){return Qh(e,`audio`)},Kg,qg;function Jg(){return qg?Kg:(qg=1,Kg=function e(t,n){if(t===n)return!0;if(t&&n&&Zm(t)==`object`&&Zm(n)==`object`){if(t.constructor!==n.constructor)return!1;var r,i,a;if(Array.isArray(t)){if(r=t.length,r!=n.length)return!1;for(i=r;i--!==0;)if(!e(t[i],n[i]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if(a=Object.keys(t),r=a.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,a[i]))return!1;for(i=r;i--!==0;){var o=a[i];if(!e(t[o],n[o]))return!1}return!0}return t!==t&&n!==n},Kg)}Jg();var Yg=N({state:`low`,reason:`none`});Yg.debugLabel=G(`cpu-load`);var Xg=function(){var e=ah(),t=mo(ig),n=mo(ag),r=mo(og),i=mo(sg),a=mo(cg),o=mo(lg),s=ft(rg).refreshDevices,c=A(function(t){return $m(void 0,void 0,void 0,function(){return eh(this,function(n){switch(n.label){case 0:return[4,e?.setInputDevicesAsync({audioDeviceId:null,videoDeviceId:t})];case 1:return n.sent(),[2]}})})},[e]),l=A(function(t){return $m(void 0,void 0,void 0,function(){return eh(this,function(n){switch(n.label){case 0:return[4,e?.setInputDevicesAsync({audioDeviceId:t,videoDeviceId:null})];case 1:return n.sent(),[2]}})})},[e]),u=A(function(t){return $m(void 0,void 0,void 0,function(){return eh(this,function(n){switch(n.label){case 0:return[4,e?.setOutputDeviceAsync({outputDeviceId:t})];case 1:return n.sent(),[2]}})})},[e]),d=[`blocked`,`in-use`,`not-found`,`constraints-invalid`,`constraints-none-specified`,`undefined-mediadevices`,`unknown`],f={cameraError:o,cameras:r,camState:t,currentCam:r.find(function(e){return e.selected}),currentMic:i.find(function(e){return e.selected}),currentSpeaker:a.find(function(e){return e.selected}),hasCamError:d.includes(t),hasMicError:d.includes(n),microphones:i,micState:n,refreshDevices:s,setCamera:c,setMicrophone:l,setSpeaker:u,speakers:a};return pt(f),f},Zg=N(null);Zg.debugLabel=G(`input-settings`);var Qg=N({hidden:0,present:0});Qg.debugLabel=G(`participant-counts`);var $g=sa(function(e){var t=N({},function(t,n,r){n($g(e),r)});return t.debugLabel=G(`participant-receive-settings-${e}`),t}),e_=function(e){return Qh(e,`screenVideo`)},t_=N(null);t_.debugLabel=G(`send-settings`);var n_=function(e){return Qh(e,`video`)};function r_({children:e}){return j(Hg,{children:e})}var i_=Fe(null),a_=`tavus:memory-user-id:`,o_=new Map;function s_(e){return`${a_}${e}`}function c_(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function l_(e){if(!e)return``;let t=s_(e);try{let e=window.localStorage.getItem(t);if(e)return e;let n=c_();return window.localStorage.setItem(t,n),n}catch{}let n=o_.get(t);if(n)return n;let r=c_();return o_.set(t,r),r}var u_=`tavus:terms-accepted:`;function d_(e){let t=5381;for(let n=0;n<e.length;n++)t=(t*33^e.charCodeAt(n))>>>0;return t.toString(36)}function f_(e,t){return`${u_}${e}:${d_(t)}`}function p_(e,t){if(!e||!t)return!1;try{return globalThis.localStorage?.getItem(f_(e,t))===`1`}catch{return!1}}function m_(e,t){if(!(!e||!t))try{globalThis.localStorage?.setItem(f_(e,t),`1`)}catch{}}var h_=null;function g_(e,t){!e||!t||(h_={deploymentId:e,content:t})}function __(){h_&&=(m_(h_.deploymentId,h_.content),null)}function v_(e){return e===`replica`||e===`user`?e:null}function y_(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function b_(e){if(!y_(e)||e.message_type!==`conversation`||typeof e.event_type!=`string`||!y_(e.properties))return null;if(e.event_type===`conversation.utterance`){let t=e.properties;return typeof t.speech==`string`?{kind:`chat-message`,sender:t.role===`replica`?`agent`:`user`,text:t.speech}:null}if(e.event_type===`conversation.utterance.streaming`){let t=e.properties;if(typeof t.speech!=`string`)return null;let n=t.final===!0||t.is_interrupted===!0;return{kind:`caption-update`,text:t.speech,final:n,role:v_(t.role)}}return null}function x_(e,t){return{message_type:`conversation`,event_type:`conversation.respond`,conversation_id:e,properties:{text:t}}}function S_(e,t){return typeof e[t]==`number`?{[t]:e[t]}:{}}function C_(e){let t=e.role===`user`||e.role===`replica`?e.role:null;return!t||typeof e.speech!=`string`?null:{kind:`utterance`,event_type:`conversation.utterance`,properties:{role:t,speech:e.speech,...S_(e,`seq`),...S_(e,`turn_idx`)}}}function w_(e){let t=e.role===`user`||e.role===`replica`?e.role:null;return!t||typeof e.speech!=`string`?null:{kind:`utterance.streaming`,event_type:`conversation.utterance.streaming`,properties:{role:t,speech:e.speech,...typeof e.final==`boolean`?{final:e.final}:{},...typeof e.is_interrupted==`boolean`?{is_interrupted:e.is_interrupted}:{},...S_(e,`seq`)}}}function T_(e){return typeof e.name!=`string`||typeof e.arguments!=`string`?null:{kind:`tool_call`,event_type:`conversation.tool_call`,properties:{name:e.name,arguments:e.arguments,...S_(e,`seq`),...S_(e,`turn_idx`)}}}function E_(e){if(typeof e.name!=`string`||typeof e.arguments!=`string`)return null;let t=e.modality===`vision`||e.modality===`audio`?e.modality:null;return t?{kind:`perception_tool_call`,event_type:`conversation.perception_tool_call`,properties:{name:e.name,arguments:e.arguments,modality:t}}:null}function D_(e){return{kind:`perception_analysis`,event_type:`conversation.perception_analysis`,properties:e}}function O_(e,t){return{kind:`speaking`,event_type:t,properties:{...S_(e,`seq`),...S_(e,`turn_idx`)}}}var k_={"conversation.utterance":C_,"conversation.utterance.streaming":w_,"conversation.tool_call":T_,"conversation.perception_tool_call":E_,"conversation.perception_analysis":D_,"conversation.replica_started_speaking":O_,"conversation.replica_stopped_speaking":O_,"conversation.user_started_speaking":O_,"conversation.user_stopped_speaking":O_};function A_(e){if(!y_(e)||e.message_type!==`conversation`||typeof e.event_type!=`string`||!y_(e.properties))return null;let t=k_[e.event_type];return t?t(e.properties,e.event_type):{kind:`unknown`,event_type:e.event_type,properties:e.properties}}function j_(e,t){return{message_type:`conversation`,event_type:t.event_type,conversation_id:e,properties:t.properties??{}}}function M_(e,t){let n=b_(e);return n?n.kind===`chat-message`?(t.appendChatMessage(n.sender,n.text),!0):(t.setCaption(n.text,n.final,n.role),!0):!1}function N_(e=5e3){let t=[],n=n=>{for(;t.length>0&&n-t[0].ts>e;)t.shift()};return{markSent(e){t.push({text:e,ts:Date.now()})},consumeMatch(e){n(Date.now());let r=t.findIndex(t=>t.text===e);return r===-1?!1:(t.splice(r,1),!0)}}}var P_=_n(`Conversation`),F_=1500,I_=Fe(null);function L_({children:e}){return j(r_,{children:j(W_,{children:e})})}function R_(e,t,n){let{role:r,speech:i}=e.properties;if(!(r===`user`&&n.consumeMatch(i)))for(let n of t)n.onUtterance?.({...e.properties})}function z_(e,t){for(let n of t)n.onToolCall?.({...e.properties})}function B_(e,t){for(let n of t)n.onPerception?.(e)}function V_(e,t){let n=e.event_type,r=n.startsWith(`conversation.replica`)?`replica`:`user`,i=n.endsWith(`started_speaking`)?`started`:`stopped`;for(let n of t)n.onSpeakingState?.({who:r,state:i,...e.properties})}function H_(e,t){for(let n of t)n.onMessage?.(e)}function U_(e,t,n){switch(e.kind){case`utterance`:case`utterance.streaming`:R_(e,t,n);return;case`tool_call`:z_(e,t);return;case`perception_tool_call`:case`perception_analysis`:B_(e,t);return;case`speaking`:V_(e,t);return;case`unknown`:H_(e,t);return}}function W_({children:e}){let{deploymentId:t,client:n,config:r}=ft(yi),i=ah(),a=jg(),o=ft(i_),s=k(()=>Ht(`idle`),[]),c=k(()=>Ht(null),[]),l=k(()=>Ht([]),[]),u=k(()=>Ht(``),[]),d=k(()=>Ht(null),[]),f=k(()=>Ht(null),[]),p=k(()=>Ht(null),[]),m=k(()=>Ht(null),[]),h=O(null),g=k(()=>N_(),[]),_=k(()=>new Set,[]),v=k(()=>Ht(`idle`),[]),y=o?.flowSignal??v,b=A(e=>{p.value=e},[p]),x=A(e=>{m.value=e},[m]),[,S]=E(a);D(()=>{S(a),a===`joined-meeting`?(s.value=`connected`,P_.info(`Connected to meeting`)):a===`left-meeting`?(s.value=`ended`,__(),P_.info(`Left meeting`)):a===`error`&&(f.value=`Meeting error`,s.value=`error`)},[a,s,f]),gn(()=>{let e=s.value;if(e===`connected`)for(let e of _)e.onConnect?.();else if(e===`ended`||e===`disconnecting`)for(let e of _)e.onDisconnect?.();else if(e===`error`){let e=f.peek()??`Unknown error`;for(let t of _)t.onError?.({code:`CONVERSATION_ERROR`,message:e})}}),gn(()=>{let e=y.value;for(let t of _)t.onModeChange?.(e)}),Ug({onAppMessage:A(e=>{M_(e?.data,{appendChatMessage(e,t){e===`user`&&g.consumeMatch(t)||(l.value=[...l.peek(),{id:crypto.randomUUID(),sender:e,text:t,timestamp:Date.now()}])},setCaption(e,t,n){u.value=e,d.value=n,h.current!==null&&(clearTimeout(h.current),h.current=null),t&&(h.current=setTimeout(()=>{u.value=``,d.value=null,h.current=null},F_))}});let t=A_(e?.data);t&&U_(t,_,g)},[l,u,d,g,_])}),D(()=>()=>{h.current!==null&&(clearTimeout(h.current),h.current=null)},[]);let C=A(async(e,a)=>{try{s.value=`connecting`,f.value=null;let o=e,l=p.peek();l&&o?.password==null&&(o={...o,password:l}),r.value.customization.conversation.unique_memory_tag===!0&&!o?.memory_stores&&(o={...o,memory_stores:[l_(t)]});let u=m.peek();m.value=null,u&&o?.captcha_token==null&&(o={...o,captcha_token:u});let d=await Sn(n,t,o,a);c.value={conversationId:d.conversation_id,conversationName:d.conversation_name,conversationUrl:d.conversation_url,callbackUrl:d.callback_url,createdAt:d.created_at},await i?.join({url:d.conversation_url})}catch(e){throw e instanceof bn&&(e.status===401||e.status===403)&&r.value.has_password===!0&&(p.value=null),P_.error(`Start failed`,e),f.value=String(e),s.value=`error`,e}},[n,t,i,s,f,c,p,m,r]),w=A(async()=>{let e=c.peek();s.value=`disconnecting`,e&&await Cn(n,t,e.conversationId).catch(e=>P_.error(`End conversation API failed`,e)),await i?.leave(),s.value=`ended`},[n,t,i,s,c]),ee=A(e=>{if(!i)return;let t=c.peek();if(!t){P_.warn(`sendChat called before session was established; dropping message`);return}g.markSent(e),i.sendAppMessage(x_(t.conversationId,e),`*`),l.value=[...l.peek(),{id:crypto.randomUUID(),sender:`user`,text:e,timestamp:Date.now()}]},[i,l,c,g]),T=A(e=>{if(!i){P_.warn(`sendMessage called before Daily was ready; dropping message`);return}let t=c.peek();if(!t){P_.warn(`sendMessage called before session was established; dropping message`);return}e.event_type===`conversation.respond`&&g.markSent(e.properties.text),i.sendAppMessage(j_(t.conversationId,e),`*`)},[i,c,g]),te=A(e=>{_.add(e)},[_]),ne=A(e=>{_.delete(e)},[_]),re=k(()=>({state:s,session:c,chatMessages:l,captionText:u,captionRole:d,error:f,password:p,setPassword:b,captchaToken:m,setCaptchaToken:x,mode:y,start:C,end:w,sendChat:ee,sendMessage:T,conversation:{start:C,end:w,sendMessage:T},__registerSubscriber:te,__unregisterSubscriber:ne}),[s,c,l,u,d,f,p,b,m,x,y,C,w,ee,T,te,ne]);return j(I_.Provider,{value:re,children:e})}function G_(){let e=ft(yi);if(!e)throw Error(`useConfig must be used within ConfigProvider`);return e}var K_=new Set([`network`,`server`,`unavailable`,`busy`,`rate_limited`]);function q_(e){return e===401||e===403?`forbidden`:e===402?`limit_exceeded`:e===423?`busy`:e===429?`rate_limited`:e===409?`concurrency`:e===503?`unavailable`:e>=500?`server`:`unknown`}function J_(e){if(!e)return;let t=e.get(`Retry-After`);if(!t)return;let n=Number.parseInt(t,10);if(!Number.isNaN(n)&&n>=0)return n;let r=Date.parse(t);if(!Number.isNaN(r)){let e=Math.floor((r-Date.now())/1e3);return e>0?e:0}}function Y_(e){if(e instanceof bn){let t=q_(e.status);return{kind:t,status:e.status,raw:e.body,retryable:K_.has(t),retryAfterSec:J_(e.headers)}}return e instanceof TypeError?{kind:`network`,raw:String(e),retryable:!0}:{kind:`unknown`,raw:String(e),retryable:!1}}function X_(e){return e===`limit_exceeded`?`daily_limit`:e===`forbidden`||e===`concurrency`?null:`busy`}var Z_=`tavus_pudl_`,Q_=3600*48,$_=new Map;function ev(){let e=new Date;return`${e.getUTCFullYear()}${String(e.getUTCMonth()+1).padStart(2,`0`)}${String(e.getUTCDate()).padStart(2,`0`)}`}function tv(e){return`${Z_}${e}`}function nv(e){try{let t=`${tv(e)}=`,n=document.cookie.split(`; `).find(e=>e.startsWith(t));if(!n)return 0;let[r,i]=decodeURIComponent(n.slice(t.length)).split(`.`);if(r!==ev())return 0;let a=Number.parseInt(i,10);return Number.isFinite(a)&&a>0?a:0}catch{return 0}}function rv(e,t){try{let n=encodeURIComponent(`${ev()}.${t}`);document.cookie=`${tv(e)}=${n}; max-age=${Q_}; path=/; SameSite=Lax`}catch{return}}function iv(e){let t=$_.get(e);return t||(t=Ht(e?nv(e):0),$_.set(e,t)),t}function av(e){if(!e)return;rv(e,nv(e)+1);let t=nv(e),n=$_.get(e);n?n.value=t:$_.set(e,Ht(t))}var ov=new Set([`Captcha token required`,`Captcha verification failed`]);function sv(e){if(!(e instanceof bn)||e.status!==403)return!1;try{let t=JSON.parse(e.body.trim());return typeof t.error==`string`&&ov.has(t.error)}catch{return!1}}function cv(e,t){let n=e!==null,r=(t?.captchaToken.peek()??null)!==null,[i,a]=E(!n||r),[o,s]=E(0);D(()=>{n||a(!0)},[n]);let c=A(e=>{t?.setCaptchaToken(e),a(!0)},[t]),l=A(()=>{a(!0)},[]),u=t?.captchaToken.value??null,d=O(null);return D(()=>{let e=d.current!==null;d.current=u,n&&u===null&&(a(!1),e&&s(e=>e+1))},[n,u]),{captchaReady:i,captchaEpoch:o,handleCaptchaToken:c,handleCaptchaFallback:l}}function lv({children:e}){let{config:t}=G_(),{start:n}=ft(I_),r=t.value.deployment_id??``,i=iv(r),a=A(()=>{let e=t.value,n=e.limits?.daily_call_limit_per_user;return n==null||e.channel!==`widget`&&e.channel!==`embed`?null:n},[t]),[o,s]=E(`idle`),[c,l]=E(!1),[u,d]=E(null),[f,p]=E(!1),m=k(()=>Ht(`idle`),[]);D(()=>{m.value=o},[o,m]),gn(()=>{let e=t.value,n=e.limits?.daily_call_limit_per_user;n!=null&&(e.channel!==`widget`&&e.channel!==`embed`||m.value===`idle`&&i.value>=n&&(d(`daily_limit`),p(!1),s(`unavailable`)))});let h=t.value.customization.show_haircheck,g=t.value.customization.conversation.modality,_=h&&g!==`chat`,v=O(!1),y=A(async()=>{l(!0);try{await n(),v.current=!1,a()!=null&&av(r),s(`call`)}catch(e){let n=Y_(e);if(sv(e)&&!v.current){v.current=!0,l(!1),s(`idle`);return}if(v.current=!1,n.kind===`forbidden`&&t.value.has_password===!0){s(`idle`);return}d(X_(n.kind)??`busy`),p(n.retryable),s(`unavailable`)}finally{l(!1)}},[n,t,a,r]),b=A(async()=>{if(o!==`idle`&&o!==`unavailable`)return;let e=a();if(e!=null&&i.value>=e){d(`daily_limit`),p(!1),s(`unavailable`);return}if(d(null),p(!1),_){s(`haircheck`);return}return y()},[o,_,y,a,i]),x=A(async()=>{o===`haircheck`&&await y()},[o,y]),S=A(()=>{o===`haircheck`&&s(`idle`)},[o]),C=A(()=>{o===`call`&&s(`ended`)},[o]),w=A(()=>{d(null),p(!1),s(`idle`)},[]),ee=k(()=>({flowSignal:m,setFlowState:s,isStarting:c,unavailableCause:u,canRetry:f,start:b,join:x,cancel:S,leave:C,restart:w}),[m,c,u,f,b,x,S,C,w]);return j(i_.Provider,{value:ee,children:e})}var uv=_n(`HostBridge`),dv=Fe(null);function fv(e){if(!e)return null;let t=e.getRootNode();return t instanceof ShadowRoot&&t.host instanceof HTMLElement?t.host:e.parentElement}function pv({children:e}){let t=ft(I_),n=ft(i_),r=ln(null),i=A(e=>{r.value=fv(e)},[r]),a=A((e,t)=>{let n=r.peek();n&&n.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0})),uv.info(`Event:`,e,t)},[r]);D(()=>{let e=r.value;if(e)return e.tavus={start:t.start,end:t.end,sendChat:t.sendChat,sendMessage:t.sendMessage},()=>{delete e.tavus}},[r.value,t]),D(()=>t.state.subscribe(e=>{switch(e){case`connected`:a(`tavus:conversation-started`,{conversationId:t.session.peek()?.conversationId??``}),a(`tavus:state-change`,{state:e});break;case`ended`:a(`tavus:conversation-ended`,{conversationId:t.session.peek()?.conversationId??``}),a(`tavus:state-change`,{state:e});break;case`error`:a(`tavus:error`,{code:`CONVERSATION_ERROR`,message:t.error.peek()??`Unknown error`}),a(`tavus:state-change`,{state:e});break;default:a(`tavus:state-change`,{state:e})}}),[t,a]),gn(()=>{if(!n)return;let e=n.flowSignal.value;a(`tavus:mode-change`,{mode:e})}),D(()=>{let e={onUtterance(e){a(`tavus:protocol-message`,{kind:`utterance`,event_type:`conversation.utterance`,properties:e})},onToolCall(e){a(`tavus:tool-call`,e),a(`tavus:protocol-message`,{kind:`tool_call`,event_type:`conversation.tool_call`,properties:e})},onPerception(e){a(`tavus:protocol-message`,e)},onSpeakingState({who:e,state:t,seq:n,turn_idx:r}){let i={state:t,...n===void 0?{}:{seq:n},...r===void 0?{}:{turn_idx:r}};a(`tavus:protocol-message`,{kind:`speaking`,event_type:e===`replica`?t===`started`?`conversation.replica_started_speaking`:`conversation.replica_stopped_speaking`:t===`started`?`conversation.user_started_speaking`:`conversation.user_stopped_speaking`,properties:i})},onMessage(e){a(`tavus:protocol-message`,e)}};return t.__registerSubscriber(e),()=>t.__unregisterSubscriber(e)},[t,a]);let o=k(()=>({shadowHost:r,dispatchEvent:a}),[r,a]);return j(dv.Provider,{value:o,children:[j(`div`,{ref:i,style:`display:contents`}),e]})}var mv=Fe(null);function hv({children:e}){let{config:t}=ft(yi),n=k(()=>qt(()=>{let e=t.value.customization.style;return e.mode===`dark`||e.mode===`system`&&(globalThis.matchMedia?.(`(prefers-color-scheme: dark)`).matches??!1)}),[t]),r=k(()=>qt(()=>{let e=t.value.customization.style;return e.style===`basic`?n.value?`white-black`:`black-white`:n.value?`${e.style}-dark`:e.style}),[t,n]),i=k(()=>qt(()=>yv(t.value.customization.style)),[t]),a=k(()=>({dataTheme:r,isDark:n,cssVars:i}),[r,n,i]);return j(mv.Provider,{value:a,children:j(`div`,{"data-theme":r.value,style:bv(i.value),class:`contents`,children:e})})}var gv=[0,.125,.25,.5,.75],_v=[0,1,2,3,4],vv=[0,.2,.25,.3];function yv(e){return{"--radius-box":`${gv[e.boxes_radius]??.5}rem`,"--radius-field":`${gv[e.field_radius]??.25}rem`,"--radius-selector":`${gv[e.selectors_radius]??.5}rem`,"--border":`${_v[e.border_width]??1}px`,"--size-field":`${vv[e.fields_size]??.25}rem`,"--size-selector":`${vv[e.selectors_size]??.25}rem`,"--depth":e.depth_effect?`1`:`0`,"--noise":e.noise_effect?`1`:`0`}}function bv(e){return Object.entries(e).map(([e,t])=>`${e}: ${t}`).join(`; `)}Fe(null);var xv=41/2,Sv=23/2,Cv=Math.hypot(xv,Sv);Array.from({length:1008},(e,t)=>{let n=t%42,r=Math.floor(t/42),i=Math.hypot(n-xv,r-Sv)/Cv*.82,a=.34+(n*13+r*7)%34/100;return{delay:`${i.toFixed(3)}s`,opacity:a.toFixed(2)}});var wv=Fe(null);function Tv({children:e}){let t=O(null);return j(wv.Provider,{value:{frameRef:t},children:j(`div`,{class:`@container/conversation w-full h-full`,children:j(`div`,{ref:t,class:`relative w-full h-full max-h-screen aspect-video @max-mobile:aspect-9/16 overflow-hidden rounded-box bg-base-100`,children:e})})})}var Ev=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),Dv=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),Ov=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()),kv=e=>{let t=Ov(e);return t.charAt(0).toUpperCase()+t.slice(1)},Av={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`,"stroke-linejoin":`round`},jv=Fe({size:24,color:`currentColor`,strokeWidth:2,absoluteStrokeWidth:!1,class:``}),Mv=()=>ft(jv),Nv=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0;return!1},Pv=({color:e,size:t,strokeWidth:n,absoluteStrokeWidth:r,children:i,iconNode:a,class:o=``,...s})=>{let{size:c=24,strokeWidth:l=2,absoluteStrokeWidth:u=!1,color:d=`currentColor`,class:f=``}=Mv()??{},p=r??u?Number(n??l)*24/Number(t??c):n??l;return oe(`svg`,{...Av,width:t??c??24,height:t??c??24,stroke:e??d,"stroke-width":p,class:Ev(`lucide`,f,o),...!i&&!Nv(s)&&{"aria-hidden":`true`},...s},[...a.map(([e,t])=>oe(e,t)),...ye(i)])},Fv=(e,t)=>{let n=({class:n=``,className:r=``,children:i,...a})=>oe(Pv,{...a,iconNode:t,class:Ev(`lucide-${Dv(kv(e))}`,`lucide-${Dv(e)}`,n,r)},i);return n.displayName=kv(e),n},Iv=Fv(`camera-off`,[[`path`,{d:`M14.564 14.558a3 3 0 1 1-4.122-4.121`,key:`1rnrzw`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M20 20H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 .819-.175`,key:`1x3arw`}],[`path`,{d:`M9.695 4.024A2 2 0 0 1 10.004 4h3.993a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v7.344`,key:`1i84u0`}]]),Lv=Fv(`camera`,[[`path`,{d:`M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z`,key:`18u6gg`}],[`circle`,{cx:`12`,cy:`13`,r:`3`,key:`1vg3eu`}]]),Rv=Fv(`captions`,[[`rect`,{width:`18`,height:`14`,x:`3`,y:`5`,rx:`2`,ry:`2`,key:`12ruh7`}],[`path`,{d:`M7 15h4M15 15h2M7 11h2M13 11h4`,key:`1ueiar`}]]),zv=Fv(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]),Bv=Fv(`ellipsis`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]]),Vv=Fv(`expand`,[[`path`,{d:`m15 15 6 6`,key:`1s409w`}],[`path`,{d:`m15 9 6-6`,key:`ko1vev`}],[`path`,{d:`M21 16v5h-5`,key:`1ck2sf`}],[`path`,{d:`M21 8V3h-5`,key:`1qoq8a`}],[`path`,{d:`M3 16v5h5`,key:`1t08am`}],[`path`,{d:`m3 21 6-6`,key:`wwnumi`}],[`path`,{d:`M3 8V3h5`,key:`1ln10m`}],[`path`,{d:`M9 9 3 3`,key:`v551iv`}]]),Hv=Fv(`external-link`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),Uv=Fv(`maximize-2`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`m21 3-7 7`,key:`1l2asr`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M9 21H3v-6`,key:`wtvkvv`}]]),Wv=Fv(`message-circle`,[[`path`,{d:`M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719`,key:`1sd12s`}]]),Gv=Fv(`mic-off`,[[`path`,{d:`M12 19v3`,key:`npa21l`}],[`path`,{d:`M15 9.34V5a3 3 0 0 0-5.68-1.33`,key:`1gzdoj`}],[`path`,{d:`M16.95 16.95A7 7 0 0 1 5 12v-2`,key:`cqa7eg`}],[`path`,{d:`M18.89 13.23A7 7 0 0 0 19 12v-2`,key:`16hl24`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M9 9v3a3 3 0 0 0 5.12 2.12`,key:`r2i35w`}]]),Kv=Fv(`mic`,[[`path`,{d:`M12 19v3`,key:`npa21l`}],[`path`,{d:`M19 10v2a7 7 0 0 1-14 0v-2`,key:`1vc78b`}],[`rect`,{x:`9`,y:`2`,width:`6`,height:`13`,rx:`3`,key:`s6n7sd`}]]),qv=Fv(`minimize-2`,[[`path`,{d:`m14 10 7-7`,key:`oa77jy`}],[`path`,{d:`M20 10h-6V4`,key:`mjg0md`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M4 14h6v6`,key:`rmj7iw`}]]),Jv=Fv(`monitor-up`,[[`path`,{d:`m9 10 3-3 3 3`,key:`11gsxs`}],[`path`,{d:`M12 13V7`,key:`h0r20n`}],[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`,key:`48i651`}],[`path`,{d:`M12 17v4`,key:`1riwvh`}],[`path`,{d:`M8 21h8`,key:`1ev6f3`}]]),Yv=Fv(`moon`,[[`path`,{d:`M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401`,key:`kfwtm`}]]),Xv=Fv(`phone-off`,[[`path`,{d:`M10.1 13.9a14 14 0 0 0 3.732 2.668 1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2 18 18 0 0 1-12.728-5.272`,key:`1wngk7`}],[`path`,{d:`M22 2 2 22`,key:`y4kqgn`}],[`path`,{d:`M4.76 13.582A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 .244.473`,key:`10hv5p`}]]),Zv=Fv(`picture-in-picture-2`,[[`path`,{d:`M21 9V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v10c0 1.1.9 2 2 2h4`,key:`daa4of`}],[`rect`,{width:`10`,height:`7`,x:`12`,y:`13`,rx:`2`,key:`1nb8gs`}]]),Qv=Fv(`send`,[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]),$v=Fv(`shrink`,[[`path`,{d:`m15 15 6 6m-6-6v4.8m0-4.8h4.8`,key:`17vawe`}],[`path`,{d:`M9 19.8V15m0 0H4.2M9 15l-6 6`,key:`chjx8e`}],[`path`,{d:`M15 4.2V9m0 0h4.8M15 9l6-6`,key:`lav6yq`}],[`path`,{d:`M9 4.2V9m0 0H4.2M9 9 3 3`,key:`1pxi2q`}]]),ey=Fv(`smile`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M8 14s1.5 2 4 2 4-2 4-2`,key:`1y1vjs`}],[`line`,{x1:`9`,x2:`9.01`,y1:`9`,y2:`9`,key:`yxxnd0`}],[`line`,{x1:`15`,x2:`15.01`,y1:`9`,y2:`9`,key:`1p4y9e`}]]),ty=Fv(`triangle-alert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),ny=Fv(`user`,[[`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`,key:`975kel`}],[`circle`,{cx:`12`,cy:`7`,r:`4`,key:`17ys0d`}]]),ry=Fv(`users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]),iy=Fv(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]);function ay(e,t){return({size:n=`var(--icon-size, 1.5rem)`,class:r,"aria-label":i})=>j(`span`,{class:r,role:`img`,"aria-label":i??t,children:j(e,{size:n})})}var oy={close:ay(iy,`Close`),leave:ay(Xv,`Leave call`),more:ay(Bv,`More`),error:ay(ty,`Error`),mic:ay(Kv,`Microphone`),"mic-off":ay(Gv,`Microphone muted`),cam:ay(Lv,`Camera`),"cam-off":ay(Iv,`Camera off`),"screen-share":ay(Jv,`Screen share`),pip:ay(Zv,`Picture in picture`),user:ay(ny,`User`),"face-smile":ay(ey,`Camera off`),captions:ay(Rv,`Closed captions`),chat:ay(Wv,`Chat`),fullscreen:ay(Uv,`Enter fullscreen`),"fullscreen-exit":ay(qv,`Exit fullscreen`),expand:ay(Vv,`Expand`),collapse:ay($v,`Collapse`),send:ay(Qv,`Send`),"external-link":ay(Hv,`External link`),clock:ay(zv,`Clock`),moon:ay(Yv,`Unavailable`),users:ay(ry,`Busy`)},sy=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M16 19H4v-2h12v2ZM4 17H2V7h2v10Zm14-8h2V7h2v10h-2v-2h-2v2h-2V7h2v2Zm-2-2H4V5h12v2Z"/></svg>`,cy=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M20 21h-2v-2h2v2Zm-6-2H4v-2h10v2Zm4 0h-2v-2h2v2Zm4 0h-2v-2h-2v-2h-2v-2h-2V7h2v2h2V7h2V5h2v14ZM4 17H2V7h2v10Zm12 0h-2v-2h2v2Zm-2-2h-2v-2h2v2Zm-2-2h-2v-2h2v2Zm-2-2H8V9h2v2ZM8 9H6V7h2v2ZM6 7H4V5h2v2Zm8 0h-4V5h4v2ZM4 5H2V3h2v2Z"/></svg>`,ly=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M3 4h18v2H3zm0 14h18v2H3zM1 6h2v12H1zm20 0h2v12h-2zM5 10h2v4H5zm8 0h2v4h-2zM7 8h4v2H7zm0 6h4v2H7zm8 0h4v2h-4zm0-6h4v2h-4z"/></svg>`,uy=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M22 22h-2v-2h-2v-2h2v-8h2v12Zm-4-4h-8v-2h8v2ZM4 12h2v2H4v2H2V4h2v8Zm6 4H8v-6h2v6Zm10-6H10V8h10v2Zm-4-4h-2V4h2v2Zm-2-2H4V2h10v2Z"/></svg>`,dy=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M18 22H6v-2h12v2ZM6 20H4v-2h2v2Zm14 0h-2v-2h2v2ZM4 18H2V6h2v12Zm18 0h-2V6h2v12Zm-5-1h-2v-2h2v2Zm-2-2h-2v-2h2v2Zm-2-2h-2V6h2v7ZM6 6H4V4h2v2Zm14 0h-2V4h2v2Zm-2-2H6V2h12v2Z"/></svg>`,fy=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M18 22H6v-2h12v2ZM6 20H4v-2h2v2Zm14 0h-2v-2h2v2ZM4 18H2V6h2v12Zm4 0H6v-2h2v2Zm14 0h-2V6h2v12Zm-12-2H8v-2h2v2Zm2-2h-2v-2h2v2Zm2-2h-2v-2h2v2Zm2-2h-2V8h2v2Zm2-2h-2V6h2v2ZM6 6H4V4h2v2Zm14 0h-2V4h2v2Zm-2-2H6V2h12v2Z"/></svg>`,py=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M7 19h2v-2h2v-2h2v2h2v2h2v2H7v-2Zm13-6H4v-2h16v2Zm-3-8h-2v2h-2v2h-2V7H9V5H7V3h10v2Z"/></svg>`,my=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M20 22H4v-2h16v2ZM4 20H2V4h2v16Zm18 0h-2V4h2v16Zm-9-2h-2v-2h2v2Zm0-4h-2V6h2v8Zm7-10H4V2h16v2Z"/></svg>`,hy=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M15 19h-2v2h-2v-2H9v-2H7v-2h10v2h-2v2Zm5-6H4v-2h16v2Zm-7-8h2v2h2v2H7V7h2V5h2V3h2v2Z"/></svg>`,gy=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M8 22H4v-2h4v2Zm12 0h-4v-2h4v2ZM4 20H2v-4h2v4Zm18 0h-2v-4h2v4Zm-6-3H8v-2h8v2Zm-8-2H6V9h2v6Zm10 0h-2V9h2v6Zm-2-6H8V7h8v2ZM4 8H2V4h2v4Zm18 0h-2V4h2v4ZM8 4H4V2h4v2Zm12 0h-4V2h4v2Z"/></svg>`,_y=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M18 22H6v-2h12v2ZM6 20H4V4h2v16Zm14 0h-2v-3h2v3ZM16 9h2v2h2v2h-2v2h-2v2h-2v-4H8v-2h6V7h2v2Zm4-2h-2V4h2v3Zm-2-3H6V2h12v2Z"/></svg>`,vy=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M13 22h-2v-2H8v-2h8v2h-3v2Zm-5-4H6v-2h2v2Zm10 0h-2v-2h2v2ZM6 16H4v-6h2v6Zm8 0h-4v-2h4v2Zm6 0h-2v-6h2v6Zm-10-2H8V4h2v10Zm6 0h-2V4h2v10ZM14 4h-4V2h4v2Z"/></svg>`,yy=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M13 22h-2v-2H8v-2h8v2h-3v2Zm9 0h-2v-2h2v2Zm-2-2h-2v-2h2v2ZM8 18H6v-2h2v2Zm10 0h-2v-2h2v2ZM6 16H4v-6h2v6Zm8-2h2v2h-6v-2h2v-2h2v2Zm-4-4h2v2h-2v2H8V8h2v2Zm10 4h-2v-4h2v4Zm-4-4h-2V4h2v6ZM8 8H6V6h2v2ZM6 6H4V4h2v2ZM4 4H2V2h2v2Zm10 0h-4V2h4v2Z"/></svg>`,by=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M18 22H8v-2h10v2ZM8 20H6v-2h2v2Zm12 0h-2v-2h2v2ZM6 18H4v-2h2v2Zm16 0h-2v-4h-2v-2h2v-2h2v8ZM4 16H2V6h2v10Zm14 0h-6v-2h6v2Zm-6-2h-2v-2h2v2Zm-2-2H8V6h2v6ZM6 6H4V4h2v2Zm8-2h-2v2h-2V4H6V2h8v2Z"/></svg>`,xy=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M5 15H3v-2h2v2Zm8 0h-2v-2h2v2Zm8 0h-2v-2h2v2ZM3 13H1v-2h2v2Zm4 0H5v-2h2v2Zm4 0H9v-2h2v2Zm4 0h-2v-2h2v2Zm4 0h-2v-2h2v2Zm4 0h-2v-2h2v2ZM5 11H3V9h2v2Zm8 0h-2V9h2v2Zm8 0h-2V9h2v2Z"/></svg>`,Sy=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M20 20H4v-2h16v2ZM4 18H2V6h2v12Zm18 0h-2V6h2v12ZM18 8v6h-8V8h8Zm2-2H4V4h16v2Zm-4 4h-4v2h4v-2Z"/></svg>`,Cy=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M20 18h-7v2h3v2H8v-2h3v-2H4v-2h16v2ZM4 16H2V4h2v12Zm18 0h-2v-6h2v6Zm-6-6h-2V8h2v2Zm2-2h-2V6h2v2Zm4-6v6h-2V6h-2V4h-2V2h6Zm-8 2H4V2h10v2Z"/></svg>`,wy=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M4 19h4v2H2v-8h2v6Zm8 0H8v-2h4v2Zm4-2h-4v-2h4v2Zm4-2h-4v-2h4v2Zm-10-2H4v-2h6v2Zm12 0h-2v-2h2v2ZM8 5H4v6H2V3h6v2Zm12 6h-4V9h4v2Zm-4-2h-4V7h4v2Zm-4-2H8V5h4v2Z"/></svg>`,Ty=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M6 22H4v-4h2v4Zm14 0h-2v-4h2v4ZM8 18H6v-2h2v2Zm10 0h-2v-2h2v2Zm-2-2H8v-2h8v2Zm-1-4H9v-2h6v2Zm-6-2H7V4h2v6Zm8 0h-2V4h2v6Zm-2-6H9V2h6v2Z"/></svg>`,Ey=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M2 22H0v-4h2v4Zm14 0h-2v-4h2v4Zm8 0h-2v-4h2v4ZM4 18H2v-2h2v2Zm10 0h-2v-2h2v2Zm8 0h-2v-2h2v2Zm-10-2H4v-2h8v2Zm8 0h-4v-2h4v2Zm-9-4H5v-2h6v2Zm8 0h-4v-2h4v2ZM5 10H3V4h2v6Zm8 0h-2V4h2v6Zm8 0h-2V4h2v6ZM11 4H5V2h6v2Zm8 0h-4V2h4v2Z"/></svg>`,Dy=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M20 22H4v-2h16v2ZM4 20H2v-6H0v-2h2V8h2v12Zm18-8h2v2h-2v6h-2V8h2v4Zm-8 6h-4v-2h4v2Zm-4-2H8v-2h2v2Zm6 0h-2v-2h2v2Zm-6-4H8v-2h2v2Zm6 0h-2v-2h2v2Zm-3-6h7v2H4V6h7V4h2v2Zm4-2h-4V2h4v2Z"/></svg>`,Oy=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M17 21H5v-2h12v2ZM5 19H3V7h2v12Zm14 0h-2v-6h2v6Zm-8-4H9v-2h2v2Zm2-2h-2v-2h2v2Zm2-2h-2V9h2v2Zm6 0h-2V7h-2V5h-4V3h8v8Zm-4-2h-2V7h2v2Zm-6-2H5V5h6v2Z"/></svg>`;function ky(e){return e.replace(/\s(width|height)="\d+"/g,``)}function Ay(e,t){let n=ky(e);return({size:e=`var(--icon-size, 1.5rem)`,class:r,"aria-label":i})=>j(`span`,{class:r,role:`img`,"aria-label":i??t,style:{display:`inline-flex`,width:e,height:e},dangerouslySetInnerHTML:{__html:n.replace(`<svg`,`<svg width="100%" height="100%"`)}})}var jy={pixelarticons:{close:Ay(fy,`Close`),leave:Ay(_y,`Leave call`),more:Ay(xy,`More`),error:Ay(my,`Error`),mic:Ay(vy,`Microphone`),"mic-off":Ay(yy,`Microphone muted`),cam:Ay(sy,`Camera`),"cam-off":Ay(cy,`Camera off`),"screen-share":Ay(Cy,`Screen share`),pip:Ay(Sy,`Picture in picture`),user:Ay(Ty,`User`),"face-smile":Ay(Dy,`Camera off`),captions:Ay(ly,`Closed captions`),chat:Ay(uy,`Chat`),fullscreen:Ay(gy,`Enter fullscreen`),"fullscreen-exit":Ay(py,`Exit fullscreen`),expand:Ay(hy,`Expand`),collapse:Ay(py,`Collapse`),send:Ay(wy,`Send`),"external-link":Ay(Oy,`External link`),clock:Ay(dy,`Clock`),moon:Ay(by,`Unavailable`),users:Ay(Ey,`Busy`)},lucide:oy};function My({name:e,...t}){let{config:n}=G_(),r=(jy[n.value.customization.style.icon_library]??jy.pixelarticons)[e];return j(r,{...t})}var Ny=`Ready when you are`,Py=`Start the conversation`;function Fy(e){return typeof e==`string`&&e.length>0?e:``}function Iy(e){let{preview:t}=e.customization,{background:n}=t,r=Fy(e.replica_thumbnail_video_url),i;i=n.type?n.type:r?`replica`:`background-gradient`;let a=Fy(n.url);return{title:t.title||Ny,description:t.description||``,btn_title:t.btn_title||Py,background:{type:i,url:a}}}var Ly={backgroundImage:`linear-gradient(to bottom right, var(--color-primary), var(--color-base-300))`};function Ry({variant:e,replicaUrl:t}){let[n,r]=E(!1);return D(()=>{r(!1)},[e.url]),e.type===`replica`&&t?j(`video`,{class:`absolute inset-0 w-full h-full object-cover`,src:t,muted:!0,autoplay:!0,loop:!0,playsinline:!0}):e.type===`custom-image`&&e.url&&!n?j(`img`,{class:`absolute inset-0 w-full h-full object-cover`,src:e.url,loading:`lazy`,alt:``,onError:()=>r(!0)}):j(`div`,{class:`absolute inset-0`,style:Ly})}function zy({className:e=``}){let{config:t}=G_(),n=Iy(t.value),r=t.value.replica_thumbnail_video_url??``;return j(`div`,{class:`relative size-16 shrink-0 rounded-box overflow-hidden bg-base-300 ${e}`,children:j(Ry,{variant:n.background,replicaUrl:r})})}var By=`absolute inset-0 bg-base-100 text-base-content flex flex-col items-center justify-center gap-6 px-6 py-8 text-center overflow-y-auto motion-safe:animate-[tavusFadeUp_280ms_ease-out]`;function Vy({children:e,class:t,role:n,"aria-live":r}){return j(`div`,{class:t?`${By} ${t}`:By,role:n,"aria-live":r,children:e})}function Hy({title:e,description:t,media:n,children:r,overlay:i}){return j(Vy,{children:[n===void 0?j(zy,{}):n,(e||t)&&j(`div`,{class:`flex flex-col items-center gap-3 max-w-sm`,children:[e&&j(`h2`,{class:`text-lg font-medium leading-snug`,children:e}),t&&j(`p`,{class:`text-base text-base-content/60 tracking-wide leading-snug`,children:t})]}),r&&j(`div`,{class:`flex flex-col items-center gap-3`,children:r}),i]})}var Uy={daily_limit:{title:`Agent is at today's limit`,description:`This Agent can take more conversations tomorrow.`},total_limit:{title:`Agent is unavailable`,description:`This Agent isn't available right now. Please check back later.`},busy:{title:`Agent is in another conversation`,description:`Please try again in a moment.`},error:{title:`Couldn't load this Agent`,description:`This Agent couldn't be loaded. Please try again later.`}};function Wy(e,t){let n=t?.[e];return{title:n?.title||Uy[e].title,description:n?.description||Uy[e].description}}var Gy={daily_limit:`clock`,total_limit:`moon`,busy:`users`,error:`error`};function Ky({cause:e}){return j(`div`,{class:`flex size-16 shrink-0 items-center justify-center rounded-box bg-base-200 text-base-content/70`,children:j(My,{name:Gy[e],size:`2rem`})})}function qy({cause:e,canRetry:t,onRetry:n,onCancel:r}){let{config:i}=G_(),a=i.value.customization?.unavailable_screen,o=Wy(e,a),s=a?.cta??[],c=e===`busy`||s.length>0||!!r;return j(Hy,{media:j(Ky,{cause:e}),title:o.title,description:o.description,children:c&&j(`div`,{class:`flex flex-wrap items-center justify-center gap-2`,children:[e===`busy`&&j(`button`,{type:`button`,class:`btn btn-neutral rounded-box`,disabled:!t,onClick:n,children:`Try again`}),s.map(e=>j(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,class:`btn btn-outline rounded-box`,children:e.title},e.url)),r&&j(`button`,{type:`button`,class:`btn btn-ghost`,onClick:r,children:`Close`})]})})}function Jy(){let e=ft(i_);return{state:e.flowSignal.value,isStarting:e.isStarting,unavailableCause:e.unavailableCause,canRetry:e.canRetry,start:e.start,join:e.join,cancel:e.cancel,leave:e.leave,restart:e.restart}}var Yy=`Thanks for joining`,Xy=`You can start a new conversation whenever you're ready.`,Zy=`Start a new conversation`;function Qy(e){try{let t=new URL(e);return t.protocol===`https:`||t.protocol===`http:`||t.protocol===`mailto:`}catch{return!1}}function $y({text:e,onRestart:t}){let{config:n}=G_(),r=n.value.customization.after_call,i=r.cta.filter(e=>Qy(e.url));return j(Hy,{title:r.title||e?.title||Yy,description:r.description||e?.description||Xy,children:[j(`button`,{type:`button`,class:`btn btn-neutral rounded-box`,onClick:t,children:e?.restart||Zy}),i.length>0&&j(`div`,{class:`flex flex-wrap items-center justify-center gap-2`,children:i.map(e=>j(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,class:`btn btn-outline rounded-box`,children:e.title},e.url))})]})}function eb(){let e=ah(),t=Hh(),{isOff:n}=n_(t),{camState:r}=Xg();return{isCamReady:k(()=>r===`granted`,[r]),isCamMuted:n,localSessionId:t,onToggleCamera:A(()=>{e?.setLocalVideo(n)},[e,n])}}function tb(){let e=ah(),t=Hh(),{isOff:n}=Gg(t),{micState:r}=Xg();return{isMicReady:k(()=>r===`granted`,[r]),isMicMuted:n,localSessionId:t,onToggleMicrophone:A(()=>{e?.setLocalAudio(n)},[e,n])}}function nb(){let e=ah(),t=Hh(),{isOff:n}=e_(t),r=!n;return{isScreenSharing:r,localSessionId:t,onToggleScreenshare:A(()=>{r?e?.stopScreenShare():e?.startScreenShare({displayMediaOptions:{audio:!1,selfBrowserSurface:`exclude`,surfaceSwitching:`include`,video:{width:1920,height:1080}}})},[e,r])}}var rb=`select-control-pill relative inline-flex items-center bg-neutral text-neutral-content`,ib=`absolute inset-0 w-full h-full opacity-0 cursor-pointer appearance-none disabled:cursor-not-allowed`,ab=`absolute right-1.5 top-1/2 -translate-y-1/2 pointer-events-none flex items-center`,ob=`absolute left-0 top-0 h-full aspect-square flex items-center justify-center pointer-events-none`,sb=`absolute left-0 top-0 z-10 btn btn-control btn-neutral`;function cb(){return j(`svg`,{style:{width:`var(--chevron-size, 0.75rem)`,height:`var(--chevron-size, 0.75rem)`},viewBox:`0 0 16 16`,fill:`none`,"aria-hidden":`true`,children:j(`path`,{d:`M4 6L8 10L12 6`,stroke:`currentColor`,"stroke-width":`1.5`,"stroke-linecap":`round`,"stroke-linejoin":`round`})})}function lb({value:e,devices:t,disabled:n,onChange:r,label:i}){return j(le,{children:[j(`select`,{class:ib,value:e,onChange:e=>r(e.target.value),disabled:n,"aria-label":i,children:t.map(({device:e})=>j(`option`,{value:e.deviceId,children:e.label},e.deviceId))}),j(`span`,{class:ab,children:j(cb,{})})]})}function ub(e){return j(`div`,{class:rb,children:j(lb,{...e})})}function db({iconName:e,...t}){return j(`div`,{class:rb,children:[j(`span`,{class:ob,"aria-hidden":`true`,children:j(My,{name:e})}),j(lb,{...t})]})}var fb=ya(()=>{let{onToggleMicrophone:e,isMicReady:t,isMicMuted:n}=tb(),{microphones:r,currentMic:i,setMicrophone:a}=Xg();return(r?.length??0)<=1?j(mb,{}):j(`div`,{class:`relative inline-flex items-center`,children:[j(ub,{value:i?.device?.deviceId,devices:r||[],disabled:!t,onChange:e=>a(e),label:`Select microphone`}),j(`button`,{type:`button`,onClick:e,disabled:!t,class:sb,"aria-label":n?`Unmute microphone`:`Mute microphone`,"aria-pressed":n,children:j(My,{name:n||!t?`mic-off`:`mic`})})]})}),pb=ya(()=>{let{onToggleCamera:e,isCamReady:t,isCamMuted:n}=eb(),{currentCam:r,cameras:i,setCamera:a}=Xg();return(i?.length??0)<=1?j(hb,{}):j(`div`,{class:`relative inline-flex items-center`,children:[j(ub,{value:r?.device?.deviceId,devices:i||[],disabled:!t,onChange:e=>a(e),label:`Select camera`}),j(`button`,{type:`button`,onClick:e,disabled:!t||!r,class:sb,"aria-label":n?`Turn camera on`:`Turn camera off`,"aria-pressed":n,children:j(My,{name:n?`cam-off`:`cam`})})]})}),mb=ya(()=>{let{onToggleMicrophone:e,isMicReady:t,isMicMuted:n}=tb();return j(`button`,{type:`button`,onClick:e,disabled:!t,class:`btn btn-control btn-neutral`,"aria-label":n?`Unmute microphone`:`Mute microphone`,"aria-pressed":n,children:j(My,{name:n||!t?`mic-off`:`mic`})})}),hb=ya(()=>{let{onToggleCamera:e,isCamReady:t,isCamMuted:n}=eb(),{currentCam:r}=Xg();return j(`button`,{type:`button`,onClick:e,disabled:!t||!r,class:`btn btn-control btn-neutral`,"aria-label":n?`Turn camera on`:`Turn camera off`,"aria-pressed":n,children:j(My,{name:n?`cam-off`:`cam`})})});ya(({compact:e=!1}={})=>{let{isMicReady:t}=tb(),{microphones:n,currentMic:r,setMicrophone:i}=Xg();return(n?.length??0)<=1?null:j(db,{iconName:`mic`,value:r?.device?.deviceId,devices:n,disabled:!t,onChange:e=>i(e),label:`Select microphone`,compact:e})}),ya(({compact:e=!1}={})=>{let{isCamReady:t}=eb(),{currentCam:n,cameras:r,setCamera:i}=Xg();return(r?.length??0)<=1?null:j(db,{iconName:`cam`,value:n?.device?.deviceId,devices:r,disabled:!t,onChange:e=>i(e),label:`Select camera`,compact:e})});var gb=ya((e={})=>{let{onToggleScreenshare:t,isScreenSharing:n}=nb();return j(`button`,{type:`button`,onClick:t,class:`btn btn-control ${n?`btn-primary`:`btn-neutral`}`,"aria-label":n?`Stop screen share`:`Start screen share`,"aria-pressed":n,children:j(My,{name:`screen-share`})})});function _b(e){let t=ft(I_);if(!t)throw Error(`useConversation must be used within ConversationProvider`);return D(()=>{if(e)return t.__registerSubscriber(e),()=>t.__unregisterSubscriber(e)},[e]),t}var vb=Fe(null);function yb({children:e,defaultEnabled:t=!1}){let[n,r]=E(t),i=A(()=>r(e=>!e),[]),a=k(()=>({isEnabled:n,toggle:i}),[n,i]);return j(vb.Provider,{value:a,children:e})}function bb(){let e=ft(vb);if(!e)throw Error(`ClosedCaptions components must be used within <ClosedCaptionsProvider>`);return e}var xb=ya(()=>{let{isEnabled:e,toggle:t}=bb();return j(`button`,{type:`button`,onClick:t,"aria-pressed":e,class:`btn btn-control ${e?`btn-primary`:`btn-neutral`}`,"aria-label":e?`Hide captions`:`Show captions`,children:j(My,{name:`captions`,"aria-label":e?`Closed Captions On`:`Closed Captions Off`})})}),Sb=ya(()=>{let{isEnabled:e}=bb(),{captionText:t,captionRole:n}=_b(),r=t.value,i=n.value;return!e||!r?null:j(`div`,{class:`absolute bottom-24 left-1/2 -translate-x-1/2 max-w-[80%] px-4 py-2 rounded-box bg-black/60 text-white`,role:`status`,"aria-live":`polite`,children:j(`div`,{class:`text-sm leading-5 max-h-15 overflow-hidden flex flex-col justify-end text-center`,children:j(`div`,{children:[j(`span`,{class:`text-xs ${i===`replica`?`text-secondary`:`text-primary`} mr-2`,children:i===`replica`?`Replica`:`You`}),r]})})})}),Cb=Fe(null);function wb({children:e,defaultOpen:t=!1}){let[n,r]=E(t),i=A(()=>r(e=>!e),[]),a=A(()=>r(!1),[]),o=k(()=>({isOpen:n,toggle:i,close:a}),[n,i,a]);return j(Cb.Provider,{value:o,children:e})}function Tb(){let e=ft(Cb);if(!e)throw Error(`Chat components must be used within <ChatProvider>`);return e}var Eb=ya((e={})=>{let{isOpen:t,toggle:n}=Tb();return j(`button`,{type:`button`,onClick:n,"aria-pressed":t,"aria-label":t?`Close chat`:`Open chat`,class:`btn btn-control ${t?`btn-primary`:`btn-neutral`}`,children:j(My,{name:`chat`})})}),Db=ya(({message:e})=>{let t=e.sender===`user`;return j(`li`,{class:`flex flex-col gap-1 ${t?`items-end`:`items-start`}`,children:[j(`span`,{class:`text-xs ${t?`text-primary`:`text-secondary`}`,children:t?`You`:`Replica`}),j(`span`,{class:`px-3 py-2 rounded-field text-sm max-w-[80%] ${t?`bg-primary text-primary-content`:`bg-base-200 text-base-content`}`,children:e.text})]})}),Ob=ya(()=>{let{isOpen:e,close:t}=Tb(),{chatMessages:n,sendChat:r,session:i}=_b(),a=i.value?.conversationId??null,o=n.value,[s,c]=E(``),l=O(null);D(()=>{let e=l.current;e&&(e.scrollTop=e.scrollHeight)},[o.length]);let u=A(()=>{let e=s.trim();!e||!a||(r(e),c(``))},[s,r,a]),d=A(e=>{e.key===`Enter`&&!e.shiftKey&&!e.isComposing&&(e.preventDefault(),u())},[u]),f=!!s.trim()&&!!a;return j(`aside`,{class:`absolute top-0 right-0 w-80 h-full bg-base-100 border-l border-base-300 flex flex-col z-30 transition-transform ${e?`translate-x-0`:`translate-x-full`} @max-mobile:w-full`,"aria-hidden":!e,inert:!e,children:[j(`header`,{class:`flex items-center justify-between px-4 py-3 border-b border-base-300`,children:[j(`span`,{class:`font-medium text-base-content`,children:`Chat`}),j(`button`,{type:`button`,class:`btn btn-ghost btn-sm btn-circle`,onClick:t,"aria-label":`Close chat`,children:j(My,{name:`close`,size:20})})]}),j(`ul`,{ref:l,class:`flex-1 overflow-y-auto p-4 flex flex-col gap-3`,role:`log`,"aria-live":`polite`,children:o.length===0?j(`li`,{class:`text-center text-sm opacity-70`,children:a?`Send a message to start the conversation.`:`Connecting…`}):o.map(e=>j(Db,{message:e},e.id))}),j(`form`,{class:`flex items-end gap-2 p-3 border-t border-base-300`,onSubmit:e=>{e.preventDefault(),u()},children:[j(`textarea`,{class:`textarea textarea-bordered textarea-sm flex-1 resize-none`,value:s,onChange:e=>c(e.target.value),onKeyDown:d,placeholder:a?`Type a message…`:`Connecting…`,disabled:!a,rows:1,"aria-label":`Message`}),j(`button`,{type:`submit`,class:`btn btn-primary btn-sm btn-circle`,disabled:!f,"aria-label":`Send message`,children:j(My,{name:`send`,size:18})})]})]})});function kb({label:e}){return j(Vy,{role:`status`,"aria-live":`polite`,class:`z-2`,children:[j(zy,{}),j(`div`,{class:`flex flex-col items-center gap-3`,children:[j(`span`,{class:`loading loading-spinner loading-md text-base-content`}),j(`span`,{class:`text-base font-medium`,children:e})]})]})}var Ab=ya(()=>j(kb,{label:`Connecting`})),jb=ya(()=>j(kb,{label:`Leaving`}));function Mb({active:e,onToggle:t,tooltip:n}){return j(`button`,{type:`button`,onClick:t,class:`btn btn-control ${e?`btn-info`:`btn-ghost`}`,"aria-label":n??(e?`Exit fullscreen`:`Enter fullscreen`),title:n,children:j(My,{name:e?`fullscreen-exit`:`fullscreen`})})}var Nb=ya(({id:e})=>{let t=Wh()===e,n=O(null),r=O(null),i=O(null),a=O(void 0);Wg(e,A(e=>{a.current&&cancelAnimationFrame(a.current),a.current=requestAnimationFrame(()=>{let t=Number(Math.max(.01,e).toFixed(2));n.current&&r.current&&i.current&&(n.current.style.height=`${20+t*40}%`,r.current.style.height=`${20+t*130}%`,i.current.style.height=`${20+t*40}%`)})},[]));let o=`w-[3px] rounded-full bg-base-100 transition-[opacity] ${t?`opacity-100`:`opacity-50`}`;return j(`div`,{class:`flex items-center justify-center w-6 h-6`,children:j(`div`,{class:`flex items-center justify-center gap-[2px] w-full h-full`,children:[j(`div`,{ref:n,class:o,style:{height:`20%`}}),j(`div`,{ref:r,class:o,style:{height:`20%`}}),j(`div`,{ref:i,class:o,style:{height:`20%`}})]})})});function Pb({sessionId:e,className:t=``}){let n=O(null),r=O(void 0);return Wg(e??``,A(t=>{e&&(r.current&&cancelAnimationFrame(r.current),r.current=requestAnimationFrame(()=>{let e=Math.max(0,Math.min(1,t**.6));n.current?.style.setProperty(`--audio-level`,String(e))}))},[e])),j(`div`,{ref:n,class:`relative aspect-square w-full max-w-[min(48cqi,16rem)] mx-auto pointer-events-none ${t}`,style:{"--audio-level":`0`},"aria-hidden":`true`,children:[j(`div`,{class:`absolute inset-0 rounded-full will-change-transform`,style:{background:`conic-gradient(from 0deg, var(--color-primary), var(--color-info, var(--color-primary)), var(--color-secondary, var(--color-primary)), var(--color-primary))`,filter:`blur(28px)`,animation:`tavusOrbSpin 18s linear infinite`,scale:`calc(1 + var(--audio-level, 0) * 0.35)`,opacity:`calc(0.45 + var(--audio-level, 0) * 0.45)`,transition:`scale 120ms ease-out, opacity 120ms ease-out`}}),j(`div`,{class:`absolute inset-[12%] rounded-full will-change-transform`,style:{background:`conic-gradient(from 180deg, color-mix(in oklab, var(--color-primary) 80%, white), transparent 30%, color-mix(in oklab, var(--color-primary) 60%, white) 70%, transparent)`,filter:`blur(14px)`,opacity:.55,mixBlendMode:`screen`,animation:`tavusOrbSpin 26s linear infinite reverse`}}),j(`div`,{class:`absolute inset-[28%] rounded-full`,style:{background:`radial-gradient(circle at 30% 30%, color-mix(in oklab, white 70%, var(--color-primary)), var(--color-primary) 60%, color-mix(in oklab, var(--color-primary) 50%, black))`,boxShadow:`0 0 60px color-mix(in oklab, var(--color-primary) 60%, transparent), inset 0 0 30px color-mix(in oklab, white 40%, transparent)`,scale:`calc(1 + var(--audio-level, 0) * 0.18)`,transition:`scale 100ms ease-out`}}),j(`div`,{class:`absolute inset-[28%] rounded-full`,style:{background:`radial-gradient(circle, color-mix(in oklab, var(--color-primary) 80%, transparent), transparent 70%)`,animation:`tavusOrbPulse 2.6s ease-in-out infinite`}})]})}function Fb({children:e,class:t,className:n,...r}){return j(`div`,{class:`tavus-mesh-bg ${t??n??``}`,...r,children:[j(`div`,{class:`tavus-mesh-blob tavus-mesh-blob-1`}),j(`div`,{class:`tavus-mesh-blob tavus-mesh-blob-2`}),j(`div`,{class:`tavus-mesh-blob tavus-mesh-blob-3`}),j(`div`,{class:`tavus-mesh-blob tavus-mesh-blob-4`}),j(`div`,{class:`tavus-mesh-blob tavus-mesh-blob-5`}),j(`div`,{class:`absolute inset-0 bg-linear-to-t from-black/30 via-black/10 to-transparent pointer-events-none backdrop-blur-xs`}),e]})}var Ib=e=>!!e.user_id?.includes(`tavus-replica`);function Lb(){return Yh({filter:Ib})}function Rb(e){let t=Lb()[0],n=n_(t??``),r=jg(),[i,a]=E(!1);return D(()=>{t&&(n.state===`playable`||e)&&a(!0)},[t,n.state,e]),r===`left-meeting`||r===`error`?{phase:`left`}:!i||!t?{phase:`connecting`}:{phase:`ready`,replicaId:t,videoState:n}}var zb=ya(({isAudioOnly:e})=>{let t=Rb(e);return t.phase===`left`?j(jb,{}):t.phase===`connecting`?j(Ab,{}):e?j(Fb,{class:`flex items-center justify-center`,children:[j(Pb,{sessionId:t.replicaId}),j(eg,{sessionId:t.replicaId})]}):j(`div`,{class:`relative w-full h-full`,children:[j(ng,{automirror:!0,sessionId:t.replicaId,type:`video`,fit:`cover`,className:`absolute inset-0 w-full h-full object-cover ${t.videoState.isOff?`hidden`:``}`}),j(eg,{sessionId:t.replicaId})]})}),Bb=ya(({onLeave:e})=>{let{config:t}=G_(),n=t.value.customization.conversation.modality===`audio`;return j(`div`,{class:`@container/pip w-full h-full`,children:j(`div`,{class:`relative w-full h-full overflow-hidden bg-linear-to-br from-base-300 to-base-200 text-base-content`,children:[j(`div`,{class:`relative w-full h-full z-5`,children:j(zb,{isAudioOnly:n})}),j(`div`,{class:`absolute bottom-4 w-full inset-x-0 z-20 flex justify-center items-center gap-2 @max-mobile:gap-1`,children:[j(mb,{}),!n&&j(hb,{}),j(`button`,{type:`button`,class:`btn btn-control btn-error`,onClick:e,"aria-label":`Leave call`,children:j(My,{name:`leave`,"aria-label":`Leave Call`})})]})]})})}),Vb=ya(({personaSessionId:e,localSessionId:t,isPresenting:n,isScreenSharing:r,isAudioOnly:i,avatarOff:a,videoRef:o})=>{let s=n||r;return j(le,{children:[j(ng,{ref:o,automirror:!0,sessionId:r?t??``:e,type:s?`screenVideo`:`video`,fit:s?`contain`:`cover`,className:`absolute inset-0 w-full h-full transition-all ${s?`object-contain`:`object-cover`} ${!s&&a?`hidden`:``}`}),n&&j(`div`,{class:`absolute bottom-4 right-4 aspect-square w-32 @max-mobile:w-24 rounded-box overflow-hidden bg-black/30 z-10`,children:i||a?j(`div`,{class:`flex w-full h-full items-center justify-center`,children:j(Pb,{sessionId:e})}):j(ng,{automirror:!0,sessionId:e,type:`video`,fit:`cover`,className:`w-full h-full object-cover`})})]})});function K(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:r,constr:o,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);let i=o.prototype,a=Object.keys(i);for(let e=0;e<a.length;e++){let t=a[e];t in n||(n[t]=i[t].bind(n))}}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,"name",{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}function Hb(e){return e&&Object.assign(Kb,e),Kb}var Ub,Wb,Gb,Kb,qb=a((()=>{Wb=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},Gb=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}},(Ub=globalThis).__zod_globalConfig??(Ub.__zod_globalConfig={}),Kb=globalThis.__zod_globalConfig}));function Jb(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function Yb(e,t=`|`){return e.map(e=>dx(e)).join(t)}function Xb(e,t){return typeof t==`bigint`?t.toString():t}function Zb(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}throw Error(`cached value already set`)}}}function Qb(e){return e==null}function $b(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function ex(e,t){let n=e/t,r=Math.round(n),i=2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}function tx(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Ox)return r===void 0&&(r=Ox,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function nx(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function rx(...e){let t={};for(let n of e)Object.assign(t,Object.getOwnPropertyDescriptors(n));return Object.defineProperties({},t)}function ix(e){return JSON.stringify(e)}function ax(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}function ox(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function sx(e){if(ox(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return!(ox(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}function cx(e){return sx(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function lx(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function ux(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function q(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function dx(e){return typeof e==`bigint`?e.toString()+`n`:typeof e==`string`?`"${e}"`:`${e}`}function fx(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}function px(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);return ux(e,rx(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return nx(this,`shape`,e),e},checks:[]}))}function mx(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);return ux(e,rx(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return nx(this,`shape`,r),r},checks:[]}))}function hx(e,t){if(!sx(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=e._zod.def.shape;for(let e in t)if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return ux(e,rx(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return nx(this,`shape`,n),n}}))}function gx(e,t){if(!sx(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return ux(e,rx(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return nx(this,`shape`,n),n}}))}function _x(e,t){if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);return ux(e,rx(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return nx(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function vx(e,t,n){let r=t._zod.def.checks;if(r&&r.length>0)throw Error(`.partial() cannot be used on object schemas containing refinements`);return ux(t,rx(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return nx(this,`shape`,i),i},checks:[]}))}function yx(e,t,n){return ux(t,rx(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return nx(this,`shape`,i),i}}))}function bx(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function xx(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function Sx(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function Cx(e){return typeof e==`string`?e:e?.message}function wx(e,t,n){let r=e.message?e.message:Cx(e.inst?._zod.def?.error?.(e))??Cx(t?.error?.(e))??Cx(n.customError?.(e))??Cx(n.localeError?.(e))??`Invalid input`,{inst:i,continue:a,input:o,...s}=e;return s.path??=[],s.message=r,t?.reportInput&&(s.input=o),s}function Tx(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function Ex(e){let t=typeof e;switch(t){case`number`:return Number.isNaN(e)?`nan`:`number`;case`object`:{if(e===null)return`null`;if(Array.isArray(e))return`array`;let t=e;if(t&&Object.getPrototypeOf(t)!==Object.prototype&&`constructor`in t&&t.constructor)return t.constructor.name}}return t}function Dx(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}var Ox,kx,Ax,jx,Mx,Nx=a((()=>{qb(),Ox=Symbol(`evaluating`),kx=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{},Ax=Zb(()=>{if(Kb.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}}),jx=new Set([`string`,`number`,`symbol`]),Mx={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]}}));function Px(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function Fx(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i];i===e.length-1?(r[n]=r[n]||{_errors:[]},r[n]._errors.push(t(a))):r[n]=r[n]||{_errors:[]},r=r[n],i++}}}};return r(e),n}var Ix,Lx,Rx,zx=a((()=>{qb(),Nx(),Ix=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,Xb,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Lx=K(`$ZodError`,Ix),Rx=K(`$ZodError`,Ix,{Parent:Error})})),Bx,Vx,Hx,Ux,Wx,Gx,Kx,qx,Jx,Yx,Xx,Zx,Qx,$x,eS=a((()=>{qb(),zx(),Nx(),Bx=e=>(t,n,r,i)=>{let a=r?{...r,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new Wb;if(o.issues.length){let t=new(i?.Err??e)(o.issues.map(e=>wx(e,a,Hb())));throw kx(t,i?.callee),t}return o.value},Vx=e=>async(t,n,r,i)=>{let a=r?{...r,async:!0}:{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new(i?.Err??e)(o.issues.map(e=>wx(e,a,Hb())));throw kx(t,i?.callee),t}return o.value},Hx=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new Wb;return a.issues.length?{success:!1,error:new(e??Lx)(a.issues.map(e=>wx(e,i,Hb())))}:{success:!0,data:a.value}},Ux=Hx(Rx),Wx=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>wx(e,i,Hb())))}:{success:!0,data:a.value}},Gx=Wx(Rx),Kx=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Bx(e)(t,n,i)},qx=e=>(t,n,r)=>Bx(e)(t,n,r),Jx=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Vx(e)(t,n,i)},Yx=e=>async(t,n,r)=>Vx(e)(t,n,r),Xx=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Hx(e)(t,n,i)},Zx=e=>(t,n,r)=>Hx(e)(t,n,r),Qx=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Wx(e)(t,n,i)},$x=e=>async(t,n,r)=>Wx(e)(t,n,r)}));function tS(){return new RegExp(hS,`u`)}function nS(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function rS(e){return RegExp(`^${nS(e)}$`)}function iS(e){let t=nS({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${wS}T(?:${r})$`)}var aS,oS,sS,cS,lS,uS,dS,fS,pS,mS,hS,gS,_S,vS,yS,bS,xS,SS,CS,wS,TS,ES,DS,OS,kS,AS,jS,MS,NS,PS=a((()=>{aS=/^[cC][0-9a-z]{6,}$/,oS=/^[0-9a-z]+$/,sS=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,cS=/^[0-9a-vA-V]{20}$/,lS=/^[A-Za-z0-9]{27}$/,uS=/^[a-zA-Z0-9_-]{21}$/,dS=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,fS=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,pS=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,mS=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,hS=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,gS=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,_S=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,vS=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,yS=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,bS=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,xS=/^[A-Za-z0-9_-]*$/,SS=/^https?$/,CS=/^\+[1-9]\d{6,14}$/,wS=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`,TS=RegExp(`^${wS}$`),ES=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},DS=/^-?\d+$/,OS=/^-?\d+(?:\.\d+)?$/,kS=/^(?:true|false)$/i,AS=/^null$/i,jS=/^undefined$/i,MS=/^[^A-Z]*$/,NS=/^[^a-z]*$/})),FS,IS,LS,RS,zS,BS,VS,HS,US,WS,GS,KS,qS,JS,YS,XS,ZS,QS=a((()=>{qb(),PS(),Nx(),FS=K(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),IS={number:`number`,bigint:`bigint`,object:`date`},LS=K(`$ZodCheckLessThan`,(e,t)=>{FS.init(e,t);let n=IS[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),RS=K(`$ZodCheckGreaterThan`,(e,t)=>{FS.init(e,t);let n=IS[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),zS=K(`$ZodCheckMultipleOf`,(e,t)=>{FS.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?n.value%t.value===BigInt(0):ex(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),BS=K(`$ZodCheckNumberFormat`,(e,t)=>{FS.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=Mx[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=DS)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),VS=K(`$ZodCheckMaxLength`,(e,t)=>{var n;FS.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Qb(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=Tx(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),HS=K(`$ZodCheckMinLength`,(e,t)=>{var n;FS.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Qb(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=Tx(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),US=K(`$ZodCheckLengthEquals`,(e,t)=>{var n;FS.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Qb(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=Tx(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),WS=K(`$ZodCheckStringFormat`,(e,t)=>{var n,r;FS.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),GS=K(`$ZodCheckRegex`,(e,t)=>{WS.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),KS=K(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=MS,WS.init(e,t)}),qS=K(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=NS,WS.init(e,t)}),JS=K(`$ZodCheckIncludes`,(e,t)=>{FS.init(e,t);let n=lx(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),YS=K(`$ZodCheckStartsWith`,(e,t)=>{FS.init(e,t);let n=RegExp(`^${lx(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),XS=K(`$ZodCheckEndsWith`,(e,t)=>{FS.init(e,t);let n=RegExp(`.*${lx(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),ZS=K(`$ZodCheckOverwrite`,(e,t)=>{FS.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}})})),$S,eC=a((()=>{$S=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
|
|
50
|
+
Passed callback for '${e}' event is NOT registered.`,t),c(!0);return}l.current++;var n=setTimeout(function(){l.current=0},50);return a(e,t,u),function(){clearTimeout(n),i(e,u)}}},[t,e,u,s,i,a]),pt({event:e,eventId:u,isBlocked:s,callback:t})};function dh(e,t){var n,r;if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(var i=0;i<e.length;i++)if(!dh(e[i],t[i]))return!1;return!0}if(MediaStream&&e instanceof MediaStream&&t instanceof MediaStream)return e.id===t.id&&e.active===t.active&&e.getTracks().length===t.getTracks().length&&e.getTracks().every(function(e,n){return dh(e,t.getTracks()[n])});if(MediaStreamTrack&&e instanceof MediaStreamTrack&&t instanceof MediaStreamTrack)return e.id===t.id&&e.kind===t.kind&&e.readyState===t.readyState;if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();if(e instanceof RegExp&&t instanceof RegExp)return e.source===t.source&&e.flags===t.flags;if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;var a=Array.from(e).sort(),o=Array.from(t).sort();return a.every(function(e,t){return dh(e,o[t])})}if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;try{for(var s=th(e.entries()),c=s.next();!c.done;c=s.next()){var l=nh(c.value,2),u=l[0],d=l[1];if(!t.has(u)||!dh(d,t.get(u)))return!1}}catch(e){n={error:e}}finally{try{c&&!c.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}return!0}if(Zm(e)!==`object`||e===null||Zm(t)!==`object`||t===null)return!1;var f=Object.keys(e),p=Object.keys(t);if(f.length!==p.length)return!1;for(var i=0;i<f.length;i++){var u=f[i];if(!Object.prototype.hasOwnProperty.call(t,u)||!dh(e[u],t[u]))return!1}return!0}function fh(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(var n=0;n<e.length;n++){var r=e[n],i=t[n],a=r!==null&&Zm(r)===`object`,o=i!==null&&Zm(i)===`object`;if(a||o){if(!dh(r,i))return!1}else if(r!==i)return!1}return!0}function G(e){return`daily-react-`+e}function ph(e){var t=new Map,n=new Map;return function(r){if(!t.has(r)){var i=N(function(t){var i=e.get(r)(t),a=n.get(r);return a!=null&&e.equals(i,a)?a:(n.set(r,i),i)});t.set(r,i)}return t.get(r)}}var mh=`::`,hh=`;`,gh=function(e,t){return e+mh+t},_h=function(e,t){return e+mh+t.join(hh)},vh=function(e,t){return bh(gh(e,t))},yh=sa(function(e){var t=N([]);return t.debugLabel=G(`participant-property-paths-${e}`),t}),bh=sa(function(e){var t=N(null);return t.debugLabel=G(`participant-property-${e}`),t}),xh=ph({equals:fh,get:function(e){return function(t){var n=nh(e.split(mh),2),r=n[0];return n[1].split(hh).map(function(e){return t(vh(r,e))})}}}),Sh=function(e,t){var n,r=mo(Array.isArray(t)?xh(_h(e,t)):bh(gh(e,t)));return pt(Array.isArray(t)?t.reduce(function(e,t,n){return e[t]=r[n],e},{}):(n={},n[t]=r,n)),r},Ch=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};function wh(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,`default`)?e.default:e}var Th,Eh;function Dh(){if(Eh)return Th;Eh=1;var e=`Expected a function`,t=NaN,n=`[object Symbol]`,r=/^\s+|\s+$/g,i=/^[-+]0x[0-9a-f]+$/i,a=/^0b[01]+$/i,o=/^0o[0-7]+$/i,s=parseInt,c=Zm(Ch)==`object`&&Ch&&Ch.Object===Object&&Ch,l=(typeof self>`u`?`undefined`:Zm(self))==`object`&&self&&self.Object===Object&&self,u=c||l||Function(`return this`)(),d=Object.prototype.toString,f=Math.max,p=Math.min,m=function(){return u.Date.now()};function h(t,n,r){var i,a,o,s,c,l,u=0,d=!1,h=!1,g=!0;if(typeof t!=`function`)throw TypeError(e);n=b(n)||0,_(r)&&(d=!!r.leading,h=`maxWait`in r,o=h?f(b(r.maxWait)||0,n):o,g=`trailing`in r?!!r.trailing:g);function v(e){var n=i,r=a;return i=a=void 0,u=e,s=t.apply(r,n),s}function y(e){return u=e,c=setTimeout(C,n),d?v(e):s}function x(e){var t=e-l,r=e-u,i=n-t;return h?p(i,o-r):i}function S(e){var t=e-l,r=e-u;return l===void 0||t>=n||t<0||h&&r>=o}function C(){var e=m();if(S(e))return w(e);c=setTimeout(C,x(e))}function w(e){return c=void 0,g&&i?v(e):(i=a=void 0,s)}function ee(){c!==void 0&&clearTimeout(c),u=0,i=l=a=c=void 0}function T(){return c===void 0?s:w(m())}function te(){var e=m(),t=S(e);if(i=arguments,a=this,l=e,t){if(c===void 0)return y(l);if(h)return c=setTimeout(C,n),v(l)}return c===void 0&&(c=setTimeout(C,n)),s}return te.cancel=ee,te.flush=T,te}function g(t,n,r){var i=!0,a=!0;if(typeof t!=`function`)throw TypeError(e);return _(r)&&(i=`leading`in r?!!r.leading:i,a=`trailing`in r?!!r.trailing:a),h(t,n,{leading:i,maxWait:n,trailing:a})}function _(e){var t=Zm(e);return!!e&&(t==`object`||t==`function`)}function v(e){return!!e&&Zm(e)==`object`}function y(e){return Zm(e)==`symbol`||v(e)&&d.call(e)==n}function b(e){if(typeof e==`number`)return e;if(y(e))return t;if(_(e)){var n=typeof e.valueOf==`function`?e.valueOf():e;e=_(n)?n+``:n}if(typeof e!=`string`)return e===0?e:+e;e=e.replace(r,``);var c=a.test(e);return c||o.test(e)?s(e.slice(2),c?2:8):i.test(e)?t:+e}return Th=g,Th}var Oh=wh(Dh()),kh=function(e,t,n,r){n===void 0&&(n=500),r===void 0&&(r=!1);var i=ft(oh),a=i.off,o=i.on,s=k(function(){var t;return Array.isArray(e)?e.reduce(function(e,t){return e[t]=r?ch():uh(),e},{}):(t={},t[e]=r?ch():uh(),t)},[e,r]),c=O([]);W(`call-instance-destroyed`,A(function(){c.current.length=0},[]));var l=k(function(){return Oh(function(){c.current.length!==0&&(t(c.current),c.current.length=0)},n,{trailing:!0})},[t,n]);D(function(){if(e){var t=function(e){c.current.push(e),l()};return Array.isArray(e)?e.forEach(function(e){return o(e,t,s[e])}):o(e,t,s[e]),function(){Array.isArray(e)?e.forEach(function(e){return a(e,s[e])}):a(e,s[e])}}},[l,e,s,a,o]),pt({event:e,eventId:s})},Ah=function(e,t,n){if(t===void 0&&(t=``),n===void 0&&(n=new Set),Zm(e)!==`object`||e===null||n.has(e))return[t];n.add(e);var r=[];for(var i in e)if(Object.prototype.hasOwnProperty.call(e,i)){var a=t?`${t}.${i}`:i;r.push.apply(r,rh([a],nh(Ah(e[i],a,n)),!1))}return n.delete(e),r},jh=function(e){return Ah(e)},Mh=function(e,t){return String(t).split(`.`).filter(function(e){return e.length}).reduce(function(e,t){return e&&e[t]},e)},Nh=function(e,t){return t.map(function(t){return Mh(e,t)})},Ph=N(null);Ph.debugLabel=G(`active-id`);var Fh=N(``);Fh.debugLabel=G(`local-id`);var Ih=N(null);Ih.debugLabel=G(`local-join-date`);var Lh=N([]);Lh.debugLabel=G(`participant-ids`);var Rh=sa(function(e){var t=N(null);return t.debugLabel=G(`participant-${e}`),t}),zh=N([]);zh.debugLabel=G(`waiting-participants`);var Bh=sa(function(e){var t=N({awaitingAccess:{level:`full`},id:e,name:``});return t.debugLabel=G(`waiting-participant-${e}`),t}),Vh=function(e){var t=e.children,n=ah(),r=nh(E(!1),2),i=r[0],a=r[1],o=F(A(function(e,t,n){t(Fh,n.local.session_id);var r=Object.values(n);t(Lh,r.map(function(e){return e.session_id})),r.forEach(function(e){t(Rh(e.session_id),e);var n=jh(e);t(yh(e.session_id),n),n.forEach(function(n){var r=nh(Nh(e,[n]),1)[0];t(vh(e.session_id,n),r)})}),a(!0)},[]));D(function(){if(!(!n||i)){var e=setInterval(function(){var t=n.participants();`local`in t&&(o(t),clearInterval(e))},100);return function(){clearInterval(e)}}},[n,i,o]);var s=A(function(){if(n){var e=n?.participants();e.local&&o(e)}},[n,o]);W(`started-camera`,s,!0),W(`access-state-updated`,s,!0),W(`joining-meeting`,F(A(function(e,t){t(Ih,new Date),s()},[s])),!0),W(`joined-meeting`,A(function(e){o(e.participants)},[o]),!0);var c=F(A(function(e,t){t(Fh,``),t(Ph,null),e(Lh).forEach(function(e){return Rh.remove(e)}),t(Lh,[])},[]));return W(`call-instance-destroyed`,c,!0),W(`left-meeting`,c,!0),kh([`active-speaker-change`,`participant-joined`,`participant-updated`,`participant-left`],F(A(function(e,t,n){n.length&&n.forEach(function(n){switch(n.action){case`active-speaker-change`:t(Ph,n.activeSpeaker.peerId),t(Rh(n.activeSpeaker.peerId),function(e){return e?U(U({},e),{last_active:new Date}):null});break;case`participant-joined`:t(Lh,function(e){return e.includes(n.participant.session_id)?e:rh(rh([],nh(e),!1),[n.participant.session_id],!1)}),t(Rh(n.participant.session_id),n.participant);var r=jh(n.participant);t(yh(n.participant.session_id),r),r.forEach(function(e){var r=nh(Nh(n.participant,[e]),1)[0];t(vh(n.participant.session_id,e),r)});break;case`participant-updated`:t(Rh(n.participant.session_id),n.participant),n.participant.local&&t(Fh,n.participant.session_id);var r=jh(n.participant),i=e(yh(n.participant.session_id));(r.length!==i.length||r.some(function(e){return!i.includes(e)}))&&t(yh(n.participant.session_id),r);var a=new Set(i),o=Nh(n.participant,r);r.forEach(function(e,r){var i=o[r];a.delete(e),t(vh(n.participant.session_id,e),function(e){return dh(e,i)?e:i})}),a.forEach(function(e){t(vh(n.participant.session_id,e),null)});break;case`participant-left`:t(Lh,function(e){return e.includes(n.participant.session_id)?e.filter(function(e){return e!==n.participant.session_id}):e}),Rh.remove(n.participant.session_id),e(yh(n.participant.session_id)).forEach(function(e){bh.remove(gh(n.participant.session_id,e))}),yh.remove(n.participant.session_id);break}})},[])),100,!0),kh([`waiting-participant-added`,`waiting-participant-updated`,`waiting-participant-removed`],F(A(function(e,t,n){n.forEach(function(e){switch(e.action){case`waiting-participant-added`:t(zh,function(t){return t.includes(e.participant.id)?t:rh(rh([],nh(t),!1),[e.participant.id],!1)}),t(Bh(e.participant.id),e.participant);break;case`waiting-participant-updated`:t(Bh(e.participant.id),e.participant);break;case`waiting-participant-removed`:t(zh,function(t){return t.filter(function(t){return t!==e.participant.id})}),Bh.remove(e.participant.id);break}})},[])),100,!0),P.createElement(P.Fragment,null,t)},Hh=function(){var e=mo(Fh);return pt(e),e},Uh=function(){return!0},Wh=function(e){var t=e===void 0?{}:e,n=t.filter,r=n===void 0?Uh:n,i=t.ignoreLocal,a=i===void 0?!1:i,o=Hh(),s=mo(Ph),c=a&&s===o,l=!r?.(s),u=nh(E(!c&&!l?s:null),2),d=u[0],f=u[1];return D(function(){c||l||f(s)},[l,c,s]),pt(d),d},Gh=function(e){return[`blocked`,`off`].includes(e)},Kh=`;`,qh=function(e,t){return`${e}${Kh}${t}`},Jh=ph({equals:dh,get:function(e){return function(t){var n=nh(e.split(Kh),2),r=n[0],i=n[1];return t(Lh).filter(function(e){switch(r){case`local`:case`owner`:case`record`:return t(vh(e,r));case`remote`:return!t(vh(e,`local`));case`screen`:var n=t(vh(e,`tracks.screenAudio.state`)),i=t(vh(e,`tracks.screenVideo.state`));return!Gh(n)||!Gh(i);default:return!0}}).sort(function(e,n){switch(i){case`joined_at`:case`session_id`:case`user_id`:case`user_name`:var r=t(vh(e,i)),a=t(vh(n,i));if(r!==void 0||a!==void 0){if(r===void 0)return-1;if(a===void 0||r>a)return 1;if(r<a)return-1}return 0;default:return 0}})}}}),Yh=function(e){var t=e===void 0?{}:e,n=t.filter,r=t.onActiveSpeakerChange,i=t.onParticipantJoined,a=t.onParticipantLeft,o=t.onParticipantUpdated,s=t.sort,c=mo(Jh(qh(typeof n==`string`?n:null,typeof s==`string`?s:null))),l=typeof n==`function`||typeof s==`function`,u=A(function(e){return typeof n!=`function`&&typeof s!=`function`?[]:c.map(function(t){return e(Rh(t))}).filter(function(e){return!!e}).filter(typeof n==`function`?n:function(){return!0}).sort(typeof s==`function`?s:function(){return 0}).map(function(e){return e.session_id}).filter(Boolean)},[n,c,s]),d=nh(E([]),2),f=d[0],p=d[1],m=F(A(function(e){if(l){var t=u(e);dh(t,f)||p(t)}},[f,u,l]));D(function(){m()},[m]),kh([`participant-joined`,`participant-updated`,`active-speaker-change`,`participant-left`],A(function(e){e.length&&(e.forEach(function(e){switch(e.action){case`participant-joined`:i?.(e);break;case`participant-updated`:o?.(e);break;case`active-speaker-change`:r?.(e);break;case`participant-left`:a?.(e);break}}),m())},[m,r,i,a,o]));var h=typeof n==`function`||typeof s==`function`?f:c;return pt(h),h},Xh=ph({equals:fh,get:function(){return function(e){return e(Jh(qh(`screen`,null))).map(function(t){return{local:e(vh(t,`local`)),screenAudio:e(vh(t,`tracks.screenAudio`)),screenVideo:e(vh(t,`tracks.screenVideo`)),screenId:`${t}-screen`,session_id:t}})}}}),Zh=function(e){var t=e===void 0?{}:e,n=t.onError,r=t.onLocalScreenShareStarted,i=t.onLocalScreenShareStopped,a=ah(),o=A(function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];a?.startScreenShare.apply(a,rh([],nh(e),!1))},[a]),s=A(function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];a?.stopScreenShare.apply(a,rh([],nh(e),!1))},[a]);W(`local-screen-share-started`,A(function(){return r?.()},[r])),W(`local-screen-share-stopped`,A(function(){return i?.()},[i])),W(`nonfatal-error`,A(function(e){e.type===`screen-share-error`&&n?.(e)},[n]));var c=mo(Xh(void 0)),l={isSharingScreen:c.some(function(e){return e.local}),screens:c,startScreenShare:o,stopScreenShare:s};return pt(l),l},Qh=function(e,t){t===void 0&&(t=`video`);var n=Sh(e,`tracks.${t}`),r=n?U(U({},n),{isOff:Gh(n.state)}):{isOff:!0,persistentTrack:void 0,state:`off`,subscribed:!1};return pt(r),r};function $h(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return A(function(t){for(var n=0;n<e.length;n++){var r=e[n];typeof r==`function`?r(t):r&&Zm(r)===`object`&&(r.current=t)}},e)}var eg=ya(Sa(function(e,t){var n=e.onPlayFailed,r=e.sessionId,i=e.type,a=i===void 0?`audio`:i,o=Qm(e,[`onPlayFailed`,`sessionId`,`type`]),s=O(null),c=Qh(r,a),l=$h(s,t),u=c?.subscribed;return D(function(){var e=s.current;if(!(!e||!c?.persistentTrack)){if(!MediaStream){console.warn(`MediaStream API not available. Can't setup ${a} for ${r}`),n?.({sessionId:r,target:e,type:a,message:`MediaStream API not available`,name:`MediaStream API not available`});return}var t=function(){e.play().catch(function(t){n?.({sessionId:r,target:e,type:a,message:t.message,name:t.name})})};return e.addEventListener(`loadedmetadata`,t),e.srcObject=new MediaStream([c.persistentTrack]),e.load(),function(){e.removeEventListener(`loadedmetadata`,t)}}},[c?.persistentTrack,n,r,a]),W(`participant-left`,A(function(e){var t=s.current;e.participant.session_id!==r||!t||(t.srcObject=null)},[r])),W(`left-meeting`,A(function(){var e=s.current;e&&(e.pause(),e.srcObject=null)},[])),P.createElement(`audio`,U({autoPlay:!0,ref:l},o,{"data-session-id":r,"data-audio-type":a,"data-subscribed":u}))}));eg.displayName=`DailyAudioTrack`;var tg=ya(Sa(function(e,t){var n=e.autoSubscribeActiveSpeaker,r=n===void 0?!1:n,i=e.maxSpeakers,a=i===void 0?5:i,o=e.onPlayFailed,s=e.playLocalScreenAudio,c=s===void 0?!1:s,l=ah(),u=nh(E(Array(a).fill(``)),2),d=u[0],f=u[1],p=Zh().screens,m=Hh(),h=Wh({ignoreLocal:!0}),g=O(null);dt(t,function(){return{getActiveSpeakerAudio:function(){return g.current?.querySelector(`audio[data-session-id="${h}"][data-audio-type="audio"]`)??null},getAllAudio:function(){return Array.from(g.current?.querySelectorAll(`audio`)??[])},getAudioBySessionId:function(e){return g.current?.querySelector(`audio[data-session-id="${e}"][data-audio-type="audio"]`)??null},getRmpAudio:function(){return Array.from(g.current?.querySelectorAll(`audio[data-audio-type="rmpAudio"]`)??[])},getScreenAudio:function(){return Array.from(g.current?.querySelectorAll(`audio[data-audio-type="screenAudio"]`)??[])},getRmpAudioBySessionId:function(e){return g.current?.querySelector(`audio[data-session-id="${e}"][data-audio-type="rmpAudio"]`)??null},getScreenAudioBySessionId:function(e){return g.current?.querySelector(`audio[data-session-id="${e}"][data-audio-type="screenAudio"]`)??null}}},[h]);var _=F(A(function(e,t,n){return $m(void 0,void 0,void 0,function(){var t,i;return eh(this,function(a){if(t=Object.values(l?.participants()??{}).filter(function(e){return!e.local&&!!e.tracks.audio.subscribed}),i=function(e){return t.some(function(t){return t.session_id===e})},!i(n))if(l&&!l.isDestroyed()&&r&&!l.subscribeToTracksAutomatically())l.updateParticipant(n,{setSubscribedTracks:{audio:!0}});else return[2];return f(function(r){if(r.includes(n))return r;var a=function(e){return!e||!i(e)};if(r.some(a)){var o=r.findIndex(a);return r[o]=n,rh([],nh(r),!1)}var s=r.findIndex(function(e){return t.some(function(t){return t.session_id===e&&Gh(t.tracks.audio.state)})});if(s>=0)return r[s]=n,rh([],nh(r),!1);var c=t.filter(function(e){return r.includes(e.session_id)&&e.session_id!==h}).sort(function(t,n){var r=e(vh(t.session_id,`last_active`))??new Date(`1970-01-01`),i=e(vh(n.session_id,`last_active`))??new Date(`1970-01-01`);return r>i?1:r<i?-1:0});if(!c.length){var l=r.findIndex(function(e){return e!==h});return r[l]=n,rh([],nh(r),!1)}var u=r.indexOf(c[0]?.session_id);return r[u]=n,rh([],nh(r),!1)}),[2]})})},[h,r,l])),v=A(function(e){f(function(t){if(!t.includes(e))return t;var n=rh([],nh(t),!1),r=n.indexOf(e);return n[r]=``,n})},[]);kh([`active-speaker-change`,`track-started`,`participant-left`],A(function(e){e.forEach(function(e){switch(e.action){case`active-speaker-change`:if(e.activeSpeaker.peerId===m)return;_(e.activeSpeaker.peerId);break;case`track-started`:e.track.kind===`audio`&&e.participant&&!e.participant.local&&_(e.participant.session_id);break;case`participant-left`:v(e.participant.session_id);break}})},[_,m,v]),200);var y=Yh({filter:A(function(e){return!!e?.tracks?.rmpAudio},[])});return P.createElement(`div`,{ref:g},d.map(function(e,t){return P.createElement(eg,{key:`speaker-slot-${t}`,onPlayFailed:o,sessionId:e,type:`audio`})}),p.filter(function(e){return c?!0:!e.local}).map(function(e){return P.createElement(eg,{key:e.screenId,onPlayFailed:o,sessionId:e.session_id,type:`screenAudio`})}),y.map(function(e){return P.createElement(eg,{key:`${e}-rmp`,onPlayFailed:o,sessionId:e,type:`rmpAudio`})}))}));tg.displayName=`DailyAudio`;var ng=Sa(function(e,t){var n=e.automirror,r=e.fit,i=r===void 0?`contain`:r,a=e.mirror,o=e.onResize,s=e.playableStyle,c=s===void 0?{}:s,l=e.sessionId,u=e.style,d=u===void 0?{}:u,f=e.type,p=f===void 0?`video`:f,m=Qm(e,[`automirror`,`fit`,`mirror`,`onResize`,`playableStyle`,`sessionId`,`style`,`type`]),h=Hh()===l,g=p===`screenVideo`,_=h&&!g,v=O(null),y=$h(v,t),b=Qh(l,p),x=b.persistentTrack,S=_||g||!b.isOff,C=Sh(l,`tracks.${p}`)?.subscribed,w=k(function(){if(typeof a==`boolean`)return a;if(!n)return!1;if(!x)return _;var e=x.getSettings();return`facingMode`in e?_&&e.facingMode===`user`:_},[n,_,a,x]);return D(function(){var e=v.current;if(e){var t=function(){var t=e.play();t!==void 0&&t.then(function(){e.controls=!1}).catch(function(t){e.controls=!0,console.warn(`Failed to play video`,t)})},n=function(){e.paused&&t()},r=function(){e.style.transform=`scale(1)`},i=function(){e.style.transform=``,setTimeout(function(){e.paused&&t()},100)},a=function(){document.visibilityState!==`hidden`&&e.paused&&t()};return e.addEventListener(`canplay`,n),e.addEventListener(`enterpictureinpicture`,r),e.addEventListener(`leavepictureinpicture`,i),document.addEventListener(`visibilitychange`,a),function(){e.removeEventListener(`canplay`,n),e.removeEventListener(`enterpictureinpicture`,r),e.removeEventListener(`leavepictureinpicture`,i),document.removeEventListener(`visibilitychange`,a)}}},[]),D(function(){var e=v.current;if(!(!e||!x)){if(!MediaStream){console.warn(`MediaStream API not available. Can't setup ${p} for ${l}`);return}return e.srcObject=new MediaStream([x]),e.load(),function(){e.srcObject=null,e.load()}}},[l,p,x,x?.id]),D(function(){var e=v.current;if(!o||!e)return;var t;function n(){t&&cancelAnimationFrame(t),t=requestAnimationFrame(function(){var e=v.current;if(!(!e||document.hidden)){var t=e.videoWidth,n=e.videoHeight;t&&n&&o?.({aspectRatio:t/n,height:n,width:t})}})}return n(),e.addEventListener(`loadedmetadata`,n),e.addEventListener(`resize`,n),function(){t&&cancelAnimationFrame(t),e.removeEventListener(`loadedmetadata`,n),e.removeEventListener(`resize`,n)}},[o]),P.createElement(`video`,U({autoPlay:!0,muted:!0,playsInline:!0,ref:y,"data-local":h,"data-mirrored":w||void 0,"data-playable":S||void 0,"data-session-id":l,"data-subscribed":C,"data-video-type":p,style:U(U({objectFit:i,transform:w?`scale(-1, 1)`:``},d),S?c:{})},m))});ng.displayName=`DailyVideo`;var rg=Fe({refreshDevices:function(){return Promise.resolve()}}),ig=N(`idle`);ig.debugLabel=G(`camera-state`);var ag=N(`idle`);ag.debugLabel=G(`microphone-state`);var og=N([]);og.debugLabel=G(`camera-devices`);var sg=N([]);sg.debugLabel=G(`microphone-devices`);var cg=N([]);cg.debugLabel=G(`speaker-devices`);var lg=N(null);lg.debugLabel=G(`last-camera-error`);var ug=function(e){var t=e.children,n=ah(),r=F(A(function(e,t){return $m(void 0,void 0,void 0,function(){var e,r,i,a,o,s,c,l,u,d;return eh(this,function(f){switch(f.label){case 0:if((navigator==null?void 0:navigator.mediaDevices)?.getUserMedia===void 0||(navigator==null?void 0:navigator.mediaDevices)?.enumerateDevices===void 0)return t(ig,`not-supported`),t(ag,`not-supported`),[2];if(!n)return[2];f.label=1;case 1:return f.trys.push([1,4,,5]),[4,n.enumerateDevices()];case 2:return e=f.sent().devices,r=e.filter(function(e){return e.kind===`videoinput`&&e.deviceId!==``}),i=e.filter(function(e){return e.kind===`audioinput`&&e.deviceId!==``}),a=e.filter(function(e){return e.kind===`audiooutput`&&e.deviceId!==``}),[4,n.getInputDevices()];case 3:return o=f.sent(),s=o.camera,c=o.mic,l=o.speaker,u=function(e,t,n){var r=n.find(function(e){return e.device.deviceId===t.deviceId}),i=`deviceId`in e&&t.deviceId===e.deviceId,a=!(`deviceId`in e)&&r?.selected;return{device:t,selected:i||!!a,state:r?.state??`granted`}},d=function(e,t){return e.device.deviceId==="default"?-1:t.device.deviceId==="default"?1:e.device.label<t.device.label?-1:+(e.device.label>t.device.label)},t(og,function(e){return r.filter(Boolean).map(function(t){return u(s,t,e)}).sort(d)}),t(sg,function(e){return i.filter(Boolean).map(function(t){return u(c,t,e)}).sort(d)}),t(cg,function(e){return a.filter(Boolean).map(function(t){return u(l,t,e)}).sort(d)}),[3,5];case 4:return f.sent(),t(ig,`not-supported`),t(ag,`not-supported`),[3,5];case 5:return[2]}})})},[n])),i=F(A(function(e,t){return $m(void 0,void 0,void 0,function(){var i,a,o,s,c,l,u,d,f,p,m,h;return eh(this,function(g){switch(g.label){case 0:if(!n||(i=e(ig),a=e(ag),o=n.participants(),!o.local))return[2];if(s=o.local.tracks,c=`prompt`,l=`prompt`,!navigator.permissions)return[3,5];g.label=1;case 1:return g.trys.push([1,4,,5]),[4,navigator.permissions.query({name:`camera`})];case 2:return u=g.sent(),c=u.state,[4,navigator.permissions.query({name:`microphone`})];case 3:return d=g.sent(),l=d.state,[3,5];case 4:return g.sent(),[3,5];case 5:return f=c===`prompt`&&[`idle`,`pending`].includes(i)&&s.video.state===`interrupted`&&!s.video.persistentTrack,p=[`idle`,`pending`].includes(i)&&!s.video.persistentTrack&&!!s.video.off?.byUser,m=l===`prompt`&&[`idle`,`pending`].includes(a)&&s.audio.state===`interrupted`&&!s.audio.persistentTrack,h=[`idle`,`pending`].includes(a)&&!s.audio.persistentTrack&&!!s.audio.off?.byUser,s.audio?.blocked?.byDeviceInUse?(t(ag,`in-use`),t(sg,function(e){return e.map(function(e){return e.selected?U(U({},e),{state:`in-use`}):e})})):s.audio?.blocked?.byDeviceMissing?t(ag,`not-found`):s.audio?.blocked?.byPermissions||l===`denied`?t(ag,`blocked`):m?t(ag,`pending`):h?t(ag,`idle`):(t(ag,`granted`),t(sg,function(e){return e.map(function(e){return e.selected?U(U({},e),{state:`granted`}):e})})),s.video?.blocked?.byDeviceInUse?(t(ig,`in-use`),t(og,function(e){return e.map(function(e){return e.selected?U(U({},e),{state:`in-use`}):e})})):s.video?.blocked?.byDeviceMissing?t(ig,`not-found`):s.video?.blocked?.byPermissions||c===`denied`?t(ig,`blocked`):f?t(ig,`pending`):p?t(ig,`idle`):(t(ig,`granted`),t(og,function(e){return e.map(function(e){return e.selected?U(U({},e),{state:`granted`}):e})})),r(),[2]}})})},[n,r]));return W(`participant-updated`,A(function(e){e.participant.local&&i()},[i])),W(`available-devices-updated`,r),W(`selected-devices-updated`,r),W(`camera-error`,F(A(function(e,t,n){switch(t(lg,n.error),n.error?.type){case`cam-in-use`:t(ig,`in-use`);break;case`mic-in-use`:t(ag,`in-use`);break;case`cam-mic-in-use`:t(ig,`in-use`),t(ag,`in-use`);break;case`not-found`:n.error?.missingMedia.includes(`video`)&&t(ig,`not-found`),n.error?.missingMedia.includes(`audio`)&&t(ag,`not-found`);break;case`permissions`:n.error?.blockedMedia.includes(`video`)&&t(ig,`blocked`),n.error?.blockedMedia.includes(`audio`)&&t(ag,`blocked`);break;case`constraints`:n.error?.reason===`invalid`?(t(ig,`constraints-invalid`),t(ag,`constraints-invalid`)):n.error?.reason===`none-specified`&&(t(ig,`constraints-none-specified`),t(ag,`constraints-none-specified`));break;case`undefined-mediadevices`:t(ig,`undefined-mediadevices`),t(ag,`undefined-mediadevices`);break;default:t(ig,`unknown`),t(ag,`unknown`);break}},[]))),W(`started-camera`,F(A(function(e,t){t(ig,`granted`),t(ag,`granted`),i()},[i]))),P.createElement(rg.Provider,{value:{refreshDevices:r}},t)};function dg(e){return e.instanceId??`__default__`}var fg=N({});fg.debugLabel=G(`live-streaming-instances`);var pg=N(function(e){var t=e(fg),n=Object.values(t),r=n.filter(function(e){return e.isLiveStreaming}),i=r[0]??n[n.length-1];return{errorMsg:n.find(function(e){return e.errorMsg})?.errorMsg,isLiveStreaming:r.length>0,layout:i?.layout}});pg.debugLabel=G(`live-streaming`);var mg=function(e){var t=e.children;return W(`live-streaming-started`,F(A(function(e,t,n){var r=dg(n);t(fg,function(e){var t;return U(U({},e),(t={},t[r]={instanceId:r,isLiveStreaming:!0,layout:n?.layout},t))})},[]))),W(`live-streaming-stopped`,F(A(function(e,t,n){var r=dg(n);t(fg,function(e){var t;return e[r]?U(U({},e),(t={},t[r]=U(U({},e[r]),{isLiveStreaming:!1,layout:void 0}),t)):e})},[]))),W(`live-streaming-error`,F(A(function(e,t,n){var r=dg(n);t(fg,function(e){var t;return U(U({},e),(t={},t[r]=U(U({},e[r]??{instanceId:r,isLiveStreaming:!1}),{errorMsg:n.errorMsg}),t))})},[]))),W(`left-meeting`,F(A(function(e,t){t(fg,{})},[]))),P.createElement(P.Fragment,null,t)},hg=N(`new`);hg.debugLabel=G(`meeting-state`);var gg=N(null);gg.debugLabel=G(`meeting-error`);var _g=N(null);_g.debugLabel=G(`non-fatal-error`);var vg=N({data:void 0,topology:`none`});vg.debugLabel=G(`meeting-session-data`);var yg=function(e){var t=e.children,n=ah(),r=F(A(function(e,t){if(n){var r=n.meetingState();return t(hg,r),r}},[n]));return W(`loading`,r),W(`loaded`,r),W(`joining-meeting`,r),W(`joined-meeting`,r),W(`left-meeting`,r),W(`error`,F(A(function(e,t,n){t(gg,n),r()},[r]))),W(`nonfatal-error`,F(A(function(e,t,n){t(_g,n)},[]))),W(`joined-meeting`,F(A(function(e,t){n&&t(vg,n.meetingSessionState())},[n]))),W(`meeting-session-state-updated`,F(A(function(e,t,n){t(vg,n.meetingSessionState)},[]))),W(`left-meeting`,F(A(function(e,t){t(vg,{data:void 0,topology:`none`})},[]))),W(`call-instance-destroyed`,F(A(function(e,t){t(hg,`new`),t(gg,null),t(_g,null),t(vg,{data:void 0,topology:`none`})},[]))),P.createElement(P.Fragment,null,t)},bg=N(`none`);bg.debugLabel=G(`topology`);var xg=N(`unknown`),Sg=N([]),Cg=N(`interrupted`),wg=N(100);wg.debugLabel=G(`network-quality`);var Tg=N(`good`);Tg.debugLabel=G(`network-threshold`);var Eg=function(e){var t=e.children,n=ah(),r=mo(bg),i=F(A(function(e,t){return $m(void 0,void 0,void 0,function(){var e;return eh(this,function(r){switch(r.label){case 0:return n?[4,n.getNetworkTopology()]:[2];case 1:return e=r.sent(),!e||e?.topology===`none`||t(bg,e.topology),[2]}})})},[n]));return W(`joined-meeting`,i),W(`network-connection`,F(A(function(e,t,n){switch(t(Cg,n.event),n.event){case`connected`:n.type===`peer-to-peer`&&t(bg,`peer`),n.type===`sfu`&&t(bg,`sfu`);break}},[]))),W(`network-quality-change`,F(A(function(e,t,n){t(xg,function(e){return e===n.networkState?e:n.networkState}),t(Sg,function(e){var t=n.networkStateReasons??[];return fh(e,t)?e:t}),t(wg,function(e){return e===n.quality?e:n.quality}),t(Tg,function(e){return e===n.threshold?e:n.threshold})},[]))),W(`left-meeting`,F(A(function(e,t){t(bg,`none`),t(xg,`unknown`),t(Sg,[]),t(Cg,`interrupted`),t(wg,100),t(Tg,`good`)},[]))),D(function(){!n||r!==`none`||i()},[n,i,r]),P.createElement(P.Fragment,null,t)};function Dg(e){return e.instanceId?e.instanceId:e.type===`local`||e.local?`__local__`:`__default__`}var Og=N({});Og.debugLabel=G(`recording-instances`);var kg=N(function(e){var t=e(Og),n=Object.values(t),r=n.filter(function(e){return e.isRecording}),i=r[0]??n[n.length-1];return{error:n.some(function(e){return e.error}),isLocalParticipantRecorded:n.some(function(e){return e.isLocalParticipantRecorded}),isRecording:r.length>0,layout:i?.layout,local:i?.local,recordingId:i?.recordingId,recordingStartedDate:i?.recordingStartedDate,startedBy:i?.startedBy,type:i?.type}});kg.debugLabel=G(`recording-state`);var Ag=function(e){var t=e.children,n=Hh(),r=Yh({filter:`record`}),i=F(A(function(e,t,n,r){var i=e(Og).__local__,a={instanceId:`__local__`,isLocalParticipantRecorded:n,isRecording:n,local:n?r:i?.local,type:n?`local`:i?.type};i&&dh(i,a)||!n&&!i||(n?t(Og,function(e){return U(U({},e),{__local__:a})}):i&&t(Og,function(e){return U(U({},e),{__local__:U(U({},i),{isLocalParticipantRecorded:!1,isRecording:!1})})}))},[]));return D(function(){i(r.length>0,r.includes(n||`local`))},[n,i,r]),W(`recording-started`,F(A(function(e,t,r){var i=Dg(r),a=!0;switch(r.type){case`cloud-audio-only`:case`cloud-beta`:case`cloud`:n&&r.layout?.preset===`single-participant`&&r.layout.session_id!==n&&(a=!1);break}t(Og,function(e){var t;return U(U({},e),(t={},t[i]={error:!1,instanceId:i,isLocalParticipantRecorded:a,isRecording:!0,layout:r?.layout,local:r?.local,recordingId:r?.recordingId,recordingStartedDate:new Date,startedBy:r?.startedBy,type:r?.type},t))})},[n]))),W(`recording-stopped`,F(A(function(e,t,n){var r=Dg(n);t(Og,function(e){var t;return e[r]?U(U({},e),(t={},t[r]=U(U({},e[r]),{isLocalParticipantRecorded:!1,isRecording:!1}),t)):e})},[]))),W(`recording-error`,F(A(function(e,t,n){var r=Dg(n);t(Og,function(e){var t,i=e[r];return U(U({},e),(t={},t[r]=U(U({},i??{instanceId:r}),{error:!0,errorMsg:n.errorMsg,isLocalParticipantRecorded:!1,isRecording:!1}),t))})},[]))),W(`left-meeting`,F(A(function(e,t){t(Og,{})},[]))),P.createElement(P.Fragment,null,t)},jg=function(){var e=mo(hg);return pt(e),e},Mg=N(null);Mg.debugLabel=G(`room-state`);var Ng=function(e){var t=e.children,n=ah(),r=jg();return W(`access-state-updated`,F(A(function(e,t){return $m(void 0,void 0,void 0,function(){var e;return eh(this,function(i){switch(i.label){case 0:return!n||r===`left-meeting`?[2]:[4,n.room()];case 1:return e=i.sent(),e&&`id`in e&&t(Mg,e),[2,e]}})})},[n,r]))),W(`left-meeting`,F(A(function(e,t){return function(){t(Mg,null)}},[]))),P.createElement(P.Fragment,null,t)},Pg=N({isTranscribing:!1,model:`general`,language:`en`,transcriptions:[]});Pg.debugLabel=G(`transcription-state`);var Fg=function(e){var t=e.children;return W(`transcription-started`,F(A(function(e,t,n){t(Pg,{error:!1,transcriptionStartDate:new Date,isTranscribing:!0,transcriptions:[],endpointing:n.endpointing,extra:n.extra,includeRawResponse:n.includeRawResponse,instanceId:n.instanceId,language:n.language,model:n.model,profanity_filter:n.profanity_filter,punctuate:n.punctuate,redact:n.redact,startedBy:n.startedBy,tier:n.tier})},[]))),W(`transcription-stopped`,F(A(function(e,t,n){t(Pg,function(e){return U(U({},e),{updatedBy:n.updatedBy,isTranscribing:!1})})},[]))),W(`transcription-error`,F(A(function(e,t){t(Pg,function(e){return U(U({},e),{error:!0,isTranscribing:!1})})},[]))),W(`left-meeting`,F(A(function(e,t){t(Pg,function(e){return U(U({},e),{isTranscribing:!1})})},[]))),W(`app-message`,F(A(function(e,t,n){n?.fromId===`transcription`&&t(Pg,function(e){return U(U({},e),{isTranscribing:!0,transcriptions:rh(rh([],nh(e.transcriptions),!1),[n.data],!1)})})},[]))),P.createElement(P.Fragment,null,t)},Ig=`0.25.2`,Lg={strictMode:!0},Rg=function(){return!0},zg={options:Lg,shouldCreateInstance:Rg},Bg=function(e,t){var n=t===void 0?zg:t,r=n.parentElRef,i=n.options,a=i===void 0?Lg:i,o=n.shouldCreateInstance,s=o===void 0?Rg:o,c=nh(E(null),2),l=c[0],u=c[1],d=O();return D(function(){if(e===`callFrame`&&r?.current===null||!s())return;function t(e){return $m(this,void 0,void 0,function(){return eh(this,function(t){switch(t.label){case 0:return[4,e.destroy()];case 1:return t.sent(),[2]}})})}var n=function(){setTimeout(function(){return u(null)},0)},i=Cm.getCallInstance();if(!l&&i&&!i.isDestroyed()){i.once(`call-instance-destroyed`,n),u(i);return}if(l){dh(d.current,a)||t(l);return}if(!i||i.isDestroyed())try{var o=U(U({},a),{aboutClient:U(U({},a.aboutClient??{}),{"daily-react":Ig})});switch(e){case`callFrame`:i=r?.current?Cm.createFrame(r.current,o):Cm.createFrame(o);break;case`callObject`:i=Cm.createCallObject(o);break}d.current=a,u(i),i.once(`call-instance-destroyed`,n)}catch(e){if(console.error(`Error creating call instance:`,e),a.strictMode)throw e}},[l,a,r,s,e]),l},Vg=function(e){return Bg(`callObject`,e)},Hg=function(e){var t=e.children,n=e.jotaiStore,r=Qm(e,[`children`,`jotaiStore`]),i=O({}),a=A(function(e){var t,n;if(`action`in e){var r=e.action,a=Array.from(i.current?.[r]??[]),o=a.filter(function(e){return nh(e,1)[0]<0}),s=a.filter(function(e){return nh(e,1)[0]>0}),c=rh(rh([],nh(o),!1),nh(s),!1);try{for(var l=th(c),u=l.next();!u.done;u=l.next()){var d=nh(u.value,2)[1];d(e)}}catch(e){t={error:e}}finally{try{u&&!u.done&&(n=l.return)&&n.call(l)}finally{if(t)throw t.error}}}},[]),o=A(function(e){e&&Object.keys(i.current).forEach(function(t){e.off(t,a),e.isDestroyed()||e.on(t,a)})},[a]),s=`callObject`in r?r.callObject:null,c=Vg({options:k(function(){return`callObject`in r?{}:r},[r]),shouldCreateInstance:A(function(){return!(`callObject`in r)},[r])}),l=s??c;D(function(){l&&o(l)},[l,o]);var u=A(function(e,t,n){var r;i.current[e]||(i.current[e]=new Map,l&&(l.off(e,a),l.isDestroyed()||l.on(e,a))),i.current[e]?.has(n)||(r=i.current[e])==null||r.set(n,t)},[l,a]),d=A(function(e,t){var n;(n=i.current[e])==null||n.delete(t),i.current[e]?.size===0&&(l?.off(e,a),delete i.current[e])},[l,a]);return P.createElement(so,{store:n},P.createElement(ih.Provider,{value:l},P.createElement(oh.Provider,{value:{on:u,off:d}},P.createElement(Ng,null,P.createElement(yg,null,P.createElement(Eg,null,P.createElement(Vh,null,P.createElement(Ag,null,P.createElement(mg,null,P.createElement(Fg,null,P.createElement(ug,null,t)))))))))))},Ug=function(e){var t=(e===void 0?{}:e).onAppMessage,n=ah(),r=A(function(e,t){t===void 0&&(t=`*`),n&&n.sendAppMessage(e,t)},[n]);return W(`app-message`,A(function(e){t?.(e,r)},[t,r])),r},Wg=function(e,t,n,r){var i=ah(),a=e===Hh();W(`local-audio-level`,A(function(e){a&&t(e.audioLevel)},[t,a])),W(`remote-participants-audio-level`,A(function(n){a||t(n.participantsAudioLevel[e])},[t,e,a])),D(function(){if(!(!i||i.isDestroyed()||!a)&&!i.isLocalAudioLevelObserverRunning())try{i.startLocalAudioLevelObserver(r)}catch{n?.(`Local audio level observer not supported in this browser`)}},[i,n,r,a]),D(function(){!i||i.isDestroyed()||a||i.isRemoteParticipantsAudioLevelObserverRunning()||i.startRemoteParticipantsAudioLevelObserver(r)},[i,r,a])},Gg=function(e){return Qh(e,`audio`)},Kg,qg;function Jg(){return qg?Kg:(qg=1,Kg=function e(t,n){if(t===n)return!0;if(t&&n&&Zm(t)==`object`&&Zm(n)==`object`){if(t.constructor!==n.constructor)return!1;var r,i,a;if(Array.isArray(t)){if(r=t.length,r!=n.length)return!1;for(i=r;i--!==0;)if(!e(t[i],n[i]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if(a=Object.keys(t),r=a.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,a[i]))return!1;for(i=r;i--!==0;){var o=a[i];if(!e(t[o],n[o]))return!1}return!0}return t!==t&&n!==n},Kg)}Jg();var Yg=N({state:`low`,reason:`none`});Yg.debugLabel=G(`cpu-load`);var Xg=function(){var e=ah(),t=mo(ig),n=mo(ag),r=mo(og),i=mo(sg),a=mo(cg),o=mo(lg),s=ft(rg).refreshDevices,c=A(function(t){return $m(void 0,void 0,void 0,function(){return eh(this,function(n){switch(n.label){case 0:return[4,e?.setInputDevicesAsync({audioDeviceId:null,videoDeviceId:t})];case 1:return n.sent(),[2]}})})},[e]),l=A(function(t){return $m(void 0,void 0,void 0,function(){return eh(this,function(n){switch(n.label){case 0:return[4,e?.setInputDevicesAsync({audioDeviceId:t,videoDeviceId:null})];case 1:return n.sent(),[2]}})})},[e]),u=A(function(t){return $m(void 0,void 0,void 0,function(){return eh(this,function(n){switch(n.label){case 0:return[4,e?.setOutputDeviceAsync({outputDeviceId:t})];case 1:return n.sent(),[2]}})})},[e]),d=[`blocked`,`in-use`,`not-found`,`constraints-invalid`,`constraints-none-specified`,`undefined-mediadevices`,`unknown`],f={cameraError:o,cameras:r,camState:t,currentCam:r.find(function(e){return e.selected}),currentMic:i.find(function(e){return e.selected}),currentSpeaker:a.find(function(e){return e.selected}),hasCamError:d.includes(t),hasMicError:d.includes(n),microphones:i,micState:n,refreshDevices:s,setCamera:c,setMicrophone:l,setSpeaker:u,speakers:a};return pt(f),f},Zg=N(null);Zg.debugLabel=G(`input-settings`);var Qg=N({hidden:0,present:0});Qg.debugLabel=G(`participant-counts`);var $g=sa(function(e){var t=N({},function(t,n,r){n($g(e),r)});return t.debugLabel=G(`participant-receive-settings-${e}`),t}),e_=function(e){return Qh(e,`screenVideo`)},t_=N(null);t_.debugLabel=G(`send-settings`);var n_=function(e){return Qh(e,`video`)};function r_({children:e}){return j(Hg,{children:e})}var i_=Fe(null),a_=`tavus:memory-user-id:`,o_=new Map;function s_(e){return`${a_}${e}`}function c_(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function l_(e){if(!e)return``;let t=s_(e);try{let e=window.localStorage.getItem(t);if(e)return e;let n=c_();return window.localStorage.setItem(t,n),n}catch{}let n=o_.get(t);if(n)return n;let r=c_();return o_.set(t,r),r}var u_=`tavus:terms-accepted:`;function d_(e){let t=5381;for(let n=0;n<e.length;n++)t=(t*33^e.charCodeAt(n))>>>0;return t.toString(36)}function f_(e,t){return`${u_}${e}:${d_(t)}`}function p_(e,t){if(!e||!t)return!1;try{return globalThis.localStorage?.getItem(f_(e,t))===`1`}catch{return!1}}function m_(e,t){if(!(!e||!t))try{globalThis.localStorage?.setItem(f_(e,t),`1`)}catch{}}var h_=null;function g_(e,t){!e||!t||(h_={deploymentId:e,content:t})}function __(){h_&&=(m_(h_.deploymentId,h_.content),null)}function v_(e){return e===`replica`||e===`user`?e:null}function y_(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function b_(e){if(!y_(e)||e.message_type!==`conversation`||typeof e.event_type!=`string`||!y_(e.properties))return null;if(e.event_type===`conversation.utterance`){let t=e.properties;return typeof t.speech==`string`?{kind:`chat-message`,sender:t.role===`replica`?`agent`:`user`,text:t.speech}:null}if(e.event_type===`conversation.utterance.streaming`){let t=e.properties;if(typeof t.speech!=`string`)return null;let n=t.final===!0||t.is_interrupted===!0;return{kind:`caption-update`,text:t.speech,final:n,role:v_(t.role)}}return null}function x_(e,t){return{message_type:`conversation`,event_type:`conversation.respond`,conversation_id:e,properties:{text:t}}}function S_(e,t){return typeof e[t]==`number`?{[t]:e[t]}:{}}function C_(e){let t=e.role===`user`||e.role===`replica`?e.role:null;return!t||typeof e.speech!=`string`?null:{kind:`utterance`,event_type:`conversation.utterance`,properties:{role:t,speech:e.speech,...S_(e,`seq`),...S_(e,`turn_idx`)}}}function w_(e){let t=e.role===`user`||e.role===`replica`?e.role:null;return!t||typeof e.speech!=`string`?null:{kind:`utterance.streaming`,event_type:`conversation.utterance.streaming`,properties:{role:t,speech:e.speech,...typeof e.final==`boolean`?{final:e.final}:{},...typeof e.is_interrupted==`boolean`?{is_interrupted:e.is_interrupted}:{},...S_(e,`seq`)}}}function T_(e){return typeof e.name!=`string`||typeof e.arguments!=`string`?null:{kind:`tool_call`,event_type:`conversation.tool_call`,properties:{name:e.name,arguments:e.arguments,...S_(e,`seq`),...S_(e,`turn_idx`)}}}function E_(e){if(typeof e.name!=`string`||typeof e.arguments!=`string`)return null;let t=e.modality===`vision`||e.modality===`audio`?e.modality:null;return t?{kind:`perception_tool_call`,event_type:`conversation.perception_tool_call`,properties:{name:e.name,arguments:e.arguments,modality:t}}:null}function D_(e){return{kind:`perception_analysis`,event_type:`conversation.perception_analysis`,properties:e}}function O_(e,t){return{kind:`speaking`,event_type:t,properties:{...S_(e,`seq`),...S_(e,`turn_idx`)}}}var k_={"conversation.utterance":C_,"conversation.utterance.streaming":w_,"conversation.tool_call":T_,"conversation.perception_tool_call":E_,"conversation.perception_analysis":D_,"conversation.replica_started_speaking":O_,"conversation.replica_stopped_speaking":O_,"conversation.user_started_speaking":O_,"conversation.user_stopped_speaking":O_};function A_(e){if(!y_(e)||e.message_type!==`conversation`||typeof e.event_type!=`string`||!y_(e.properties))return null;let t=k_[e.event_type];return t?t(e.properties,e.event_type):{kind:`unknown`,event_type:e.event_type,properties:e.properties}}function j_(e,t){return{message_type:`conversation`,event_type:t.event_type,conversation_id:e,properties:t.properties??{}}}function M_(e,t){let n=b_(e);return n?n.kind===`chat-message`?(t.appendChatMessage(n.sender,n.text),!0):(t.setCaption(n.text,n.final,n.role),!0):!1}function N_(e=5e3){let t=[],n=n=>{for(;t.length>0&&n-t[0].ts>e;)t.shift()};return{markSent(e){t.push({text:e,ts:Date.now()})},consumeMatch(e){n(Date.now());let r=t.findIndex(t=>t.text===e);return r===-1?!1:(t.splice(r,1),!0)}}}var P_=_n(`Conversation`),F_=1500,I_=Fe(null);function L_({children:e}){return j(r_,{children:j(W_,{children:e})})}function R_(e,t,n){let{role:r,speech:i}=e.properties;if(!(r===`user`&&n.consumeMatch(i)))for(let n of t)n.onUtterance?.({...e.properties})}function z_(e,t){for(let n of t)n.onToolCall?.({...e.properties})}function B_(e,t){for(let n of t)n.onPerception?.(e)}function V_(e,t){let n=e.event_type,r=n.startsWith(`conversation.replica`)?`replica`:`user`,i=n.endsWith(`started_speaking`)?`started`:`stopped`;for(let n of t)n.onSpeakingState?.({who:r,state:i,...e.properties})}function H_(e,t){for(let n of t)n.onMessage?.(e)}function U_(e,t,n){switch(e.kind){case`utterance`:case`utterance.streaming`:R_(e,t,n);return;case`tool_call`:z_(e,t);return;case`perception_tool_call`:case`perception_analysis`:B_(e,t);return;case`speaking`:V_(e,t);return;case`unknown`:H_(e,t);return}}function W_({children:e}){let{deploymentId:t,client:n,config:r}=ft(yi),i=ah(),a=jg(),o=ft(i_),s=k(()=>Ht(`idle`),[]),c=k(()=>Ht(null),[]),l=k(()=>Ht([]),[]),u=k(()=>Ht(``),[]),d=k(()=>Ht(null),[]),f=k(()=>Ht(null),[]),p=k(()=>Ht(null),[]),m=k(()=>Ht(null),[]),h=O(null),g=k(()=>N_(),[]),_=k(()=>new Set,[]),v=k(()=>Ht(`idle`),[]),y=o?.flowSignal??v,b=A(e=>{p.value=e},[p]),x=A(e=>{m.value=e},[m]),[,S]=E(a);D(()=>{S(a),a===`joined-meeting`?(s.value=`connected`,P_.info(`Connected to meeting`)):a===`left-meeting`?(s.value=`ended`,__(),P_.info(`Left meeting`)):a===`error`&&(f.value=`Meeting error`,s.value=`error`)},[a,s,f]),gn(()=>{let e=s.value;if(e===`connected`)for(let e of _)e.onConnect?.();else if(e===`ended`||e===`disconnecting`)for(let e of _)e.onDisconnect?.();else if(e===`error`){let e=f.peek()??`Unknown error`;for(let t of _)t.onError?.({code:`CONVERSATION_ERROR`,message:e})}}),gn(()=>{let e=y.value;for(let t of _)t.onModeChange?.(e)}),Ug({onAppMessage:A(e=>{M_(e?.data,{appendChatMessage(e,t){e===`user`&&g.consumeMatch(t)||(l.value=[...l.peek(),{id:crypto.randomUUID(),sender:e,text:t,timestamp:Date.now()}])},setCaption(e,t,n){u.value=e,d.value=n,h.current!==null&&(clearTimeout(h.current),h.current=null),t&&(h.current=setTimeout(()=>{u.value=``,d.value=null,h.current=null},F_))}});let t=A_(e?.data);t&&U_(t,_,g)},[l,u,d,g,_])}),D(()=>()=>{h.current!==null&&(clearTimeout(h.current),h.current=null)},[]);let C=A(async(e,a)=>{try{s.value=`connecting`,f.value=null;let o=e,l=p.peek();l&&o?.password==null&&(o={...o,password:l}),r.value.customization.conversation.unique_memory_tag===!0&&!o?.memory_stores&&(o={...o,memory_stores:[l_(t)]});let u=m.peek();m.value=null,u&&o?.captcha_token==null&&(o={...o,captcha_token:u});let d=await Sn(n,t,o,a);c.value={conversationId:d.conversation_id,conversationName:d.conversation_name,conversationUrl:d.conversation_url,callbackUrl:d.callback_url,createdAt:d.created_at},await i?.join({url:d.conversation_url})}catch(e){throw e instanceof bn&&(e.status===401||e.status===403)&&r.value.has_password===!0&&(p.value=null),P_.error(`Start failed`,e),f.value=String(e),s.value=`error`,e}},[n,t,i,s,f,c,p,m,r]),w=A(async()=>{let e=c.peek();s.value=`disconnecting`,e&&await Cn(n,t,e.conversationId).catch(e=>P_.error(`End conversation API failed`,e)),await i?.leave(),s.value=`ended`},[n,t,i,s,c]),ee=A(e=>{if(!i)return;let t=c.peek();if(!t){P_.warn(`sendChat called before session was established; dropping message`);return}g.markSent(e),i.sendAppMessage(x_(t.conversationId,e),`*`),l.value=[...l.peek(),{id:crypto.randomUUID(),sender:`user`,text:e,timestamp:Date.now()}]},[i,l,c,g]),T=A(e=>{if(!i){P_.warn(`sendMessage called before Daily was ready; dropping message`);return}let t=c.peek();if(!t){P_.warn(`sendMessage called before session was established; dropping message`);return}e.event_type===`conversation.respond`&&g.markSent(e.properties.text),i.sendAppMessage(j_(t.conversationId,e),`*`)},[i,c,g]),te=A(e=>{_.add(e)},[_]),ne=A(e=>{_.delete(e)},[_]),re=k(()=>({state:s,session:c,chatMessages:l,captionText:u,captionRole:d,error:f,password:p,setPassword:b,captchaToken:m,setCaptchaToken:x,mode:y,start:C,end:w,sendChat:ee,sendMessage:T,conversation:{start:C,end:w,sendMessage:T},__registerSubscriber:te,__unregisterSubscriber:ne}),[s,c,l,u,d,f,p,b,m,x,y,C,w,ee,T,te,ne]);return j(I_.Provider,{value:re,children:e})}function G_(){let e=ft(yi);if(!e)throw Error(`useConfig must be used within ConfigProvider`);return e}var K_=new Set([`network`,`server`,`unavailable`,`busy`,`rate_limited`]);function q_(e){return e===401||e===403?`forbidden`:e===402?`limit_exceeded`:e===423?`busy`:e===429?`rate_limited`:e===409?`concurrency`:e===503?`unavailable`:e>=500?`server`:`unknown`}function J_(e){if(!e)return;let t=e.get(`Retry-After`);if(!t)return;let n=Number.parseInt(t,10);if(!Number.isNaN(n)&&n>=0)return n;let r=Date.parse(t);if(!Number.isNaN(r)){let e=Math.floor((r-Date.now())/1e3);return e>0?e:0}}function Y_(e){if(e instanceof bn){let t=q_(e.status);return{kind:t,status:e.status,raw:e.body,retryable:K_.has(t),retryAfterSec:J_(e.headers)}}return e instanceof TypeError?{kind:`network`,raw:String(e),retryable:!0}:{kind:`unknown`,raw:String(e),retryable:!1}}function X_(e){return e===`limit_exceeded`?`daily_limit`:e===`forbidden`||e===`concurrency`?null:`busy`}var Z_=`tavus_pudl_`,Q_=3600*48,$_=new Map;function ev(){let e=new Date;return`${e.getUTCFullYear()}${String(e.getUTCMonth()+1).padStart(2,`0`)}${String(e.getUTCDate()).padStart(2,`0`)}`}function tv(e){return`${Z_}${e}`}function nv(e){try{let t=`${tv(e)}=`,n=document.cookie.split(`; `).find(e=>e.startsWith(t));if(!n)return 0;let[r,i]=decodeURIComponent(n.slice(t.length)).split(`.`);if(r!==ev())return 0;let a=Number.parseInt(i,10);return Number.isFinite(a)&&a>0?a:0}catch{return 0}}function rv(e,t){try{let n=encodeURIComponent(`${ev()}.${t}`);document.cookie=`${tv(e)}=${n}; max-age=${Q_}; path=/; SameSite=Lax`}catch{return}}function iv(e){let t=$_.get(e);return t||(t=Ht(e?nv(e):0),$_.set(e,t)),t}function av(e){if(!e)return;rv(e,nv(e)+1);let t=nv(e),n=$_.get(e);n?n.value=t:$_.set(e,Ht(t))}var ov=new Set([`Captcha token required`,`Captcha verification failed`]);function sv(e){if(!(e instanceof bn)||e.status!==403)return!1;try{let t=JSON.parse(e.body.trim());return typeof t.error==`string`&&ov.has(t.error)}catch{return!1}}function cv(e,t){let n=e!==null,r=(t?.captchaToken.peek()??null)!==null,[i,a]=E(!n||r),[o,s]=E(0);D(()=>{n||a(!0)},[n]);let c=A(e=>{t?.setCaptchaToken(e),a(!0)},[t]),l=A(()=>{a(!0)},[]),u=t?.captchaToken.value??null,d=O(null);return D(()=>{let e=d.current!==null;d.current=u,n&&u===null&&(a(!1),e&&s(e=>e+1))},[n,u]),{captchaReady:i,captchaEpoch:o,handleCaptchaToken:c,handleCaptchaFallback:l}}function lv({children:e}){let{config:t}=G_(),{start:n}=ft(I_),r=t.value.deployment_id??``,i=iv(r),a=A(()=>{let e=t.value,n=e.limits?.daily_call_limit_per_user;return n==null||e.channel!==`widget`&&e.channel!==`embed`?null:n},[t]),[o,s]=E(`idle`),[c,l]=E(!1),[u,d]=E(null),[f,p]=E(!1),m=k(()=>Ht(`idle`),[]);D(()=>{m.value=o},[o,m]),gn(()=>{let e=t.value,n=e.limits?.daily_call_limit_per_user;n!=null&&(e.channel!==`widget`&&e.channel!==`embed`||m.value===`idle`&&i.value>=n&&(d(`daily_limit`),p(!1),s(`unavailable`)))});let h=t.value.customization.show_haircheck,g=t.value.customization.conversation.modality,_=h&&g!==`chat`,v=O(!1),y=A(async()=>{l(!0);try{await n(),v.current=!1,a()!=null&&av(r),s(`call`)}catch(e){let n=Y_(e);if(sv(e)&&!v.current){v.current=!0,l(!1),s(`idle`);return}if(v.current=!1,n.kind===`forbidden`&&t.value.has_password===!0){s(`idle`);return}d(X_(n.kind)??`busy`),p(n.retryable),s(`unavailable`)}finally{l(!1)}},[n,t,a,r]),b=A(async()=>{if(o!==`idle`&&o!==`unavailable`)return;let e=a();if(e!=null&&i.value>=e){d(`daily_limit`),p(!1),s(`unavailable`);return}if(d(null),p(!1),_){s(`haircheck`);return}return y()},[o,_,y,a,i]),x=A(async()=>{o===`haircheck`&&await y()},[o,y]),S=A(()=>{o===`haircheck`&&s(`idle`)},[o]),C=A(()=>{o===`call`&&s(`ended`)},[o]),w=A(()=>{d(null),p(!1),s(`idle`)},[]),ee=k(()=>({flowSignal:m,setFlowState:s,isStarting:c,unavailableCause:u,canRetry:f,start:b,join:x,cancel:S,leave:C,restart:w}),[m,c,u,f,b,x,S,C,w]);return j(i_.Provider,{value:ee,children:e})}var uv=_n(`HostBridge`),dv=Fe(null);function fv(e){if(!e)return null;let t=e.getRootNode();return t instanceof ShadowRoot&&t.host instanceof HTMLElement?t.host:e.parentElement}function pv({children:e}){let t=ft(I_),n=ft(i_),r=ln(null),i=A(e=>{r.value=fv(e)},[r]),a=A((e,t)=>{let n=r.peek();n&&n.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0})),uv.info(`Event:`,e,t)},[r]);D(()=>{let e=r.value;if(e)return e.tavus={start:t.start,end:t.end,sendChat:t.sendChat,sendMessage:t.sendMessage},()=>{delete e.tavus}},[r.value,t]),D(()=>t.state.subscribe(e=>{switch(e){case`connected`:a(`tavus:conversation-started`,{conversationId:t.session.peek()?.conversationId??``}),a(`tavus:state-change`,{state:e});break;case`ended`:a(`tavus:conversation-ended`,{conversationId:t.session.peek()?.conversationId??``}),a(`tavus:state-change`,{state:e});break;case`error`:a(`tavus:error`,{code:`CONVERSATION_ERROR`,message:t.error.peek()??`Unknown error`}),a(`tavus:state-change`,{state:e});break;default:a(`tavus:state-change`,{state:e})}}),[t,a]),gn(()=>{if(!n)return;let e=n.flowSignal.value;a(`tavus:mode-change`,{mode:e})}),D(()=>{let e={onUtterance(e){a(`tavus:protocol-message`,{kind:`utterance`,event_type:`conversation.utterance`,properties:e})},onToolCall(e){a(`tavus:tool-call`,e),a(`tavus:protocol-message`,{kind:`tool_call`,event_type:`conversation.tool_call`,properties:e})},onPerception(e){a(`tavus:protocol-message`,e)},onSpeakingState({who:e,state:t,seq:n,turn_idx:r}){let i={state:t,...n===void 0?{}:{seq:n},...r===void 0?{}:{turn_idx:r}};a(`tavus:protocol-message`,{kind:`speaking`,event_type:e===`replica`?t===`started`?`conversation.replica_started_speaking`:`conversation.replica_stopped_speaking`:t===`started`?`conversation.user_started_speaking`:`conversation.user_stopped_speaking`,properties:i})},onMessage(e){a(`tavus:protocol-message`,e)}};return t.__registerSubscriber(e),()=>t.__unregisterSubscriber(e)},[t,a]);let o=k(()=>({shadowHost:r,dispatchEvent:a}),[r,a]);return j(dv.Provider,{value:o,children:[j(`div`,{ref:i,style:`display:contents`}),e]})}var mv=Fe(null);function hv({children:e}){let{config:t}=ft(yi),n=k(()=>qt(()=>{let e=t.value.customization.style;return e.mode===`dark`||e.mode===`system`&&(globalThis.matchMedia?.(`(prefers-color-scheme: dark)`).matches??!1)}),[t]),r=k(()=>qt(()=>{let e=t.value.customization.style;return e.style===`basic`?n.value?`white-black`:`black-white`:n.value?`${e.style}-dark`:e.style}),[t,n]),i=k(()=>qt(()=>yv(t.value.customization.style)),[t]),a=k(()=>({dataTheme:r,isDark:n,cssVars:i}),[r,n,i]);return j(mv.Provider,{value:a,children:j(`div`,{"data-theme":r.value,style:bv(i.value),class:`contents`,children:e})})}var gv=[0,.125,.25,.5,.75],_v=[0,1,2,3,4],vv=[0,.2,.25,.3];function yv(e){return{"--radius-box":`${gv[e.boxes_radius]??.5}rem`,"--radius-field":`${gv[e.field_radius]??.25}rem`,"--radius-selector":`${gv[e.selectors_radius]??.5}rem`,"--border":`${_v[e.border_width]??1}px`,"--size-field":`${vv[e.fields_size]??.25}rem`,"--size-selector":`${vv[e.selectors_size]??.25}rem`,"--depth":e.depth_effect?`1`:`0`,"--noise":e.noise_effect?`1`:`0`}}function bv(e){return Object.entries(e).map(([e,t])=>`${e}: ${t}`).join(`; `)}Fe(null);var xv=41/2,Sv=23/2,Cv=Math.hypot(xv,Sv);Array.from({length:1008},(e,t)=>{let n=t%42,r=Math.floor(t/42),i=Math.hypot(n-xv,r-Sv)/Cv*.82,a=.34+(n*13+r*7)%34/100;return{delay:`${i.toFixed(3)}s`,opacity:a.toFixed(2)}});var wv=Fe(null);function Tv({children:e}){let t=O(null);return j(wv.Provider,{value:{frameRef:t},children:j(`div`,{class:`@container/conversation w-full h-full`,children:j(`div`,{ref:t,class:`relative w-full h-full max-h-screen aspect-video @max-mobile:aspect-9/16 overflow-hidden rounded-box bg-base-100`,children:e})})})}var Ev=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),Dv=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),Ov=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()),kv=e=>{let t=Ov(e);return t.charAt(0).toUpperCase()+t.slice(1)},Av={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`,"stroke-linejoin":`round`},jv=Fe({size:24,color:`currentColor`,strokeWidth:2,absoluteStrokeWidth:!1,class:``}),Mv=()=>ft(jv),Nv=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0;return!1},Pv=({color:e,size:t,strokeWidth:n,absoluteStrokeWidth:r,children:i,iconNode:a,class:o=``,...s})=>{let{size:c=24,strokeWidth:l=2,absoluteStrokeWidth:u=!1,color:d=`currentColor`,class:f=``}=Mv()??{},p=r??u?Number(n??l)*24/Number(t??c):n??l;return oe(`svg`,{...Av,width:t??c??24,height:t??c??24,stroke:e??d,"stroke-width":p,class:Ev(`lucide`,f,o),...!i&&!Nv(s)&&{"aria-hidden":`true`},...s},[...a.map(([e,t])=>oe(e,t)),...ye(i)])},Fv=(e,t)=>{let n=({class:n=``,className:r=``,children:i,...a})=>oe(Pv,{...a,iconNode:t,class:Ev(`lucide-${Dv(kv(e))}`,`lucide-${Dv(e)}`,n,r)},i);return n.displayName=kv(e),n},Iv=Fv(`camera-off`,[[`path`,{d:`M14.564 14.558a3 3 0 1 1-4.122-4.121`,key:`1rnrzw`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M20 20H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 .819-.175`,key:`1x3arw`}],[`path`,{d:`M9.695 4.024A2 2 0 0 1 10.004 4h3.993a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v7.344`,key:`1i84u0`}]]),Lv=Fv(`camera`,[[`path`,{d:`M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z`,key:`18u6gg`}],[`circle`,{cx:`12`,cy:`13`,r:`3`,key:`1vg3eu`}]]),Rv=Fv(`captions`,[[`rect`,{width:`18`,height:`14`,x:`3`,y:`5`,rx:`2`,ry:`2`,key:`12ruh7`}],[`path`,{d:`M7 15h4M15 15h2M7 11h2M13 11h4`,key:`1ueiar`}]]),zv=Fv(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]),Bv=Fv(`ellipsis`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]]),Vv=Fv(`expand`,[[`path`,{d:`m15 15 6 6`,key:`1s409w`}],[`path`,{d:`m15 9 6-6`,key:`ko1vev`}],[`path`,{d:`M21 16v5h-5`,key:`1ck2sf`}],[`path`,{d:`M21 8V3h-5`,key:`1qoq8a`}],[`path`,{d:`M3 16v5h5`,key:`1t08am`}],[`path`,{d:`m3 21 6-6`,key:`wwnumi`}],[`path`,{d:`M3 8V3h5`,key:`1ln10m`}],[`path`,{d:`M9 9 3 3`,key:`v551iv`}]]),Hv=Fv(`external-link`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),Uv=Fv(`maximize-2`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`m21 3-7 7`,key:`1l2asr`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M9 21H3v-6`,key:`wtvkvv`}]]),Wv=Fv(`message-circle`,[[`path`,{d:`M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719`,key:`1sd12s`}]]),Gv=Fv(`mic-off`,[[`path`,{d:`M12 19v3`,key:`npa21l`}],[`path`,{d:`M15 9.34V5a3 3 0 0 0-5.68-1.33`,key:`1gzdoj`}],[`path`,{d:`M16.95 16.95A7 7 0 0 1 5 12v-2`,key:`cqa7eg`}],[`path`,{d:`M18.89 13.23A7 7 0 0 0 19 12v-2`,key:`16hl24`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M9 9v3a3 3 0 0 0 5.12 2.12`,key:`r2i35w`}]]),Kv=Fv(`mic`,[[`path`,{d:`M12 19v3`,key:`npa21l`}],[`path`,{d:`M19 10v2a7 7 0 0 1-14 0v-2`,key:`1vc78b`}],[`rect`,{x:`9`,y:`2`,width:`6`,height:`13`,rx:`3`,key:`s6n7sd`}]]),qv=Fv(`minimize-2`,[[`path`,{d:`m14 10 7-7`,key:`oa77jy`}],[`path`,{d:`M20 10h-6V4`,key:`mjg0md`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M4 14h6v6`,key:`rmj7iw`}]]),Jv=Fv(`monitor-up`,[[`path`,{d:`m9 10 3-3 3 3`,key:`11gsxs`}],[`path`,{d:`M12 13V7`,key:`h0r20n`}],[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`,key:`48i651`}],[`path`,{d:`M12 17v4`,key:`1riwvh`}],[`path`,{d:`M8 21h8`,key:`1ev6f3`}]]),Yv=Fv(`moon`,[[`path`,{d:`M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401`,key:`kfwtm`}]]),Xv=Fv(`phone-off`,[[`path`,{d:`M10.1 13.9a14 14 0 0 0 3.732 2.668 1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2 18 18 0 0 1-12.728-5.272`,key:`1wngk7`}],[`path`,{d:`M22 2 2 22`,key:`y4kqgn`}],[`path`,{d:`M4.76 13.582A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 .244.473`,key:`10hv5p`}]]),Zv=Fv(`picture-in-picture-2`,[[`path`,{d:`M21 9V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v10c0 1.1.9 2 2 2h4`,key:`daa4of`}],[`rect`,{width:`10`,height:`7`,x:`12`,y:`13`,rx:`2`,key:`1nb8gs`}]]),Qv=Fv(`send`,[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]),$v=Fv(`shrink`,[[`path`,{d:`m15 15 6 6m-6-6v4.8m0-4.8h4.8`,key:`17vawe`}],[`path`,{d:`M9 19.8V15m0 0H4.2M9 15l-6 6`,key:`chjx8e`}],[`path`,{d:`M15 4.2V9m0 0h4.8M15 9l6-6`,key:`lav6yq`}],[`path`,{d:`M9 4.2V9m0 0H4.2M9 9 3 3`,key:`1pxi2q`}]]),ey=Fv(`smile`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M8 14s1.5 2 4 2 4-2 4-2`,key:`1y1vjs`}],[`line`,{x1:`9`,x2:`9.01`,y1:`9`,y2:`9`,key:`yxxnd0`}],[`line`,{x1:`15`,x2:`15.01`,y1:`9`,y2:`9`,key:`1p4y9e`}]]),ty=Fv(`triangle-alert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),ny=Fv(`user`,[[`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`,key:`975kel`}],[`circle`,{cx:`12`,cy:`7`,r:`4`,key:`17ys0d`}]]),ry=Fv(`users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]),iy=Fv(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]);function ay(e,t){return({size:n=`var(--icon-size, 1.5rem)`,class:r,"aria-label":i})=>j(`span`,{class:r,role:`img`,"aria-label":i??t,children:j(e,{size:n})})}var oy={close:ay(iy,`Close`),leave:ay(Xv,`Leave call`),more:ay(Bv,`More`),error:ay(ty,`Error`),mic:ay(Kv,`Microphone`),"mic-off":ay(Gv,`Microphone muted`),cam:ay(Lv,`Camera`),"cam-off":ay(Iv,`Camera off`),"screen-share":ay(Jv,`Screen share`),pip:ay(Zv,`Picture in picture`),user:ay(ny,`User`),"face-smile":ay(ey,`Camera off`),captions:ay(Rv,`Closed captions`),chat:ay(Wv,`Chat`),fullscreen:ay(Uv,`Enter fullscreen`),"fullscreen-exit":ay(qv,`Exit fullscreen`),expand:ay(Vv,`Expand`),collapse:ay($v,`Collapse`),send:ay(Qv,`Send`),"external-link":ay(Hv,`External link`),clock:ay(zv,`Clock`),moon:ay(Yv,`Unavailable`),users:ay(ry,`Busy`)},sy=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M16 19H4v-2h12v2ZM4 17H2V7h2v10Zm14-8h2V7h2v10h-2v-2h-2v2h-2V7h2v2Zm-2-2H4V5h12v2Z"/></svg>`,cy=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M20 21h-2v-2h2v2Zm-6-2H4v-2h10v2Zm4 0h-2v-2h2v2Zm4 0h-2v-2h-2v-2h-2v-2h-2V7h2v2h2V7h2V5h2v14ZM4 17H2V7h2v10Zm12 0h-2v-2h2v2Zm-2-2h-2v-2h2v2Zm-2-2h-2v-2h2v2Zm-2-2H8V9h2v2ZM8 9H6V7h2v2ZM6 7H4V5h2v2Zm8 0h-4V5h4v2ZM4 5H2V3h2v2Z"/></svg>`,ly=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M3 4h18v2H3zm0 14h18v2H3zM1 6h2v12H1zm20 0h2v12h-2zM5 10h2v4H5zm8 0h2v4h-2zM7 8h4v2H7zm0 6h4v2H7zm8 0h4v2h-4zm0-6h4v2h-4z"/></svg>`,uy=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M22 22h-2v-2h-2v-2h2v-8h2v12Zm-4-4h-8v-2h8v2ZM4 12h2v2H4v2H2V4h2v8Zm6 4H8v-6h2v6Zm10-6H10V8h10v2Zm-4-4h-2V4h2v2Zm-2-2H4V2h10v2Z"/></svg>`,dy=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M18 22H6v-2h12v2ZM6 20H4v-2h2v2Zm14 0h-2v-2h2v2ZM4 18H2V6h2v12Zm18 0h-2V6h2v12Zm-5-1h-2v-2h2v2Zm-2-2h-2v-2h2v2Zm-2-2h-2V6h2v7ZM6 6H4V4h2v2Zm14 0h-2V4h2v2Zm-2-2H6V2h12v2Z"/></svg>`,fy=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M18 22H6v-2h12v2ZM6 20H4v-2h2v2Zm14 0h-2v-2h2v2ZM4 18H2V6h2v12Zm4 0H6v-2h2v2Zm14 0h-2V6h2v12Zm-12-2H8v-2h2v2Zm2-2h-2v-2h2v2Zm2-2h-2v-2h2v2Zm2-2h-2V8h2v2Zm2-2h-2V6h2v2ZM6 6H4V4h2v2Zm14 0h-2V4h2v2Zm-2-2H6V2h12v2Z"/></svg>`,py=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M7 19h2v-2h2v-2h2v2h2v2h2v2H7v-2Zm13-6H4v-2h16v2Zm-3-8h-2v2h-2v2h-2V7H9V5H7V3h10v2Z"/></svg>`,my=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M20 22H4v-2h16v2ZM4 20H2V4h2v16Zm18 0h-2V4h2v16Zm-9-2h-2v-2h2v2Zm0-4h-2V6h2v8Zm7-10H4V2h16v2Z"/></svg>`,hy=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M15 19h-2v2h-2v-2H9v-2H7v-2h10v2h-2v2Zm5-6H4v-2h16v2Zm-7-8h2v2h2v2H7V7h2V5h2V3h2v2Z"/></svg>`,gy=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M8 22H4v-2h4v2Zm12 0h-4v-2h4v2ZM4 20H2v-4h2v4Zm18 0h-2v-4h2v4Zm-6-3H8v-2h8v2Zm-8-2H6V9h2v6Zm10 0h-2V9h2v6Zm-2-6H8V7h8v2ZM4 8H2V4h2v4Zm18 0h-2V4h2v4ZM8 4H4V2h4v2Zm12 0h-4V2h4v2Z"/></svg>`,_y=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M18 22H6v-2h12v2ZM6 20H4V4h2v16Zm14 0h-2v-3h2v3ZM16 9h2v2h2v2h-2v2h-2v2h-2v-4H8v-2h6V7h2v2Zm4-2h-2V4h2v3Zm-2-3H6V2h12v2Z"/></svg>`,vy=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M13 22h-2v-2H8v-2h8v2h-3v2Zm-5-4H6v-2h2v2Zm10 0h-2v-2h2v2ZM6 16H4v-6h2v6Zm8 0h-4v-2h4v2Zm6 0h-2v-6h2v6Zm-10-2H8V4h2v10Zm6 0h-2V4h2v10ZM14 4h-4V2h4v2Z"/></svg>`,yy=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M13 22h-2v-2H8v-2h8v2h-3v2Zm9 0h-2v-2h2v2Zm-2-2h-2v-2h2v2ZM8 18H6v-2h2v2Zm10 0h-2v-2h2v2ZM6 16H4v-6h2v6Zm8-2h2v2h-6v-2h2v-2h2v2Zm-4-4h2v2h-2v2H8V8h2v2Zm10 4h-2v-4h2v4Zm-4-4h-2V4h2v6ZM8 8H6V6h2v2ZM6 6H4V4h2v2ZM4 4H2V2h2v2Zm10 0h-4V2h4v2Z"/></svg>`,by=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M18 22H8v-2h10v2ZM8 20H6v-2h2v2Zm12 0h-2v-2h2v2ZM6 18H4v-2h2v2Zm16 0h-2v-4h-2v-2h2v-2h2v8ZM4 16H2V6h2v10Zm14 0h-6v-2h6v2Zm-6-2h-2v-2h2v2Zm-2-2H8V6h2v6ZM6 6H4V4h2v2Zm8-2h-2v2h-2V4H6V2h8v2Z"/></svg>`,xy=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M5 15H3v-2h2v2Zm8 0h-2v-2h2v2Zm8 0h-2v-2h2v2ZM3 13H1v-2h2v2Zm4 0H5v-2h2v2Zm4 0H9v-2h2v2Zm4 0h-2v-2h2v2Zm4 0h-2v-2h2v2Zm4 0h-2v-2h2v2ZM5 11H3V9h2v2Zm8 0h-2V9h2v2Zm8 0h-2V9h2v2Z"/></svg>`,Sy=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M20 20H4v-2h16v2ZM4 18H2V6h2v12Zm18 0h-2V6h2v12ZM18 8v6h-8V8h8Zm2-2H4V4h16v2Zm-4 4h-4v2h4v-2Z"/></svg>`,Cy=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M20 18h-7v2h3v2H8v-2h3v-2H4v-2h16v2ZM4 16H2V4h2v12Zm18 0h-2v-6h2v6Zm-6-6h-2V8h2v2Zm2-2h-2V6h2v2Zm4-6v6h-2V6h-2V4h-2V2h6Zm-8 2H4V2h10v2Z"/></svg>`,wy=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M4 19h4v2H2v-8h2v6Zm8 0H8v-2h4v2Zm4-2h-4v-2h4v2Zm4-2h-4v-2h4v2Zm-10-2H4v-2h6v2Zm12 0h-2v-2h2v2ZM8 5H4v6H2V3h6v2Zm12 6h-4V9h4v2Zm-4-2h-4V7h4v2Zm-4-2H8V5h4v2Z"/></svg>`,Ty=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M6 22H4v-4h2v4Zm14 0h-2v-4h2v4ZM8 18H6v-2h2v2Zm10 0h-2v-2h2v2Zm-2-2H8v-2h8v2Zm-1-4H9v-2h6v2Zm-6-2H7V4h2v6Zm8 0h-2V4h2v6Zm-2-6H9V2h6v2Z"/></svg>`,Ey=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M2 22H0v-4h2v4Zm14 0h-2v-4h2v4Zm8 0h-2v-4h2v4ZM4 18H2v-2h2v2Zm10 0h-2v-2h2v2Zm8 0h-2v-2h2v2Zm-10-2H4v-2h8v2Zm8 0h-4v-2h4v2Zm-9-4H5v-2h6v2Zm8 0h-4v-2h4v2ZM5 10H3V4h2v6Zm8 0h-2V4h2v6Zm8 0h-2V4h2v6ZM11 4H5V2h6v2Zm8 0h-4V2h4v2Z"/></svg>`,Dy=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M20 22H4v-2h16v2ZM4 20H2v-6H0v-2h2V8h2v12Zm18-8h2v2h-2v6h-2V8h2v4Zm-8 6h-4v-2h4v2Zm-4-2H8v-2h2v2Zm6 0h-2v-2h2v2Zm-6-4H8v-2h2v2Zm6 0h-2v-2h2v2Zm-3-6h7v2H4V6h7V4h2v2Zm4-2h-4V2h4v2Z"/></svg>`,Oy=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M17 21H5v-2h12v2ZM5 19H3V7h2v12Zm14 0h-2v-6h2v6Zm-8-4H9v-2h2v2Zm2-2h-2v-2h2v2Zm2-2h-2V9h2v2Zm6 0h-2V7h-2V5h-4V3h8v8Zm-4-2h-2V7h2v2Zm-6-2H5V5h6v2Z"/></svg>`;function ky(e){return e.replace(/\s(width|height)="\d+"/g,``)}function Ay(e,t){let n=ky(e);return({size:e=`var(--icon-size, 1.5rem)`,class:r,"aria-label":i})=>j(`span`,{class:r,role:`img`,"aria-label":i??t,style:{display:`inline-flex`,width:e,height:e},dangerouslySetInnerHTML:{__html:n.replace(`<svg`,`<svg width="100%" height="100%"`)}})}var jy={pixelarticons:{close:Ay(fy,`Close`),leave:Ay(_y,`Leave call`),more:Ay(xy,`More`),error:Ay(my,`Error`),mic:Ay(vy,`Microphone`),"mic-off":Ay(yy,`Microphone muted`),cam:Ay(sy,`Camera`),"cam-off":Ay(cy,`Camera off`),"screen-share":Ay(Cy,`Screen share`),pip:Ay(Sy,`Picture in picture`),user:Ay(Ty,`User`),"face-smile":Ay(Dy,`Camera off`),captions:Ay(ly,`Closed captions`),chat:Ay(uy,`Chat`),fullscreen:Ay(gy,`Enter fullscreen`),"fullscreen-exit":Ay(py,`Exit fullscreen`),expand:Ay(hy,`Expand`),collapse:Ay(py,`Collapse`),send:Ay(wy,`Send`),"external-link":Ay(Oy,`External link`),clock:Ay(dy,`Clock`),moon:Ay(by,`Unavailable`),users:Ay(Ey,`Busy`)},lucide:oy};function My({name:e,...t}){let{config:n}=G_(),r=(jy[n.value.customization.style.icon_library]??jy.pixelarticons)[e];return j(r,{...t})}var Ny=`Ready when you are`,Py=`Start the conversation`;function Fy(e){return typeof e==`string`&&e.length>0?e:``}function Iy(e){let t=Fy(e.replica_thumbnail_image_url);if(t)return{url:t,kind:`image`};let n=Fy(e.replica_thumbnail_video_url);return n?{url:n,kind:`video`}:null}function Ly(e){let{preview:t}=e.customization,{background:n}=t,r=Iy(e),i;i=n.type?n.type:r?`replica`:`background-gradient`;let a=Fy(n.url);return{title:t.title||Ny,description:t.description||``,btn_title:t.btn_title||Py,background:{type:i,url:a}}}var Ry={backgroundImage:`linear-gradient(to bottom right, var(--color-primary), var(--color-base-300))`};function zy({variant:e,replica:t}){let[n,r]=E(!1);return D(()=>{r(!1)},[e.url]),e.type===`replica`&&t?t.kind===`image`?j(`img`,{class:`absolute inset-0 w-full h-full object-cover`,src:t.url,loading:`lazy`,alt:``}):j(`video`,{class:`absolute inset-0 w-full h-full object-cover`,src:t.url,muted:!0,autoplay:!0,loop:!0,playsinline:!0}):e.type===`custom-image`&&e.url&&!n?j(`img`,{class:`absolute inset-0 w-full h-full object-cover`,src:e.url,loading:`lazy`,alt:``,onError:()=>r(!0)}):j(`div`,{class:`absolute inset-0`,style:Ry})}function By({className:e=``}){let{config:t}=G_(),n=Ly(t.value),r=Iy(t.value);return j(`div`,{class:`relative size-16 shrink-0 rounded-box overflow-hidden bg-base-300 ${e}`,children:j(zy,{variant:n.background,replica:r})})}var Vy=`absolute inset-0 bg-base-100 text-base-content flex flex-col items-center justify-center gap-6 px-6 py-8 text-center overflow-y-auto motion-safe:animate-[tavusFadeUp_280ms_ease-out]`;function Hy({children:e,class:t,role:n,"aria-live":r}){return j(`div`,{class:t?`${Vy} ${t}`:Vy,role:n,"aria-live":r,children:e})}function Uy({title:e,description:t,media:n,children:r,overlay:i}){return j(Hy,{children:[n===void 0?j(By,{}):n,(e||t)&&j(`div`,{class:`flex flex-col items-center gap-3 max-w-sm`,children:[e&&j(`h2`,{class:`text-lg font-medium leading-snug`,children:e}),t&&j(`p`,{class:`text-base text-base-content/60 tracking-wide leading-snug`,children:t})]}),r&&j(`div`,{class:`flex flex-col items-center gap-3`,children:r}),i]})}var Wy={daily_limit:{title:`Agent is at today's limit`,description:`This Agent can take more conversations tomorrow.`},total_limit:{title:`Agent is unavailable`,description:`This Agent isn't available right now. Please check back later.`},busy:{title:`Agent is in another conversation`,description:`Please try again in a moment.`},error:{title:`Couldn't load this Agent`,description:`This Agent couldn't be loaded. Please try again later.`}};function Gy(e,t){let n=t?.[e];return{title:n?.title||Wy[e].title,description:n?.description||Wy[e].description}}var Ky={daily_limit:`clock`,total_limit:`moon`,busy:`users`,error:`error`};function qy({cause:e}){return j(`div`,{class:`flex size-16 shrink-0 items-center justify-center rounded-box bg-base-200 text-base-content/70`,children:j(My,{name:Ky[e],size:`2rem`})})}function Jy({cause:e,canRetry:t,onRetry:n,onCancel:r}){let{config:i}=G_(),a=i.value.customization?.unavailable_screen,o=Gy(e,a),s=a?.cta??[],c=e===`busy`||s.length>0||!!r;return j(Uy,{media:j(qy,{cause:e}),title:o.title,description:o.description,children:c&&j(`div`,{class:`flex flex-wrap items-center justify-center gap-2`,children:[e===`busy`&&j(`button`,{type:`button`,class:`btn btn-neutral rounded-box`,disabled:!t,onClick:n,children:`Try again`}),s.map(e=>j(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,class:`btn btn-outline rounded-box`,children:e.title},e.url)),r&&j(`button`,{type:`button`,class:`btn btn-ghost`,onClick:r,children:`Close`})]})})}function Yy(){let e=ft(i_);return{state:e.flowSignal.value,isStarting:e.isStarting,unavailableCause:e.unavailableCause,canRetry:e.canRetry,start:e.start,join:e.join,cancel:e.cancel,leave:e.leave,restart:e.restart}}var Xy=`Thanks for joining`,Zy=`You can start a new conversation whenever you're ready.`,Qy=`Start a new conversation`;function $y(e){try{let t=new URL(e);return t.protocol===`https:`||t.protocol===`http:`||t.protocol===`mailto:`}catch{return!1}}function eb({text:e,onRestart:t}){let{config:n}=G_(),r=n.value.customization.after_call,i=r.cta.filter(e=>$y(e.url));return j(Uy,{title:r.title||e?.title||Xy,description:r.description||e?.description||Zy,children:[j(`button`,{type:`button`,class:`btn btn-neutral rounded-box`,onClick:t,children:e?.restart||Qy}),i.length>0&&j(`div`,{class:`flex flex-wrap items-center justify-center gap-2`,children:i.map(e=>j(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,class:`btn btn-outline rounded-box`,children:e.title},e.url))})]})}function tb(){let e=ah(),t=Hh(),{isOff:n}=n_(t),{camState:r}=Xg();return{isCamReady:k(()=>r===`granted`,[r]),isCamMuted:n,localSessionId:t,onToggleCamera:A(()=>{e?.setLocalVideo(n)},[e,n])}}function nb(){let e=ah(),t=Hh(),{isOff:n}=Gg(t),{micState:r}=Xg();return{isMicReady:k(()=>r===`granted`,[r]),isMicMuted:n,localSessionId:t,onToggleMicrophone:A(()=>{e?.setLocalAudio(n)},[e,n])}}function rb(){let e=ah(),t=Hh(),{isOff:n}=e_(t),r=!n;return{isScreenSharing:r,localSessionId:t,onToggleScreenshare:A(()=>{r?e?.stopScreenShare():e?.startScreenShare({displayMediaOptions:{audio:!1,selfBrowserSurface:`exclude`,surfaceSwitching:`include`,video:{width:1920,height:1080}}})},[e,r])}}var ib=`select-control-pill relative inline-flex items-center bg-neutral text-neutral-content`,ab=`absolute inset-0 w-full h-full opacity-0 cursor-pointer appearance-none disabled:cursor-not-allowed`,ob=`absolute right-1.5 top-1/2 -translate-y-1/2 pointer-events-none flex items-center`,sb=`absolute left-0 top-0 h-full aspect-square flex items-center justify-center pointer-events-none`,cb=`absolute left-0 top-0 z-10 btn btn-control btn-neutral`;function lb(){return j(`svg`,{style:{width:`var(--chevron-size, 0.75rem)`,height:`var(--chevron-size, 0.75rem)`},viewBox:`0 0 16 16`,fill:`none`,"aria-hidden":`true`,children:j(`path`,{d:`M4 6L8 10L12 6`,stroke:`currentColor`,"stroke-width":`1.5`,"stroke-linecap":`round`,"stroke-linejoin":`round`})})}function ub({value:e,devices:t,disabled:n,onChange:r,label:i}){return j(le,{children:[j(`select`,{class:ab,value:e,onChange:e=>r(e.target.value),disabled:n,"aria-label":i,children:t.map(({device:e})=>j(`option`,{value:e.deviceId,children:e.label},e.deviceId))}),j(`span`,{class:ob,children:j(lb,{})})]})}function db(e){return j(`div`,{class:ib,children:j(ub,{...e})})}function fb({iconName:e,...t}){return j(`div`,{class:ib,children:[j(`span`,{class:sb,"aria-hidden":`true`,children:j(My,{name:e})}),j(ub,{...t})]})}var pb=ya(()=>{let{onToggleMicrophone:e,isMicReady:t,isMicMuted:n}=nb(),{microphones:r,currentMic:i,setMicrophone:a}=Xg();return(r?.length??0)<=1?j(hb,{}):j(`div`,{class:`relative inline-flex items-center`,children:[j(db,{value:i?.device?.deviceId,devices:r||[],disabled:!t,onChange:e=>a(e),label:`Select microphone`}),j(`button`,{type:`button`,onClick:e,disabled:!t,class:cb,"aria-label":n?`Unmute microphone`:`Mute microphone`,"aria-pressed":n,children:j(My,{name:n||!t?`mic-off`:`mic`})})]})}),mb=ya(()=>{let{onToggleCamera:e,isCamReady:t,isCamMuted:n}=tb(),{currentCam:r,cameras:i,setCamera:a}=Xg();return(i?.length??0)<=1?j(gb,{}):j(`div`,{class:`relative inline-flex items-center`,children:[j(db,{value:r?.device?.deviceId,devices:i||[],disabled:!t,onChange:e=>a(e),label:`Select camera`}),j(`button`,{type:`button`,onClick:e,disabled:!t||!r,class:cb,"aria-label":n?`Turn camera on`:`Turn camera off`,"aria-pressed":n,children:j(My,{name:n?`cam-off`:`cam`})})]})}),hb=ya(()=>{let{onToggleMicrophone:e,isMicReady:t,isMicMuted:n}=nb();return j(`button`,{type:`button`,onClick:e,disabled:!t,class:`btn btn-control btn-neutral`,"aria-label":n?`Unmute microphone`:`Mute microphone`,"aria-pressed":n,children:j(My,{name:n||!t?`mic-off`:`mic`})})}),gb=ya(()=>{let{onToggleCamera:e,isCamReady:t,isCamMuted:n}=tb(),{currentCam:r}=Xg();return j(`button`,{type:`button`,onClick:e,disabled:!t||!r,class:`btn btn-control btn-neutral`,"aria-label":n?`Turn camera on`:`Turn camera off`,"aria-pressed":n,children:j(My,{name:n?`cam-off`:`cam`})})});ya(({compact:e=!1}={})=>{let{isMicReady:t}=nb(),{microphones:n,currentMic:r,setMicrophone:i}=Xg();return(n?.length??0)<=1?null:j(fb,{iconName:`mic`,value:r?.device?.deviceId,devices:n,disabled:!t,onChange:e=>i(e),label:`Select microphone`,compact:e})}),ya(({compact:e=!1}={})=>{let{isCamReady:t}=tb(),{currentCam:n,cameras:r,setCamera:i}=Xg();return(r?.length??0)<=1?null:j(fb,{iconName:`cam`,value:n?.device?.deviceId,devices:r,disabled:!t,onChange:e=>i(e),label:`Select camera`,compact:e})});var _b=ya((e={})=>{let{onToggleScreenshare:t,isScreenSharing:n}=rb();return j(`button`,{type:`button`,onClick:t,class:`btn btn-control ${n?`btn-primary`:`btn-neutral`}`,"aria-label":n?`Stop screen share`:`Start screen share`,"aria-pressed":n,children:j(My,{name:`screen-share`})})});function vb(e){let t=ft(I_);if(!t)throw Error(`useConversation must be used within ConversationProvider`);return D(()=>{if(e)return t.__registerSubscriber(e),()=>t.__unregisterSubscriber(e)},[e]),t}var yb=Fe(null);function bb({children:e,defaultEnabled:t=!1}){let[n,r]=E(t),i=A(()=>r(e=>!e),[]),a=k(()=>({isEnabled:n,toggle:i}),[n,i]);return j(yb.Provider,{value:a,children:e})}function xb(){let e=ft(yb);if(!e)throw Error(`ClosedCaptions components must be used within <ClosedCaptionsProvider>`);return e}var Sb=ya(()=>{let{isEnabled:e,toggle:t}=xb();return j(`button`,{type:`button`,onClick:t,"aria-pressed":e,class:`btn btn-control ${e?`btn-primary`:`btn-neutral`}`,"aria-label":e?`Hide captions`:`Show captions`,children:j(My,{name:`captions`,"aria-label":e?`Closed Captions On`:`Closed Captions Off`})})}),Cb=ya(()=>{let{isEnabled:e}=xb(),{captionText:t,captionRole:n}=vb(),r=t.value,i=n.value;return!e||!r?null:j(`div`,{class:`absolute bottom-24 left-1/2 -translate-x-1/2 max-w-[80%] px-4 py-2 rounded-box bg-black/60 text-white`,role:`status`,"aria-live":`polite`,children:j(`div`,{class:`text-sm leading-5 max-h-15 overflow-hidden flex flex-col justify-end text-center`,children:j(`div`,{children:[j(`span`,{class:`text-xs ${i===`replica`?`text-secondary`:`text-primary`} mr-2`,children:i===`replica`?`Replica`:`You`}),r]})})})}),wb=Fe(null);function Tb({children:e,defaultOpen:t=!1}){let[n,r]=E(t),i=A(()=>r(e=>!e),[]),a=A(()=>r(!1),[]),o=k(()=>({isOpen:n,toggle:i,close:a}),[n,i,a]);return j(wb.Provider,{value:o,children:e})}function Eb(){let e=ft(wb);if(!e)throw Error(`Chat components must be used within <ChatProvider>`);return e}var Db=ya((e={})=>{let{isOpen:t,toggle:n}=Eb();return j(`button`,{type:`button`,onClick:n,"aria-pressed":t,"aria-label":t?`Close chat`:`Open chat`,class:`btn btn-control ${t?`btn-primary`:`btn-neutral`}`,children:j(My,{name:`chat`})})}),Ob=ya(({message:e})=>{let t=e.sender===`user`;return j(`li`,{class:`flex flex-col gap-1 ${t?`items-end`:`items-start`}`,children:[j(`span`,{class:`text-xs ${t?`text-primary`:`text-secondary`}`,children:t?`You`:`Replica`}),j(`span`,{class:`px-3 py-2 rounded-field text-sm max-w-[80%] ${t?`bg-primary text-primary-content`:`bg-base-200 text-base-content`}`,children:e.text})]})}),kb=ya(()=>{let{isOpen:e,close:t}=Eb(),{chatMessages:n,sendChat:r,session:i}=vb(),a=i.value?.conversationId??null,o=n.value,[s,c]=E(``),l=O(null);D(()=>{let e=l.current;e&&(e.scrollTop=e.scrollHeight)},[o.length]);let u=A(()=>{let e=s.trim();!e||!a||(r(e),c(``))},[s,r,a]),d=A(e=>{e.key===`Enter`&&!e.shiftKey&&!e.isComposing&&(e.preventDefault(),u())},[u]),f=!!s.trim()&&!!a;return j(`aside`,{class:`absolute top-0 right-0 w-80 h-full bg-base-100 border-l border-base-300 flex flex-col z-30 transition-transform ${e?`translate-x-0`:`translate-x-full`} @max-mobile:w-full`,"aria-hidden":!e,inert:!e,children:[j(`header`,{class:`flex items-center justify-between px-4 py-3 border-b border-base-300`,children:[j(`span`,{class:`font-medium text-base-content`,children:`Chat`}),j(`button`,{type:`button`,class:`btn btn-ghost btn-sm btn-circle`,onClick:t,"aria-label":`Close chat`,children:j(My,{name:`close`,size:20})})]}),j(`ul`,{ref:l,class:`flex-1 overflow-y-auto p-4 flex flex-col gap-3`,role:`log`,"aria-live":`polite`,children:o.length===0?j(`li`,{class:`text-center text-sm opacity-70`,children:a?`Send a message to start the conversation.`:`Connecting…`}):o.map(e=>j(Ob,{message:e},e.id))}),j(`form`,{class:`flex items-end gap-2 p-3 border-t border-base-300`,onSubmit:e=>{e.preventDefault(),u()},children:[j(`textarea`,{class:`textarea textarea-bordered textarea-sm flex-1 resize-none`,value:s,onChange:e=>c(e.target.value),onKeyDown:d,placeholder:a?`Type a message…`:`Connecting…`,disabled:!a,rows:1,"aria-label":`Message`}),j(`button`,{type:`submit`,class:`btn btn-primary btn-sm btn-circle`,disabled:!f,"aria-label":`Send message`,children:j(My,{name:`send`,size:18})})]})]})});function Ab({label:e}){return j(Hy,{role:`status`,"aria-live":`polite`,class:`z-2`,children:[j(By,{}),j(`div`,{class:`flex flex-col items-center gap-3`,children:[j(`span`,{class:`loading loading-spinner loading-md text-base-content`}),j(`span`,{class:`text-base font-medium`,children:e})]})]})}var jb=ya(()=>j(Ab,{label:`Connecting`})),Mb=ya(()=>j(Ab,{label:`Leaving`}));function Nb({active:e,onToggle:t,tooltip:n}){return j(`button`,{type:`button`,onClick:t,class:`btn btn-control ${e?`btn-info`:`btn-ghost`}`,"aria-label":n??(e?`Exit fullscreen`:`Enter fullscreen`),title:n,children:j(My,{name:e?`fullscreen-exit`:`fullscreen`})})}var Pb=ya(({id:e})=>{let t=Wh()===e,n=O(null),r=O(null),i=O(null),a=O(void 0);Wg(e,A(e=>{a.current&&cancelAnimationFrame(a.current),a.current=requestAnimationFrame(()=>{let t=Number(Math.max(.01,e).toFixed(2));n.current&&r.current&&i.current&&(n.current.style.height=`${20+t*40}%`,r.current.style.height=`${20+t*130}%`,i.current.style.height=`${20+t*40}%`)})},[]));let o=`w-[3px] rounded-full bg-base-100 transition-[opacity] ${t?`opacity-100`:`opacity-50`}`;return j(`div`,{class:`flex items-center justify-center w-6 h-6`,children:j(`div`,{class:`flex items-center justify-center gap-[2px] w-full h-full`,children:[j(`div`,{ref:n,class:o,style:{height:`20%`}}),j(`div`,{ref:r,class:o,style:{height:`20%`}}),j(`div`,{ref:i,class:o,style:{height:`20%`}})]})})});function Fb({sessionId:e,className:t=``}){let n=O(null),r=O(void 0);return Wg(e??``,A(t=>{e&&(r.current&&cancelAnimationFrame(r.current),r.current=requestAnimationFrame(()=>{let e=Math.max(0,Math.min(1,t**.6));n.current?.style.setProperty(`--audio-level`,String(e))}))},[e])),j(`div`,{ref:n,class:`relative aspect-square w-full max-w-[min(48cqi,16rem)] mx-auto pointer-events-none ${t}`,style:{"--audio-level":`0`},"aria-hidden":`true`,children:[j(`div`,{class:`absolute inset-0 rounded-full will-change-transform`,style:{background:`conic-gradient(from 0deg, var(--color-primary), var(--color-info, var(--color-primary)), var(--color-secondary, var(--color-primary)), var(--color-primary))`,filter:`blur(28px)`,animation:`tavusOrbSpin 18s linear infinite`,scale:`calc(1 + var(--audio-level, 0) * 0.35)`,opacity:`calc(0.45 + var(--audio-level, 0) * 0.45)`,transition:`scale 120ms ease-out, opacity 120ms ease-out`}}),j(`div`,{class:`absolute inset-[12%] rounded-full will-change-transform`,style:{background:`conic-gradient(from 180deg, color-mix(in oklab, var(--color-primary) 80%, white), transparent 30%, color-mix(in oklab, var(--color-primary) 60%, white) 70%, transparent)`,filter:`blur(14px)`,opacity:.55,mixBlendMode:`screen`,animation:`tavusOrbSpin 26s linear infinite reverse`}}),j(`div`,{class:`absolute inset-[28%] rounded-full`,style:{background:`radial-gradient(circle at 30% 30%, color-mix(in oklab, white 70%, var(--color-primary)), var(--color-primary) 60%, color-mix(in oklab, var(--color-primary) 50%, black))`,boxShadow:`0 0 60px color-mix(in oklab, var(--color-primary) 60%, transparent), inset 0 0 30px color-mix(in oklab, white 40%, transparent)`,scale:`calc(1 + var(--audio-level, 0) * 0.18)`,transition:`scale 100ms ease-out`}}),j(`div`,{class:`absolute inset-[28%] rounded-full`,style:{background:`radial-gradient(circle, color-mix(in oklab, var(--color-primary) 80%, transparent), transparent 70%)`,animation:`tavusOrbPulse 2.6s ease-in-out infinite`}})]})}function Ib({children:e,class:t,className:n,...r}){return j(`div`,{class:`tavus-mesh-bg ${t??n??``}`,...r,children:[j(`div`,{class:`tavus-mesh-blob tavus-mesh-blob-1`}),j(`div`,{class:`tavus-mesh-blob tavus-mesh-blob-2`}),j(`div`,{class:`tavus-mesh-blob tavus-mesh-blob-3`}),j(`div`,{class:`tavus-mesh-blob tavus-mesh-blob-4`}),j(`div`,{class:`tavus-mesh-blob tavus-mesh-blob-5`}),j(`div`,{class:`absolute inset-0 bg-linear-to-t from-black/30 via-black/10 to-transparent pointer-events-none backdrop-blur-xs`}),e]})}var Lb=e=>!!e.user_id?.includes(`tavus-replica`);function Rb(){return Yh({filter:Lb})}function zb(e){let t=Rb()[0],n=n_(t??``),r=jg(),[i,a]=E(!1);return D(()=>{t&&(n.state===`playable`||e)&&a(!0)},[t,n.state,e]),r===`left-meeting`||r===`error`?{phase:`left`}:!i||!t?{phase:`connecting`}:{phase:`ready`,replicaId:t,videoState:n}}var Bb=ya(({isAudioOnly:e})=>{let t=zb(e);return t.phase===`left`?j(Mb,{}):t.phase===`connecting`?j(jb,{}):e?j(Ib,{class:`flex items-center justify-center`,children:[j(Fb,{sessionId:t.replicaId}),j(eg,{sessionId:t.replicaId})]}):j(`div`,{class:`relative w-full h-full`,children:[j(ng,{automirror:!0,sessionId:t.replicaId,type:`video`,fit:`cover`,className:`absolute inset-0 w-full h-full object-cover ${t.videoState.isOff?`hidden`:``}`}),j(eg,{sessionId:t.replicaId})]})}),Vb=ya(({onLeave:e})=>{let{config:t}=G_(),n=t.value.customization.conversation.modality===`audio`;return j(`div`,{class:`@container/pip w-full h-full`,children:j(`div`,{class:`relative w-full h-full overflow-hidden bg-linear-to-br from-base-300 to-base-200 text-base-content`,children:[j(`div`,{class:`relative w-full h-full z-5`,children:j(Bb,{isAudioOnly:n})}),j(`div`,{class:`absolute bottom-4 w-full inset-x-0 z-20 flex justify-center items-center gap-2 @max-mobile:gap-1`,children:[j(hb,{}),!n&&j(gb,{}),j(`button`,{type:`button`,class:`btn btn-control btn-error`,onClick:e,"aria-label":`Leave call`,children:j(My,{name:`leave`,"aria-label":`Leave Call`})})]})]})})}),Hb=ya(({personaSessionId:e,localSessionId:t,isPresenting:n,isScreenSharing:r,isAudioOnly:i,avatarOff:a,videoRef:o})=>{let s=n||r;return j(le,{children:[j(ng,{ref:o,automirror:!0,sessionId:r?t??``:e,type:s?`screenVideo`:`video`,fit:s?`contain`:`cover`,className:`absolute inset-0 w-full h-full transition-all ${s?`object-contain`:`object-cover`} ${!s&&a?`hidden`:``}`}),n&&j(`div`,{class:`absolute bottom-4 right-4 aspect-square w-32 @max-mobile:w-24 rounded-box overflow-hidden bg-black/30 z-10`,children:i||a?j(`div`,{class:`flex w-full h-full items-center justify-center`,children:j(Fb,{sessionId:e})}):j(ng,{automirror:!0,sessionId:e,type:`video`,fit:`cover`,className:`w-full h-full object-cover`})})]})});function K(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:r,constr:o,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);let i=o.prototype,a=Object.keys(i);for(let e=0;e<a.length;e++){let t=a[e];t in n||(n[t]=i[t].bind(n))}}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,"name",{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}function Ub(e){return e&&Object.assign(qb,e),qb}var Wb,Gb,Kb,qb,Jb=a((()=>{Gb=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},Kb=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}},(Wb=globalThis).__zod_globalConfig??(Wb.__zod_globalConfig={}),qb=globalThis.__zod_globalConfig}));function Yb(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function Xb(e,t=`|`){return e.map(e=>fx(e)).join(t)}function Zb(e,t){return typeof t==`bigint`?t.toString():t}function Qb(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}throw Error(`cached value already set`)}}}function $b(e){return e==null}function ex(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function tx(e,t){let n=e/t,r=Math.round(n),i=2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}function nx(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==kx)return r===void 0&&(r=kx,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function rx(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function ix(...e){let t={};for(let n of e)Object.assign(t,Object.getOwnPropertyDescriptors(n));return Object.defineProperties({},t)}function ax(e){return JSON.stringify(e)}function ox(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}function sx(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function cx(e){if(sx(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return!(sx(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}function lx(e){return cx(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function ux(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function dx(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function q(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function fx(e){return typeof e==`bigint`?e.toString()+`n`:typeof e==`string`?`"${e}"`:`${e}`}function px(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}function mx(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);return dx(e,ix(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return rx(this,`shape`,e),e},checks:[]}))}function hx(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);return dx(e,ix(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return rx(this,`shape`,r),r},checks:[]}))}function gx(e,t){if(!cx(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=e._zod.def.shape;for(let e in t)if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return dx(e,ix(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return rx(this,`shape`,n),n}}))}function _x(e,t){if(!cx(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return dx(e,ix(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return rx(this,`shape`,n),n}}))}function vx(e,t){if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);return dx(e,ix(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return rx(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function yx(e,t,n){let r=t._zod.def.checks;if(r&&r.length>0)throw Error(`.partial() cannot be used on object schemas containing refinements`);return dx(t,ix(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return rx(this,`shape`,i),i},checks:[]}))}function bx(e,t,n){return dx(t,ix(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return rx(this,`shape`,i),i}}))}function xx(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Sx(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function Cx(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function wx(e){return typeof e==`string`?e:e?.message}function Tx(e,t,n){let r=e.message?e.message:wx(e.inst?._zod.def?.error?.(e))??wx(t?.error?.(e))??wx(n.customError?.(e))??wx(n.localeError?.(e))??`Invalid input`,{inst:i,continue:a,input:o,...s}=e;return s.path??=[],s.message=r,t?.reportInput&&(s.input=o),s}function Ex(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function Dx(e){let t=typeof e;switch(t){case`number`:return Number.isNaN(e)?`nan`:`number`;case`object`:{if(e===null)return`null`;if(Array.isArray(e))return`array`;let t=e;if(t&&Object.getPrototypeOf(t)!==Object.prototype&&`constructor`in t&&t.constructor)return t.constructor.name}}return t}function Ox(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}var kx,Ax,jx,Mx,Nx,Px=a((()=>{Jb(),kx=Symbol(`evaluating`),Ax=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{},jx=Qb(()=>{if(qb.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}}),Mx=new Set([`string`,`number`,`symbol`]),Nx={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]}}));function Fx(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function Ix(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i];i===e.length-1?(r[n]=r[n]||{_errors:[]},r[n]._errors.push(t(a))):r[n]=r[n]||{_errors:[]},r=r[n],i++}}}};return r(e),n}var Lx,Rx,zx,Bx=a((()=>{Jb(),Px(),Lx=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,Zb,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Rx=K(`$ZodError`,Lx),zx=K(`$ZodError`,Lx,{Parent:Error})})),Vx,Hx,Ux,Wx,Gx,Kx,qx,Jx,Yx,Xx,Zx,Qx,$x,eS,tS=a((()=>{Jb(),Bx(),Px(),Vx=e=>(t,n,r,i)=>{let a=r?{...r,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new Gb;if(o.issues.length){let t=new(i?.Err??e)(o.issues.map(e=>Tx(e,a,Ub())));throw Ax(t,i?.callee),t}return o.value},Hx=e=>async(t,n,r,i)=>{let a=r?{...r,async:!0}:{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new(i?.Err??e)(o.issues.map(e=>Tx(e,a,Ub())));throw Ax(t,i?.callee),t}return o.value},Ux=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new Gb;return a.issues.length?{success:!1,error:new(e??Rx)(a.issues.map(e=>Tx(e,i,Ub())))}:{success:!0,data:a.value}},Wx=Ux(zx),Gx=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>Tx(e,i,Ub())))}:{success:!0,data:a.value}},Kx=Gx(zx),qx=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Vx(e)(t,n,i)},Jx=e=>(t,n,r)=>Vx(e)(t,n,r),Yx=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Hx(e)(t,n,i)},Xx=e=>async(t,n,r)=>Hx(e)(t,n,r),Zx=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Ux(e)(t,n,i)},Qx=e=>(t,n,r)=>Ux(e)(t,n,r),$x=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Gx(e)(t,n,i)},eS=e=>async(t,n,r)=>Gx(e)(t,n,r)}));function nS(){return new RegExp(gS,`u`)}function rS(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function iS(e){return RegExp(`^${rS(e)}$`)}function aS(e){let t=rS({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${TS}T(?:${r})$`)}var oS,sS,cS,lS,uS,dS,fS,pS,mS,hS,gS,_S,vS,yS,bS,xS,SS,CS,wS,TS,ES,DS,OS,kS,AS,jS,MS,NS,PS,FS=a((()=>{oS=/^[cC][0-9a-z]{6,}$/,sS=/^[0-9a-z]+$/,cS=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,lS=/^[0-9a-vA-V]{20}$/,uS=/^[A-Za-z0-9]{27}$/,dS=/^[a-zA-Z0-9_-]{21}$/,fS=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,pS=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,mS=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,hS=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,gS=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,_S=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,vS=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,yS=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,bS=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,xS=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,SS=/^[A-Za-z0-9_-]*$/,CS=/^https?$/,wS=/^\+[1-9]\d{6,14}$/,TS=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`,ES=RegExp(`^${TS}$`),DS=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},OS=/^-?\d+$/,kS=/^-?\d+(?:\.\d+)?$/,AS=/^(?:true|false)$/i,jS=/^null$/i,MS=/^undefined$/i,NS=/^[^A-Z]*$/,PS=/^[^a-z]*$/})),IS,LS,RS,zS,BS,VS,HS,US,WS,GS,KS,qS,JS,YS,XS,ZS,QS,$S=a((()=>{Jb(),FS(),Px(),IS=K(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),LS={number:`number`,bigint:`bigint`,object:`date`},RS=K(`$ZodCheckLessThan`,(e,t)=>{IS.init(e,t);let n=LS[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),zS=K(`$ZodCheckGreaterThan`,(e,t)=>{IS.init(e,t);let n=LS[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),BS=K(`$ZodCheckMultipleOf`,(e,t)=>{IS.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?n.value%t.value===BigInt(0):tx(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),VS=K(`$ZodCheckNumberFormat`,(e,t)=>{IS.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=Nx[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=OS)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),HS=K(`$ZodCheckMaxLength`,(e,t)=>{var n;IS.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!$b(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=Ex(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),US=K(`$ZodCheckMinLength`,(e,t)=>{var n;IS.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!$b(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=Ex(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),WS=K(`$ZodCheckLengthEquals`,(e,t)=>{var n;IS.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!$b(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=Ex(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),GS=K(`$ZodCheckStringFormat`,(e,t)=>{var n,r;IS.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),KS=K(`$ZodCheckRegex`,(e,t)=>{GS.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),qS=K(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=NS,GS.init(e,t)}),JS=K(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=PS,GS.init(e,t)}),YS=K(`$ZodCheckIncludes`,(e,t)=>{IS.init(e,t);let n=ux(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),XS=K(`$ZodCheckStartsWith`,(e,t)=>{IS.init(e,t);let n=RegExp(`^${ux(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),ZS=K(`$ZodCheckEndsWith`,(e,t)=>{IS.init(e,t);let n=RegExp(`.*${ux(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),QS=K(`$ZodCheckOverwrite`,(e,t)=>{IS.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}})})),eC,tC=a((()=>{eC=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
|
|
51
51
|
`).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.args,n=[...(this?.content??[``]).map(e=>` ${e}`)];return new e(...t,n.join(`
|
|
52
|
-
`))}}})),tC,nC=a((()=>{tC={major:4,minor:4,patch:3}}));function rC(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}function iC(e){if(!xS.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return rC(t.padEnd(Math.ceil(t.length/4)*4,`=`))}function aC(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}function oC(e,t,n){e.issues.length&&t.issues.push(...Sx(n,e.issues)),t.value[n]=e.value}function sC(e,t,n,r,i,a){let o=n in r;if(e.issues.length){if(i&&a&&!o)return;t.issues.push(...Sx(n,e.issues))}if(!o&&!i){e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]});return}e.value===void 0?o&&(t.value[n]=void 0):t.value[n]=e.value}function cC(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${n}": expected a Zod schema`);let n=fx(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function lC(e,t,n,r,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type,u=c.optin===`optional`,d=c.optout===`optional`;for(let i in t){if(i===`__proto__`||s.has(i))continue;if(l===`never`){o.push(i);continue}let a=c.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>sC(e,n,i,t,u,d))):sC(a,n,i,t,u,d)}return o.length&&n.issues.push({code:`unrecognized_keys`,keys:o,input:t,inst:a}),e.length?Promise.all(e).then(()=>n):n}function uC(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!bx(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>wx(e,r,Hb())))}),t)}function dC(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(sx(e)&&sx(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=dC(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=dC(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function fC(e,t,n){let r=new Map,i;for(let n of t.issues)if(n.code===`unrecognized_keys`){i??=n;for(let e of n.keys)r.has(e)||r.set(e,{}),r.get(e).l=!0}else e.issues.push(n);for(let t of n.issues)if(t.code===`unrecognized_keys`)for(let e of t.keys)r.has(e)||r.set(e,{}),r.get(e).r=!0;else e.issues.push(t);let a=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(a.length&&i&&e.issues.push({...i,keys:a}),bx(e))return e;let o=dC(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}function pC(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}function mC(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}function hC(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}function gC(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}function _C(e){return e.value=Object.freeze(e.value),e}function vC(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(Dx(e))}}var yC,bC,xC,SC,CC,wC,TC,EC,DC,OC,kC,AC,jC,MC,NC,PC,FC,IC,LC,RC,zC,BC,VC,HC,UC,WC,GC,KC,qC,JC,YC,XC,ZC,QC,$C,ew,tw,nw,rw,iw,aw,ow,sw,cw,lw,uw,dw,fw,pw,mw,hw,gw,_w,vw,yw=a((()=>{QS(),qb(),eC(),eS(),PS(),Nx(),nC(),yC=K(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=tC;let r=[...e._zod.def.checks??[]];e._zod.traits.has(`$ZodCheck`)&&r.unshift(e);for(let t of r)for(let n of t._zod.onattach)n(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(e,t,n)=>{let r=bx(e),i;for(let a of t){if(a._zod.def.when){if(xx(e)||!a._zod.def.when(e))continue}else if(r)continue;let t=e.issues.length,o=a._zod.check(e);if(o instanceof Promise&&n?.async===!1)throw new Wb;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o,e.issues.length!==t&&(r||=bx(e,t))});else{if(e.issues.length===t)continue;r||=bx(e,t)}}return i?i.then(()=>e):e},n=(n,i,a)=>{if(bx(n))return n.aborted=!0,n;let o=t(i,r,a);if(o instanceof Promise){if(a.async===!1)throw new Wb;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(i,a)=>{if(a.skipChecks)return e._zod.parse(i,a);if(a.direction===`backward`){let t=e._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,i,a)):n(t,i,a)}let o=e._zod.parse(i,a);if(o instanceof Promise){if(a.async===!1)throw new Wb;return o.then(e=>t(e,r,a))}return t(o,r,a)}}tx(e,`~standard`,()=>({validate:t=>{try{let n=Ux(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return Gx(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}))}),bC=K(`$ZodString`,(e,t)=>{yC.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??ES(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),xC=K(`$ZodStringFormat`,(e,t)=>{WS.init(e,t),bC.init(e,t)}),SC=K(`$ZodGUID`,(e,t)=>{t.pattern??=fS,xC.init(e,t)}),CC=K(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=pS(e)}else t.pattern??=pS();xC.init(e,t)}),wC=K(`$ZodEmail`,(e,t)=>{t.pattern??=mS,xC.init(e,t)}),TC=K(`$ZodURL`,(e,t)=>{xC.init(e,t),e._zod.check=n=>{try{let r=n.value.trim();if(!t.normalize&&t.protocol?.source===SS.source&&!/^https?:\/\//i.test(r)){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}let i=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(`:`)?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=i.href:n.value=r;return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),EC=K(`$ZodEmoji`,(e,t)=>{t.pattern??=tS(),xC.init(e,t)}),DC=K(`$ZodNanoID`,(e,t)=>{t.pattern??=uS,xC.init(e,t)}),OC=K(`$ZodCUID`,(e,t)=>{t.pattern??=aS,xC.init(e,t)}),kC=K(`$ZodCUID2`,(e,t)=>{t.pattern??=oS,xC.init(e,t)}),AC=K(`$ZodULID`,(e,t)=>{t.pattern??=sS,xC.init(e,t)}),jC=K(`$ZodXID`,(e,t)=>{t.pattern??=cS,xC.init(e,t)}),MC=K(`$ZodKSUID`,(e,t)=>{t.pattern??=lS,xC.init(e,t)}),NC=K(`$ZodISODateTime`,(e,t)=>{t.pattern??=iS(t),xC.init(e,t)}),PC=K(`$ZodISODate`,(e,t)=>{t.pattern??=TS,xC.init(e,t)}),FC=K(`$ZodISOTime`,(e,t)=>{t.pattern??=rS(t),xC.init(e,t)}),IC=K(`$ZodISODuration`,(e,t)=>{t.pattern??=dS,xC.init(e,t)}),LC=K(`$ZodIPv4`,(e,t)=>{t.pattern??=gS,xC.init(e,t),e._zod.bag.format=`ipv4`}),RC=K(`$ZodIPv6`,(e,t)=>{t.pattern??=_S,xC.init(e,t),e._zod.bag.format=`ipv6`,e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}}),zC=K(`$ZodCIDRv4`,(e,t)=>{t.pattern??=vS,xC.init(e,t)}),BC=K(`$ZodCIDRv6`,(e,t)=>{t.pattern??=yS,xC.init(e,t),e._zod.check=n=>{let r=n.value.split(`/`);try{if(r.length!==2)throw Error();let[e,t]=r;if(!t)throw Error();let n=Number(t);if(`${n}`!==t||n<0||n>128)throw Error();new URL(`http://[${e}]`)}catch{n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}}}),VC=K(`$ZodBase64`,(e,t)=>{t.pattern??=bS,xC.init(e,t),e._zod.bag.contentEncoding=`base64`,e._zod.check=n=>{rC(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}}),HC=K(`$ZodBase64URL`,(e,t)=>{t.pattern??=xS,xC.init(e,t),e._zod.bag.contentEncoding=`base64url`,e._zod.check=n=>{iC(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),UC=K(`$ZodE164`,(e,t)=>{t.pattern??=CS,xC.init(e,t)}),WC=K(`$ZodJWT`,(e,t)=>{xC.init(e,t),e._zod.check=n=>{aC(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),GC=K(`$ZodNumber`,(e,t)=>{yC.init(e,t),e._zod.pattern=e._zod.bag.pattern??OS,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:`Infinity`:void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),KC=K(`$ZodNumberFormat`,(e,t)=>{BS.init(e,t),GC.init(e,t)}),qC=K(`$ZodBoolean`,(e,t)=>{yC.init(e,t),e._zod.pattern=kS,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),JC=K(`$ZodUndefined`,(e,t)=>{yC.init(e,t),e._zod.pattern=jS,e._zod.values=new Set([void 0]),e._zod.parse=(t,n)=>{let r=t.value;return r===void 0||t.issues.push({expected:`undefined`,code:`invalid_type`,input:r,inst:e}),t}}),YC=K(`$ZodNull`,(e,t)=>{yC.init(e,t),e._zod.pattern=AS,e._zod.values=new Set([null]),e._zod.parse=(t,n)=>{let r=t.value;return r===null||t.issues.push({expected:`null`,code:`invalid_type`,input:r,inst:e}),t}}),XC=K(`$ZodUnknown`,(e,t)=>{yC.init(e,t),e._zod.parse=e=>e}),ZC=K(`$ZodNever`,(e,t)=>{yC.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)}),QC=K(`$ZodArray`,(e,t)=>{yC.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:`array`,code:`invalid_type`,input:i,inst:e}),n;n.value=Array(i.length);let a=[];for(let e=0;e<i.length;e++){let o=i[e],s=t.element._zod.run({value:o,issues:[]},r);s instanceof Promise?a.push(s.then(t=>oC(t,n,e))):oC(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}}),$C=K(`$ZodObject`,(e,t)=>{if(yC.init(e,t),!Object.getOwnPropertyDescriptor(t,`shape`)?.get){let e=t.shape;Object.defineProperty(t,"shape",{get:()=>{let n={...e};return Object.defineProperty(t,"shape",{value:n}),n}})}let n=Zb(()=>cC(t));tx(e._zod,`propValues`,()=>{let e=t.shape,n={};for(let t in e){let r=e[t]._zod;if(r.values){n[t]??(n[t]=new Set);for(let e of r.values)n[t].add(e)}}return n});let r=ox,i=t.catchall,a;e._zod.parse=(t,o)=>{a??=n.value;let s=t.value;if(!r(s))return t.issues.push({expected:`object`,code:`invalid_type`,input:s,inst:e}),t;t.value={};let c=[],l=a.shape;for(let e of a.keys){let n=l[e],r=n._zod.optin===`optional`,i=n._zod.optout===`optional`,a=n._zod.run({value:s[e],issues:[]},o);a instanceof Promise?c.push(a.then(n=>sC(n,t,e,s,r,i))):sC(a,t,e,s,r,i)}return i?lC(c,s,t,o,n.value,e):c.length?Promise.all(c).then(()=>t):t}}),ew=K(`$ZodObjectJIT`,(e,t)=>{$C.init(e,t);let n=e._zod.parse,r=Zb(()=>cC(t)),i=e=>{let t=new $S([`shape`,`payload`,`ctx`]),n=r.value,i=e=>{let t=ix(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write(`const input = payload.value;`);let a=Object.create(null),o=0;for(let e of n.keys)a[e]=`key_${o++}`;t.write(`const newResult = {};`);for(let r of n.keys){let n=a[r],o=ix(r),s=e[r],c=s?._zod?.optin===`optional`,l=s?._zod?.optout===`optional`;t.write(`const ${n} = ${i(r)};`),c&&l?t.write(`
|
|
52
|
+
`))}}})),nC,rC=a((()=>{nC={major:4,minor:4,patch:3}}));function iC(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}function aC(e){if(!SS.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return iC(t.padEnd(Math.ceil(t.length/4)*4,`=`))}function oC(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}function sC(e,t,n){e.issues.length&&t.issues.push(...Cx(n,e.issues)),t.value[n]=e.value}function cC(e,t,n,r,i,a){let o=n in r;if(e.issues.length){if(i&&a&&!o)return;t.issues.push(...Cx(n,e.issues))}if(!o&&!i){e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]});return}e.value===void 0?o&&(t.value[n]=void 0):t.value[n]=e.value}function lC(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${n}": expected a Zod schema`);let n=px(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function uC(e,t,n,r,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type,u=c.optin===`optional`,d=c.optout===`optional`;for(let i in t){if(i===`__proto__`||s.has(i))continue;if(l===`never`){o.push(i);continue}let a=c.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>cC(e,n,i,t,u,d))):cC(a,n,i,t,u,d)}return o.length&&n.issues.push({code:`unrecognized_keys`,keys:o,input:t,inst:a}),e.length?Promise.all(e).then(()=>n):n}function dC(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!xx(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>Tx(e,r,Ub())))}),t)}function fC(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(cx(e)&&cx(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=fC(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=fC(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function pC(e,t,n){let r=new Map,i;for(let n of t.issues)if(n.code===`unrecognized_keys`){i??=n;for(let e of n.keys)r.has(e)||r.set(e,{}),r.get(e).l=!0}else e.issues.push(n);for(let t of n.issues)if(t.code===`unrecognized_keys`)for(let e of t.keys)r.has(e)||r.set(e,{}),r.get(e).r=!0;else e.issues.push(t);let a=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(a.length&&i&&e.issues.push({...i,keys:a}),xx(e))return e;let o=fC(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}function mC(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}function hC(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}function gC(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}function _C(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}function vC(e){return e.value=Object.freeze(e.value),e}function yC(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(Ox(e))}}var bC,xC,SC,CC,wC,TC,EC,DC,OC,kC,AC,jC,MC,NC,PC,FC,IC,LC,RC,zC,BC,VC,HC,UC,WC,GC,KC,qC,JC,YC,XC,ZC,QC,$C,ew,tw,nw,rw,iw,aw,ow,sw,cw,lw,uw,dw,fw,pw,mw,hw,gw,_w,vw,yw,bw=a((()=>{$S(),Jb(),tC(),tS(),FS(),Px(),rC(),bC=K(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=nC;let r=[...e._zod.def.checks??[]];e._zod.traits.has(`$ZodCheck`)&&r.unshift(e);for(let t of r)for(let n of t._zod.onattach)n(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(e,t,n)=>{let r=xx(e),i;for(let a of t){if(a._zod.def.when){if(Sx(e)||!a._zod.def.when(e))continue}else if(r)continue;let t=e.issues.length,o=a._zod.check(e);if(o instanceof Promise&&n?.async===!1)throw new Gb;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o,e.issues.length!==t&&(r||=xx(e,t))});else{if(e.issues.length===t)continue;r||=xx(e,t)}}return i?i.then(()=>e):e},n=(n,i,a)=>{if(xx(n))return n.aborted=!0,n;let o=t(i,r,a);if(o instanceof Promise){if(a.async===!1)throw new Gb;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(i,a)=>{if(a.skipChecks)return e._zod.parse(i,a);if(a.direction===`backward`){let t=e._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,i,a)):n(t,i,a)}let o=e._zod.parse(i,a);if(o instanceof Promise){if(a.async===!1)throw new Gb;return o.then(e=>t(e,r,a))}return t(o,r,a)}}nx(e,`~standard`,()=>({validate:t=>{try{let n=Wx(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return Kx(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}))}),xC=K(`$ZodString`,(e,t)=>{bC.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??DS(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),SC=K(`$ZodStringFormat`,(e,t)=>{GS.init(e,t),xC.init(e,t)}),CC=K(`$ZodGUID`,(e,t)=>{t.pattern??=pS,SC.init(e,t)}),wC=K(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=mS(e)}else t.pattern??=mS();SC.init(e,t)}),TC=K(`$ZodEmail`,(e,t)=>{t.pattern??=hS,SC.init(e,t)}),EC=K(`$ZodURL`,(e,t)=>{SC.init(e,t),e._zod.check=n=>{try{let r=n.value.trim();if(!t.normalize&&t.protocol?.source===CS.source&&!/^https?:\/\//i.test(r)){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}let i=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(`:`)?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=i.href:n.value=r;return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),DC=K(`$ZodEmoji`,(e,t)=>{t.pattern??=nS(),SC.init(e,t)}),OC=K(`$ZodNanoID`,(e,t)=>{t.pattern??=dS,SC.init(e,t)}),kC=K(`$ZodCUID`,(e,t)=>{t.pattern??=oS,SC.init(e,t)}),AC=K(`$ZodCUID2`,(e,t)=>{t.pattern??=sS,SC.init(e,t)}),jC=K(`$ZodULID`,(e,t)=>{t.pattern??=cS,SC.init(e,t)}),MC=K(`$ZodXID`,(e,t)=>{t.pattern??=lS,SC.init(e,t)}),NC=K(`$ZodKSUID`,(e,t)=>{t.pattern??=uS,SC.init(e,t)}),PC=K(`$ZodISODateTime`,(e,t)=>{t.pattern??=aS(t),SC.init(e,t)}),FC=K(`$ZodISODate`,(e,t)=>{t.pattern??=ES,SC.init(e,t)}),IC=K(`$ZodISOTime`,(e,t)=>{t.pattern??=iS(t),SC.init(e,t)}),LC=K(`$ZodISODuration`,(e,t)=>{t.pattern??=fS,SC.init(e,t)}),RC=K(`$ZodIPv4`,(e,t)=>{t.pattern??=_S,SC.init(e,t),e._zod.bag.format=`ipv4`}),zC=K(`$ZodIPv6`,(e,t)=>{t.pattern??=vS,SC.init(e,t),e._zod.bag.format=`ipv6`,e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}}),BC=K(`$ZodCIDRv4`,(e,t)=>{t.pattern??=yS,SC.init(e,t)}),VC=K(`$ZodCIDRv6`,(e,t)=>{t.pattern??=bS,SC.init(e,t),e._zod.check=n=>{let r=n.value.split(`/`);try{if(r.length!==2)throw Error();let[e,t]=r;if(!t)throw Error();let n=Number(t);if(`${n}`!==t||n<0||n>128)throw Error();new URL(`http://[${e}]`)}catch{n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}}}),HC=K(`$ZodBase64`,(e,t)=>{t.pattern??=xS,SC.init(e,t),e._zod.bag.contentEncoding=`base64`,e._zod.check=n=>{iC(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}}),UC=K(`$ZodBase64URL`,(e,t)=>{t.pattern??=SS,SC.init(e,t),e._zod.bag.contentEncoding=`base64url`,e._zod.check=n=>{aC(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),WC=K(`$ZodE164`,(e,t)=>{t.pattern??=wS,SC.init(e,t)}),GC=K(`$ZodJWT`,(e,t)=>{SC.init(e,t),e._zod.check=n=>{oC(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),KC=K(`$ZodNumber`,(e,t)=>{bC.init(e,t),e._zod.pattern=e._zod.bag.pattern??kS,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:`Infinity`:void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),qC=K(`$ZodNumberFormat`,(e,t)=>{VS.init(e,t),KC.init(e,t)}),JC=K(`$ZodBoolean`,(e,t)=>{bC.init(e,t),e._zod.pattern=AS,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),YC=K(`$ZodUndefined`,(e,t)=>{bC.init(e,t),e._zod.pattern=MS,e._zod.values=new Set([void 0]),e._zod.parse=(t,n)=>{let r=t.value;return r===void 0||t.issues.push({expected:`undefined`,code:`invalid_type`,input:r,inst:e}),t}}),XC=K(`$ZodNull`,(e,t)=>{bC.init(e,t),e._zod.pattern=jS,e._zod.values=new Set([null]),e._zod.parse=(t,n)=>{let r=t.value;return r===null||t.issues.push({expected:`null`,code:`invalid_type`,input:r,inst:e}),t}}),ZC=K(`$ZodUnknown`,(e,t)=>{bC.init(e,t),e._zod.parse=e=>e}),QC=K(`$ZodNever`,(e,t)=>{bC.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)}),$C=K(`$ZodArray`,(e,t)=>{bC.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:`array`,code:`invalid_type`,input:i,inst:e}),n;n.value=Array(i.length);let a=[];for(let e=0;e<i.length;e++){let o=i[e],s=t.element._zod.run({value:o,issues:[]},r);s instanceof Promise?a.push(s.then(t=>sC(t,n,e))):sC(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}}),ew=K(`$ZodObject`,(e,t)=>{if(bC.init(e,t),!Object.getOwnPropertyDescriptor(t,`shape`)?.get){let e=t.shape;Object.defineProperty(t,"shape",{get:()=>{let n={...e};return Object.defineProperty(t,"shape",{value:n}),n}})}let n=Qb(()=>lC(t));nx(e._zod,`propValues`,()=>{let e=t.shape,n={};for(let t in e){let r=e[t]._zod;if(r.values){n[t]??(n[t]=new Set);for(let e of r.values)n[t].add(e)}}return n});let r=sx,i=t.catchall,a;e._zod.parse=(t,o)=>{a??=n.value;let s=t.value;if(!r(s))return t.issues.push({expected:`object`,code:`invalid_type`,input:s,inst:e}),t;t.value={};let c=[],l=a.shape;for(let e of a.keys){let n=l[e],r=n._zod.optin===`optional`,i=n._zod.optout===`optional`,a=n._zod.run({value:s[e],issues:[]},o);a instanceof Promise?c.push(a.then(n=>cC(n,t,e,s,r,i))):cC(a,t,e,s,r,i)}return i?uC(c,s,t,o,n.value,e):c.length?Promise.all(c).then(()=>t):t}}),tw=K(`$ZodObjectJIT`,(e,t)=>{ew.init(e,t);let n=e._zod.parse,r=Qb(()=>lC(t)),i=e=>{let t=new eC([`shape`,`payload`,`ctx`]),n=r.value,i=e=>{let t=ax(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write(`const input = payload.value;`);let a=Object.create(null),o=0;for(let e of n.keys)a[e]=`key_${o++}`;t.write(`const newResult = {};`);for(let r of n.keys){let n=a[r],o=ax(r),s=e[r],c=s?._zod?.optin===`optional`,l=s?._zod?.optout===`optional`;t.write(`const ${n} = ${i(r)};`),c&&l?t.write(`
|
|
53
53
|
if (${n}.issues.length) {
|
|
54
54
|
if (${o} in input) {
|
|
55
55
|
payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
|
|
@@ -108,15 +108,15 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
-
`)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=ox,s=!Kb.jitless,c=s&&Ax.value,l=t.catchall,u;e._zod.parse=(d,f)=>{u??=r.value;let p=d.value;return o(p)?s&&c&&f?.async===!1&&f.jitless!==!0?(a||=i(t.shape),d=a(d,f),l?lC([],p,d,f,u,e):d):n(d,f):(d.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),d)}}),tw=K(`$ZodUnion`,(e,t)=>{yC.init(e,t),tx(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),tx(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),tx(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),tx(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>$b(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>uC(t,r,e,i)):uC(o,r,e,i)}}),nw=K(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,tw.init(e,t);let n=e._zod.parse;tx(e._zod,`propValues`,()=>{let e={};for(let n of t.options){let r=n._zod.propValues;if(!r||Object.keys(r).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(let[t,n]of Object.entries(r)){e[t]||(e[t]=new Set);for(let r of n)e[t].add(r)}}return e});let r=Zb(()=>{let e=t.options,n=new Map;for(let r of e){let e=r._zod.propValues?.[t.discriminator];if(!e||e.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(let t of e){if(n.has(t))throw Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,r)}}return n});e._zod.parse=(i,a)=>{let o=i.value;if(!ox(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=r.value.get(o?.[t.discriminator]);return s?s._zod.run(i,a):t.unionFallback||a.direction===`backward`?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,options:Array.from(r.value.keys()),input:o,path:[t.discriminator],inst:e}),i)}}),rw=K(`$ZodIntersection`,(e,t)=>{yC.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>fC(e,t,n)):fC(e,i,a)}}),iw=K(`$ZodRecord`,(e,t)=>{yC.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!sx(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[],o=t.keyType._zod.values;if(o){n.value={};let s=new Set;for(let c of o)if(typeof c==`string`||typeof c==`number`||typeof c==`symbol`){s.add(typeof c==`number`?c.toString():c);let o=t.keyType._zod.run({value:c,issues:[]},r);if(o instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(o.issues.length){n.issues.push({code:`invalid_key`,origin:`record`,issues:o.issues.map(e=>wx(e,r,Hb())),input:c,path:[c],inst:e});continue}let l=o.value,u=t.valueType._zod.run({value:i[c],issues:[]},r);u instanceof Promise?a.push(u.then(e=>{e.issues.length&&n.issues.push(...Sx(c,e.issues)),n.value[l]=e.value})):(u.issues.length&&n.issues.push(...Sx(c,u.issues)),n.value[l]=u.value)}let c;for(let e in i)s.has(e)||(c??=[],c.push(e));c&&c.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:c})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o===`__proto__`||!Object.prototype.propertyIsEnumerable.call(i,o))continue;let s=t.keyType._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof o==`string`&&OS.test(o)&&s.issues.length){let e=t.keyType._zod.run({value:Number(o),issues:[]},r);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(s=e)}if(s.issues.length){t.mode===`loose`?n.value[o]=i[o]:n.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>wx(e,r,Hb())),input:o,path:[o],inst:e});continue}let c=t.valueType._zod.run({value:i[o],issues:[]},r);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&n.issues.push(...Sx(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...Sx(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),aw=K(`$ZodEnum`,(e,t)=>{yC.init(e,t);let n=Jb(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>jx.has(typeof e)).map(e=>typeof e==`string`?lx(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),ow=K(`$ZodLiteral`,(e,t)=>{if(yC.init(e,t),t.values.length===0)throw Error(`Cannot create literal schema with no valid values`);let n=new Set(t.values);e._zod.values=n,e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?lx(e):e?lx(e.toString()):String(e)).join(`|`)})$`),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),sw=K(`$ZodTransform`,(e,t)=>{yC.init(e,t),e._zod.optin=`optional`,e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Gb(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n.fallback=!0,n));if(i instanceof Promise)throw new Wb;return n.value=i,n.fallback=!0,n}}),cw=K(`$ZodOptional`,(e,t)=>{yC.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,tx(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),tx(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${$b(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=e.value,i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(e=>pC(e,r)):pC(i,r)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),lw=K(`$ZodExactOptional`,(e,t)=>{cw.init(e,t),tx(e._zod,`values`,()=>t.innerType._zod.values),tx(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),uw=K(`$ZodNullable`,(e,t)=>{yC.init(e,t),tx(e._zod,`optin`,()=>t.innerType._zod.optin),tx(e._zod,`optout`,()=>t.innerType._zod.optout),tx(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${$b(e.source)}|null)$`):void 0}),tx(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),dw=K(`$ZodDefault`,(e,t)=>{yC.init(e,t),e._zod.optin=`optional`,tx(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>mC(e,t)):mC(r,t)}}),fw=K(`$ZodPrefault`,(e,t)=>{yC.init(e,t),e._zod.optin=`optional`,tx(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),pw=K(`$ZodNonOptional`,(e,t)=>{yC.init(e,t),tx(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>hC(t,e)):hC(i,e)}}),mw=K(`$ZodCatch`,(e,t)=>{yC.init(e,t),e._zod.optin=`optional`,tx(e._zod,`optout`,()=>t.innerType._zod.optout),tx(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>wx(e,n,Hb()))},input:e.value}),e.issues=[],e.fallback=!0),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>wx(e,n,Hb()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),hw=K(`$ZodPipe`,(e,t)=>{yC.init(e,t),tx(e._zod,`values`,()=>t.in._zod.values),tx(e._zod,`optin`,()=>t.in._zod.optin),tx(e._zod,`optout`,()=>t.out._zod.optout),tx(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>gC(e,t.in,n)):gC(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>gC(e,t.out,n)):gC(r,t.out,n)}}),gw=K(`$ZodPreprocess`,(e,t)=>{hw.init(e,t)}),_w=K(`$ZodReadonly`,(e,t)=>{yC.init(e,t),tx(e._zod,`propValues`,()=>t.innerType._zod.propValues),tx(e._zod,`values`,()=>t.innerType._zod.values),tx(e._zod,`optin`,()=>t.innerType?._zod?.optin),tx(e._zod,`optout`,()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(_C):_C(r)}}),vw=K(`$ZodCustom`,(e,t)=>{FS.init(e,t),yC.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>vC(t,n,r,e));vC(i,n,r,e)}})}));function bw(){return{localeError:xw()}}var xw,Sw=a((()=>{Nx(),xw=()=>{let e={string:{unit:`characters`,verb:`to have`},file:{unit:`bytes`,verb:`to have`},array:{unit:`items`,verb:`to have`},set:{unit:`items`,verb:`to have`},map:{unit:`entries`,verb:`to have`}};function t(t){return e[t]??null}let n={regex:`input`,email:`email address`,url:`URL`,emoji:`emoji`,uuid:`UUID`,uuidv4:`UUIDv4`,uuidv6:`UUIDv6`,nanoid:`nanoid`,guid:`GUID`,cuid:`cuid`,cuid2:`cuid2`,ulid:`ULID`,xid:`XID`,ksuid:`KSUID`,datetime:`ISO datetime`,date:`ISO date`,time:`ISO time`,duration:`ISO duration`,ipv4:`IPv4 address`,ipv6:`IPv6 address`,mac:`MAC address`,cidrv4:`IPv4 range`,cidrv6:`IPv6 range`,base64:`base64-encoded string`,base64url:`base64url-encoded string`,json_string:`JSON string`,e164:`E.164 number`,jwt:`JWT`,template_literal:`input`},r={nan:`NaN`};return e=>{switch(e.code){case`invalid_type`:{let t=r[e.expected]??e.expected,n=Ex(e.input);return`Invalid input: expected ${t}, received ${r[n]??n}`}case`invalid_value`:return e.values.length===1?`Invalid input: expected ${dx(e.values[0])}`:`Invalid option: expected one of ${Yb(e.values,`|`)}`;case`too_big`:{let n=e.inclusive?`<=`:`<`,r=t(e.origin);return r?`Too big: expected ${e.origin??`value`} to have ${n}${e.maximum.toString()} ${r.unit??`elements`}`:`Too big: expected ${e.origin??`value`} to be ${n}${e.maximum.toString()}`}case`too_small`:{let n=e.inclusive?`>=`:`>`,r=t(e.origin);return r?`Too small: expected ${e.origin} to have ${n}${e.minimum.toString()} ${r.unit}`:`Too small: expected ${e.origin} to be ${n}${e.minimum.toString()}`}case`invalid_format`:{let t=e;return t.format===`starts_with`?`Invalid string: must start with "${t.prefix}"`:t.format===`ends_with`?`Invalid string: must end with "${t.suffix}"`:t.format===`includes`?`Invalid string: must include "${t.includes}"`:t.format===`regex`?`Invalid string: must match pattern ${t.pattern}`:`Invalid ${n[t.format]??e.format}`}case`not_multiple_of`:return`Invalid number: must be a multiple of ${e.divisor}`;case`unrecognized_keys`:return`Unrecognized key${e.keys.length>1?`s`:``}: ${Yb(e.keys,`, `)}`;case`invalid_key`:return`Invalid key in ${e.origin}`;case`invalid_union`:return e.options&&Array.isArray(e.options)&&e.options.length>0?`Invalid discriminator value. Expected ${e.options.map(e=>`'${e}'`).join(` | `)}`:`Invalid input`;case`invalid_element`:return`Invalid value in ${e.origin}`;default:return`Invalid input`}}}}));function Cw(){return new Tw}var ww,Tw,Ew,Dw=a((()=>{Tw=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}},(ww=globalThis).__zod_globalRegistry??(ww.__zod_globalRegistry=Cw()),Ew=globalThis.__zod_globalRegistry}));function Ow(e,t){return new e({type:`string`,...q(t)})}function kw(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...q(t)})}function Aw(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...q(t)})}function jw(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...q(t)})}function Mw(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...q(t)})}function Nw(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...q(t)})}function Pw(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...q(t)})}function Fw(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...q(t)})}function Iw(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...q(t)})}function Lw(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...q(t)})}function Rw(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...q(t)})}function zw(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...q(t)})}function Bw(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...q(t)})}function Vw(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...q(t)})}function Hw(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...q(t)})}function Uw(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...q(t)})}function Ww(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...q(t)})}function Gw(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...q(t)})}function Kw(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...q(t)})}function qw(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...q(t)})}function Jw(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...q(t)})}function Yw(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...q(t)})}function Xw(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...q(t)})}function Zw(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...q(t)})}function Qw(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...q(t)})}function $w(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...q(t)})}function eT(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...q(t)})}function tT(e,t){return new e({type:`number`,checks:[],...q(t)})}function nT(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...q(t)})}function rT(e,t){return new e({type:`boolean`,...q(t)})}function iT(e,t){return new e({type:`undefined`,...q(t)})}function aT(e,t){return new e({type:`null`,...q(t)})}function oT(e){return new e({type:`unknown`})}function sT(e,t){return new e({type:`never`,...q(t)})}function cT(e,t){return new LS({check:`less_than`,...q(t),value:e,inclusive:!1})}function lT(e,t){return new LS({check:`less_than`,...q(t),value:e,inclusive:!0})}function uT(e,t){return new RS({check:`greater_than`,...q(t),value:e,inclusive:!1})}function dT(e,t){return new RS({check:`greater_than`,...q(t),value:e,inclusive:!0})}function fT(e,t){return new zS({check:`multiple_of`,...q(t),value:e})}function pT(e,t){return new VS({check:`max_length`,...q(t),maximum:e})}function mT(e,t){return new HS({check:`min_length`,...q(t),minimum:e})}function hT(e,t){return new US({check:`length_equals`,...q(t),length:e})}function gT(e,t){return new GS({check:`string_format`,format:`regex`,...q(t),pattern:e})}function _T(e){return new KS({check:`string_format`,format:`lowercase`,...q(e)})}function vT(e){return new qS({check:`string_format`,format:`uppercase`,...q(e)})}function yT(e,t){return new JS({check:`string_format`,format:`includes`,...q(t),includes:e})}function bT(e,t){return new YS({check:`string_format`,format:`starts_with`,...q(t),prefix:e})}function xT(e,t){return new XS({check:`string_format`,format:`ends_with`,...q(t),suffix:e})}function ST(e){return new ZS({check:`overwrite`,tx:e})}function CT(e){return ST(t=>t.normalize(e))}function wT(){return ST(e=>e.trim())}function TT(){return ST(e=>e.toLowerCase())}function ET(){return ST(e=>e.toUpperCase())}function DT(){return ST(e=>ax(e))}function OT(e,t,n){return new e({type:`array`,element:t,...q(n)})}function kT(e,t,n){let r=q(n);return r.abort??=!0,new e({type:`custom`,check:`custom`,fn:t,...r})}function AT(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...q(n)})}function jT(e,t){let n=MT(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(Dx(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=t.value,r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(Dx(r))}},e(t.value,t)),t);return n}function MT(e,t){let n=new FS({check:`custom`,...q(t)});return n._zod.check=e,n}var NT=a((()=>{QS(),Nx()}));function PT(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??Ew,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,external:e?.external??void 0}}function FT(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,FT(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io===`input`&&RT(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function IT(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${a}`}}if(t[1]===n)return{ref:`#`};let i=`#/${r}/`,a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+a}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
|
|
111
|
+
`)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=sx,s=!qb.jitless,c=s&&jx.value,l=t.catchall,u;e._zod.parse=(d,f)=>{u??=r.value;let p=d.value;return o(p)?s&&c&&f?.async===!1&&f.jitless!==!0?(a||=i(t.shape),d=a(d,f),l?uC([],p,d,f,u,e):d):n(d,f):(d.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),d)}}),nw=K(`$ZodUnion`,(e,t)=>{bC.init(e,t),nx(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),nx(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),nx(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),nx(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>ex(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>dC(t,r,e,i)):dC(o,r,e,i)}}),rw=K(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,nw.init(e,t);let n=e._zod.parse;nx(e._zod,`propValues`,()=>{let e={};for(let n of t.options){let r=n._zod.propValues;if(!r||Object.keys(r).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(let[t,n]of Object.entries(r)){e[t]||(e[t]=new Set);for(let r of n)e[t].add(r)}}return e});let r=Qb(()=>{let e=t.options,n=new Map;for(let r of e){let e=r._zod.propValues?.[t.discriminator];if(!e||e.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(let t of e){if(n.has(t))throw Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,r)}}return n});e._zod.parse=(i,a)=>{let o=i.value;if(!sx(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=r.value.get(o?.[t.discriminator]);return s?s._zod.run(i,a):t.unionFallback||a.direction===`backward`?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,options:Array.from(r.value.keys()),input:o,path:[t.discriminator],inst:e}),i)}}),iw=K(`$ZodIntersection`,(e,t)=>{bC.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>pC(e,t,n)):pC(e,i,a)}}),aw=K(`$ZodRecord`,(e,t)=>{bC.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!cx(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[],o=t.keyType._zod.values;if(o){n.value={};let s=new Set;for(let c of o)if(typeof c==`string`||typeof c==`number`||typeof c==`symbol`){s.add(typeof c==`number`?c.toString():c);let o=t.keyType._zod.run({value:c,issues:[]},r);if(o instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(o.issues.length){n.issues.push({code:`invalid_key`,origin:`record`,issues:o.issues.map(e=>Tx(e,r,Ub())),input:c,path:[c],inst:e});continue}let l=o.value,u=t.valueType._zod.run({value:i[c],issues:[]},r);u instanceof Promise?a.push(u.then(e=>{e.issues.length&&n.issues.push(...Cx(c,e.issues)),n.value[l]=e.value})):(u.issues.length&&n.issues.push(...Cx(c,u.issues)),n.value[l]=u.value)}let c;for(let e in i)s.has(e)||(c??=[],c.push(e));c&&c.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:c})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o===`__proto__`||!Object.prototype.propertyIsEnumerable.call(i,o))continue;let s=t.keyType._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof o==`string`&&kS.test(o)&&s.issues.length){let e=t.keyType._zod.run({value:Number(o),issues:[]},r);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(s=e)}if(s.issues.length){t.mode===`loose`?n.value[o]=i[o]:n.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>Tx(e,r,Ub())),input:o,path:[o],inst:e});continue}let c=t.valueType._zod.run({value:i[o],issues:[]},r);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&n.issues.push(...Cx(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...Cx(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),ow=K(`$ZodEnum`,(e,t)=>{bC.init(e,t);let n=Yb(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>Mx.has(typeof e)).map(e=>typeof e==`string`?ux(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),sw=K(`$ZodLiteral`,(e,t)=>{if(bC.init(e,t),t.values.length===0)throw Error(`Cannot create literal schema with no valid values`);let n=new Set(t.values);e._zod.values=n,e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?ux(e):e?ux(e.toString()):String(e)).join(`|`)})$`),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),cw=K(`$ZodTransform`,(e,t)=>{bC.init(e,t),e._zod.optin=`optional`,e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Kb(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n.fallback=!0,n));if(i instanceof Promise)throw new Gb;return n.value=i,n.fallback=!0,n}}),lw=K(`$ZodOptional`,(e,t)=>{bC.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,nx(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),nx(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${ex(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=e.value,i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(e=>mC(e,r)):mC(i,r)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),uw=K(`$ZodExactOptional`,(e,t)=>{lw.init(e,t),nx(e._zod,`values`,()=>t.innerType._zod.values),nx(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),dw=K(`$ZodNullable`,(e,t)=>{bC.init(e,t),nx(e._zod,`optin`,()=>t.innerType._zod.optin),nx(e._zod,`optout`,()=>t.innerType._zod.optout),nx(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${ex(e.source)}|null)$`):void 0}),nx(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),fw=K(`$ZodDefault`,(e,t)=>{bC.init(e,t),e._zod.optin=`optional`,nx(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>hC(e,t)):hC(r,t)}}),pw=K(`$ZodPrefault`,(e,t)=>{bC.init(e,t),e._zod.optin=`optional`,nx(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),mw=K(`$ZodNonOptional`,(e,t)=>{bC.init(e,t),nx(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>gC(t,e)):gC(i,e)}}),hw=K(`$ZodCatch`,(e,t)=>{bC.init(e,t),e._zod.optin=`optional`,nx(e._zod,`optout`,()=>t.innerType._zod.optout),nx(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>Tx(e,n,Ub()))},input:e.value}),e.issues=[],e.fallback=!0),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>Tx(e,n,Ub()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),gw=K(`$ZodPipe`,(e,t)=>{bC.init(e,t),nx(e._zod,`values`,()=>t.in._zod.values),nx(e._zod,`optin`,()=>t.in._zod.optin),nx(e._zod,`optout`,()=>t.out._zod.optout),nx(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>_C(e,t.in,n)):_C(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>_C(e,t.out,n)):_C(r,t.out,n)}}),_w=K(`$ZodPreprocess`,(e,t)=>{gw.init(e,t)}),vw=K(`$ZodReadonly`,(e,t)=>{bC.init(e,t),nx(e._zod,`propValues`,()=>t.innerType._zod.propValues),nx(e._zod,`values`,()=>t.innerType._zod.values),nx(e._zod,`optin`,()=>t.innerType?._zod?.optin),nx(e._zod,`optout`,()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(vC):vC(r)}}),yw=K(`$ZodCustom`,(e,t)=>{IS.init(e,t),bC.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>yC(t,n,r,e));yC(i,n,r,e)}})}));function xw(){return{localeError:Sw()}}var Sw,Cw=a((()=>{Px(),Sw=()=>{let e={string:{unit:`characters`,verb:`to have`},file:{unit:`bytes`,verb:`to have`},array:{unit:`items`,verb:`to have`},set:{unit:`items`,verb:`to have`},map:{unit:`entries`,verb:`to have`}};function t(t){return e[t]??null}let n={regex:`input`,email:`email address`,url:`URL`,emoji:`emoji`,uuid:`UUID`,uuidv4:`UUIDv4`,uuidv6:`UUIDv6`,nanoid:`nanoid`,guid:`GUID`,cuid:`cuid`,cuid2:`cuid2`,ulid:`ULID`,xid:`XID`,ksuid:`KSUID`,datetime:`ISO datetime`,date:`ISO date`,time:`ISO time`,duration:`ISO duration`,ipv4:`IPv4 address`,ipv6:`IPv6 address`,mac:`MAC address`,cidrv4:`IPv4 range`,cidrv6:`IPv6 range`,base64:`base64-encoded string`,base64url:`base64url-encoded string`,json_string:`JSON string`,e164:`E.164 number`,jwt:`JWT`,template_literal:`input`},r={nan:`NaN`};return e=>{switch(e.code){case`invalid_type`:{let t=r[e.expected]??e.expected,n=Dx(e.input);return`Invalid input: expected ${t}, received ${r[n]??n}`}case`invalid_value`:return e.values.length===1?`Invalid input: expected ${fx(e.values[0])}`:`Invalid option: expected one of ${Xb(e.values,`|`)}`;case`too_big`:{let n=e.inclusive?`<=`:`<`,r=t(e.origin);return r?`Too big: expected ${e.origin??`value`} to have ${n}${e.maximum.toString()} ${r.unit??`elements`}`:`Too big: expected ${e.origin??`value`} to be ${n}${e.maximum.toString()}`}case`too_small`:{let n=e.inclusive?`>=`:`>`,r=t(e.origin);return r?`Too small: expected ${e.origin} to have ${n}${e.minimum.toString()} ${r.unit}`:`Too small: expected ${e.origin} to be ${n}${e.minimum.toString()}`}case`invalid_format`:{let t=e;return t.format===`starts_with`?`Invalid string: must start with "${t.prefix}"`:t.format===`ends_with`?`Invalid string: must end with "${t.suffix}"`:t.format===`includes`?`Invalid string: must include "${t.includes}"`:t.format===`regex`?`Invalid string: must match pattern ${t.pattern}`:`Invalid ${n[t.format]??e.format}`}case`not_multiple_of`:return`Invalid number: must be a multiple of ${e.divisor}`;case`unrecognized_keys`:return`Unrecognized key${e.keys.length>1?`s`:``}: ${Xb(e.keys,`, `)}`;case`invalid_key`:return`Invalid key in ${e.origin}`;case`invalid_union`:return e.options&&Array.isArray(e.options)&&e.options.length>0?`Invalid discriminator value. Expected ${e.options.map(e=>`'${e}'`).join(` | `)}`:`Invalid input`;case`invalid_element`:return`Invalid value in ${e.origin}`;default:return`Invalid input`}}}}));function ww(){return new Ew}var Tw,Ew,Dw,Ow=a((()=>{Ew=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}},(Tw=globalThis).__zod_globalRegistry??(Tw.__zod_globalRegistry=ww()),Dw=globalThis.__zod_globalRegistry}));function kw(e,t){return new e({type:`string`,...q(t)})}function Aw(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...q(t)})}function jw(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...q(t)})}function Mw(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...q(t)})}function Nw(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...q(t)})}function Pw(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...q(t)})}function Fw(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...q(t)})}function Iw(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...q(t)})}function Lw(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...q(t)})}function Rw(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...q(t)})}function zw(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...q(t)})}function Bw(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...q(t)})}function Vw(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...q(t)})}function Hw(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...q(t)})}function Uw(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...q(t)})}function Ww(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...q(t)})}function Gw(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...q(t)})}function Kw(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...q(t)})}function qw(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...q(t)})}function Jw(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...q(t)})}function Yw(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...q(t)})}function Xw(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...q(t)})}function Zw(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...q(t)})}function Qw(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...q(t)})}function $w(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...q(t)})}function eT(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...q(t)})}function tT(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...q(t)})}function nT(e,t){return new e({type:`number`,checks:[],...q(t)})}function rT(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...q(t)})}function iT(e,t){return new e({type:`boolean`,...q(t)})}function aT(e,t){return new e({type:`undefined`,...q(t)})}function oT(e,t){return new e({type:`null`,...q(t)})}function sT(e){return new e({type:`unknown`})}function cT(e,t){return new e({type:`never`,...q(t)})}function lT(e,t){return new RS({check:`less_than`,...q(t),value:e,inclusive:!1})}function uT(e,t){return new RS({check:`less_than`,...q(t),value:e,inclusive:!0})}function dT(e,t){return new zS({check:`greater_than`,...q(t),value:e,inclusive:!1})}function fT(e,t){return new zS({check:`greater_than`,...q(t),value:e,inclusive:!0})}function pT(e,t){return new BS({check:`multiple_of`,...q(t),value:e})}function mT(e,t){return new HS({check:`max_length`,...q(t),maximum:e})}function hT(e,t){return new US({check:`min_length`,...q(t),minimum:e})}function gT(e,t){return new WS({check:`length_equals`,...q(t),length:e})}function _T(e,t){return new KS({check:`string_format`,format:`regex`,...q(t),pattern:e})}function vT(e){return new qS({check:`string_format`,format:`lowercase`,...q(e)})}function yT(e){return new JS({check:`string_format`,format:`uppercase`,...q(e)})}function bT(e,t){return new YS({check:`string_format`,format:`includes`,...q(t),includes:e})}function xT(e,t){return new XS({check:`string_format`,format:`starts_with`,...q(t),prefix:e})}function ST(e,t){return new ZS({check:`string_format`,format:`ends_with`,...q(t),suffix:e})}function CT(e){return new QS({check:`overwrite`,tx:e})}function wT(e){return CT(t=>t.normalize(e))}function TT(){return CT(e=>e.trim())}function ET(){return CT(e=>e.toLowerCase())}function DT(){return CT(e=>e.toUpperCase())}function OT(){return CT(e=>ox(e))}function kT(e,t,n){return new e({type:`array`,element:t,...q(n)})}function AT(e,t,n){let r=q(n);return r.abort??=!0,new e({type:`custom`,check:`custom`,fn:t,...r})}function jT(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...q(n)})}function MT(e,t){let n=NT(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(Ox(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=t.value,r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(Ox(r))}},e(t.value,t)),t);return n}function NT(e,t){let n=new IS({check:`custom`,...q(t)});return n._zod.check=e,n}var PT=a((()=>{$S(),Px()}));function FT(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??Dw,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,external:e?.external??void 0}}function IT(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,IT(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io===`input`&&zT(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function LT(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${a}`}}if(t[1]===n)return{ref:`#`};let i=`#/${r}/`,a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+a}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
|
|
112
112
|
|
|
113
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function LT(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e===`$ref`||e===`allOf`||e in a||delete i[e];if(s.$ref&&n.def)for(let e in i)e===`$ref`||e===`allOf`||e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e===`$ref`||e===`allOf`||e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,o[e.defId]=e.def)}e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:BT(t,`input`,e.processors),output:BT(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function RT(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return RT(r.element,n);if(r.type===`set`)return RT(r.valueType,n);if(r.type===`lazy`)return RT(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`)return RT(r.innerType,n);if(r.type===`intersection`)return RT(r.left,n)||RT(r.right,n);if(r.type===`record`||r.type===`map`)return RT(r.keyType,n)||RT(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:RT(r.in,n)||RT(r.out,n);if(r.type===`object`){for(let e in r.shape)if(RT(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(RT(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(RT(e,n))return!0;return!!(r.rest&&RT(r.rest,n))}return!1}var zT,BT,VT=a((()=>{Dw(),zT=(e,t={})=>n=>{let r=PT({...n,processors:t});return FT(e,r),IT(r,e),LT(r,e)},BT=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=PT({...i??{},target:a,io:t,processors:n});return FT(e,o),IT(o,e),LT(o,e)}})),HT,UT,WT,GT,KT,qT,JT,YT,XT,ZT,QT,$T,eE,tE,nE,rE,iE,aE,oE,sE,cE,lE,uE,dE,fE,pE=a((()=>{VT(),Nx(),HT={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},UT=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=HT[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},WT=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;typeof s==`string`&&s.includes(`int`)?i.type=`integer`:i.type=`number`;let d=typeof u==`number`&&u>=(a??-1/0),f=typeof l==`number`&&l<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof o==`number`&&(i.maximum=o),typeof c==`number`&&(i.multipleOf=c)},GT=(e,t,n,r)=>{n.type=`boolean`},KT=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},qT=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Undefined cannot be represented in JSON Schema`)},JT=(e,t,n,r)=>{n.not={}},YT=(e,t,n,r)=>{},XT=(e,t,n,r)=>{let i=e._zod.def,a=Jb(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},ZT=(e,t,n,r)=>{let i=e._zod.def,a=[];for(let e of i.values)if(e===void 0){if(t.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(t.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);a.push(Number(e))}else a.push(e);if(a.length!==0)if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a},QT=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},$T=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},eE=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=FT(a.element,t,{...r,path:[...r.path,`items`]})},tE=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=FT(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=FT(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},nE=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>FT(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},rE=(e,t,n,r)=>{let i=e._zod.def,a=FT(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=FT(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},iE=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=FT(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else (t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=FT(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=FT(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},aE=(e,t,n,r)=>{let i=e._zod.def,a=FT(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},oE=(e,t,n,r)=>{let i=e._zod.def;FT(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},sE=(e,t,n,r)=>{let i=e._zod.def;FT(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},cE=(e,t,n,r)=>{let i=e._zod.def;FT(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},lE=(e,t,n,r)=>{let i=e._zod.def;FT(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},uE=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;FT(o,t,r);let s=t.seen.get(e);s.ref=o},dE=(e,t,n,r)=>{let i=e._zod.def;FT(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},fE=(e,t,n,r)=>{let i=e._zod.def;FT(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType}})),mE=a((()=>{qb(),eS(),zx(),yw(),QS(),nC(),Nx(),PS(),Sw(),Dw(),eC(),NT(),VT(),pE(),VT()})),hE=a((()=>{mE()}));function gE(e){return Zw(bE,e)}function _E(e){return Qw(xE,e)}function vE(e){return $w(SE,e)}function yE(e){return eT(CE,e)}var bE,xE,SE,CE,wE=a((()=>{mE(),uO(),bE=K(`ZodISODateTime`,(e,t)=>{NC.init(e,t),_D.init(e,t)}),xE=K(`ZodISODate`,(e,t)=>{PC.init(e,t),_D.init(e,t)}),SE=K(`ZodISOTime`,(e,t)=>{FC.init(e,t),_D.init(e,t)}),CE=K(`ZodISODuration`,(e,t)=>{IC.init(e,t),_D.init(e,t)})})),TE,EE,DE=a((()=>{mE(),Nx(),TE=(e,t)=>{Lx.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>Fx(e,t)},flatten:{value:t=>Px(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Xb,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Xb,2)}},isEmpty:{get(){return e.issues.length===0}}})},EE=K(`ZodError`,TE,{Parent:Error})})),OE,kE,AE,jE,ME,NE,PE,FE,IE,LE,RE,zE,BE=a((()=>{mE(),DE(),OE=Bx(EE),kE=Vx(EE),AE=Hx(EE),jE=Wx(EE),ME=Kx(EE),NE=qx(EE),PE=Jx(EE),FE=Yx(EE),IE=Xx(EE),LE=Zx(EE),RE=Qx(EE),zE=$x(EE)}));function VE(e,t,n){let r=Object.getPrototypeOf(e),i=pD.get(r);if(i||(i=new Set,pD.set(r,i)),!i.has(t)){i.add(t);for(let e in n){let t=n[e];Object.defineProperty(r,e,{configurable:!0,enumerable:!1,get(){let n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}function J(e){return Ow(gD,e)}function Y(e){return tT(LD,e)}function HE(e){return nT(RD,e)}function UE(e){return rT(zD,e)}function WE(e){return iT(BD,e)}function GE(e){return aT(VD,e)}function KE(){return oT(HD)}function qE(e){return sT(UD,e)}function X(e,t){return OT(WD,e,t)}function Z(e,t){return new GD({type:`object`,shape:e??{},...q(t)})}function JE(e,t){return new GD({type:`object`,shape:e,catchall:KE(),...q(t)})}function Q(e,t){return new KD({type:`union`,options:e,...q(t)})}function YE(e,t,n){return new qD({type:`union`,options:t,discriminator:e,...q(n)})}function XE(e,t){return new JD({type:`intersection`,left:e,right:t})}function ZE(e,t,n){return!t||!t._zod?new YD({type:`record`,keyType:J(),valueType:e,...q(t)}):new YD({type:`record`,keyType:e,valueType:t,...q(n)})}function QE(e,t){return new XD({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...q(t)})}function $(e,t){return new ZD({type:`literal`,values:Array.isArray(e)?e:[e],...q(t)})}function $E(e){return new QD({type:`transform`,transform:e})}function eD(e){return new $D({type:`optional`,innerType:e})}function tD(e){return new eO({type:`optional`,innerType:e})}function nD(e){return new tO({type:`nullable`,innerType:e})}function rD(e,t){return new nO({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():cx(t)}})}function iD(e,t){return new rO({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():cx(t)}})}function aD(e,t){return new iO({type:`nonoptional`,innerType:e,...q(t)})}function oD(e,t){return new aO({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}function sD(e,t){return new oO({type:`pipe`,in:e,out:t})}function cD(e){return new cO({type:`readonly`,innerType:e})}function lD(e,t){return kT(lO,e??(()=>!0),t)}function uD(e,t={}){return AT(lO,e,t)}function dD(e,t){return jT(e,t)}function fD(e,t){return new sO({type:`pipe`,in:$E(e),out:t})}var pD,mD,hD,gD,_D,vD,yD,bD,xD,SD,CD,wD,TD,ED,DD,OD,kD,AD,jD,MD,ND,PD,FD,ID,LD,RD,zD,BD,VD,HD,UD,WD,GD,KD,qD,JD,YD,XD,ZD,QD,$D,eO,tO,nO,rO,iO,aO,oO,sO,cO,lO,uO=a((()=>{mE(),pE(),VT(),hE(),wE(),BE(),pD=new WeakMap,mD=K(`ZodType`,(e,t)=>(yC.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:BT(e,`input`),output:BT(e,`output`)}}),e.toJSONSchema=zT(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>OE(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>AE(e,t,n),e.parseAsync=async(t,n)=>kE(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>jE(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>ME(e,t,n),e.decode=(t,n)=>NE(e,t,n),e.encodeAsync=async(t,n)=>PE(e,t,n),e.decodeAsync=async(t,n)=>FE(e,t,n),e.safeEncode=(t,n)=>IE(e,t,n),e.safeDecode=(t,n)=>LE(e,t,n),e.safeEncodeAsync=async(t,n)=>RE(e,t,n),e.safeDecodeAsync=async(t,n)=>zE(e,t,n),VE(e,`ZodType`,{check(...e){let t=this.def;return this.clone(rx(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return ux(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(uD(e,t))},superRefine(e,t){return this.check(dD(e,t))},overwrite(e){return this.check(ST(e))},optional(){return eD(this)},exactOptional(){return tD(this)},nullable(){return nD(this)},nullish(){return eD(nD(this))},nonoptional(e){return aD(this,e)},array(){return X(this)},or(e){return Q([this,e])},and(e){return XE(this,e)},transform(e){return sD(this,$E(e))},default(e){return rD(this,e)},prefault(e){return iD(this,e)},catch(e){return oD(this,e)},pipe(e){return sD(this,e)},readonly(){return cD(this)},describe(e){let t=this.clone();return Ew.add(t,{description:e}),t},meta(...e){if(e.length===0)return Ew.get(this);let t=this.clone();return Ew.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,"description",{get(){return Ew.get(e)?.description},configurable:!0}),e)),hD=K(`_ZodString`,(e,t)=>{bC.init(e,t),mD.init(e,t),e._zod.processJSONSchema=(t,n,r)=>UT(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,VE(e,`_ZodString`,{regex(...e){return this.check(gT(...e))},includes(...e){return this.check(yT(...e))},startsWith(...e){return this.check(bT(...e))},endsWith(...e){return this.check(xT(...e))},min(...e){return this.check(mT(...e))},max(...e){return this.check(pT(...e))},length(...e){return this.check(hT(...e))},nonempty(...e){return this.check(mT(1,...e))},lowercase(e){return this.check(_T(e))},uppercase(e){return this.check(vT(e))},trim(){return this.check(wT())},normalize(...e){return this.check(CT(...e))},toLowerCase(){return this.check(TT())},toUpperCase(){return this.check(ET())},slugify(){return this.check(DT())}})}),gD=K(`ZodString`,(e,t)=>{bC.init(e,t),hD.init(e,t),e.email=t=>e.check(kw(vD,t)),e.url=t=>e.check(Fw(xD,t)),e.jwt=t=>e.check(Xw(ID,t)),e.emoji=t=>e.check(Iw(SD,t)),e.guid=t=>e.check(Aw(yD,t)),e.uuid=t=>e.check(jw(bD,t)),e.uuidv4=t=>e.check(Mw(bD,t)),e.uuidv6=t=>e.check(Nw(bD,t)),e.uuidv7=t=>e.check(Pw(bD,t)),e.nanoid=t=>e.check(Lw(CD,t)),e.guid=t=>e.check(Aw(yD,t)),e.cuid=t=>e.check(Rw(wD,t)),e.cuid2=t=>e.check(zw(TD,t)),e.ulid=t=>e.check(Bw(ED,t)),e.base64=t=>e.check(qw(ND,t)),e.base64url=t=>e.check(Jw(PD,t)),e.xid=t=>e.check(Vw(DD,t)),e.ksuid=t=>e.check(Hw(OD,t)),e.ipv4=t=>e.check(Uw(kD,t)),e.ipv6=t=>e.check(Ww(AD,t)),e.cidrv4=t=>e.check(Gw(jD,t)),e.cidrv6=t=>e.check(Kw(MD,t)),e.e164=t=>e.check(Yw(FD,t)),e.datetime=t=>e.check(gE(t)),e.date=t=>e.check(_E(t)),e.time=t=>e.check(vE(t)),e.duration=t=>e.check(yE(t))}),_D=K(`ZodStringFormat`,(e,t)=>{xC.init(e,t),hD.init(e,t)}),vD=K(`ZodEmail`,(e,t)=>{wC.init(e,t),_D.init(e,t)}),yD=K(`ZodGUID`,(e,t)=>{SC.init(e,t),_D.init(e,t)}),bD=K(`ZodUUID`,(e,t)=>{CC.init(e,t),_D.init(e,t)}),xD=K(`ZodURL`,(e,t)=>{TC.init(e,t),_D.init(e,t)}),SD=K(`ZodEmoji`,(e,t)=>{EC.init(e,t),_D.init(e,t)}),CD=K(`ZodNanoID`,(e,t)=>{DC.init(e,t),_D.init(e,t)}),wD=K(`ZodCUID`,(e,t)=>{OC.init(e,t),_D.init(e,t)}),TD=K(`ZodCUID2`,(e,t)=>{kC.init(e,t),_D.init(e,t)}),ED=K(`ZodULID`,(e,t)=>{AC.init(e,t),_D.init(e,t)}),DD=K(`ZodXID`,(e,t)=>{jC.init(e,t),_D.init(e,t)}),OD=K(`ZodKSUID`,(e,t)=>{MC.init(e,t),_D.init(e,t)}),kD=K(`ZodIPv4`,(e,t)=>{LC.init(e,t),_D.init(e,t)}),AD=K(`ZodIPv6`,(e,t)=>{RC.init(e,t),_D.init(e,t)}),jD=K(`ZodCIDRv4`,(e,t)=>{zC.init(e,t),_D.init(e,t)}),MD=K(`ZodCIDRv6`,(e,t)=>{BC.init(e,t),_D.init(e,t)}),ND=K(`ZodBase64`,(e,t)=>{VC.init(e,t),_D.init(e,t)}),PD=K(`ZodBase64URL`,(e,t)=>{HC.init(e,t),_D.init(e,t)}),FD=K(`ZodE164`,(e,t)=>{UC.init(e,t),_D.init(e,t)}),ID=K(`ZodJWT`,(e,t)=>{WC.init(e,t),_D.init(e,t)}),LD=K(`ZodNumber`,(e,t)=>{GC.init(e,t),mD.init(e,t),e._zod.processJSONSchema=(t,n,r)=>WT(e,t,n,r),VE(e,`ZodNumber`,{gt(e,t){return this.check(uT(e,t))},gte(e,t){return this.check(dT(e,t))},min(e,t){return this.check(dT(e,t))},lt(e,t){return this.check(cT(e,t))},lte(e,t){return this.check(lT(e,t))},max(e,t){return this.check(lT(e,t))},int(e){return this.check(HE(e))},safe(e){return this.check(HE(e))},positive(e){return this.check(uT(0,e))},nonnegative(e){return this.check(dT(0,e))},negative(e){return this.check(cT(0,e))},nonpositive(e){return this.check(lT(0,e))},multipleOf(e,t){return this.check(fT(e,t))},step(e,t){return this.check(fT(e,t))},finite(){return this}});let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null}),RD=K(`ZodNumberFormat`,(e,t)=>{KC.init(e,t),LD.init(e,t)}),zD=K(`ZodBoolean`,(e,t)=>{qC.init(e,t),mD.init(e,t),e._zod.processJSONSchema=(t,n,r)=>GT(e,t,n,r)}),BD=K(`ZodUndefined`,(e,t)=>{JC.init(e,t),mD.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qT(e,t,n,r)}),VD=K(`ZodNull`,(e,t)=>{YC.init(e,t),mD.init(e,t),e._zod.processJSONSchema=(t,n,r)=>KT(e,t,n,r)}),HD=K(`ZodUnknown`,(e,t)=>{XC.init(e,t),mD.init(e,t),e._zod.processJSONSchema=(t,n,r)=>YT(e,t,n,r)}),UD=K(`ZodNever`,(e,t)=>{ZC.init(e,t),mD.init(e,t),e._zod.processJSONSchema=(t,n,r)=>JT(e,t,n,r)}),WD=K(`ZodArray`,(e,t)=>{QC.init(e,t),mD.init(e,t),e._zod.processJSONSchema=(t,n,r)=>eE(e,t,n,r),e.element=t.element,VE(e,`ZodArray`,{min(e,t){return this.check(mT(e,t))},nonempty(e){return this.check(mT(1,e))},max(e,t){return this.check(pT(e,t))},length(e,t){return this.check(hT(e,t))},unwrap(){return this.element}})}),GD=K(`ZodObject`,(e,t)=>{ew.init(e,t),mD.init(e,t),e._zod.processJSONSchema=(t,n,r)=>tE(e,t,n,r),tx(e,`shape`,()=>t.shape),VE(e,`ZodObject`,{keyof(){return QE(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:KE()})},loose(){return this.clone({...this._zod.def,catchall:KE()})},strict(){return this.clone({...this._zod.def,catchall:qE()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return hx(this,e)},safeExtend(e){return gx(this,e)},merge(e){return _x(this,e)},pick(e){return px(this,e)},omit(e){return mx(this,e)},partial(...e){return vx($D,this,e[0])},required(...e){return yx(iO,this,e[0])}})}),KD=K(`ZodUnion`,(e,t)=>{tw.init(e,t),mD.init(e,t),e._zod.processJSONSchema=(t,n,r)=>nE(e,t,n,r),e.options=t.options}),qD=K(`ZodDiscriminatedUnion`,(e,t)=>{KD.init(e,t),nw.init(e,t)}),JD=K(`ZodIntersection`,(e,t)=>{rw.init(e,t),mD.init(e,t),e._zod.processJSONSchema=(t,n,r)=>rE(e,t,n,r)}),YD=K(`ZodRecord`,(e,t)=>{iw.init(e,t),mD.init(e,t),e._zod.processJSONSchema=(t,n,r)=>iE(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType}),XD=K(`ZodEnum`,(e,t)=>{aw.init(e,t),mD.init(e,t),e._zod.processJSONSchema=(t,n,r)=>XT(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new XD({...t,checks:[],...q(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new XD({...t,checks:[],...q(r),entries:i})}}),ZD=K(`ZodLiteral`,(e,t)=>{ow.init(e,t),mD.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ZT(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})}),QD=K(`ZodTransform`,(e,t)=>{sw.init(e,t),mD.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$T(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Gb(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Dx(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(Dx(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=i,n.fallback=!0,n)}}),$D=K(`ZodOptional`,(e,t)=>{cw.init(e,t),mD.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fE(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}),eO=K(`ZodExactOptional`,(e,t)=>{lw.init(e,t),mD.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fE(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}),tO=K(`ZodNullable`,(e,t)=>{uw.init(e,t),mD.init(e,t),e._zod.processJSONSchema=(t,n,r)=>aE(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}),nO=K(`ZodDefault`,(e,t)=>{dw.init(e,t),mD.init(e,t),e._zod.processJSONSchema=(t,n,r)=>sE(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap}),rO=K(`ZodPrefault`,(e,t)=>{fw.init(e,t),mD.init(e,t),e._zod.processJSONSchema=(t,n,r)=>cE(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}),iO=K(`ZodNonOptional`,(e,t)=>{pw.init(e,t),mD.init(e,t),e._zod.processJSONSchema=(t,n,r)=>oE(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}),aO=K(`ZodCatch`,(e,t)=>{mw.init(e,t),mD.init(e,t),e._zod.processJSONSchema=(t,n,r)=>lE(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap}),oO=K(`ZodPipe`,(e,t)=>{hw.init(e,t),mD.init(e,t),e._zod.processJSONSchema=(t,n,r)=>uE(e,t,n,r),e.in=t.in,e.out=t.out}),sO=K(`ZodPreprocess`,(e,t)=>{oO.init(e,t),gw.init(e,t)}),cO=K(`ZodReadonly`,(e,t)=>{_w.init(e,t),mD.init(e,t),e._zod.processJSONSchema=(t,n,r)=>dE(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}),lO=K(`ZodCustom`,(e,t)=>{vw.init(e,t),mD.init(e,t),e._zod.processJSONSchema=(t,n,r)=>QT(e,t,n,r)})})),dO,fO=a((()=>{mE(),dO||={}})),pO=a((()=>{mE(),uO(),hE(),DE(),BE(),fO(),Sw(),pE(),Dw(),hE(),wE(),uO(),Nx(),Hb(bw())})),mO=a((()=>{pO(),pO()})),hO=a((()=>{mO()}));hO();var gO=`io.modelcontextprotocol/related-task`,_O=lD(e=>e!==null&&(typeof e==`object`||typeof e==`function`)),vO=Q([J(),Y().int()]),yO=J();JE({ttl:Y().optional(),pollInterval:Y().optional()});var bO=Z({ttl:Y().optional()}),xO=Z({taskId:J()}),SO=JE({progressToken:vO.optional(),[gO]:xO.optional()}),CO=Z({_meta:SO.optional()}),wO=CO.extend({task:bO.optional()}),TO=e=>wO.safeParse(e).success,EO=Z({method:J(),params:CO.loose().optional()}),DO=Z({_meta:SO.optional()}),OO=Z({method:J(),params:DO.loose().optional()}),kO=JE({_meta:SO.optional()}),AO=Q([J(),Y().int()]),jO=Z({jsonrpc:$(`2.0`),id:AO,...EO.shape}).strict(),MO=e=>jO.safeParse(e).success,NO=Z({jsonrpc:$(`2.0`),...OO.shape}).strict(),PO=e=>NO.safeParse(e).success,FO=Z({jsonrpc:$(`2.0`),id:AO,result:kO}).strict(),IO=e=>FO.safeParse(e).success,LO;(function(e){e[e.ConnectionClosed=-32e3]=`ConnectionClosed`,e[e.RequestTimeout=-32001]=`RequestTimeout`,e[e.ParseError=-32700]=`ParseError`,e[e.InvalidRequest=-32600]=`InvalidRequest`,e[e.MethodNotFound=-32601]=`MethodNotFound`,e[e.InvalidParams=-32602]=`InvalidParams`,e[e.InternalError=-32603]=`InternalError`,e[e.UrlElicitationRequired=-32042]=`UrlElicitationRequired`})(LO||={});var RO=Z({jsonrpc:$(`2.0`),id:AO.optional(),error:Z({code:Y().int(),message:J(),data:KE().optional()})}).strict(),zO=e=>RO.safeParse(e).success;Q([jO,NO,FO,RO]),Q([FO,RO]);var BO=kO.strict(),VO=DO.extend({requestId:AO.optional(),reason:J().optional()}),HO=OO.extend({method:$(`notifications/cancelled`),params:VO}),UO=Z({icons:X(Z({src:J(),mimeType:J().optional(),sizes:X(J()).optional(),theme:QE([`light`,`dark`]).optional()})).optional()}),WO=Z({name:J(),title:J().optional()}),GO=WO.extend({...WO.shape,...UO.shape,version:J(),websiteUrl:J().optional(),description:J().optional()}),KO=fD(e=>e&&typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,XE(Z({form:XE(Z({applyDefaults:UE().optional()}),ZE(J(),KE())).optional(),url:_O.optional()}),ZE(J(),KE()).optional())),qO=JE({list:_O.optional(),cancel:_O.optional(),requests:JE({sampling:JE({createMessage:_O.optional()}).optional(),elicitation:JE({create:_O.optional()}).optional()}).optional()}),JO=JE({list:_O.optional(),cancel:_O.optional(),requests:JE({tools:JE({call:_O.optional()}).optional()}).optional()}),YO=Z({experimental:ZE(J(),_O).optional(),sampling:Z({context:_O.optional(),tools:_O.optional()}).optional(),elicitation:KO.optional(),roots:Z({listChanged:UE().optional()}).optional(),tasks:qO.optional(),extensions:ZE(J(),_O).optional()}),XO=CO.extend({protocolVersion:J(),capabilities:YO,clientInfo:GO}),ZO=EO.extend({method:$(`initialize`),params:XO}),QO=Z({experimental:ZE(J(),_O).optional(),logging:_O.optional(),completions:_O.optional(),prompts:Z({listChanged:UE().optional()}).optional(),resources:Z({subscribe:UE().optional(),listChanged:UE().optional()}).optional(),tools:Z({listChanged:UE().optional()}).optional(),tasks:JO.optional(),extensions:ZE(J(),_O).optional()}),$O=kO.extend({protocolVersion:J(),capabilities:QO,serverInfo:GO,instructions:J().optional()}),ek=OO.extend({method:$(`notifications/initialized`),params:DO.optional()}),tk=EO.extend({method:$(`ping`),params:CO.optional()}),nk=Z({progress:Y(),total:eD(Y()),message:eD(J())}),rk=Z({...DO.shape,...nk.shape,progressToken:vO}),ik=OO.extend({method:$(`notifications/progress`),params:rk}),ak=CO.extend({cursor:yO.optional()}),ok=EO.extend({params:ak.optional()}),sk=kO.extend({nextCursor:yO.optional()}),ck=QE([`working`,`input_required`,`completed`,`failed`,`cancelled`]),lk=Z({taskId:J(),status:ck,ttl:Q([Y(),GE()]),createdAt:J(),lastUpdatedAt:J(),pollInterval:eD(Y()),statusMessage:eD(J())}),uk=kO.extend({task:lk}),dk=DO.merge(lk),fk=OO.extend({method:$(`notifications/tasks/status`),params:dk}),pk=EO.extend({method:$(`tasks/get`),params:CO.extend({taskId:J()})}),mk=kO.merge(lk),hk=EO.extend({method:$(`tasks/result`),params:CO.extend({taskId:J()})});kO.loose();var gk=ok.extend({method:$(`tasks/list`)}),_k=sk.extend({tasks:X(lk)}),vk=EO.extend({method:$(`tasks/cancel`),params:CO.extend({taskId:J()})}),yk=kO.merge(lk),bk=Z({uri:J(),mimeType:eD(J()),_meta:ZE(J(),KE()).optional()}),xk=bk.extend({text:J()}),Sk=J().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:`Invalid Base64 string`}),Ck=bk.extend({blob:Sk}),wk=QE([`user`,`assistant`]),Tk=Z({audience:X(wk).optional(),priority:Y().min(0).max(1).optional(),lastModified:gE({offset:!0}).optional()}),Ek=Z({...WO.shape,...UO.shape,uri:J(),description:eD(J()),mimeType:eD(J()),size:eD(Y()),annotations:Tk.optional(),_meta:eD(JE({}))}),Dk=Z({...WO.shape,...UO.shape,uriTemplate:J(),description:eD(J()),mimeType:eD(J()),annotations:Tk.optional(),_meta:eD(JE({}))}),Ok=ok.extend({method:$(`resources/list`)}),kk=sk.extend({resources:X(Ek)}),Ak=ok.extend({method:$(`resources/templates/list`)}),jk=sk.extend({resourceTemplates:X(Dk)}),Mk=CO.extend({uri:J()}),Nk=Mk,Pk=EO.extend({method:$(`resources/read`),params:Nk}),Fk=kO.extend({contents:X(Q([xk,Ck]))}),Ik=OO.extend({method:$(`notifications/resources/list_changed`),params:DO.optional()}),Lk=Mk,Rk=EO.extend({method:$(`resources/subscribe`),params:Lk}),zk=Mk,Bk=EO.extend({method:$(`resources/unsubscribe`),params:zk}),Vk=DO.extend({uri:J()}),Hk=OO.extend({method:$(`notifications/resources/updated`),params:Vk}),Uk=Z({name:J(),description:eD(J()),required:eD(UE())}),Wk=Z({...WO.shape,...UO.shape,description:eD(J()),arguments:eD(X(Uk)),_meta:eD(JE({}))}),Gk=ok.extend({method:$(`prompts/list`)}),Kk=sk.extend({prompts:X(Wk)}),qk=CO.extend({name:J(),arguments:ZE(J(),J()).optional()}),Jk=EO.extend({method:$(`prompts/get`),params:qk}),Yk=Z({type:$(`text`),text:J(),annotations:Tk.optional(),_meta:ZE(J(),KE()).optional()}),Xk=Z({type:$(`image`),data:Sk,mimeType:J(),annotations:Tk.optional(),_meta:ZE(J(),KE()).optional()}),Zk=Z({type:$(`audio`),data:Sk,mimeType:J(),annotations:Tk.optional(),_meta:ZE(J(),KE()).optional()}),Qk=Z({type:$(`tool_use`),name:J(),id:J(),input:ZE(J(),KE()),_meta:ZE(J(),KE()).optional()}),$k=Z({type:$(`resource`),resource:Q([xk,Ck]),annotations:Tk.optional(),_meta:ZE(J(),KE()).optional()}),eA=Ek.extend({type:$(`resource_link`)}),tA=Q([Yk,Xk,Zk,eA,$k]),nA=Z({role:wk,content:tA}),rA=kO.extend({description:J().optional(),messages:X(nA)}),iA=OO.extend({method:$(`notifications/prompts/list_changed`),params:DO.optional()}),aA=Z({title:J().optional(),readOnlyHint:UE().optional(),destructiveHint:UE().optional(),idempotentHint:UE().optional(),openWorldHint:UE().optional()}),oA=Z({taskSupport:QE([`required`,`optional`,`forbidden`]).optional()}),sA=Z({...WO.shape,...UO.shape,description:J().optional(),inputSchema:Z({type:$(`object`),properties:ZE(J(),_O).optional(),required:X(J()).optional()}).catchall(KE()),outputSchema:Z({type:$(`object`),properties:ZE(J(),_O).optional(),required:X(J()).optional()}).catchall(KE()).optional(),annotations:aA.optional(),execution:oA.optional(),_meta:ZE(J(),KE()).optional()}),cA=ok.extend({method:$(`tools/list`)}),lA=sk.extend({tools:X(sA)}),uA=kO.extend({content:X(tA).default([]),structuredContent:ZE(J(),KE()).optional(),isError:UE().optional()});uA.or(kO.extend({toolResult:KE()}));var dA=wO.extend({name:J(),arguments:ZE(J(),KE()).optional()}),fA=EO.extend({method:$(`tools/call`),params:dA}),pA=OO.extend({method:$(`notifications/tools/list_changed`),params:DO.optional()});Z({autoRefresh:UE().default(!0),debounceMs:Y().int().nonnegative().default(300)});var mA=QE([`debug`,`info`,`notice`,`warning`,`error`,`critical`,`alert`,`emergency`]),hA=CO.extend({level:mA}),gA=EO.extend({method:$(`logging/setLevel`),params:hA}),_A=DO.extend({level:mA,logger:J().optional(),data:KE()}),vA=OO.extend({method:$(`notifications/message`),params:_A}),yA=Z({hints:X(Z({name:J().optional()})).optional(),costPriority:Y().min(0).max(1).optional(),speedPriority:Y().min(0).max(1).optional(),intelligencePriority:Y().min(0).max(1).optional()}),bA=Z({mode:QE([`auto`,`required`,`none`]).optional()}),xA=Z({type:$(`tool_result`),toolUseId:J().describe(`The unique identifier for the corresponding tool call.`),content:X(tA).default([]),structuredContent:Z({}).loose().optional(),isError:UE().optional(),_meta:ZE(J(),KE()).optional()}),SA=YE(`type`,[Yk,Xk,Zk]),CA=YE(`type`,[Yk,Xk,Zk,Qk,xA]),wA=Z({role:wk,content:Q([CA,X(CA)]),_meta:ZE(J(),KE()).optional()}),TA=wO.extend({messages:X(wA),modelPreferences:yA.optional(),systemPrompt:J().optional(),includeContext:QE([`none`,`thisServer`,`allServers`]).optional(),temperature:Y().optional(),maxTokens:Y().int(),stopSequences:X(J()).optional(),metadata:_O.optional(),tools:X(sA).optional(),toolChoice:bA.optional()}),EA=EO.extend({method:$(`sampling/createMessage`),params:TA}),DA=kO.extend({model:J(),stopReason:eD(QE([`endTurn`,`stopSequence`,`maxTokens`]).or(J())),role:wk,content:SA}),OA=kO.extend({model:J(),stopReason:eD(QE([`endTurn`,`stopSequence`,`maxTokens`,`toolUse`]).or(J())),role:wk,content:Q([CA,X(CA)])}),kA=Z({type:$(`boolean`),title:J().optional(),description:J().optional(),default:UE().optional()}),AA=Z({type:$(`string`),title:J().optional(),description:J().optional(),minLength:Y().optional(),maxLength:Y().optional(),format:QE([`email`,`uri`,`date`,`date-time`]).optional(),default:J().optional()}),jA=Z({type:QE([`number`,`integer`]),title:J().optional(),description:J().optional(),minimum:Y().optional(),maximum:Y().optional(),default:Y().optional()}),MA=Z({type:$(`string`),title:J().optional(),description:J().optional(),enum:X(J()),default:J().optional()}),NA=Z({type:$(`string`),title:J().optional(),description:J().optional(),oneOf:X(Z({const:J(),title:J()})),default:J().optional()}),PA=Q([Q([Z({type:$(`string`),title:J().optional(),description:J().optional(),enum:X(J()),enumNames:X(J()).optional(),default:J().optional()}),Q([MA,NA]),Q([Z({type:$(`array`),title:J().optional(),description:J().optional(),minItems:Y().optional(),maxItems:Y().optional(),items:Z({type:$(`string`),enum:X(J())}),default:X(J()).optional()}),Z({type:$(`array`),title:J().optional(),description:J().optional(),minItems:Y().optional(),maxItems:Y().optional(),items:Z({anyOf:X(Z({const:J(),title:J()}))}),default:X(J()).optional()})])]),kA,AA,jA]),FA=Q([wO.extend({mode:$(`form`).optional(),message:J(),requestedSchema:Z({type:$(`object`),properties:ZE(J(),PA),required:X(J()).optional()})}),wO.extend({mode:$(`url`),message:J(),elicitationId:J(),url:J().url()})]),IA=EO.extend({method:$(`elicitation/create`),params:FA}),LA=DO.extend({elicitationId:J()}),RA=OO.extend({method:$(`notifications/elicitation/complete`),params:LA}),zA=kO.extend({action:QE([`accept`,`decline`,`cancel`]),content:fD(e=>e===null?void 0:e,ZE(J(),Q([J(),Y(),UE(),X(J())])).optional())}),BA=Z({type:$(`ref/resource`),uri:J()}),VA=Z({type:$(`ref/prompt`),name:J()}),HA=CO.extend({ref:Q([VA,BA]),argument:Z({name:J(),value:J()}),context:Z({arguments:ZE(J(),J()).optional()}).optional()}),UA=EO.extend({method:$(`completion/complete`),params:HA}),WA=kO.extend({completion:JE({values:X(J()).max(100),total:eD(Y().int()),hasMore:eD(UE())})}),GA=Z({uri:J().startsWith(`file://`),name:J().optional(),_meta:ZE(J(),KE()).optional()}),KA=EO.extend({method:$(`roots/list`),params:CO.optional()}),qA=kO.extend({roots:X(GA)}),JA=OO.extend({method:$(`notifications/roots/list_changed`),params:DO.optional()});Q([tk,ZO,UA,gA,Jk,Gk,Ok,Ak,Pk,Rk,Bk,fA,cA,pk,hk,gk,vk]),Q([HO,ik,ek,JA,fk]),Q([BO,DA,OA,zA,qA,mk,_k,uk]),Q([tk,EA,IA,KA,pk,hk,gk,vk]),Q([HO,ik,vA,Hk,Ik,pA,iA,fk,RA]),Q([BO,$O,WA,rA,Kk,kk,jk,Fk,uA,lA,mk,_k,uk]);var YA=class e extends Error{constructor(e,t,n){super(`MCP error ${e}: ${t}`),this.code=e,this.data=n,this.name=`McpError`}static fromError(t,n,r){if(t===LO.UrlElicitationRequired&&r){let e=r;if(e.elicitations)return new XA(e.elicitations,n)}return new e(t,n,r)}},XA=class extends YA{constructor(e,t=`URL elicitation${e.length>1?`s`:``} required`){super(LO.UrlElicitationRequired,t,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}};NT(),Nx(),PS(),qb(),eS(),pE(),zx(),init_locales(),mE(),Dw();function ZA(e){return!!e._zod}function QA(e,t){return ZA(e)?Ux(e,t):e.safeParse(t)}function $A(e){if(!e)return;let t;if(t=ZA(e)?e._zod?.def?.shape:e.shape,t){if(typeof t==`function`)try{return t()}catch{return}return t}}function ej(e){if(ZA(e)){let t=e._zod?.def;if(t){if(t.value!==void 0)return t.value;if(Array.isArray(t.values)&&t.values.length>0)return t.values[0]}}let t=e._def;if(t){if(t.value!==void 0)return t.value;if(Array.isArray(t.values)&&t.values.length>0)return t.values[0]}let n=e.value;if(n!==void 0)return n}function tj(e){return e===`completed`||e===`failed`||e===`cancelled`}function nj(e){let t=$A(e)?.method;if(!t)throw Error(`Schema is missing a method literal`);let n=ej(t);if(typeof n!=`string`)throw Error(`Schema method literal must be a string`);return n}function rj(e,t){let n=QA(e,t);if(!n.success)throw n.error;return n.data}var ij=class{constructor(e){this._options=e,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(HO,e=>{this._oncancel(e)}),this.setNotificationHandler(ik,e=>{this._onprogress(e)}),this.setRequestHandler(tk,e=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(pk,async(e,t)=>{let n=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!n)throw new YA(LO.InvalidParams,`Failed to retrieve task: Task not found`);return{...n}}),this.setRequestHandler(hk,async(e,t)=>{let n=async()=>{let r=e.params.taskId;if(this._taskMessageQueue){let e;for(;e=await this._taskMessageQueue.dequeue(r,t.sessionId);){if(e.type===`response`||e.type===`error`){let t=e.message,n=t.id,r=this._requestResolvers.get(n);if(r)if(this._requestResolvers.delete(n),e.type===`response`)r(t);else{let e=t;r(new YA(e.error.code,e.error.message,e.error.data))}else{let t=e.type===`response`?`Response`:`Error`;this._onerror(Error(`${t} handler missing for request ${n}`))}continue}await this._transport?.send(e.message,{relatedRequestId:t.requestId})}}let i=await this._taskStore.getTask(r,t.sessionId);if(!i)throw new YA(LO.InvalidParams,`Task not found: ${r}`);if(!tj(i.status))return await this._waitForTaskUpdate(r,t.signal),await n();if(tj(i.status)){let e=await this._taskStore.getTaskResult(r,t.sessionId);return this._clearTaskQueue(r),{...e,_meta:{...e._meta,[gO]:{taskId:r}}}}return await n()};return await n()}),this.setRequestHandler(gk,async(e,t)=>{try{let{tasks:n,nextCursor:r}=await this._taskStore.listTasks(e.params?.cursor,t.sessionId);return{tasks:n,nextCursor:r,_meta:{}}}catch(e){throw new YA(LO.InvalidParams,`Failed to list tasks: ${e instanceof Error?e.message:String(e)}`)}}),this.setRequestHandler(vk,async(e,t)=>{try{let n=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!n)throw new YA(LO.InvalidParams,`Task not found: ${e.params.taskId}`);if(tj(n.status))throw new YA(LO.InvalidParams,`Cannot cancel task in terminal status: ${n.status}`);await this._taskStore.updateTaskStatus(e.params.taskId,`cancelled`,`Client cancelled task execution.`,t.sessionId),this._clearTaskQueue(e.params.taskId);let r=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!r)throw new YA(LO.InvalidParams,`Task not found after cancellation: ${e.params.taskId}`);return{_meta:{},...r}}catch(e){throw e instanceof YA?e:new YA(LO.InvalidRequest,`Failed to cancel task: ${e instanceof Error?e.message:String(e)}`)}}))}async _oncancel(e){e.params.requestId&&this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,t,n,r,i=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(r,t),startTime:Date.now(),timeout:t,maxTotalTimeout:n,resetTimeoutOnProgress:i,onTimeout:r})}_resetTimeout(e){let t=this._timeoutInfo.get(e);if(!t)return!1;let n=Date.now()-t.startTime;if(t.maxTotalTimeout&&n>=t.maxTotalTimeout)throw this._timeoutInfo.delete(e),YA.fromError(LO.RequestTimeout,`Maximum total timeout exceeded`,{maxTotalTimeout:t.maxTotalTimeout,totalElapsed:n});return clearTimeout(t.timeoutId),t.timeoutId=setTimeout(t.onTimeout,t.timeout),!0}_cleanupTimeout(e){let t=this._timeoutInfo.get(e);t&&(clearTimeout(t.timeoutId),this._timeoutInfo.delete(e))}async connect(e){if(this._transport)throw Error(`Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.`);this._transport=e;let t=this.transport?.onclose;this._transport.onclose=()=>{t?.(),this._onclose()};let n=this.transport?.onerror;this._transport.onerror=e=>{n?.(e),this._onerror(e)};let r=this._transport?.onmessage;this._transport.onmessage=(e,t)=>{r?.(e,t),IO(e)||zO(e)?this._onresponse(e):MO(e)?this._onrequest(e,t):PO(e)?this._onnotification(e):this._onerror(Error(`Unknown message type: ${JSON.stringify(e)}`))},await this._transport.start()}_onclose(){let e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(let e of this._timeoutInfo.values())clearTimeout(e.timeoutId);this._timeoutInfo.clear();for(let e of this._requestHandlerAbortControllers.values())e.abort();this._requestHandlerAbortControllers.clear();let t=YA.fromError(LO.ConnectionClosed,`Connection closed`);this._transport=void 0,this.onclose?.();for(let n of e.values())n(t)}_onerror(e){this.onerror?.(e)}_onnotification(e){let t=this._notificationHandlers.get(e.method)??this.fallbackNotificationHandler;t!==void 0&&Promise.resolve().then(()=>t(e)).catch(e=>this._onerror(Error(`Uncaught error in notification handler: ${e}`)))}_onrequest(e,t){let n=this._requestHandlers.get(e.method)??this.fallbackRequestHandler,r=this._transport,i=e.params?._meta?.[gO]?.taskId;if(n===void 0){let t={jsonrpc:`2.0`,id:e.id,error:{code:LO.MethodNotFound,message:`Method not found`}};i&&this._taskMessageQueue?this._enqueueTaskMessage(i,{type:`error`,message:t,timestamp:Date.now()},r?.sessionId).catch(e=>this._onerror(Error(`Failed to enqueue error response: ${e}`))):r?.send(t).catch(e=>this._onerror(Error(`Failed to send an error response: ${e}`)));return}let a=new AbortController;this._requestHandlerAbortControllers.set(e.id,a);let o=TO(e.params)?e.params.task:void 0,s=this._taskStore?this.requestTaskStore(e,r?.sessionId):void 0,c={signal:a.signal,sessionId:r?.sessionId,_meta:e.params?._meta,sendNotification:async t=>{if(a.signal.aborted)return;let n={relatedRequestId:e.id};i&&(n.relatedTask={taskId:i}),await this.notification(t,n)},sendRequest:async(t,n,r)=>{if(a.signal.aborted)throw new YA(LO.ConnectionClosed,`Request was cancelled`);let o={...r,relatedRequestId:e.id};i&&!o.relatedTask&&(o.relatedTask={taskId:i});let c=o.relatedTask?.taskId??i;return c&&s&&await s.updateTaskStatus(c,`input_required`),await this.request(t,n,o)},authInfo:t?.authInfo,requestId:e.id,requestInfo:t?.requestInfo,taskId:i,taskStore:s,taskRequestedTtl:o?.ttl,closeSSEStream:t?.closeSSEStream,closeStandaloneSSEStream:t?.closeStandaloneSSEStream};Promise.resolve().then(()=>{o&&this.assertTaskHandlerCapability(e.method)}).then(()=>n(e,c)).then(async t=>{if(a.signal.aborted)return;let n={result:t,jsonrpc:`2.0`,id:e.id};i&&this._taskMessageQueue?await this._enqueueTaskMessage(i,{type:`response`,message:n,timestamp:Date.now()},r?.sessionId):await r?.send(n)},async t=>{if(a.signal.aborted)return;let n={jsonrpc:`2.0`,id:e.id,error:{code:Number.isSafeInteger(t.code)?t.code:LO.InternalError,message:t.message??`Internal error`,...t.data!==void 0&&{data:t.data}}};i&&this._taskMessageQueue?await this._enqueueTaskMessage(i,{type:`error`,message:n,timestamp:Date.now()},r?.sessionId):await r?.send(n)}).catch(e=>this._onerror(Error(`Failed to send response: ${e}`))).finally(()=>{this._requestHandlerAbortControllers.get(e.id)===a&&this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){let{progressToken:t,...n}=e.params,r=Number(t),i=this._progressHandlers.get(r);if(!i){this._onerror(Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let a=this._responseHandlers.get(r),o=this._timeoutInfo.get(r);if(o&&a&&o.resetTimeoutOnProgress)try{this._resetTimeout(r)}catch(e){this._responseHandlers.delete(r),this._progressHandlers.delete(r),this._cleanupTimeout(r),a(e);return}i(n)}_onresponse(e){let t=Number(e.id),n=this._requestResolvers.get(t);if(n){this._requestResolvers.delete(t),IO(e)?n(e):n(new YA(e.error.code,e.error.message,e.error.data));return}let r=this._responseHandlers.get(t);if(r===void 0){this._onerror(Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}this._responseHandlers.delete(t),this._cleanupTimeout(t);let i=!1;if(IO(e)&&e.result&&typeof e.result==`object`){let n=e.result;if(n.task&&typeof n.task==`object`){let e=n.task;typeof e.taskId==`string`&&(i=!0,this._taskProgressTokens.set(e.taskId,t))}}i||this._progressHandlers.delete(t),IO(e)?r(e):r(YA.fromError(e.error.code,e.error.message,e.error.data))}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(e,t,n){let{task:r}=n??{};if(!r){try{yield{type:`result`,result:await this.request(e,t,n)}}catch(e){yield{type:`error`,error:e instanceof YA?e:new YA(LO.InternalError,String(e))}}return}let i;try{let r=await this.request(e,uk,n);if(r.task)i=r.task.taskId,yield{type:`taskCreated`,task:r.task};else throw new YA(LO.InternalError,`Task creation did not return a task`);for(;;){let e=await this.getTask({taskId:i},n);if(yield{type:`taskStatus`,task:e},tj(e.status)){e.status===`completed`?yield{type:`result`,result:await this.getTaskResult({taskId:i},t,n)}:e.status===`failed`?yield{type:`error`,error:new YA(LO.InternalError,`Task ${i} failed`)}:e.status===`cancelled`&&(yield{type:`error`,error:new YA(LO.InternalError,`Task ${i} was cancelled`)});return}if(e.status===`input_required`){yield{type:`result`,result:await this.getTaskResult({taskId:i},t,n)};return}let r=e.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(e=>setTimeout(e,r)),n?.signal?.throwIfAborted()}}catch(e){yield{type:`error`,error:e instanceof YA?e:new YA(LO.InternalError,String(e))}}}request(e,t,n){let{relatedRequestId:r,resumptionToken:i,onresumptiontoken:a,task:o,relatedTask:s}=n??{};return new Promise((c,l)=>{let u=e=>{l(e)};if(!this._transport){u(Error(`Not connected`));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(e.method),o&&this.assertTaskCapability(e.method)}catch(e){u(e);return}n?.signal?.throwIfAborted();let d=this._requestMessageId++,f={...e,jsonrpc:`2.0`,id:d};n?.onprogress&&(this._progressHandlers.set(d,n.onprogress),f.params={...e.params,_meta:{...e.params?._meta||{},progressToken:d}}),o&&(f.params={...f.params,task:o}),s&&(f.params={...f.params,_meta:{...f.params?._meta||{},[gO]:s}});let p=e=>{this._responseHandlers.delete(d),this._progressHandlers.delete(d),this._cleanupTimeout(d),this._transport?.send({jsonrpc:`2.0`,method:`notifications/cancelled`,params:{requestId:d,reason:String(e)}},{relatedRequestId:r,resumptionToken:i,onresumptiontoken:a}).catch(e=>this._onerror(Error(`Failed to send cancellation: ${e}`))),l(e instanceof YA?e:new YA(LO.RequestTimeout,String(e)))};this._responseHandlers.set(d,e=>{if(!n?.signal?.aborted){if(e instanceof Error)return l(e);try{let n=QA(t,e.result);n.success?c(n.data):l(n.error)}catch(e){l(e)}}}),n?.signal?.addEventListener(`abort`,()=>{p(n?.signal?.reason)});let m=n?.timeout??6e4;this._setupTimeout(d,m,n?.maxTotalTimeout,()=>p(YA.fromError(LO.RequestTimeout,`Request timed out`,{timeout:m})),n?.resetTimeoutOnProgress??!1);let h=s?.taskId;h?(this._requestResolvers.set(d,e=>{let t=this._responseHandlers.get(d);t?t(e):this._onerror(Error(`Response handler missing for side-channeled request ${d}`))}),this._enqueueTaskMessage(h,{type:`request`,message:f,timestamp:Date.now()}).catch(e=>{this._cleanupTimeout(d),l(e)})):this._transport.send(f,{relatedRequestId:r,resumptionToken:i,onresumptiontoken:a}).catch(e=>{this._cleanupTimeout(d),l(e)})})}async getTask(e,t){return this.request({method:`tasks/get`,params:e},mk,t)}async getTaskResult(e,t,n){return this.request({method:`tasks/result`,params:e},t,n)}async listTasks(e,t){return this.request({method:`tasks/list`,params:e},_k,t)}async cancelTask(e,t){return this.request({method:`tasks/cancel`,params:e},yk,t)}async notification(e,t){if(!this._transport)throw Error(`Not connected`);this.assertNotificationCapability(e.method);let n=t?.relatedTask?.taskId;if(n){let r={...e,jsonrpc:`2.0`,params:{...e.params,_meta:{...e.params?._meta||{},[gO]:t.relatedTask}}};await this._enqueueTaskMessage(n,{type:`notification`,message:r,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(e.method)&&!e.params&&!t?.relatedRequestId&&!t?.relatedTask){if(this._pendingDebouncedNotifications.has(e.method))return;this._pendingDebouncedNotifications.add(e.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;let n={...e,jsonrpc:`2.0`};t?.relatedTask&&(n={...n,params:{...n.params,_meta:{...n.params?._meta||{},[gO]:t.relatedTask}}}),this._transport?.send(n,t).catch(e=>this._onerror(e))});return}let r={...e,jsonrpc:`2.0`};t?.relatedTask&&(r={...r,params:{...r.params,_meta:{...r.params?._meta||{},[gO]:t.relatedTask}}}),await this._transport.send(r,t)}setRequestHandler(e,t){let n=nj(e);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(n,r)=>{let i=rj(e,n);return Promise.resolve(t(i,r))})}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,t){let n=nj(e);this._notificationHandlers.set(n,n=>{let r=rj(e,n);return Promise.resolve(t(r))})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}_cleanupTaskProgressHandler(e){let t=this._taskProgressTokens.get(e);t!==void 0&&(this._progressHandlers.delete(t),this._taskProgressTokens.delete(e))}async _enqueueTaskMessage(e,t,n){if(!this._taskStore||!this._taskMessageQueue)throw Error(`Cannot enqueue task message: taskStore and taskMessageQueue are not configured`);let r=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(e,t,n,r)}async _clearTaskQueue(e,t){if(this._taskMessageQueue){let n=await this._taskMessageQueue.dequeueAll(e,t);for(let t of n)if(t.type===`request`&&MO(t.message)){let n=t.message.id,r=this._requestResolvers.get(n);r?(r(new YA(LO.InternalError,`Task cancelled or completed`)),this._requestResolvers.delete(n)):this._onerror(Error(`Resolver missing for request ${n} during task ${e} cleanup`))}}}async _waitForTaskUpdate(e,t){let n=this._options?.defaultTaskPollInterval??1e3;try{let t=await this._taskStore?.getTask(e);t?.pollInterval&&(n=t.pollInterval)}catch{}return new Promise((e,r)=>{if(t.aborted){r(new YA(LO.InvalidRequest,`Request cancelled`));return}let i=setTimeout(e,n);t.addEventListener(`abort`,()=>{clearTimeout(i),r(new YA(LO.InvalidRequest,`Request cancelled`))},{once:!0})})}requestTaskStore(e,t){let n=this._taskStore;if(!n)throw Error(`No task store configured`);return{createTask:async r=>{if(!e)throw Error(`No request provided`);return await n.createTask(r,e.id,{method:e.method,params:e.params},t)},getTask:async e=>{let r=await n.getTask(e,t);if(!r)throw new YA(LO.InvalidParams,`Failed to retrieve task: Task not found`);return r},storeTaskResult:async(e,r,i)=>{await n.storeTaskResult(e,r,i,t);let a=await n.getTask(e,t);if(a){let t=fk.parse({method:`notifications/tasks/status`,params:a});await this.notification(t),tj(a.status)&&this._cleanupTaskProgressHandler(e)}},getTaskResult:e=>n.getTaskResult(e,t),updateTaskStatus:async(e,r,i)=>{let a=await n.getTask(e,t);if(!a)throw new YA(LO.InvalidParams,`Task "${e}" not found - it may have been cleaned up`);if(tj(a.status))throw new YA(LO.InvalidParams,`Cannot update task "${e}" from terminal status "${a.status}" to "${r}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await n.updateTaskStatus(e,r,i,t);let o=await n.getTask(e,t);if(o){let t=fk.parse({method:`notifications/tasks/status`,params:o});await this.notification(t),tj(o.status)&&this._cleanupTaskProgressHandler(e)}},listTasks:e=>n.listTasks(e,t)}}};hO(),(e=>typeof require<`u`?require:typeof Proxy<`u`?new Proxy(e,{get:(e,t)=>(typeof require<`u`?require:e)[t]}):e)(function(e){if(typeof require<`u`)return require.apply(this,arguments);throw Error(`Dynamic require of "`+e+`" is not supported`)});var aj=class extends ij{_registeredMethods=new Set;_eventSlots=new Map;onEventDispatch(e,t){}_ensureEventSlot(e){let t=this._eventSlots.get(e);if(!t){let n=this.eventSchemas[e];if(!n)throw Error(`Unknown event: ${String(e)}`);t={listeners:[]},this._eventSlots.set(e,t);let r=n.shape.method.value;this._registeredMethods.add(r);let i=t;super.setNotificationHandler(n,t=>{let n=t.params;this.onEventDispatch(e,n),i.onHandler?.(n);for(let e of[...i.listeners])e(n)})}return t}setEventHandler(e,t){let n=this._ensureEventSlot(e);n.onHandler&&t&&console.warn(`[MCP Apps] on${String(e)} handler replaced. Use addEventListener("${String(e)}", …) to add multiple listeners without replacing.`),n.onHandler=t}getEventHandler(e){return this._eventSlots.get(e)?.onHandler}addEventListener(e,t){this._ensureEventSlot(e).listeners.push(t)}removeEventListener(e,t){let n=this._eventSlots.get(e);if(!n)return;let r=n.listeners.indexOf(t);r!==-1&&n.listeners.splice(r,1)}setRequestHandler=(e,t)=>{this._assertMethodNotRegistered(e,`setRequestHandler`),super.setRequestHandler(e,t)};setNotificationHandler=(e,t)=>{this._assertMethodNotRegistered(e,`setNotificationHandler`),super.setNotificationHandler(e,t)};warnIfRequestHandlerReplaced(e,t,n){t&&n&&console.warn(`[MCP Apps] ${e} handler replaced. Previous handler will no longer be called.`)}replaceRequestHandler=(e,t)=>{let n=e.shape.method.value;this._registeredMethods.add(n),super.setRequestHandler(e,t)};_assertMethodNotRegistered(e,t){let n=e.shape.method.value;if(this._registeredMethods.has(n))throw Error(`Handler for "${n}" already registered (via ${t}). Use addEventListener() to attach multiple listeners, or the on* setter for replace semantics.`);this._registeredMethods.add(n)}},oj=`2026-01-26`,sj=Q([$(`light`),$(`dark`)]).describe(`Color theme preference for the host environment.`),cj=Q([$(`inline`),$(`fullscreen`),$(`pip`)]).describe(`Display mode for UI presentation.`),lj=ZE(Q([$(`--color-background-primary`),$(`--color-background-secondary`),$(`--color-background-tertiary`),$(`--color-background-inverse`),$(`--color-background-ghost`),$(`--color-background-info`),$(`--color-background-danger`),$(`--color-background-success`),$(`--color-background-warning`),$(`--color-background-disabled`),$(`--color-text-primary`),$(`--color-text-secondary`),$(`--color-text-tertiary`),$(`--color-text-inverse`),$(`--color-text-ghost`),$(`--color-text-info`),$(`--color-text-danger`),$(`--color-text-success`),$(`--color-text-warning`),$(`--color-text-disabled`),$(`--color-border-primary`),$(`--color-border-secondary`),$(`--color-border-tertiary`),$(`--color-border-inverse`),$(`--color-border-ghost`),$(`--color-border-info`),$(`--color-border-danger`),$(`--color-border-success`),$(`--color-border-warning`),$(`--color-border-disabled`),$(`--color-ring-primary`),$(`--color-ring-secondary`),$(`--color-ring-inverse`),$(`--color-ring-info`),$(`--color-ring-danger`),$(`--color-ring-success`),$(`--color-ring-warning`),$(`--font-sans`),$(`--font-mono`),$(`--font-weight-normal`),$(`--font-weight-medium`),$(`--font-weight-semibold`),$(`--font-weight-bold`),$(`--font-text-xs-size`),$(`--font-text-sm-size`),$(`--font-text-md-size`),$(`--font-text-lg-size`),$(`--font-heading-xs-size`),$(`--font-heading-sm-size`),$(`--font-heading-md-size`),$(`--font-heading-lg-size`),$(`--font-heading-xl-size`),$(`--font-heading-2xl-size`),$(`--font-heading-3xl-size`),$(`--font-text-xs-line-height`),$(`--font-text-sm-line-height`),$(`--font-text-md-line-height`),$(`--font-text-lg-line-height`),$(`--font-heading-xs-line-height`),$(`--font-heading-sm-line-height`),$(`--font-heading-md-line-height`),$(`--font-heading-lg-line-height`),$(`--font-heading-xl-line-height`),$(`--font-heading-2xl-line-height`),$(`--font-heading-3xl-line-height`),$(`--border-radius-xs`),$(`--border-radius-sm`),$(`--border-radius-md`),$(`--border-radius-lg`),$(`--border-radius-xl`),$(`--border-radius-full`),$(`--border-width-regular`),$(`--shadow-hairline`),$(`--shadow-sm`),$(`--shadow-md`),$(`--shadow-lg`)]).describe(`CSS variable keys available to MCP apps for theming.`).describe(`Style variables for theming MCP apps.
|
|
113
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function RT(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e===`$ref`||e===`allOf`||e in a||delete i[e];if(s.$ref&&n.def)for(let e in i)e===`$ref`||e===`allOf`||e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e===`$ref`||e===`allOf`||e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,o[e.defId]=e.def)}e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:VT(t,`input`,e.processors),output:VT(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function zT(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return zT(r.element,n);if(r.type===`set`)return zT(r.valueType,n);if(r.type===`lazy`)return zT(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`)return zT(r.innerType,n);if(r.type===`intersection`)return zT(r.left,n)||zT(r.right,n);if(r.type===`record`||r.type===`map`)return zT(r.keyType,n)||zT(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:zT(r.in,n)||zT(r.out,n);if(r.type===`object`){for(let e in r.shape)if(zT(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(zT(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(zT(e,n))return!0;return!!(r.rest&&zT(r.rest,n))}return!1}var BT,VT,HT=a((()=>{Ow(),BT=(e,t={})=>n=>{let r=FT({...n,processors:t});return IT(e,r),LT(r,e),RT(r,e)},VT=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=FT({...i??{},target:a,io:t,processors:n});return IT(e,o),LT(o,e),RT(o,e)}})),UT,WT,GT,KT,qT,JT,YT,XT,ZT,QT,$T,eE,tE,nE,rE,iE,aE,oE,sE,cE,lE,uE,dE,fE,pE,mE=a((()=>{HT(),Px(),UT={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},WT=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=UT[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},GT=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;typeof s==`string`&&s.includes(`int`)?i.type=`integer`:i.type=`number`;let d=typeof u==`number`&&u>=(a??-1/0),f=typeof l==`number`&&l<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof o==`number`&&(i.maximum=o),typeof c==`number`&&(i.multipleOf=c)},KT=(e,t,n,r)=>{n.type=`boolean`},qT=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},JT=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Undefined cannot be represented in JSON Schema`)},YT=(e,t,n,r)=>{n.not={}},XT=(e,t,n,r)=>{},ZT=(e,t,n,r)=>{let i=e._zod.def,a=Yb(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},QT=(e,t,n,r)=>{let i=e._zod.def,a=[];for(let e of i.values)if(e===void 0){if(t.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(t.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);a.push(Number(e))}else a.push(e);if(a.length!==0)if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a},$T=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},eE=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},tE=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=IT(a.element,t,{...r,path:[...r.path,`items`]})},nE=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=IT(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=IT(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},rE=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>IT(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},iE=(e,t,n,r)=>{let i=e._zod.def,a=IT(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=IT(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},aE=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=IT(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else (t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=IT(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=IT(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},oE=(e,t,n,r)=>{let i=e._zod.def,a=IT(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},sE=(e,t,n,r)=>{let i=e._zod.def;IT(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},cE=(e,t,n,r)=>{let i=e._zod.def;IT(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},lE=(e,t,n,r)=>{let i=e._zod.def;IT(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},uE=(e,t,n,r)=>{let i=e._zod.def;IT(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},dE=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;IT(o,t,r);let s=t.seen.get(e);s.ref=o},fE=(e,t,n,r)=>{let i=e._zod.def;IT(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},pE=(e,t,n,r)=>{let i=e._zod.def;IT(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType}})),hE=a((()=>{Jb(),tS(),Bx(),bw(),$S(),rC(),Px(),FS(),Cw(),Ow(),tC(),PT(),HT(),mE(),HT()})),gE=a((()=>{hE()}));function _E(e){return Qw(xE,e)}function vE(e){return $w(SE,e)}function yE(e){return eT(CE,e)}function bE(e){return tT(wE,e)}var xE,SE,CE,wE,TE=a((()=>{hE(),dO(),xE=K(`ZodISODateTime`,(e,t)=>{PC.init(e,t),vD.init(e,t)}),SE=K(`ZodISODate`,(e,t)=>{FC.init(e,t),vD.init(e,t)}),CE=K(`ZodISOTime`,(e,t)=>{IC.init(e,t),vD.init(e,t)}),wE=K(`ZodISODuration`,(e,t)=>{LC.init(e,t),vD.init(e,t)})})),EE,DE,OE=a((()=>{hE(),Px(),EE=(e,t)=>{Rx.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>Ix(e,t)},flatten:{value:t=>Fx(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Zb,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Zb,2)}},isEmpty:{get(){return e.issues.length===0}}})},DE=K(`ZodError`,EE,{Parent:Error})})),kE,AE,jE,ME,NE,PE,FE,IE,LE,RE,zE,BE,VE=a((()=>{hE(),OE(),kE=Vx(DE),AE=Hx(DE),jE=Ux(DE),ME=Gx(DE),NE=qx(DE),PE=Jx(DE),FE=Yx(DE),IE=Xx(DE),LE=Zx(DE),RE=Qx(DE),zE=$x(DE),BE=eS(DE)}));function HE(e,t,n){let r=Object.getPrototypeOf(e),i=mD.get(r);if(i||(i=new Set,mD.set(r,i)),!i.has(t)){i.add(t);for(let e in n){let t=n[e];Object.defineProperty(r,e,{configurable:!0,enumerable:!1,get(){let n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}function J(e){return kw(_D,e)}function Y(e){return nT(RD,e)}function UE(e){return rT(zD,e)}function WE(e){return iT(BD,e)}function GE(e){return aT(VD,e)}function KE(e){return oT(HD,e)}function qE(){return sT(UD)}function JE(e){return cT(WD,e)}function X(e,t){return kT(GD,e,t)}function Z(e,t){return new KD({type:`object`,shape:e??{},...q(t)})}function YE(e,t){return new KD({type:`object`,shape:e,catchall:qE(),...q(t)})}function Q(e,t){return new qD({type:`union`,options:e,...q(t)})}function XE(e,t,n){return new JD({type:`union`,options:t,discriminator:e,...q(n)})}function ZE(e,t){return new YD({type:`intersection`,left:e,right:t})}function QE(e,t,n){return!t||!t._zod?new XD({type:`record`,keyType:J(),valueType:e,...q(t)}):new XD({type:`record`,keyType:e,valueType:t,...q(n)})}function $E(e,t){return new ZD({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...q(t)})}function $(e,t){return new QD({type:`literal`,values:Array.isArray(e)?e:[e],...q(t)})}function eD(e){return new $D({type:`transform`,transform:e})}function tD(e){return new eO({type:`optional`,innerType:e})}function nD(e){return new tO({type:`optional`,innerType:e})}function rD(e){return new nO({type:`nullable`,innerType:e})}function iD(e,t){return new rO({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():lx(t)}})}function aD(e,t){return new iO({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():lx(t)}})}function oD(e,t){return new aO({type:`nonoptional`,innerType:e,...q(t)})}function sD(e,t){return new oO({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}function cD(e,t){return new sO({type:`pipe`,in:e,out:t})}function lD(e){return new lO({type:`readonly`,innerType:e})}function uD(e,t){return AT(uO,e??(()=>!0),t)}function dD(e,t={}){return jT(uO,e,t)}function fD(e,t){return MT(e,t)}function pD(e,t){return new cO({type:`pipe`,in:eD(e),out:t})}var mD,hD,gD,_D,vD,yD,bD,xD,SD,CD,wD,TD,ED,DD,OD,kD,AD,jD,MD,ND,PD,FD,ID,LD,RD,zD,BD,VD,HD,UD,WD,GD,KD,qD,JD,YD,XD,ZD,QD,$D,eO,tO,nO,rO,iO,aO,oO,sO,cO,lO,uO,dO=a((()=>{hE(),mE(),HT(),gE(),TE(),VE(),mD=new WeakMap,hD=K(`ZodType`,(e,t)=>(bC.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:VT(e,`input`),output:VT(e,`output`)}}),e.toJSONSchema=BT(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>kE(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>jE(e,t,n),e.parseAsync=async(t,n)=>AE(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>ME(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>NE(e,t,n),e.decode=(t,n)=>PE(e,t,n),e.encodeAsync=async(t,n)=>FE(e,t,n),e.decodeAsync=async(t,n)=>IE(e,t,n),e.safeEncode=(t,n)=>LE(e,t,n),e.safeDecode=(t,n)=>RE(e,t,n),e.safeEncodeAsync=async(t,n)=>zE(e,t,n),e.safeDecodeAsync=async(t,n)=>BE(e,t,n),HE(e,`ZodType`,{check(...e){let t=this.def;return this.clone(ix(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return dx(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(dD(e,t))},superRefine(e,t){return this.check(fD(e,t))},overwrite(e){return this.check(CT(e))},optional(){return tD(this)},exactOptional(){return nD(this)},nullable(){return rD(this)},nullish(){return tD(rD(this))},nonoptional(e){return oD(this,e)},array(){return X(this)},or(e){return Q([this,e])},and(e){return ZE(this,e)},transform(e){return cD(this,eD(e))},default(e){return iD(this,e)},prefault(e){return aD(this,e)},catch(e){return sD(this,e)},pipe(e){return cD(this,e)},readonly(){return lD(this)},describe(e){let t=this.clone();return Dw.add(t,{description:e}),t},meta(...e){if(e.length===0)return Dw.get(this);let t=this.clone();return Dw.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,"description",{get(){return Dw.get(e)?.description},configurable:!0}),e)),gD=K(`_ZodString`,(e,t)=>{xC.init(e,t),hD.init(e,t),e._zod.processJSONSchema=(t,n,r)=>WT(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,HE(e,`_ZodString`,{regex(...e){return this.check(_T(...e))},includes(...e){return this.check(bT(...e))},startsWith(...e){return this.check(xT(...e))},endsWith(...e){return this.check(ST(...e))},min(...e){return this.check(hT(...e))},max(...e){return this.check(mT(...e))},length(...e){return this.check(gT(...e))},nonempty(...e){return this.check(hT(1,...e))},lowercase(e){return this.check(vT(e))},uppercase(e){return this.check(yT(e))},trim(){return this.check(TT())},normalize(...e){return this.check(wT(...e))},toLowerCase(){return this.check(ET())},toUpperCase(){return this.check(DT())},slugify(){return this.check(OT())}})}),_D=K(`ZodString`,(e,t)=>{xC.init(e,t),gD.init(e,t),e.email=t=>e.check(Aw(yD,t)),e.url=t=>e.check(Iw(SD,t)),e.jwt=t=>e.check(Zw(LD,t)),e.emoji=t=>e.check(Lw(CD,t)),e.guid=t=>e.check(jw(bD,t)),e.uuid=t=>e.check(Mw(xD,t)),e.uuidv4=t=>e.check(Nw(xD,t)),e.uuidv6=t=>e.check(Pw(xD,t)),e.uuidv7=t=>e.check(Fw(xD,t)),e.nanoid=t=>e.check(Rw(wD,t)),e.guid=t=>e.check(jw(bD,t)),e.cuid=t=>e.check(zw(TD,t)),e.cuid2=t=>e.check(Bw(ED,t)),e.ulid=t=>e.check(Vw(DD,t)),e.base64=t=>e.check(Jw(PD,t)),e.base64url=t=>e.check(Yw(FD,t)),e.xid=t=>e.check(Hw(OD,t)),e.ksuid=t=>e.check(Uw(kD,t)),e.ipv4=t=>e.check(Ww(AD,t)),e.ipv6=t=>e.check(Gw(jD,t)),e.cidrv4=t=>e.check(Kw(MD,t)),e.cidrv6=t=>e.check(qw(ND,t)),e.e164=t=>e.check(Xw(ID,t)),e.datetime=t=>e.check(_E(t)),e.date=t=>e.check(vE(t)),e.time=t=>e.check(yE(t)),e.duration=t=>e.check(bE(t))}),vD=K(`ZodStringFormat`,(e,t)=>{SC.init(e,t),gD.init(e,t)}),yD=K(`ZodEmail`,(e,t)=>{TC.init(e,t),vD.init(e,t)}),bD=K(`ZodGUID`,(e,t)=>{CC.init(e,t),vD.init(e,t)}),xD=K(`ZodUUID`,(e,t)=>{wC.init(e,t),vD.init(e,t)}),SD=K(`ZodURL`,(e,t)=>{EC.init(e,t),vD.init(e,t)}),CD=K(`ZodEmoji`,(e,t)=>{DC.init(e,t),vD.init(e,t)}),wD=K(`ZodNanoID`,(e,t)=>{OC.init(e,t),vD.init(e,t)}),TD=K(`ZodCUID`,(e,t)=>{kC.init(e,t),vD.init(e,t)}),ED=K(`ZodCUID2`,(e,t)=>{AC.init(e,t),vD.init(e,t)}),DD=K(`ZodULID`,(e,t)=>{jC.init(e,t),vD.init(e,t)}),OD=K(`ZodXID`,(e,t)=>{MC.init(e,t),vD.init(e,t)}),kD=K(`ZodKSUID`,(e,t)=>{NC.init(e,t),vD.init(e,t)}),AD=K(`ZodIPv4`,(e,t)=>{RC.init(e,t),vD.init(e,t)}),jD=K(`ZodIPv6`,(e,t)=>{zC.init(e,t),vD.init(e,t)}),MD=K(`ZodCIDRv4`,(e,t)=>{BC.init(e,t),vD.init(e,t)}),ND=K(`ZodCIDRv6`,(e,t)=>{VC.init(e,t),vD.init(e,t)}),PD=K(`ZodBase64`,(e,t)=>{HC.init(e,t),vD.init(e,t)}),FD=K(`ZodBase64URL`,(e,t)=>{UC.init(e,t),vD.init(e,t)}),ID=K(`ZodE164`,(e,t)=>{WC.init(e,t),vD.init(e,t)}),LD=K(`ZodJWT`,(e,t)=>{GC.init(e,t),vD.init(e,t)}),RD=K(`ZodNumber`,(e,t)=>{KC.init(e,t),hD.init(e,t),e._zod.processJSONSchema=(t,n,r)=>GT(e,t,n,r),HE(e,`ZodNumber`,{gt(e,t){return this.check(dT(e,t))},gte(e,t){return this.check(fT(e,t))},min(e,t){return this.check(fT(e,t))},lt(e,t){return this.check(lT(e,t))},lte(e,t){return this.check(uT(e,t))},max(e,t){return this.check(uT(e,t))},int(e){return this.check(UE(e))},safe(e){return this.check(UE(e))},positive(e){return this.check(dT(0,e))},nonnegative(e){return this.check(fT(0,e))},negative(e){return this.check(lT(0,e))},nonpositive(e){return this.check(uT(0,e))},multipleOf(e,t){return this.check(pT(e,t))},step(e,t){return this.check(pT(e,t))},finite(){return this}});let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null}),zD=K(`ZodNumberFormat`,(e,t)=>{qC.init(e,t),RD.init(e,t)}),BD=K(`ZodBoolean`,(e,t)=>{JC.init(e,t),hD.init(e,t),e._zod.processJSONSchema=(t,n,r)=>KT(e,t,n,r)}),VD=K(`ZodUndefined`,(e,t)=>{YC.init(e,t),hD.init(e,t),e._zod.processJSONSchema=(t,n,r)=>JT(e,t,n,r)}),HD=K(`ZodNull`,(e,t)=>{XC.init(e,t),hD.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qT(e,t,n,r)}),UD=K(`ZodUnknown`,(e,t)=>{ZC.init(e,t),hD.init(e,t),e._zod.processJSONSchema=(t,n,r)=>XT(e,t,n,r)}),WD=K(`ZodNever`,(e,t)=>{QC.init(e,t),hD.init(e,t),e._zod.processJSONSchema=(t,n,r)=>YT(e,t,n,r)}),GD=K(`ZodArray`,(e,t)=>{$C.init(e,t),hD.init(e,t),e._zod.processJSONSchema=(t,n,r)=>tE(e,t,n,r),e.element=t.element,HE(e,`ZodArray`,{min(e,t){return this.check(hT(e,t))},nonempty(e){return this.check(hT(1,e))},max(e,t){return this.check(mT(e,t))},length(e,t){return this.check(gT(e,t))},unwrap(){return this.element}})}),KD=K(`ZodObject`,(e,t)=>{tw.init(e,t),hD.init(e,t),e._zod.processJSONSchema=(t,n,r)=>nE(e,t,n,r),nx(e,`shape`,()=>t.shape),HE(e,`ZodObject`,{keyof(){return $E(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:qE()})},loose(){return this.clone({...this._zod.def,catchall:qE()})},strict(){return this.clone({...this._zod.def,catchall:JE()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return gx(this,e)},safeExtend(e){return _x(this,e)},merge(e){return vx(this,e)},pick(e){return mx(this,e)},omit(e){return hx(this,e)},partial(...e){return yx(eO,this,e[0])},required(...e){return bx(aO,this,e[0])}})}),qD=K(`ZodUnion`,(e,t)=>{nw.init(e,t),hD.init(e,t),e._zod.processJSONSchema=(t,n,r)=>rE(e,t,n,r),e.options=t.options}),JD=K(`ZodDiscriminatedUnion`,(e,t)=>{qD.init(e,t),rw.init(e,t)}),YD=K(`ZodIntersection`,(e,t)=>{iw.init(e,t),hD.init(e,t),e._zod.processJSONSchema=(t,n,r)=>iE(e,t,n,r)}),XD=K(`ZodRecord`,(e,t)=>{aw.init(e,t),hD.init(e,t),e._zod.processJSONSchema=(t,n,r)=>aE(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType}),ZD=K(`ZodEnum`,(e,t)=>{ow.init(e,t),hD.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ZT(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new ZD({...t,checks:[],...q(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new ZD({...t,checks:[],...q(r),entries:i})}}),QD=K(`ZodLiteral`,(e,t)=>{sw.init(e,t),hD.init(e,t),e._zod.processJSONSchema=(t,n,r)=>QT(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})}),$D=K(`ZodTransform`,(e,t)=>{cw.init(e,t),hD.init(e,t),e._zod.processJSONSchema=(t,n,r)=>eE(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Kb(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Ox(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(Ox(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=i,n.fallback=!0,n)}}),eO=K(`ZodOptional`,(e,t)=>{lw.init(e,t),hD.init(e,t),e._zod.processJSONSchema=(t,n,r)=>pE(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}),tO=K(`ZodExactOptional`,(e,t)=>{uw.init(e,t),hD.init(e,t),e._zod.processJSONSchema=(t,n,r)=>pE(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}),nO=K(`ZodNullable`,(e,t)=>{dw.init(e,t),hD.init(e,t),e._zod.processJSONSchema=(t,n,r)=>oE(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}),rO=K(`ZodDefault`,(e,t)=>{fw.init(e,t),hD.init(e,t),e._zod.processJSONSchema=(t,n,r)=>cE(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap}),iO=K(`ZodPrefault`,(e,t)=>{pw.init(e,t),hD.init(e,t),e._zod.processJSONSchema=(t,n,r)=>lE(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}),aO=K(`ZodNonOptional`,(e,t)=>{mw.init(e,t),hD.init(e,t),e._zod.processJSONSchema=(t,n,r)=>sE(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}),oO=K(`ZodCatch`,(e,t)=>{hw.init(e,t),hD.init(e,t),e._zod.processJSONSchema=(t,n,r)=>uE(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap}),sO=K(`ZodPipe`,(e,t)=>{gw.init(e,t),hD.init(e,t),e._zod.processJSONSchema=(t,n,r)=>dE(e,t,n,r),e.in=t.in,e.out=t.out}),cO=K(`ZodPreprocess`,(e,t)=>{sO.init(e,t),_w.init(e,t)}),lO=K(`ZodReadonly`,(e,t)=>{vw.init(e,t),hD.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fE(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}),uO=K(`ZodCustom`,(e,t)=>{yw.init(e,t),hD.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$T(e,t,n,r)})})),fO,pO=a((()=>{hE(),fO||={}})),mO=a((()=>{hE(),dO(),gE(),OE(),VE(),pO(),Cw(),mE(),Ow(),gE(),TE(),dO(),Px(),Ub(xw())})),hO=a((()=>{mO(),mO()})),gO=a((()=>{hO()}));gO();var _O=`io.modelcontextprotocol/related-task`,vO=uD(e=>e!==null&&(typeof e==`object`||typeof e==`function`)),yO=Q([J(),Y().int()]),bO=J();YE({ttl:Y().optional(),pollInterval:Y().optional()});var xO=Z({ttl:Y().optional()}),SO=Z({taskId:J()}),CO=YE({progressToken:yO.optional(),[_O]:SO.optional()}),wO=Z({_meta:CO.optional()}),TO=wO.extend({task:xO.optional()}),EO=e=>TO.safeParse(e).success,DO=Z({method:J(),params:wO.loose().optional()}),OO=Z({_meta:CO.optional()}),kO=Z({method:J(),params:OO.loose().optional()}),AO=YE({_meta:CO.optional()}),jO=Q([J(),Y().int()]),MO=Z({jsonrpc:$(`2.0`),id:jO,...DO.shape}).strict(),NO=e=>MO.safeParse(e).success,PO=Z({jsonrpc:$(`2.0`),...kO.shape}).strict(),FO=e=>PO.safeParse(e).success,IO=Z({jsonrpc:$(`2.0`),id:jO,result:AO}).strict(),LO=e=>IO.safeParse(e).success,RO;(function(e){e[e.ConnectionClosed=-32e3]=`ConnectionClosed`,e[e.RequestTimeout=-32001]=`RequestTimeout`,e[e.ParseError=-32700]=`ParseError`,e[e.InvalidRequest=-32600]=`InvalidRequest`,e[e.MethodNotFound=-32601]=`MethodNotFound`,e[e.InvalidParams=-32602]=`InvalidParams`,e[e.InternalError=-32603]=`InternalError`,e[e.UrlElicitationRequired=-32042]=`UrlElicitationRequired`})(RO||={});var zO=Z({jsonrpc:$(`2.0`),id:jO.optional(),error:Z({code:Y().int(),message:J(),data:qE().optional()})}).strict(),BO=e=>zO.safeParse(e).success;Q([MO,PO,IO,zO]),Q([IO,zO]);var VO=AO.strict(),HO=OO.extend({requestId:jO.optional(),reason:J().optional()}),UO=kO.extend({method:$(`notifications/cancelled`),params:HO}),WO=Z({icons:X(Z({src:J(),mimeType:J().optional(),sizes:X(J()).optional(),theme:$E([`light`,`dark`]).optional()})).optional()}),GO=Z({name:J(),title:J().optional()}),KO=GO.extend({...GO.shape,...WO.shape,version:J(),websiteUrl:J().optional(),description:J().optional()}),qO=pD(e=>e&&typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,ZE(Z({form:ZE(Z({applyDefaults:WE().optional()}),QE(J(),qE())).optional(),url:vO.optional()}),QE(J(),qE()).optional())),JO=YE({list:vO.optional(),cancel:vO.optional(),requests:YE({sampling:YE({createMessage:vO.optional()}).optional(),elicitation:YE({create:vO.optional()}).optional()}).optional()}),YO=YE({list:vO.optional(),cancel:vO.optional(),requests:YE({tools:YE({call:vO.optional()}).optional()}).optional()}),XO=Z({experimental:QE(J(),vO).optional(),sampling:Z({context:vO.optional(),tools:vO.optional()}).optional(),elicitation:qO.optional(),roots:Z({listChanged:WE().optional()}).optional(),tasks:JO.optional(),extensions:QE(J(),vO).optional()}),ZO=wO.extend({protocolVersion:J(),capabilities:XO,clientInfo:KO}),QO=DO.extend({method:$(`initialize`),params:ZO}),$O=Z({experimental:QE(J(),vO).optional(),logging:vO.optional(),completions:vO.optional(),prompts:Z({listChanged:WE().optional()}).optional(),resources:Z({subscribe:WE().optional(),listChanged:WE().optional()}).optional(),tools:Z({listChanged:WE().optional()}).optional(),tasks:YO.optional(),extensions:QE(J(),vO).optional()}),ek=AO.extend({protocolVersion:J(),capabilities:$O,serverInfo:KO,instructions:J().optional()}),tk=kO.extend({method:$(`notifications/initialized`),params:OO.optional()}),nk=DO.extend({method:$(`ping`),params:wO.optional()}),rk=Z({progress:Y(),total:tD(Y()),message:tD(J())}),ik=Z({...OO.shape,...rk.shape,progressToken:yO}),ak=kO.extend({method:$(`notifications/progress`),params:ik}),ok=wO.extend({cursor:bO.optional()}),sk=DO.extend({params:ok.optional()}),ck=AO.extend({nextCursor:bO.optional()}),lk=$E([`working`,`input_required`,`completed`,`failed`,`cancelled`]),uk=Z({taskId:J(),status:lk,ttl:Q([Y(),KE()]),createdAt:J(),lastUpdatedAt:J(),pollInterval:tD(Y()),statusMessage:tD(J())}),dk=AO.extend({task:uk}),fk=OO.merge(uk),pk=kO.extend({method:$(`notifications/tasks/status`),params:fk}),mk=DO.extend({method:$(`tasks/get`),params:wO.extend({taskId:J()})}),hk=AO.merge(uk),gk=DO.extend({method:$(`tasks/result`),params:wO.extend({taskId:J()})});AO.loose();var _k=sk.extend({method:$(`tasks/list`)}),vk=ck.extend({tasks:X(uk)}),yk=DO.extend({method:$(`tasks/cancel`),params:wO.extend({taskId:J()})}),bk=AO.merge(uk),xk=Z({uri:J(),mimeType:tD(J()),_meta:QE(J(),qE()).optional()}),Sk=xk.extend({text:J()}),Ck=J().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:`Invalid Base64 string`}),wk=xk.extend({blob:Ck}),Tk=$E([`user`,`assistant`]),Ek=Z({audience:X(Tk).optional(),priority:Y().min(0).max(1).optional(),lastModified:_E({offset:!0}).optional()}),Dk=Z({...GO.shape,...WO.shape,uri:J(),description:tD(J()),mimeType:tD(J()),size:tD(Y()),annotations:Ek.optional(),_meta:tD(YE({}))}),Ok=Z({...GO.shape,...WO.shape,uriTemplate:J(),description:tD(J()),mimeType:tD(J()),annotations:Ek.optional(),_meta:tD(YE({}))}),kk=sk.extend({method:$(`resources/list`)}),Ak=ck.extend({resources:X(Dk)}),jk=sk.extend({method:$(`resources/templates/list`)}),Mk=ck.extend({resourceTemplates:X(Ok)}),Nk=wO.extend({uri:J()}),Pk=Nk,Fk=DO.extend({method:$(`resources/read`),params:Pk}),Ik=AO.extend({contents:X(Q([Sk,wk]))}),Lk=kO.extend({method:$(`notifications/resources/list_changed`),params:OO.optional()}),Rk=Nk,zk=DO.extend({method:$(`resources/subscribe`),params:Rk}),Bk=Nk,Vk=DO.extend({method:$(`resources/unsubscribe`),params:Bk}),Hk=OO.extend({uri:J()}),Uk=kO.extend({method:$(`notifications/resources/updated`),params:Hk}),Wk=Z({name:J(),description:tD(J()),required:tD(WE())}),Gk=Z({...GO.shape,...WO.shape,description:tD(J()),arguments:tD(X(Wk)),_meta:tD(YE({}))}),Kk=sk.extend({method:$(`prompts/list`)}),qk=ck.extend({prompts:X(Gk)}),Jk=wO.extend({name:J(),arguments:QE(J(),J()).optional()}),Yk=DO.extend({method:$(`prompts/get`),params:Jk}),Xk=Z({type:$(`text`),text:J(),annotations:Ek.optional(),_meta:QE(J(),qE()).optional()}),Zk=Z({type:$(`image`),data:Ck,mimeType:J(),annotations:Ek.optional(),_meta:QE(J(),qE()).optional()}),Qk=Z({type:$(`audio`),data:Ck,mimeType:J(),annotations:Ek.optional(),_meta:QE(J(),qE()).optional()}),$k=Z({type:$(`tool_use`),name:J(),id:J(),input:QE(J(),qE()),_meta:QE(J(),qE()).optional()}),eA=Z({type:$(`resource`),resource:Q([Sk,wk]),annotations:Ek.optional(),_meta:QE(J(),qE()).optional()}),tA=Dk.extend({type:$(`resource_link`)}),nA=Q([Xk,Zk,Qk,tA,eA]),rA=Z({role:Tk,content:nA}),iA=AO.extend({description:J().optional(),messages:X(rA)}),aA=kO.extend({method:$(`notifications/prompts/list_changed`),params:OO.optional()}),oA=Z({title:J().optional(),readOnlyHint:WE().optional(),destructiveHint:WE().optional(),idempotentHint:WE().optional(),openWorldHint:WE().optional()}),sA=Z({taskSupport:$E([`required`,`optional`,`forbidden`]).optional()}),cA=Z({...GO.shape,...WO.shape,description:J().optional(),inputSchema:Z({type:$(`object`),properties:QE(J(),vO).optional(),required:X(J()).optional()}).catchall(qE()),outputSchema:Z({type:$(`object`),properties:QE(J(),vO).optional(),required:X(J()).optional()}).catchall(qE()).optional(),annotations:oA.optional(),execution:sA.optional(),_meta:QE(J(),qE()).optional()}),lA=sk.extend({method:$(`tools/list`)}),uA=ck.extend({tools:X(cA)}),dA=AO.extend({content:X(nA).default([]),structuredContent:QE(J(),qE()).optional(),isError:WE().optional()});dA.or(AO.extend({toolResult:qE()}));var fA=TO.extend({name:J(),arguments:QE(J(),qE()).optional()}),pA=DO.extend({method:$(`tools/call`),params:fA}),mA=kO.extend({method:$(`notifications/tools/list_changed`),params:OO.optional()});Z({autoRefresh:WE().default(!0),debounceMs:Y().int().nonnegative().default(300)});var hA=$E([`debug`,`info`,`notice`,`warning`,`error`,`critical`,`alert`,`emergency`]),gA=wO.extend({level:hA}),_A=DO.extend({method:$(`logging/setLevel`),params:gA}),vA=OO.extend({level:hA,logger:J().optional(),data:qE()}),yA=kO.extend({method:$(`notifications/message`),params:vA}),bA=Z({hints:X(Z({name:J().optional()})).optional(),costPriority:Y().min(0).max(1).optional(),speedPriority:Y().min(0).max(1).optional(),intelligencePriority:Y().min(0).max(1).optional()}),xA=Z({mode:$E([`auto`,`required`,`none`]).optional()}),SA=Z({type:$(`tool_result`),toolUseId:J().describe(`The unique identifier for the corresponding tool call.`),content:X(nA).default([]),structuredContent:Z({}).loose().optional(),isError:WE().optional(),_meta:QE(J(),qE()).optional()}),CA=XE(`type`,[Xk,Zk,Qk]),wA=XE(`type`,[Xk,Zk,Qk,$k,SA]),TA=Z({role:Tk,content:Q([wA,X(wA)]),_meta:QE(J(),qE()).optional()}),EA=TO.extend({messages:X(TA),modelPreferences:bA.optional(),systemPrompt:J().optional(),includeContext:$E([`none`,`thisServer`,`allServers`]).optional(),temperature:Y().optional(),maxTokens:Y().int(),stopSequences:X(J()).optional(),metadata:vO.optional(),tools:X(cA).optional(),toolChoice:xA.optional()}),DA=DO.extend({method:$(`sampling/createMessage`),params:EA}),OA=AO.extend({model:J(),stopReason:tD($E([`endTurn`,`stopSequence`,`maxTokens`]).or(J())),role:Tk,content:CA}),kA=AO.extend({model:J(),stopReason:tD($E([`endTurn`,`stopSequence`,`maxTokens`,`toolUse`]).or(J())),role:Tk,content:Q([wA,X(wA)])}),AA=Z({type:$(`boolean`),title:J().optional(),description:J().optional(),default:WE().optional()}),jA=Z({type:$(`string`),title:J().optional(),description:J().optional(),minLength:Y().optional(),maxLength:Y().optional(),format:$E([`email`,`uri`,`date`,`date-time`]).optional(),default:J().optional()}),MA=Z({type:$E([`number`,`integer`]),title:J().optional(),description:J().optional(),minimum:Y().optional(),maximum:Y().optional(),default:Y().optional()}),NA=Z({type:$(`string`),title:J().optional(),description:J().optional(),enum:X(J()),default:J().optional()}),PA=Z({type:$(`string`),title:J().optional(),description:J().optional(),oneOf:X(Z({const:J(),title:J()})),default:J().optional()}),FA=Q([Q([Z({type:$(`string`),title:J().optional(),description:J().optional(),enum:X(J()),enumNames:X(J()).optional(),default:J().optional()}),Q([NA,PA]),Q([Z({type:$(`array`),title:J().optional(),description:J().optional(),minItems:Y().optional(),maxItems:Y().optional(),items:Z({type:$(`string`),enum:X(J())}),default:X(J()).optional()}),Z({type:$(`array`),title:J().optional(),description:J().optional(),minItems:Y().optional(),maxItems:Y().optional(),items:Z({anyOf:X(Z({const:J(),title:J()}))}),default:X(J()).optional()})])]),AA,jA,MA]),IA=Q([TO.extend({mode:$(`form`).optional(),message:J(),requestedSchema:Z({type:$(`object`),properties:QE(J(),FA),required:X(J()).optional()})}),TO.extend({mode:$(`url`),message:J(),elicitationId:J(),url:J().url()})]),LA=DO.extend({method:$(`elicitation/create`),params:IA}),RA=OO.extend({elicitationId:J()}),zA=kO.extend({method:$(`notifications/elicitation/complete`),params:RA}),BA=AO.extend({action:$E([`accept`,`decline`,`cancel`]),content:pD(e=>e===null?void 0:e,QE(J(),Q([J(),Y(),WE(),X(J())])).optional())}),VA=Z({type:$(`ref/resource`),uri:J()}),HA=Z({type:$(`ref/prompt`),name:J()}),UA=wO.extend({ref:Q([HA,VA]),argument:Z({name:J(),value:J()}),context:Z({arguments:QE(J(),J()).optional()}).optional()}),WA=DO.extend({method:$(`completion/complete`),params:UA}),GA=AO.extend({completion:YE({values:X(J()).max(100),total:tD(Y().int()),hasMore:tD(WE())})}),KA=Z({uri:J().startsWith(`file://`),name:J().optional(),_meta:QE(J(),qE()).optional()}),qA=DO.extend({method:$(`roots/list`),params:wO.optional()}),JA=AO.extend({roots:X(KA)}),YA=kO.extend({method:$(`notifications/roots/list_changed`),params:OO.optional()});Q([nk,QO,WA,_A,Yk,Kk,kk,jk,Fk,zk,Vk,pA,lA,mk,gk,_k,yk]),Q([UO,ak,tk,YA,pk]),Q([VO,OA,kA,BA,JA,hk,vk,dk]),Q([nk,DA,LA,qA,mk,gk,_k,yk]),Q([UO,ak,yA,Uk,Lk,mA,aA,pk,zA]),Q([VO,ek,GA,iA,qk,Ak,Mk,Ik,dA,uA,hk,vk,dk]);var XA=class e extends Error{constructor(e,t,n){super(`MCP error ${e}: ${t}`),this.code=e,this.data=n,this.name=`McpError`}static fromError(t,n,r){if(t===RO.UrlElicitationRequired&&r){let e=r;if(e.elicitations)return new ZA(e.elicitations,n)}return new e(t,n,r)}},ZA=class extends XA{constructor(e,t=`URL elicitation${e.length>1?`s`:``} required`){super(RO.UrlElicitationRequired,t,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}};PT(),Px(),FS(),Jb(),tS(),mE(),Bx(),init_locales(),hE(),Ow();function QA(e){return!!e._zod}function $A(e,t){return QA(e)?Wx(e,t):e.safeParse(t)}function ej(e){if(!e)return;let t;if(t=QA(e)?e._zod?.def?.shape:e.shape,t){if(typeof t==`function`)try{return t()}catch{return}return t}}function tj(e){if(QA(e)){let t=e._zod?.def;if(t){if(t.value!==void 0)return t.value;if(Array.isArray(t.values)&&t.values.length>0)return t.values[0]}}let t=e._def;if(t){if(t.value!==void 0)return t.value;if(Array.isArray(t.values)&&t.values.length>0)return t.values[0]}let n=e.value;if(n!==void 0)return n}function nj(e){return e===`completed`||e===`failed`||e===`cancelled`}function rj(e){let t=ej(e)?.method;if(!t)throw Error(`Schema is missing a method literal`);let n=tj(t);if(typeof n!=`string`)throw Error(`Schema method literal must be a string`);return n}function ij(e,t){let n=$A(e,t);if(!n.success)throw n.error;return n.data}var aj=class{constructor(e){this._options=e,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(UO,e=>{this._oncancel(e)}),this.setNotificationHandler(ak,e=>{this._onprogress(e)}),this.setRequestHandler(nk,e=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(mk,async(e,t)=>{let n=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!n)throw new XA(RO.InvalidParams,`Failed to retrieve task: Task not found`);return{...n}}),this.setRequestHandler(gk,async(e,t)=>{let n=async()=>{let r=e.params.taskId;if(this._taskMessageQueue){let e;for(;e=await this._taskMessageQueue.dequeue(r,t.sessionId);){if(e.type===`response`||e.type===`error`){let t=e.message,n=t.id,r=this._requestResolvers.get(n);if(r)if(this._requestResolvers.delete(n),e.type===`response`)r(t);else{let e=t;r(new XA(e.error.code,e.error.message,e.error.data))}else{let t=e.type===`response`?`Response`:`Error`;this._onerror(Error(`${t} handler missing for request ${n}`))}continue}await this._transport?.send(e.message,{relatedRequestId:t.requestId})}}let i=await this._taskStore.getTask(r,t.sessionId);if(!i)throw new XA(RO.InvalidParams,`Task not found: ${r}`);if(!nj(i.status))return await this._waitForTaskUpdate(r,t.signal),await n();if(nj(i.status)){let e=await this._taskStore.getTaskResult(r,t.sessionId);return this._clearTaskQueue(r),{...e,_meta:{...e._meta,[_O]:{taskId:r}}}}return await n()};return await n()}),this.setRequestHandler(_k,async(e,t)=>{try{let{tasks:n,nextCursor:r}=await this._taskStore.listTasks(e.params?.cursor,t.sessionId);return{tasks:n,nextCursor:r,_meta:{}}}catch(e){throw new XA(RO.InvalidParams,`Failed to list tasks: ${e instanceof Error?e.message:String(e)}`)}}),this.setRequestHandler(yk,async(e,t)=>{try{let n=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!n)throw new XA(RO.InvalidParams,`Task not found: ${e.params.taskId}`);if(nj(n.status))throw new XA(RO.InvalidParams,`Cannot cancel task in terminal status: ${n.status}`);await this._taskStore.updateTaskStatus(e.params.taskId,`cancelled`,`Client cancelled task execution.`,t.sessionId),this._clearTaskQueue(e.params.taskId);let r=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!r)throw new XA(RO.InvalidParams,`Task not found after cancellation: ${e.params.taskId}`);return{_meta:{},...r}}catch(e){throw e instanceof XA?e:new XA(RO.InvalidRequest,`Failed to cancel task: ${e instanceof Error?e.message:String(e)}`)}}))}async _oncancel(e){e.params.requestId&&this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,t,n,r,i=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(r,t),startTime:Date.now(),timeout:t,maxTotalTimeout:n,resetTimeoutOnProgress:i,onTimeout:r})}_resetTimeout(e){let t=this._timeoutInfo.get(e);if(!t)return!1;let n=Date.now()-t.startTime;if(t.maxTotalTimeout&&n>=t.maxTotalTimeout)throw this._timeoutInfo.delete(e),XA.fromError(RO.RequestTimeout,`Maximum total timeout exceeded`,{maxTotalTimeout:t.maxTotalTimeout,totalElapsed:n});return clearTimeout(t.timeoutId),t.timeoutId=setTimeout(t.onTimeout,t.timeout),!0}_cleanupTimeout(e){let t=this._timeoutInfo.get(e);t&&(clearTimeout(t.timeoutId),this._timeoutInfo.delete(e))}async connect(e){if(this._transport)throw Error(`Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.`);this._transport=e;let t=this.transport?.onclose;this._transport.onclose=()=>{t?.(),this._onclose()};let n=this.transport?.onerror;this._transport.onerror=e=>{n?.(e),this._onerror(e)};let r=this._transport?.onmessage;this._transport.onmessage=(e,t)=>{r?.(e,t),LO(e)||BO(e)?this._onresponse(e):NO(e)?this._onrequest(e,t):FO(e)?this._onnotification(e):this._onerror(Error(`Unknown message type: ${JSON.stringify(e)}`))},await this._transport.start()}_onclose(){let e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(let e of this._timeoutInfo.values())clearTimeout(e.timeoutId);this._timeoutInfo.clear();for(let e of this._requestHandlerAbortControllers.values())e.abort();this._requestHandlerAbortControllers.clear();let t=XA.fromError(RO.ConnectionClosed,`Connection closed`);this._transport=void 0,this.onclose?.();for(let n of e.values())n(t)}_onerror(e){this.onerror?.(e)}_onnotification(e){let t=this._notificationHandlers.get(e.method)??this.fallbackNotificationHandler;t!==void 0&&Promise.resolve().then(()=>t(e)).catch(e=>this._onerror(Error(`Uncaught error in notification handler: ${e}`)))}_onrequest(e,t){let n=this._requestHandlers.get(e.method)??this.fallbackRequestHandler,r=this._transport,i=e.params?._meta?.[_O]?.taskId;if(n===void 0){let t={jsonrpc:`2.0`,id:e.id,error:{code:RO.MethodNotFound,message:`Method not found`}};i&&this._taskMessageQueue?this._enqueueTaskMessage(i,{type:`error`,message:t,timestamp:Date.now()},r?.sessionId).catch(e=>this._onerror(Error(`Failed to enqueue error response: ${e}`))):r?.send(t).catch(e=>this._onerror(Error(`Failed to send an error response: ${e}`)));return}let a=new AbortController;this._requestHandlerAbortControllers.set(e.id,a);let o=EO(e.params)?e.params.task:void 0,s=this._taskStore?this.requestTaskStore(e,r?.sessionId):void 0,c={signal:a.signal,sessionId:r?.sessionId,_meta:e.params?._meta,sendNotification:async t=>{if(a.signal.aborted)return;let n={relatedRequestId:e.id};i&&(n.relatedTask={taskId:i}),await this.notification(t,n)},sendRequest:async(t,n,r)=>{if(a.signal.aborted)throw new XA(RO.ConnectionClosed,`Request was cancelled`);let o={...r,relatedRequestId:e.id};i&&!o.relatedTask&&(o.relatedTask={taskId:i});let c=o.relatedTask?.taskId??i;return c&&s&&await s.updateTaskStatus(c,`input_required`),await this.request(t,n,o)},authInfo:t?.authInfo,requestId:e.id,requestInfo:t?.requestInfo,taskId:i,taskStore:s,taskRequestedTtl:o?.ttl,closeSSEStream:t?.closeSSEStream,closeStandaloneSSEStream:t?.closeStandaloneSSEStream};Promise.resolve().then(()=>{o&&this.assertTaskHandlerCapability(e.method)}).then(()=>n(e,c)).then(async t=>{if(a.signal.aborted)return;let n={result:t,jsonrpc:`2.0`,id:e.id};i&&this._taskMessageQueue?await this._enqueueTaskMessage(i,{type:`response`,message:n,timestamp:Date.now()},r?.sessionId):await r?.send(n)},async t=>{if(a.signal.aborted)return;let n={jsonrpc:`2.0`,id:e.id,error:{code:Number.isSafeInteger(t.code)?t.code:RO.InternalError,message:t.message??`Internal error`,...t.data!==void 0&&{data:t.data}}};i&&this._taskMessageQueue?await this._enqueueTaskMessage(i,{type:`error`,message:n,timestamp:Date.now()},r?.sessionId):await r?.send(n)}).catch(e=>this._onerror(Error(`Failed to send response: ${e}`))).finally(()=>{this._requestHandlerAbortControllers.get(e.id)===a&&this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){let{progressToken:t,...n}=e.params,r=Number(t),i=this._progressHandlers.get(r);if(!i){this._onerror(Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let a=this._responseHandlers.get(r),o=this._timeoutInfo.get(r);if(o&&a&&o.resetTimeoutOnProgress)try{this._resetTimeout(r)}catch(e){this._responseHandlers.delete(r),this._progressHandlers.delete(r),this._cleanupTimeout(r),a(e);return}i(n)}_onresponse(e){let t=Number(e.id),n=this._requestResolvers.get(t);if(n){this._requestResolvers.delete(t),LO(e)?n(e):n(new XA(e.error.code,e.error.message,e.error.data));return}let r=this._responseHandlers.get(t);if(r===void 0){this._onerror(Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}this._responseHandlers.delete(t),this._cleanupTimeout(t);let i=!1;if(LO(e)&&e.result&&typeof e.result==`object`){let n=e.result;if(n.task&&typeof n.task==`object`){let e=n.task;typeof e.taskId==`string`&&(i=!0,this._taskProgressTokens.set(e.taskId,t))}}i||this._progressHandlers.delete(t),LO(e)?r(e):r(XA.fromError(e.error.code,e.error.message,e.error.data))}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(e,t,n){let{task:r}=n??{};if(!r){try{yield{type:`result`,result:await this.request(e,t,n)}}catch(e){yield{type:`error`,error:e instanceof XA?e:new XA(RO.InternalError,String(e))}}return}let i;try{let r=await this.request(e,dk,n);if(r.task)i=r.task.taskId,yield{type:`taskCreated`,task:r.task};else throw new XA(RO.InternalError,`Task creation did not return a task`);for(;;){let e=await this.getTask({taskId:i},n);if(yield{type:`taskStatus`,task:e},nj(e.status)){e.status===`completed`?yield{type:`result`,result:await this.getTaskResult({taskId:i},t,n)}:e.status===`failed`?yield{type:`error`,error:new XA(RO.InternalError,`Task ${i} failed`)}:e.status===`cancelled`&&(yield{type:`error`,error:new XA(RO.InternalError,`Task ${i} was cancelled`)});return}if(e.status===`input_required`){yield{type:`result`,result:await this.getTaskResult({taskId:i},t,n)};return}let r=e.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(e=>setTimeout(e,r)),n?.signal?.throwIfAborted()}}catch(e){yield{type:`error`,error:e instanceof XA?e:new XA(RO.InternalError,String(e))}}}request(e,t,n){let{relatedRequestId:r,resumptionToken:i,onresumptiontoken:a,task:o,relatedTask:s}=n??{};return new Promise((c,l)=>{let u=e=>{l(e)};if(!this._transport){u(Error(`Not connected`));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(e.method),o&&this.assertTaskCapability(e.method)}catch(e){u(e);return}n?.signal?.throwIfAborted();let d=this._requestMessageId++,f={...e,jsonrpc:`2.0`,id:d};n?.onprogress&&(this._progressHandlers.set(d,n.onprogress),f.params={...e.params,_meta:{...e.params?._meta||{},progressToken:d}}),o&&(f.params={...f.params,task:o}),s&&(f.params={...f.params,_meta:{...f.params?._meta||{},[_O]:s}});let p=e=>{this._responseHandlers.delete(d),this._progressHandlers.delete(d),this._cleanupTimeout(d),this._transport?.send({jsonrpc:`2.0`,method:`notifications/cancelled`,params:{requestId:d,reason:String(e)}},{relatedRequestId:r,resumptionToken:i,onresumptiontoken:a}).catch(e=>this._onerror(Error(`Failed to send cancellation: ${e}`))),l(e instanceof XA?e:new XA(RO.RequestTimeout,String(e)))};this._responseHandlers.set(d,e=>{if(!n?.signal?.aborted){if(e instanceof Error)return l(e);try{let n=$A(t,e.result);n.success?c(n.data):l(n.error)}catch(e){l(e)}}}),n?.signal?.addEventListener(`abort`,()=>{p(n?.signal?.reason)});let m=n?.timeout??6e4;this._setupTimeout(d,m,n?.maxTotalTimeout,()=>p(XA.fromError(RO.RequestTimeout,`Request timed out`,{timeout:m})),n?.resetTimeoutOnProgress??!1);let h=s?.taskId;h?(this._requestResolvers.set(d,e=>{let t=this._responseHandlers.get(d);t?t(e):this._onerror(Error(`Response handler missing for side-channeled request ${d}`))}),this._enqueueTaskMessage(h,{type:`request`,message:f,timestamp:Date.now()}).catch(e=>{this._cleanupTimeout(d),l(e)})):this._transport.send(f,{relatedRequestId:r,resumptionToken:i,onresumptiontoken:a}).catch(e=>{this._cleanupTimeout(d),l(e)})})}async getTask(e,t){return this.request({method:`tasks/get`,params:e},hk,t)}async getTaskResult(e,t,n){return this.request({method:`tasks/result`,params:e},t,n)}async listTasks(e,t){return this.request({method:`tasks/list`,params:e},vk,t)}async cancelTask(e,t){return this.request({method:`tasks/cancel`,params:e},bk,t)}async notification(e,t){if(!this._transport)throw Error(`Not connected`);this.assertNotificationCapability(e.method);let n=t?.relatedTask?.taskId;if(n){let r={...e,jsonrpc:`2.0`,params:{...e.params,_meta:{...e.params?._meta||{},[_O]:t.relatedTask}}};await this._enqueueTaskMessage(n,{type:`notification`,message:r,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(e.method)&&!e.params&&!t?.relatedRequestId&&!t?.relatedTask){if(this._pendingDebouncedNotifications.has(e.method))return;this._pendingDebouncedNotifications.add(e.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;let n={...e,jsonrpc:`2.0`};t?.relatedTask&&(n={...n,params:{...n.params,_meta:{...n.params?._meta||{},[_O]:t.relatedTask}}}),this._transport?.send(n,t).catch(e=>this._onerror(e))});return}let r={...e,jsonrpc:`2.0`};t?.relatedTask&&(r={...r,params:{...r.params,_meta:{...r.params?._meta||{},[_O]:t.relatedTask}}}),await this._transport.send(r,t)}setRequestHandler(e,t){let n=rj(e);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(n,r)=>{let i=ij(e,n);return Promise.resolve(t(i,r))})}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,t){let n=rj(e);this._notificationHandlers.set(n,n=>{let r=ij(e,n);return Promise.resolve(t(r))})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}_cleanupTaskProgressHandler(e){let t=this._taskProgressTokens.get(e);t!==void 0&&(this._progressHandlers.delete(t),this._taskProgressTokens.delete(e))}async _enqueueTaskMessage(e,t,n){if(!this._taskStore||!this._taskMessageQueue)throw Error(`Cannot enqueue task message: taskStore and taskMessageQueue are not configured`);let r=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(e,t,n,r)}async _clearTaskQueue(e,t){if(this._taskMessageQueue){let n=await this._taskMessageQueue.dequeueAll(e,t);for(let t of n)if(t.type===`request`&&NO(t.message)){let n=t.message.id,r=this._requestResolvers.get(n);r?(r(new XA(RO.InternalError,`Task cancelled or completed`)),this._requestResolvers.delete(n)):this._onerror(Error(`Resolver missing for request ${n} during task ${e} cleanup`))}}}async _waitForTaskUpdate(e,t){let n=this._options?.defaultTaskPollInterval??1e3;try{let t=await this._taskStore?.getTask(e);t?.pollInterval&&(n=t.pollInterval)}catch{}return new Promise((e,r)=>{if(t.aborted){r(new XA(RO.InvalidRequest,`Request cancelled`));return}let i=setTimeout(e,n);t.addEventListener(`abort`,()=>{clearTimeout(i),r(new XA(RO.InvalidRequest,`Request cancelled`))},{once:!0})})}requestTaskStore(e,t){let n=this._taskStore;if(!n)throw Error(`No task store configured`);return{createTask:async r=>{if(!e)throw Error(`No request provided`);return await n.createTask(r,e.id,{method:e.method,params:e.params},t)},getTask:async e=>{let r=await n.getTask(e,t);if(!r)throw new XA(RO.InvalidParams,`Failed to retrieve task: Task not found`);return r},storeTaskResult:async(e,r,i)=>{await n.storeTaskResult(e,r,i,t);let a=await n.getTask(e,t);if(a){let t=pk.parse({method:`notifications/tasks/status`,params:a});await this.notification(t),nj(a.status)&&this._cleanupTaskProgressHandler(e)}},getTaskResult:e=>n.getTaskResult(e,t),updateTaskStatus:async(e,r,i)=>{let a=await n.getTask(e,t);if(!a)throw new XA(RO.InvalidParams,`Task "${e}" not found - it may have been cleaned up`);if(nj(a.status))throw new XA(RO.InvalidParams,`Cannot update task "${e}" from terminal status "${a.status}" to "${r}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await n.updateTaskStatus(e,r,i,t);let o=await n.getTask(e,t);if(o){let t=pk.parse({method:`notifications/tasks/status`,params:o});await this.notification(t),nj(o.status)&&this._cleanupTaskProgressHandler(e)}},listTasks:e=>n.listTasks(e,t)}}};gO(),(e=>typeof require<`u`?require:typeof Proxy<`u`?new Proxy(e,{get:(e,t)=>(typeof require<`u`?require:e)[t]}):e)(function(e){if(typeof require<`u`)return require.apply(this,arguments);throw Error(`Dynamic require of "`+e+`" is not supported`)});var oj=class extends aj{_registeredMethods=new Set;_eventSlots=new Map;onEventDispatch(e,t){}_ensureEventSlot(e){let t=this._eventSlots.get(e);if(!t){let n=this.eventSchemas[e];if(!n)throw Error(`Unknown event: ${String(e)}`);t={listeners:[]},this._eventSlots.set(e,t);let r=n.shape.method.value;this._registeredMethods.add(r);let i=t;super.setNotificationHandler(n,t=>{let n=t.params;this.onEventDispatch(e,n),i.onHandler?.(n);for(let e of[...i.listeners])e(n)})}return t}setEventHandler(e,t){let n=this._ensureEventSlot(e);n.onHandler&&t&&console.warn(`[MCP Apps] on${String(e)} handler replaced. Use addEventListener("${String(e)}", …) to add multiple listeners without replacing.`),n.onHandler=t}getEventHandler(e){return this._eventSlots.get(e)?.onHandler}addEventListener(e,t){this._ensureEventSlot(e).listeners.push(t)}removeEventListener(e,t){let n=this._eventSlots.get(e);if(!n)return;let r=n.listeners.indexOf(t);r!==-1&&n.listeners.splice(r,1)}setRequestHandler=(e,t)=>{this._assertMethodNotRegistered(e,`setRequestHandler`),super.setRequestHandler(e,t)};setNotificationHandler=(e,t)=>{this._assertMethodNotRegistered(e,`setNotificationHandler`),super.setNotificationHandler(e,t)};warnIfRequestHandlerReplaced(e,t,n){t&&n&&console.warn(`[MCP Apps] ${e} handler replaced. Previous handler will no longer be called.`)}replaceRequestHandler=(e,t)=>{let n=e.shape.method.value;this._registeredMethods.add(n),super.setRequestHandler(e,t)};_assertMethodNotRegistered(e,t){let n=e.shape.method.value;if(this._registeredMethods.has(n))throw Error(`Handler for "${n}" already registered (via ${t}). Use addEventListener() to attach multiple listeners, or the on* setter for replace semantics.`);this._registeredMethods.add(n)}},sj=`2026-01-26`,cj=Q([$(`light`),$(`dark`)]).describe(`Color theme preference for the host environment.`),lj=Q([$(`inline`),$(`fullscreen`),$(`pip`)]).describe(`Display mode for UI presentation.`),uj=QE(Q([$(`--color-background-primary`),$(`--color-background-secondary`),$(`--color-background-tertiary`),$(`--color-background-inverse`),$(`--color-background-ghost`),$(`--color-background-info`),$(`--color-background-danger`),$(`--color-background-success`),$(`--color-background-warning`),$(`--color-background-disabled`),$(`--color-text-primary`),$(`--color-text-secondary`),$(`--color-text-tertiary`),$(`--color-text-inverse`),$(`--color-text-ghost`),$(`--color-text-info`),$(`--color-text-danger`),$(`--color-text-success`),$(`--color-text-warning`),$(`--color-text-disabled`),$(`--color-border-primary`),$(`--color-border-secondary`),$(`--color-border-tertiary`),$(`--color-border-inverse`),$(`--color-border-ghost`),$(`--color-border-info`),$(`--color-border-danger`),$(`--color-border-success`),$(`--color-border-warning`),$(`--color-border-disabled`),$(`--color-ring-primary`),$(`--color-ring-secondary`),$(`--color-ring-inverse`),$(`--color-ring-info`),$(`--color-ring-danger`),$(`--color-ring-success`),$(`--color-ring-warning`),$(`--font-sans`),$(`--font-mono`),$(`--font-weight-normal`),$(`--font-weight-medium`),$(`--font-weight-semibold`),$(`--font-weight-bold`),$(`--font-text-xs-size`),$(`--font-text-sm-size`),$(`--font-text-md-size`),$(`--font-text-lg-size`),$(`--font-heading-xs-size`),$(`--font-heading-sm-size`),$(`--font-heading-md-size`),$(`--font-heading-lg-size`),$(`--font-heading-xl-size`),$(`--font-heading-2xl-size`),$(`--font-heading-3xl-size`),$(`--font-text-xs-line-height`),$(`--font-text-sm-line-height`),$(`--font-text-md-line-height`),$(`--font-text-lg-line-height`),$(`--font-heading-xs-line-height`),$(`--font-heading-sm-line-height`),$(`--font-heading-md-line-height`),$(`--font-heading-lg-line-height`),$(`--font-heading-xl-line-height`),$(`--font-heading-2xl-line-height`),$(`--font-heading-3xl-line-height`),$(`--border-radius-xs`),$(`--border-radius-sm`),$(`--border-radius-md`),$(`--border-radius-lg`),$(`--border-radius-xl`),$(`--border-radius-full`),$(`--border-width-regular`),$(`--shadow-hairline`),$(`--shadow-sm`),$(`--shadow-md`),$(`--shadow-lg`)]).describe(`CSS variable keys available to MCP apps for theming.`).describe(`Style variables for theming MCP apps.
|
|
114
114
|
|
|
115
115
|
Individual style keys are optional - hosts may provide any subset of these values.
|
|
116
116
|
Values are strings containing CSS values (colors, sizes, font stacks, etc.).
|
|
117
117
|
|
|
118
118
|
Note: This type uses \`Record<K, string | undefined>\` rather than \`Partial<Record<K, string>>\`
|
|
119
|
-
for compatibility with Zod schema generation. Both are functionally equivalent for validation.`),Q([J(),
|
|
119
|
+
for compatibility with Zod schema generation. Both are functionally equivalent for validation.`),Q([J(),GE()]).describe(`Style variables for theming MCP apps.
|
|
120
120
|
|
|
121
121
|
Individual style keys are optional - hosts may provide any subset of these values.
|
|
122
122
|
Values are strings containing CSS values (colors, sizes, font stacks, etc.).
|
|
@@ -128,10 +128,10 @@ Individual style keys are optional - hosts may provide any subset of these value
|
|
|
128
128
|
Values are strings containing CSS values (colors, sizes, font stacks, etc.).
|
|
129
129
|
|
|
130
130
|
Note: This type uses \`Record<K, string | undefined>\` rather than \`Partial<Record<K, string>>\`
|
|
131
|
-
for compatibility with Zod schema generation. Both are functionally equivalent for validation.`),
|
|
131
|
+
for compatibility with Zod schema generation. Both are functionally equivalent for validation.`),dj=Z({method:$(`ui/open-link`),params:Z({url:J().describe(`URL to open in the host's browser`)})});Z({isError:WE().optional().describe(`True if the host failed to open the URL (e.g., due to security policy).`)}).passthrough(),Z({isError:WE().optional().describe(`True if the download failed (e.g., user cancelled or host denied).`)}).passthrough(),Z({isError:WE().optional().describe(`True if the host rejected or failed to deliver the message.`)}).passthrough();var fj=Z({method:$(`ui/notifications/sandbox-proxy-ready`),params:Z({})}),pj=Z({connectDomains:X(J()).optional().describe(`Origins for network requests (fetch/XHR/WebSocket).
|
|
132
132
|
|
|
133
133
|
- Maps to CSP \`connect-src\` directive
|
|
134
|
-
- Empty or omitted → no network connections (secure default)`),resourceDomains:X(J()).optional().describe("Origins for static resources (images, scripts, stylesheets, fonts, media).\n\n- Maps to CSP `img-src`, `script-src`, `style-src`, `font-src`, `media-src` directives\n- Wildcard subdomains supported: `https://*.example.com`\n- Empty or omitted → no network resources (secure default)"),frameDomains:X(J()).optional().describe("Origins for nested iframes.\n\n- Maps to CSP `frame-src` directive\n- Empty or omitted → no nested iframes allowed (`frame-src 'none'`)"),baseUriDomains:X(J()).optional().describe("Allowed base URIs for the document.\n\n- Maps to CSP `base-uri` directive\n- Empty or omitted → only same origin allowed (`base-uri 'self'`)")}),
|
|
134
|
+
- Empty or omitted → no network connections (secure default)`),resourceDomains:X(J()).optional().describe("Origins for static resources (images, scripts, stylesheets, fonts, media).\n\n- Maps to CSP `img-src`, `script-src`, `style-src`, `font-src`, `media-src` directives\n- Wildcard subdomains supported: `https://*.example.com`\n- Empty or omitted → no network resources (secure default)"),frameDomains:X(J()).optional().describe("Origins for nested iframes.\n\n- Maps to CSP `frame-src` directive\n- Empty or omitted → no nested iframes allowed (`frame-src 'none'`)"),baseUriDomains:X(J()).optional().describe("Allowed base URIs for the document.\n\n- Maps to CSP `base-uri` directive\n- Empty or omitted → only same origin allowed (`base-uri 'self'`)")}),mj=Z({camera:Z({}).optional().describe(`Request camera access.
|
|
135
135
|
|
|
136
136
|
Maps to Permission Policy \`camera\` feature.`),microphone:Z({}).optional().describe(`Request microphone access.
|
|
137
137
|
|
|
@@ -139,7 +139,7 @@ Maps to Permission Policy \`microphone\` feature.`),geolocation:Z({}).optional()
|
|
|
139
139
|
|
|
140
140
|
Maps to Permission Policy \`geolocation\` feature.`),clipboardWrite:Z({}).optional().describe(`Request clipboard write access.
|
|
141
141
|
|
|
142
|
-
Maps to Permission Policy \`clipboard-write\` feature.`)}),
|
|
142
|
+
Maps to Permission Policy \`clipboard-write\` feature.`)}),hj=Z({method:$(`ui/notifications/size-changed`),params:Z({width:Y().optional().describe(`New width in pixels.`),height:Y().optional().describe(`New height in pixels.`)})});Z({method:$(`ui/notifications/tool-input`),params:Z({arguments:QE(J(),qE().describe(`Complete tool call arguments as key-value pairs.`)).optional().describe(`Complete tool call arguments as key-value pairs.`)})}),Z({method:$(`ui/notifications/tool-input-partial`),params:Z({arguments:QE(J(),qE().describe(`Partial tool call arguments (incomplete, may change).`)).optional().describe(`Partial tool call arguments (incomplete, may change).`)})}),Z({method:$(`ui/notifications/tool-cancelled`),params:Z({reason:J().optional().describe(`Optional reason for the cancellation (e.g., "user action", "timeout").`)})});var gj=Z({fonts:J().optional()}),_j=Z({variables:uj.optional().describe(`CSS variables for theming the app.`),css:gj.optional().describe(`CSS blocks that apps can inject.`)});Z({method:$(`ui/resource-teardown`),params:Z({})});var vj=QE(J(),qE()),yj=Z({text:Z({}).optional().describe(`Host supports text content blocks.`),image:Z({}).optional().describe(`Host supports image content blocks.`),audio:Z({}).optional().describe(`Host supports audio content blocks.`),resource:Z({}).optional().describe(`Host supports resource content blocks.`),resourceLink:Z({}).optional().describe(`Host supports resource link content blocks.`),structuredContent:Z({}).optional().describe(`Host supports structured content.`)}),bj=Z({method:$(`ui/notifications/request-teardown`),params:Z({}).optional()}),xj=Z({experimental:Z({}).optional().describe(`Experimental features (structure TBD).`),openLinks:Z({}).optional().describe(`Host supports opening external URLs.`),downloadFile:Z({}).optional().describe(`Host supports file downloads via ui/download-file.`),serverTools:Z({listChanged:WE().optional().describe(`Host supports tools/list_changed notifications.`)}).optional().describe(`Host can proxy tool calls to the MCP server.`),serverResources:Z({listChanged:WE().optional().describe(`Host supports resources/list_changed notifications.`)}).optional().describe(`Host can proxy resource reads to the MCP server.`),logging:Z({}).optional().describe(`Host accepts log messages.`),sandbox:Z({permissions:mj.optional().describe(`Permissions granted by the host (camera, microphone, geolocation).`),csp:pj.optional().describe(`CSP domains approved by the host.`)}).optional().describe(`Sandbox configuration applied by the host.`),updateModelContext:yj.optional().describe(`Host accepts context updates (ui/update-model-context) to be included in the model's context for future turns.`),message:yj.optional().describe(`Host supports receiving content messages (ui/message) from the view.`),sampling:Z({tools:Z({}).optional().describe("Host supports tool use via `tools` and `toolChoice` parameters.")}).optional().describe("Host supports LLM sampling (sampling/createMessage) from the view.\nMirrors the MCP `ClientCapabilities.sampling` shape so hosts can pass it through.")}),Sj=Z({experimental:Z({}).optional().describe(`Experimental features (structure TBD).`),tools:Z({listChanged:WE().optional().describe(`App supports tools/list_changed notifications.`)}).optional().describe(`App exposes MCP-style tools that the host can call.`),availableDisplayModes:X(lj).optional().describe(`Display modes the app supports.`)}),Cj=Z({method:$(`ui/notifications/initialized`),params:Z({}).optional()});Z({csp:pj.optional().describe(`Content Security Policy configuration for UI resources.`),permissions:mj.optional().describe(`Sandbox permissions requested by the UI resource.`),domain:J().optional().describe(`Dedicated origin for view sandbox.
|
|
143
143
|
|
|
144
144
|
Useful when views need stable, dedicated origins for OAuth callbacks, CORS policies, or API key allowlists.
|
|
145
145
|
|
|
@@ -147,22 +147,22 @@ Useful when views need stable, dedicated origins for OAuth callbacks, CORS polic
|
|
|
147
147
|
- Hash-based subdomains (e.g., \`{hash}.claudemcpcontent.com\`)
|
|
148
148
|
- URL-derived subdomains (e.g., \`www-example-com.oaiusercontent.com\`)
|
|
149
149
|
|
|
150
|
-
If omitted, host uses default sandbox origin (typically per-conversation).`),prefersBorder:
|
|
150
|
+
If omitted, host uses default sandbox origin (typically per-conversation).`),prefersBorder:WE().optional().describe(`Visual boundary preference - true if view prefers a visible border.
|
|
151
151
|
|
|
152
152
|
Boolean requesting whether a visible border and background is provided by the host. Specifying an explicit value for this is recommended because hosts' defaults may vary.
|
|
153
153
|
|
|
154
154
|
- \`true\`: request visible border + background
|
|
155
155
|
- \`false\`: request no visible border + background
|
|
156
|
-
- omitted: host decides border`)});var
|
|
156
|
+
- omitted: host decides border`)});var wj=Z({method:$(`ui/request-display-mode`),params:Z({mode:lj.describe(`The display mode being requested.`)})});Z({mode:lj.describe(`The display mode that was actually set. May differ from requested if not supported.`)}).passthrough();var Tj=Q([$(`model`),$(`app`)]).describe(`Tool visibility scope - who can access the tool.`);Z({resourceUri:J().optional(),visibility:X(Tj).optional().describe(`Who can access this tool. Default: ["model", "app"]
|
|
157
157
|
- "model": Tool visible to and callable by the agent
|
|
158
|
-
- "app": Tool callable by the app from this server only`),csp:
|
|
159
|
-
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:UE().optional().describe(`Whether the device supports touch input.`),hover:UE().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:Dj.describe(`Partial context update containing only changed fields.`)});var Oj=Z({method:$(`ui/update-model-context`),params:Z({content:X(tA).optional().describe(`Context content blocks (text, image, etc.).`),structuredContent:ZE(J(),KE().describe(`Structured content for machine-readable context data.`)).optional().describe(`Structured content for machine-readable context data.`)})}),kj=Z({method:$(`ui/initialize`),params:Z({appInfo:GO.describe(`App identification (name and version).`),appCapabilities:xj.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:GO.describe(`Host application identification and version.`),hostCapabilities:bj.describe(`Features and capabilities provided by the host.`),hostContext:Dj.describe(`Rich context about the host environment.`)}).passthrough();var Aj=[oj],jj=class extends aj{_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:mj,sandboxready:dj,initialized:Sj,requestteardown:yj,loggingmessage:vA};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(kj,e=>this._oninitialize(e)),this.setRequestHandler(tk,(e,t)=>(this.onping?.(e.params,t),{})),this.replaceRequestHandler(Cj,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(Ej,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(uj,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(Tj,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(Cj,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(Oj,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(fA,async(e,t)=>{if(!this._oncalltool)throw Error(`No oncalltool handler set`);return this._oncalltool(e.params,t)})}set oncreatesamplingmessage(e){this.setRequestHandler(EA,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(Ok,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(Ak,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(Pk,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(Gk,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:Aj.includes(t)?t:oj,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];Mj(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},_j,t)}sendResourceTeardown=this.teardownResource;callTool(e,t){return this.request({method:`tools/call`,params:e},uA,t)}listTools(e,t){return this.request({method:`tools/list`,params:e},lA,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},uA,{signal:t.signal}),e.tools.listChanged&&this._client.setNotificationHandler(pA,e=>this.sendToolListChanged(e.params))),e.resources&&(this.onlistresources=async(e,t)=>this._client.request({method:`resources/list`,params:e},kk,{signal:t.signal}),this.onlistresourcetemplates=async(e,t)=>this._client.request({method:`resources/templates/list`,params:e},jk,{signal:t.signal}),this.onreadresource=async(e,t)=>this._client.request({method:`resources/read`,params:e},Fk,{signal:t.signal}),e.resources.listChanged&&this._client.setNotificationHandler(Ik,e=>this.sendResourceListChanged(e.params))),e.prompts&&(this.onlistprompts=async(e,t)=>this._client.request({method:`prompts/list`,params:e},Kk,{signal:t.signal}),e.prompts.listChanged&&this._client.setNotificationHandler(iA,e=>this.sendPromptListChanged(e.params)))}return super.connect(e)}};function Mj(e,t){return JSON.stringify(e)===JSON.stringify(t)}function Nj(){let e=ft(mv);if(!e)throw Error(`useTheme must be used within ThemeProvider`);return e}async function Pj(e){try{await e.teardownResource({},{timeout:1e3})}catch{}try{await e.close()}catch{}}function Fj({state:e}){return e.enabled?j(`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:[j(`summary`,{class:`cursor-pointer font-medium`,children:`Magic Canvas debug`}),j(`dl`,{class:`mt-2 grid gap-2`,children:[j(Ij,{label:`iframe`,value:e.iframeLifecycleState}),j(Ij,{label:`post`,value:e.lastInteractionPostResult}),j(Ij,{label:`context`,value:e.lastModelContextUpdate}),j(Ij,{label:`error`,value:e.lastError}),j(Lj,{label:`tool_call`,value:e.lastToolCall}),j(Lj,{label:`canvas_config`,value:e.parsedCanvasConfig})]})]}):null}function Ij({label:e,value:t}){return t?j(`div`,{children:[j(`dt`,{class:`font-semibold`,children:e}),j(`dd`,{class:`break-words text-base-content/70`,children:t})]}):null}function Lj({label:e,value:t}){return t===void 0?null:j(`div`,{children:[j(`dt`,{class:`font-semibold`,children:e}),j(`dd`,{children:j(`pre`,{class:`max-h-40 overflow-auto rounded bg-base-200 p-2 text-[10px] leading-relaxed`,children:JSON.stringify(t,null,2)})})]})}var Rj=new Set([`mcp-ui.tavus.io`,`mcp-ui.tavus-preview.io`]),zj=[`.sandbox-tavus.io`],Bj=new Set([`tavusapi.com`]);function Vj(e){let t;try{t=new URL(e)}catch{return!1}return Wj(t)?!0:t.protocol===`https:`?Rj.has(t.hostname)?!0:zj.some(e=>t.hostname.endsWith(e)):!1}function Hj(e){return Vj(e)}function Uj(e){let t;try{t=new URL(e)}catch{return!1}return Gj(t)?!0:t.protocol===`https:`&&Bj.has(t.hostname)}function Wj(e){return Gj(e)}function Gj(e){return!Kj()||e.protocol!==`http:`&&e.protocol!==`https:`?!1:[`localhost`,`127.0.0.1`,`::1`,`[::1]`].includes(e.hostname)}function Kj(){try{let e=globalThis.location?.hostname;return typeof e==`string`&&[`localhost`,`127.0.0.1`,`::1`,`[::1]`].includes(e)}catch{return!1}}var qj=`tavus.canvas.interaction`,Jj=[`safe-area-right`,`safe-area-left`,`safe-area-bottom`,`full`],Yj=`safe-area-right`,Xj={x:275/1280,y:111/720,width:730/1280,height:609/720},Zj={type:`snapshot_mirror`};function Qj(e){return yM(e)?e.message_type===`conversation`&&e.event_type===`conversation.tool_call`&&typeof e.conversation_id==`string`&&yM(e.properties):!1}function $j(e){if(!yM(e))return null;let t=NM(e,`component`),n=NM(e,`component_version`),r=NM(e,`sandbox_url`),i=IM(e,`mcp_server_url`,Hj),a=IM(e,`api_base_url`,Uj),o=IM(e,`interaction_url`,Uj),s=CM(e.layout),c=e.version;return c!==1||!t||!n||!r||!Vj(r)||i===null||a===null||o===null||s===null?null:{version:c,component:t,component_version:n,resource_uri:NM(e,`resource_uri`),sandbox_url:r,mcp_server_url:i,mcp_tool_name:NM(e,`mcp_tool_name`),api_base_url:a,interaction_url:o,layout:s,host_context:yM(e.host_context)?e.host_context:void 0}}function eM(e){if(e===void 0)return{ok:!0,value:{}};if(yM(e))return{ok:!0,value:e};if(typeof e!=`string`)return{ok:!1,error:Error(`Magic Canvas tool arguments must be an object or JSON string.`)};try{let t=JSON.parse(e);return yM(t)?{ok:!0,value:t}:{ok:!1,error:Error(`Magic Canvas tool arguments must decode to an object.`)}}catch(e){return{ok:!1,error:bM(e)}}}function tM(e){let t=e.properties.name;if(t!==`canvas_clear`&&t!==`update_component`)return null;let n=eM(e.properties.arguments);if(!n.ok)throw n.error;if(t===`canvas_clear`){let t=n.value.tool_call_id,r=n.value.reason;if(t!==void 0&&typeof t!=`string`)throw Error(`Magic Canvas clear tool_call_id must be a string when provided.`);if(r!==void 0&&typeof r!=`string`)throw Error(`Magic Canvas clear reason must be a string when provided.`);return{kind:`clear`,conversation_id:e.conversation_id,tool_call_id:t,reason:r}}let r=n.value.tool_call_id,i=n.value.updates;if(typeof r!=`string`||r.length===0)throw Error(`Magic Canvas update_component requires a target tool_call_id.`);if(!yM(i))throw Error(`Magic Canvas update_component requires an object updates payload.`);return{kind:`update`,conversation_id:e.conversation_id,tool_call_id:r,updates:i}}function nM(e){return e.display_mode===`fullscreen`?`full`:e.preferred_slot}function rM(e){return e===`full`||e===`safe-area-bottom`}function iM(e,t){let n=nM(t.layout);return rM(n)?[t]:[...e.filter(e=>{let t=nM(e.layout);return!rM(t)&&t!==n}),t]}function aM(e,t){switch(t.kind){case`show`:{let n=e.find(e=>e.id===t.instance.id),r=n?{...t.instance,revision:n.revision+1}:t.instance;return iM(e.filter(e=>e.id!==t.instance.id),r)}case`update`:{let n=e=>e.conversation_id===t.conversation_id&&e.tool_call_id===t.tool_call_id,r=hM(t.updates),i,a=e.map(e=>{if(!n(e))return e;let t={...e,arguments:{...e.arguments,...r.componentArguments},layout:{preferred_slot:r.preferredSlot??e.layout.preferred_slot,display_mode:r.displayMode??e.layout.display_mode,avoid_safe_area:r.avoidSafeArea??e.layout.avoid_safe_area,safe_area:r.safeArea??e.layout.safe_area,backdrop:r.backdrop??e.layout.backdrop},revision:e.revision+1};return i=t,t});if(i===void 0)return a;let o=e.find(n);return o&&nM(o.layout)===nM(i.layout)?a:iM(a.filter(e=>!n(e)),i)}case`clear`:return t.tool_call_id?e.filter(e=>!(e.conversation_id===t.conversation_id&&e.tool_call_id===t.tool_call_id)):e.filter(e=>e.conversation_id!==t.conversation_id)}}function oM(e){if(!yM(e)||!Array.isArray(e.content))return null;for(let t of e.content){if(!yM(t))continue;let e=(yM(t._meta)?t._meta:null)?.[qj];if(yM(e))return LM(e)}return null}function sM(e,t){let n=t.type,r=t.value;if(!n)throw Error(`Magic Canvas interaction is missing type.`);if(r===void 0)throw Error(`Magic Canvas interaction is missing value.`);return{interaction_id:t.interaction_id??vM(e.tool_call_id,n),conversation_id:e.conversation_id,tool_call_id:e.tool_call_id,component:t.component??e.canvas_config.component,component_version:t.component_version??e.canvas_config.component_version,type:n,value:r,metadata:yM(t.metadata)?t.metadata:{}}}function cM(e){return e.type===`dismiss`||e.type===`clear`?!0:e.type!==`submit`&&e.type!==`skip`?!1:e.component===`canvas.question`||e.component===`canvas.input`||e.component===`canvas.calendar`}function lM(e){return!yM(e)||!Array.isArray(e.content)?``:e.content.map(e=>yM(e)&&e.type===`text`&&typeof e.text==`string`?e.text:``).filter(Boolean).join(`
|
|
160
|
-
`).trim()}function
|
|
161
|
-
`)}function
|
|
162
|
-
`).trim():``}function SM(e){let t=JSON.stringify(e);return t?t.length<=2e3?t:`${t.slice(0,2e3)}...`:`{}`}function CM(e){if(e===void 0)return;if(!yM(e))return null;let t=wM(e),n=kM(e.safe_area??e.safeArea),r=AM(e.backdrop);return n===null||r===null?null:{...t?{preferred_slot:t}:{},...jM(e.avoid_safe_area??e.avoidSafeArea,`avoid_safe_area`),...n?{safe_area:n}:{},...r?{backdrop:r}:{}}}function wM(e){if(typeof e==`string`&&MM(e))return e;if(!yM(e))return;let t=e.preferred_slot??e.preferredSlot??e.slot;return typeof t==`string`&&MM(t)?t:void 0}function TM(e){if(e.presentation===!0||e.fullscreen===!0)return`fullscreen`;if(e.presentation===!1||e.fullscreen===!1)return`inline`;let t=e.display_mode??e.displayMode;return t===`fullscreen`||t===`inline`?t:void 0}function EM(e){let t=yM(e.layout)?e.layout:void 0,n=e.avoid_safe_area??e.avoidSafeArea??t?.avoid_safe_area??t?.avoidSafeArea;return typeof n==`boolean`?n:void 0}function DM(e){let t=yM(e.layout)?e.layout:void 0;return kM(e.safe_area??e.safeArea??t?.safe_area??t?.safeArea)??void 0}function OM(e){let t=yM(e.layout)?e.layout:void 0;return AM(e.backdrop??t?.backdrop)??void 0}function kM(e){if(e===void 0)return;if(!yM(e))return null;let t=PM(e,`x`),n=PM(e,`y`),r=PM(e,`width`),i=PM(e,`height`);return t===void 0||n===void 0||r===void 0||i===void 0||t<0||n<0||r<=0||i<=0||t+r>1.001||n+i>1.001?null:{x:FM(t,0,1),y:FM(n,0,1),width:FM(r,0,1),height:FM(i,0,1)}}function AM(e){if(e===void 0)return;if(e===`snapshot_mirror`||e===`none`)return{type:e};if(!yM(e))return null;let t=e.type;return t===`snapshot_mirror`||t===`none`?{type:t}:null}function jM(e,t){return typeof e==`boolean`?{[t]:e}:{}}function MM(e){return Jj.includes(e)}function NM(e,t){let n=e[t];return typeof n==`string`&&n.length>0?n:void 0}function PM(e,t){let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0}function FM(e,t,n){return Math.min(Math.max(e,t),n)}function IM(e,t,n){let r=NM(e,t);if(r)return n(r)?r:null}function LM(e){return e.interaction_id!==void 0&&typeof e.interaction_id!=`string`||e.component!==void 0&&typeof e.component!=`string`||e.component_version!==void 0&&typeof e.component_version!=`string`||e.type!==void 0&&typeof e.type!=`string`||e.metadata!==void 0&&!yM(e.metadata)?null:e}var RM=`tavus-deployment magic-canvas/0.0.0`;function zM(e){if(!Qj(e)||e.canvas_config===void 0||e.canvas_config===null)return null;let t=$j(e.canvas_config),n=e.properties.tool_call_id;if(!t)return null;if(!n)throw Error(`Received Magic Canvas tool call without tool_call_id.`);let r=eM(e.properties.arguments);if(!r.ok)throw r.error;return dM({conversationId:e.conversation_id,toolCallId:n,args:r.value,canvasConfig:t})}function BM(e){if(!Qj(e))return null;if(e.canvas_config!==void 0&&e.canvas_config!==null){let t=zM(e);return t?{kind:`show`,instance:t}:null}return tM(e)}function VM(e){return{body:{interaction_id:e.interaction_id,tool_call_id:e.tool_call_id,component:e.component,component_version:e.component_version,type:e.type,value:e.value,metadata:e.metadata}}}function HM(e,t){return{theme:e.theme,displayMode:t?.display_mode??`inline`,availableDisplayModes:[`inline`,`fullscreen`],...t?{containerDimensions:_M(t),layout:{preferred_slot:t.preferred_slot,viable_slot:t.viable_slot,avoid_safe_area:t.avoid_safe_area,safe_area:t.safe_area,backdrop:t.backdrop}}:{},platform:`web`,userAgent:RM,styles:{variables:UM(e.cssVars)}}}function UM(e){return{"--border-radius-md":e[`--radius-box`]??e[`--tavus-boxes-radius`]??`0.5rem`,"--border-radius-sm":e[`--radius-field`]??e[`--tavus-field-radius`]??`0.375rem`,"--border-radius-xs":e[`--radius-selector`]??`0.25rem`,"--border-radius-lg":e[`--radius-box`]??e[`--tavus-boxes-radius`]??`0.75rem`,"--border-width-regular":e[`--border`]??e[`--tavus-border-width`]??`1px`,"--font-text-sm-size":`0.875rem`,"--font-text-md-size":`1rem`,...WM(e)}}function WM(e){let t=e[`--color-base-content`],n=e[`--color-base-100`],r=e[`--color-base-200`],i=e[`--color-base-300`],a=e[`--color-error`],o={},s=(e,t)=>{t&&(o[e]=t)},c=(e,t,n)=>e&&n?`color-mix(in oklch, ${e} ${t}%, ${n})`:void 0;return s(`--color-background-primary`,n),s(`--color-background-secondary`,r),s(`--color-border-secondary`,i),s(`--color-border-primary`,c(t,28,n)),s(`--color-text-primary`,t),s(`--color-text-secondary`,c(t,62,n)),s(`--color-text-danger`,a),s(`--color-border-danger`,a),o}var GM=1e3,KM=5e3,qM=1200,JM=48,YM=`allow-scripts`,XM={"canvas.scheduling_embed":`allow-scripts allow-same-origin allow-popups allow-forms`};function ZM(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 QM=class{onmessage;onerror;onclose;#e;#t;constructor(e){this.#e=e}start(){let e=e=>{ZM(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 $M(e){for(let t of Jj)if(e.some(e=>pN(e)===t))return t;return null}function eN({onLayoutEffectChange:e,onRenderedSlotChange:t,debugEnabled:n=mN()}={}){let{client:r}=G_(),{dataTheme:i,cssVars:a}=Nj(),o=ah(),s=jg(),[c,l]=E([]),[u,d]=cN(),[f,p]=E(()=>({enabled:n,iframeLifecycleState:`idle`})),m=A(e=>{p(t=>({...t,...e}))},[]),h=A((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=k(()=>({theme:i.value===`dark`?`dark`:`light`,cssVars:a.value}),[i.value,a.value]);D(()=>{p(e=>e.enabled===n?e:{...e,enabled:n})},[n]),Ug({onAppMessage:A(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=BM(e.data);if(!t)return;l(e=>aM(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:_N(e).message})}},[s,m])});let _=c.map(e=>({instance:e,layout:fM(e,d)})),v=pM(_.map(({layout:e})=>e),d),y=[..._].reverse().find(({layout:e})=>e.display_mode===`fullscreen`)?.instance.tool_call_id;D(()=>{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=$M(_.map(({layout:e})=>e));D(()=>{t?.(b)},[t,b]);let x=c.length>0||f.enabled;return j(`div`,{ref:u,"data-magic-canvas-root":!0,class:`pointer-events-none absolute inset-0 z-30`,children:[x&&y&&j(`div`,{class:`absolute inset-0 bg-black/45`}),x&&Jj.map(e=>{let t=_.filter(({layout:t})=>pN(t)===e);return t.length===0?null:j(tN,{slot:e,safeAreaTop:v.safe_area?.y,children:e=>t.map(({instance:t,layout:n})=>j(nN,{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&&j(`div`,{class:`absolute right-4 bottom-24 @max-mobile:right-3 @max-mobile:bottom-20`,children:j(Fj,{state:f})})]})}function tN({slot:e,safeAreaTop:t,children:n}){let[r,i]=lN(),a=n(e===`full`?void 0:i);if(e===`safe-area-left`||e===`safe-area-right`){let n=t==null?`1rem`:`${t*100}%`;return j(`div`,{ref:r,class:fN(e),style:{top:n,bottom:`${dN}px`},"data-canvas-slot":e,children:j(`div`,{class:`my-auto flex w-full flex-col gap-2`,children:a})})}return j(`div`,{ref:r,class:fN(e),"data-canvas-slot":e,children:a})}function nN({availableHeight:e,client:t,hostTheme:n,instance:r,layout:i,dimmed:a,onDebug:o,onComplete:s,onDisplayModeChange:c,sendAppMessage:l}){let u=O(null),d=O(null),f=O(e),p=O(320),m=O(n),h=O(r),g=O(i),_=O(-1),v=O(s),y=O(c),b=O(l),[x,S]=E(320);D(()=>{h.current=r},[r]),D(()=>{p.current=x,d.current?.setHostContext(oN(h.current,m.current,g.current,f.current,x))},[x]),D(()=>{f.current=e;let t=aN(n,u.current);m.current=t,d.current?.setHostContext(oN(h.current,t,g.current,e,p.current))},[e,n]),D(()=>{g.current=i,d.current?.setHostContext(oN(h.current,m.current,i,e,p.current))},[e,i]),D(()=>{v.current=s,y.current=c,b.current=l},[s,c,l]),D(()=>{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:_N(e).message})},C=()=>{if(n||!a)return;let e=h.current,t=uM(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 jj(null,{name:`tavus-deployment`,version:`0.0.0`},{logging:{},message:{text:{},structuredContent:{}},updateModelContext:{text:{},structuredContent:{}}},{hostContext:oN(r,aN(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,JM),720))},u.onmessage=async e=>{let r=oM(e),i=lM(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=sM(e,r),s=VM(a),l=new AbortController,u=globalThis.setTimeout(()=>l.abort(),KM);try{await wn(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}),cM(a)&&(a.type===`submit`?(c&&clearTimeout(c),c=setTimeout(()=>{c=null,n||v.current()},qM)):v.current())}catch(e){let t=_N(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()},GM),{}),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(oN(h.current,m.current,g.current,f.current,p.current)),{mode:t}},u.connect(new QM(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&&Pj(i)}},[t,r.id,r.canvas_config.sandbox_url,o]),D(()=>{r.revision!==0&&(r.revision<=_.current||(_.current=r.revision,d.current?.sendToolInput({arguments:r.arguments}).catch(e=>{o({iframeLifecycleState:`error`,lastError:_N(e).message})})))},[r.arguments,r.revision,o]);let C=i.viable_slot===`full`||i.display_mode===`fullscreen`,w=C?null:sN(x,e),ee=w?.placeholderStyle,T=w?.cardStyle,te=C?{height:`100%`}:w?.iframeStyle??{height:`${x}px`},ne=[`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(` `),re=XM[r.canvas_config.component]??YM,ie=j(`div`,{class:ne,style:T,"data-canvas-card":i.viable_slot,children:j(`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:re,style:te})});return C?ie:j(`div`,{class:`block w-full`,style:ee,children:ie})}var rN=[`--color-base-100`,`--color-base-200`,`--color-base-300`,`--color-base-content`,`--color-primary`,`--color-error`];function iN(e){if(!e||typeof getComputedStyle!=`function`)return{};let t=getComputedStyle(e),n={};for(let e of rN){let r=t.getPropertyValue(e).trim();r&&(n[e]=r)}return n}function aN(e,t){let n=iN(t);return Object.keys(n).length===0?e:{...e,cssVars:{...e.cssVars,...n}}}function oN(e,t,n,r,i){let a=HM(t,n),o=n.viable_slot===`full`||n.display_mode===`fullscreen`,s=o?void 0:hN(r),c=o?1:sN(i??0,r)?.displayScale??1;return{...e.canvas_config.host_context,...a,containerDimensions:{...gN(a.containerDimensions)?a.containerDimensions:{},...s===void 0?{}:{maxHeight:s},displayScale:c}}}function sN(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 cN(){let e=O(null),[t,n]=E(()=>uN(null));return D(()=>{let t=()=>n(t=>{let n=uN(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 lN(){let e=O(null),[t,n]=E();return D(()=>{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 uN(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 dN=72;function fN(e){let t=`absolute flex gap-2`;switch(e){case`safe-area-left`:return`${t} left-4 w-[min(28rem,calc(100vw_-_2rem))] flex-col overflow-y-auto`;case`safe-area-right`:return`${t} right-4 w-[min(28rem,calc(100vw_-_2rem))] 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 pN(e){return e.display_mode===`fullscreen`&&e.preferred_slot!==`full`?e.preferred_slot:e.viable_slot}function mN(){return!1}function hN(e){return e===void 0||!Number.isFinite(e)||e<=0?720:Math.min(Math.floor(e),720)}function gN(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function _N(e){return e instanceof Error?e:Error(String(e))}var vN=24,yN=96;function bN(e=document){let t=Array.from(e.querySelectorAll(`[data-canvas-card]`)).map(e=>e.getBoundingClientRect());return t.length===0?null:{left:Math.min(...t.map(e=>e.left)),right:Math.max(...t.map(e=>e.right)),top:Math.min(...t.map(e=>e.top)),bottom:Math.max(...t.map(e=>e.bottom))}}function xN(e){let t=e?.getRootNode();return t instanceof ShadowRoot?t:document}function SN(e,t,n){if(!t)return!1;let r=globalThis.innerWidth,i=globalThis.innerHeight,a=e?.safe_area??Xj,o=a.x*r+n,s=(a.x+a.width)*r+n,c=a.y*i,l=(a.y+a.height)*i;return o<t.right&&s>t.left&&c<t.bottom&&l>t.top}function CN(e,t,n){let[r,i]=E(()=>e?bN(xN(n?.current)):null);return ut(()=>{if(!e){i(null);return}let t=xN(n?.current),r=()=>i(bN(t)),a=new ResizeObserver(r),o=()=>{for(let e of t.querySelectorAll(`[data-canvas-card]`))a.observe(e)};r(),o(),a.observe(document.documentElement);let s=globalThis.requestAnimationFrame(()=>{r(),o()});return globalThis.addEventListener(`resize`,r),()=>{a.disconnect(),globalThis.removeEventListener(`resize`,r),globalThis.cancelAnimationFrame(s)}},[e,t,n]),e?r:null}function wN(e,t,n,r,i){let a=e?.side??(n===`safe-area-left`?`left`:n===`safe-area-right`?`right`:null);return{usePip:a!=null&&(t===`pip`||t===`auto`&&SN(e,r,i)),side:a}}function TN(e,t=document){let n=globalThis.innerWidth,r=globalThis.innerHeight,i=Array.from(t.querySelectorAll(`[data-canvas-card]`)).map(e=>e.getBoundingClientRect()),a,o,s,c;if(i.length>0){let t=Math.min(...i.map(e=>e.left)),r=Math.max(...i.map(e=>e.right));s=Math.min(...i.map(e=>e.top)),c=Math.max(...i.map(e=>e.bottom)),[a,o]=e===`right`?[0,t]:[r,n]}else{let t=Math.min(448,Math.max(0,n-32));[a,o]=e===`right`?[0,n-16-t]:[16+t,n],s=0,c=r}let l=o-a>=144&&c-s>=yN&&a>=0&&o<=n;if(i.length>0&&!l){let t=Math.min(448,Math.max(0,n-32));[a,o]=e===`right`?[0,n-16-t]:[16+t,n],s=0,c=r}let u=Math.max(0,o-a-vN*2),d=Math.max(yN,Math.min(u,r-vN*2));return{centerX:(a+o)/2,centerY:(s+c)/2,diameter:d}}var EN=`560ms linear(0, 0, .0001, .0002, .0003, .0005, .0007, .001, .0013, .0016, .002, .0024, .0029, .0033, .0039, .0044, .005, .0057, .0063, .007, .0079, .0086, .0094, .0103, .0112, .0121, .0132 1.84%, .0153, .0175, .0201, .0226, .0253, .0283, .0313, .0345, .038, .0416, .0454, .0493, .0535, .0576, .0621, .0667, .0714, .0764, .0816 5.04%, .0897, .098 5.62%, .1071, .1165, .1263 6.56%, .137, .1481 7.25%, .1601 7.62%, .1706 7.94%, .1819 8.28%, .194, .2068 9.02%, .2331 9.79%, .2898 11.44%, .3151 12.18%, .3412 12.95%, .3533, .365 13.66%, .3786, .3918, .4045, .4167, .4288, .4405, .452, .4631 16.72%, .4759, .4884, .5005, .5124, .5242, .5354, .5467, .5576, .5686, .5791, .5894, .5995, .6094, .6194, .6289, .6385, .6477, .6569, .6659 24.45%, .6702, .6747, .6789, .6833, .6877, .6919, .696, .7002, .7043, .7084, .7125, .7165, .7205, .7244, .7283, .7321, .7358, .7396, .7433, .7471, .7507, .7544, .7579, .7615, .7649, .7685, .7718, .7752, .7786, .782, .7853, .7885, .7918, .7951, .7982, .8013, .8043, .8075, .8104, .8135, .8165, .8195, .8224, .8253, .8281, .8309, .8336, .8365, .8391, .8419, .8446, .8472, .8499, .8524, .855, .8575, .8599, .8625 37.27%, .8651, .8678, .8703, .8729, .8754, .8779, .8803, .8827, .8851, .8875, .8898, .892, .8942, .8965, .8987, .9009, .903, .9051, .9071, .9092, .9112, .9132, .9151, .9171, .919, .9209, .9227, .9245, .9262, .928, .9297, .9314, .9331, .9347, .9364, .9379, .9395, .941, .9425, .944, .9454, .9469, .9483, .9497, .951, .9524, .9537, .955, .9562, .9574, .9586, .9599, .961, .9622, .9633, .9644, .9655, .9665, .9676, .9686, .9696, .9705, .9715, .9724, .9733, .9742, .975, .9758, .9766, .9774, .9782, .9789, .9796, .9804, .9811, .9817, .9824, .9831, .9837, .9843, .9849, .9855, .986, .9866, .9871, .9877, .9882, .9887, .9892, .9896 70.56%, .9905 71.67%, .9914 72.82%, .9922, .9929 75.2%, .9936 76.43%, .9942 77.71%, .9948 79.03%, .9954 80.39%, .9959 81.81%, .9963 83.28%, .9968 84.82%, .9972 86.41%, .9975 88.07%, .9979 89.81%, .9982 91.64%, .9984 93.56%, .9987 95.58%, .9989 97.72%, .9991)`;function DN(e,t){let n=Math.abs(t)/2;return e===`left`?`${n}px center`:`calc(100% - ${n}px) center`}function ON(e,t,n){let[r,i]=E(()=>e&&t?TN(t,xN(n?.current)):null);return ut(()=>{if(!e||!t){i(null);return}let r=xN(n?.current),a=()=>i(TN(t,r)),o=new ResizeObserver(a),s=()=>{for(let e of r.querySelectorAll(`[data-canvas-card]`))o.observe(e)};a(),s(),o.observe(document.documentElement);let c=globalThis.requestAnimationFrame(()=>{a(),s()});return globalThis.addEventListener(`resize`,a),()=>{o.disconnect(),globalThis.removeEventListener(`resize`,a),globalThis.cancelAnimationFrame(c)}},[e,t,n]),e&&t?r:null}function kN(e,t){let[n,r]=E(null);return ut(()=>{if(!t){r(null);return}let n=e.current;if(!n)return;let i=()=>{let e=n.clientWidth,t=n.clientHeight;r(e&&t?{width:e,height:t}:null)},a=new ResizeObserver(i);return a.observe(n),i(),()=>a.disconnect()},[t,e]),t?n:null}var AN=1;function jN(e,t,n){return Math.min(Math.max(e,t),n)}function MN(e,t,n,r){let i=Math.min(e.diameter/t.height,1),a=r?.safe_area??Xj,o=((a.x+a.width/2)*t.width+n)*i,s=(a.y+a.height/2)*t.height*i,c=e.diameter/2;return{scale:i,tx:jN(e.centerX-o,e.centerX+c-t.width*i,e.centerX-c),ty:jN(e.centerY-s,e.centerY+c-t.height*i,e.centerY-c)}}var NN=[`cx`,`cy`,`r`,`tx`,`ty`,`s`,`shift`];function PN(e,t,n,r,i){if(!n)return null;let{width:a,height:o}=n,s={x:a/2,y:o/2},c=null;if(e&&(c=MN(e,n,r,i),s={x:(e.centerX-c.tx)/c.scale,y:(e.centerY-c.ty)/c.scale}),t&&c&&e)return{cx:s.x,cy:s.y,r:e.diameter/2/c.scale,tx:c.tx,ty:c.ty,s:c.scale,shift:r};let l=Math.hypot(Math.max(s.x,a-s.x),Math.max(s.y,o-s.y));return{cx:s.x,cy:s.y,r:l*1.1,tx:0,ty:0,s:1,shift:r}}function FN(e,t,n){let r=O(null),i=O(e),a=O(n),o=O(0),s=O(0);i.current=e,a.current=n,D(()=>{let e=i.current;if(!e)return;if(!r.current||IN()){r.current={values:{...e},velocity:{cx:0,cy:0,r:0,tx:0,ty:0,s:0,shift:0}},a.current(e,!0);return}if(o.current)return;let n=Math.max(t,160)/4e3;s.current=performance.now();let c=e=>{o.current=0;let t=i.current,l=r.current;if(!t||!l)return;let u=Math.min((e-s.current)/1e3,1/30);s.current=e;let d=!0;for(let e of NN){let r=(t[e]-l.values[e])/(n*n)-2/n*l.velocity[e],i=l.velocity[e]+r*u,a=l.values[e]+i*u,o=e===`s`?.001:.25;Math.abs(t[e]-a)<o&&Math.abs(i)*n<o?(l.values[e]=t[e],l.velocity[e]=0):(l.values[e]=a,l.velocity[e]=i,d=!1)}a.current(l.values,d),d||(o.current=globalThis.requestAnimationFrame(c))};o.current=globalThis.requestAnimationFrame(c)},[e?NN.map(t=>Math.round(e[t]*100)).join():``,t]),D(()=>()=>{o.current&&globalThis.cancelAnimationFrame(o.current)},[])}function IN(){return globalThis.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches??!1}function LN({geom:e,visible:t}){return j(`div`,{"aria-hidden":`true`,"data-morph":`ring`,class:`pointer-events-none absolute z-10 rounded-full`,style:{top:`${e.centerY-e.diameter/2}px`,left:`${e.centerX-e.diameter/2}px`,width:`${e.diameter}px`,height:`${e.diameter}px`,boxShadow:`0 0 0 3px rgb(255 255 255 / 12%), 0 18px 50px rgb(0 0 0 / 55%)`,opacity:+!!t,transition:`opacity 240ms ease-out`}})}function RN(e,t){let n=t>=0?`left`:`right`,r=O({side:n,shift:t});D(()=>{e&&(r.current={side:n,shift:t})},[e,n,t]);let i=e?n:r.current.side;return{side:i,transformOrigin:DN(i,e?t:r.current.shift),translateX:e?0:-r.current.shift}}function zN(e,t,n){return`${e.side??``}:${e.active}:${t}:${n??``}`}function BN({snapshotUrl:e,transformOrigin:t}){return j(`div`,{class:`absolute inset-0 bg-cover bg-center`,style:{backgroundImage:`url("${e}")`,transform:`scaleX(-1)`,transformOrigin:t}})}function VN({snapshotUrl:e,translateX:t,transition:n,transformOrigin:r}){return j(`div`,{"aria-hidden":`true`,"data-morph":`mirror`,class:`pointer-events-none absolute z-0 overflow-hidden`,style:{inset:`0 0`,transform:`translate3d(${t}px, 0, 0)`,transition:`transform ${n}`,willChange:`transform`},children:j(BN,{snapshotUrl:e,transformOrigin:r})})}function HN({ambient:e,usePip:t,transition:n}){return e===`none`?null:j(`div`,{"aria-hidden":`true`,"data-morph":`ambient`,class:`pointer-events-none absolute inset-0 z-0`,style:{opacity:+!!t,transition:`opacity ${n}`,background:e===`darker`?`rgb(0 0 0 / 40%)`:`rgb(0 0 0 / 15%)`}})}function UN({morphCapable:e,snapshotUrl:t,mirrorSide:n,videoShiftX:r,transition:i,sceneRef:a,videoWrapRef:o,fill:s,videoRef:c}){return j(`div`,{ref:a,"data-morph":`scene`,class:`absolute inset-0`,style:e?{transformOrigin:`top left`}:void 0,children:j(`div`,{ref:o,class:`absolute inset-0`,style:e?void 0:{transform:`translate3d(${r}px, 0, 0)`,transition:`transform ${i}`},children:[s(c),e&&t!==null&&j(`div`,{"aria-hidden":`true`,"data-morph":`window-mirror`,class:`absolute top-0 bottom-0 w-full`,style:n===`right`?{left:`calc(100% - ${AN}px)`}:{right:`calc(100% - ${AN}px)`},children:j(BN,{snapshotUrl:t,transformOrigin:`center`})})]})})}function WN({canvasLayoutEffect:e,smartSidecarActive:t,isScreenSharing:n,fill:r,captureSnapshot:i,transition:a=EN,transitionMs:o=560,personaMode:s=`shift`,renderedSlot:c=null,ambient:l=`default`,children:u}){let d=O(null),[f,p]=E(null),m=t&&e.backdrop.type===`snapshot_mirror`,h=t?e.video_shift_x:0,g=O(null),_=zN(e,h,c),{usePip:v,side:y}=wN(e,s,c,CN(s!==`shift`,_,g),h),b=ON(s!==`shift`,y,g),x=RN(m,h);D(()=>{if(!m)return;let e=!1,t=0,n,r=0,a=()=>{if(e)return;let t=i(d.current);if(t){p(t);return}r+=1,r<8&&(n=globalThis.setTimeout(a,150))};return typeof globalThis.requestAnimationFrame==`function`?t=globalThis.requestAnimationFrame(a):n=globalThis.setTimeout(a,0),()=>{e=!0,t&&globalThis.cancelAnimationFrame?.(t),n&&globalThis.clearTimeout(n)}},[m,e.side,e.video_shift_x,i]),D(()=>{if(m||f===null)return;let e=globalThis.setTimeout(()=>{p(null)},o);return()=>globalThis.clearTimeout(e)},[m,f,o]);let S=v&&y!=null&&b!=null,C=s!==`shift`,w=kN(g,C),ee=f!==null&&!C,T=C&&y!=null,te=O(null),ne=O(null),[re,ie]=E(!0),ae=O(!0),oe=A((e,t)=>{let n=te.current;n&&(n.style.clipPath=`circle(${e.r}px at ${e.cx}px ${e.cy}px)`,n.style.transform=`translate(${e.tx}px, ${e.ty}px) scale(${e.s})`);let r=ne.current;r&&(r.style.transform=`translate3d(${e.shift}px, 0, 0)`),ae.current!==t&&(ae.current=t,ie(t))},[]);return FN(C?PN(b,S,w,h,e):null,o,oe),j(`div`,{ref:g,class:`relative w-full h-full overflow-hidden ${n?`flex items-center justify-center`:``}`,children:[ee&&f!==null&&j(VN,{snapshotUrl:f,translateX:x.translateX,transition:a,transformOrigin:x.transformOrigin}),T&&j(HN,{ambient:l,usePip:v,transition:a}),j(`div`,{"data-morph":`fg`,class:`absolute inset-0 z-10`,children:j(UN,{morphCapable:C,snapshotUrl:f,mirrorSide:x.side,videoShiftX:h,transition:a,sceneRef:te,videoWrapRef:ne,fill:r,videoRef:d})}),C&&b&&j(LN,{geom:b,visible:S&&re}),u]})}var GN=1e4;function KN({onTimeout:e,timeoutMs:t=GN,active:n=!0}){let r=Lb().length>0,[i,a]=E(!1),o=O(e);return D(()=>{o.current=e},[e]),D(()=>{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 qN(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.message_type===`system`&&t.event_type===`system.shutdown`}function JN({onShutdown:e}){let t=O(e);D(()=>{t.current=e},[e]),Ug({onAppMessage:A(e=>{qN(e?.data)&&t.current()},[])})}function YN(){let e=ah();return{joinCall:A(({url:t})=>{e?.join({url:t})},[e]),leaveCall:A(()=>{e?.leave()},[e])}}var XN=_n(`PiP`),ZN=360,QN=280;function $N(){return globalThis.window!==void 0&&`documentPictureInPicture`in globalThis.window}function eP(e){let{enabled:t,active:n}=e,[r,i]=E(null),a=$N(),o=ft(mv),s=A(()=>{i(e=>(e&&!e.closed&&e.close(),null))},[]),c=A(async()=>{if(a&&!(!t||!n)&&!(r&&!r.closed))try{let e=await globalThis.window.documentPictureInPicture.requestWindow({width:ZN,height:QN}),t=Je.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){XN.warn(`Failed to open PiP window`,e)}},[a,t,n,r]);return D(()=>{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){XN.warn(`mediaSession metadata setup failed`,e)}let t=(t,n)=>{try{e.setActionHandler(t,n),r.push(t)}catch(e){XN.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]),D(()=>{(!n||!t)&&r&&!r.closed&&s()},[n,t,r,s]),D(()=>()=>{r&&!r.closed&&r.close()},[r]),D(()=>{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 tP={active:!1,video_shift_x:0,backdrop:{type:`snapshot_mirror`}},nP=ya(({id:e,showAudioWave:t=!0})=>{let n=n_(e).isOff;return j(`div`,{class:`relative aspect-square w-32 @max-mobile:w-24 rounded-box overflow-hidden bg-black/30 z-10 ${n?`hidden`:``}`,children:[j(ng,{automirror:!0,sessionId:e,type:`video`,fit:`cover`,className:`w-full h-full object-cover ${n?`hidden`:``}`}),t&&j(`div`,{class:`absolute bottom-2 right-2`,children:j(Nb,{id:e})})]})}),rP=ya(()=>{let e=Hh(),{isScreenSharing:t}=nb(),n=Lb()[0];return j(le,{children:[t&&n&&j(nP,{id:n}),e&&j(nP,{id:e,showAudioWave:!1})]})}),iP=ya(()=>j(`div`,{class:`absolute top-4 left-4 flex flex-col items-end gap-2 z-20`,children:j(rP,{})})),aP=ya(({isAudioOnly:e,canvasLayoutEffect:t,canvasRenderedSlot:n})=>{let r=Hh(),i=!e_(r??``).isOff,a=Rb(e),o=e_(a.phase===`ready`?a.replicaId:``),s=!i&&(o.state===`playable`||o.state===`loading`),c=t.active&&!i&&(!e||s);return a.phase===`left`?j(jb,{}):a.phase===`connecting`?j(Ab,{}):e&&!s?j(`div`,{class:`absolute inset-0 flex items-center justify-center`,children:[j(Pb,{sessionId:a.replicaId}),j(eg,{sessionId:a.replicaId})]}):j(WN,{canvasLayoutEffect:s?{...t,backdrop:{type:`none`}}:t,smartSidecarActive:c,isScreenSharing:i,captureSnapshot:lP,personaMode:s?`shift`:`auto`,renderedSlot:n,fill:t=>j(Vb,{personaSessionId:a.replicaId,localSessionId:r,isPresenting:s,isScreenSharing:i,isAudioOnly:e,avatarOff:a.videoState.isOff,videoRef:t}),children:j(eg,{sessionId:a.replicaId})})}),oP=ya(({items:e})=>{let[t,n]=E(!1),r=O(null);return D(()=>{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]),j(`div`,{ref:r,class:`relative`,children:[j(`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:j(My,{name:`more`})}),t&&j(`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})]})}),sP=ya(({items:e})=>e.length<=1?j(le,{children:e}):j(oP,{items:e})),cP=ya(({onLeave:e})=>{let{joinCall:t,leaveCall:n}=YN(),r=jg(),{hasMicError:i}=Xg(),{config:a}=G_(),{session:o,end:s}=_b(),c=O(null),l=ft(wv)?.frameRef??c,[u,d]=E(!1),[f,p]=E(!1),[m,h]=E(tP),[g,_]=E(null),v=o.value?.conversationUrl,y=a.value.customization.conversation,b=y.modality===`audio`,x=y.enable_chat,S=y.enable_closed_captions,C=y.enable_picture_in_picture,{pipWindow:w}=eP({enabled:C,active:r===`joined-meeting`});D(()=>(v&&t({url:v}),()=>{n()}),[]),D(()=>{(r===`left-meeting`||r===`error`)&&e()},[r,e]),D(()=>{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 ee=A(()=>{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?.()},[]);A(()=>{p(e=>!e)},[]);let T=A(()=>{s(),n()},[s]);if(KN({active:r===`joined-meeting`,onTimeout:T}),JN({onShutdown:T}),!v)return null;let te=[j(gb,{compact:!0},`screen-share`)];return x&&te.push(j(Eb,{compact:!0},`chat`)),j(yb,{children:j(wb,{children:[j(`div`,{class:`absolute inset-0`,children:[j(`div`,{class:`relative w-full h-full z-[5]`,children:[i&&j(`div`,{class:`absolute top-0 left-0 right-0 z-10 bg-error text-error-content px-4 py-2 text-sm text-center`,children:`Camera or microphone access denied. Please check your settings and try again.`}),j(aP,{isAudioOnly:b,canvasLayoutEffect:m,canvasRenderedSlot:g}),!b&&j(iP,{}),j(Sb,{}),j(eN,{debugEnabled:f,onLayoutEffectChange:h,onRenderedSlotChange:_}),j(`div`,{class:`absolute top-4 right-4 z-20`,children:j(Mb,{active:u,onToggle:ee,compact:!0})})]}),j(Ob,{}),j(`div`,{class:`pointer-events-none absolute bottom-6 left-0 right-0 z-20 transition-opacity transition-transform ${r===`left-meeting`?`opacity-0 translate-y-5`:`opacity-100 translate-y-0`}`,"aria-hidden":r===`left-meeting`,children:j(`div`,{class:`flex justify-center items-center gap-2 @max-mobile:gap-1 ${r===`left-meeting`?``:`pointer-events-auto`}`,children:[j(fb,{}),!b&&j(pb,{}),S&&j(xb,{}),j(sP,{items:te}),j(`button`,{type:`button`,class:`btn btn-control btn-error`,onClick:T,"aria-label":`Leave call`,children:j(My,{name:`leave`,"aria-label":`Leave Call`})})]})})]}),w&&Ia(j(Bb,{onLeave:T}),w.document.body)]})})});function lP(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 uP({loading:e=!1,disabled:t,class:n,children:r,...i}){return j(`button`,{type:`button`,class:`btn relative ${n?` ${n}`:``}`,disabled:t||e,"aria-busy":e||void 0,...i,children:[j(`span`,{children:r}),e&&j(`span`,{class:`absolute inset-0 flex items-center justify-center backdrop-blur-xs`,"aria-hidden":`true`,children:j(`span`,{class:`loading loading-spinner loading-sm`})})]})}function dP(e){switch(e){case`blocked`:return`denied`;case`in-use`:return`in-use`;case`not-found`:return`not-found`;case`not-supported`:case`undefined-mediadevices`:return`unsupported`;case`constraints-invalid`:case`constraints-none-specified`:return`unknown`;default:return null}}function fP(e){let t=e instanceof Error?e.name:``,n=e instanceof Error?e.message.toLowerCase():``;return t===`NotAllowedError`||n.includes(`denied`)||n.includes(`not allowed`)?`denied`:t===`NotReadableError`||n.includes(`in use`)||n.includes(`readable`)?`in-use`:t===`NotFoundError`||n.includes(`not found`)||n.includes(`no device`)?`not-found`:t===`NotSupportedError`||n.includes(`not supported`)?`unsupported`:`unknown`}function pP(){let e=ah(),{micState:t,camState:n}=Xg(),{config:r}=G_(),i=r.value.customization.conversation.modality,a=i===`video`,[o,s]=E(null),[c,l]=E(null),[u,d]=E(!1);D(()=>{let e=!1;return navigator.permissions.query({name:`microphone`}).then(t=>{e||(s(t.state),t.onchange=()=>{e||s(t.state)})}).catch(()=>{}),()=>{e=!0}},[]);let f=A(()=>{if(!e)return;l(null),d(!0);let t={};a||(t.videoSource=!1),Promise.resolve(e.startCamera(t)).catch(e=>{l(fP(e))})},[e,a]),p=k(()=>c&&t!==`granted`?c:dP(t),[t,c]),m=k(()=>a?c&&n!==`granted`&&t===`granted`?c:dP(n):null,[n,t,a,c]),h=k(()=>p??m??null,[p,m]),g=k(()=>c||(u?h:null),[u,c,h]),_=k(()=>o===`prompt`&&g===null,[o,g]),v=k(()=>o===`denied`||g!==null,[o,g]),y=k(()=>g===null&&o!==`prompt`&&o!==`denied`&&t===`granted`&&(!a||n===`granted`),[o,t,n,a,g]);return{isPermissionsPrompt:_,isPermissionsLoading:k(()=>!_&&!v&&!y,[_,v,y]),isPermissionsGranted:y,isPermissionsDenied:v,permissionErrorReason:g,micErrorReason:u?p:null,camErrorReason:u?m:null,modality:i,requestPermissions:f}}function mP(e,t,n,r){return t?e?.prompt??`Make sure your camera and mic are ready!`:n?e?.loading??`Getting your camera and mic ready...`:r?e?.denied??`Camera and mic access denied. Allow permissions to continue.`:null}function hP({message:e}){return j(`div`,{class:`relative max-w-[min(20rem,90%)]`,children:[j(`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}),j(`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:j(`path`,{d:`M0 0 L8 8 L16 0 Z`,fill:`currentColor`})})]})}var gP=ya(({text:e,isJoining:t=!1,onJoin:n,onCancel:r})=>{let i=ah(),{localSessionId:a,isCamMuted:o}=eb(),{isPermissionsPrompt:s,isPermissionsLoading:c,isPermissionsGranted:l,isPermissionsDenied:u,requestPermissions:d}=pP();D(()=>{d()},[]);let f=mP(e,s,c,u);return j(`div`,{class:`absolute inset-0 motion-safe:animate-[tavusFadeUp_280ms_ease-out]`,children:[l&&!o?j(`div`,{class:`absolute inset-0 flex items-center justify-center bg-black overflow-hidden`,children:j(ng,{type:`video`,sessionId:a??``,mirror:!0,fit:`cover`,className:`w-full h-full object-cover!`})}):j(`div`,{class:`absolute inset-0 flex items-center justify-center text-base-content/40`,children:j(My,{name:`face-smile`,size:`7rem`,"aria-label":`Camera off`})}),j(`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:[f&&j(hP,{message:f}),j(`div`,{class:`flex flex-wrap items-center justify-center gap-1.5 @max-mobile:gap-1`,children:[j(`div`,{class:`flex items-center justify-center gap-1.5 shrink-0 @max-mobile:gap-1`,children:[j(fb,{}),j(pb,{})]}),j(uP,{class:`btn-accent `,loading:t,disabled:!l,onClick:n,children:e?.join??`Join Video Chat`}),u&&j(`button`,{type:`button`,class:`btn btn-error `,onClick:()=>{i&&i.leave(),r?.()},children:e?.cancel??`Cancel`})]})]})]})}),_P=`Password required`,vP=`Enter the password to start this conversation.`,yP=`Password`,bP=`Continue`;function xP({onSubmit:e,text:t,isSubmitting:n=!1,errorMessage:r}){let[i,a]=E(``),o=mt();return j(`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:j(`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:j(`div`,{class:`card-body gap-3`,children:[j(`h3`,{id:`${o}-title`,class:`card-title text-base-content`,children:t?.title??_P}),j(`p`,{class:`text-sm text-base-content/70`,children:t?.description??vP}),j(`input`,{id:o,type:`password`,autocomplete:`current-password`,class:`input input-bordered w-full`,placeholder:t?.placeholder??yP,value:i,disabled:n,onInput:e=>a(e.target.value),autoFocus:!0}),r&&j(`p`,{class:`text-error text-xs`,role:`alert`,children:r}),j(uP,{class:`btn-primary`,type:`submit`,disabled:!i.trim(),loading:n,children:t?.submit??bP})]})})})}var SP=_n(`CaptchaChallenge`),CP=1;function wP(e){return typeof e==`object`&&!!e&&e.source===`tavus-captcha`&&typeof e.type==`string`}function TP({captcha:e,deploymentId:t,onToken:n,onFallback:r}){let i=(ft(Ct).baseUrl??`https://tavusapi.com`).replace(/\/+$/,``).split(`/`).slice(0,3).join(`/`),[a,o]=E(0),[s,c]=E(0),[l,u]=E(!1),[d,f]=E(!1),p=`${i}${e.challenge_path}?deployment_uuid=${encodeURIComponent(t)}&action=${encodeURIComponent(e.action)}&parent_origin=${encodeURIComponent(window.location.origin)}`,m=A(()=>{f(!1),o(e=>e+1)},[]);return D(()=>{function e(e){if(l||e.origin!==i)return;let a=e.data;if(wP(a)&&a.deployment_uuid===t){if(a.type===`interactive`){f(!0);return}if(a.type===`token`&&a.token){SP.info(`Captcha token received`),f(!1),n(a.token);return}if(a.type===`expired`){SP.info(`Captcha token expired, reloading iframe`),m();return}a.type===`error`&&(SP.warn(`Captcha error received`,a.code),s<CP?(c(e=>e+1),m()):(SP.warn(`Captcha error retries exhausted, falling back to no-token mode`),u(!0),r()))}}return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},[i,t,s,l,n,r,m]),l?null:j(`div`,{class:d?`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":!d,children:j(`iframe`,{src:p,sandbox:`allow-scripts allow-same-origin allow-forms allow-popups`,title:`Security challenge`,style:{border:`none`,width:`300px`,height:`65px`},scrolling:`no`},a)})}function EP({text:e,onStart:t,isStarting:n}){let{config:r,deploymentId:i}=G_(),a=ft(I_),o=Iy(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=k(()=>d&&p_(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}=cv(_,a),S=mt(),[C,w]=E(f),ee=_!==null&&!v,T=n||d&&!C||g||ee;return j(Hy,{title:o.title,description:o.description,overlay:j(le,{children:[ee&&j(TP,{captcha:_,deploymentId:i,onToken:b,onFallback:x},y),g&&a?j(xP,{onSubmit:a.setPassword}):null]}),children:[j(uP,{class:`btn-neutral rounded-box`,onClick:()=>{d&&C&&!f&&g_(i,c),t()},disabled:T,loading:n,children:s}),u&&j(`div`,{class:`max-w-xs`,children:p?j(`label`,{for:S,class:`flex items-center gap-2 text-xs text-left cursor-pointer`,children:[j(`input`,{id:S,type:`checkbox`,class:`checkbox checkbox-secondary checkbox-xs mt-0.5 shrink-0`,checked:C,onChange:e=>w(e.target.checked)}),j(`span`,{class:`leading-snug`,children:c})]}):j(`p`,{class:`text-xs leading-snug text-base-content/60`,children:c})})]})}function DP({flow:e,welcomeText:t,onUnavailableCancel:n}){switch(e.state){case`idle`:return j(EP,{text:t,onStart:()=>{e.start()},isStarting:e.isStarting});case`haircheck`:return j(gP,{onJoin:()=>{e.join()},onCancel:()=>e.cancel(),isJoining:e.isStarting});case`call`:return j(cP,{onLeave:()=>e.leave()});case`ended`:return j($y,{onRestart:()=>e.restart()});case`unavailable`:return j(qy,{cause:e.unavailableCause??`busy`,canRetry:e.canRetry,onRetry:()=>{e.start()},onCancel:n});default:{let t=e.state;throw Error(`Unreachable flow state: ${String(t)}`)}}}var OP=Fe(null);function kP({children:e}){let{config:t}=ft(yi),n=t.peek().customization?.widget,r=n?.expandable??`default`,i=ln(r===`start-expanded`||r===`always`),a=ln(n?.variant??`full`),o=ln(n?.position??`bottom-right`),s=ln(r),c=ln(n?.avatar?.type??`orb`),l=O(r);gn(()=>{let e=t.value.customization?.widget,n=e?.expandable??`default`;a.value=e?.variant??`full`,o.value=e?.position??`bottom-right`,s.value=n,c.value=e?.avatar?.type??`orb`,l.current!==n&&(i.value=n===`start-expanded`||n===`always`,l.current=n)});let u=A(()=>{s.peek()!==`always`&&(i.value=!i.peek())},[i,s]),d=A(()=>{i.value=!0},[i]),f=A(()=>{s.peek()!==`always`&&(i.value=!1)},[i,s]),p=k(()=>({expanded:i,variant:a,position:o,expandable:s,avatarType:c,toggle:u,expand:d,collapse:f}),[i,a,o,s,c,u,d,f]);return j(OP.Provider,{value:p,children:e})}function AP(){let{config:e}=G_();if(e.value.show_tavus_branding!==!1)return j(jP,{});let t=e.value.customization.branding;return t?.logo||t?.text?j(MP,{logo:t.logo,text:t.text}):null}function jP(){let{isDark:e}=Nj(),t=e.value?`white`:`#140206`;return j(`a`,{href:`https://tavus.io`,target:`_blank`,rel:`noopener noreferrer`,class:`inline-flex items-center gap-1 text-xs text-base-content/50 hover:text-base-content/80 transition-colors`,children:[j(`svg`,{viewBox:`0 0 488 452`,class:`h-2.5 w-2.5 shrink-0`,fill:`none`,"aria-hidden":`true`,children:[j(`path`,{d:`M160 152V208H104V152H160Z`,fill:t}),j(`path`,{"fill-rule":`evenodd`,"clip-rule":`evenodd`,d:`M488 270.5L436 285L451 326L418.766 346L441 360L423 392L435 452H0V0H394.766L488 270.5ZM24 24V428H216.2L209 392L227 360L204.766 346L237 326L222 285L274 270.5L189.038 24H24ZM352 152C336.536 152 324 164.536 324 180C324 195.464 336.536 208 352 208C367.464 208 380 195.464 380 180C380 164.536 367.464 152 352 152Z`,fill:t})]}),j(`span`,{children:[`Powered by `,j(`span`,{class:`underline`,children:`Tavus`})]})]})}function MP({logo:e,text:t}){return j(`div`,{class:`inline-flex items-center gap-1 text-xs text-base-content/50`,children:[e?j(`img`,{src:e,alt:t||`Branding`,class:`h-2.5 shrink-0`}):null,t?j(`span`,{children:t}):null]})}var NP={title:`Hi! Want to chat?`,btn_title:`Start conversation`};function PP(){let{config:e}=G_(),t=e.value.customization.widget?.text;return k(()=>({title:t?.title||NP.title,btn_title:t?.btn_title||NP.btn_title}),[t])}function FP(){let e=ft(OP);if(!e)throw Error(`useWidgetUI must be used within WidgetUIProvider`);return e}var IP={xs:`w-6 h-6`,sm:`w-8 h-8`,md:`w-10 h-10`,lg:`w-16 h-16`},LP={xs:`w-3 h-3`,sm:`w-4 h-4`,md:`w-5 h-5`,lg:`w-8 h-8`};function RP({size:e=`md`,className:t=``}){let{avatarType:n}=FP(),{config:r}=G_(),i=r.value.replica_thumbnail_video_url??null;return(Iy(r.value).background.type===`replica`||n.value===`image`)&&i?j(`div`,{class:`relative ${IP[e]} rounded-box overflow-hidden bg-base-300 ${t}`,children:j(`video`,{src:i,class:`absolute inset-0 w-full h-full object-cover`,muted:!0,autoplay:!0,loop:!0,playsinline:!0})}):j(`div`,{class:`relative ${IP[e]} rounded-box bg-primary/15 flex items-center justify-center ${t}`,children:j(`span`,{class:`${LP[e]} rounded-full bg-primary animate-pulse`})})}function zP({variant:e}){let{toggle:t}=FP(),n=PP();return e===`tiny`?j(`button`,{type:`button`,onClick:t,"aria-label":n.btn_title,class:`rounded-box overflow-hidden shadow-xl hover:shadow-2xl transition-shadow cursor-pointer`,children:j(RP,{size:`lg`})}):e===`compact`?j(`button`,{type:`button`,onClick:t,"aria-label":n.btn_title,class:`group flex items-center gap-2.5 py-2.5 pl-2.5 pr-8 rounded-box bg-base-100 text-base-content border border-base-300 shadow-lg hover:shadow-xl transition-shadow cursor-pointer text-left`,children:[j(RP,{size:`md`}),j(`span`,{class:`flex flex-col gap-0.5`,children:[j(`span`,{class:`text-base font-medium leading-tight`,children:n.title}),j(`span`,{class:`text-sm text-base-content/60 leading-tight`,children:n.btn_title})]})]}):j(`button`,{type:`button`,onClick:t,"aria-label":n.btn_title,class:`flex flex-col gap-3 p-3 w-64 rounded-box bg-base-100 text-base-content border border-base-300 shadow-xl hover:shadow-2xl transition-shadow cursor-pointer text-left`,children:[j(`div`,{class:`flex items-center gap-2.5`,children:[j(RP,{size:`md`}),j(`span`,{class:`text-sm font-medium leading-snug`,children:n.title})]}),j(`span`,{class:`btn btn-primary btn-sm w-full pointer-events-none gap-2 flex items-center`,children:[j(My,{name:`cam`,size:16}),j(`span`,{className:`leading-4`,children:n.btn_title})]})]})}var BP=`tavus:widget:greeting-dismissed`;function VP({anchor:e}){let t=PP(),{variant:n,expand:r}=FP(),[i,a]=E(!1);D(()=>{if(n.value===`tiny`){try{if(sessionStorage.getItem(BP)===`1`)return}catch{}a(!0)}},[n]);let o=A(e=>{e.stopPropagation();try{sessionStorage.setItem(BP,`1`)}catch{}a(!1)},[]);if(!i)return null;let s=e===`right`?`right-[-6px] border-r border-b`:`left-[-6px] border-l border-t`,c=e===`right`?`-right-2`:`-left-2`;return j(`button`,{type:`button`,onClick:r,class:`relative max-w-56 rounded-box bg-base-100 text-base-content shadow-lg border border-base-300 px-3 py-2 text-sm text-left cursor-pointer animate-[tavusFadeUp_240ms_ease-out] hover:bg-base-200 transition-colors`,children:[j(`p`,{class:`leading-snug pr-3`,children:t.title}),j(`span`,{role:`button`,tabIndex:0,onClick:o,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&o(e)},class:`absolute -top-2 ${c} btn btn-ghost btn-circle btn-xs bg-base-100 border border-base-300 shadow-sm`,"aria-label":`Dismiss`,children:`×`}),j(`span`,{class:`absolute bottom-3 w-3 h-3 rotate-45 bg-base-100 border-base-300 ${s}`})]})}function HP(){let e=ft(dv);if(!e)throw Error(`useHostBridge must be used within HostBridgeProvider`);return e}var UP=`bg-base-100 text-base-content rounded-box border border-base-300 shadow-xl w-[22rem] flex flex-col animate-[tavusPopIn_180ms_ease-out]`,WP=`bg-base-100 text-base-content w-[100vw] h-[100dvh] flex flex-col animate-[tavusFadeUp_180ms_ease-out]`,GP=`p-1 flex-1 min-h-0`,KP=`p-1 flex-1 min-h-0`;function qP({variant:e,children:t,fullscreen:n}){let{collapse:r,expandable:i}=FP(),a=i.value!==`always`;return n?j(`div`,{class:WP,children:[j(`div`,{class:`flex items-center justify-end gap-2 px-2.5 py-1.5 border-b border-base-300`,children:a&&j(`button`,{type:`button`,class:`btn btn-ghost btn-circle btn-xs`,onClick:r,"aria-label":`Close`,children:j(My,{name:`close`,size:14})})}),j(`div`,{class:KP,children:t}),j(`div`,{class:`flex justify-end px-2.5`,children:j(AP,{})})]}):j(`div`,{class:`flex flex-col h-[min(34rem,calc(100dvh-3rem))]`,children:[j(`div`,{class:`${UP} flex-1 overflow-hidden`,children:[j(`div`,{class:`flex items-center justify-end gap-2 px-2.5 pt-1.5 shrink-0`,children:a&&j(`button`,{type:`button`,class:`btn btn-ghost btn-circle btn-xs`,onClick:r,"aria-label":`Close`,children:j(My,{name:`close`,size:14})})}),j(`div`,{class:GP,children:t})]}),j(`div`,{class:`flex justify-end pr-2 pt-1.5 shrink-0`,children:j(AP,{})})]})}var JP=_n(`Widget`),YP=`1rem`,XP=480;function ZP(){return typeof window>`u`?!1:window.innerWidth<=XP}function QP(e){switch(e){case`bottom-right`:return{bottom:YP,right:YP};case`bottom-left`:return{bottom:YP,left:YP};case`top-right`:return{top:YP,right:YP};case`top-left`:return{top:YP,left:YP};case`top`:return{top:YP,left:`50%`,transform:`translateX(-50%)`};case`bottom`:return{bottom:YP,left:`50%`,transform:`translateX(-50%)`}}}var $P=[`top`,`bottom`,`left`,`right`,`transform`];function eF(e){return e===`bottom-left`||e===`top-left`?`left`:`right`}function tF(){let{config:e,initError:t}=G_(),n=PP(),{expanded:r,position:i,variant:a}=FP(),{shadowHost:o}=HP(),s=Jy(),c=ln(ZP());D(()=>{if(typeof window>`u`)return;c.value=ZP();let e=()=>{c.value=ZP()};return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[c]);let l=k(()=>({fallback_button:n.btn_title}),[n.btn_title]);if(gn(()=>{let e=o.value,t=i.value,n=r.value,a=n&&c.value;if(e){if(a)e.style.top=`0`,e.style.right=`0`,e.style.bottom=`0`,e.style.left=`0`,e.style.transform=``;else{let n=QP(t);for(let t of $P)e.style[t]=n[t]??``}e.dataset.tavusWidgetPosition=t,e.dataset.tavusWidgetExpanded=n?`true`:`false`,e.dataset.tavusWidgetFullscreen=a?`true`:`false`,e.dataset.tavusWidgetSmall=c.value?`true`:`false`}}),t.value)return JP.error(`Widget cannot initialize (init request failed):`,t.value),null;if(e.value.is_available===!1&&e.value.unavailable_reason===`total_limit`)return JP.error(`Widget is unavailable (total_limit reached) — not rendering`),null;if(!r.value){let e=eF(i.value),t=e===`right`?`flex items-end gap-2 justify-end`:`flex items-end gap-2 flex-row-reverse justify-end`,n=e===`right`?`justify-end pr-2`:`justify-start pl-2`;return j(`div`,{class:`flex flex-col`,children:[j(`div`,{class:t,children:[j(VP,{anchor:e}),j(zP,{variant:a.value})]}),j(`div`,{class:`flex ${n} pt-1.5`,children:j(AP,{})})]})}return e.value.is_available===!1?j(qP,{variant:a.value,fullscreen:c.value,children:j(Tv,{children:j(qy,{cause:e.value.unavailable_reason??`daily_limit`,canRetry:!1,onRetry:()=>{}})})}):j(qP,{variant:a.value,fullscreen:c.value,children:j(Tv,{children:j(DP,{flow:s,welcomeText:l,onUnavailableCancel:()=>s.restart()})})})}var nF=`:host {
|
|
158
|
+
- "app": Tool callable by the app from this server only`),csp:JE().optional(),permissions:JE().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 Ej=Z({method:$(`ui/download-file`),params:Z({contents:X(Q([eA,tA])).describe(`Resource contents to download — embedded (inline data) or linked (host fetches). Uses standard MCP resource types.`)})}),Dj=Z({method:$(`ui/message`),params:Z({role:$(`user`).describe(`Message role, currently only "user" is supported.`),content:X(nA).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:pj.optional().describe(`CSP configuration from resource metadata.`),permissions:mj.optional().describe(`Sandbox permissions from resource metadata.`)})}),Z({method:$(`ui/notifications/tool-result`),params:dA.describe(`Standard MCP tool execution result.`)});var Oj=Z({toolInfo:Z({id:jO.optional().describe(`JSON-RPC id of the tools/call request.`),tool:cA.describe(`Tool definition including name, inputSchema, etc.`)}).optional().describe(`Metadata of the tool call that instantiated this App.`),theme:cj.optional().describe(`Current color theme preference.`),styles:_j.optional().describe(`Style configuration for theming the app.`),displayMode:lj.optional().describe(`How the UI is currently displayed.`),availableDisplayModes:X(lj).optional().describe(`Display modes the host supports.`),containerDimensions:Q([Z({height:Y().describe(`Fixed container height in pixels.`)}),Z({maxHeight:Q([Y(),GE()]).optional().describe(`Maximum container height in pixels.`)})]).and(Q([Z({width:Y().describe(`Fixed container width in pixels.`)}),Z({maxWidth:Q([Y(),GE()]).optional().describe(`Maximum container width in pixels.`)})])).optional().describe(`Container dimensions. Represents the dimensions of the iframe or other
|
|
159
|
+
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:WE().optional().describe(`Whether the device supports touch input.`),hover:WE().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:Oj.describe(`Partial context update containing only changed fields.`)});var kj=Z({method:$(`ui/update-model-context`),params:Z({content:X(nA).optional().describe(`Context content blocks (text, image, etc.).`),structuredContent:QE(J(),qE().describe(`Structured content for machine-readable context data.`)).optional().describe(`Structured content for machine-readable context data.`)})}),Aj=Z({method:$(`ui/initialize`),params:Z({appInfo:KO.describe(`App identification (name and version).`),appCapabilities:Sj.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:KO.describe(`Host application identification and version.`),hostCapabilities:xj.describe(`Features and capabilities provided by the host.`),hostContext:Oj.describe(`Rich context about the host environment.`)}).passthrough();var jj=[sj],Mj=class extends oj{_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:hj,sandboxready:fj,initialized:Cj,requestteardown:bj,loggingmessage:yA};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(Aj,e=>this._oninitialize(e)),this.setRequestHandler(nk,(e,t)=>(this.onping?.(e.params,t),{})),this.replaceRequestHandler(wj,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(Dj,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(dj,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(Ej,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(wj,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(kj,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(pA,async(e,t)=>{if(!this._oncalltool)throw Error(`No oncalltool handler set`);return this._oncalltool(e.params,t)})}set oncreatesamplingmessage(e){this.setRequestHandler(DA,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(kk,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(jk,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(Fk,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(Kk,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:jj.includes(t)?t:sj,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];Nj(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},vj,t)}sendResourceTeardown=this.teardownResource;callTool(e,t){return this.request({method:`tools/call`,params:e},dA,t)}listTools(e,t){return this.request({method:`tools/list`,params:e},uA,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},dA,{signal:t.signal}),e.tools.listChanged&&this._client.setNotificationHandler(mA,e=>this.sendToolListChanged(e.params))),e.resources&&(this.onlistresources=async(e,t)=>this._client.request({method:`resources/list`,params:e},Ak,{signal:t.signal}),this.onlistresourcetemplates=async(e,t)=>this._client.request({method:`resources/templates/list`,params:e},Mk,{signal:t.signal}),this.onreadresource=async(e,t)=>this._client.request({method:`resources/read`,params:e},Ik,{signal:t.signal}),e.resources.listChanged&&this._client.setNotificationHandler(Lk,e=>this.sendResourceListChanged(e.params))),e.prompts&&(this.onlistprompts=async(e,t)=>this._client.request({method:`prompts/list`,params:e},qk,{signal:t.signal}),e.prompts.listChanged&&this._client.setNotificationHandler(aA,e=>this.sendPromptListChanged(e.params)))}return super.connect(e)}};function Nj(e,t){return JSON.stringify(e)===JSON.stringify(t)}function Pj(){let e=ft(mv);if(!e)throw Error(`useTheme must be used within ThemeProvider`);return e}async function Fj(e){try{await e.teardownResource({},{timeout:1e3})}catch{}try{await e.close()}catch{}}function Ij({state:e}){return e.enabled?j(`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:[j(`summary`,{class:`cursor-pointer font-medium`,children:`Magic Canvas debug`}),j(`dl`,{class:`mt-2 grid gap-2`,children:[j(Lj,{label:`iframe`,value:e.iframeLifecycleState}),j(Lj,{label:`post`,value:e.lastInteractionPostResult}),j(Lj,{label:`context`,value:e.lastModelContextUpdate}),j(Lj,{label:`error`,value:e.lastError}),j(Rj,{label:`tool_call`,value:e.lastToolCall}),j(Rj,{label:`canvas_config`,value:e.parsedCanvasConfig})]})]}):null}function Lj({label:e,value:t}){return t?j(`div`,{children:[j(`dt`,{class:`font-semibold`,children:e}),j(`dd`,{class:`break-words text-base-content/70`,children:t})]}):null}function Rj({label:e,value:t}){return t===void 0?null:j(`div`,{children:[j(`dt`,{class:`font-semibold`,children:e}),j(`dd`,{children:j(`pre`,{class:`max-h-40 overflow-auto rounded bg-base-200 p-2 text-[10px] leading-relaxed`,children:JSON.stringify(t,null,2)})})]})}var zj=new Set([`mcp-ui.tavus.io`,`mcp-ui.tavus-preview.io`]),Bj=[`.sandbox-tavus.io`],Vj=new Set([`tavusapi.com`]);function Hj(e){let t;try{t=new URL(e)}catch{return!1}return Gj(t)?!0:t.protocol===`https:`?zj.has(t.hostname)?!0:Bj.some(e=>t.hostname.endsWith(e)):!1}function Uj(e){return Hj(e)}function Wj(e){let t;try{t=new URL(e)}catch{return!1}return Kj(t)?!0:t.protocol===`https:`&&Vj.has(t.hostname)}function Gj(e){return Kj(e)}function Kj(e){return!qj()||e.protocol!==`http:`&&e.protocol!==`https:`?!1:[`localhost`,`127.0.0.1`,`::1`,`[::1]`].includes(e.hostname)}function qj(){try{let e=globalThis.location?.hostname;return typeof e==`string`&&[`localhost`,`127.0.0.1`,`::1`,`[::1]`].includes(e)}catch{return!1}}var Jj=`tavus.canvas.interaction`,Yj=[`safe-area-right`,`safe-area-left`,`safe-area-bottom`,`full`],Xj=`safe-area-right`,Zj={x:275/1280,y:111/720,width:730/1280,height:609/720},Qj={type:`snapshot_mirror`};function $j(e){return bM(e)?e.message_type===`conversation`&&e.event_type===`conversation.tool_call`&&typeof e.conversation_id==`string`&&bM(e.properties):!1}function eM(e){if(!bM(e))return null;let t=PM(e,`component`),n=PM(e,`component_version`),r=PM(e,`sandbox_url`),i=LM(e,`mcp_server_url`,Uj),a=LM(e,`api_base_url`,Wj),o=LM(e,`interaction_url`,Wj),s=wM(e.layout),c=e.version;return c!==1||!t||!n||!r||!Hj(r)||i===null||a===null||o===null||s===null?null:{version:c,component:t,component_version:n,resource_uri:PM(e,`resource_uri`),sandbox_url:r,mcp_server_url:i,mcp_tool_name:PM(e,`mcp_tool_name`),api_base_url:a,interaction_url:o,layout:s,host_context:bM(e.host_context)?e.host_context:void 0}}function tM(e){if(e===void 0)return{ok:!0,value:{}};if(bM(e))return{ok:!0,value:e};if(typeof e!=`string`)return{ok:!1,error:Error(`Magic Canvas tool arguments must be an object or JSON string.`)};try{let t=JSON.parse(e);return bM(t)?{ok:!0,value:t}:{ok:!1,error:Error(`Magic Canvas tool arguments must decode to an object.`)}}catch(e){return{ok:!1,error:xM(e)}}}function nM(e){let t=e.properties.name;if(t!==`canvas_clear`&&t!==`update_component`)return null;let n=tM(e.properties.arguments);if(!n.ok)throw n.error;if(t===`canvas_clear`){let t=n.value.tool_call_id,r=n.value.reason;if(t!==void 0&&typeof t!=`string`)throw Error(`Magic Canvas clear tool_call_id must be a string when provided.`);if(r!==void 0&&typeof r!=`string`)throw Error(`Magic Canvas clear reason must be a string when provided.`);return{kind:`clear`,conversation_id:e.conversation_id,tool_call_id:t,reason:r}}let r=n.value.tool_call_id,i=n.value.updates;if(typeof r!=`string`||r.length===0)throw Error(`Magic Canvas update_component requires a target tool_call_id.`);if(!bM(i))throw Error(`Magic Canvas update_component requires an object updates payload.`);return{kind:`update`,conversation_id:e.conversation_id,tool_call_id:r,updates:i}}function rM(e){return e.display_mode===`fullscreen`?`full`:e.preferred_slot}function iM(e){return e===`full`||e===`safe-area-bottom`}function aM(e,t){let n=rM(t.layout);return iM(n)?[t]:[...e.filter(e=>{let t=rM(e.layout);return!iM(t)&&t!==n}),t]}function oM(e,t){switch(t.kind){case`show`:{let n=e.find(e=>e.id===t.instance.id),r=n?{...t.instance,revision:n.revision+1}:t.instance;return aM(e.filter(e=>e.id!==t.instance.id),r)}case`update`:{let n=e=>e.conversation_id===t.conversation_id&&e.tool_call_id===t.tool_call_id,r=gM(t.updates),i,a=e.map(e=>{if(!n(e))return e;let t={...e,arguments:{...e.arguments,...r.componentArguments},layout:{preferred_slot:r.preferredSlot??e.layout.preferred_slot,display_mode:r.displayMode??e.layout.display_mode,avoid_safe_area:r.avoidSafeArea??e.layout.avoid_safe_area,safe_area:r.safeArea??e.layout.safe_area,backdrop:r.backdrop??e.layout.backdrop},revision:e.revision+1};return i=t,t});if(i===void 0)return a;let o=e.find(n);return o&&rM(o.layout)===rM(i.layout)?a:aM(a.filter(e=>!n(e)),i)}case`clear`:return t.tool_call_id?e.filter(e=>!(e.conversation_id===t.conversation_id&&e.tool_call_id===t.tool_call_id)):e.filter(e=>e.conversation_id!==t.conversation_id)}}function sM(e){if(!bM(e)||!Array.isArray(e.content))return null;for(let t of e.content){if(!bM(t))continue;let e=(bM(t._meta)?t._meta:null)?.[Jj];if(bM(e))return RM(e)}return null}function cM(e,t){let n=t.type,r=t.value;if(!n)throw Error(`Magic Canvas interaction is missing type.`);if(r===void 0)throw Error(`Magic Canvas interaction is missing value.`);return{interaction_id:t.interaction_id??yM(e.tool_call_id,n),conversation_id:e.conversation_id,tool_call_id:e.tool_call_id,component:t.component??e.canvas_config.component,component_version:t.component_version??e.canvas_config.component_version,type:n,value:r,metadata:bM(t.metadata)?t.metadata:{}}}function lM(e){return e.type===`dismiss`||e.type===`clear`?!0:e.type!==`submit`&&e.type!==`skip`?!1:e.component===`canvas.question`||e.component===`canvas.input`||e.component===`canvas.calendar`}function uM(e){return!bM(e)||!Array.isArray(e.content)?``:e.content.map(e=>bM(e)&&e.type===`text`&&typeof e.text==`string`?e.text:``).filter(Boolean).join(`
|
|
160
|
+
`).trim()}function dM(e,t){let n=bM(t.structuredContent)?t.structuredContent:void 0,r=SM(t.content),i=typeof n?.state==`string`?n.state:`updated`,a=typeof n?.summary==`string`?n.summary:r,o=[`Magic Canvas state update for ${e.canvas_config.component} (${e.tool_call_id}).`,`State: ${i}.`];return a&&o.push(`Summary: ${a}`),n&&o.push(`Structured state: ${CM(n)}`),r&&r!==a&&o.push(r),o.join(`
|
|
161
|
+
`)}function fM({conversationId:e,toolCallId:t,args:n,canvasConfig:r}){let i=gM(n);return{id:t,conversation_id:e,tool_call_id:t,arguments:i.componentArguments,canvas_config:r,layout:{preferred_slot:i.preferredSlot??r.layout?.preferred_slot??_M(r.component),display_mode:i.displayMode??`inline`,avoid_safe_area:i.avoidSafeArea??r.layout?.avoid_safe_area??!0,safe_area:i.safeArea??r.layout?.safe_area??Zj,backdrop:i.backdrop??r.layout?.backdrop??Qj},revision:0}}function pM(e,t){let n=e.layout.display_mode;return{...e.layout,display_mode:n,viable_slot:n===`fullscreen`?`full`:hM(e.layout.preferred_slot,t)}}function mM(e,t){let n=e.filter(e=>!e.avoid_safe_area||e.display_mode===`fullscreen`?!1:e.viable_slot===`safe-area-left`||e.viable_slot===`safe-area-right`),r=n.some(e=>e.viable_slot===`safe-area-left`),i=n.some(e=>e.viable_slot===`safe-area-right`);if(r&&i)return{active:!1,video_shift_x:0,backdrop:Qj};let a=[...n].reverse()[0];if(!a||t.width<900)return{active:!1,video_shift_x:0,backdrop:Qj};let o=Math.min(448,Math.max(0,t.width-32)),s=a.safe_area,c=s.x*t.width,l=(s.x+s.width)*t.width,u=Math.min(360,t.width*.3),d=0;return d=a.viable_slot===`safe-area-left`?IM(16+o+24-c,0,u):-IM(l-(t.width-16-o-24),0,u),{active:!0,side:a.viable_slot===`safe-area-left`?`left`:`right`,video_shift_x:Math.round(d),safe_area:s,backdrop:a.backdrop}}function hM(e,t){return e===`full`||e===`safe-area-bottom`&&t.visualViewportHeight!==void 0&&t.visualViewportHeight<t.height*.75?`full`:(e===`safe-area-left`||e===`safe-area-right`)&&t.width<768&&t.height>=t.width?`safe-area-bottom`:e}function gM(e){let t={};for(let[n,r]of Object.entries(e))n===`layout`||n===`preferred_slot`||n===`preferredSlot`||n===`display_mode`||n===`displayMode`||n===`presentation`||n===`fullscreen`||n===`avoid_safe_area`||n===`avoidSafeArea`||n===`safe_area`||n===`safeArea`||n===`backdrop`||(t[n]=r);return{componentArguments:t,preferredSlot:TM(e.layout)??TM(e.preferred_slot)??TM(e.preferredSlot),displayMode:EM(e),avoidSafeArea:DM(e),safeArea:OM(e),backdrop:kM(e)}}function _M(e){switch(e){case`canvas.alert`:return`safe-area-bottom`;case`canvas.chart`:case`canvas.image`:case`canvas.video`:return`full`;default:return Xj}}function vM(e,t){let n=t?.displayScale??1;if(e.display_mode===`fullscreen`||e.viable_slot===`full`)return{maxWidth:void 0,maxHeight:void 0,displayScale:n};let r=t?.maxHeight??720;return e.viable_slot===`safe-area-bottom`?{maxWidth:720,maxHeight:r,displayScale:n}:{width:384,maxHeight:r,displayScale:n}}function yM(e,t){return`ci_${e.replace(/[^a-zA-Z0-9_-]/g,`_`)}_${t}_${globalThis.crypto?.randomUUID?.()??Math.random().toString(36).slice(2,10)}`}function bM(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function xM(e){return e instanceof Error?e:Error(String(e))}function SM(e){return Array.isArray(e)?e.map(e=>bM(e)&&e.type===`text`&&typeof e.text==`string`?e.text:``).filter(Boolean).join(`
|
|
162
|
+
`).trim():``}function CM(e){let t=JSON.stringify(e);return t?t.length<=2e3?t:`${t.slice(0,2e3)}...`:`{}`}function wM(e){if(e===void 0)return;if(!bM(e))return null;let t=TM(e),n=AM(e.safe_area??e.safeArea),r=jM(e.backdrop);return n===null||r===null?null:{...t?{preferred_slot:t}:{},...MM(e.avoid_safe_area??e.avoidSafeArea,`avoid_safe_area`),...n?{safe_area:n}:{},...r?{backdrop:r}:{}}}function TM(e){if(typeof e==`string`&&NM(e))return e;if(!bM(e))return;let t=e.preferred_slot??e.preferredSlot??e.slot;return typeof t==`string`&&NM(t)?t:void 0}function EM(e){if(e.presentation===!0||e.fullscreen===!0)return`fullscreen`;if(e.presentation===!1||e.fullscreen===!1)return`inline`;let t=e.display_mode??e.displayMode;return t===`fullscreen`||t===`inline`?t:void 0}function DM(e){let t=bM(e.layout)?e.layout:void 0,n=e.avoid_safe_area??e.avoidSafeArea??t?.avoid_safe_area??t?.avoidSafeArea;return typeof n==`boolean`?n:void 0}function OM(e){let t=bM(e.layout)?e.layout:void 0;return AM(e.safe_area??e.safeArea??t?.safe_area??t?.safeArea)??void 0}function kM(e){let t=bM(e.layout)?e.layout:void 0;return jM(e.backdrop??t?.backdrop)??void 0}function AM(e){if(e===void 0)return;if(!bM(e))return null;let t=FM(e,`x`),n=FM(e,`y`),r=FM(e,`width`),i=FM(e,`height`);return t===void 0||n===void 0||r===void 0||i===void 0||t<0||n<0||r<=0||i<=0||t+r>1.001||n+i>1.001?null:{x:IM(t,0,1),y:IM(n,0,1),width:IM(r,0,1),height:IM(i,0,1)}}function jM(e){if(e===void 0)return;if(e===`snapshot_mirror`||e===`none`)return{type:e};if(!bM(e))return null;let t=e.type;return t===`snapshot_mirror`||t===`none`?{type:t}:null}function MM(e,t){return typeof e==`boolean`?{[t]:e}:{}}function NM(e){return Yj.includes(e)}function PM(e,t){let n=e[t];return typeof n==`string`&&n.length>0?n:void 0}function FM(e,t){let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0}function IM(e,t,n){return Math.min(Math.max(e,t),n)}function LM(e,t,n){let r=PM(e,t);if(r)return n(r)?r:null}function RM(e){return e.interaction_id!==void 0&&typeof e.interaction_id!=`string`||e.component!==void 0&&typeof e.component!=`string`||e.component_version!==void 0&&typeof e.component_version!=`string`||e.type!==void 0&&typeof e.type!=`string`||e.metadata!==void 0&&!bM(e.metadata)?null:e}var zM=`tavus-deployment magic-canvas/0.0.0`;function BM(e){if(!$j(e)||e.canvas_config===void 0||e.canvas_config===null)return null;let t=eM(e.canvas_config),n=e.properties.tool_call_id;if(!t)return null;if(!n)throw Error(`Received Magic Canvas tool call without tool_call_id.`);let r=tM(e.properties.arguments);if(!r.ok)throw r.error;return fM({conversationId:e.conversation_id,toolCallId:n,args:r.value,canvasConfig:t})}function VM(e){if(!$j(e))return null;if(e.canvas_config!==void 0&&e.canvas_config!==null){let t=BM(e);return t?{kind:`show`,instance:t}:null}return nM(e)}function HM(e){return{body:{interaction_id:e.interaction_id,tool_call_id:e.tool_call_id,component:e.component,component_version:e.component_version,type:e.type,value:e.value,metadata:e.metadata}}}function UM(e,t){return{theme:e.theme,displayMode:t?.display_mode??`inline`,availableDisplayModes:[`inline`,`fullscreen`],...t?{containerDimensions:vM(t),layout:{preferred_slot:t.preferred_slot,viable_slot:t.viable_slot,avoid_safe_area:t.avoid_safe_area,safe_area:t.safe_area,backdrop:t.backdrop}}:{},platform:`web`,userAgent:zM,styles:{variables:WM(e.cssVars)}}}function WM(e){return{"--border-radius-md":e[`--radius-box`]??e[`--tavus-boxes-radius`]??`0.5rem`,"--border-radius-sm":e[`--radius-field`]??e[`--tavus-field-radius`]??`0.375rem`,"--border-radius-xs":e[`--radius-selector`]??`0.25rem`,"--border-radius-lg":e[`--radius-box`]??e[`--tavus-boxes-radius`]??`0.75rem`,"--border-width-regular":e[`--border`]??e[`--tavus-border-width`]??`1px`,"--font-text-sm-size":`0.875rem`,"--font-text-md-size":`1rem`,...GM(e)}}function GM(e){let t=e[`--color-base-content`],n=e[`--color-base-100`],r=e[`--color-base-200`],i=e[`--color-base-300`],a=e[`--color-error`],o={},s=(e,t)=>{t&&(o[e]=t)},c=(e,t,n)=>e&&n?`color-mix(in oklch, ${e} ${t}%, ${n})`:void 0;return s(`--color-background-primary`,n),s(`--color-background-secondary`,r),s(`--color-border-secondary`,i),s(`--color-border-primary`,c(t,28,n)),s(`--color-text-primary`,t),s(`--color-text-secondary`,c(t,62,n)),s(`--color-text-danger`,a),s(`--color-border-danger`,a),o}var KM=1e3,qM=5e3,JM=1200,YM=48,XM=`allow-scripts`,ZM={"canvas.scheduling_embed":`allow-scripts allow-same-origin allow-popups allow-forms`};function QM(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 $M=class{onmessage;onerror;onclose;#e;#t;constructor(e){this.#e=e}start(){let e=e=>{QM(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 eN(e){for(let t of Yj)if(e.some(e=>mN(e)===t))return t;return null}function tN({onLayoutEffectChange:e,onRenderedSlotChange:t,debugEnabled:n=hN()}={}){let{client:r}=G_(),{dataTheme:i,cssVars:a}=Pj(),o=ah(),s=jg(),[c,l]=E([]),[u,d]=lN(),[f,p]=E(()=>({enabled:n,iframeLifecycleState:`idle`})),m=A(e=>{p(t=>({...t,...e}))},[]),h=A((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=k(()=>({theme:i.value===`dark`?`dark`:`light`,cssVars:a.value}),[i.value,a.value]);D(()=>{p(e=>e.enabled===n?e:{...e,enabled:n})},[n]),Ug({onAppMessage:A(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=VM(e.data);if(!t)return;l(e=>oM(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:vN(e).message})}},[s,m])});let _=c.map(e=>({instance:e,layout:pM(e,d)})),v=mM(_.map(({layout:e})=>e),d),y=[..._].reverse().find(({layout:e})=>e.display_mode===`fullscreen`)?.instance.tool_call_id;D(()=>{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=eN(_.map(({layout:e})=>e));D(()=>{t?.(b)},[t,b]);let x=c.length>0||f.enabled;return j(`div`,{ref:u,"data-magic-canvas-root":!0,class:`pointer-events-none absolute inset-0 z-30`,children:[x&&y&&j(`div`,{class:`absolute inset-0 bg-black/45`}),x&&Yj.map(e=>{let t=_.filter(({layout:t})=>mN(t)===e);return t.length===0?null:j(nN,{slot:e,safeAreaTop:v.safe_area?.y,children:e=>t.map(({instance:t,layout:n})=>j(rN,{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&&j(`div`,{class:`absolute right-4 bottom-24 @max-mobile:right-3 @max-mobile:bottom-20`,children:j(Ij,{state:f})})]})}function nN({slot:e,safeAreaTop:t,children:n}){let[r,i]=uN(),a=n(e===`full`?void 0:i);if(e===`safe-area-left`||e===`safe-area-right`){let n=t==null?`1rem`:`${t*100}%`;return j(`div`,{ref:r,class:pN(e),style:{top:n,bottom:`${fN}px`},"data-canvas-slot":e,children:j(`div`,{class:`my-auto flex w-full flex-col gap-2`,children:a})})}return j(`div`,{ref:r,class:pN(e),"data-canvas-slot":e,children:a})}function rN({availableHeight:e,client:t,hostTheme:n,instance:r,layout:i,dimmed:a,onDebug:o,onComplete:s,onDisplayModeChange:c,sendAppMessage:l}){let u=O(null),d=O(null),f=O(e),p=O(320),m=O(n),h=O(r),g=O(i),_=O(-1),v=O(s),y=O(c),b=O(l),[x,S]=E(320);D(()=>{h.current=r},[r]),D(()=>{p.current=x,d.current?.setHostContext(sN(h.current,m.current,g.current,f.current,x))},[x]),D(()=>{f.current=e;let t=oN(n,u.current);m.current=t,d.current?.setHostContext(sN(h.current,t,g.current,e,p.current))},[e,n]),D(()=>{g.current=i,d.current?.setHostContext(sN(h.current,m.current,i,e,p.current))},[e,i]),D(()=>{v.current=s,y.current=c,b.current=l},[s,c,l]),D(()=>{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:vN(e).message})},C=()=>{if(n||!a)return;let e=h.current,t=dM(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 Mj(null,{name:`tavus-deployment`,version:`0.0.0`},{logging:{},message:{text:{},structuredContent:{}},updateModelContext:{text:{},structuredContent:{}}},{hostContext:sN(r,oN(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,YM),720))},u.onmessage=async e=>{let r=sM(e),i=uM(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=cM(e,r),s=HM(a),l=new AbortController,u=globalThis.setTimeout(()=>l.abort(),qM);try{await wn(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}),lM(a)&&(a.type===`submit`?(c&&clearTimeout(c),c=setTimeout(()=>{c=null,n||v.current()},JM)):v.current())}catch(e){let t=vN(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()},KM),{}),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(sN(h.current,m.current,g.current,f.current,p.current)),{mode:t}},u.connect(new $M(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&&Fj(i)}},[t,r.id,r.canvas_config.sandbox_url,o]),D(()=>{r.revision!==0&&(r.revision<=_.current||(_.current=r.revision,d.current?.sendToolInput({arguments:r.arguments}).catch(e=>{o({iframeLifecycleState:`error`,lastError:vN(e).message})})))},[r.arguments,r.revision,o]);let C=i.viable_slot===`full`||i.display_mode===`fullscreen`,w=C?null:cN(x,e),ee=w?.placeholderStyle,T=w?.cardStyle,te=C?{height:`100%`}:w?.iframeStyle??{height:`${x}px`},ne=[`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(` `),re=ZM[r.canvas_config.component]??XM,ie=j(`div`,{class:ne,style:T,"data-canvas-card":i.viable_slot,children:j(`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:re,style:te})});return C?ie:j(`div`,{class:`block w-full`,style:ee,children:ie})}var iN=[`--color-base-100`,`--color-base-200`,`--color-base-300`,`--color-base-content`,`--color-primary`,`--color-error`];function aN(e){if(!e||typeof getComputedStyle!=`function`)return{};let t=getComputedStyle(e),n={};for(let e of iN){let r=t.getPropertyValue(e).trim();r&&(n[e]=r)}return n}function oN(e,t){let n=aN(t);return Object.keys(n).length===0?e:{...e,cssVars:{...e.cssVars,...n}}}function sN(e,t,n,r,i){let a=UM(t,n),o=n.viable_slot===`full`||n.display_mode===`fullscreen`,s=o?void 0:gN(r),c=o?1:cN(i??0,r)?.displayScale??1;return{...e.canvas_config.host_context,...a,containerDimensions:{..._N(a.containerDimensions)?a.containerDimensions:{},...s===void 0?{}:{maxHeight:s},displayScale:c}}}function cN(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 lN(){let e=O(null),[t,n]=E(()=>dN(null));return D(()=>{let t=()=>n(t=>{let n=dN(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 uN(){let e=O(null),[t,n]=E();return D(()=>{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 dN(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 fN=72;function pN(e){let t=`absolute flex gap-2`;switch(e){case`safe-area-left`:return`${t} left-4 w-[min(28rem,calc(100vw_-_2rem))] flex-col overflow-y-auto`;case`safe-area-right`:return`${t} right-4 w-[min(28rem,calc(100vw_-_2rem))] 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 mN(e){return e.display_mode===`fullscreen`&&e.preferred_slot!==`full`?e.preferred_slot:e.viable_slot}function hN(){return!1}function gN(e){return e===void 0||!Number.isFinite(e)||e<=0?720:Math.min(Math.floor(e),720)}function _N(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function vN(e){return e instanceof Error?e:Error(String(e))}var yN=24,bN=96;function xN(e=document){let t=Array.from(e.querySelectorAll(`[data-canvas-card]`)).map(e=>e.getBoundingClientRect());return t.length===0?null:{left:Math.min(...t.map(e=>e.left)),right:Math.max(...t.map(e=>e.right)),top:Math.min(...t.map(e=>e.top)),bottom:Math.max(...t.map(e=>e.bottom))}}function SN(e){let t=e?.getRootNode();return t instanceof ShadowRoot?t:document}function CN(e,t,n){if(!t)return!1;let r=globalThis.innerWidth,i=globalThis.innerHeight,a=e?.safe_area??Zj,o=a.x*r+n,s=(a.x+a.width)*r+n,c=a.y*i,l=(a.y+a.height)*i;return o<t.right&&s>t.left&&c<t.bottom&&l>t.top}function wN(e,t,n){let[r,i]=E(()=>e?xN(SN(n?.current)):null);return ut(()=>{if(!e){i(null);return}let t=SN(n?.current),r=()=>i(xN(t)),a=new ResizeObserver(r),o=()=>{for(let e of t.querySelectorAll(`[data-canvas-card]`))a.observe(e)};r(),o(),a.observe(document.documentElement);let s=globalThis.requestAnimationFrame(()=>{r(),o()});return globalThis.addEventListener(`resize`,r),()=>{a.disconnect(),globalThis.removeEventListener(`resize`,r),globalThis.cancelAnimationFrame(s)}},[e,t,n]),e?r:null}function TN(e,t,n,r,i){let a=e?.side??(n===`safe-area-left`?`left`:n===`safe-area-right`?`right`:null);return{usePip:a!=null&&(t===`pip`||t===`auto`&&CN(e,r,i)),side:a}}function EN(e,t=document){let n=globalThis.innerWidth,r=globalThis.innerHeight,i=Array.from(t.querySelectorAll(`[data-canvas-card]`)).map(e=>e.getBoundingClientRect()),a,o,s,c;if(i.length>0){let t=Math.min(...i.map(e=>e.left)),r=Math.max(...i.map(e=>e.right));s=Math.min(...i.map(e=>e.top)),c=Math.max(...i.map(e=>e.bottom)),[a,o]=e===`right`?[0,t]:[r,n]}else{let t=Math.min(448,Math.max(0,n-32));[a,o]=e===`right`?[0,n-16-t]:[16+t,n],s=0,c=r}let l=o-a>=144&&c-s>=bN&&a>=0&&o<=n;if(i.length>0&&!l){let t=Math.min(448,Math.max(0,n-32));[a,o]=e===`right`?[0,n-16-t]:[16+t,n],s=0,c=r}let u=Math.max(0,o-a-yN*2),d=Math.max(bN,Math.min(u,r-yN*2));return{centerX:(a+o)/2,centerY:(s+c)/2,diameter:d}}var DN=`560ms linear(0, 0, .0001, .0002, .0003, .0005, .0007, .001, .0013, .0016, .002, .0024, .0029, .0033, .0039, .0044, .005, .0057, .0063, .007, .0079, .0086, .0094, .0103, .0112, .0121, .0132 1.84%, .0153, .0175, .0201, .0226, .0253, .0283, .0313, .0345, .038, .0416, .0454, .0493, .0535, .0576, .0621, .0667, .0714, .0764, .0816 5.04%, .0897, .098 5.62%, .1071, .1165, .1263 6.56%, .137, .1481 7.25%, .1601 7.62%, .1706 7.94%, .1819 8.28%, .194, .2068 9.02%, .2331 9.79%, .2898 11.44%, .3151 12.18%, .3412 12.95%, .3533, .365 13.66%, .3786, .3918, .4045, .4167, .4288, .4405, .452, .4631 16.72%, .4759, .4884, .5005, .5124, .5242, .5354, .5467, .5576, .5686, .5791, .5894, .5995, .6094, .6194, .6289, .6385, .6477, .6569, .6659 24.45%, .6702, .6747, .6789, .6833, .6877, .6919, .696, .7002, .7043, .7084, .7125, .7165, .7205, .7244, .7283, .7321, .7358, .7396, .7433, .7471, .7507, .7544, .7579, .7615, .7649, .7685, .7718, .7752, .7786, .782, .7853, .7885, .7918, .7951, .7982, .8013, .8043, .8075, .8104, .8135, .8165, .8195, .8224, .8253, .8281, .8309, .8336, .8365, .8391, .8419, .8446, .8472, .8499, .8524, .855, .8575, .8599, .8625 37.27%, .8651, .8678, .8703, .8729, .8754, .8779, .8803, .8827, .8851, .8875, .8898, .892, .8942, .8965, .8987, .9009, .903, .9051, .9071, .9092, .9112, .9132, .9151, .9171, .919, .9209, .9227, .9245, .9262, .928, .9297, .9314, .9331, .9347, .9364, .9379, .9395, .941, .9425, .944, .9454, .9469, .9483, .9497, .951, .9524, .9537, .955, .9562, .9574, .9586, .9599, .961, .9622, .9633, .9644, .9655, .9665, .9676, .9686, .9696, .9705, .9715, .9724, .9733, .9742, .975, .9758, .9766, .9774, .9782, .9789, .9796, .9804, .9811, .9817, .9824, .9831, .9837, .9843, .9849, .9855, .986, .9866, .9871, .9877, .9882, .9887, .9892, .9896 70.56%, .9905 71.67%, .9914 72.82%, .9922, .9929 75.2%, .9936 76.43%, .9942 77.71%, .9948 79.03%, .9954 80.39%, .9959 81.81%, .9963 83.28%, .9968 84.82%, .9972 86.41%, .9975 88.07%, .9979 89.81%, .9982 91.64%, .9984 93.56%, .9987 95.58%, .9989 97.72%, .9991)`;function ON(e,t){let n=Math.abs(t)/2;return e===`left`?`${n}px center`:`calc(100% - ${n}px) center`}function kN(e,t,n){let[r,i]=E(()=>e&&t?EN(t,SN(n?.current)):null);return ut(()=>{if(!e||!t){i(null);return}let r=SN(n?.current),a=()=>i(EN(t,r)),o=new ResizeObserver(a),s=()=>{for(let e of r.querySelectorAll(`[data-canvas-card]`))o.observe(e)};a(),s(),o.observe(document.documentElement);let c=globalThis.requestAnimationFrame(()=>{a(),s()});return globalThis.addEventListener(`resize`,a),()=>{o.disconnect(),globalThis.removeEventListener(`resize`,a),globalThis.cancelAnimationFrame(c)}},[e,t,n]),e&&t?r:null}function AN(e,t){let[n,r]=E(null);return ut(()=>{if(!t){r(null);return}let n=e.current;if(!n)return;let i=()=>{let e=n.clientWidth,t=n.clientHeight;r(e&&t?{width:e,height:t}:null)},a=new ResizeObserver(i);return a.observe(n),i(),()=>a.disconnect()},[t,e]),t?n:null}var jN=1;function MN(e,t,n){return Math.min(Math.max(e,t),n)}function NN(e,t,n,r){let i=Math.min(e.diameter/t.height,1),a=r?.safe_area??Zj,o=((a.x+a.width/2)*t.width+n)*i,s=(a.y+a.height/2)*t.height*i,c=e.diameter/2;return{scale:i,tx:MN(e.centerX-o,e.centerX+c-t.width*i,e.centerX-c),ty:MN(e.centerY-s,e.centerY+c-t.height*i,e.centerY-c)}}var PN=[`cx`,`cy`,`r`,`tx`,`ty`,`s`,`shift`];function FN(e,t,n,r,i){if(!n)return null;let{width:a,height:o}=n,s={x:a/2,y:o/2},c=null;if(e&&(c=NN(e,n,r,i),s={x:(e.centerX-c.tx)/c.scale,y:(e.centerY-c.ty)/c.scale}),t&&c&&e)return{cx:s.x,cy:s.y,r:e.diameter/2/c.scale,tx:c.tx,ty:c.ty,s:c.scale,shift:r};let l=Math.hypot(Math.max(s.x,a-s.x),Math.max(s.y,o-s.y));return{cx:s.x,cy:s.y,r:l*1.1,tx:0,ty:0,s:1,shift:r}}function IN(e,t,n){let r=O(null),i=O(e),a=O(n),o=O(0),s=O(0);i.current=e,a.current=n,D(()=>{let e=i.current;if(!e)return;if(!r.current||LN()){r.current={values:{...e},velocity:{cx:0,cy:0,r:0,tx:0,ty:0,s:0,shift:0}},a.current(e,!0);return}if(o.current)return;let n=Math.max(t,160)/4e3;s.current=performance.now();let c=e=>{o.current=0;let t=i.current,l=r.current;if(!t||!l)return;let u=Math.min((e-s.current)/1e3,1/30);s.current=e;let d=!0;for(let e of PN){let r=(t[e]-l.values[e])/(n*n)-2/n*l.velocity[e],i=l.velocity[e]+r*u,a=l.values[e]+i*u,o=e===`s`?.001:.25;Math.abs(t[e]-a)<o&&Math.abs(i)*n<o?(l.values[e]=t[e],l.velocity[e]=0):(l.values[e]=a,l.velocity[e]=i,d=!1)}a.current(l.values,d),d||(o.current=globalThis.requestAnimationFrame(c))};o.current=globalThis.requestAnimationFrame(c)},[e?PN.map(t=>Math.round(e[t]*100)).join():``,t]),D(()=>()=>{o.current&&globalThis.cancelAnimationFrame(o.current)},[])}function LN(){return globalThis.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches??!1}function RN({geom:e,visible:t}){return j(`div`,{"aria-hidden":`true`,"data-morph":`ring`,class:`pointer-events-none absolute z-10 rounded-full`,style:{top:`${e.centerY-e.diameter/2}px`,left:`${e.centerX-e.diameter/2}px`,width:`${e.diameter}px`,height:`${e.diameter}px`,boxShadow:`0 0 0 3px rgb(255 255 255 / 12%), 0 18px 50px rgb(0 0 0 / 55%)`,opacity:+!!t,transition:`opacity 240ms ease-out`}})}function zN(e,t){let n=t>=0?`left`:`right`,r=O({side:n,shift:t});D(()=>{e&&(r.current={side:n,shift:t})},[e,n,t]);let i=e?n:r.current.side;return{side:i,transformOrigin:ON(i,e?t:r.current.shift),translateX:e?0:-r.current.shift}}function BN(e,t,n){return`${e.side??``}:${e.active}:${t}:${n??``}`}function VN({snapshotUrl:e,transformOrigin:t}){return j(`div`,{class:`absolute inset-0 bg-cover bg-center`,style:{backgroundImage:`url("${e}")`,transform:`scaleX(-1)`,transformOrigin:t}})}function HN({snapshotUrl:e,translateX:t,transition:n,transformOrigin:r}){return j(`div`,{"aria-hidden":`true`,"data-morph":`mirror`,class:`pointer-events-none absolute z-0 overflow-hidden`,style:{inset:`0 0`,transform:`translate3d(${t}px, 0, 0)`,transition:`transform ${n}`,willChange:`transform`},children:j(VN,{snapshotUrl:e,transformOrigin:r})})}function UN({ambient:e,usePip:t,transition:n}){return e===`none`?null:j(`div`,{"aria-hidden":`true`,"data-morph":`ambient`,class:`pointer-events-none absolute inset-0 z-0`,style:{opacity:+!!t,transition:`opacity ${n}`,background:e===`darker`?`rgb(0 0 0 / 40%)`:`rgb(0 0 0 / 15%)`}})}function WN({morphCapable:e,snapshotUrl:t,mirrorSide:n,videoShiftX:r,transition:i,sceneRef:a,videoWrapRef:o,fill:s,videoRef:c}){return j(`div`,{ref:a,"data-morph":`scene`,class:`absolute inset-0`,style:e?{transformOrigin:`top left`}:void 0,children:j(`div`,{ref:o,class:`absolute inset-0`,style:e?void 0:{transform:`translate3d(${r}px, 0, 0)`,transition:`transform ${i}`},children:[s(c),e&&t!==null&&j(`div`,{"aria-hidden":`true`,"data-morph":`window-mirror`,class:`absolute top-0 bottom-0 w-full`,style:n===`right`?{left:`calc(100% - ${jN}px)`}:{right:`calc(100% - ${jN}px)`},children:j(VN,{snapshotUrl:t,transformOrigin:`center`})})]})})}function GN({canvasLayoutEffect:e,smartSidecarActive:t,isScreenSharing:n,fill:r,captureSnapshot:i,transition:a=DN,transitionMs:o=560,personaMode:s=`shift`,renderedSlot:c=null,ambient:l=`default`,children:u}){let d=O(null),[f,p]=E(null),m=t&&e.backdrop.type===`snapshot_mirror`,h=t?e.video_shift_x:0,g=O(null),_=BN(e,h,c),{usePip:v,side:y}=TN(e,s,c,wN(s!==`shift`,_,g),h),b=kN(s!==`shift`,y,g),x=zN(m,h);D(()=>{if(!m)return;let e=!1,t=0,n,r=0,a=()=>{if(e)return;let t=i(d.current);if(t){p(t);return}r+=1,r<8&&(n=globalThis.setTimeout(a,150))};return typeof globalThis.requestAnimationFrame==`function`?t=globalThis.requestAnimationFrame(a):n=globalThis.setTimeout(a,0),()=>{e=!0,t&&globalThis.cancelAnimationFrame?.(t),n&&globalThis.clearTimeout(n)}},[m,e.side,e.video_shift_x,i]),D(()=>{if(m||f===null)return;let e=globalThis.setTimeout(()=>{p(null)},o);return()=>globalThis.clearTimeout(e)},[m,f,o]);let S=v&&y!=null&&b!=null,C=s!==`shift`,w=AN(g,C),ee=f!==null&&!C,T=C&&y!=null,te=O(null),ne=O(null),[re,ie]=E(!0),ae=O(!0),oe=A((e,t)=>{let n=te.current;n&&(n.style.clipPath=`circle(${e.r}px at ${e.cx}px ${e.cy}px)`,n.style.transform=`translate(${e.tx}px, ${e.ty}px) scale(${e.s})`);let r=ne.current;r&&(r.style.transform=`translate3d(${e.shift}px, 0, 0)`),ae.current!==t&&(ae.current=t,ie(t))},[]);return IN(C?FN(b,S,w,h,e):null,o,oe),j(`div`,{ref:g,class:`relative w-full h-full overflow-hidden ${n?`flex items-center justify-center`:``}`,children:[ee&&f!==null&&j(HN,{snapshotUrl:f,translateX:x.translateX,transition:a,transformOrigin:x.transformOrigin}),T&&j(UN,{ambient:l,usePip:v,transition:a}),j(`div`,{"data-morph":`fg`,class:`absolute inset-0 z-10`,children:j(WN,{morphCapable:C,snapshotUrl:f,mirrorSide:x.side,videoShiftX:h,transition:a,sceneRef:te,videoWrapRef:ne,fill:r,videoRef:d})}),C&&b&&j(RN,{geom:b,visible:S&&re}),u]})}var KN=1e4;function qN({onTimeout:e,timeoutMs:t=KN,active:n=!0}){let r=Rb().length>0,[i,a]=E(!1),o=O(e);return D(()=>{o.current=e},[e]),D(()=>{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 JN(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.message_type===`system`&&t.event_type===`system.shutdown`}function YN({onShutdown:e}){let t=O(e);D(()=>{t.current=e},[e]),Ug({onAppMessage:A(e=>{JN(e?.data)&&t.current()},[])})}function XN(){let e=ah();return{joinCall:A(({url:t})=>{e?.join({url:t})},[e]),leaveCall:A(()=>{e?.leave()},[e])}}var ZN=_n(`PiP`),QN=360,$N=280;function eP(){return globalThis.window!==void 0&&`documentPictureInPicture`in globalThis.window}function tP(e){let{enabled:t,active:n}=e,[r,i]=E(null),a=eP(),o=ft(mv),s=A(()=>{i(e=>(e&&!e.closed&&e.close(),null))},[]),c=A(async()=>{if(a&&!(!t||!n)&&!(r&&!r.closed))try{let e=await globalThis.window.documentPictureInPicture.requestWindow({width:QN,height:$N}),t=Je.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){ZN.warn(`Failed to open PiP window`,e)}},[a,t,n,r]);return D(()=>{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){ZN.warn(`mediaSession metadata setup failed`,e)}let t=(t,n)=>{try{e.setActionHandler(t,n),r.push(t)}catch(e){ZN.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]),D(()=>{(!n||!t)&&r&&!r.closed&&s()},[n,t,r,s]),D(()=>()=>{r&&!r.closed&&r.close()},[r]),D(()=>{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 nP={active:!1,video_shift_x:0,backdrop:{type:`snapshot_mirror`}},rP=ya(({id:e,showAudioWave:t=!0})=>{let n=n_(e).isOff;return j(`div`,{class:`relative aspect-square w-32 @max-mobile:w-24 rounded-box overflow-hidden bg-black/30 z-10 ${n?`hidden`:``}`,children:[j(ng,{automirror:!0,sessionId:e,type:`video`,fit:`cover`,className:`w-full h-full object-cover ${n?`hidden`:``}`}),t&&j(`div`,{class:`absolute bottom-2 right-2`,children:j(Pb,{id:e})})]})}),iP=ya(()=>{let e=Hh(),{isScreenSharing:t}=rb(),n=Rb()[0];return j(le,{children:[t&&n&&j(rP,{id:n}),e&&j(rP,{id:e,showAudioWave:!1})]})}),aP=ya(()=>j(`div`,{class:`absolute top-4 left-4 flex flex-col items-end gap-2 z-20`,children:j(iP,{})})),oP=ya(({isAudioOnly:e,canvasLayoutEffect:t,canvasRenderedSlot:n})=>{let r=Hh(),i=!e_(r??``).isOff,a=zb(e),o=e_(a.phase===`ready`?a.replicaId:``),s=!i&&(o.state===`playable`||o.state===`loading`),c=t.active&&!i&&(!e||s);return a.phase===`left`?j(Mb,{}):a.phase===`connecting`?j(jb,{}):e&&!s?j(`div`,{class:`absolute inset-0 flex items-center justify-center`,children:[j(Fb,{sessionId:a.replicaId}),j(eg,{sessionId:a.replicaId})]}):j(GN,{canvasLayoutEffect:s?{...t,backdrop:{type:`none`}}:t,smartSidecarActive:c,isScreenSharing:i,captureSnapshot:uP,personaMode:s?`shift`:`auto`,renderedSlot:n,fill:t=>j(Hb,{personaSessionId:a.replicaId,localSessionId:r,isPresenting:s,isScreenSharing:i,isAudioOnly:e,avatarOff:a.videoState.isOff,videoRef:t}),children:j(eg,{sessionId:a.replicaId})})}),sP=ya(({items:e})=>{let[t,n]=E(!1),r=O(null);return D(()=>{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]),j(`div`,{ref:r,class:`relative`,children:[j(`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:j(My,{name:`more`})}),t&&j(`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})]})}),cP=ya(({items:e})=>e.length<=1?j(le,{children:e}):j(sP,{items:e})),lP=ya(({onLeave:e})=>{let{joinCall:t,leaveCall:n}=XN(),r=jg(),{hasMicError:i}=Xg(),{config:a}=G_(),{session:o,end:s}=vb(),c=O(null),l=ft(wv)?.frameRef??c,[u,d]=E(!1),[f,p]=E(!1),[m,h]=E(nP),[g,_]=E(null),v=o.value?.conversationUrl,y=a.value.customization.conversation,b=y.modality===`audio`,x=y.enable_chat,S=y.enable_closed_captions,C=y.enable_picture_in_picture,{pipWindow:w}=tP({enabled:C,active:r===`joined-meeting`});D(()=>(v&&t({url:v}),()=>{n()}),[]),D(()=>{(r===`left-meeting`||r===`error`)&&e()},[r,e]),D(()=>{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 ee=A(()=>{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?.()},[]);A(()=>{p(e=>!e)},[]);let T=A(()=>{s(),n()},[s]);if(qN({active:r===`joined-meeting`,onTimeout:T}),YN({onShutdown:T}),!v)return null;let te=[j(_b,{compact:!0},`screen-share`)];return x&&te.push(j(Db,{compact:!0},`chat`)),j(bb,{children:j(Tb,{children:[j(`div`,{class:`absolute inset-0`,children:[j(`div`,{class:`relative w-full h-full z-[5]`,children:[i&&j(`div`,{class:`absolute top-0 left-0 right-0 z-10 bg-error text-error-content px-4 py-2 text-sm text-center`,children:`Camera or microphone access denied. Please check your settings and try again.`}),j(oP,{isAudioOnly:b,canvasLayoutEffect:m,canvasRenderedSlot:g}),!b&&j(aP,{}),j(Cb,{}),j(tN,{debugEnabled:f,onLayoutEffectChange:h,onRenderedSlotChange:_}),j(`div`,{class:`absolute top-4 right-4 z-20`,children:j(Nb,{active:u,onToggle:ee,compact:!0})})]}),j(kb,{}),j(`div`,{class:`pointer-events-none absolute bottom-6 left-0 right-0 z-20 transition-opacity transition-transform ${r===`left-meeting`?`opacity-0 translate-y-5`:`opacity-100 translate-y-0`}`,"aria-hidden":r===`left-meeting`,children:j(`div`,{class:`flex justify-center items-center gap-2 @max-mobile:gap-1 ${r===`left-meeting`?``:`pointer-events-auto`}`,children:[j(pb,{}),!b&&j(mb,{}),S&&j(Sb,{}),j(cP,{items:te}),j(`button`,{type:`button`,class:`btn btn-control btn-error`,onClick:T,"aria-label":`Leave call`,children:j(My,{name:`leave`,"aria-label":`Leave Call`})})]})})]}),w&&Ia(j(Vb,{onLeave:T}),w.document.body)]})})});function uP(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 dP({loading:e=!1,disabled:t,class:n,children:r,...i}){return j(`button`,{type:`button`,class:`btn relative ${n?` ${n}`:``}`,disabled:t||e,"aria-busy":e||void 0,...i,children:[j(`span`,{children:r}),e&&j(`span`,{class:`absolute inset-0 flex items-center justify-center backdrop-blur-xs`,"aria-hidden":`true`,children:j(`span`,{class:`loading loading-spinner loading-sm`})})]})}function fP(e){switch(e){case`blocked`:return`denied`;case`in-use`:return`in-use`;case`not-found`:return`not-found`;case`not-supported`:case`undefined-mediadevices`:return`unsupported`;case`constraints-invalid`:case`constraints-none-specified`:return`unknown`;default:return null}}function pP(e){let t=e instanceof Error?e.name:``,n=e instanceof Error?e.message.toLowerCase():``;return t===`NotAllowedError`||n.includes(`denied`)||n.includes(`not allowed`)?`denied`:t===`NotReadableError`||n.includes(`in use`)||n.includes(`readable`)?`in-use`:t===`NotFoundError`||n.includes(`not found`)||n.includes(`no device`)?`not-found`:t===`NotSupportedError`||n.includes(`not supported`)?`unsupported`:`unknown`}function mP(){let e=ah(),{micState:t,camState:n}=Xg(),{config:r}=G_(),i=r.value.customization.conversation.modality,a=i===`video`,[o,s]=E(null),[c,l]=E(null),[u,d]=E(!1);D(()=>{let e=!1;return navigator.permissions.query({name:`microphone`}).then(t=>{e||(s(t.state),t.onchange=()=>{e||s(t.state)})}).catch(()=>{}),()=>{e=!0}},[]);let f=A(()=>{if(!e)return;l(null),d(!0);let t={};a||(t.videoSource=!1),Promise.resolve(e.startCamera(t)).catch(e=>{l(pP(e))})},[e,a]),p=k(()=>c&&t!==`granted`?c:fP(t),[t,c]),m=k(()=>a?c&&n!==`granted`&&t===`granted`?c:fP(n):null,[n,t,a,c]),h=k(()=>p??m??null,[p,m]),g=k(()=>c||(u?h:null),[u,c,h]),_=k(()=>o===`prompt`&&g===null,[o,g]),v=k(()=>o===`denied`||g!==null,[o,g]),y=k(()=>g===null&&o!==`prompt`&&o!==`denied`&&t===`granted`&&(!a||n===`granted`),[o,t,n,a,g]);return{isPermissionsPrompt:_,isPermissionsLoading:k(()=>!_&&!v&&!y,[_,v,y]),isPermissionsGranted:y,isPermissionsDenied:v,permissionErrorReason:g,micErrorReason:u?p:null,camErrorReason:u?m:null,modality:i,requestPermissions:f}}function hP(e,t,n,r){return t?e?.prompt??`Make sure your camera and mic are ready!`:n?e?.loading??`Getting your camera and mic ready...`:r?e?.denied??`Camera and mic access denied. Allow permissions to continue.`:null}function gP({message:e}){return j(`div`,{class:`relative max-w-[min(20rem,90%)]`,children:[j(`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}),j(`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:j(`path`,{d:`M0 0 L8 8 L16 0 Z`,fill:`currentColor`})})]})}var _P=ya(({text:e,isJoining:t=!1,onJoin:n,onCancel:r})=>{let i=ah(),{localSessionId:a,isCamMuted:o}=tb(),{isPermissionsPrompt:s,isPermissionsLoading:c,isPermissionsGranted:l,isPermissionsDenied:u,requestPermissions:d}=mP();D(()=>{d()},[]);let f=hP(e,s,c,u);return j(`div`,{class:`absolute inset-0 motion-safe:animate-[tavusFadeUp_280ms_ease-out]`,children:[l&&!o?j(`div`,{class:`absolute inset-0 flex items-center justify-center bg-black overflow-hidden`,children:j(ng,{type:`video`,sessionId:a??``,mirror:!0,fit:`cover`,className:`w-full h-full object-cover!`})}):j(`div`,{class:`absolute inset-0 flex items-center justify-center text-base-content/40`,children:j(My,{name:`face-smile`,size:`7rem`,"aria-label":`Camera off`})}),j(`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:[f&&j(gP,{message:f}),j(`div`,{class:`flex flex-wrap items-center justify-center gap-1.5 @max-mobile:gap-1`,children:[j(`div`,{class:`flex items-center justify-center gap-1.5 shrink-0 @max-mobile:gap-1`,children:[j(pb,{}),j(mb,{})]}),j(dP,{class:`btn-accent `,loading:t,disabled:!l,onClick:n,children:e?.join??`Join Video Chat`}),u&&j(`button`,{type:`button`,class:`btn btn-error `,onClick:()=>{i&&i.leave(),r?.()},children:e?.cancel??`Cancel`})]})]})]})}),vP=`Password required`,yP=`Enter the password to start this conversation.`,bP=`Password`,xP=`Continue`;function SP({onSubmit:e,text:t,isSubmitting:n=!1,errorMessage:r}){let[i,a]=E(``),o=mt();return j(`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:j(`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:j(`div`,{class:`card-body gap-3`,children:[j(`h3`,{id:`${o}-title`,class:`card-title text-base-content`,children:t?.title??vP}),j(`p`,{class:`text-sm text-base-content/70`,children:t?.description??yP}),j(`input`,{id:o,type:`password`,autocomplete:`current-password`,class:`input input-bordered w-full`,placeholder:t?.placeholder??bP,value:i,disabled:n,onInput:e=>a(e.target.value),autoFocus:!0}),r&&j(`p`,{class:`text-error text-xs`,role:`alert`,children:r}),j(dP,{class:`btn-primary`,type:`submit`,disabled:!i.trim(),loading:n,children:t?.submit??xP})]})})})}var CP=_n(`CaptchaChallenge`),wP=1;function TP(e){return typeof e==`object`&&!!e&&e.source===`tavus-captcha`&&typeof e.type==`string`}function EP({captcha:e,deploymentId:t,onToken:n,onFallback:r}){let i=(ft(Ct).baseUrl??`https://tavusapi.com`).replace(/\/+$/,``).split(`/`).slice(0,3).join(`/`),[a,o]=E(0),[s,c]=E(0),[l,u]=E(!1),[d,f]=E(!1),p=`${i}${e.challenge_path}?deployment_uuid=${encodeURIComponent(t)}&action=${encodeURIComponent(e.action)}&parent_origin=${encodeURIComponent(window.location.origin)}`,m=A(()=>{f(!1),o(e=>e+1)},[]);return D(()=>{function e(e){if(l||e.origin!==i)return;let a=e.data;if(TP(a)&&a.deployment_uuid===t){if(a.type===`interactive`){f(!0);return}if(a.type===`token`&&a.token){CP.info(`Captcha token received`),f(!1),n(a.token);return}if(a.type===`expired`){CP.info(`Captcha token expired, reloading iframe`),m();return}a.type===`error`&&(CP.warn(`Captcha error received`,a.code),s<wP?(c(e=>e+1),m()):(CP.warn(`Captcha error retries exhausted, falling back to no-token mode`),u(!0),r()))}}return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},[i,t,s,l,n,r,m]),l?null:j(`div`,{class:d?`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":!d,children:j(`iframe`,{src:p,sandbox:`allow-scripts allow-same-origin allow-forms allow-popups`,title:`Security challenge`,style:{border:`none`,width:`300px`,height:`65px`},scrolling:`no`},a)})}function DP({text:e,onStart:t,isStarting:n}){let{config:r,deploymentId:i}=G_(),a=ft(I_),o=Ly(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=k(()=>d&&p_(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}=cv(_,a),S=mt(),[C,w]=E(f),ee=_!==null&&!v,T=n||d&&!C||g||ee;return j(Uy,{title:o.title,description:o.description,overlay:j(le,{children:[ee&&j(EP,{captcha:_,deploymentId:i,onToken:b,onFallback:x},y),g&&a?j(SP,{onSubmit:a.setPassword}):null]}),children:[j(dP,{class:`btn-neutral rounded-box`,onClick:()=>{d&&C&&!f&&g_(i,c),t()},disabled:T,loading:n,children:s}),u&&j(`div`,{class:`max-w-xs`,children:p?j(`label`,{for:S,class:`flex items-center gap-2 text-xs text-left cursor-pointer`,children:[j(`input`,{id:S,type:`checkbox`,class:`checkbox checkbox-secondary checkbox-xs mt-0.5 shrink-0`,checked:C,onChange:e=>w(e.target.checked)}),j(`span`,{class:`leading-snug`,children:c})]}):j(`p`,{class:`text-xs leading-snug text-base-content/60`,children:c})})]})}function OP({flow:e,welcomeText:t,onUnavailableCancel:n}){switch(e.state){case`idle`:return j(DP,{text:t,onStart:()=>{e.start()},isStarting:e.isStarting});case`haircheck`:return j(_P,{onJoin:()=>{e.join()},onCancel:()=>e.cancel(),isJoining:e.isStarting});case`call`:return j(lP,{onLeave:()=>e.leave()});case`ended`:return j(eb,{onRestart:()=>e.restart()});case`unavailable`:return j(Jy,{cause:e.unavailableCause??`busy`,canRetry:e.canRetry,onRetry:()=>{e.start()},onCancel:n});default:{let t=e.state;throw Error(`Unreachable flow state: ${String(t)}`)}}}var kP=Fe(null);function AP({children:e}){let{config:t}=ft(yi),n=t.peek().customization?.widget,r=n?.expandable??`default`,i=ln(r===`start-expanded`||r===`always`),a=ln(n?.variant??`full`),o=ln(n?.position??`bottom-right`),s=ln(r),c=ln(n?.avatar?.type??`orb`),l=O(r);gn(()=>{let e=t.value.customization?.widget,n=e?.expandable??`default`;a.value=e?.variant??`full`,o.value=e?.position??`bottom-right`,s.value=n,c.value=e?.avatar?.type??`orb`,l.current!==n&&(i.value=n===`start-expanded`||n===`always`,l.current=n)});let u=A(()=>{s.peek()!==`always`&&(i.value=!i.peek())},[i,s]),d=A(()=>{i.value=!0},[i]),f=A(()=>{s.peek()!==`always`&&(i.value=!1)},[i,s]),p=k(()=>({expanded:i,variant:a,position:o,expandable:s,avatarType:c,toggle:u,expand:d,collapse:f}),[i,a,o,s,c,u,d,f]);return j(kP.Provider,{value:p,children:e})}function jP(){let{config:e}=G_();if(e.value.show_tavus_branding!==!1)return j(MP,{});let t=e.value.customization.branding;return t?.logo||t?.text?j(NP,{logo:t.logo,text:t.text}):null}function MP(){let{isDark:e}=Pj(),t=e.value?`white`:`#140206`;return j(`a`,{href:`https://tavus.io`,target:`_blank`,rel:`noopener noreferrer`,class:`inline-flex items-center gap-1 text-xs text-base-content/50 hover:text-base-content/80 transition-colors`,children:[j(`svg`,{viewBox:`0 0 488 452`,class:`h-2.5 w-2.5 shrink-0`,fill:`none`,"aria-hidden":`true`,children:[j(`path`,{d:`M160 152V208H104V152H160Z`,fill:t}),j(`path`,{"fill-rule":`evenodd`,"clip-rule":`evenodd`,d:`M488 270.5L436 285L451 326L418.766 346L441 360L423 392L435 452H0V0H394.766L488 270.5ZM24 24V428H216.2L209 392L227 360L204.766 346L237 326L222 285L274 270.5L189.038 24H24ZM352 152C336.536 152 324 164.536 324 180C324 195.464 336.536 208 352 208C367.464 208 380 195.464 380 180C380 164.536 367.464 152 352 152Z`,fill:t})]}),j(`span`,{children:[`Powered by `,j(`span`,{class:`underline`,children:`Tavus`})]})]})}function NP({logo:e,text:t}){return j(`div`,{class:`inline-flex items-center gap-1 text-xs text-base-content/50`,children:[e?j(`img`,{src:e,alt:t||`Branding`,class:`h-2.5 shrink-0`}):null,t?j(`span`,{children:t}):null]})}var PP={title:`Hi! Want to chat?`,btn_title:`Start conversation`};function FP(){let{config:e}=G_(),t=e.value.customization.widget?.text;return k(()=>({title:t?.title||PP.title,btn_title:t?.btn_title||PP.btn_title}),[t])}function IP(){let e=ft(kP);if(!e)throw Error(`useWidgetUI must be used within WidgetUIProvider`);return e}var LP={xs:`w-6 h-6`,sm:`w-8 h-8`,md:`w-10 h-10`,lg:`w-16 h-16`},RP={xs:`w-3 h-3`,sm:`w-4 h-4`,md:`w-5 h-5`,lg:`w-8 h-8`};function zP({size:e=`md`,className:t=``}){let{avatarType:n}=IP(),{config:r}=G_(),i=Iy(r.value);return(Ly(r.value).background.type===`replica`||n.value===`image`)&&i?j(`div`,{class:`relative ${LP[e]} rounded-box overflow-hidden bg-base-300 ${t}`,children:i.kind===`image`?j(`img`,{src:i.url,class:`absolute inset-0 w-full h-full object-cover`,loading:`lazy`,alt:``}):j(`video`,{src:i.url,class:`absolute inset-0 w-full h-full object-cover`,muted:!0,autoplay:!0,loop:!0,playsinline:!0})}):j(`div`,{class:`relative ${LP[e]} rounded-box bg-primary/15 flex items-center justify-center ${t}`,children:j(`span`,{class:`${RP[e]} rounded-full bg-primary animate-pulse`})})}function BP({variant:e}){let{toggle:t}=IP(),n=FP();return e===`tiny`?j(`button`,{type:`button`,onClick:t,"aria-label":n.btn_title,class:`rounded-box overflow-hidden shadow-xl hover:shadow-2xl transition-shadow cursor-pointer`,children:j(zP,{size:`lg`})}):e===`compact`?j(`button`,{type:`button`,onClick:t,"aria-label":n.btn_title,class:`group flex items-center gap-2.5 py-2.5 pl-2.5 pr-8 rounded-box bg-base-100 text-base-content border border-base-300 shadow-lg hover:shadow-xl transition-shadow cursor-pointer text-left`,children:[j(zP,{size:`md`}),j(`span`,{class:`flex flex-col gap-0.5`,children:[j(`span`,{class:`text-base font-medium leading-tight`,children:n.title}),j(`span`,{class:`text-sm text-base-content/60 leading-tight`,children:n.btn_title})]})]}):j(`button`,{type:`button`,onClick:t,"aria-label":n.btn_title,class:`flex flex-col gap-3 p-3 w-64 rounded-box bg-base-100 text-base-content border border-base-300 shadow-xl hover:shadow-2xl transition-shadow cursor-pointer text-left`,children:[j(`div`,{class:`flex items-center gap-2.5`,children:[j(zP,{size:`md`}),j(`span`,{class:`text-sm font-medium leading-snug`,children:n.title})]}),j(`span`,{class:`btn btn-primary btn-sm w-full pointer-events-none gap-2 flex items-center`,children:[j(My,{name:`cam`,size:16}),j(`span`,{className:`leading-4`,children:n.btn_title})]})]})}var VP=`tavus:widget:greeting-dismissed`;function HP({anchor:e}){let t=FP(),{variant:n,expand:r}=IP(),[i,a]=E(!1);D(()=>{if(n.value===`tiny`){try{if(sessionStorage.getItem(VP)===`1`)return}catch{}a(!0)}},[n]);let o=A(e=>{e.stopPropagation();try{sessionStorage.setItem(VP,`1`)}catch{}a(!1)},[]);if(!i)return null;let s=e===`right`?`right-[-6px] border-r border-b`:`left-[-6px] border-l border-t`,c=e===`right`?`-right-2`:`-left-2`;return j(`button`,{type:`button`,onClick:r,class:`relative max-w-56 rounded-box bg-base-100 text-base-content shadow-lg border border-base-300 px-3 py-2 text-sm text-left cursor-pointer animate-[tavusFadeUp_240ms_ease-out] hover:bg-base-200 transition-colors`,children:[j(`p`,{class:`leading-snug pr-3`,children:t.title}),j(`span`,{role:`button`,tabIndex:0,onClick:o,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&o(e)},class:`absolute -top-2 ${c} btn btn-ghost btn-circle btn-xs bg-base-100 border border-base-300 shadow-sm`,"aria-label":`Dismiss`,children:`×`}),j(`span`,{class:`absolute bottom-3 w-3 h-3 rotate-45 bg-base-100 border-base-300 ${s}`})]})}function UP(){let e=ft(dv);if(!e)throw Error(`useHostBridge must be used within HostBridgeProvider`);return e}var WP=`bg-base-100 text-base-content rounded-box border border-base-300 shadow-xl w-[22rem] flex flex-col animate-[tavusPopIn_180ms_ease-out]`,GP=`bg-base-100 text-base-content w-[100vw] h-[100dvh] flex flex-col animate-[tavusFadeUp_180ms_ease-out]`,KP=`p-1 flex-1 min-h-0`,qP=`p-1 flex-1 min-h-0`;function JP({variant:e,children:t,fullscreen:n}){let{collapse:r,expandable:i}=IP(),a=i.value!==`always`;return n?j(`div`,{class:GP,children:[j(`div`,{class:`flex items-center justify-end gap-2 px-2.5 py-1.5 border-b border-base-300`,children:a&&j(`button`,{type:`button`,class:`btn btn-ghost btn-circle btn-xs`,onClick:r,"aria-label":`Close`,children:j(My,{name:`close`,size:14})})}),j(`div`,{class:qP,children:t}),j(`div`,{class:`flex justify-end px-2.5`,children:j(jP,{})})]}):j(`div`,{class:`flex flex-col h-[min(34rem,calc(100dvh-3rem))]`,children:[j(`div`,{class:`${WP} flex-1 overflow-hidden`,children:[j(`div`,{class:`flex items-center justify-end gap-2 px-2.5 pt-1.5 shrink-0`,children:a&&j(`button`,{type:`button`,class:`btn btn-ghost btn-circle btn-xs`,onClick:r,"aria-label":`Close`,children:j(My,{name:`close`,size:14})})}),j(`div`,{class:KP,children:t})]}),j(`div`,{class:`flex justify-end pr-2 pt-1.5 shrink-0`,children:j(jP,{})})]})}var YP=_n(`Widget`),XP=`1rem`,ZP=480;function QP(){return typeof window>`u`?!1:window.innerWidth<=ZP}function $P(e){switch(e){case`bottom-right`:return{bottom:XP,right:XP};case`bottom-left`:return{bottom:XP,left:XP};case`top-right`:return{top:XP,right:XP};case`top-left`:return{top:XP,left:XP};case`top`:return{top:XP,left:`50%`,transform:`translateX(-50%)`};case`bottom`:return{bottom:XP,left:`50%`,transform:`translateX(-50%)`}}}var eF=[`top`,`bottom`,`left`,`right`,`transform`];function tF(e){return e===`bottom-left`||e===`top-left`?`left`:`right`}function nF(){let{config:e,initError:t}=G_(),n=FP(),{expanded:r,position:i,variant:a}=IP(),{shadowHost:o}=UP(),s=Yy(),c=ln(QP());D(()=>{if(typeof window>`u`)return;c.value=QP();let e=()=>{c.value=QP()};return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[c]);let l=k(()=>({fallback_button:n.btn_title}),[n.btn_title]);if(gn(()=>{let e=o.value,t=i.value,n=r.value,a=n&&c.value;if(e){if(a)e.style.top=`0`,e.style.right=`0`,e.style.bottom=`0`,e.style.left=`0`,e.style.transform=``;else{let n=$P(t);for(let t of eF)e.style[t]=n[t]??``}e.dataset.tavusWidgetPosition=t,e.dataset.tavusWidgetExpanded=n?`true`:`false`,e.dataset.tavusWidgetFullscreen=a?`true`:`false`,e.dataset.tavusWidgetSmall=c.value?`true`:`false`}}),t.value)return YP.error(`Widget cannot initialize (init request failed):`,t.value),null;if(e.value.is_available===!1&&e.value.unavailable_reason===`total_limit`)return YP.error(`Widget is unavailable (total_limit reached) — not rendering`),null;if(!r.value){let e=tF(i.value),t=e===`right`?`flex items-end gap-2 justify-end`:`flex items-end gap-2 flex-row-reverse justify-end`,n=e===`right`?`justify-end pr-2`:`justify-start pl-2`;return j(`div`,{class:`flex flex-col`,children:[j(`div`,{class:t,children:[j(HP,{anchor:e}),j(BP,{variant:a.value})]}),j(`div`,{class:`flex ${n} pt-1.5`,children:j(jP,{})})]})}return e.value.is_available===!1?j(JP,{variant:a.value,fullscreen:c.value,children:j(Tv,{children:j(Jy,{cause:e.value.unavailable_reason??`daily_limit`,canRetry:!1,onRetry:()=>{}})})}):j(JP,{variant:a.value,fullscreen:c.value,children:j(Tv,{children:j(OP,{flow:s,welcomeText:l,onUnavailableCancel:()=>s.restart()})})})}var rF=`:host {
|
|
163
163
|
display: block;
|
|
164
164
|
position: fixed;
|
|
165
165
|
z-index: 50;
|
|
166
166
|
background: transparent;
|
|
167
167
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
|
168
|
-
}`;function
|
|
168
|
+
}`;function iF(e){return j(le,{children:[j(`style`,{dangerouslySetInnerHTML:{__html:Je}}),j(`style`,{dangerouslySetInnerHTML:{__html:rF}}),j(Tt,{"deployment-id":e[`deployment-id`],"override-config":e[`override-config`],"conversational-context":e[`conversational-context`],"custom-greeting":e[`custom-greeting`],"base-url":e[`base-url`],token:e.token,children:j(bi,{children:j(Si,{children:j(L_,{children:j(lv,{children:j(pv,{children:j(hv,{children:j(AP,{children:j(nF,{})})})})})})})})})]})}var aF;function oF(){aF||=Be(iF,`tavus-widget`,[`deployment-id`,`override-config`,`conversational-context`,`custom-greeting`,`base-url`,`token`],{shadow:!0,mode:`open`})}var sF=[`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`],cF=class{element=null;tagName;constructor(e=`tavus-widget`){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`&&oF(),e.TAVUS_EVENT_NAMES=sF,e.TavusIntegration=cF,e})({});
|