@clockworkdog/cogs-client 3.0.0-alpha.16 → 3.0.0-alpha.17
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/browser/index.mjs +955 -875
- package/dist/browser/index.umd.js +9 -9
- package/dist/state-based/MediaClipManager.d.ts +3 -4
- package/dist/state-based/MediaClipManager.js +165 -81
- package/dist/types/MediaSchema.d.ts +6 -2
- package/dist/types/MediaSchema.js +2 -0
- package/dist/utils/device.d.ts +2 -0
- package/dist/utils/device.js +4 -0
- package/dist/utils/getStateAtTime.d.ts +12 -2
- package/dist/utils/getStateAtTime.js +1 -1
- package/dist/utils/modulo.d.ts +6 -0
- package/dist/utils/modulo.js +17 -0
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(y,
|
|
1
|
+
(function(y,F){typeof exports=="object"&&typeof module<"u"?F(exports):typeof define=="function"&&define.amd?define(["exports"],F):(y=typeof globalThis<"u"?globalThis:y||self,F(y.COGS={}))})(this,function(y){"use strict";var F=(e=>(e.Setup="setup",e.Preshow="pre-show",e.InProgress="in progress",e.Finished="finished",e))(F||{});/*! *****************************************************************************
|
|
2
2
|
Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
3
|
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
4
4
|
this file except in compliance with the License. You may obtain a copy of the
|
|
@@ -11,28 +11,28 @@
|
|
|
11
11
|
|
|
12
12
|
See the Apache Version 2.0 License for specific language governing permissions
|
|
13
13
|
and limitations under the License.
|
|
14
|
-
***************************************************************************** */var
|
|
14
|
+
***************************************************************************** */var me=function(e,t){return me=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var o in r)r.hasOwnProperty(o)&&(n[o]=r[o])},me(e,t)};function Le(e,t){me(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}function tn(e){var t=typeof Symbol=="function"&&e[Symbol.iterator],n=0;return t?t.call(e):{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}}function nn(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),o,s=[],i;try{for(;(t===void 0||t-- >0)&&!(o=r.next()).done;)s.push(o.value)}catch(c){i={error:c}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(i)throw i.error}}return s}function rn(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(nn(arguments[t]));return e}var Ue=function(){function e(t,n){this.target=n,this.type=t}return e}(),on=function(e){Le(t,e);function t(n,r){var o=e.call(this,"error",r)||this;return o.message=n.message,o.error=n,o}return t}(Ue),sn=function(e){Le(t,e);function t(n,r,o){n===void 0&&(n=1e3),r===void 0&&(r="");var s=e.call(this,"close",o)||this;return s.wasClean=!0,s.code=n,s.reason=r,s}return t}(Ue);/*!
|
|
15
15
|
* Reconnecting WebSocket
|
|
16
16
|
* by Pedro Ladaria <pedro.ladaria@gmail.com>
|
|
17
17
|
* https://github.com/pladaria/reconnecting-websocket
|
|
18
18
|
* License MIT
|
|
19
|
-
*/var tn=function(){if(typeof WebSocket<"u")return WebSocket},nn=function(e){return typeof e<"u"&&!!e&&e.CLOSING===2},N={maxReconnectionDelay:1e4,minReconnectionDelay:1e3+Math.random()*4e3,minUptime:5e3,reconnectionDelayGrowFactor:1.3,connectionTimeout:4e3,maxRetries:1/0,maxEnqueuedMessages:1/0},rn=function(){function e(t,n,r){var o=this;r===void 0&&(r={}),this._listeners={error:[],message:[],open:[],close:[]},this._retryCount=-1,this._shouldReconnect=!0,this._connectLock=!1,this._binaryType="blob",this._closeCalled=!1,this._messageQueue=[],this.onclose=null,this.onerror=null,this.onmessage=null,this.onopen=null,this._handleOpen=function(s){o._debug("open event");var i=o._options.minUptime,c=i===void 0?N.minUptime:i;clearTimeout(o._connectTimeout),o._uptimeTimeout=setTimeout(function(){return o._acceptOpen()},c),o._ws.binaryType=o._binaryType,o._messageQueue.forEach(function(a){return o._ws.send(a)}),o._messageQueue=[],o.onopen&&o.onopen(s),o._listeners.open.forEach(function(a){return o._callEventListener(s,a)})},this._handleMessage=function(s){o._debug("message event"),o.onmessage&&o.onmessage(s),o._listeners.message.forEach(function(i){return o._callEventListener(s,i)})},this._handleError=function(s){o._debug("error event",s.message),o._disconnect(void 0,s.message==="TIMEOUT"?"timeout":void 0),o.onerror&&o.onerror(s),o._debug("exec error listeners"),o._listeners.error.forEach(function(i){return o._callEventListener(s,i)}),o._connect()},this._handleClose=function(s){o._debug("close event"),o._clearTimeouts(),o._shouldReconnect&&o._connect(),o.onclose&&o.onclose(s),o._listeners.close.forEach(function(i){return o._callEventListener(s,i)})},this._url=t,this._protocols=n,this._options=r,this._options.startClosed&&(this._shouldReconnect=!1),this._connect()}return Object.defineProperty(e,"CONNECTING",{get:function(){return 0},enumerable:!0,configurable:!0}),Object.defineProperty(e,"OPEN",{get:function(){return 1},enumerable:!0,configurable:!0}),Object.defineProperty(e,"CLOSING",{get:function(){return 2},enumerable:!0,configurable:!0}),Object.defineProperty(e,"CLOSED",{get:function(){return 3},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"CONNECTING",{get:function(){return e.CONNECTING},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"OPEN",{get:function(){return e.OPEN},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"CLOSING",{get:function(){return e.CLOSING},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"CLOSED",{get:function(){return e.CLOSED},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"binaryType",{get:function(){return this._ws?this._ws.binaryType:this._binaryType},set:function(t){this._binaryType=t,this._ws&&(this._ws.binaryType=t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"retryCount",{get:function(){return Math.max(this._retryCount,0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"bufferedAmount",{get:function(){var t=this._messageQueue.reduce(function(n,r){return typeof r=="string"?n+=r.length:r instanceof Blob?n+=r.size:n+=r.byteLength,n},0);return t+(this._ws?this._ws.bufferedAmount:0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"extensions",{get:function(){return this._ws?this._ws.extensions:""},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"protocol",{get:function(){return this._ws?this._ws.protocol:""},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"readyState",{get:function(){return this._ws?this._ws.readyState:this._options.startClosed?e.CLOSED:e.CONNECTING},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"url",{get:function(){return this._ws?this._ws.url:""},enumerable:!0,configurable:!0}),e.prototype.close=function(t,n){if(t===void 0&&(t=1e3),this._closeCalled=!0,this._shouldReconnect=!1,this._clearTimeouts(),!this._ws){this._debug("close enqueued: no ws instance");return}if(this._ws.readyState===this.CLOSED){this._debug("close: already closed");return}this._ws.close(t,n)},e.prototype.reconnect=function(t,n){this._shouldReconnect=!0,this._closeCalled=!1,this._retryCount=-1,!this._ws||this._ws.readyState===this.CLOSED?this._connect():(this._disconnect(t,n),this._connect())},e.prototype.send=function(t){if(this._ws&&this._ws.readyState===this.OPEN)this._debug("send",t),this._ws.send(t);else{var n=this._options.maxEnqueuedMessages,r=n===void 0?N.maxEnqueuedMessages:n;this._messageQueue.length<r&&(this._debug("enqueue",t),this._messageQueue.push(t))}},e.prototype.addEventListener=function(t,n){this._listeners[t]&&this._listeners[t].push(n)},e.prototype.dispatchEvent=function(t){var n,r,o=this._listeners[t.type];if(o)try{for(var s=Ht(o),i=s.next();!i.done;i=s.next()){var c=i.value;this._callEventListener(t,c)}}catch(a){n={error:a}}finally{try{i&&!i.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}return!0},e.prototype.removeEventListener=function(t,n){this._listeners[t]&&(this._listeners[t]=this._listeners[t].filter(function(r){return r!==n}))},e.prototype._debug=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];this._options.debug&&console.log.apply(console,Xt(["RWS>"],t))},e.prototype._getNextDelay=function(){var t=this._options,n=t.reconnectionDelayGrowFactor,r=n===void 0?N.reconnectionDelayGrowFactor:n,o=t.minReconnectionDelay,s=o===void 0?N.minReconnectionDelay:o,i=t.maxReconnectionDelay,c=i===void 0?N.maxReconnectionDelay:i,a=0;return this._retryCount>0&&(a=s*Math.pow(r,this._retryCount-1),a>c&&(a=c)),this._debug("next delay",a),a},e.prototype._wait=function(){var t=this;return new Promise(function(n){setTimeout(n,t._getNextDelay())})},e.prototype._getNextUrl=function(t){if(typeof t=="string")return Promise.resolve(t);if(typeof t=="function"){var n=t();if(typeof n=="string")return Promise.resolve(n);if(n.then)return n}throw Error("Invalid URL")},e.prototype._connect=function(){var t=this;if(!(this._connectLock||!this._shouldReconnect)){this._connectLock=!0;var n=this._options,r=n.maxRetries,o=r===void 0?N.maxRetries:r,s=n.connectionTimeout,i=s===void 0?N.connectionTimeout:s,c=n.WebSocket,a=c===void 0?tn():c;if(this._retryCount>=o){this._debug("max retries reached",this._retryCount,">=",o);return}if(this._retryCount++,this._debug("connect",this._retryCount),this._removeListeners(),!nn(a))throw Error("No valid WebSocket class provided");this._wait().then(function(){return t._getNextUrl(t._url)}).then(function(l){t._closeCalled||(t._debug("connect",{url:l,protocols:t._protocols}),t._ws=t._protocols?new a(l,t._protocols):new a(l),t._ws.binaryType=t._binaryType,t._connectLock=!1,t._addListeners(),t._connectTimeout=setTimeout(function(){return t._handleTimeout()},i))})}},e.prototype._handleTimeout=function(){this._debug("timeout event"),this._handleError(new Qt(Error("TIMEOUT"),this))},e.prototype._disconnect=function(t,n){if(t===void 0&&(t=1e3),this._clearTimeouts(),!!this._ws){this._removeListeners();try{this._ws.close(t,n),this._handleClose(new en(t,n,this))}catch{}}},e.prototype._acceptOpen=function(){this._debug("accept open"),this._retryCount=0},e.prototype._callEventListener=function(t,n){"handleEvent"in n?n.handleEvent(t):n(t)},e.prototype._removeListeners=function(){this._ws&&(this._debug("removeListeners"),this._ws.removeEventListener("open",this._handleOpen),this._ws.removeEventListener("close",this._handleClose),this._ws.removeEventListener("message",this._handleMessage),this._ws.removeEventListener("error",this._handleError))},e.prototype._addListeners=function(){this._ws&&(this._debug("addListeners"),this._ws.addEventListener("open",this._handleOpen),this._ws.addEventListener("close",this._handleClose),this._ws.addEventListener("message",this._handleMessage),this._ws.addEventListener("error",this._handleError))},e.prototype._clearTimeouts=function(){clearTimeout(this._connectTimeout),clearTimeout(this._uptimeTimeout)},e}();const Le=12095;function je(e){const t=typeof window<"u"?window.location:void 0,n=`/assets/${encodeURIComponent(e)}`;return`${t?.protocol}//${t?.hostname}:${Le}${n}`}async function on(e){const t=await fetch(e);return URL.createObjectURL(new Blob([await t.arrayBuffer()]))}class sn{_items;#e=new EventTarget;constructor(t){this._items={...t}}handleDataStoreItemsMessage(t){this._items={...this._items,...t.items},Object.entries(t.items).forEach(([n,r])=>{this.dispatchEvent(new fe(n,r))}),this.dispatchEvent(new pe(t.items))}get items(){return this._items}getItem(t){return this._items[t]}setItems(t){return this._items={...this._items,...t},Object.entries(t).forEach(([n,r])=>{this.dispatchEvent(new fe(n,r))}),this.dispatchEvent(new pe(t)),this}addEventListener(t,n,r){this.#e.addEventListener(t,n,r)}removeEventListener(t,n,r){this.#e.removeEventListener(t,n,r)}dispatchEvent(t){this.#e.dispatchEvent(t)}}class fe extends Event{constructor(t,n){super("item"),this.key=t,this.value=n}_cogsConnectionEventType="item"}class pe extends Event{constructor(t){super("items"),this.items=t}_cogsConnectionEventType="item"}const H=globalThis.Date;function cn(e){const t=e-H.now();function n(...o){return o.length===0?new H(n.now()):new H(...o)}const r=Object.getOwnPropertyDescriptors(H);Object.defineProperties(n,r),n.now=function(){return H.now()+t},globalThis.Date=n}let un=0;function an(){return++un}const ln=5,hn=1e4;function dn({interval:e,send:t,onChange:n=cn,syncSampleSize:r=ln,syncRequestTimeout:o=hn}){const s={};async function i(){const h=[];for(let m=0;m<r;m++){const E=new Promise(I=>{const X=an(),Ae=Date.now(),Re=performance.now();t({timesync:{id:X}});const T=(S,x)=>I({sentAt:Re,receivedAt:S,serverNow:x,clientNow:Ae});s[X]={complete:T},setTimeout(()=>I(null),o)});h.push(E),await E}const p=(await Promise.all(h)).filter(m=>m!==null),d=fn(p);isNaN(d)||n(Date.now()+d)}const c=h=>{const p=performance.now(),d=s[h.timesync.id];d&&d.complete(p,h.timesync.now)};i();const a=setInterval(i,e);return{receive:c,destroy:()=>{clearInterval(a)}}}function fn(e){return e.map(({sentAt:t,receivedAt:n,clientNow:r,serverNow:o})=>{const s=(n-t)/2;return o-r-s}).reduce((t,n)=>t+n,0)/e.length}class pn{constructor(t,{hostname:n=document.location.hostname,port:r=Le}={},o,s){this.manifest=t,this.currentState={...o},this.store=new sn(s??{});const{useReconnectingWebsocket:i,path:c,pathParams:a}=mn(document.location.href);this.urlParams=new URLSearchParams(a),this.urlParams.set("screenWidth",window.screen.width.toString()),this.urlParams.set("screenHeight",window.screen.height.toString()),this.urlParams.set("screenPixelRatio",window.devicePixelRatio.toString());const l=`ws://${n}:${r}${c}?${this.urlParams}`;this.websocket=i?new rn(l):new WebSocket(l);let h;this.websocket.onopen=()=>{this.currentConfig={},this.currentState={},this.dispatchEvent(new Ue),this.setState(this.currentState),h=dn({interval:6e4,send:p=>{this.websocket.send(JSON.stringify(p))}})},this.websocket.addEventListener("message",({data:p})=>{try{const d=JSON.parse(p);if(typeof d=="object"&&d!==null&&"timesync"in d){const m=d;h?.receive(m)}}catch(d){console.error(d)}}),this.websocket.onclose=()=>{h?.destroy(),this.dispatchEvent(new xe)},this.websocket.addEventListener("message",({data:p})=>{try{const d=JSON.parse(p);try{if(d.config)this.currentConfig=d.config,this.dispatchEvent(new Fe(this.currentConfig));else if(d.updates)this.currentState={...this.currentState,...d.updates},this.dispatchEvent(new Ve(d.updates));else if(d.event&&d.event.key)this.dispatchEvent(new We(d.event.key,d.event.value));else if(typeof d.message=="object"){const m=d.message;switch(m.type){case"adjustable_timer_update":this._timerState={startedAt:Date.now(),durationMillis:m.durationMillis,ticking:m.ticking};break;case"show_phase":this._showPhase=m.phase,this.dispatchEvent(new Ge(m.phase));break;case"media_config_update":this._mediaConfig=m;for(const E of["preferOptimizedAudio","preferOptimizedVideo","preferOptimizedImages"])m[E]?this.urlParams.set(E,"true"):this.urlParams.delete(E);this.dispatchEvent(new Ke(m));break;case"data_store_items":this.store.handleDataStoreItemsMessage(m);break}this.dispatchEvent(new Me(m))}}catch(m){console.warn("Error handling data",p,m)}}catch(d){console.error("Unable to parse incoming data from server",p,d)}}),this.store.addEventListener("items",p=>{this.sendDataStoreItems(p.items)});{const p=async()=>{if(navigator.mediaDevices){const d=(await navigator.mediaDevices.enumerateDevices()).filter(({kind:m})=>m==="audiooutput");this.sendAudioOutputs(d),this.audioOutputs=d}};this.eventTarget.addEventListener("open",p),navigator.mediaDevices?.addEventListener("devicechange",p),p()}}websocket;eventTarget=new EventTarget;currentConfig={};get config(){return{...this.currentConfig}}currentState={};get state(){return{...this.currentState}}_showPhase=M.Setup;get showPhase(){return this._showPhase}_timerState=null;get timerState(){return this._timerState?{...this._timerState}:null}_mediaConfig=null;get mediaConfig(){return this._mediaConfig?{...this._mediaConfig}:null}getAssetUrl(t){return`${je(t)}?${this.urlParams?.toString()??""}`}audioOutputs=void 0;_selectedAudioOutput="";get selectedAudioOutput(){return this._selectedAudioOutput}store;urlParams;get isConnected(){return this.websocket.readyState===WebSocket.OPEN}close(){this.websocket.close()}sendEvent(t,...[n]){this.isConnected&&this.websocket.send(JSON.stringify({event:{key:t,value:n}}))}setState(t){this.currentState={...this.currentState,...t},this.isConnected&&this.websocket.send(JSON.stringify({updates:t}))}getAudioSinkId(t){return t?this.audioOutputs?.find(({label:n})=>n===t)?.deviceId:""}sendAudioOutputs(t){this.isConnected&&this.websocket.send(JSON.stringify({audioOutputs:t}))}sendDataStoreItems(t){this.isConnected&&this.websocket.send(JSON.stringify({dataStoreItems:t}))}setPluginWindowVisible(t){this.isConnected&&this.websocket.send(JSON.stringify({window:{visible:t}}))}addEventListener(t,n,r){this.eventTarget.addEventListener(t,n,r)}removeEventListener(t,n,r){this.eventTarget.removeEventListener(t,n,r)}dispatchEvent(t){this.eventTarget.dispatchEvent(t)}}function mn(e){const t=new URL(e),n=new URLSearchParams(t.searchParams),r=n.get("local_id"),o=n.get("simulator")==="true",s=n.get("display")??"",i=t.pathname.startsWith("/plugin/")?decodeURIComponent(t.pathname.split("/")[2]):void 0;if(r){const c=n.get("t")??"";return n.delete("local_id"),{path:`/local/${encodeURIComponent(r)}`,pathParams:new URLSearchParams({t:c}),useReconnectingWebsocket:!0}}else if(o){const c=n.get("name")??"";return n.delete("simulator"),n.delete("name"),{path:`/simulator/${encodeURIComponent(c)}`,pathParams:n,useReconnectingWebsocket:!0}}else if(s){const c=n.get("displayIdIndex")??"";return n.delete("display"),n.delete("displayIdIndex"),{path:`/display/${encodeURIComponent(s)}/${encodeURIComponent(c)}`}}else{if(i)return{path:`/plugin/${encodeURIComponent(i)}`,useReconnectingWebsocket:!0};{const c=n.get("serial")??"";return n.delete("serial"),{path:`/client/${encodeURIComponent(c)}`,pathParams:n}}}}class Ue extends Event{_cogsConnectionEventType="open";constructor(){super("open")}}class xe extends Event{_cogsConnectionEventType="close";constructor(){super("close")}}class Me extends Event{constructor(t){super("message"),this.message=t}_cogsConnectionEventType="message"}class Fe extends Event{constructor(t){super("config"),this.config=t}_cogsConnectionEventType="config"}class Ve extends Event{constructor(t){super("state"),this.state=t}_cogsConnectionEventType="state"}class We extends Event{constructor(t,n){super("event"),this.name=t,this.value=n}_cogsConnectionEventType="event"}class Ke extends Event{constructor(t){super("mediaConfig"),this.mediaConfig=t}_cogsConnectionEventType="mediaConfig"}class Ge extends Event{constructor(t){super("showPhase"),this.showPhase=t}_cogsConnectionEventType="showPhase"}function u(e,t,n){function r(c,a){if(c._zod||Object.defineProperty(c,"_zod",{value:{def:a,constr:i,traits:new Set},enumerable:!1}),c._zod.traits.has(e))return;c._zod.traits.add(e),t(c,a);const l=i.prototype,h=Object.keys(l);for(let p=0;p<h.length;p++){const d=h[p];d in c||(c[d]=l[d].bind(c))}}const o=n?.Parent??Object;class s extends o{}Object.defineProperty(s,"name",{value:e});function i(c){var a;const l=n?.Parent?new s:this;r(l,c),(a=l._zod).deferred??(a.deferred=[]);for(const h of l._zod.deferred)h();return l}return Object.defineProperty(i,"init",{value:r}),Object.defineProperty(i,Symbol.hasInstance,{value:c=>n?.Parent&&c instanceof n.Parent?!0:c?._zod?.traits?.has(e)}),Object.defineProperty(i,"name",{value:e}),i}class F extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Je extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const Be={};function P(e){return Be}function _n(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,o])=>t.indexOf(+r)===-1).map(([r,o])=>o)}function me(e,t){return typeof t=="bigint"?t.toString():t}function _e(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function ge(e){return e==null}function ve(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function gn(e,t){const n=(e.toString().split(".")[1]||"").length,r=t.toString();let o=(r.split(".")[1]||"").length;if(o===0&&/\d?e-\d?/.test(r)){const a=r.match(/\d?e-(\d?)/);a?.[1]&&(o=Number.parseInt(a[1]))}const s=n>o?n:o,i=Number.parseInt(e.toFixed(s).replace(".","")),c=Number.parseInt(t.toFixed(s).replace(".",""));return i%c/10**s}const Ye=Symbol("evaluating");function _(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Ye)return r===void 0&&(r=Ye,r=n()),r},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function D(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function L(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function He(e){return JSON.stringify(e)}function vn(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const qe="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Q(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const bn=_e(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function V(e){if(Q(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(Q(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Xe(e){return V(e)?{...e}:Array.isArray(e)?[...e]:e}const yn=new Set(["string","number","symbol"]);function W(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function A(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function f(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new 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 wn(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const kn={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function En(e,t){const n=e._zod.def,r=L(e._zod.def,{get shape(){const o={};for(const s in t){if(!(s in n.shape))throw new Error(`Unrecognized key: "${s}"`);t[s]&&(o[s]=n.shape[s])}return D(this,"shape",o),o},checks:[]});return A(e,r)}function zn(e,t){const n=e._zod.def,r=L(e._zod.def,{get shape(){const o={...e._zod.def.shape};for(const s in t){if(!(s in n.shape))throw new Error(`Unrecognized key: "${s}"`);t[s]&&delete o[s]}return D(this,"shape",o),o},checks:[]});return A(e,r)}function $n(e,t){if(!V(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0)throw new Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");const o=L(e._zod.def,{get shape(){const s={...e._zod.def.shape,...t};return D(this,"shape",s),s},checks:[]});return A(e,o)}function Zn(e,t){if(!V(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n={...e._zod.def,get shape(){const r={...e._zod.def.shape,...t};return D(this,"shape",r),r},checks:e._zod.def.checks};return A(e,n)}function Sn(e,t){const n=L(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t._zod.def.shape};return D(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:[]});return A(e,n)}function Tn(e,t,n){const r=L(t._zod.def,{get shape(){const o=t._zod.def.shape,s={...o};if(n)for(const i in n){if(!(i in o))throw new Error(`Unrecognized key: "${i}"`);n[i]&&(s[i]=e?new e({type:"optional",innerType:o[i]}):o[i])}else for(const i in o)s[i]=e?new e({type:"optional",innerType:o[i]}):o[i];return D(this,"shape",s),s},checks:[]});return A(t,r)}function On(e,t,n){const r=L(t._zod.def,{get shape(){const o=t._zod.def.shape,s={...o};if(n)for(const i in n){if(!(i in s))throw new Error(`Unrecognized key: "${i}"`);n[i]&&(s[i]=new e({type:"nonoptional",innerType:o[i]}))}else for(const i in o)s[i]=new e({type:"nonoptional",innerType:o[i]});return D(this,"shape",s),s},checks:[]});return A(t,r)}function K(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 j(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function ee(e){return typeof e=="string"?e:e?.message}function R(e,t,n){const r={...e,path:e.path??[]};if(!e.message){const o=ee(e.inst?._zod.def?.error?.(e))??ee(t?.error?.(e))??ee(n.customError?.(e))??ee(n.localeError?.(e))??"Invalid input";r.message=o}return delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function be(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function q(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}const Qe=(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,me,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},et=u("$ZodError",Qe),tt=u("$ZodError",Qe,{Parent:Error});function Cn(e,t=n=>n.message){const n={},r=[];for(const o of e.issues)o.path.length>0?(n[o.path[0]]=n[o.path[0]]||[],n[o.path[0]].push(t(o))):r.push(t(o));return{formErrors:r,fieldErrors:n}}function In(e,t=n=>n.message){const n={_errors:[]},r=o=>{for(const s of o.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(i=>r({issues:i}));else if(s.code==="invalid_key")r({issues:s.issues});else if(s.code==="invalid_element")r({issues:s.issues});else if(s.path.length===0)n._errors.push(t(s));else{let i=n,c=0;for(;c<s.path.length;){const a=s.path[c];c===s.path.length-1?(i[a]=i[a]||{_errors:[]},i[a]._errors.push(t(s))):i[a]=i[a]||{_errors:[]},i=i[a],c++}}};return r(e),n}const ye=e=>(t,n,r,o)=>{const s=r?Object.assign(r,{async:!1}):{async:!1},i=t._zod.run({value:n,issues:[]},s);if(i instanceof Promise)throw new F;if(i.issues.length){const c=new(o?.Err??e)(i.issues.map(a=>R(a,s,P())));throw qe(c,o?.callee),c}return i.value},we=e=>async(t,n,r,o)=>{const s=r?Object.assign(r,{async:!0}):{async:!0};let i=t._zod.run({value:n,issues:[]},s);if(i instanceof Promise&&(i=await i),i.issues.length){const c=new(o?.Err??e)(i.issues.map(a=>R(a,s,P())));throw qe(c,o?.callee),c}return i.value},te=e=>(t,n,r)=>{const o=r?{...r,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},o);if(s instanceof Promise)throw new F;return s.issues.length?{success:!1,error:new(e??et)(s.issues.map(i=>R(i,o,P())))}:{success:!0,data:s.value}},Pn=te(tt),ne=e=>async(t,n,r)=>{const o=r?Object.assign(r,{async:!0}):{async:!0};let s=t._zod.run({value:n,issues:[]},o);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new e(s.issues.map(i=>R(i,o,P())))}:{success:!0,data:s.value}},An=ne(tt),Rn=e=>(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return ye(e)(t,n,o)},Nn=e=>(t,n,r)=>ye(e)(t,n,r),Dn=e=>async(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return we(e)(t,n,o)},Ln=e=>async(t,n,r)=>we(e)(t,n,r),jn=e=>(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return te(e)(t,n,o)},Un=e=>(t,n,r)=>te(e)(t,n,r),xn=e=>async(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return ne(e)(t,n,o)},Mn=e=>async(t,n,r)=>ne(e)(t,n,r),Fn=/^[cC][^\s-]{8,}$/,Vn=/^[0-9a-z]+$/,Wn=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Kn=/^[0-9a-vA-V]{20}$/,Gn=/^[A-Za-z0-9]{27}$/,Jn=/^[a-zA-Z0-9_-]{21}$/,Bn=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Yn=/^([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})$/,nt=e=>e?new 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)$/,Hn=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,qn="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Xn(){return new RegExp(qn,"u")}const Qn=/^(?:(?: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])$/,er=/^(([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}|:))$/,tr=/^((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])$/,nr=/^(([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])$/,rr=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,rt=/^[A-Za-z0-9_-]*$/,or=/^\+(?:[0-9]){6,14}[0-9]$/,ot="(?:(?:\\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])))",sr=new RegExp(`^${ot}$`);function st(e){const 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 ir(e){return new RegExp(`^${st(e)}$`)}function cr(e){const t=st({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${t}(?:${n.join("|")})`;return new RegExp(`^${ot}T(?:${r})$`)}const ur=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},ar=/^-?\d+$/,lr=/^-?\d+(?:\.\d+)?/,hr=/^null$/i,dr=/^[^A-Z]*$/,fr=/^[^a-z]*$/,z=u("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),it={number:"number",bigint:"bigint",object:"date"},ct=u("$ZodCheckLessThan",(e,t)=>{z.init(e,t);const n=it[typeof t.value];e._zod.onattach.push(r=>{const o=r._zod.bag,s=(t.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<s&&(t.inclusive?o.maximum=t.value:o.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:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),ut=u("$ZodCheckGreaterThan",(e,t)=>{z.init(e,t);const n=it[typeof t.value];e._zod.onattach.push(r=>{const o=r._zod.bag,s=(t.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>s&&(t.inclusive?o.minimum=t.value:o.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:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),pr=u("$ZodCheckMultipleOf",(e,t)=>{z.init(e,t),e._zod.onattach.push(n=>{var r;(r=n._zod.bag).multipleOf??(r.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%t.value===BigInt(0):gn(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})}}),mr=u("$ZodCheckNumberFormat",(e,t)=>{z.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),r=n?"int":"number",[o,s]=kn[t.format];e._zod.onattach.push(i=>{const c=i._zod.bag;c.format=t.format,c.minimum=o,c.maximum=s,n&&(c.pattern=ar)}),e._zod.check=i=>{const c=i.value;if(n){if(!Number.isInteger(c)){i.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:c,inst:e});return}if(!Number.isSafeInteger(c)){c>0?i.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,continue:!t.abort}):i.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,continue:!t.abort});return}}c<o&&i.issues.push({origin:"number",input:c,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),c>s&&i.issues.push({origin:"number",input:c,code:"too_big",maximum:s,inst:e})}}),_r=u("$ZodCheckMaxLength",(e,t)=>{var n;z.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!ge(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(r._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{const o=r.value;if(o.length<=t.maximum)return;const i=be(o);r.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),gr=u("$ZodCheckMinLength",(e,t)=>{var n;z.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!ge(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(r._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{const o=r.value;if(o.length>=t.minimum)return;const i=be(o);r.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),vr=u("$ZodCheckLengthEquals",(e,t)=>{var n;z.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!ge(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),e._zod.check=r=>{const o=r.value,s=o.length;if(s===t.length)return;const i=be(o),c=s>t.length;r.issues.push({origin:i,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),re=u("$ZodCheckStringFormat",(e,t)=>{var n,r;z.init(e,t),e._zod.onattach.push(o=>{const s=o._zod.bag;s.format=t.format,t.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),br=u("$ZodCheckRegex",(e,t)=>{re.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})}}),yr=u("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=dr),re.init(e,t)}),wr=u("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=fr),re.init(e,t)}),kr=u("$ZodCheckIncludes",(e,t)=>{z.init(e,t);const n=W(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(o=>{const s=o._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),Er=u("$ZodCheckStartsWith",(e,t)=>{z.init(e,t);const n=new RegExp(`^${W(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),zr=u("$ZodCheckEndsWith",(e,t)=>{z.init(e,t);const n=new RegExp(`.*${W(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}}),$r=u("$ZodCheckOverwrite",(e,t)=>{z.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class Zr{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const r=t.split(`
|
|
19
|
+
*/var cn=function(){if(typeof WebSocket<"u")return WebSocket},un=function(e){return typeof e<"u"&&!!e&&e.CLOSING===2},D={maxReconnectionDelay:1e4,minReconnectionDelay:1e3+Math.random()*4e3,minUptime:5e3,reconnectionDelayGrowFactor:1.3,connectionTimeout:4e3,maxRetries:1/0,maxEnqueuedMessages:1/0},an=function(){function e(t,n,r){var o=this;r===void 0&&(r={}),this._listeners={error:[],message:[],open:[],close:[]},this._retryCount=-1,this._shouldReconnect=!0,this._connectLock=!1,this._binaryType="blob",this._closeCalled=!1,this._messageQueue=[],this.onclose=null,this.onerror=null,this.onmessage=null,this.onopen=null,this._handleOpen=function(s){o._debug("open event");var i=o._options.minUptime,c=i===void 0?D.minUptime:i;clearTimeout(o._connectTimeout),o._uptimeTimeout=setTimeout(function(){return o._acceptOpen()},c),o._ws.binaryType=o._binaryType,o._messageQueue.forEach(function(a){return o._ws.send(a)}),o._messageQueue=[],o.onopen&&o.onopen(s),o._listeners.open.forEach(function(a){return o._callEventListener(s,a)})},this._handleMessage=function(s){o._debug("message event"),o.onmessage&&o.onmessage(s),o._listeners.message.forEach(function(i){return o._callEventListener(s,i)})},this._handleError=function(s){o._debug("error event",s.message),o._disconnect(void 0,s.message==="TIMEOUT"?"timeout":void 0),o.onerror&&o.onerror(s),o._debug("exec error listeners"),o._listeners.error.forEach(function(i){return o._callEventListener(s,i)}),o._connect()},this._handleClose=function(s){o._debug("close event"),o._clearTimeouts(),o._shouldReconnect&&o._connect(),o.onclose&&o.onclose(s),o._listeners.close.forEach(function(i){return o._callEventListener(s,i)})},this._url=t,this._protocols=n,this._options=r,this._options.startClosed&&(this._shouldReconnect=!1),this._connect()}return Object.defineProperty(e,"CONNECTING",{get:function(){return 0},enumerable:!0,configurable:!0}),Object.defineProperty(e,"OPEN",{get:function(){return 1},enumerable:!0,configurable:!0}),Object.defineProperty(e,"CLOSING",{get:function(){return 2},enumerable:!0,configurable:!0}),Object.defineProperty(e,"CLOSED",{get:function(){return 3},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"CONNECTING",{get:function(){return e.CONNECTING},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"OPEN",{get:function(){return e.OPEN},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"CLOSING",{get:function(){return e.CLOSING},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"CLOSED",{get:function(){return e.CLOSED},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"binaryType",{get:function(){return this._ws?this._ws.binaryType:this._binaryType},set:function(t){this._binaryType=t,this._ws&&(this._ws.binaryType=t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"retryCount",{get:function(){return Math.max(this._retryCount,0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"bufferedAmount",{get:function(){var t=this._messageQueue.reduce(function(n,r){return typeof r=="string"?n+=r.length:r instanceof Blob?n+=r.size:n+=r.byteLength,n},0);return t+(this._ws?this._ws.bufferedAmount:0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"extensions",{get:function(){return this._ws?this._ws.extensions:""},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"protocol",{get:function(){return this._ws?this._ws.protocol:""},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"readyState",{get:function(){return this._ws?this._ws.readyState:this._options.startClosed?e.CLOSED:e.CONNECTING},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"url",{get:function(){return this._ws?this._ws.url:""},enumerable:!0,configurable:!0}),e.prototype.close=function(t,n){if(t===void 0&&(t=1e3),this._closeCalled=!0,this._shouldReconnect=!1,this._clearTimeouts(),!this._ws){this._debug("close enqueued: no ws instance");return}if(this._ws.readyState===this.CLOSED){this._debug("close: already closed");return}this._ws.close(t,n)},e.prototype.reconnect=function(t,n){this._shouldReconnect=!0,this._closeCalled=!1,this._retryCount=-1,!this._ws||this._ws.readyState===this.CLOSED?this._connect():(this._disconnect(t,n),this._connect())},e.prototype.send=function(t){if(this._ws&&this._ws.readyState===this.OPEN)this._debug("send",t),this._ws.send(t);else{var n=this._options.maxEnqueuedMessages,r=n===void 0?D.maxEnqueuedMessages:n;this._messageQueue.length<r&&(this._debug("enqueue",t),this._messageQueue.push(t))}},e.prototype.addEventListener=function(t,n){this._listeners[t]&&this._listeners[t].push(n)},e.prototype.dispatchEvent=function(t){var n,r,o=this._listeners[t.type];if(o)try{for(var s=tn(o),i=s.next();!i.done;i=s.next()){var c=i.value;this._callEventListener(t,c)}}catch(a){n={error:a}}finally{try{i&&!i.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}return!0},e.prototype.removeEventListener=function(t,n){this._listeners[t]&&(this._listeners[t]=this._listeners[t].filter(function(r){return r!==n}))},e.prototype._debug=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];this._options.debug&&console.log.apply(console,rn(["RWS>"],t))},e.prototype._getNextDelay=function(){var t=this._options,n=t.reconnectionDelayGrowFactor,r=n===void 0?D.reconnectionDelayGrowFactor:n,o=t.minReconnectionDelay,s=o===void 0?D.minReconnectionDelay:o,i=t.maxReconnectionDelay,c=i===void 0?D.maxReconnectionDelay:i,a=0;return this._retryCount>0&&(a=s*Math.pow(r,this._retryCount-1),a>c&&(a=c)),this._debug("next delay",a),a},e.prototype._wait=function(){var t=this;return new Promise(function(n){setTimeout(n,t._getNextDelay())})},e.prototype._getNextUrl=function(t){if(typeof t=="string")return Promise.resolve(t);if(typeof t=="function"){var n=t();if(typeof n=="string")return Promise.resolve(n);if(n.then)return n}throw Error("Invalid URL")},e.prototype._connect=function(){var t=this;if(!(this._connectLock||!this._shouldReconnect)){this._connectLock=!0;var n=this._options,r=n.maxRetries,o=r===void 0?D.maxRetries:r,s=n.connectionTimeout,i=s===void 0?D.connectionTimeout:s,c=n.WebSocket,a=c===void 0?cn():c;if(this._retryCount>=o){this._debug("max retries reached",this._retryCount,">=",o);return}if(this._retryCount++,this._debug("connect",this._retryCount),this._removeListeners(),!un(a))throw Error("No valid WebSocket class provided");this._wait().then(function(){return t._getNextUrl(t._url)}).then(function(l){t._closeCalled||(t._debug("connect",{url:l,protocols:t._protocols}),t._ws=t._protocols?new a(l,t._protocols):new a(l),t._ws.binaryType=t._binaryType,t._connectLock=!1,t._addListeners(),t._connectTimeout=setTimeout(function(){return t._handleTimeout()},i))})}},e.prototype._handleTimeout=function(){this._debug("timeout event"),this._handleError(new on(Error("TIMEOUT"),this))},e.prototype._disconnect=function(t,n){if(t===void 0&&(t=1e3),this._clearTimeouts(),!!this._ws){this._removeListeners();try{this._ws.close(t,n),this._handleClose(new sn(t,n,this))}catch{}}},e.prototype._acceptOpen=function(){this._debug("accept open"),this._retryCount=0},e.prototype._callEventListener=function(t,n){"handleEvent"in n?n.handleEvent(t):n(t)},e.prototype._removeListeners=function(){this._ws&&(this._debug("removeListeners"),this._ws.removeEventListener("open",this._handleOpen),this._ws.removeEventListener("close",this._handleClose),this._ws.removeEventListener("message",this._handleMessage),this._ws.removeEventListener("error",this._handleError))},e.prototype._addListeners=function(){this._ws&&(this._debug("addListeners"),this._ws.addEventListener("open",this._handleOpen),this._ws.addEventListener("close",this._handleClose),this._ws.addEventListener("message",this._handleMessage),this._ws.addEventListener("error",this._handleError))},e.prototype._clearTimeouts=function(){clearTimeout(this._connectTimeout),clearTimeout(this._uptimeTimeout)},e}();const xe=12095;function Me(e){const t=typeof window<"u"?window.location:void 0,n=`/assets/${encodeURIComponent(e)}`;return`${t?.protocol}//${t?.hostname}:${xe}${n}`}async function ln(e){const t=await fetch(e);return URL.createObjectURL(new Blob([await t.arrayBuffer()]))}class hn{_items;#e=new EventTarget;constructor(t){this._items={...t}}handleDataStoreItemsMessage(t){this._items={...this._items,...t.items},Object.entries(t.items).forEach(([n,r])=>{this.dispatchEvent(new _e(n,r))}),this.dispatchEvent(new ge(t.items))}get items(){return this._items}getItem(t){return this._items[t]}setItems(t){return this._items={...this._items,...t},Object.entries(t).forEach(([n,r])=>{this.dispatchEvent(new _e(n,r))}),this.dispatchEvent(new ge(t)),this}addEventListener(t,n,r){this.#e.addEventListener(t,n,r)}removeEventListener(t,n,r){this.#e.removeEventListener(t,n,r)}dispatchEvent(t){this.#e.dispatchEvent(t)}}class _e extends Event{constructor(t,n){super("item"),this.key=t,this.value=n}_cogsConnectionEventType="item"}class ge extends Event{constructor(t){super("items"),this.items=t}_cogsConnectionEventType="item"}const q=globalThis.Date;function dn(e){const t=e-q.now();function n(...o){return o.length===0?new q(n.now()):new q(...o)}const r=Object.getOwnPropertyDescriptors(q);Object.defineProperties(n,r),n.now=function(){return q.now()+t},globalThis.Date=n}let fn=0;function pn(){return++fn}const mn=5,_n=1e4;function gn({interval:e,send:t,onChange:n=dn,syncSampleSize:r=mn,syncRequestTimeout:o=_n}){const s={};async function i(){const h=[];for(let m=0;m<r;m++){const E=new Promise(P=>{const Q=pn(),De=Date.now(),je=performance.now();t({timesync:{id:Q}});const O=(S,M)=>P({sentAt:je,receivedAt:S,serverNow:M,clientNow:De});s[Q]={complete:O},setTimeout(()=>P(null),o)});h.push(E),await E}const p=(await Promise.all(h)).filter(m=>m!==null),d=vn(p);isNaN(d)||n(Date.now()+d)}const c=h=>{const p=performance.now(),d=s[h.timesync.id];d&&d.complete(p,h.timesync.now)};i();const a=setInterval(i,e);return{receive:c,destroy:()=>{clearInterval(a)}}}function vn(e){return e.map(({sentAt:t,receivedAt:n,clientNow:r,serverNow:o})=>{const s=(n-t)/2;return o-r-s}).reduce((t,n)=>t+n,0)/e.length}class bn{constructor(t,{hostname:n=document.location.hostname,port:r=xe}={},o,s){this.manifest=t,this.currentState={...o},this.store=new hn(s??{});const{useReconnectingWebsocket:i,path:c,pathParams:a}=wn(document.location.href);this.urlParams=new URLSearchParams(a),this.urlParams.set("screenWidth",window.screen.width.toString()),this.urlParams.set("screenHeight",window.screen.height.toString()),this.urlParams.set("screenPixelRatio",window.devicePixelRatio.toString());const l=`ws://${n}:${r}${c}?${this.urlParams}`;this.websocket=i?new an(l):new WebSocket(l);let h;this.websocket.onopen=()=>{this.currentConfig={},this.currentState={},this.dispatchEvent(new Fe),this.setState(this.currentState),h=gn({interval:6e4,send:p=>{this.websocket.send(JSON.stringify(p))}})},this.websocket.addEventListener("message",({data:p})=>{try{const d=JSON.parse(p);if(typeof d=="object"&&d!==null&&"timesync"in d){const m=d;h?.receive(m)}}catch(d){console.error(d)}}),this.websocket.onclose=()=>{h?.destroy(),this.dispatchEvent(new Ke)},this.websocket.addEventListener("message",({data:p})=>{try{const d=JSON.parse(p);try{if(d.config)this.currentConfig=d.config,this.dispatchEvent(new We(this.currentConfig));else if(d.updates)this.currentState={...this.currentState,...d.updates},this.dispatchEvent(new Ge(d.updates));else if(d.event&&d.event.key)this.dispatchEvent(new Be(d.event.key,d.event.value));else if(typeof d.message=="object"){const m=d.message;switch(m.type){case"adjustable_timer_update":this._timerState={startedAt:Date.now(),durationMillis:m.durationMillis,ticking:m.ticking};break;case"show_phase":this._showPhase=m.phase,this.dispatchEvent(new He(m.phase));break;case"media_config_update":this._mediaConfig=m;for(const E of["preferOptimizedAudio","preferOptimizedVideo","preferOptimizedImages"])m[E]?this.urlParams.set(E,"true"):this.urlParams.delete(E);this.dispatchEvent(new Je(m));break;case"data_store_items":this.store.handleDataStoreItemsMessage(m);break}this.dispatchEvent(new Ve(m))}}catch(m){console.warn("Error handling data",p,m)}}catch(d){console.error("Unable to parse incoming data from server",p,d)}}),this.store.addEventListener("items",p=>{this.sendDataStoreItems(p.items)});{const p=async()=>{if(navigator.mediaDevices){const d=(await navigator.mediaDevices.enumerateDevices()).filter(({kind:m})=>m==="audiooutput");this.sendAudioOutputs(d),this.audioOutputs=d}};this.eventTarget.addEventListener("open",p),navigator.mediaDevices?.addEventListener("devicechange",p),p()}}websocket;eventTarget=new EventTarget;currentConfig={};get config(){return{...this.currentConfig}}currentState={};get state(){return{...this.currentState}}_showPhase=F.Setup;get showPhase(){return this._showPhase}_timerState=null;get timerState(){return this._timerState?{...this._timerState}:null}_mediaConfig=null;get mediaConfig(){return this._mediaConfig?{...this._mediaConfig}:null}getAssetUrl(t){return`${Me(t)}?${this.urlParams?.toString()??""}`}audioOutputs=void 0;_selectedAudioOutput="";get selectedAudioOutput(){return this._selectedAudioOutput}store;urlParams;get isConnected(){return this.websocket.readyState===WebSocket.OPEN}close(){this.websocket.close()}sendEvent(t,...[n]){this.isConnected&&this.websocket.send(JSON.stringify({event:{key:t,value:n}}))}setState(t){this.currentState={...this.currentState,...t},this.isConnected&&this.websocket.send(JSON.stringify({updates:t}))}getAudioSinkId(t){return t?this.audioOutputs?.find(({label:n})=>n===t)?.deviceId:""}sendAudioOutputs(t){this.isConnected&&this.websocket.send(JSON.stringify({audioOutputs:t}))}sendDataStoreItems(t){this.isConnected&&this.websocket.send(JSON.stringify({dataStoreItems:t}))}setPluginWindowVisible(t){this.isConnected&&this.websocket.send(JSON.stringify({window:{visible:t}}))}addEventListener(t,n,r){this.eventTarget.addEventListener(t,n,r)}removeEventListener(t,n,r){this.eventTarget.removeEventListener(t,n,r)}dispatchEvent(t){this.eventTarget.dispatchEvent(t)}}function wn(e){const t=new URL(e),n=new URLSearchParams(t.searchParams),r=n.get("local_id"),o=n.get("simulator")==="true",s=n.get("display")??"",i=t.pathname.startsWith("/plugin/")?decodeURIComponent(t.pathname.split("/")[2]):void 0;if(r){const c=n.get("t")??"";return n.delete("local_id"),{path:`/local/${encodeURIComponent(r)}`,pathParams:new URLSearchParams({t:c}),useReconnectingWebsocket:!0}}else if(o){const c=n.get("name")??"";return n.delete("simulator"),n.delete("name"),{path:`/simulator/${encodeURIComponent(c)}`,pathParams:n,useReconnectingWebsocket:!0}}else if(s){const c=n.get("displayIdIndex")??"";return n.delete("display"),n.delete("displayIdIndex"),{path:`/display/${encodeURIComponent(s)}/${encodeURIComponent(c)}`}}else{if(i)return{path:`/plugin/${encodeURIComponent(i)}`,useReconnectingWebsocket:!0};{const c=n.get("serial")??"";return n.delete("serial"),{path:`/client/${encodeURIComponent(c)}`,pathParams:n}}}}class Fe extends Event{_cogsConnectionEventType="open";constructor(){super("open")}}class Ke extends Event{_cogsConnectionEventType="close";constructor(){super("close")}}class Ve extends Event{constructor(t){super("message"),this.message=t}_cogsConnectionEventType="message"}class We extends Event{constructor(t){super("config"),this.config=t}_cogsConnectionEventType="config"}class Ge extends Event{constructor(t){super("state"),this.state=t}_cogsConnectionEventType="state"}class Be extends Event{constructor(t,n){super("event"),this.name=t,this.value=n}_cogsConnectionEventType="event"}class Je extends Event{constructor(t){super("mediaConfig"),this.mediaConfig=t}_cogsConnectionEventType="mediaConfig"}class He extends Event{constructor(t){super("showPhase"),this.showPhase=t}_cogsConnectionEventType="showPhase"}function u(e,t,n){function r(c,a){if(c._zod||Object.defineProperty(c,"_zod",{value:{def:a,constr:i,traits:new Set},enumerable:!1}),c._zod.traits.has(e))return;c._zod.traits.add(e),t(c,a);const l=i.prototype,h=Object.keys(l);for(let p=0;p<h.length;p++){const d=h[p];d in c||(c[d]=l[d].bind(c))}}const o=n?.Parent??Object;class s extends o{}Object.defineProperty(s,"name",{value:e});function i(c){var a;const l=n?.Parent?new s:this;r(l,c),(a=l._zod).deferred??(a.deferred=[]);for(const h of l._zod.deferred)h();return l}return Object.defineProperty(i,"init",{value:r}),Object.defineProperty(i,Symbol.hasInstance,{value:c=>n?.Parent&&c instanceof n.Parent?!0:c?._zod?.traits?.has(e)}),Object.defineProperty(i,"name",{value:e}),i}class K extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Ye extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const qe={};function A(e){return qe}function yn(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,o])=>t.indexOf(+r)===-1).map(([r,o])=>o)}function ve(e,t){return typeof t=="bigint"?t.toString():t}function be(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function we(e){return e==null}function ye(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function kn(e,t){const n=(e.toString().split(".")[1]||"").length,r=t.toString();let o=(r.split(".")[1]||"").length;if(o===0&&/\d?e-\d?/.test(r)){const a=r.match(/\d?e-(\d?)/);a?.[1]&&(o=Number.parseInt(a[1]))}const s=n>o?n:o,i=Number.parseInt(e.toFixed(s).replace(".","")),c=Number.parseInt(t.toFixed(s).replace(".",""));return i%c/10**s}const Xe=Symbol("evaluating");function _(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Xe)return r===void 0&&(r=Xe,r=n()),r},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function j(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function L(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function Qe(e){return JSON.stringify(e)}function En(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const et="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function ee(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const zn=be(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function V(e){if(ee(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(ee(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function tt(e){return V(e)?{...e}:Array.isArray(e)?[...e]:e}const $n=new Set(["string","number","symbol"]);function W(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function R(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function f(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new 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 Zn(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const Sn={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function On(e,t){const n=e._zod.def,r=L(e._zod.def,{get shape(){const o={};for(const s in t){if(!(s in n.shape))throw new Error(`Unrecognized key: "${s}"`);t[s]&&(o[s]=n.shape[s])}return j(this,"shape",o),o},checks:[]});return R(e,r)}function Tn(e,t){const n=e._zod.def,r=L(e._zod.def,{get shape(){const o={...e._zod.def.shape};for(const s in t){if(!(s in n.shape))throw new Error(`Unrecognized key: "${s}"`);t[s]&&delete o[s]}return j(this,"shape",o),o},checks:[]});return R(e,r)}function In(e,t){if(!V(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0)throw new Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");const o=L(e._zod.def,{get shape(){const s={...e._zod.def.shape,...t};return j(this,"shape",s),s},checks:[]});return R(e,o)}function Cn(e,t){if(!V(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n={...e._zod.def,get shape(){const r={...e._zod.def.shape,...t};return j(this,"shape",r),r},checks:e._zod.def.checks};return R(e,n)}function Pn(e,t){const n=L(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t._zod.def.shape};return j(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:[]});return R(e,n)}function An(e,t,n){const r=L(t._zod.def,{get shape(){const o=t._zod.def.shape,s={...o};if(n)for(const i in n){if(!(i in o))throw new Error(`Unrecognized key: "${i}"`);n[i]&&(s[i]=e?new e({type:"optional",innerType:o[i]}):o[i])}else for(const i in o)s[i]=e?new e({type:"optional",innerType:o[i]}):o[i];return j(this,"shape",s),s},checks:[]});return R(t,r)}function Rn(e,t,n){const r=L(t._zod.def,{get shape(){const o=t._zod.def.shape,s={...o};if(n)for(const i in n){if(!(i in s))throw new Error(`Unrecognized key: "${i}"`);n[i]&&(s[i]=new e({type:"nonoptional",innerType:o[i]}))}else for(const i in o)s[i]=new e({type:"nonoptional",innerType:o[i]});return j(this,"shape",s),s},checks:[]});return R(t,r)}function G(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 U(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function te(e){return typeof e=="string"?e:e?.message}function N(e,t,n){const r={...e,path:e.path??[]};if(!e.message){const o=te(e.inst?._zod.def?.error?.(e))??te(t?.error?.(e))??te(n.customError?.(e))??te(n.localeError?.(e))??"Invalid input";r.message=o}return delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function ke(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function X(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}const nt=(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,ve,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},rt=u("$ZodError",nt),ot=u("$ZodError",nt,{Parent:Error});function Nn(e,t=n=>n.message){const n={},r=[];for(const o of e.issues)o.path.length>0?(n[o.path[0]]=n[o.path[0]]||[],n[o.path[0]].push(t(o))):r.push(t(o));return{formErrors:r,fieldErrors:n}}function Dn(e,t=n=>n.message){const n={_errors:[]},r=o=>{for(const s of o.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(i=>r({issues:i}));else if(s.code==="invalid_key")r({issues:s.issues});else if(s.code==="invalid_element")r({issues:s.issues});else if(s.path.length===0)n._errors.push(t(s));else{let i=n,c=0;for(;c<s.path.length;){const a=s.path[c];c===s.path.length-1?(i[a]=i[a]||{_errors:[]},i[a]._errors.push(t(s))):i[a]=i[a]||{_errors:[]},i=i[a],c++}}};return r(e),n}const Ee=e=>(t,n,r,o)=>{const s=r?Object.assign(r,{async:!1}):{async:!1},i=t._zod.run({value:n,issues:[]},s);if(i instanceof Promise)throw new K;if(i.issues.length){const c=new(o?.Err??e)(i.issues.map(a=>N(a,s,A())));throw et(c,o?.callee),c}return i.value},ze=e=>async(t,n,r,o)=>{const s=r?Object.assign(r,{async:!0}):{async:!0};let i=t._zod.run({value:n,issues:[]},s);if(i instanceof Promise&&(i=await i),i.issues.length){const c=new(o?.Err??e)(i.issues.map(a=>N(a,s,A())));throw et(c,o?.callee),c}return i.value},ne=e=>(t,n,r)=>{const o=r?{...r,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},o);if(s instanceof Promise)throw new K;return s.issues.length?{success:!1,error:new(e??rt)(s.issues.map(i=>N(i,o,A())))}:{success:!0,data:s.value}},jn=ne(ot),re=e=>async(t,n,r)=>{const o=r?Object.assign(r,{async:!0}):{async:!0};let s=t._zod.run({value:n,issues:[]},o);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new e(s.issues.map(i=>N(i,o,A())))}:{success:!0,data:s.value}},Ln=re(ot),Un=e=>(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Ee(e)(t,n,o)},xn=e=>(t,n,r)=>Ee(e)(t,n,r),Mn=e=>async(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return ze(e)(t,n,o)},Fn=e=>async(t,n,r)=>ze(e)(t,n,r),Kn=e=>(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return ne(e)(t,n,o)},Vn=e=>(t,n,r)=>ne(e)(t,n,r),Wn=e=>async(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return re(e)(t,n,o)},Gn=e=>async(t,n,r)=>re(e)(t,n,r),Bn=/^[cC][^\s-]{8,}$/,Jn=/^[0-9a-z]+$/,Hn=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Yn=/^[0-9a-vA-V]{20}$/,qn=/^[A-Za-z0-9]{27}$/,Xn=/^[a-zA-Z0-9_-]{21}$/,Qn=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,er=/^([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})$/,st=e=>e?new 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)$/,tr=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,nr="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function rr(){return new RegExp(nr,"u")}const or=/^(?:(?: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])$/,sr=/^(([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}|:))$/,ir=/^((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])$/,cr=/^(([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])$/,ur=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,it=/^[A-Za-z0-9_-]*$/,ar=/^\+(?:[0-9]){6,14}[0-9]$/,ct="(?:(?:\\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])))",lr=new RegExp(`^${ct}$`);function ut(e){const 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 hr(e){return new RegExp(`^${ut(e)}$`)}function dr(e){const t=ut({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${t}(?:${n.join("|")})`;return new RegExp(`^${ct}T(?:${r})$`)}const fr=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},pr=/^-?\d+$/,mr=/^-?\d+(?:\.\d+)?/,_r=/^(?:true|false)$/i,gr=/^null$/i,vr=/^[^A-Z]*$/,br=/^[^a-z]*$/,z=u("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),at={number:"number",bigint:"bigint",object:"date"},lt=u("$ZodCheckLessThan",(e,t)=>{z.init(e,t);const n=at[typeof t.value];e._zod.onattach.push(r=>{const o=r._zod.bag,s=(t.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<s&&(t.inclusive?o.maximum=t.value:o.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:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),ht=u("$ZodCheckGreaterThan",(e,t)=>{z.init(e,t);const n=at[typeof t.value];e._zod.onattach.push(r=>{const o=r._zod.bag,s=(t.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>s&&(t.inclusive?o.minimum=t.value:o.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:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),wr=u("$ZodCheckMultipleOf",(e,t)=>{z.init(e,t),e._zod.onattach.push(n=>{var r;(r=n._zod.bag).multipleOf??(r.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%t.value===BigInt(0):kn(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})}}),yr=u("$ZodCheckNumberFormat",(e,t)=>{z.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),r=n?"int":"number",[o,s]=Sn[t.format];e._zod.onattach.push(i=>{const c=i._zod.bag;c.format=t.format,c.minimum=o,c.maximum=s,n&&(c.pattern=pr)}),e._zod.check=i=>{const c=i.value;if(n){if(!Number.isInteger(c)){i.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:c,inst:e});return}if(!Number.isSafeInteger(c)){c>0?i.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,continue:!t.abort}):i.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,continue:!t.abort});return}}c<o&&i.issues.push({origin:"number",input:c,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),c>s&&i.issues.push({origin:"number",input:c,code:"too_big",maximum:s,inst:e})}}),kr=u("$ZodCheckMaxLength",(e,t)=>{var n;z.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!we(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(r._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{const o=r.value;if(o.length<=t.maximum)return;const i=ke(o);r.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Er=u("$ZodCheckMinLength",(e,t)=>{var n;z.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!we(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(r._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{const o=r.value;if(o.length>=t.minimum)return;const i=ke(o);r.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),zr=u("$ZodCheckLengthEquals",(e,t)=>{var n;z.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!we(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),e._zod.check=r=>{const o=r.value,s=o.length;if(s===t.length)return;const i=ke(o),c=s>t.length;r.issues.push({origin:i,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),oe=u("$ZodCheckStringFormat",(e,t)=>{var n,r;z.init(e,t),e._zod.onattach.push(o=>{const s=o._zod.bag;s.format=t.format,t.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),$r=u("$ZodCheckRegex",(e,t)=>{oe.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})}}),Zr=u("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=vr),oe.init(e,t)}),Sr=u("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=br),oe.init(e,t)}),Or=u("$ZodCheckIncludes",(e,t)=>{z.init(e,t);const n=W(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(o=>{const s=o._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),Tr=u("$ZodCheckStartsWith",(e,t)=>{z.init(e,t);const n=new RegExp(`^${W(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),Ir=u("$ZodCheckEndsWith",(e,t)=>{z.init(e,t);const n=new RegExp(`.*${W(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}}),Cr=u("$ZodCheckOverwrite",(e,t)=>{z.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class Pr{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const r=t.split(`
|
|
20
20
|
`).filter(i=>i),o=Math.min(...r.map(i=>i.length-i.trimStart().length)),s=r.map(i=>i.slice(o)).map(i=>" ".repeat(this.indent*2)+i);for(const i of s)this.content.push(i)}compile(){const t=Function,n=this?.args,o=[...(this?.content??[""]).map(s=>` ${s}`)];return new t(...n,o.join(`
|
|
21
|
-
`))}}const
|
|
21
|
+
`))}}const Ar={major:4,minor:1,patch:13},g=u("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Ar;const r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(const o of r)for(const s of o._zod.onattach)s(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const o=(i,c,a)=>{let l=G(i),h;for(const p of c){if(p._zod.def.when){if(!p._zod.def.when(i))continue}else if(l)continue;const d=i.issues.length,m=p._zod.check(i);if(m instanceof Promise&&a?.async===!1)throw new K;if(h||m instanceof Promise)h=(h??Promise.resolve()).then(async()=>{await m,i.issues.length!==d&&(l||(l=G(i,d)))});else{if(i.issues.length===d)continue;l||(l=G(i,d))}}return h?h.then(()=>i):i},s=(i,c,a)=>{if(G(i))return i.aborted=!0,i;const l=o(c,r,a);if(l instanceof Promise){if(a.async===!1)throw new K;return l.then(h=>e._zod.parse(h,a))}return e._zod.parse(l,a)};e._zod.run=(i,c)=>{if(c.skipChecks)return e._zod.parse(i,c);if(c.direction==="backward"){const l=e._zod.parse({value:i.value,issues:[]},{...c,skipChecks:!0});return l instanceof Promise?l.then(h=>s(h,i,c)):s(l,i,c)}const a=e._zod.parse(i,c);if(a instanceof Promise){if(c.async===!1)throw new K;return a.then(l=>o(l,r,c))}return o(a,r,c)}}e["~standard"]={validate:o=>{try{const s=jn(e,o);return s.success?{value:s.data}:{issues:s.error?.issues}}catch{return Ln(e,o).then(i=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}}),$e=u("$ZodString",(e,t)=>{g.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??fr(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}}),v=u("$ZodStringFormat",(e,t)=>{oe.init(e,t),$e.init(e,t)}),Rr=u("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=er),v.init(e,t)}),Nr=u("$ZodUUID",(e,t)=>{if(t.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=st(r))}else t.pattern??(t.pattern=st());v.init(e,t)}),Dr=u("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=tr),v.init(e,t)}),jr=u("$ZodURL",(e,t)=>{v.init(e,t),e._zod.check=n=>{try{const r=n.value.trim(),o=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(o.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(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.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=o.href:n.value=r;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),Lr=u("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=rr()),v.init(e,t)}),Ur=u("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Xn),v.init(e,t)}),xr=u("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Bn),v.init(e,t)}),Mr=u("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Jn),v.init(e,t)}),Fr=u("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Hn),v.init(e,t)}),Kr=u("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Yn),v.init(e,t)}),Vr=u("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=qn),v.init(e,t)}),Wr=u("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=dr(t)),v.init(e,t)}),Gr=u("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=lr),v.init(e,t)}),Br=u("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=hr(t)),v.init(e,t)}),Jr=u("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Qn),v.init(e,t)}),Hr=u("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=or),v.init(e,t),e._zod.bag.format="ipv4"}),Yr=u("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=sr),v.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})}}}),qr=u("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=ir),v.init(e,t)}),Xr=u("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=cr),v.init(e,t),e._zod.check=n=>{const r=n.value.split("/");try{if(r.length!==2)throw new Error;const[o,s]=r;if(!s)throw new Error;const i=Number(s);if(`${i}`!==s)throw new Error;if(i<0||i>128)throw new Error;new URL(`http://[${o}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function dt(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const Qr=u("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=ur),v.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{dt(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function eo(e){if(!it.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return dt(n)}const to=u("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=it),v.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{eo(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),no=u("$ZodE164",(e,t)=>{t.pattern??(t.pattern=ar),v.init(e,t)});function ro(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[r]=n;if(!r)return!1;const o=JSON.parse(atob(r));return!("typ"in o&&o?.typ!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}const oo=u("$ZodJWT",(e,t)=>{v.init(e,t),e._zod.check=n=>{ro(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),ft=u("$ZodNumber",(e,t)=>{g.init(e,t),e._zod.pattern=e._zod.bag.pattern??mr,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const o=n.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return n;const s=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...s?{received:s}:{}}),n}}),so=u("$ZodNumberFormat",(e,t)=>{yr.init(e,t),ft.init(e,t)}),io=u("$ZodBoolean",(e,t)=>{g.init(e,t),e._zod.pattern=_r,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}const o=n.value;return typeof o=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),n}}),co=u("$ZodNull",(e,t)=>{g.init(e,t),e._zod.pattern=gr,e._zod.values=new Set([null]),e._zod.parse=(n,r)=>{const o=n.value;return o===null||n.issues.push({expected:"null",code:"invalid_type",input:o,inst:e}),n}}),uo=u("$ZodUnknown",(e,t)=>{g.init(e,t),e._zod.parse=n=>n}),ao=u("$ZodNever",(e,t)=>{g.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function pt(e,t,n){e.issues.length&&t.issues.push(...U(n,e.issues)),t.value[n]=e.value}const lo=u("$ZodArray",(e,t)=>{g.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;if(!Array.isArray(o))return n.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),n;n.value=Array(o.length);const s=[];for(let i=0;i<o.length;i++){const c=o[i],a=t.element._zod.run({value:c,issues:[]},r);a instanceof Promise?s.push(a.then(l=>pt(l,n,i))):pt(a,n,i)}return s.length?Promise.all(s).then(()=>n):n}});function se(e,t,n,r){e.issues.length&&t.issues.push(...U(n,e.issues)),e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}function mt(e){const t=Object.keys(e.shape);for(const r of t)if(!e.shape?.[r]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${r}": expected a Zod schema`);const n=Zn(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function _t(e,t,n,r,o,s){const i=[],c=o.keySet,a=o.catchall._zod,l=a.def.type;for(const h in t){if(c.has(h))continue;if(l==="never"){i.push(h);continue}const p=a.run({value:t[h],issues:[]},r);p instanceof Promise?e.push(p.then(d=>se(d,n,h,t))):se(p,n,h,t)}return i.length&&n.issues.push({code:"unrecognized_keys",keys:i,input:t,inst:s}),e.length?Promise.all(e).then(()=>n):n}const ho=u("$ZodObject",(e,t)=>{if(g.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){const c=t.shape;Object.defineProperty(t,"shape",{get:()=>{const a={...c};return Object.defineProperty(t,"shape",{value:a}),a}})}const r=be(()=>mt(t));_(e._zod,"propValues",()=>{const c=t.shape,a={};for(const l in c){const h=c[l]._zod;if(h.values){a[l]??(a[l]=new Set);for(const p of h.values)a[l].add(p)}}return a});const o=ee,s=t.catchall;let i;e._zod.parse=(c,a)=>{i??(i=r.value);const l=c.value;if(!o(l))return c.issues.push({expected:"object",code:"invalid_type",input:l,inst:e}),c;c.value={};const h=[],p=i.shape;for(const d of i.keys){const E=p[d]._zod.run({value:l[d],issues:[]},a);E instanceof Promise?h.push(E.then(P=>se(P,c,d,l))):se(E,c,d,l)}return s?_t(h,l,c,a,r.value,e):h.length?Promise.all(h).then(()=>c):c}}),fo=u("$ZodObjectJIT",(e,t)=>{ho.init(e,t);const n=e._zod.parse,r=be(()=>mt(t)),o=d=>{const m=new Pr(["shape","payload","ctx"]),E=r.value,P=O=>{const S=Qe(O);return`shape[${S}]._zod.run({ value: input[${S}], issues: [] }, ctx)`};m.write("const input = payload.value;");const Q=Object.create(null);let De=0;for(const O of E.keys)Q[O]=`key_${De++}`;m.write("const newResult = {};");for(const O of E.keys){const S=Q[O],M=Qe(O);m.write(`const ${S} = ${P(O)};`),m.write(`
|
|
22
22
|
if (${S}.issues.length) {
|
|
23
23
|
payload.issues = payload.issues.concat(${S}.issues.map(iss => ({
|
|
24
24
|
...iss,
|
|
25
|
-
path: iss.path ? [${
|
|
25
|
+
path: iss.path ? [${M}, ...iss.path] : [${M}]
|
|
26
26
|
})));
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
|
|
30
30
|
if (${S}.value === undefined) {
|
|
31
|
-
if (${
|
|
32
|
-
newResult[${
|
|
31
|
+
if (${M} in input) {
|
|
32
|
+
newResult[${M}] = undefined;
|
|
33
33
|
}
|
|
34
34
|
} else {
|
|
35
|
-
newResult[${
|
|
35
|
+
newResult[${M}] = ${S}.value;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
`)}m.write("payload.value = newResult;"),m.write("return payload;");const Re=m.compile();return(T,S)=>Re(d,T,S)};let s;const i=Q,c=!Be.jitless,l=c&&bn.value,h=t.catchall;let p;e._zod.parse=(d,m)=>{p??(p=r.value);const E=d.value;return i(E)?c&&l&&m?.async===!1&&m.jitless!==!0?(s||(s=o(t.shape)),d=s(d,m),h?ft([],E,d,m,p,e):d):n(d,m):(d.issues.push({expected:"object",code:"invalid_type",input:E,inst:e}),d)}});function pt(e,t,n,r){for(const s of e)if(s.issues.length===0)return t.value=s.value,t;const o=e.filter(s=>!K(s));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(s=>s.issues.map(i=>R(i,r,P())))}),t)}const io=u("$ZodUnion",(e,t)=>{g.init(e,t),_(e._zod,"optin",()=>t.options.some(o=>o._zod.optin==="optional")?"optional":void 0),_(e._zod,"optout",()=>t.options.some(o=>o._zod.optout==="optional")?"optional":void 0),_(e._zod,"values",()=>{if(t.options.every(o=>o._zod.values))return new Set(t.options.flatMap(o=>Array.from(o._zod.values)))}),_(e._zod,"pattern",()=>{if(t.options.every(o=>o._zod.pattern)){const o=t.options.map(s=>s._zod.pattern);return new RegExp(`^(${o.map(s=>ve(s.source)).join("|")})$`)}});const n=t.options.length===1,r=t.options[0]._zod.run;e._zod.parse=(o,s)=>{if(n)return r(o,s);let i=!1;const c=[];for(const a of t.options){const l=a._zod.run({value:o.value,issues:[]},s);if(l instanceof Promise)c.push(l),i=!0;else{if(l.issues.length===0)return l;c.push(l)}}return i?Promise.all(c).then(a=>pt(a,o,e,s)):pt(c,o,e,s)}}),co=u("$ZodIntersection",(e,t)=>{g.init(e,t),e._zod.parse=(n,r)=>{const o=n.value,s=t.left._zod.run({value:o,issues:[]},r),i=t.right._zod.run({value:o,issues:[]},r);return s instanceof Promise||i instanceof Promise?Promise.all([s,i]).then(([a,l])=>mt(n,a,l)):mt(n,s,i)}});function Ee(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(V(e)&&V(t)){const n=Object.keys(t),r=Object.keys(e).filter(s=>n.indexOf(s)!==-1),o={...e,...t};for(const s of r){const i=Ee(e[s],t[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};o[s]=i.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<e.length;r++){const o=e[r],s=t[r],i=Ee(o,s);if(!i.valid)return{valid:!1,mergeErrorPath:[r,...i.mergeErrorPath]};n.push(i.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function mt(e,t,n){if(t.issues.length&&e.issues.push(...t.issues),n.issues.length&&e.issues.push(...n.issues),K(e))return e;const r=Ee(t.value,n.value);if(!r.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(r.mergeErrorPath)}`);return e.value=r.data,e}const uo=u("$ZodTuple",(e,t)=>{g.init(e,t);const n=t.items;e._zod.parse=(r,o)=>{const s=r.value;if(!Array.isArray(s))return r.issues.push({input:s,inst:e,expected:"tuple",code:"invalid_type"}),r;r.value=[];const i=[],c=[...n].reverse().findIndex(h=>h._zod.optin!=="optional"),a=c===-1?0:n.length-c;if(!t.rest){const h=s.length>n.length,p=s.length<a-1;if(h||p)return r.issues.push({...h?{code:"too_big",maximum:n.length}:{code:"too_small",minimum:n.length},input:s,inst:e,origin:"array"}),r}let l=-1;for(const h of n){if(l++,l>=s.length&&l>=a)continue;const p=h._zod.run({value:s[l],issues:[]},o);p instanceof Promise?i.push(p.then(d=>se(d,r,l))):se(p,r,l)}if(t.rest){const h=s.slice(n.length);for(const p of h){l++;const d=t.rest._zod.run({value:p,issues:[]},o);d instanceof Promise?i.push(d.then(m=>se(m,r,l))):se(d,r,l)}}return i.length?Promise.all(i).then(()=>r):r}});function se(e,t,n){e.issues.length&&t.issues.push(...j(n,e.issues)),t.value[n]=e.value}const ao=u("$ZodRecord",(e,t)=>{g.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;if(!V(o))return n.issues.push({expected:"record",code:"invalid_type",input:o,inst:e}),n;const s=[],i=t.keyType._zod.values;if(i){n.value={};const c=new Set;for(const l of i)if(typeof l=="string"||typeof l=="number"||typeof l=="symbol"){c.add(typeof l=="number"?l.toString():l);const h=t.valueType._zod.run({value:o[l],issues:[]},r);h instanceof Promise?s.push(h.then(p=>{p.issues.length&&n.issues.push(...j(l,p.issues)),n.value[l]=p.value})):(h.issues.length&&n.issues.push(...j(l,h.issues)),n.value[l]=h.value)}let a;for(const l in o)c.has(l)||(a=a??[],a.push(l));a&&a.length>0&&n.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:a})}else{n.value={};for(const c of Reflect.ownKeys(o)){if(c==="__proto__")continue;const a=t.keyType._zod.run({value:c,issues:[]},r);if(a instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(a.issues.length){n.issues.push({code:"invalid_key",origin:"record",issues:a.issues.map(h=>R(h,r,P())),input:c,path:[c],inst:e}),n.value[a.value]=a.value;continue}const l=t.valueType._zod.run({value:o[c],issues:[]},r);l instanceof Promise?s.push(l.then(h=>{h.issues.length&&n.issues.push(...j(c,h.issues)),n.value[a.value]=h.value})):(l.issues.length&&n.issues.push(...j(c,l.issues)),n.value[a.value]=l.value)}}return s.length?Promise.all(s).then(()=>n):n}}),lo=u("$ZodEnum",(e,t)=>{g.init(e,t);const n=_n(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(o=>yn.has(typeof o)).map(o=>typeof o=="string"?W(o):o.toString()).join("|")})$`),e._zod.parse=(o,s)=>{const i=o.value;return r.has(i)||o.issues.push({code:"invalid_value",values:n,input:i,inst:e}),o}}),ho=u("$ZodLiteral",(e,t)=>{if(g.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");const n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map(r=>typeof r=="string"?W(r):r?W(r.toString()):String(r)).join("|")})$`),e._zod.parse=(r,o)=>{const s=r.value;return n.has(s)||r.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),r}}),fo=u("$ZodTransform",(e,t)=>{g.init(e,t),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Je(e.constructor.name);const o=t.transform(n.value,n);if(r.async)return(o instanceof Promise?o:Promise.resolve(o)).then(i=>(n.value=i,n));if(o instanceof Promise)throw new F;return n.value=o,n}});function _t(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const po=u("$ZodOptional",(e,t)=>{g.init(e,t),e._zod.optin="optional",e._zod.optout="optional",_(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),_(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${ve(n.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(t.innerType._zod.optin==="optional"){const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(s=>_t(s,n.value)):_t(o,n.value)}return n.value===void 0?n:t.innerType._zod.run(n,r)}}),mo=u("$ZodNullable",(e,t)=>{g.init(e,t),_(e._zod,"optin",()=>t.innerType._zod.optin),_(e._zod,"optout",()=>t.innerType._zod.optout),_(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${ve(n.source)}|null)$`):void 0}),_(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>n.value===null?n:t.innerType._zod.run(n,r)}),_o=u("$ZodDefault",(e,t)=>{g.init(e,t),e._zod.optin="optional",_(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);if(n.value===void 0)return n.value=t.defaultValue,n;const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(s=>gt(s,t)):gt(o,t)}});function gt(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const go=u("$ZodPrefault",(e,t)=>{g.init(e,t),e._zod.optin="optional",_(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>(r.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,r))}),vo=u("$ZodNonOptional",(e,t)=>{g.init(e,t),_(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(r=>r!==void 0)):void 0}),e._zod.parse=(n,r)=>{const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(s=>vt(s,e)):vt(o,e)}});function vt(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const bo=u("$ZodCatch",(e,t)=>{g.init(e,t),_(e._zod,"optin",()=>t.innerType._zod.optin),_(e._zod,"optout",()=>t.innerType._zod.optout),_(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(s=>(n.value=s.value,s.issues.length&&(n.value=t.catchValue({...n,error:{issues:s.issues.map(i=>R(i,r,P()))},input:n.value}),n.issues=[]),n)):(n.value=o.value,o.issues.length&&(n.value=t.catchValue({...n,error:{issues:o.issues.map(s=>R(s,r,P()))},input:n.value}),n.issues=[]),n)}}),yo=u("$ZodPipe",(e,t)=>{g.init(e,t),_(e._zod,"values",()=>t.in._zod.values),_(e._zod,"optin",()=>t.in._zod.optin),_(e._zod,"optout",()=>t.out._zod.optout),_(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){const s=t.out._zod.run(n,r);return s instanceof Promise?s.then(i=>ie(i,t.in,r)):ie(s,t.in,r)}const o=t.in._zod.run(n,r);return o instanceof Promise?o.then(s=>ie(s,t.out,r)):ie(o,t.out,r)}});function ie(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const wo=u("$ZodReadonly",(e,t)=>{g.init(e,t),_(e._zod,"propValues",()=>t.innerType._zod.propValues),_(e._zod,"values",()=>t.innerType._zod.values),_(e._zod,"optin",()=>t.innerType?._zod?.optin),_(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(bt):bt(o)}});function bt(e){return e.value=Object.freeze(e.value),e}const ko=u("$ZodCustom",(e,t)=>{z.init(e,t),g.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{const r=n.value,o=t.fn(r);if(o instanceof Promise)return o.then(s=>yt(s,n,r,e));yt(o,n,r,e)}});function yt(e,t,n,r){if(!e){const o={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(o.params=r._zod.def.params),t.issues.push(q(o))}}var wt;class Eo{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const r=n[0];if(this._map.set(t,r),r&&typeof r=="object"&&"id"in r){if(this._idmap.has(r.id))throw new Error(`ID ${r.id} already exists in the registry`);this._idmap.set(r.id,t)}return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const r={...this.get(n)??{}};delete r.id;const o={...r,...this._map.get(t)};return Object.keys(o).length?o:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function zo(){return new Eo}(wt=globalThis).__zod_globalRegistry??(wt.__zod_globalRegistry=zo());const ce=globalThis.__zod_globalRegistry;function $o(e,t){return new e({type:"string",...f(t)})}function Zo(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...f(t)})}function kt(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...f(t)})}function So(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...f(t)})}function To(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...f(t)})}function Oo(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...f(t)})}function Co(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...f(t)})}function Io(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...f(t)})}function Po(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...f(t)})}function Ao(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...f(t)})}function Ro(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...f(t)})}function No(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...f(t)})}function Do(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...f(t)})}function Lo(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...f(t)})}function jo(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...f(t)})}function Uo(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...f(t)})}function xo(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...f(t)})}function Mo(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...f(t)})}function Fo(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...f(t)})}function Vo(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...f(t)})}function Wo(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...f(t)})}function Ko(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...f(t)})}function Go(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...f(t)})}function Jo(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...f(t)})}function Bo(e,t){return new e({type:"string",format:"date",check:"string_format",...f(t)})}function Yo(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...f(t)})}function Ho(e,t){return new e({type:"string",format:"duration",check:"string_format",...f(t)})}function qo(e,t){return new e({type:"number",checks:[],...f(t)})}function Xo(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...f(t)})}function Qo(e,t){return new e({type:"null",...f(t)})}function es(e){return new e({type:"unknown"})}function ts(e,t){return new e({type:"never",...f(t)})}function Et(e,t){return new ct({check:"less_than",...f(t),value:e,inclusive:!1})}function ze(e,t){return new ct({check:"less_than",...f(t),value:e,inclusive:!0})}function zt(e,t){return new ut({check:"greater_than",...f(t),value:e,inclusive:!1})}function $e(e,t){return new ut({check:"greater_than",...f(t),value:e,inclusive:!0})}function $t(e,t){return new pr({check:"multiple_of",...f(t),value:e})}function Zt(e,t){return new _r({check:"max_length",...f(t),maximum:e})}function ue(e,t){return new gr({check:"min_length",...f(t),minimum:e})}function St(e,t){return new vr({check:"length_equals",...f(t),length:e})}function ns(e,t){return new br({check:"string_format",format:"regex",...f(t),pattern:e})}function rs(e){return new yr({check:"string_format",format:"lowercase",...f(e)})}function os(e){return new wr({check:"string_format",format:"uppercase",...f(e)})}function ss(e,t){return new kr({check:"string_format",format:"includes",...f(t),includes:e})}function is(e,t){return new Er({check:"string_format",format:"starts_with",...f(t),prefix:e})}function cs(e,t){return new zr({check:"string_format",format:"ends_with",...f(t),suffix:e})}function G(e){return new $r({check:"overwrite",tx:e})}function us(e){return G(t=>t.normalize(e))}function as(){return G(e=>e.trim())}function ls(){return G(e=>e.toLowerCase())}function hs(){return G(e=>e.toUpperCase())}function ds(){return G(e=>vn(e))}function fs(e,t,n){return new e({type:"array",element:t,...f(n)})}function ps(e,t,n){return new e({type:"custom",check:"custom",fn:t,...f(n)})}function ms(e){const t=_s(n=>(n.addIssue=r=>{if(typeof r=="string")n.issues.push(q(r,n.value,t._zod.def));else{const o=r;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=n.value),o.inst??(o.inst=t),o.continue??(o.continue=!t._zod.def.abort),n.issues.push(q(o))}},e(n.value,n)));return t}function _s(e,t){const n=new z({check:"custom",...f(t)});return n._zod.check=e,n}const gs=u("ZodISODateTime",(e,t)=>{Ur.init(e,t),k.init(e,t)});function vs(e){return Jo(gs,e)}const bs=u("ZodISODate",(e,t)=>{xr.init(e,t),k.init(e,t)});function ys(e){return Bo(bs,e)}const ws=u("ZodISOTime",(e,t)=>{Mr.init(e,t),k.init(e,t)});function ks(e){return Yo(ws,e)}const Es=u("ZodISODuration",(e,t)=>{Fr.init(e,t),k.init(e,t)});function zs(e){return Ho(Es,e)}const $=u("ZodError",(e,t)=>{et.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>In(e,n)},flatten:{value:n=>Cn(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,me,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,me,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),$s=ye($),Zs=we($),Ss=te($),Ts=ne($),Os=Rn($),Cs=Nn($),Is=Dn($),Ps=Ln($),As=jn($),Rs=Un($),Ns=xn($),Ds=Mn($),w=u("ZodType",(e,t)=>(g.init(e,t),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(L(t,{checks:[...t.checks??[],...n.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]})),e.clone=(n,r)=>A(e,n,r),e.brand=()=>e,e.register=(n,r)=>(n.add(e,r),e),e.parse=(n,r)=>$s(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>Ss(e,n,r),e.parseAsync=async(n,r)=>Zs(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>Ts(e,n,r),e.spa=e.safeParseAsync,e.encode=(n,r)=>Os(e,n,r),e.decode=(n,r)=>Cs(e,n,r),e.encodeAsync=async(n,r)=>Is(e,n,r),e.decodeAsync=async(n,r)=>Ps(e,n,r),e.safeEncode=(n,r)=>As(e,n,r),e.safeDecode=(n,r)=>Rs(e,n,r),e.safeEncodeAsync=async(n,r)=>Ns(e,n,r),e.safeDecodeAsync=async(n,r)=>Ds(e,n,r),e.refine=(n,r)=>e.check(Pi(n,r)),e.superRefine=n=>e.check(Ai(n)),e.overwrite=n=>e.check(G(n)),e.optional=()=>Rt(e),e.nullable=()=>Nt(e),e.nullish=()=>Rt(Nt(e)),e.nonoptional=n=>$i(e,n),e.array=()=>ui(e),e.or=n=>U([e,n]),e.and=n=>di(e,n),e.transform=n=>Lt(e,bi(n)),e.default=n=>ki(e,n),e.prefault=n=>zi(e,n),e.catch=n=>Si(e,n),e.pipe=n=>Lt(e,n),e.readonly=()=>Ci(e),e.describe=n=>{const r=e.clone();return ce.add(r,{description:n}),r},Object.defineProperty(e,"description",{get(){return ce.get(e)?.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return ce.get(e);const r=e.clone();return ce.add(r,n[0]),r},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),Tt=u("_ZodString",(e,t)=>{ke.init(e,t),w.init(e,t);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...r)=>e.check(ns(...r)),e.includes=(...r)=>e.check(ss(...r)),e.startsWith=(...r)=>e.check(is(...r)),e.endsWith=(...r)=>e.check(cs(...r)),e.min=(...r)=>e.check(ue(...r)),e.max=(...r)=>e.check(Zt(...r)),e.length=(...r)=>e.check(St(...r)),e.nonempty=(...r)=>e.check(ue(1,...r)),e.lowercase=r=>e.check(rs(r)),e.uppercase=r=>e.check(os(r)),e.trim=()=>e.check(as()),e.normalize=(...r)=>e.check(us(...r)),e.toLowerCase=()=>e.check(ls()),e.toUpperCase=()=>e.check(hs()),e.slugify=()=>e.check(ds())}),Ls=u("ZodString",(e,t)=>{ke.init(e,t),Tt.init(e,t),e.email=n=>e.check(Zo(js,n)),e.url=n=>e.check(Io(Us,n)),e.jwt=n=>e.check(Go(ei,n)),e.emoji=n=>e.check(Po(xs,n)),e.guid=n=>e.check(kt(Ot,n)),e.uuid=n=>e.check(So(ae,n)),e.uuidv4=n=>e.check(To(ae,n)),e.uuidv6=n=>e.check(Oo(ae,n)),e.uuidv7=n=>e.check(Co(ae,n)),e.nanoid=n=>e.check(Ao(Ms,n)),e.guid=n=>e.check(kt(Ot,n)),e.cuid=n=>e.check(Ro(Fs,n)),e.cuid2=n=>e.check(No(Vs,n)),e.ulid=n=>e.check(Do(Ws,n)),e.base64=n=>e.check(Vo(qs,n)),e.base64url=n=>e.check(Wo(Xs,n)),e.xid=n=>e.check(Lo(Ks,n)),e.ksuid=n=>e.check(jo(Gs,n)),e.ipv4=n=>e.check(Uo(Js,n)),e.ipv6=n=>e.check(xo(Bs,n)),e.cidrv4=n=>e.check(Mo(Ys,n)),e.cidrv6=n=>e.check(Fo(Hs,n)),e.e164=n=>e.check(Ko(Qs,n)),e.datetime=n=>e.check(vs(n)),e.date=n=>e.check(ys(n)),e.time=n=>e.check(ks(n)),e.duration=n=>e.check(zs(n))});function J(e){return $o(Ls,e)}const k=u("ZodStringFormat",(e,t)=>{v.init(e,t),Tt.init(e,t)}),js=u("ZodEmail",(e,t)=>{Cr.init(e,t),k.init(e,t)}),Ot=u("ZodGUID",(e,t)=>{Tr.init(e,t),k.init(e,t)}),ae=u("ZodUUID",(e,t)=>{Or.init(e,t),k.init(e,t)}),Us=u("ZodURL",(e,t)=>{Ir.init(e,t),k.init(e,t)}),xs=u("ZodEmoji",(e,t)=>{Pr.init(e,t),k.init(e,t)}),Ms=u("ZodNanoID",(e,t)=>{Ar.init(e,t),k.init(e,t)}),Fs=u("ZodCUID",(e,t)=>{Rr.init(e,t),k.init(e,t)}),Vs=u("ZodCUID2",(e,t)=>{Nr.init(e,t),k.init(e,t)}),Ws=u("ZodULID",(e,t)=>{Dr.init(e,t),k.init(e,t)}),Ks=u("ZodXID",(e,t)=>{Lr.init(e,t),k.init(e,t)}),Gs=u("ZodKSUID",(e,t)=>{jr.init(e,t),k.init(e,t)}),Js=u("ZodIPv4",(e,t)=>{Vr.init(e,t),k.init(e,t)}),Bs=u("ZodIPv6",(e,t)=>{Wr.init(e,t),k.init(e,t)}),Ys=u("ZodCIDRv4",(e,t)=>{Kr.init(e,t),k.init(e,t)}),Hs=u("ZodCIDRv6",(e,t)=>{Gr.init(e,t),k.init(e,t)}),qs=u("ZodBase64",(e,t)=>{Jr.init(e,t),k.init(e,t)}),Xs=u("ZodBase64URL",(e,t)=>{Yr.init(e,t),k.init(e,t)}),Qs=u("ZodE164",(e,t)=>{Hr.init(e,t),k.init(e,t)}),ei=u("ZodJWT",(e,t)=>{Xr.init(e,t),k.init(e,t)}),Ct=u("ZodNumber",(e,t)=>{lt.init(e,t),w.init(e,t),e.gt=(r,o)=>e.check(zt(r,o)),e.gte=(r,o)=>e.check($e(r,o)),e.min=(r,o)=>e.check($e(r,o)),e.lt=(r,o)=>e.check(Et(r,o)),e.lte=(r,o)=>e.check(ze(r,o)),e.max=(r,o)=>e.check(ze(r,o)),e.int=r=>e.check(It(r)),e.safe=r=>e.check(It(r)),e.positive=r=>e.check(zt(0,r)),e.nonnegative=r=>e.check($e(0,r)),e.negative=r=>e.check(Et(0,r)),e.nonpositive=r=>e.check(ze(0,r)),e.multipleOf=(r,o)=>e.check($t(r,o)),e.step=(r,o)=>e.check($t(r,o)),e.finite=()=>e;const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function Z(e){return qo(Ct,e)}const ti=u("ZodNumberFormat",(e,t)=>{Qr.init(e,t),Ct.init(e,t)});function It(e){return Xo(ti,e)}const ni=u("ZodNull",(e,t)=>{eo.init(e,t),w.init(e,t)});function ri(e){return Qo(ni,e)}const oi=u("ZodUnknown",(e,t)=>{to.init(e,t),w.init(e,t)});function Pt(){return es(oi)}const si=u("ZodNever",(e,t)=>{no.init(e,t),w.init(e,t)});function ii(e){return ts(si,e)}const ci=u("ZodArray",(e,t)=>{ro.init(e,t),w.init(e,t),e.element=t.element,e.min=(n,r)=>e.check(ue(n,r)),e.nonempty=n=>e.check(ue(1,n)),e.max=(n,r)=>e.check(Zt(n,r)),e.length=(n,r)=>e.check(St(n,r)),e.unwrap=()=>e.element});function ui(e,t){return fs(ci,e,t)}const ai=u("ZodObject",(e,t)=>{so.init(e,t),w.init(e,t),_(e,"shape",()=>t.shape),e.keyof=()=>_i(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Pt()}),e.loose=()=>e.clone({...e._zod.def,catchall:Pt()}),e.strict=()=>e.clone({...e._zod.def,catchall:ii()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>$n(e,n),e.safeExtend=n=>Zn(e,n),e.merge=n=>Sn(e,n),e.pick=n=>En(e,n),e.omit=n=>zn(e,n),e.partial=(...n)=>Tn(At,e,n[0]),e.required=(...n)=>On(Dt,e,n[0])});function b(e,t){const n={type:"object",shape:e??{},...f(t)};return new ai(n)}const li=u("ZodUnion",(e,t)=>{io.init(e,t),w.init(e,t),e.options=t.options});function U(e,t){return new li({type:"union",options:e,...f(t)})}const hi=u("ZodIntersection",(e,t)=>{co.init(e,t),w.init(e,t)});function di(e,t){return new hi({type:"intersection",left:e,right:t})}const fi=u("ZodTuple",(e,t)=>{uo.init(e,t),w.init(e,t),e.rest=n=>e.clone({...e._zod.def,rest:n})});function O(e,t,n){const r=t instanceof g,o=r?n:t,s=r?t:null;return new fi({type:"tuple",items:e,rest:s,...f(o)})}const pi=u("ZodRecord",(e,t)=>{ao.init(e,t),w.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType});function mi(e,t,n){return new pi({type:"record",keyType:e,valueType:t,...f(n)})}const Ze=u("ZodEnum",(e,t)=>{lo.init(e,t),w.init(e,t),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(r,o)=>{const s={};for(const i of r)if(n.has(i))s[i]=t.entries[i];else throw new Error(`Key ${i} not found in enum`);return new Ze({...t,checks:[],...f(o),entries:s})},e.exclude=(r,o)=>{const s={...t.entries};for(const i of r)if(n.has(i))delete s[i];else throw new Error(`Key ${i} not found in enum`);return new Ze({...t,checks:[],...f(o),entries:s})}});function _i(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new Ze({type:"enum",entries:n,...f(t)})}const gi=u("ZodLiteral",(e,t)=>{ho.init(e,t),w.init(e,t),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function C(e,t){return new gi({type:"literal",values:Array.isArray(e)?e:[e],...f(t)})}const vi=u("ZodTransform",(e,t)=>{fo.init(e,t),w.init(e,t),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Je(e.constructor.name);n.addIssue=s=>{if(typeof s=="string")n.issues.push(q(s,n.value,t));else{const i=s;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=n.value),i.inst??(i.inst=e),n.issues.push(q(i))}};const o=t.transform(n.value,n);return o instanceof Promise?o.then(s=>(n.value=s,n)):(n.value=o,n)}});function bi(e){return new vi({type:"transform",transform:e})}const At=u("ZodOptional",(e,t)=>{po.init(e,t),w.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Rt(e){return new At({type:"optional",innerType:e})}const yi=u("ZodNullable",(e,t)=>{mo.init(e,t),w.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Nt(e){return new yi({type:"nullable",innerType:e})}const wi=u("ZodDefault",(e,t)=>{_o.init(e,t),w.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function ki(e,t){return new wi({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Xe(t)}})}const Ei=u("ZodPrefault",(e,t)=>{go.init(e,t),w.init(e,t),e.unwrap=()=>e._zod.def.innerType});function zi(e,t){return new Ei({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Xe(t)}})}const Dt=u("ZodNonOptional",(e,t)=>{vo.init(e,t),w.init(e,t),e.unwrap=()=>e._zod.def.innerType});function $i(e,t){return new Dt({type:"nonoptional",innerType:e,...f(t)})}const Zi=u("ZodCatch",(e,t)=>{bo.init(e,t),w.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Si(e,t){return new Zi({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const Ti=u("ZodPipe",(e,t)=>{yo.init(e,t),w.init(e,t),e.in=t.in,e.out=t.out});function Lt(e,t){return new Ti({type:"pipe",in:e,out:t})}const Oi=u("ZodReadonly",(e,t)=>{wo.init(e,t),w.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Ci(e){return new Oi({type:"readonly",innerType:e})}const Ii=u("ZodCustom",(e,t)=>{ko.init(e,t),w.init(e,t)});function Pi(e,t={}){return ps(Ii,e,t)}function Ai(e){return ms(e)}const le=b({t:Z().gte(0),rate:Z().gte(0)}),B=b({opacity:Z().gte(0).lte(1),zIndex:Z().default(0)}),Y=b({volume:Z().gte(0).lte(1)}),Ri=b({type:C("image"),file:J(),fit:U([C("contain"),C("cover"),C("none")])}),Ni=b({type:C("audio"),file:J(),audioOutput:J()}),Di=b({type:C("video"),file:J(),audioOutput:J(),fit:U([C("contain"),C("cover"),C("none")])}),Se=O([Z(),ri()]),Li=O([Z(),b({set:b({...B.shape}).partial()}).partial()]),ji=O([Z(),b({set:b({...B.shape}).partial(),lerp:b({...B.shape}).partial()}).partial()]),Ui=O([Z(),b({set:b({...le.shape,...Y.shape}).partial()}).partial()]),xi=O([Z(),b({set:b({...le.shape,...Y.shape}).partial(),lerp:b({...Y.shape}).partial()}).partial()]),Mi=O([Z(),b({set:b({...le.shape,...Y.shape,...B.shape}).partial()}).partial()]),Fi=O([Z(),b({set:b({...le.shape,...Y.shape,...B.shape}).partial(),lerp:b({...Y.shape,...B.shape}).partial()}).partial()]),Vi=b({...Ri.shape,keyframes:O([ji],U([Li,Se]))}),Wi=b({...Ni.shape,keyframes:O([xi],U([Ui,Se]))}),Ki=b({...Di.shape,keyframes:O([Fi],U([Mi,Se]))}),Gi=mi(J(),U([Vi,Wi,Ki])),jt={opacity:1,zIndex:0},Te={t:0,rate:1,volume:1},Ut={t:0,rate:1,volume:1,opacity:1,zIndex:0},Ji=Object.freeze(Object.defineProperty({__proto__:null,MediaSurfaceStateSchema:Gi,defaultAudioOptions:Te,defaultImageOptions:jt,defaultVideoOptions:Ut},Symbol.toStringTag,{value:"Module"}));function he(e,t){if(!e.keyframes.filter(r=>r[1]===null).some(r=>r[0]<=t))switch(e.type){case"image":{if(e.keyframes[0][0]>t)return;const o=e.keyframes.filter(i=>i[1]!==null),s=Oe(o,t);return{...jt,...s}}case"audio":{const r=e.keyframes.filter(i=>i[1]!==null),o=xt(r,t);if(!o)return;const s=Oe(r,t);return{...Te,...s,...o}}case"video":{const r=e.keyframes.filter(i=>i[1]!==null),o=xt(r,t);if(!o)return;const s=Oe(r,t);return{...Ut,...s,...o}}}}function Oe(e,t){const n={};for(const[o,s]of e)o<=t?(Object.entries(s.lerp??{}).forEach(([i,c])=>{n[i]??={},n[i].before=[o,c]}),Object.entries(s.set??{}).forEach(([i,c])=>{n[i]??={},n[i].before=[o,c]})):Object.entries(s.lerp??{}).forEach(([i,c])=>{n[i]??={},n[i].after===void 0&&(n[i].after=[o,c])});const r={};return Object.entries(n).forEach(([o,{before:s,after:i}])=>{if(i===void 0&&s){r[o]=s[1];return}if(s&&i&&s[0]===i[0]){r[o]=i[1];return}if(s&&typeof s[1]=="number"&&i&&typeof i[1]=="number"){r[o]=s[1]+(t-s[0])*(i[1]-s[1])/(i[0]-s[0]);return}}),r}function xt(e,t){const n=e[0];if(!n||n[0]>t)return;let r=0,{t:o,rate:s}=Te;for(const[l,h]of e){if(l>t)break;const{set:p}=h;if(!p)continue;const{t:d,rate:m}=p;if(d!==void 0){r=l,o=d,m!==void 0&&(s=m);continue}if(m!==void 0){const I=(l-r)*s;r=l,o+=I,s=m}}const c=(t-r)*s,a=o+c;return{rate:s,t:a}}const Ce=e=>{try{const{pathname:t}=new URL(e,window.location.href);return t}catch{return}};class Ie{constructor(t,n,r,o,s,i){this.surfaceElement=t,this.clipElement=n,this.constructAssetURL=o,this.getAudioOutput=s,this.mediaPreloader=i,this._state=r}isConnected(t){return!(!this.surfaceElement||!this.clipElement||!this.surfaceElement.contains(this.clipElement)||t&&!this.clipElement.contains(t))}_state;setState(t){this._state=t}timeout;loop=async()=>{clearTimeout(this.timeout),this.isConnected()?(this.update(),this.timeout=setTimeout(this.loop,Wt)):this.destroy()}}function Pe(e,t,n,r,o){let s;const i=r(n.file),c=Ce(i);switch(n.type){case"image":s=e instanceof HTMLImageElement?e:document.createElement("img"),Ce(s.src)!==c&&(s.src=i);break;case"audio":case"video":{if(e!==void 0){const a=Ce(e.src);e.tagName.toLowerCase()===n.type&&a!==void 0&&a===c&&(s=e)}s||(s=o.getElement(n.file,n.type));break}}return(t.children.length!==1||t.childNodes[0]!==s)&&t.replaceChildren(s),s.style.position="absolute",s.style.width="100%",s.style.height="100%",s}function Mt(e,t,n){const r=String(t.opacity);e.style.opacity!==r&&(e.style.opacity=r);const o=Math.round(t.zIndex??0);parseInt(e.style.zIndex)!==o&&(e.style.zIndex=String(o)),e.style.objectFit!==n&&(e.style.objectFit=n)}function Ft(e,t,n,r){const o=t.volume*r;if(e.volume!==o&&(e.volume=o),e.sinkId!==n)try{e.setSinkId(n).catch(()=>{})}catch{}}const Vt=50,Bi=500,Wt=5,Kt=1e3,Yi=5,Hi=5,qi=.3,Xi=.1;function Qi(e){return Math.sign(e)*Math.pow(Math.abs(e)/Kt,qi)*Xi}function Gt(e,t,n,r,o){if(e.paused&&t.rate>0&&e.play().catch(()=>{}),e.duration){const a=n.filter(([l,h])=>l>t.t&&(h?.set?.t!==void 0||h?.set?.rate!==void 0))[0];if(a?.[1]?.set?.t===0){const l=(e.duration-t.t)/t.rate,h=a[0]-t.t,p=Math.abs(l-h)<=Hi;e.loop!==p&&(e.loop=p)}}const i=e.currentTime*1e3-t.t,c=Math.abs(i);switch(!0){case(r.state==="idle"&&t.rate>0&&c<=Vt):return e.playbackRate!==t.rate&&(e.playbackRate=t.rate),{state:"idle"};case(r.state==="idle"&&t.rate>0&&o===!0&&c<=Bi):return e.playbackRate!==t.rate&&(e.playbackRate=t.rate),{state:"idle"};case(r.state==="idle"&&o!==!0&&t.rate>0&&c>Vt&&c<=Kt):{const a=Qi(i),l=Math.max(0,t.rate-a);return e.playbackRate!==l&&(e.playbackRate=l),{state:"intercepting"}}case(r.state==="intercepting"&&t.rate>0&&c<=Wt):return e.playbackRate!==t.rate&&(e.playbackRate=t.rate),{state:"idle"};case(r.state==="intercepting"&&Math.sign(i)===Math.sign(e.playbackRate-t.rate)):return{state:"idle"};case r.state==="intercepting":return{state:"intercepting"};case r.state==="seeking":return{state:"seeking"};default:return e.playbackRate!==t.rate&&(e.playbackRate=t.rate),e.currentTime=(t.t+t.rate*Yi)/1e3,{state:"seeking"}}}class ec extends Ie{imageElement;update(){const t=he(this._state,Date.now());t?this.imageElement=Pe(this.imageElement,this.clipElement,this._state,this.constructAssetURL,this.mediaPreloader):this.imageElement&&this.destroy(),!(!t||!this.imageElement)&&Mt(this.imageElement,t,this._state.fit)}destroy(){this.imageElement&&(this.imageElement.remove(),this.imageElement.src="",this.imageElement=void 0)}}class Jt extends Ie{syncState={state:"idle"};audioElement;volume=1;update(){const t=he(this._state,Date.now());if(t?this.audioElement=Pe(this.audioElement,this.clipElement,this._state,this.constructAssetURL,this.mediaPreloader):this.destroy(),!t||!this.audioElement)return;const n=this.getAudioOutput(this._state.audioOutput);Ft(this.audioElement,t,n,this.volume);const r=Gt(this.audioElement,t,this._state.keyframes,this.syncState,this._state.disablePlaybackRateAdjustment);this.syncState.state!=="seeking"&&r.state==="seeking"&&this.audioElement.addEventListener("seeked",()=>{this.syncState={state:"idle"}},{passive:!0,once:!0}),this.syncState=r}destroy(){this.audioElement&&(this.audioElement.pause(),this.audioElement.remove(),this.audioElement.volume=0,this.audioElement.currentTime=0,this.mediaPreloader.releaseElement(this.audioElement)),this.audioElement=void 0}}class Bt extends Ie{syncState={state:"idle"};videoElement;volume=1;update(){const t=he(this._state,Date.now());if(t?this.videoElement=Pe(this.videoElement,this.clipElement,this._state,this.constructAssetURL,this.mediaPreloader):this.destroy(),!t||!this.videoElement)return;const n=this.getAudioOutput(this._state.audioOutput);Mt(this.videoElement,t,this._state.fit),Ft(this.videoElement,t,n,this.volume);const r=Gt(this.videoElement,t,this._state.keyframes,this.syncState,this._state.disablePlaybackRateAdjustment);this.syncState.state!=="seeking"&&r.state==="seeking"&&this.videoElement.addEventListener("seeked",()=>{this.syncState={state:"idle"}},{passive:!0,once:!0}),this.syncState=r}destroy(){this.videoElement&&(this.videoElement.pause(),this.videoElement.remove(),this.videoElement.volume=0,this.videoElement.currentTime=0,this.mediaPreloader.releaseElement(this.videoElement)),this.videoElement=void 0}}class Yt{_state;_elements={};_constructAssetURL;constructor(t,n={}){this._constructAssetURL=t,this._state=n}get state(){return{...this._state}}setState(t){this._state=t,this.update()}update(){for(const[t,n]of Object.entries(this._elements)){if(!(t in this._state)){if(n.inUse){console.warn(`Failed to clean up element ${n.element.src}`);continue}n.element.src="",n.element.load(),delete this._elements[t]}n.inUse=n.element.isConnected}for(const[t,n]of Object.entries(this._state)){if(t in this._elements)continue;let r;switch(n.preload===!0?r="auto":n.preload===!1?r="none":r=n.preload,n.type){case"audio":{const o=document.createElement("audio");o.src=this._constructAssetURL(t),o.preload=r,this._elements[t]={element:o,inUse:!1,type:"audio"};break}case"video":{const o=document.createElement("video");o.src=this._constructAssetURL(t),o.preload=r,this._elements[t]={element:o,inUse:!1,type:"video"};break}}}}getElement(t,n){const r=this._elements[t];if(r&&r.inUse===!1)return r.inUse=!0,r.element;{const o=document.createElement(n);return o.src=this._constructAssetURL(t),n==="video"&&(this._elements[t]={element:o,type:n,inUse:!0}),o}}releaseElement(t){if(typeof t=="string"){const n=this._elements[t];n&&(n.inUse=!1)}else Object.values(this._elements).forEach(n=>{n.element===t&&(n.inUse=!1)})}}const tc="data-clip-id";class nc{constructor(t,n,r,o=new Yt(t)){this.constructAssetUrl=t,this.getAudioOutput=n,this.mediaPreloader=o,this._element=document.createElement("div"),this._element.className="surface-manager",this._element.style.width="100%",this._element.style.height="100%",this._state=r||{},this.update()}_state={};setState(t){this._state=t,this.update()}_volume=1;get volume(){return this._volume}set volume(t){this._volume=t,Object.values(this.resources).forEach(({manager:n})=>{(n instanceof Jt||n instanceof Bt)&&(n.volume=t)})}_element;get element(){return this._element}resources={};update(){Object.entries(this.resources).forEach(([n,{element:r,manager:o}])=>{n in this._state||(delete this.resources[n],r.remove(),o?.destroy())});const t=Object.keys(this._state).toSorted().map(n=>{const r=this.resources[n];if(r)return r.element;{const o=document.createElement("div");return o.setAttribute(tc,n),this.resources[n]={element:o},o}});this._element.replaceChildren(...t),Object.keys(this._state).toSorted().forEach(n=>{const r=this._state[n],o=this.resources[n];if(!o)throw new Error("Failed to create resource");if(o.manager)o.manager.setState(r);else switch(r.type){case"image":o.manager=new ec(this._element,o.element,r,this.constructAssetUrl,this.getAudioOutput,this.mediaPreloader),o.manager.loop();break;case"audio":{const s=new Jt(this._element,o.element,r,this.constructAssetUrl,this.getAudioOutput,this.mediaPreloader);o.manager=s,s.volume=this._volume,s.loop();break}case"video":{const s=new Bt(this._element,o.element,r,this.constructAssetUrl,this.getAudioOutput,this.mediaPreloader);o.manager=s,s.volume=this._volume,s.loop();break}}})}}const rc=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));y.CogsConfigChangedEvent=Fe,y.CogsConnection=pn,y.CogsConnectionCloseEvent=xe,y.CogsConnectionOpenEvent=Ue,y.CogsIncomingEvent=We,y.CogsMediaConfigChangedEvent=Ke,y.CogsMessageEvent=Me,y.CogsShowPhaseChangedEvent=Ge,y.CogsStateChangedEvent=Ve,y.DataStoreItemEvent=fe,y.DataStoreItemsEvent=pe,y.ManifestTypes=rc,y.MediaPreloader=Yt,y.MediaSchema=Ji,y.SurfaceManager=nc,y.assetUrl=je,y.getStateAtTime=he,y.preloadUrl=on,Object.defineProperty(y,Symbol.toStringTag,{value:"Module"})});
|
|
38
|
+
`)}m.write("payload.value = newResult;"),m.write("return payload;");const je=m.compile();return(O,S)=>je(d,O,S)};let s;const i=ee,c=!qe.jitless,l=c&&zn.value,h=t.catchall;let p;e._zod.parse=(d,m)=>{p??(p=r.value);const E=d.value;return i(E)?c&&l&&m?.async===!1&&m.jitless!==!0?(s||(s=o(t.shape)),d=s(d,m),h?_t([],E,d,m,p,e):d):n(d,m):(d.issues.push({expected:"object",code:"invalid_type",input:E,inst:e}),d)}});function gt(e,t,n,r){for(const s of e)if(s.issues.length===0)return t.value=s.value,t;const o=e.filter(s=>!G(s));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(s=>s.issues.map(i=>N(i,r,A())))}),t)}const po=u("$ZodUnion",(e,t)=>{g.init(e,t),_(e._zod,"optin",()=>t.options.some(o=>o._zod.optin==="optional")?"optional":void 0),_(e._zod,"optout",()=>t.options.some(o=>o._zod.optout==="optional")?"optional":void 0),_(e._zod,"values",()=>{if(t.options.every(o=>o._zod.values))return new Set(t.options.flatMap(o=>Array.from(o._zod.values)))}),_(e._zod,"pattern",()=>{if(t.options.every(o=>o._zod.pattern)){const o=t.options.map(s=>s._zod.pattern);return new RegExp(`^(${o.map(s=>ye(s.source)).join("|")})$`)}});const n=t.options.length===1,r=t.options[0]._zod.run;e._zod.parse=(o,s)=>{if(n)return r(o,s);let i=!1;const c=[];for(const a of t.options){const l=a._zod.run({value:o.value,issues:[]},s);if(l instanceof Promise)c.push(l),i=!0;else{if(l.issues.length===0)return l;c.push(l)}}return i?Promise.all(c).then(a=>gt(a,o,e,s)):gt(c,o,e,s)}}),mo=u("$ZodIntersection",(e,t)=>{g.init(e,t),e._zod.parse=(n,r)=>{const o=n.value,s=t.left._zod.run({value:o,issues:[]},r),i=t.right._zod.run({value:o,issues:[]},r);return s instanceof Promise||i instanceof Promise?Promise.all([s,i]).then(([a,l])=>vt(n,a,l)):vt(n,s,i)}});function Ze(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(V(e)&&V(t)){const n=Object.keys(t),r=Object.keys(e).filter(s=>n.indexOf(s)!==-1),o={...e,...t};for(const s of r){const i=Ze(e[s],t[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};o[s]=i.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<e.length;r++){const o=e[r],s=t[r],i=Ze(o,s);if(!i.valid)return{valid:!1,mergeErrorPath:[r,...i.mergeErrorPath]};n.push(i.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function vt(e,t,n){if(t.issues.length&&e.issues.push(...t.issues),n.issues.length&&e.issues.push(...n.issues),G(e))return e;const r=Ze(t.value,n.value);if(!r.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(r.mergeErrorPath)}`);return e.value=r.data,e}const _o=u("$ZodTuple",(e,t)=>{g.init(e,t);const n=t.items;e._zod.parse=(r,o)=>{const s=r.value;if(!Array.isArray(s))return r.issues.push({input:s,inst:e,expected:"tuple",code:"invalid_type"}),r;r.value=[];const i=[],c=[...n].reverse().findIndex(h=>h._zod.optin!=="optional"),a=c===-1?0:n.length-c;if(!t.rest){const h=s.length>n.length,p=s.length<a-1;if(h||p)return r.issues.push({...h?{code:"too_big",maximum:n.length}:{code:"too_small",minimum:n.length},input:s,inst:e,origin:"array"}),r}let l=-1;for(const h of n){if(l++,l>=s.length&&l>=a)continue;const p=h._zod.run({value:s[l],issues:[]},o);p instanceof Promise?i.push(p.then(d=>ie(d,r,l))):ie(p,r,l)}if(t.rest){const h=s.slice(n.length);for(const p of h){l++;const d=t.rest._zod.run({value:p,issues:[]},o);d instanceof Promise?i.push(d.then(m=>ie(m,r,l))):ie(d,r,l)}}return i.length?Promise.all(i).then(()=>r):r}});function ie(e,t,n){e.issues.length&&t.issues.push(...U(n,e.issues)),t.value[n]=e.value}const go=u("$ZodRecord",(e,t)=>{g.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;if(!V(o))return n.issues.push({expected:"record",code:"invalid_type",input:o,inst:e}),n;const s=[],i=t.keyType._zod.values;if(i){n.value={};const c=new Set;for(const l of i)if(typeof l=="string"||typeof l=="number"||typeof l=="symbol"){c.add(typeof l=="number"?l.toString():l);const h=t.valueType._zod.run({value:o[l],issues:[]},r);h instanceof Promise?s.push(h.then(p=>{p.issues.length&&n.issues.push(...U(l,p.issues)),n.value[l]=p.value})):(h.issues.length&&n.issues.push(...U(l,h.issues)),n.value[l]=h.value)}let a;for(const l in o)c.has(l)||(a=a??[],a.push(l));a&&a.length>0&&n.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:a})}else{n.value={};for(const c of Reflect.ownKeys(o)){if(c==="__proto__")continue;const a=t.keyType._zod.run({value:c,issues:[]},r);if(a instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(a.issues.length){n.issues.push({code:"invalid_key",origin:"record",issues:a.issues.map(h=>N(h,r,A())),input:c,path:[c],inst:e}),n.value[a.value]=a.value;continue}const l=t.valueType._zod.run({value:o[c],issues:[]},r);l instanceof Promise?s.push(l.then(h=>{h.issues.length&&n.issues.push(...U(c,h.issues)),n.value[a.value]=h.value})):(l.issues.length&&n.issues.push(...U(c,l.issues)),n.value[a.value]=l.value)}}return s.length?Promise.all(s).then(()=>n):n}}),vo=u("$ZodEnum",(e,t)=>{g.init(e,t);const n=yn(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(o=>$n.has(typeof o)).map(o=>typeof o=="string"?W(o):o.toString()).join("|")})$`),e._zod.parse=(o,s)=>{const i=o.value;return r.has(i)||o.issues.push({code:"invalid_value",values:n,input:i,inst:e}),o}}),bo=u("$ZodLiteral",(e,t)=>{if(g.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");const n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map(r=>typeof r=="string"?W(r):r?W(r.toString()):String(r)).join("|")})$`),e._zod.parse=(r,o)=>{const s=r.value;return n.has(s)||r.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),r}}),wo=u("$ZodTransform",(e,t)=>{g.init(e,t),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Ye(e.constructor.name);const o=t.transform(n.value,n);if(r.async)return(o instanceof Promise?o:Promise.resolve(o)).then(i=>(n.value=i,n));if(o instanceof Promise)throw new K;return n.value=o,n}});function bt(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const yo=u("$ZodOptional",(e,t)=>{g.init(e,t),e._zod.optin="optional",e._zod.optout="optional",_(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),_(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${ye(n.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(t.innerType._zod.optin==="optional"){const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(s=>bt(s,n.value)):bt(o,n.value)}return n.value===void 0?n:t.innerType._zod.run(n,r)}}),ko=u("$ZodNullable",(e,t)=>{g.init(e,t),_(e._zod,"optin",()=>t.innerType._zod.optin),_(e._zod,"optout",()=>t.innerType._zod.optout),_(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${ye(n.source)}|null)$`):void 0}),_(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>n.value===null?n:t.innerType._zod.run(n,r)}),Eo=u("$ZodDefault",(e,t)=>{g.init(e,t),e._zod.optin="optional",_(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);if(n.value===void 0)return n.value=t.defaultValue,n;const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(s=>wt(s,t)):wt(o,t)}});function wt(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const zo=u("$ZodPrefault",(e,t)=>{g.init(e,t),e._zod.optin="optional",_(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>(r.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,r))}),$o=u("$ZodNonOptional",(e,t)=>{g.init(e,t),_(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(r=>r!==void 0)):void 0}),e._zod.parse=(n,r)=>{const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(s=>yt(s,e)):yt(o,e)}});function yt(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const Zo=u("$ZodCatch",(e,t)=>{g.init(e,t),_(e._zod,"optin",()=>t.innerType._zod.optin),_(e._zod,"optout",()=>t.innerType._zod.optout),_(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(s=>(n.value=s.value,s.issues.length&&(n.value=t.catchValue({...n,error:{issues:s.issues.map(i=>N(i,r,A()))},input:n.value}),n.issues=[]),n)):(n.value=o.value,o.issues.length&&(n.value=t.catchValue({...n,error:{issues:o.issues.map(s=>N(s,r,A()))},input:n.value}),n.issues=[]),n)}}),So=u("$ZodPipe",(e,t)=>{g.init(e,t),_(e._zod,"values",()=>t.in._zod.values),_(e._zod,"optin",()=>t.in._zod.optin),_(e._zod,"optout",()=>t.out._zod.optout),_(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){const s=t.out._zod.run(n,r);return s instanceof Promise?s.then(i=>ce(i,t.in,r)):ce(s,t.in,r)}const o=t.in._zod.run(n,r);return o instanceof Promise?o.then(s=>ce(s,t.out,r)):ce(o,t.out,r)}});function ce(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const Oo=u("$ZodReadonly",(e,t)=>{g.init(e,t),_(e._zod,"propValues",()=>t.innerType._zod.propValues),_(e._zod,"values",()=>t.innerType._zod.values),_(e._zod,"optin",()=>t.innerType?._zod?.optin),_(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(kt):kt(o)}});function kt(e){return e.value=Object.freeze(e.value),e}const To=u("$ZodCustom",(e,t)=>{z.init(e,t),g.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{const r=n.value,o=t.fn(r);if(o instanceof Promise)return o.then(s=>Et(s,n,r,e));Et(o,n,r,e)}});function Et(e,t,n,r){if(!e){const o={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(o.params=r._zod.def.params),t.issues.push(X(o))}}var zt;class Io{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const r=n[0];if(this._map.set(t,r),r&&typeof r=="object"&&"id"in r){if(this._idmap.has(r.id))throw new Error(`ID ${r.id} already exists in the registry`);this._idmap.set(r.id,t)}return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const r={...this.get(n)??{}};delete r.id;const o={...r,...this._map.get(t)};return Object.keys(o).length?o:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function Co(){return new Io}(zt=globalThis).__zod_globalRegistry??(zt.__zod_globalRegistry=Co());const ue=globalThis.__zod_globalRegistry;function Po(e,t){return new e({type:"string",...f(t)})}function Ao(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...f(t)})}function $t(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...f(t)})}function Ro(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...f(t)})}function No(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...f(t)})}function Do(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...f(t)})}function jo(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...f(t)})}function Lo(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...f(t)})}function Uo(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...f(t)})}function xo(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...f(t)})}function Mo(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...f(t)})}function Fo(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...f(t)})}function Ko(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...f(t)})}function Vo(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...f(t)})}function Wo(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...f(t)})}function Go(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...f(t)})}function Bo(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...f(t)})}function Jo(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...f(t)})}function Ho(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...f(t)})}function Yo(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...f(t)})}function qo(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...f(t)})}function Xo(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...f(t)})}function Qo(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...f(t)})}function es(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...f(t)})}function ts(e,t){return new e({type:"string",format:"date",check:"string_format",...f(t)})}function ns(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...f(t)})}function rs(e,t){return new e({type:"string",format:"duration",check:"string_format",...f(t)})}function os(e,t){return new e({type:"number",checks:[],...f(t)})}function ss(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...f(t)})}function is(e,t){return new e({type:"boolean",...f(t)})}function cs(e,t){return new e({type:"null",...f(t)})}function us(e){return new e({type:"unknown"})}function as(e,t){return new e({type:"never",...f(t)})}function Zt(e,t){return new lt({check:"less_than",...f(t),value:e,inclusive:!1})}function Se(e,t){return new lt({check:"less_than",...f(t),value:e,inclusive:!0})}function St(e,t){return new ht({check:"greater_than",...f(t),value:e,inclusive:!1})}function Oe(e,t){return new ht({check:"greater_than",...f(t),value:e,inclusive:!0})}function Ot(e,t){return new wr({check:"multiple_of",...f(t),value:e})}function Tt(e,t){return new kr({check:"max_length",...f(t),maximum:e})}function ae(e,t){return new Er({check:"min_length",...f(t),minimum:e})}function It(e,t){return new zr({check:"length_equals",...f(t),length:e})}function ls(e,t){return new $r({check:"string_format",format:"regex",...f(t),pattern:e})}function hs(e){return new Zr({check:"string_format",format:"lowercase",...f(e)})}function ds(e){return new Sr({check:"string_format",format:"uppercase",...f(e)})}function fs(e,t){return new Or({check:"string_format",format:"includes",...f(t),includes:e})}function ps(e,t){return new Tr({check:"string_format",format:"starts_with",...f(t),prefix:e})}function ms(e,t){return new Ir({check:"string_format",format:"ends_with",...f(t),suffix:e})}function B(e){return new Cr({check:"overwrite",tx:e})}function _s(e){return B(t=>t.normalize(e))}function gs(){return B(e=>e.trim())}function vs(){return B(e=>e.toLowerCase())}function bs(){return B(e=>e.toUpperCase())}function ws(){return B(e=>En(e))}function ys(e,t,n){return new e({type:"array",element:t,...f(n)})}function ks(e,t,n){return new e({type:"custom",check:"custom",fn:t,...f(n)})}function Es(e){const t=zs(n=>(n.addIssue=r=>{if(typeof r=="string")n.issues.push(X(r,n.value,t._zod.def));else{const o=r;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=n.value),o.inst??(o.inst=t),o.continue??(o.continue=!t._zod.def.abort),n.issues.push(X(o))}},e(n.value,n)));return t}function zs(e,t){const n=new z({check:"custom",...f(t)});return n._zod.check=e,n}const $s=u("ZodISODateTime",(e,t)=>{Wr.init(e,t),k.init(e,t)});function Zs(e){return es($s,e)}const Ss=u("ZodISODate",(e,t)=>{Gr.init(e,t),k.init(e,t)});function Os(e){return ts(Ss,e)}const Ts=u("ZodISOTime",(e,t)=>{Br.init(e,t),k.init(e,t)});function Is(e){return ns(Ts,e)}const Cs=u("ZodISODuration",(e,t)=>{Jr.init(e,t),k.init(e,t)});function Ps(e){return rs(Cs,e)}const $=u("ZodError",(e,t)=>{rt.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>Dn(e,n)},flatten:{value:n=>Nn(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,ve,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,ve,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),As=Ee($),Rs=ze($),Ns=ne($),Ds=re($),js=Un($),Ls=xn($),Us=Mn($),xs=Fn($),Ms=Kn($),Fs=Vn($),Ks=Wn($),Vs=Gn($),b=u("ZodType",(e,t)=>(g.init(e,t),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(L(t,{checks:[...t.checks??[],...n.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]})),e.clone=(n,r)=>R(e,n,r),e.brand=()=>e,e.register=(n,r)=>(n.add(e,r),e),e.parse=(n,r)=>As(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>Ns(e,n,r),e.parseAsync=async(n,r)=>Rs(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>Ds(e,n,r),e.spa=e.safeParseAsync,e.encode=(n,r)=>js(e,n,r),e.decode=(n,r)=>Ls(e,n,r),e.encodeAsync=async(n,r)=>Us(e,n,r),e.decodeAsync=async(n,r)=>xs(e,n,r),e.safeEncode=(n,r)=>Ms(e,n,r),e.safeDecode=(n,r)=>Fs(e,n,r),e.safeEncodeAsync=async(n,r)=>Ks(e,n,r),e.safeDecodeAsync=async(n,r)=>Vs(e,n,r),e.refine=(n,r)=>e.check(Mi(n,r)),e.superRefine=n=>e.check(Fi(n)),e.overwrite=n=>e.check(B(n)),e.optional=()=>Lt(e),e.nullable=()=>Ut(e),e.nullish=()=>Lt(Ut(e)),e.nonoptional=n=>Ri(e,n),e.array=()=>gi(e),e.or=n=>x([e,n]),e.and=n=>yi(e,n),e.transform=n=>Mt(e,Oi(n)),e.default=n=>Ci(e,n),e.prefault=n=>Ai(e,n),e.catch=n=>Di(e,n),e.pipe=n=>Mt(e,n),e.readonly=()=>Ui(e),e.describe=n=>{const r=e.clone();return ue.add(r,{description:n}),r},Object.defineProperty(e,"description",{get(){return ue.get(e)?.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return ue.get(e);const r=e.clone();return ue.add(r,n[0]),r},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),Ct=u("_ZodString",(e,t)=>{$e.init(e,t),b.init(e,t);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...r)=>e.check(ls(...r)),e.includes=(...r)=>e.check(fs(...r)),e.startsWith=(...r)=>e.check(ps(...r)),e.endsWith=(...r)=>e.check(ms(...r)),e.min=(...r)=>e.check(ae(...r)),e.max=(...r)=>e.check(Tt(...r)),e.length=(...r)=>e.check(It(...r)),e.nonempty=(...r)=>e.check(ae(1,...r)),e.lowercase=r=>e.check(hs(r)),e.uppercase=r=>e.check(ds(r)),e.trim=()=>e.check(gs()),e.normalize=(...r)=>e.check(_s(...r)),e.toLowerCase=()=>e.check(vs()),e.toUpperCase=()=>e.check(bs()),e.slugify=()=>e.check(ws())}),Ws=u("ZodString",(e,t)=>{$e.init(e,t),Ct.init(e,t),e.email=n=>e.check(Ao(Gs,n)),e.url=n=>e.check(Lo(Bs,n)),e.jwt=n=>e.check(Qo(ui,n)),e.emoji=n=>e.check(Uo(Js,n)),e.guid=n=>e.check($t(Pt,n)),e.uuid=n=>e.check(Ro(le,n)),e.uuidv4=n=>e.check(No(le,n)),e.uuidv6=n=>e.check(Do(le,n)),e.uuidv7=n=>e.check(jo(le,n)),e.nanoid=n=>e.check(xo(Hs,n)),e.guid=n=>e.check($t(Pt,n)),e.cuid=n=>e.check(Mo(Ys,n)),e.cuid2=n=>e.check(Fo(qs,n)),e.ulid=n=>e.check(Ko(Xs,n)),e.base64=n=>e.check(Yo(si,n)),e.base64url=n=>e.check(qo(ii,n)),e.xid=n=>e.check(Vo(Qs,n)),e.ksuid=n=>e.check(Wo(ei,n)),e.ipv4=n=>e.check(Go(ti,n)),e.ipv6=n=>e.check(Bo(ni,n)),e.cidrv4=n=>e.check(Jo(ri,n)),e.cidrv6=n=>e.check(Ho(oi,n)),e.e164=n=>e.check(Xo(ci,n)),e.datetime=n=>e.check(Zs(n)),e.date=n=>e.check(Os(n)),e.time=n=>e.check(Is(n)),e.duration=n=>e.check(Ps(n))});function J(e){return Po(Ws,e)}const k=u("ZodStringFormat",(e,t)=>{v.init(e,t),Ct.init(e,t)}),Gs=u("ZodEmail",(e,t)=>{Dr.init(e,t),k.init(e,t)}),Pt=u("ZodGUID",(e,t)=>{Rr.init(e,t),k.init(e,t)}),le=u("ZodUUID",(e,t)=>{Nr.init(e,t),k.init(e,t)}),Bs=u("ZodURL",(e,t)=>{jr.init(e,t),k.init(e,t)}),Js=u("ZodEmoji",(e,t)=>{Lr.init(e,t),k.init(e,t)}),Hs=u("ZodNanoID",(e,t)=>{Ur.init(e,t),k.init(e,t)}),Ys=u("ZodCUID",(e,t)=>{xr.init(e,t),k.init(e,t)}),qs=u("ZodCUID2",(e,t)=>{Mr.init(e,t),k.init(e,t)}),Xs=u("ZodULID",(e,t)=>{Fr.init(e,t),k.init(e,t)}),Qs=u("ZodXID",(e,t)=>{Kr.init(e,t),k.init(e,t)}),ei=u("ZodKSUID",(e,t)=>{Vr.init(e,t),k.init(e,t)}),ti=u("ZodIPv4",(e,t)=>{Hr.init(e,t),k.init(e,t)}),ni=u("ZodIPv6",(e,t)=>{Yr.init(e,t),k.init(e,t)}),ri=u("ZodCIDRv4",(e,t)=>{qr.init(e,t),k.init(e,t)}),oi=u("ZodCIDRv6",(e,t)=>{Xr.init(e,t),k.init(e,t)}),si=u("ZodBase64",(e,t)=>{Qr.init(e,t),k.init(e,t)}),ii=u("ZodBase64URL",(e,t)=>{to.init(e,t),k.init(e,t)}),ci=u("ZodE164",(e,t)=>{no.init(e,t),k.init(e,t)}),ui=u("ZodJWT",(e,t)=>{oo.init(e,t),k.init(e,t)}),At=u("ZodNumber",(e,t)=>{ft.init(e,t),b.init(e,t),e.gt=(r,o)=>e.check(St(r,o)),e.gte=(r,o)=>e.check(Oe(r,o)),e.min=(r,o)=>e.check(Oe(r,o)),e.lt=(r,o)=>e.check(Zt(r,o)),e.lte=(r,o)=>e.check(Se(r,o)),e.max=(r,o)=>e.check(Se(r,o)),e.int=r=>e.check(Rt(r)),e.safe=r=>e.check(Rt(r)),e.positive=r=>e.check(St(0,r)),e.nonnegative=r=>e.check(Oe(0,r)),e.negative=r=>e.check(Zt(0,r)),e.nonpositive=r=>e.check(Se(0,r)),e.multipleOf=(r,o)=>e.check(Ot(r,o)),e.step=(r,o)=>e.check(Ot(r,o)),e.finite=()=>e;const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function Z(e){return os(At,e)}const ai=u("ZodNumberFormat",(e,t)=>{so.init(e,t),At.init(e,t)});function Rt(e){return ss(ai,e)}const li=u("ZodBoolean",(e,t)=>{io.init(e,t),b.init(e,t)});function Nt(e){return is(li,e)}const hi=u("ZodNull",(e,t)=>{co.init(e,t),b.init(e,t)});function di(e){return cs(hi,e)}const fi=u("ZodUnknown",(e,t)=>{uo.init(e,t),b.init(e,t)});function Dt(){return us(fi)}const pi=u("ZodNever",(e,t)=>{ao.init(e,t),b.init(e,t)});function mi(e){return as(pi,e)}const _i=u("ZodArray",(e,t)=>{lo.init(e,t),b.init(e,t),e.element=t.element,e.min=(n,r)=>e.check(ae(n,r)),e.nonempty=n=>e.check(ae(1,n)),e.max=(n,r)=>e.check(Tt(n,r)),e.length=(n,r)=>e.check(It(n,r)),e.unwrap=()=>e.element});function gi(e,t){return ys(_i,e,t)}const vi=u("ZodObject",(e,t)=>{fo.init(e,t),b.init(e,t),_(e,"shape",()=>t.shape),e.keyof=()=>$i(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Dt()}),e.loose=()=>e.clone({...e._zod.def,catchall:Dt()}),e.strict=()=>e.clone({...e._zod.def,catchall:mi()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>In(e,n),e.safeExtend=n=>Cn(e,n),e.merge=n=>Pn(e,n),e.pick=n=>On(e,n),e.omit=n=>Tn(e,n),e.partial=(...n)=>An(jt,e,n[0]),e.required=(...n)=>Rn(xt,e,n[0])});function w(e,t){const n={type:"object",shape:e??{},...f(t)};return new vi(n)}const bi=u("ZodUnion",(e,t)=>{po.init(e,t),b.init(e,t),e.options=t.options});function x(e,t){return new bi({type:"union",options:e,...f(t)})}const wi=u("ZodIntersection",(e,t)=>{mo.init(e,t),b.init(e,t)});function yi(e,t){return new wi({type:"intersection",left:e,right:t})}const ki=u("ZodTuple",(e,t)=>{_o.init(e,t),b.init(e,t),e.rest=n=>e.clone({...e._zod.def,rest:n})});function T(e,t,n){const r=t instanceof g,o=r?n:t,s=r?t:null;return new ki({type:"tuple",items:e,rest:s,...f(o)})}const Ei=u("ZodRecord",(e,t)=>{go.init(e,t),b.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType});function zi(e,t,n){return new Ei({type:"record",keyType:e,valueType:t,...f(n)})}const Te=u("ZodEnum",(e,t)=>{vo.init(e,t),b.init(e,t),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(r,o)=>{const s={};for(const i of r)if(n.has(i))s[i]=t.entries[i];else throw new Error(`Key ${i} not found in enum`);return new Te({...t,checks:[],...f(o),entries:s})},e.exclude=(r,o)=>{const s={...t.entries};for(const i of r)if(n.has(i))delete s[i];else throw new Error(`Key ${i} not found in enum`);return new Te({...t,checks:[],...f(o),entries:s})}});function $i(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new Te({type:"enum",entries:n,...f(t)})}const Zi=u("ZodLiteral",(e,t)=>{bo.init(e,t),b.init(e,t),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function C(e,t){return new Zi({type:"literal",values:Array.isArray(e)?e:[e],...f(t)})}const Si=u("ZodTransform",(e,t)=>{wo.init(e,t),b.init(e,t),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Ye(e.constructor.name);n.addIssue=s=>{if(typeof s=="string")n.issues.push(X(s,n.value,t));else{const i=s;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=n.value),i.inst??(i.inst=e),n.issues.push(X(i))}};const o=t.transform(n.value,n);return o instanceof Promise?o.then(s=>(n.value=s,n)):(n.value=o,n)}});function Oi(e){return new Si({type:"transform",transform:e})}const jt=u("ZodOptional",(e,t)=>{yo.init(e,t),b.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Lt(e){return new jt({type:"optional",innerType:e})}const Ti=u("ZodNullable",(e,t)=>{ko.init(e,t),b.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Ut(e){return new Ti({type:"nullable",innerType:e})}const Ii=u("ZodDefault",(e,t)=>{Eo.init(e,t),b.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Ci(e,t){return new Ii({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():tt(t)}})}const Pi=u("ZodPrefault",(e,t)=>{zo.init(e,t),b.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Ai(e,t){return new Pi({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():tt(t)}})}const xt=u("ZodNonOptional",(e,t)=>{$o.init(e,t),b.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Ri(e,t){return new xt({type:"nonoptional",innerType:e,...f(t)})}const Ni=u("ZodCatch",(e,t)=>{Zo.init(e,t),b.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Di(e,t){return new Ni({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const ji=u("ZodPipe",(e,t)=>{So.init(e,t),b.init(e,t),e.in=t.in,e.out=t.out});function Mt(e,t){return new ji({type:"pipe",in:e,out:t})}const Li=u("ZodReadonly",(e,t)=>{Oo.init(e,t),b.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Ui(e){return new Li({type:"readonly",innerType:e})}const xi=u("ZodCustom",(e,t)=>{To.init(e,t),b.init(e,t)});function Mi(e,t={}){return ks(xi,e,t)}function Fi(e){return Es(e)}const he=w({t:Z().gte(0),rate:Z().gte(0)}),H=w({opacity:Z().gte(0).lte(1),zIndex:Z().default(0)}),Y=w({volume:Z().gte(0).lte(1)}),Ki=w({type:C("image"),file:J(),fit:x([C("contain"),C("cover"),C("none")])}),Vi=w({type:C("audio"),file:J(),audioOutput:J(),enablePlaybackRateAdjustment:Nt()}),Wi=w({type:C("video"),file:J(),audioOutput:J(),enablePlaybackRateAdjustment:Nt(),fit:x([C("contain"),C("cover"),C("none")])}),Ie=T([Z(),di()]),Gi=T([Z(),w({set:w({...H.shape}).partial()}).partial()]),Bi=T([Z(),w({set:w({...H.shape}).partial(),lerp:w({...H.shape}).partial()}).partial()]),Ji=T([Z(),w({set:w({...he.shape,...Y.shape}).partial()}).partial()]),Hi=T([Z(),w({set:w({...he.shape,...Y.shape}).partial(),lerp:w({...Y.shape}).partial()}).partial()]),Yi=T([Z(),w({set:w({...he.shape,...Y.shape,...H.shape}).partial()}).partial()]),qi=T([Z(),w({set:w({...he.shape,...Y.shape,...H.shape}).partial(),lerp:w({...Y.shape,...H.shape}).partial()}).partial()]),Xi=w({...Ki.shape,keyframes:T([Bi],x([Gi,Ie]))}),Qi=w({...Vi.shape,keyframes:T([Hi],x([Ji,Ie]))}),ec=w({...Wi.shape,keyframes:T([qi],x([Yi,Ie]))}),tc=zi(J(),x([Xi,Qi,ec])),Ft={opacity:1,zIndex:0},Ce={t:0,rate:1,volume:1},Kt={t:0,rate:1,volume:1,opacity:1,zIndex:0},nc=Object.freeze(Object.defineProperty({__proto__:null,MediaSurfaceStateSchema:tc,defaultAudioOptions:Ce,defaultImageOptions:Ft,defaultVideoOptions:Kt},Symbol.toStringTag,{value:"Module"}));function de(e,t){if(!e.keyframes.filter(r=>r[1]===null).some(r=>r[0]<=t))switch(e.type){case"image":{if(e.keyframes[0][0]>t)return;const o=e.keyframes.filter(i=>i[1]!==null),s=Pe(o,t);return{...Ft,...s}}case"audio":{const r=e.keyframes.filter(i=>i[1]!==null),o=Vt(r,t);if(!o)return;const s=Pe(r,t);return{...Ce,...s,...o}}case"video":{const r=e.keyframes.filter(i=>i[1]!==null),o=Vt(r,t);if(!o)return;const s=Pe(r,t);return{...Kt,...s,...o}}}}function Pe(e,t){const n={};for(const[o,s]of e)o<=t?(Object.entries(s.lerp??{}).forEach(([i,c])=>{n[i]??={},n[i].before=[o,c]}),Object.entries(s.set??{}).forEach(([i,c])=>{n[i]??={},n[i].before=[o,c]})):Object.entries(s.lerp??{}).forEach(([i,c])=>{n[i]??={},n[i].after===void 0&&(n[i].after=[o,c])});const r={};return Object.entries(n).forEach(([o,{before:s,after:i}])=>{if(i===void 0&&s){r[o]=s[1];return}if(s&&i&&s[0]===i[0]){r[o]=i[1];return}if(s&&typeof s[1]=="number"&&i&&typeof i[1]=="number"){r[o]=s[1]+(t-s[0])*(i[1]-s[1])/(i[0]-s[0]);return}}),r}function Vt(e,t){const n=e[0];if(!n||n[0]>t)return;let r=0,{t:o,rate:s}=Ce;for(const[l,h]of e){if(l>t)break;const{set:p}=h;if(!p)continue;const{t:d,rate:m}=p;if(d!==void 0){r=l,o=d,m!==void 0&&(s=m);continue}if(m!==void 0){const P=(l-r)*s;r=l,o+=P,s=m}}const c=(t-r)*s,a=o+c;return{rate:s,t:a}}const rc=typeof navigator<"u"&&typeof navigator.standalone<"u",oc="GestureEvent"in window;function fe(e,t){return(e%t+t)%t}function sc(e,t,n){return e=fe(e,n),t=fe(t,n),Math.abs(e-t)<n/2?e-t:e<t?e+n-t:e-(t+n)}const Ae=e=>{try{const{pathname:t}=new URL(e,window.location.href);return t}catch{return}};class Re{constructor(t,n,r,o,s,i){this.surfaceElement=t,this.clipElement=n,this.constructAssetURL=o,this.getAudioOutput=s,this.mediaPreloader=i,this._state=r}isConnected(t){return!(!this.surfaceElement||!this.clipElement||!this.surfaceElement.contains(this.clipElement)||t&&!this.clipElement.contains(t))}_state;setState(t){this._state=t}timeout;loop=async()=>{clearTimeout(this.timeout),this.isConnected()?(this.update(),this.timeout=setTimeout(this.loop,Yt)):this.destroy()}}function Ne(e,t,n,r,o){let s;const i=r(n.file),c=Ae(i);switch(n.type){case"image":s=e instanceof HTMLImageElement?e:document.createElement("img"),Ae(s.src)!==c&&(s.src=i);break;case"audio":case"video":{if(e!==void 0){const a=Ae(e.src);e.tagName.toLowerCase()===n.type&&a!==void 0&&a===c&&(s=e)}s||(s=o.getElement(n.file,n.type)),s instanceof HTMLVideoElement&&!s.playsInline&&(s.playsInline=!0);break}}return(t.children.length!==1||t.childNodes[0]!==s)&&t.replaceChildren(s),s.style.position="absolute",s.style.width="100%",s.style.height="100%",s}function Wt(e,t,n){const r=String(t.opacity);e.style.opacity!==r&&(e.style.opacity=r);const o=Math.round(t.zIndex??0);parseInt(e.style.zIndex)!==o&&(e.style.zIndex=String(o)),e.style.objectFit!==n&&(e.style.objectFit=n)}function Gt(e,t,n,r){const o=t.volume*r;if(rc)o===0&&!e.muted?e.muted=!0:o>0&&e.muted&&(e.muted=!1);else if(e.muted&&(e.muted=!1),e.volume!==o&&(e.volume=o),e.sinkId!==n)try{e.setSinkId(n).catch(()=>{})}catch{}}const Bt=2e3,ic=1e3,Jt=100,Ht=50,Yt=5,pe=1e3,cc=10,uc=5,ac=.3,lc=.1;function hc(e){return Math.sign(e)*Math.pow(Math.abs(e)/pe,ac)*lc}function I(e,t){e.playbackRate!==t&&(e.playbackRate=t),e.paused&&e.play().catch(()=>{})}function qt(e,t,n,r,o){const s=o&&!oc;let i=!1;if(e.duration){const h=n.filter(([p,d])=>p>t.t&&(d?.set?.t!==void 0||d?.set?.rate!==void 0))[0];if(h?.[1]?.set?.t===0){const p=(e.duration-t.t)/t.rate,d=h[0]-t.t;i=Math.abs(p-d)<=uc,e.loop!==i&&(e.loop=i)}}const c=e.currentTime*1e3,a=i&&e.duration!==void 0?sc(c,t.t,e.duration*1e3):c-t.t,l=Math.abs(a);switch(!0){case(!s&&r.state==="idle"&&t.rate>0&&l>Bt):{const h=(t.t+t.rate*ic)/1e3;return e.duration!==void 0&&h>e.duration&&!i?{state:"idle"}:(I(e,0),e.currentTime=i?fe(h,e.duration*1e3):h,{state:"seeking-ahead"})}case(r.state==="seeking-ahead"&&e.seeking===!0):return{state:"seeking-ahead"};case(r.state==="seeking-ahead"&&e.seeking===!1):return I(e,0),{state:"seeked-ahead"};case(r.state==="seeked-ahead"&&a<-Jt):return I(e,t.rate),console.warn("Failed to seek ahead in time"),{state:"idle"};case(r.state==="seeked-ahead"&&l<=Jt):return I(e,t.rate),{state:"idle"};case(r.state==="seeked-ahead"&&l>Bt*1.5):return console.warn("Failed to seek ahead"),{state:"idle"};case r.state==="seeked-ahead":return{state:"seeked-ahead"};case(s&&r.state==="idle"&&t.rate>0&&l>Ht&&l<=pe):{const h=hc(a),p=Math.max(0,t.rate-h);return I(e,p),{state:"intercepting"}}case(r.state==="intercepting"&&l<=Yt):return I(e,t.rate),{state:"idle"};case(r.state==="intercepting"&&Math.sign(a)===Math.sign(e.playbackRate-t.rate)):return I(e,t.rate),{state:"idle"};case(r.state==="intercepting"&&l<pe*2):return{state:"intercepting"};case r.state==="intercepting":return I(e,t.rate),{state:"idle"};case(s&&r.state==="idle"&&l>pe):{const h=(t.t+t.rate*cc)/1e3;return e.currentTime=i?fe(h,e.duration*1e3):h,I(e,t.rate),{state:"seeking"}}case(r.state==="seeking"&&e.seeking):return{state:"seeking"};case(r.state==="seeking"&&!e.seeking):return{state:"idle"};case r.state==="idle":return I(e,t.rate),t.rate===0&&l>Ht&&(e.currentTime=t.t/1e3),{state:"idle"};default:return{state:"idle"}}}class dc extends Re{imageElement;update(){const t=de(this._state,Date.now());t?this.imageElement=Ne(this.imageElement,this.clipElement,this._state,this.constructAssetURL,this.mediaPreloader):this.imageElement&&this.destroy(),!(!t||!this.imageElement)&&Wt(this.imageElement,t,this._state.fit)}destroy(){this.imageElement&&(this.imageElement.remove(),this.imageElement.src="",this.imageElement=void 0)}}class Xt extends Re{syncState={state:"idle"};audioElement;volume=1;update(){const t=de(this._state,Date.now());if(t?this.audioElement=Ne(this.audioElement,this.clipElement,this._state,this.constructAssetURL,this.mediaPreloader):this.destroy(),!t||!this.audioElement)return;const n=this.getAudioOutput(this._state.audioOutput);Gt(this.audioElement,t,n,this.volume);const r=qt(this.audioElement,t,this._state.keyframes,this.syncState,this._state.enablePlaybackRateAdjustment);this.syncState=r}destroy(){this.audioElement&&(this.audioElement.pause(),this.audioElement.remove(),this.audioElement.volume=0,this.audioElement.currentTime=0,this.mediaPreloader.releaseElement(this.audioElement)),this.audioElement=void 0}}class Qt extends Re{syncState={state:"idle"};videoElement;volume=1;update(){const t=de(this._state,Date.now());if(t?this.videoElement=Ne(this.videoElement,this.clipElement,this._state,this.constructAssetURL,this.mediaPreloader):this.destroy(),!t||!this.videoElement)return;const n=this.getAudioOutput(this._state.audioOutput);Wt(this.videoElement,t,this._state.fit),Gt(this.videoElement,t,n,this.volume);const r=qt(this.videoElement,t,this._state.keyframes,this.syncState,this._state.enablePlaybackRateAdjustment);this.syncState=r}destroy(){this.videoElement&&(this.videoElement.pause(),this.videoElement.remove(),this.videoElement.volume=0,this.videoElement.currentTime=0,this.mediaPreloader.releaseElement(this.videoElement)),this.videoElement=void 0}}class en{_state;_elements={};_constructAssetURL;constructor(t,n={}){this._constructAssetURL=t,this._state=n}get state(){return{...this._state}}setState(t){this._state=t,this.update()}update(){for(const[t,n]of Object.entries(this._elements)){if(!(t in this._state)){if(n.inUse){console.warn(`Failed to clean up element ${n.element.src}`);continue}n.element.src="",n.element.load(),delete this._elements[t]}n.inUse=n.element.isConnected}for(const[t,n]of Object.entries(this._state)){if(t in this._elements)continue;let r;switch(n.preload===!0?r="auto":n.preload===!1?r="none":r=n.preload,n.type){case"audio":{const o=document.createElement("audio");o.src=this._constructAssetURL(t),o.preload=r,this._elements[t]={element:o,inUse:!1,type:"audio"};break}case"video":{const o=document.createElement("video");o.src=this._constructAssetURL(t),o.preload=r,this._elements[t]={element:o,inUse:!1,type:"video"};break}}}}getElement(t,n){const r=this._elements[t];if(r&&r.inUse===!1)return r.inUse=!0,r.element;{const o=document.createElement(n);return o.src=this._constructAssetURL(t),n==="video"&&(this._elements[t]={element:o,type:n,inUse:!0}),o}}releaseElement(t){if(typeof t=="string"){const n=this._elements[t];n&&(n.inUse=!1)}else Object.values(this._elements).forEach(n=>{n.element===t&&(n.inUse=!1)})}}const fc="data-clip-id";class pc{constructor(t,n,r,o=new en(t)){this.constructAssetUrl=t,this.getAudioOutput=n,this.mediaPreloader=o,this._element=document.createElement("div"),this._element.className="surface-manager",this._element.style.width="100%",this._element.style.height="100%",this._state=r||{},this.update()}_state={};setState(t){this._state=t,this.update()}_volume=1;get volume(){return this._volume}set volume(t){this._volume=t,Object.values(this.resources).forEach(({manager:n})=>{(n instanceof Xt||n instanceof Qt)&&(n.volume=t)})}_element;get element(){return this._element}resources={};update(){Object.entries(this.resources).forEach(([n,{element:r,manager:o}])=>{n in this._state||(delete this.resources[n],r.remove(),o?.destroy())});const t=Object.keys(this._state).toSorted().map(n=>{const r=this.resources[n];if(r)return r.element;{const o=document.createElement("div");return o.setAttribute(fc,n),this.resources[n]={element:o},o}});this._element.replaceChildren(...t),Object.keys(this._state).toSorted().forEach(n=>{const r=this._state[n],o=this.resources[n];if(!o)throw new Error("Failed to create resource");if(o.manager)o.manager.setState(r);else switch(r.type){case"image":o.manager=new dc(this._element,o.element,r,this.constructAssetUrl,this.getAudioOutput,this.mediaPreloader),o.manager.loop();break;case"audio":{const s=new Xt(this._element,o.element,r,this.constructAssetUrl,this.getAudioOutput,this.mediaPreloader);o.manager=s,s.volume=this._volume,s.loop();break}case"video":{const s=new Qt(this._element,o.element,r,this.constructAssetUrl,this.getAudioOutput,this.mediaPreloader);o.manager=s,s.volume=this._volume,s.loop();break}}})}}const mc=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));y.CogsConfigChangedEvent=We,y.CogsConnection=bn,y.CogsConnectionCloseEvent=Ke,y.CogsConnectionOpenEvent=Fe,y.CogsIncomingEvent=Be,y.CogsMediaConfigChangedEvent=Je,y.CogsMessageEvent=Ve,y.CogsShowPhaseChangedEvent=He,y.CogsStateChangedEvent=Ge,y.DataStoreItemEvent=_e,y.DataStoreItemsEvent=ge,y.ManifestTypes=mc,y.MediaPreloader=en,y.MediaSchema=nc,y.SurfaceManager=pc,y.assetUrl=Me,y.getStateAtTime=de,y.preloadUrl=ln,Object.defineProperty(y,Symbol.toStringTag,{value:"Module"})});
|
|
@@ -37,14 +37,13 @@ export declare function assertVisualProperties(mediaElement: HTMLMediaElement |
|
|
|
37
37
|
*/
|
|
38
38
|
export declare function assertAudialProperties(mediaElement: HTMLMediaElement, properties: AudialProperties, sinkId: string, surfaceVolume: number): void;
|
|
39
39
|
interface TemporalSyncState {
|
|
40
|
-
state: 'idle' | 'seeking' | 'intercepting';
|
|
40
|
+
state: 'idle' | 'seeking' | 'intercepting' | 'seeking-ahead' | 'seeked-ahead';
|
|
41
41
|
}
|
|
42
42
|
/**
|
|
43
43
|
* Makes sure the media is at the correct time and speed.
|
|
44
|
-
* -
|
|
45
|
-
* - If we are too far away to smoothly realign, we will seek to the correct time.
|
|
44
|
+
* - Algorithms and constants defined above
|
|
46
45
|
*/
|
|
47
|
-
export declare function assertTemporalProperties(mediaElement: HTMLMediaElement, properties: TemporalProperties, keyframes: VideoState['keyframes'], syncState: TemporalSyncState,
|
|
46
|
+
export declare function assertTemporalProperties(mediaElement: HTMLMediaElement, properties: TemporalProperties, keyframes: VideoState['keyframes'], syncState: TemporalSyncState, enablePlaybackRateAdjustment: boolean): TemporalSyncState;
|
|
48
47
|
export declare class ImageManager extends MediaClipManager<ImageState> {
|
|
49
48
|
private imageElement;
|
|
50
49
|
protected update(): void;
|